OSDN Git Service

Stabilize regression test
[pgdbmsstats/pg_dbms_stats.git] / Makefile
index a06a180..0c36fc4 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,8 +1,13 @@
 # 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
-DBMSSTATSVER = 1.3.2
+DOCDIR = doc
+EXTDIR = ext_scripts
 
 ifdef UNIT_TEST
 PG_CPPFLAGS = -DUNIT_TEST
@@ -10,30 +15,31 @@ 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
-DATA = pg_dbms_stats--1.3.2.sql pg_dbms_stats--1.0--1.3.2.sql
 
-REGRESS = init-common ut_fdw_init init-$(MAJORVERSION) ut-common \
-                 ut-$(MAJORVERSION)  ut_imp_exp-$(MAJORVERSION)
+REGRESS = init-common ut_fdw_init init-$(REGTESTVER) ut-common \
+                 ut-$(REGTESTVER)  ut_imp_exp-$(REGTESTVER)
+EXTRA_INSTALL = contrib/file_fdw
 
-REGRESS_OPTS = --encoding=UTF8 --temp-config=regress.conf --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))
 
-DOCS = export_effective_stats-$(MAJORVERSION).sql.sample \
-       export_plain_stats-$(MAJORVERSION).sql.sample
+# 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
-STARBALL94 = pg_dbms_stats94-$(DBMSSTATSVER).tar.gz
-STARBALL93 = pg_dbms_stats93-$(DBMSSTATSVER).tar.gz
-STARBALL92 = pg_dbms_stats92-$(DBMSSTATSVER).tar.gz
-STARBALL91 = pg_dbms_stats91-$(DBMSSTATSVER).tar.gz
-STARBALLS = $(STARBALL) $(STARBALL94s) $(STARBALL93) $(STARBALL92) $(STARBALL91)
+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 \
-       pg_dbms_stats--1.0--1.3.2.sql export_plain_stats.sql.sample \
-       export_effective_stats.sql.sample \
+       sql/ut_fdw_init.sql expected/ut_fdw_init.out \
        export_stats.dmp ut-fdw.csv $(DATA) $(STARBALLS) RPMS/*/* \
        *~
 
@@ -54,24 +60,28 @@ include $(top_builddir)/src/Makefile.global
 include $(top_srcdir)/contrib/contrib-global.mk
 endif
 
-ifeq "$(MAJORVERSION)" "9.4"
-MAJORVERSION=9.3
-endif
+REGTESTVER = $(MAJORVERSION)
 
-TARSOURCES = Makefile *.c  *.h pg_dbms_stats--*-9.*.sql pg_dbms_stats.control \
-       export_*_stats-9.*.sql.sample COPYRIGHT \
-       doc/* expected/*.out sql/*.sql input/*.source input/*.csv \
-       output/*.source SPECS/*.spec
+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: rpm93 rpm92 rpm91
+rpms: $(RPMS)
 
 sourcetar: $(STARBALL)
 
-$(DATA): %.sql: %-$(MAJORVERSION).sql                                                                                  
+$(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 \
@@ -82,14 +92,6 @@ $(STARBALLS): $(TARSOURCES)
        tar -chzf $@ $(addprefix $(subst .tar.gz,,$@)/, $^)
        rm $(subst .tar.gz,,$@)
 
-rpm94: $(STARBALL94)
-       MAKE_ROOT=`pwd` rpmbuild -bb SPECS/pg_dbms_stats94.spec
-
-rpm93: $(STARBALL93)
-       MAKE_ROOT=`pwd` rpmbuild -bb SPECS/pg_dbms_stats93.spec
-
-rpm92: $(STARBALL92)
-       MAKE_ROOT=`pwd` rpmbuild -bb SPECS/pg_dbms_stats92.spec
+$(RPMS): rpm% : SPECS/pg_dbms_stats%.spec pg_dbms_stats%-$(DBMSSTATSVER).tar.gz
+       MAKE_ROOT=`pwd` rpmbuild -bb $<
 
-rpm91: $(STARBALL91)
-       MAKE_ROOT=`pwd` rpmbuild -bb SPECS/pg_dbms_stats91.spec