Make distprep and *clean build targets recurse into all subdirectories.

Certain subdirectories do not get built if corresponding options are not
selected at configure time.  However, "make distprep" should visit such
directories anyway, so that constructing derived files to be included in
the tarball happens without requiring all configure options to be given
in the tarball build script.  Likewise, it's better if cleanup actions
unconditionally visit all directories (for example, this ensures proper
cleanup if someone has done a manual make in such a subdirectory).

To handle this, set up a convention that subdirectories that are
conditionally included in SUBDIRS should be added to ALWAYS_SUBDIRS
instead when they are excluded.

Back-patch to 9.1, so that plpython's spiexceptions.h will get provided
in 9.1 tarballs.  There don't appear to be any instances where distprep
actions got missed in previous releases, and anyway this fix requires
gmake 3.80 so we don't want to apply it before 9.1.
This commit is contained in:
Tom Lane 2011-07-03 13:55:02 -04:00
parent 19b7fac86d
commit acb9198b96
5 changed files with 48 additions and 14 deletions

View File

@ -52,18 +52,26 @@ SUBDIRS = \
ifeq ($(with_openssl),yes) ifeq ($(with_openssl),yes)
SUBDIRS += sslinfo SUBDIRS += sslinfo
else
ALWAYS_SUBDIRS += sslinfo
endif endif
ifeq ($(with_ossp_uuid),yes) ifeq ($(with_ossp_uuid),yes)
SUBDIRS += uuid-ossp SUBDIRS += uuid-ossp
else
ALWAYS_SUBDIRS += uuid-ossp
endif endif
ifeq ($(with_libxml),yes) ifeq ($(with_libxml),yes)
SUBDIRS += xml2 SUBDIRS += xml2
else
ALWAYS_SUBDIRS += xml2
endif endif
ifeq ($(with_selinux),yes) ifeq ($(with_selinux),yes)
SUBDIRS += sepgsql SUBDIRS += sepgsql
else
ALWAYS_SUBDIRS += sepgsql
endif endif
# Missing: # Missing:
@ -71,3 +79,4 @@ endif
$(recurse) $(recurse)
$(recurse_always)

View File

@ -19,6 +19,8 @@
# Meta configuration # Meta configuration
standard_targets = all install installdirs uninstall distprep clean distclean maintainer-clean coverage check installcheck maintainer-check standard_targets = all install installdirs uninstall distprep clean distclean maintainer-clean coverage check installcheck maintainer-check
# these targets should recurse even into subdirectories not being built:
standard_always_targets = distprep clean distclean maintainer-clean
.PHONY: $(standard_targets) install-strip html man installcheck-parallel .PHONY: $(standard_targets) install-strip html man installcheck-parallel
@ -603,6 +605,16 @@ endef
# $3: target to run in subdir (defaults to current element of $1) # $3: target to run in subdir (defaults to current element of $1)
recurse = $(foreach target,$(if $1,$1,$(standard_targets)),$(foreach subdir,$(if $2,$2,$(SUBDIRS)),$(eval $(call _create_recursive_target,$(target),$(subdir),$(if $3,$3,$(target)))))) recurse = $(foreach target,$(if $1,$1,$(standard_targets)),$(foreach subdir,$(if $2,$2,$(SUBDIRS)),$(eval $(call _create_recursive_target,$(target),$(subdir),$(if $3,$3,$(target))))))
# If a makefile's list of SUBDIRS varies depending on configuration, then
# any subdirectories excluded from SUBDIRS should instead be added to
# ALWAYS_SUBDIRS, and then it must call recurse_always as well as recurse.
# This ensures that distprep, distclean, etc will apply to all subdirectories.
# In the normal case all arguments will be defaulted.
# $1: targets to make recursive (defaults to standard_always_targets)
# $2: list of subdirs (defaults to ALWAYS_SUBDIRS variable)
# $3: target to run in subdir (defaults to current element of $1)
recurse_always = $(foreach target,$(if $1,$1,$(standard_always_targets)),$(foreach subdir,$(if $2,$2,$(ALWAYS_SUBDIRS)),$(eval $(call _create_recursive_target,$(target),$(subdir),$(if $3,$3,$(target))))))
########################################################################## ##########################################################################
# #

View File

@ -15,8 +15,12 @@ include $(top_builddir)/src/Makefile.global
SUBDIRS = initdb pg_ctl pg_dump \ SUBDIRS = initdb pg_ctl pg_dump \
psql scripts pg_config pg_controldata pg_resetxlog pg_basebackup psql scripts pg_config pg_controldata pg_resetxlog pg_basebackup
ifeq ($(PORTNAME), win32) ifeq ($(PORTNAME), win32)
SUBDIRS+=pgevent SUBDIRS += pgevent
else
ALWAYS_SUBDIRS += pgevent
endif endif
$(recurse) $(recurse)
$(recurse_always)

View File

@ -16,14 +16,21 @@ SUBDIRS = plpgsql
ifeq ($(with_perl), yes) ifeq ($(with_perl), yes)
SUBDIRS += plperl SUBDIRS += plperl
else
ALWAYS_SUBDIRS += plperl
endif endif
ifeq ($(with_python), yes) ifeq ($(with_python), yes)
SUBDIRS += plpython SUBDIRS += plpython
else
ALWAYS_SUBDIRS += plpython
endif endif
ifeq ($(with_tcl), yes) ifeq ($(with_tcl), yes)
SUBDIRS += tcl SUBDIRS += tcl
else
ALWAYS_SUBDIRS += tcl
endif endif
$(recurse) $(recurse)
$(recurse_always)

View File

@ -95,16 +95,8 @@ PSQLDIR = $(bindir)
include $(top_srcdir)/src/Makefile.shlib include $(top_srcdir)/src/Makefile.shlib
# Force this dependency to be known even without dependency info built:
plpython.o: spiexceptions.h
spiexceptions.h: $(top_srcdir)/src/backend/utils/errcodes.txt generate-spiexceptions.pl
$(PERL) $(srcdir)/generate-spiexceptions.pl $< > $@
all: all-lib all: all-lib
distprep: spiexceptions.h
install: all install-lib install-data install: all install-lib install-data
@ -151,13 +143,13 @@ installcheck: submake prep3
$(pg_regress_installcheck) --inputdir=./python3 --outputdir=./python3 $(REGRESS_OPTS) $(REGRESS) $(pg_regress_installcheck) --inputdir=./python3 --outputdir=./python3 $(REGRESS_OPTS) $(REGRESS)
clean: clean3 clean: clean3
else else # not Python 3
check: submake check: submake
$(pg_regress_check) $(REGRESS_OPTS) $(REGRESS) $(pg_regress_check) $(REGRESS_OPTS) $(REGRESS)
installcheck: submake installcheck: submake
$(pg_regress_installcheck) $(REGRESS_OPTS) $(REGRESS) $(pg_regress_installcheck) $(REGRESS_OPTS) $(REGRESS)
endif endif # not Python 3
.PHONY: submake .PHONY: submake
submake: submake:
@ -170,9 +162,6 @@ ifeq ($(PORTNAME), win32)
rm -f python${pytverstr}.def rm -f python${pytverstr}.def
endif endif
maintainer-clean: distclean
rm -f spiexceptions.h
else # can't build else # can't build
all: all:
@ -183,3 +172,16 @@ all:
echo "" echo ""
endif # can't build endif # can't build
# distprep and maintainer-clean rules should be run even if we can't build.
# Force this dependency to be known even without dependency info built:
plpython.o: spiexceptions.h
spiexceptions.h: $(top_srcdir)/src/backend/utils/errcodes.txt generate-spiexceptions.pl
$(PERL) $(srcdir)/generate-spiexceptions.pl $< > $@
distprep: spiexceptions.h
maintainer-clean: distclean
rm -f spiexceptions.h