@@ -7,25 +7,56 @@ src/pglogical_relid_map.o src/ddd.o src/bkb.o src/spill.o src/state.o \
77src/resolver.o src/ddl.o src/syncpoint.o src/global_tx.o
88MODULE_big = multimaster
99
10- PG_CPPFLAGS += -I$(libpq_srcdir )
11- SHLIB_LINK = $(libpq )
10+ ifndef USE_PGXS # hmm, user didn't requested to use pgxs
11+ # relative path to this makefile
12+ mkfile_path := $(word $(words $(MAKEFILE_LIST ) ) ,$(MAKEFILE_LIST ) )
13+ # relative path to dir with this makefile
14+ mkfile_dir := $(dir $(mkfile_path ) )
15+ # abs path to dir with this makefile
16+ mkfile_abspath := $(shell cd $(mkfile_dir ) && pwd -P)
17+ # parent dir name of directory with makefile
18+ parent_dir_name := $(shell basename $(shell dirname $(mkfile_abspath ) ) )
19+ ifneq ($(parent_dir_name ) ,contrib) # a-ha, but the extension is not inside 'contrib' dir
20+ USE_PGXS := 1 # so use it anyway, most probably that's what the user wants
21+ endif
22+ endif
23+ # $(info) is introduced in 3.81, and PG doesn't support makes older than 3.80
24+ ifeq ($(MAKE_VERSION ) ,3.80)
25+ $(warning $$USE_PGXS is [${USE_PGXS}] (we use it automatically if not in contrib dir))
26+ else
27+ $(info $$USE_PGXS is [${USE_PGXS}] (we use it automatically if not in contrib dir))
28+ endif
1229
13- ifdef USE_PGXS
30+ ifdef USE_PGXS # use pgxs
31+ # You can specify path to pg_config in PG_CONFIG var
32+ ifndef PG_CONFIG
33+ PG_CONFIG := pg_config
34+ endif
1435PG_CPPFLAGS += -I$(CURDIR ) /src/include
15- PG_CONFIG = pg_config
36+ # add installation top include directory for libpq header
37+ # (seems like server/ dir is added by pgxs)
38+ PG_CPPFLAGS += -I$(shell $(PG_CONFIG ) --includedir)
39+ SHLIB_LINK += -lpq # add libpq
1640PGXS := $(shell $(PG_CONFIG ) --pgxs)
1741include $(PGXS )
18- else
42+
43+ else # assume the extension is in contrib/ dir of pg distribution
44+ # EXTRA_INSTALL=contrib/pg_pathman contrib/referee
1945PG_CPPFLAGS += -I$(top_srcdir ) /$(subdir ) /src/include
46+ PG_CPPFLAGS += -I$(libpq_srcdir ) # include libpq-fe, defined in Makefile.global.in
47+ SHLIB_LINK = $(libpq ) # defined in Makefile.global.in
2048subdir = contrib/mmts
2149top_builddir = ../..
2250include $(top_builddir ) /src/Makefile.global
2351include $(top_srcdir ) /contrib/contrib-global.mk
24- endif
52+ endif # USE_PGXS
2553
2654.PHONY : all
2755
28- EXTRA_INSTALL =contrib/pg_pathman contrib/referee
56+ # recurse down to referee/ on install
57+ referee-install :
58+ USE_PGXS=$(USE_PGXS ) $(MAKE ) -C referee install
59+ install : referee-install
2960
3061all : multimaster.so
3162
@@ -38,22 +69,38 @@ submake-regress:
3869# PROVE_TESTS ?=
3970# endif
4071PROVE_FLAGS += --timer
72+ ifndef USE_PGXS
4173check : temp-install submake-regress
4274 $(prove_check )
75+ else # pgxs build
76+ # Note that for PGXS build we override here bail-out recipe defined in pgxs.mk,
77+ # but well, why should we chose another name?
78+ # submake-regress won't work as we have no access to the source; we assume
79+ # regress is already installed
80+ # final spell is inspired by
81+ # https://www.2ndquadrant.com/en/blog/using-postgresql-tap-framework-extensions/
82+ # and Makefile.global.in which is obviously the original source
83+ check :
84+ rm -rf ' $(CURDIR)' /tmp_check
85+ $(MKDIR_P ) ' $(CURDIR)' /tmp_check
86+ PGXS=$(PGXS ) TESTDIR=' $(CURDIR)' PATH=" $( bindir) :$$ PATH" PG_REGRESS=' $(top_builddir)/src/test/regress/pg_regress' $(PROVE ) $(PG_PROVE_FLAGS ) $(PROVE_FLAGS ) $(if $(PROVE_TESTS ) ,$(PROVE_TESTS ) ,t/* .pl)
87+ endif
4388
89+ # PG_PROVE_FLAGS adds PostgresNode and friends include dir
4490start : temp-install
4591 rm -rf ' $(CURDIR)' /tmp_check
4692 $(MKDIR_P ) ' $(CURDIR)' /tmp_check
4793 cd $(srcdir ) && TESTDIR=' $(CURDIR)' \
4894 $(with_temp_install ) \
49- PG_REGRESS=' $(CURDIR)/$( top_builddir)/src/test/regress/pg_regress' \
50- perl run.pl --action=start $(RUN_OPTS )
95+ PG_REGRESS=' $(top_builddir)/src/test/regress/pg_regress' \
96+ perl $( PG_PROVE_FLAGS ) run.pl --action=start $(RUN_OPTS )
5197
5298stop :
5399 cd $(srcdir ) && TESTDIR=' $(CURDIR)' \
54- $( with_temp_install ) \
55- perl run.pl --action=stop $(RUN_OPTS )
100+ PG_REGRESS= ' $(top_builddir)/src/test/regress/pg_regress ' \
101+ perl $( PG_PROVE_FLAGS ) run.pl --action=stop $(RUN_OPTS )
56102
103+ # for manual testing: runs core regress tests on 'make start'ed cluster
57104run-pg-regress : submake-regress
58105 cd $(CURDIR ) /$(top_builddir ) /src/test/regress && \
59106 $(with_temp_install ) \
@@ -67,6 +114,7 @@ run-pg-regress: submake-regress
67114 --dlpath=$(CURDIR ) /$(top_builddir ) /src/test/regress \
68115 --inputdir=$(abs_top_srcdir ) /src/test/regress
69116
117+ # for manual testing: runs contrib/test_partition on 'make start'ed cluster
70118run-pathman-regress :
71119 cd $(CURDIR ) /$(top_builddir ) /src/test/regress && \
72120 $(with_temp_install ) \
0 commit comments