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.
This commit is contained in:
Daniele Varrazzo 2013-04-18 01:10:22 +01:00
parent dd06f25930
commit 14c4d4653e
3 changed files with 16 additions and 13 deletions

View File

@ -8,20 +8,23 @@
PG_CONFIG ?= pg_config
SUBDIRS = bin lib
# Pull out the version number from pg_config
VERSION := $(shell $(PG_CONFIG) --version | awk '{print $$2}')
ifeq ("$(VERSION)","")
$(error pg_config not found)
endif
# version as a number, e.g. 9.1.4 -> 90104
INTVERSION := $(shell echo $(VERSION) | sed -E 's/([0-9]+)\.([0-9]+)\.?([0-9]+)?(.*)/(\1*100+\2)*100+0\3/' | bc)
# version as a number, e.g. 9.1.4 -> 901
INTVERSION := $(shell echo $$(($$(echo $(VERSION) | sed -E 's/([0-9]+)\.([0-9]+).*/\1*100+\2/'))))
# We support PostgreSQL 8.3 and later.
ifeq ($(shell echo $$(($(INTVERSION) < 80300))),1)
ifeq ($(shell echo $$(($(INTVERSION) < 803))),1)
$(error pg_repack requires PostgreSQL 8.3 or later. This is $(VERSION))
endif
SUBDIRS = bin lib
all install installdirs uninstall distprep clean distclean maintainer-clean debug:
@for dir in $(SUBDIRS); do \
$(MAKE) -C $$dir $@ || exit; \

View File

@ -8,9 +8,9 @@
PG_CONFIG ?= pg_config
# version as a number, e.g. 9.1.4 -> 90104
# version as a number, e.g. 9.1.4 -> 901
VERSION := $(shell $(PG_CONFIG) --version | awk '{print $$2}')
INTVERSION := $(shell echo $(VERSION) | sed -E 's/([0-9]+)\.([0-9]+)\.?([0-9]+)?.*/(\1*100+\2)*100+0\3/' | bc)
INTVERSION := $(shell echo $$(($$(echo $(VERSION) | sed -E 's/([0-9]+)\.([0-9]+).*/\1*100+\2/'))))
SRCS = pg_repack.c pgut/pgut.c pgut/pgut-fe.c
OBJS = $(SRCS:.c=.o)
@ -21,7 +21,7 @@ PROGRAM = pg_repack
# Test suite
#
ifeq ($(shell echo $$(($(INTVERSION) >= 90100))),1)
ifeq ($(shell echo $$(($(INTVERSION) >= 901))),1)
REGRESS = init-extension
else
REGRESS = init-legacy
@ -29,8 +29,8 @@ endif
REGRESS += repack tablespace
# This test depends on collate, not supported before 9.0
ifeq ($(shell echo $$(($(INTVERSION) >= 90000))),1)
# This test depends on collate, not supported before 9.1
ifeq ($(shell echo $$(($(INTVERSION) >= 901))),1)
REGRESS += issue3
endif

View File

@ -8,9 +8,9 @@
PG_CONFIG ?= pg_config
# version as a number, e.g. 9.1.4 -> 90104
# version as a number, e.g. 9.1.4 -> 901
VERSION := $(shell $(PG_CONFIG) --version | awk '{print $$2}')
INTVERSION := $(shell echo $(VERSION) | sed -E 's/([0-9]+)\.([0-9]+)\.?([0-9]+)?.*/(\1*100+\2)*100+0\3/' | bc)
INTVERSION := $(shell echo $$(($$(echo $(VERSION) | sed -E 's/([0-9]+)\.([0-9]+).*/\1*100+\2/'))))
EXTENSION = pg_repack
MODULE_big = $(EXTENSION)
@ -24,7 +24,7 @@ REPACK_VERSION = $(shell grep '"version":' ../META.json | head -1 \
PG_CPPFLAGS = -DREPACK_VERSION=$(REPACK_VERSION)
# Support CREATE EXTENSION for PG >= 9.1 and a simple sql script for PG < 9.1
ifeq ($(shell echo $$(($(INTVERSION) >= 90100))),1)
ifeq ($(shell echo $$(($(INTVERSION) >= 901))),1)
DATA_built = pg_repack--$(REPACK_VERSION).sql pg_repack.control
else
DATA_built = pg_repack.sql