@@ -10,27 +10,34 @@ MODULE_big = pg_shardman
10
10
OBJS = pg_shardman.o
11
11
PGFILEDESC = "pg_shardman - sharding for Postgres"
12
12
13
- ifdef USE_SOURCETREE # assume the extension is in contrib/ dir of pg distribution
14
- PG_CPPFLAGS = -I $( libpq_srcdir )
15
- SHLIB_LINK = $( libpq )
16
- SHLIB_PREREQS = submake-libpq
17
- subdir = contrib/pg_shardman
18
- top_builddir = ../..
19
- include $( top_builddir ) /src/Makefile.global
20
- include $( top_srcdir ) /contrib/contrib-global.mk
21
- else # use pgxs
13
+ mkfile_path := $( abspath $( lastword $( MAKEFILE_LIST ) ) ) # abs path to this makefile
14
+ mkfile_dir := $( shell basename $( dir $( mkfile_path ) ) ) # parent dir of the project
15
+ ifndef USE_PGXS # hmm, user didn't requested to use pgxs
16
+ ifneq ( $( mkfile_dir ) ,contrib) # a-ha, but we are not inside 'contrib' dir
17
+ USE_PGXS := 1 # so use it anyway, most probably that's use user wants
18
+ endif
19
+ endif
20
+
21
+ ifdef USE_PGXS # use pgxs
22
22
# You can specify path to pg_config in PG_CONFIG var
23
23
ifndef PG_CONFIG
24
24
PG_CONFIG := pg_config
25
25
endif
26
26
PG_CONFIG = pg_config
27
-
28
27
INCLUDEDIR := $(shell $(PG_CONFIG ) --includedir)
29
28
PG_CPPFLAGS += -I$(INCLUDEDIR ) # add server's include directory for libpq-fe.h
30
29
SHLIB_LINK += -lpq # add libpq
31
-
32
30
PGXS := $(shell $(PG_CONFIG ) --pgxs)
33
31
include $(PGXS )
32
+
33
+ else # assume the extension is in contrib/ dir of pg distribution
34
+ PG_CPPFLAGS = -I$(libpq_srcdir ) # include libpq-fe, defined in Makefile.global.in
35
+ SHLIB_LINK = $(libpq ) # defined in Makefile.global.in
36
+ SHLIB_PREREQS = submake-libpq
37
+ subdir = contrib/pg_shardman
38
+ top_builddir = ../..
39
+ include $(top_builddir ) /src/Makefile.global
40
+ include $(top_srcdir ) /contrib/contrib-global.mk
34
41
endif
35
42
36
43
python_tests :
0 commit comments