diff --git a/Makefile b/Makefile index d74c55a..a10744e 100644 --- a/Makefile +++ b/Makefile @@ -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; \ diff --git a/bin/Makefile b/bin/Makefile index 04f38f2..1193e5f 100644 --- a/bin/Makefile +++ b/bin/Makefile @@ -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 diff --git a/lib/Makefile b/lib/Makefile index 8698163..1035742 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -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