forked from ossc-db/pg_dbms_stats
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
97 lines (75 loc) · 2.89 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# pg_dbms_stats/Makefile
DBMSSTATSVER = 1.3.7
PGVERS = 91 92 93 94 95 96
IS_PRE_95 = $(filter 0,$(shell test "$(MAJORVERSION)" \< "9.5"; echo $$?))
MODULE_big = pg_dbms_stats
OBJS = pg_dbms_stats.o dump.o import.o
DOCDIR = doc
EXTDIR = ext_scripts
ifdef UNIT_TEST
PG_CPPFLAGS = -DUNIT_TEST
endif
LAST_LIBPATH=$(shell echo $(LD_LIBRARY_PATH) | sed -e "s/^.*;//")
CHECKING=$(shell echo $(LAST_LIBPATH)| grep './tmp_check/install/' | wc -l)
EXTENSION = pg_dbms_stats
REGRESS = init-common ut_fdw_init init-$(REGTESTVER) ut-common \
ut-$(REGTESTVER) ut_imp_exp-$(REGTESTVER)
EXTRA_INSTALL = contrib/file_fdw
# Before 9.5 needs extra-install flag for pg_regress
REGRESS_OPTS = --encoding=UTF8 --temp-config=regress.conf $(if $(IS_PRE_95),--extra-install=$(EXTRA_INSTALL))
# Pick up only the install scripts needed for the PG version.
DATA = $(subst -$(MAJORVERSION).sql,.sql,$(filter %-$(MAJORVERSION).sql,$(notdir $(wildcard ext_scripts/*.sql))))
DOCS = $(DOCDIR)/export_effective_stats-$(MAJORVERSION).sql.sample \
$(DOCDIR)/export_plain_stats-$(MAJORVERSION).sql.sample
# Source tarballs required for rpmbuild
STARBALL = pg_dbms_stats-$(DBMSSTATSVER).tar.gz
STARBALLS = $(STARBALL) $(foreach v,$(PGVERS),pg_dbms_stats$(v)-$(DBMSSTATSVER).tar.gz)
# Generate RPM target names for all target PG versions
RPMS = $(foreach v,$(PGVERS),rpm$(v))
EXTRA_CLEAN = sql/ut_anyarray-*.sql expected/ut_anyarray-*.out \
sql/ut_imp_exp-*.sql expected/ut_imp_exp-*.out \
sql/ut_fdw_init.sql expected/ut_fdw_init.out \
export_stats.dmp ut-fdw.csv $(DATA) $(STARBALLS) RPMS/*/* \
*~
ifndef USE_PGXS
ifeq ($(wildcard ../../contrib/contrib-global.mk),)
USE_PGXS=1
endif
endif
ifdef USE_PGXS
PG_CONFIG = pg_config
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)
else
subdir = contrib/pg_dbms_stats
top_builddir = ../..
include $(top_builddir)/src/Makefile.global
include $(top_srcdir)/contrib/contrib-global.mk
endif
REGTESTVER = $(MAJORVERSION)
TARSOURCES = Makefile *.c *.h \
$(EXTDIR)/pg_dbms_stats--*-9.*.sql \
pg_dbms_stats.control COPYRIGHT ChangeLog ChangeLog.ja \
README.installcheck regress.conf \
doc/* expected/init-*.out expected/ut-*.out \
sql/init-*.sql sql/ut-*.sql \
input/*.source input/*.csv output/*.source SPECS/*.spec
all: $(DATA) $(DOCS)
rpms: $(RPMS)
sourcetar: $(STARBALL)
$(DATA): %.sql: $(EXTDIR)/%-$(MAJORVERSION).sql
cp $< $@
# Source tar balls are the same for all target PG versions.
# This is because rpmbuild requires a tar ball with the same base name
# with target rpm file.
$(STARBALLS): $(TARSOURCES)
if [ -h $(subst .tar.gz,,$@) ]; then rm $(subst .tar.gz,,$@); fi
if [ -e $(subst .tar.gz,,$@) ]; then \
echo "$(subst .tar.gz,,$@) is not a symlink. Stop."; \
exit 1; \
fi
ln -s . $(subst .tar.gz,,$@)
tar -chzf $@ $(addprefix $(subst .tar.gz,,$@)/, $^)
rm $(subst .tar.gz,,$@)
$(RPMS): rpm% : SPECS/pg_dbms_stats%.spec pg_dbms_stats%-$(DBMSSTATSVER).tar.gz
MAKE_ROOT=`pwd` rpmbuild -bb $<