Skip to content

Commit e787c91

Browse files
committed
Fix makefiles to make pg_repack buildable as contrib
1 parent b031812 commit e787c91

File tree

4 files changed

+48
-56
lines changed

4 files changed

+48
-56
lines changed

contrib/pg_repack/Makefile

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,38 +6,32 @@
66
# Portions Copyright (c) 2012-2015, The Reorg Development Team
77
#
88

9+
ifdef USE_PGXS
910
PG_CONFIG ?= pg_config
10-
EXTENSION = pg_repack
11-
12-
.PHONY: dist/$(EXTENSION)-$(EXTVERSION).zip
13-
1411
# Pull out PostgreSQL version number from pg_config
1512
VERSION := $(shell $(PG_CONFIG) --version | awk '{print $$2}')
1613
ifeq ("$(VERSION)","")
1714
$(error pg_config not found)
1815
endif
19-
20-
# PostgreSQL version as a number, e.g. 9.1.4 -> 901
21-
INTVERSION := $(shell echo $$(($$(echo $(VERSION) | sed 's/\([[:digit:]]\{1,\}\)\.\([[:digit:]]\{1,\}\).*/\1*100+\2/'))))
22-
23-
# The version number of the library
24-
EXTVERSION = $(shell grep '"version":' META.json | head -1 \
25-
| sed -e 's/[ ]*"version":[ ]*"\(.*\)",/\1/')
26-
27-
ifeq ($(shell echo $$(($(INTVERSION) < 803))),1)
28-
$(error $(EXTENSION) requires PostgreSQL 8.3 or later. This is $(VERSION))
16+
else
17+
subdir= contrib/pg_repack
18+
top_builddir = ../..
19+
include $(top_builddir)/src/Makefile.global
20+
include $(top_srcdir)/contrib/contrib-global.mk
2921
endif
22+
EXTENSION = pg_repack
23+
3024

3125
SUBDIRS = bin lib regress
3226

3327
all install installdirs uninstall distprep clean distclean maintainer-clean debug:
34-
@for dir in $(SUBDIRS); do \
28+
for dir in $(SUBDIRS); do \
3529
$(MAKE) -C $$dir $@ || exit; \
3630
done
3731

3832
# We'd like check operations to run all the subtests before failing.
3933
check installcheck:
40-
@CHECKERR=0; for dir in $(SUBDIRS); do \
34+
CHECKERR=0; for dir in $(SUBDIRS); do \
4135
$(MAKE) -C $$dir $@ || CHECKERR=$$?; \
4236
done; \
4337
exit $$CHECKERR

contrib/pg_repack/bin/Makefile

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,21 @@
55
# Portions Copyright (c) 2011, Itagaki Takahiro
66
# Portions Copyright (c) 2012-2015, The Reorg Development Team
77
#
8-
9-
PG_CONFIG ?= pg_config
10-
118
SRCS = pg_repack.c pgut/pgut.c pgut/pgut-fe.c
129
OBJS = $(SRCS:.c=.o)
1310
PROGRAM = pg_repack
11+
PG_CPPFLAGS = -I$(libpq_srcdir)
12+
ifdef USE_PGXS
13+
PG_CONFIG = pg_config
14+
PGXS := $(shell $(PG_CONFIG) --pgxs)
15+
include $(PGXS)
16+
else
17+
subdir= contrib/pg_repack/bin
18+
top_builddir = ../../..
19+
include $(top_builddir)/src/Makefile.global
20+
include $(top_srcdir)/contrib/contrib-global.mk
21+
endif
22+
1423

1524

1625
# The version number of the program. It should be the same of the library.
@@ -25,10 +34,6 @@ endif
2534

2635
PG_LIBS = $(libpq)
2736

28-
USE_PGXS = 1 # use pgxs if not in contrib directory
29-
PG_CONFIG = pg_config
30-
PGXS := $(shell $(PG_CONFIG) --pgxs)
31-
include $(PGXS)
3237

3338
# remove dependency on libxml2, libxslt, and libpam.
3439
# XXX: find a better way to make sure we are linking with libraries

contrib/pg_repack/lib/Makefile

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,26 @@
66
# Portions Copyright (c) 2012-2015, The Reorg Development Team
77
#
88

9+
EXTENSION = pg_repack
10+
MODULE_big = $(EXTENSION)
11+
12+
OBJS = repack.o pgut/pgut-be.o pgut/pgut-spi.o
13+
ifdef USE_PGXS
914
PG_CONFIG ?= pg_config
15+
PGXS := $(shell $(PG_CONFIG) --pgxs)
16+
VERSION := $(shell $(PG_CONFIG) --version | awk '{print $$2}')
17+
include $(PGXS)
18+
else
19+
subdir= contrib/pg_repack/lib
20+
top_builddir = ../../..
21+
include $(top_builddir)/src/Makefile.global
22+
include $(top_srcdir)/contrib/contrib-global.mk
23+
endif
24+
1025

1126
# version as a number, e.g. 9.1.4 -> 901
12-
VERSION := $(shell $(PG_CONFIG) --version | awk '{print $$2}')
1327
INTVERSION := $(shell echo $$(($$(echo $(VERSION) | sed 's/\([[:digit:]]\{1,\}\)\.\([[:digit:]]\{1,\}\).*/\1*100+\2/'))))
1428

15-
EXTENSION = pg_repack
16-
MODULE_big = $(EXTENSION)
17-
18-
OBJS = repack.o pgut/pgut-be.o pgut/pgut-spi.o
1929

2030
SHLIB_EXPORTS = exports.txt
2131

@@ -33,10 +43,6 @@ DATA_built = pg_repack.sql
3343
DATA = uninstall_pg_repack.sql
3444
endif
3545

36-
USE_PGXS = 1
37-
PGXS := $(shell $(PG_CONFIG) --pgxs)
38-
include $(PGXS)
39-
4046
# remove dependency on libxml2, libxslt, and libpam.
4147
# XXX: find a better way to make sure we are linking with libraries
4248
# from pg_config which we actually need.

contrib/pg_repack/regress/Makefile

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,24 @@
66
# Portions Copyright (c) 2012-2015, The Reorg Development Team
77
#
88

9-
PG_CONFIG ?= pg_config
109

10+
ifdef PGXS
11+
PG_CONFIG = pg_config
12+
PGXS := $(shell $(PG_CONFIG) --pgxs)
13+
include $(PGXS)
1114
# version as a number, e.g. 9.1.4 -> 901
1215
VERSION := $(shell $(PG_CONFIG) --version | awk '{print $$2}')
1316
INTVERSION := $(shell echo $$(($$(echo $(VERSION) | sed 's/\([[:digit:]]\{1,\}\)\.\([[:digit:]]\{1,\}\).*/\1*100+\2/' ))))
14-
17+
else
18+
subdir= contrib/pg_repack/regress
19+
top_builddir = ../../..
20+
include $(top_builddir)/src/Makefile.global
21+
include $(top_srcdir)/contrib/contrib-global.mk
22+
endif
1523

1624
#
1725
# Test suite
1826
#
1927

20-
ifeq ($(shell echo $$(($(INTVERSION) >= 901))),1)
21-
REGRESS := init-extension
22-
else
23-
REGRESS := init-legacy
24-
endif
28+
REGRESS := init-extension psql repack tablespace issue3
2529

26-
# plpgsql not available by default on pg < 9.0
27-
ifeq ($(shell echo $$(($(INTVERSION) < 900))),1)
28-
REGRESS += plpgsql
29-
endif
30-
31-
REGRESS += repack tablespace
32-
33-
# This test depends on collate, not supported before 9.1
34-
ifeq ($(shell echo $$(($(INTVERSION) >= 901))),1)
35-
REGRESS += issue3
36-
endif
37-
38-
39-
USE_PGXS = 1 # use pgxs if not in contrib directory
40-
PG_CONFIG = pg_config
41-
PGXS := $(shell $(PG_CONFIG) --pgxs)
42-
include $(PGXS)

0 commit comments

Comments
 (0)