Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 00a1429

Browse files
committed
More portable way of determining pg_shardman location.
Previously used $(abs ...) and $(info ...) are not availabe in GNU make 3.80. Now we determine absolute path with cd && pwd, it seems to be the most sane portable approach (readlink and realpath are not ubiquitous too).
1 parent 713e2d5 commit 00a1429

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

Makefile

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,25 @@ MODULE_big = pg_shardman
1010
OBJS = pg_shardman.o
1111
PGFILEDESC = "pg_shardman - sharding for Postgres"
1212

13-
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST))) # abs path to this makefile
14-
mkfile_dir := $(shell basename $(shell dirname $(dir $(mkfile_path)))) # parent dir of the project
1513
ifndef USE_PGXS # hmm, user didn't requested to use pgxs
16-
ifneq ($(strip $(mkfile_dir)),contrib) # a-ha, but we are not inside 'contrib' dir
14+
# relative path to this makefile
15+
mkfile_path := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
16+
# relative path to dir with this makefile
17+
mkfile_dir := $(dir $(mkfile_path))
18+
# abs path to dir with this makefile
19+
mkfile_abspath := $(shell cd $(mkfile_dir) && pwd -P)
20+
# parent dir name of directory with makefile
21+
parent_dir_name := $(shell basename $(shell dirname $(mkfile_abspath)))
22+
ifneq ($(parent_dir_name),contrib) # a-ha, but this shardman is not inside 'contrib' dir
1723
USE_PGXS := 1 # so use it anyway, most probably that's what the user wants
1824
endif
1925
endif
26+
# $(info) is introduced in 3.81, and PG doesn't support makes older than 3.80
27+
ifeq ($(MAKE_VERSION),3.80)
28+
$(warning $$USE_PGXS is [${USE_PGXS}] (we use it automatically if not in contrib dir))
29+
else
2030
$(info $$USE_PGXS is [${USE_PGXS}] (we use it automatically if not in contrib dir))
31+
endif
2132

2233
ifdef USE_PGXS # use pgxs
2334
# You can specify path to pg_config in PG_CONFIG var

0 commit comments

Comments
 (0)