Check PostgreSQL version number as number in the makefile
Not entirely happy about the solution but I like the uniform tests.
This commit is contained in:
parent
22762fce28
commit
c314cbda75
12
Makefile
12
Makefile
@ -6,18 +6,18 @@
|
|||||||
# Portions Copyright (c) 2012, The Reorg Development Team
|
# Portions Copyright (c) 2012, The Reorg Development Team
|
||||||
#
|
#
|
||||||
|
|
||||||
USE_PGXS = 1
|
PG_CONFIG ?= pg_config
|
||||||
PG_CONFIG = pg_config
|
|
||||||
PGXS := $(shell $(PG_CONFIG) --pgxs)
|
|
||||||
include $(PGXS)
|
|
||||||
|
|
||||||
SUBDIRS = bin lib
|
SUBDIRS = bin lib
|
||||||
|
|
||||||
# Pull out the version number from pg_config
|
# Pull out the version number from pg_config
|
||||||
VERSION = $(shell $(PG_CONFIG) --version | awk '{print $$2}')
|
VERSION := $(shell $(PG_CONFIG) --version | awk '{print $$2}')
|
||||||
|
|
||||||
|
# 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)
|
||||||
|
|
||||||
# We support PostgreSQL 8.3 and later.
|
# We support PostgreSQL 8.3 and later.
|
||||||
ifneq ($(shell echo $(VERSION) | grep -E "^7\.|^8\.[012]"),)
|
ifeq ($(shell echo $$(($(INTVERSION) < 80300))),1)
|
||||||
$(error pg_repack requires PostgreSQL 8.3 or later. This is $(VERSION))
|
$(error pg_repack requires PostgreSQL 8.3 or later. This is $(VERSION))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
38
bin/Makefile
38
bin/Makefile
@ -5,12 +5,24 @@
|
|||||||
# Portions Copyright (c) 2011, Itagaki Takahiro
|
# Portions Copyright (c) 2011, Itagaki Takahiro
|
||||||
# Portions Copyright (c) 2012, The Reorg Development Team
|
# Portions Copyright (c) 2012, The Reorg Development Team
|
||||||
#
|
#
|
||||||
|
|
||||||
|
PG_CONFIG ?= pg_config
|
||||||
|
|
||||||
|
# version as a number, e.g. 9.1.4 -> 90104
|
||||||
|
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)
|
||||||
|
|
||||||
SRCS = pg_repack.c pgut/pgut.c pgut/pgut-fe.c
|
SRCS = pg_repack.c pgut/pgut.c pgut/pgut-fe.c
|
||||||
OBJS = $(SRCS:.c=.o)
|
OBJS = $(SRCS:.c=.o)
|
||||||
PROGRAM = pg_repack
|
PROGRAM = pg_repack
|
||||||
REGRESS = init repack tablespace
|
|
||||||
|
|
||||||
EXTRA_CLEAN = sql/init-$(MAJORVERSION).sql sql/init.sql
|
ifeq ($(shell echo $$(($(INTVERSION) >= 90100))),1)
|
||||||
|
REGRESS = init-extension
|
||||||
|
else
|
||||||
|
REGRESS = init-legacy
|
||||||
|
endif
|
||||||
|
|
||||||
|
REGRESS += repack tablespace
|
||||||
|
|
||||||
# The version number of the program. It should be the same of the library.
|
# The version number of the program. It should be the same of the library.
|
||||||
REPACK_VERSION = $(shell grep '"version":' ../META.json | head -1 \
|
REPACK_VERSION = $(shell grep '"version":' ../META.json | head -1 \
|
||||||
@ -33,25 +45,3 @@ include $(PGXS)
|
|||||||
LIBS := $(filter-out -lxml2, $(LIBS))
|
LIBS := $(filter-out -lxml2, $(LIBS))
|
||||||
LIBS := $(filter-out -lxslt, $(LIBS))
|
LIBS := $(filter-out -lxslt, $(LIBS))
|
||||||
|
|
||||||
ifndef MAJORVERSION
|
|
||||||
MAJORVERSION := $(basename $(VERSION))
|
|
||||||
endif
|
|
||||||
|
|
||||||
sql/init.sql: sql/init-$(MAJORVERSION).sql
|
|
||||||
cp sql/init-$(MAJORVERSION).sql sql/init.sql
|
|
||||||
expected/init.out: expected/init-$(MAJORVERSION).out
|
|
||||||
cp expected/init-$(MAJORVERSION).out expected/init.out
|
|
||||||
sql/init-8.3.sql:
|
|
||||||
cp sql/init-legacy.sql sql/init-8.3.sql
|
|
||||||
sql/init-8.4.sql:
|
|
||||||
cp sql/init-legacy.sql sql/init-8.4.sql
|
|
||||||
sql/init-9.0.sql:
|
|
||||||
cp sql/init-legacy.sql sql/init-9.0.sql
|
|
||||||
sql/init-9.1.sql:
|
|
||||||
cp sql/init-extension.sql sql/init-9.1.sql
|
|
||||||
sql/init-9.2.sql:
|
|
||||||
cp sql/init-extension.sql sql/init-9.2.sql
|
|
||||||
sql/init-9.3.sql:
|
|
||||||
cp sql/init-extension.sql sql/init-9.3.sql
|
|
||||||
|
|
||||||
installcheck: sql/init.sql
|
|
||||||
|
3
bin/expected/init-extension.out
Normal file
3
bin/expected/init-extension.out
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
SET client_min_messages = warning;
|
||||||
|
CREATE EXTENSION pg_repack;
|
||||||
|
RESET client_min_messages;
|
@ -1,5 +1,3 @@
|
|||||||
SET client_min_messages = warning;
|
SET client_min_messages = warning;
|
||||||
\set ECHO none
|
|
||||||
CREATE EXTENSION pg_repack;
|
CREATE EXTENSION pg_repack;
|
||||||
\set ECHO all
|
|
||||||
RESET client_min_messages;
|
RESET client_min_messages;
|
||||||
|
11
lib/Makefile
11
lib/Makefile
@ -6,7 +6,11 @@
|
|||||||
# Portions Copyright (c) 2012, The Reorg Development Team
|
# Portions Copyright (c) 2012, The Reorg Development Team
|
||||||
#
|
#
|
||||||
|
|
||||||
PG_CONFIG = pg_config
|
PG_CONFIG ?= pg_config
|
||||||
|
|
||||||
|
# version as a number, e.g. 9.1.4 -> 90104
|
||||||
|
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)
|
||||||
|
|
||||||
EXTENSION = pg_repack
|
EXTENSION = pg_repack
|
||||||
MODULE_big = $(EXTENSION)
|
MODULE_big = $(EXTENSION)
|
||||||
@ -20,10 +24,7 @@ REPACK_VERSION = $(shell grep '"version":' ../META.json | head -1 \
|
|||||||
PG_CPPFLAGS = -DREPACK_VERSION=$(REPACK_VERSION)
|
PG_CPPFLAGS = -DREPACK_VERSION=$(REPACK_VERSION)
|
||||||
|
|
||||||
# Support CREATE EXTENSION for PG >= 9.1 and a simple sql script for PG < 9.1
|
# Support CREATE EXTENSION for PG >= 9.1 and a simple sql script for PG < 9.1
|
||||||
HAVE_EXTENSION = $(shell $(PG_CONFIG) --version \
|
ifeq ($(shell echo $$(($(INTVERSION) >= 90100))),1)
|
||||||
| grep -qE " 8\.| 9\.0" && echo no || echo yes)
|
|
||||||
|
|
||||||
ifeq ($(HAVE_EXTENSION),yes)
|
|
||||||
DATA_built = pg_repack--$(REPACK_VERSION).sql pg_repack.control
|
DATA_built = pg_repack--$(REPACK_VERSION).sql pg_repack.control
|
||||||
else
|
else
|
||||||
DATA_built = pg_repack.sql
|
DATA_built = pg_repack.sql
|
||||||
|
Loading…
x
Reference in New Issue
Block a user