From 14d309cc55d88b73d4c9d1fa51b535ae491405fd Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Thu, 8 May 2014 22:34:51 -0400 Subject: [PATCH] Fix missing dependencies in ecpg's test Makefiles. Ensure that ecpg preprocessor output files are rebuilt when re-testing after a change in the ecpg preprocessor itself, or a change in any of several include files that get copied verbatim into the output files. The lack of these dependencies was what created problems for Kevin Grittner after the recent pgindent run. There's no way for --enable-depend to discover these dependencies automatically, so we've gotta put them into the Makefiles by hand. While at it, reduce the amount of duplication in the ecpg invocations. --- src/interfaces/ecpg/test/Makefile.regress | 21 ++++++++++++-- .../ecpg/test/compat_informix/Makefile | 28 ++----------------- src/interfaces/ecpg/test/preproc/Makefile | 16 +++++------ src/interfaces/ecpg/test/sql/Makefile | 4 +-- 4 files changed, 31 insertions(+), 38 deletions(-) diff --git a/src/interfaces/ecpg/test/Makefile.regress b/src/interfaces/ecpg/test/Makefile.regress index edfece07df6..fd6e83aeafa 100644 --- a/src/interfaces/ecpg/test/Makefile.regress +++ b/src/interfaces/ecpg/test/Makefile.regress @@ -1,3 +1,6 @@ +# This file is included into the Makefiles of subdirectories of ecpg/test/, +# so the file references have one more level of .. than you might expect. + override CPPFLAGS := -I../../include -I$(top_srcdir)/src/interfaces/ecpg/include \ -I$(libpq_srcdir) $(CPPFLAGS) override CFLAGS += $(PTHREAD_CFLAGS) @@ -5,13 +8,25 @@ override CFLAGS += $(PTHREAD_CFLAGS) override LDFLAGS := -L../../ecpglib -L../../pgtypeslib $(filter-out -l%, $(libpq)) $(LDFLAGS) override LIBS := -lecpg -lpgtypes $(filter -l%, $(libpq)) $(LIBS) $(PTHREAD_LIBS) -ECPG = ../../preproc/ecpg --regression -I$(srcdir)/../../include +# Standard way to invoke the ecpg preprocessor +ECPG = ../../preproc/ecpg --regression -I$(srcdir)/../../include -I$(srcdir) + +# Files that most or all ecpg preprocessor test outputs depend on +ECPG_TEST_DEPENDENCIES = ../../preproc/ecpg \ + $(srcdir)/../regression.h \ + $(srcdir)/../../include/sqlca.h \ + $(srcdir)/../../include/sqlda.h \ + $(srcdir)/../../include/sqltypes.h \ + $(srcdir)/../../include/sql3types.h %: %.o $(CC) $(CFLAGS) $< $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@ -%.c: %.pgc ../regression.h - $(ECPG) -o $@ -I$(srcdir) $< +# Caution: this build rule is overridden in some child Makefiles +# where it's necessary to use nondefault switches to ecpg; +# make sure those rules match except for the extra switches. +%.c: %.pgc $(ECPG_TEST_DEPENDENCIES) + $(ECPG) -o $@ $< clean: rm -f $(TESTS) $(TESTS:%=%.o) $(TESTS:%=%.c) diff --git a/src/interfaces/ecpg/test/compat_informix/Makefile b/src/interfaces/ecpg/test/compat_informix/Makefile index a8e2ca972ec..8a5e8544967 100644 --- a/src/interfaces/ecpg/test/compat_informix/Makefile +++ b/src/interfaces/ecpg/test/compat_informix/Makefile @@ -3,9 +3,8 @@ top_builddir = ../../../../.. include $(top_builddir)/src/Makefile.global include $(top_srcdir)/$(subdir)/../Makefile.regress -# special informix compatibility switches +# Use special informix compatibility switch for all tests in this directory ECPG += -C INFORMIX -ECPG_NOIND = $(ECPG) -r no_indicator override LDFLAGS := -L../../compatlib $(LDFLAGS) override LIBS := -lecpg_compat $(LIBS) @@ -22,26 +21,5 @@ TESTS = test_informix test_informix.c \ all: $(TESTS) -test_informix.c: test_informix.pgc ../regression.h - $(ECPG) -o $@ -I$(srcdir) $< - -test_informix2.c: test_informix2.pgc ../regression.h - $(ECPG) -o $@ -I$(srcdir) $< - -sqlda.c: sqlda.pgc ../regression.h - $(ECPG) -o $@ -I$(srcdir) $< - -dec_test.c: dec_test.pgc ../regression.h - $(ECPG) -o $@ -I$(srcdir) $< - -rfmtdate.c: rfmtdate.pgc ../regression.h - $(ECPG) -o $@ -I$(srcdir) $< - -rfmtlong.c: rfmtlong.pgc ../regression.h - $(ECPG) -o $@ -I$(srcdir) $< - -rnull.c: rnull.pgc ../regression.h - $(ECPG_NOIND) -o $@ -I$(srcdir) $< - -charfuncs.c: charfuncs.pgc ../regression.h - $(ECPG) -o $@ -I$(srcdir) $< +rnull.c: rnull.pgc $(ECPG_TEST_DEPENDENCIES) + $(ECPG) -r no_indicator -o $@ $< diff --git a/src/interfaces/ecpg/test/preproc/Makefile b/src/interfaces/ecpg/test/preproc/Makefile index 95eb154cf12..d658a4d6b2c 100644 --- a/src/interfaces/ecpg/test/preproc/Makefile +++ b/src/interfaces/ecpg/test/preproc/Makefile @@ -19,14 +19,14 @@ TESTS = array_of_struct array_of_struct.c \ all: $(TESTS) -array_of_struct.c: array_of_struct.pgc ../regression.h - $(ECPG) -c -o $@ -I$(srcdir) $< +array_of_struct.c: array_of_struct.pgc $(ECPG_TEST_DEPENDENCIES) + $(ECPG) -c -o $@ $< -pointer_to_struct.c: pointer_to_struct.pgc ../regression.h - $(ECPG) -c -o $@ -I$(srcdir) $< +pointer_to_struct.c: pointer_to_struct.pgc $(ECPG_TEST_DEPENDENCIES) + $(ECPG) -c -o $@ $< -autoprep.c: autoprep.pgc ../regression.h - $(ECPG) -r prepare -o $@ -I$(srcdir) $< +autoprep.c: autoprep.pgc $(ECPG_TEST_DEPENDENCIES) + $(ECPG) -r prepare -o $@ $< -strings.c: strings.pgc strings.h ../regression.h - $(ECPG) -i -o $@ -I$(srcdir) $< +strings.c: strings.pgc strings.h $(ECPG_TEST_DEPENDENCIES) + $(ECPG) -i -o $@ $< diff --git a/src/interfaces/ecpg/test/sql/Makefile b/src/interfaces/ecpg/test/sql/Makefile index 18c37b665e1..6bc67e92daf 100644 --- a/src/interfaces/ecpg/test/sql/Makefile +++ b/src/interfaces/ecpg/test/sql/Makefile @@ -26,5 +26,5 @@ TESTS = array array.c \ all: $(TESTS) -oldexec.c: oldexec.pgc ../regression.h - $(ECPG) -r questionmarks -o $@ -I$(srcdir) $< +oldexec.c: oldexec.pgc $(ECPG_TEST_DEPENDENCIES) + $(ECPG) -r questionmarks -o $@ $<