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; \