Skip to content

Commit 14c4d46

Browse files
committed
Make the version number arith without using bc
Not as available as I thought. Can't use the 0 prefix to make the 3rd number optional as $(()) parses is as octal, so only use the first 2 numbers. Also fixed collate test: not available on PG 9.0.
1 parent dd06f25 commit 14c4d46

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

Makefile

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,23 @@
88

99
PG_CONFIG ?= pg_config
1010

11-
SUBDIRS = bin lib
12-
1311
# Pull out the version number from pg_config
1412
VERSION := $(shell $(PG_CONFIG) --version | awk '{print $$2}')
13+
ifeq ("$(VERSION)","")
14+
$(error pg_config not found)
15+
endif
1516

16-
# version as a number, e.g. 9.1.4 -> 90104
17-
INTVERSION := $(shell echo $(VERSION) | sed -E 's/([0-9]+)\.([0-9]+)\.?([0-9]+)?(.*)/(\1*100+\2)*100+0\3/' | bc)
17+
# version as a number, e.g. 9.1.4 -> 901
18+
INTVERSION := $(shell echo $$(($$(echo $(VERSION) | sed -E 's/([0-9]+)\.([0-9]+).*/\1*100+\2/'))))
1819

1920
# We support PostgreSQL 8.3 and later.
20-
ifeq ($(shell echo $$(($(INTVERSION) < 80300))),1)
21+
ifeq ($(shell echo $$(($(INTVERSION) < 803))),1)
2122
$(error pg_repack requires PostgreSQL 8.3 or later. This is $(VERSION))
2223
endif
2324

2425

26+
SUBDIRS = bin lib
27+
2528
all install installdirs uninstall distprep clean distclean maintainer-clean debug:
2629
@for dir in $(SUBDIRS); do \
2730
$(MAKE) -C $$dir $@ || exit; \

bin/Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
PG_CONFIG ?= pg_config
1010

11-
# version as a number, e.g. 9.1.4 -> 90104
11+
# version as a number, e.g. 9.1.4 -> 901
1212
VERSION := $(shell $(PG_CONFIG) --version | awk '{print $$2}')
13-
INTVERSION := $(shell echo $(VERSION) | sed -E 's/([0-9]+)\.([0-9]+)\.?([0-9]+)?.*/(\1*100+\2)*100+0\3/' | bc)
13+
INTVERSION := $(shell echo $$(($$(echo $(VERSION) | sed -E 's/([0-9]+)\.([0-9]+).*/\1*100+\2/'))))
1414

1515
SRCS = pg_repack.c pgut/pgut.c pgut/pgut-fe.c
1616
OBJS = $(SRCS:.c=.o)
@@ -21,16 +21,16 @@ PROGRAM = pg_repack
2121
# Test suite
2222
#
2323

24-
ifeq ($(shell echo $$(($(INTVERSION) >= 90100))),1)
24+
ifeq ($(shell echo $$(($(INTVERSION) >= 901))),1)
2525
REGRESS = init-extension
2626
else
2727
REGRESS = init-legacy
2828
endif
2929

3030
REGRESS += repack tablespace
3131

32-
# This test depends on collate, not supported before 9.0
33-
ifeq ($(shell echo $$(($(INTVERSION) >= 90000))),1)
32+
# This test depends on collate, not supported before 9.1
33+
ifeq ($(shell echo $$(($(INTVERSION) >= 901))),1)
3434
REGRESS += issue3
3535
endif
3636

lib/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
PG_CONFIG ?= pg_config
1010

11-
# version as a number, e.g. 9.1.4 -> 90104
11+
# version as a number, e.g. 9.1.4 -> 901
1212
VERSION := $(shell $(PG_CONFIG) --version | awk '{print $$2}')
13-
INTVERSION := $(shell echo $(VERSION) | sed -E 's/([0-9]+)\.([0-9]+)\.?([0-9]+)?.*/(\1*100+\2)*100+0\3/' | bc)
13+
INTVERSION := $(shell echo $$(($$(echo $(VERSION) | sed -E 's/([0-9]+)\.([0-9]+).*/\1*100+\2/'))))
1414

1515
EXTENSION = pg_repack
1616
MODULE_big = $(EXTENSION)
@@ -24,7 +24,7 @@ REPACK_VERSION = $(shell grep '"version":' ../META.json | head -1 \
2424
PG_CPPFLAGS = -DREPACK_VERSION=$(REPACK_VERSION)
2525

2626
# Support CREATE EXTENSION for PG >= 9.1 and a simple sql script for PG < 9.1
27-
ifeq ($(shell echo $$(($(INTVERSION) >= 90100))),1)
27+
ifeq ($(shell echo $$(($(INTVERSION) >= 901))),1)
2828
DATA_built = pg_repack--$(REPACK_VERSION).sql pg_repack.control
2929
else
3030
DATA_built = pg_repack.sql

0 commit comments

Comments
 (0)