input file. Such a warning will also be present in the next
Autoconf version (2.70).
+* Cleaning rules:
+
+ - Recursive cleaning rules descends into the $(SUBDIRS) in the natural
+ order (as done by the other recursive rules), rather than in the
+ inverse order. They used to do that in order to work a round a
+ limitation in an older implementation of the automatic dependency
+ tracking support, but that limitation had been lifted years ago
+ already, when the automatic dependency tracking based on side-effects
+ of compilation had been introduced.
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
New in 1.12.1:
# (which will cause the Makefiles to be regenerated when you run 'make');
# (2) otherwise, pass the desired values on the 'make' command line.
-$(RECURSIVE_TARGETS):
+$(RECURSIVE_TARGETS) $(RECURSIVE_CLEAN_TARGETS):
## Using $failcom allows "-k" to keep its natural meaning when running a
## recursive rule.
@fail= failcom='exit 1'; \
done; \
dot_seen=no; \
target=`echo $@ | sed s/-recursive//`; \
- list='$(SUBDIRS)'; for subdir in $$list; do \
+## For distclean and maintainer-clean we make sure to use the full
+## list of subdirectories. We do this so that 'configure; make
+## distclean' really is a no-op, even if SUBDIRS is conditional.
+ case "$@" in \
+ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
+ *) list='$(SUBDIRS)' ;; \
+ esac; \
+ for subdir in $$list; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
dot_seen=yes; \
distclean: distclean-recursive
maintainer-clean: maintainer-clean-recursive
-## We run all 'clean' targets in reverse order. Why? It's an attempt
-## to alleviate a problem that can happen when dependencies are
-## enabled. In this case, the .P file in one directory can depend on
-## some automatically generated header in an earlier directory. Since
-## the dependencies are required before any target is examined, make
-## bombs.
-$(RECURSIVE_CLEAN_TARGETS):
-## Using $failcom allows "-k" to keep its natural meaning when running a
-## recursive rule.
- @fail= failcom='exit 1'; \
- for f in x $$MAKEFLAGS; do \
- case $$f in \
- *=* | --[!k]*);; \
- *k*) failcom='fail=yes';; \
- esac; \
- done; \
- dot_seen=no; \
-## For distclean and maintainer-clean we make sure to use the full
-## list of subdirectories. We do this so that 'configure; make
-## distclean' really is a no-op, even if SUBDIRS is conditional. For
-## other clean targets this doesn't matter.
- case "$@" in \
- distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
- *) list='$(SUBDIRS)' ;; \
- esac; \
- rev=''; for subdir in $$list; do \
- if test "$$subdir" = "."; then :; else \
- rev="$$subdir $$rev"; \
- fi; \
- done; \
-## Always do '.' last.
- rev="$$rev ."; \
- target=`echo $@ | sed s/-recursive//`; \
- for subdir in $$rev; do \
- echo "Making $$target in $$subdir"; \
- if test "$$subdir" = "."; then \
- local_target="$$target-am"; \
- else \
- local_target="$$target"; \
- fi; \
- ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
- || eval $$failcom; \
- done && test -z "$$fail"
t/subdir8.sh \
t/subdir9.sh \
t/subdir10.sh \
+t/subdir-distclean.sh \
t/subdirbuiltsources.sh \
t/subcond.sh \
t/subcond2.sh \
--- /dev/null
+#! /bin/sh
+# Copyright (C) 2012 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Check that "./configure && make && make distclean" is actually a
+# no-op, even when conditional SUBDIRS are involved.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_CONFIG_FILES([sub1/Makefile sub2/Makefile sub1/subsub/Makefile])
+AM_CONDITIONAL([COND], [false])
+AC_SUBST([extra_subdirs], [''])
+AC_OUTPUT
+END
+
+mkdir sub1 sub2 sub1/subsub
+
+cat > Makefile.am << 'END'
+SUBDIRS = sub1
+if COND
+SUBDIRS += sub2
+endif
+END
+
+cat > sub1/Makefile.am << 'END'
+all-local:
+ : > run
+CLEANFILES = run
+SUBDIRS = @extra_subdirs@
+DIST_SUBDIRS = subsub
+END
+
+cat > sub2/Makefile.am << 'END'
+all-local:
+ @echo "Should not run in `pwd`!"
+ exit 1
+DISTCLEANFILES = oops
+END
+cp sub2/Makefile.am sub1/subsub/Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -c --add-missing
+
+./configure
+
+test -f sub1/Makefile
+test -f sub2/Makefile
+test -f sub1/subsub/Makefile
+
+$MAKE
+test -f sub1/run
+touch sub2/oops sub1/subsub/oops
+
+$MAKE distclean
+test ! -f sub1/run
+test ! -f sub2/oops
+test ! -f sub1/subsub/oops
+test ! -f sub1/Makefile
+test ! -f sub2/Makefile
+test ! -f sub1/subsub/Makefile
+
+mkdir build
+cd build
+
+../configure
+
+$MAKE
+
+test -f sub1/Makefile
+test -f sub2/Makefile
+test -f sub1/subsub/Makefile
+
+test -f sub1/run
+touch sub2/oops sub1/subsub/oops
+
+$MAKE -j4 maintainer-clean
+test ! -f sub1/run
+test ! -f sub2/oops
+test ! -f sub1/subsub/oops
+test ! -f sub1/Makefile
+test ! -f sub2/Makefile
+test ! -f sub1/subsub/Makefile
+
+cd ..
+
+./configure
+$MAKE distclean
+
+: