From: <sg...@us...> - 2003-09-01 04:59:26
|
Update of /cvsroot/libfunutil/libfunutil/toc/make In directory sc8-pr-cvs1:/tmp/cvs-serv1147/toc/make Modified Files: cleaner.make subdirs_traverser.make Log Message: major re-thinking vis-a-vis clean/distclean and subdirs. Index: cleaner.make =================================================================== RCS file: /cvsroot/libfunutil/libfunutil/toc/make/cleaner.make,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- cleaner.make 31 Aug 2003 20:22:15 -0000 1.5 +++ cleaner.make 1 Sep 2003 04:59:22 -0000 1.6 @@ -6,6 +6,20 @@ # include path/to/this/file # # That creates 'clean' and 'distclean' targets which will nuke those files/dirs. +# +# Special case: cleaning subdirs in an order other than that specified in $(SUBDIRS): +# +# Set TOC_OVERRIDE_CLEAN to 1 /before including toc.make/ in any given +# makefile in order to have 'clean' clean/distclean targets, i.e., one you can +# re-order all you want by using dependencies. +# e.g.: +# clean: $(addprefix clean-,bin sbin lib doc tests .) +# or: +# clean: precleaner subdirs-clean clean-. aftercleaner +# +# If you do this the default clean/distclean behaviour will be to do NOTHING, +# so you must be sure to set the dist/clean deps. + .PHONY: clean distclean clean-. @@ -19,17 +33,33 @@ done; \ exit 0 + +clean-%: # assume $* is a subdirectory + @$(call toc_make_subdirs,$*,clean) +distclean-%: # assume $* is a subdirectory + @$(call toc_make_subdirs,$*,distclean) + + clean-.: @$(call toc_clean_files,$(wildcard $(CLEAN_FILES))) -clean-subdirs: -clean: clean-subdirs clean-. -# we clean depth-first to keep some top-level generated files from being nuked :/ -# todo: fix this by moving those files into a generated-files-only dir. -# -# Note: distclean does not depend on clean so that a recursive distclean does not -# climb down the tree twice :/ - distclean-.: @$(call toc_clean_files,$(wildcard $(CLEAN_FILES) $(DISTCLEAN_FILES))) -distclean-subdirs: -distclean: distclean-subdirs distclean-. + +subdirs-clean: # implemented elsewhere +subdirs-distclean: # implemented elsewhere +clean-subdirs: subdirs-clean +distclean-subdirs: subdirs-distclean + + +# toc-XXX stubs: don't use these directly +toc-clean: subdirs-clean clean-. +toc-distclean: subdirs-distclean distclean-. +# we clean depth-first to keep some top-level generated files from being nuked :/ + +ifeq (1,$(TOC_OVERRIDE_CLEAN)) +clean: +distclean: +else +clean: toc-clean +distclean: toc-distclean +endif Index: subdirs_traverser.make =================================================================== RCS file: /cvsroot/libfunutil/libfunutil/toc/make/subdirs_traverser.make,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- subdirs_traverser.make 31 Aug 2003 20:26:43 -0000 1.10 +++ subdirs_traverser.make 1 Sep 2003 04:59:22 -0000 1.11 @@ -5,54 +5,49 @@ # include path/to/subdirs_traverser.make # all: subdirs # NOTES: -# - Does not properly handle "." in SUBDIRS. # - SUBDIRS must be defined BEFORE including this file. This is a # side-effect of the implementation: make expands this var # at compile time, so to say, so it can build the proper subdir # targets. Adding to the SUBDIRS var later doesn't affect which targets -# get created. +# get created, but ARE necessary for targets like install-subdirs :/. +# +# DO NOT put "." in the SUBDIRS! +# + # toc_make_subdirs call()able function: # $1 = list of dirs # $2 = target toc_make_subdirs = \ test "x$(1)" = "x" && exit 0; \ - tgt="$(2)"; test -z "$$tgt" && tgt="all"; \ - for b in $(1) ""; do test -z "$$b" && continue; \ + tgt="$(2)"; test x = "x$$tgt" && tgt="all"; \ + for b in $(1) "x"; do test "x" = "$$b" && break; \ pwd=$$(pwd); \ cd $$pwd/$$b || exit; \ echo "Making $$tgt in $$pwd/$${b}"; \ - ${MAKE} $$tgt || exit; \ + ${MAKE} --no-print-directory $$tgt || exit; \ cd $$pwd || exit; \ done -SUBDIRS_CLEANERS = $(patsubst %,clean-%,$(SUBDIRS)) -SUBDIRS_DISTCLEANERS = $(patsubst %,distclean-%,$(SUBDIRS)) -$(SUBDIRS_CLEANERS) $(SUBDIRS_DISTCLEANERS): - @dir=$@;target=$$dir; dir=$${dir##*-}; target=$${target%%-*}; \ - ${MAKE} -C $$dir $$target - -.PHONY: subdirs $(SUBDIRS) $(SUBDIRS_CLEANERS) $(SUBDIRS_DISTCLEANERS) \ - distclean-subdirs clean-subdirs +.PHONY: subdirs distclean-subdirs clean-subdirs $(SUBDIRS) +# note that this only works for subdirs defined BEFORE including this file: $(SUBDIRS): - @$(call toc_make_subdirs,$@) + ${MAKE} -C $@ +# @$(call toc_make_subdirs,$@) -# make $* as a subdirectory: -subdir-%: # makes $* subdir - @$(call toc_make_subdirs,$*) -clean-%: # cleans $* subdir - @$(call toc_make_subdirs,$*,clean) -# @test -d "$*" || exit 0; -distclean-%: - @$(call toc_make_subdirs,$*,distclean) -subdirs-%: # calls $* target in all $(SUBDIRS) + +subdir-%: # make $* as a subdirectory + @test "x$*" = "x." && exit 0; $(call toc_make_subdirs,$*) + +subdirs-%: ## calls $* target in all $(SUBDIRS) @$(call toc_make_subdirs,$(SUBDIRS),$*) subdirs: $(addprefix subdir-,$(SUBDIRS)) +#subdirs: subdirs-all +# ${MAKE} $(addprefix subdir-,$(SUBDIRS)) +#subdirs-all +# @$(call toc_make_subdirs,$(SUBDIRS),all) -clean-subdirs: $(patsubst %,clean-%,$(SUBDIRS)) - -distclean-subdirs: $(patsubst %,distclean-%,$(SUBDIRS)) |