Hello Automakers. After some experimenting, I've refined my ideas a bit (they're still somewhat muddy and rough at the edges, though). Below are the details. Comments welcome.
-*-*-*- Expected features of user recursive targets in Automake: + User recursive targets can be defined through the use of a new make variable `EXTRA_RECURSIVE_TARGETS'. We should hopefully be able to support automake conditionals in its definition; but apart from that, the variable's content will probably have to be literal -- i.e. no AC_SUBST'd stuff and no make macros: EXTRA_RECURSIVE_TARGETS = @FOO@ $(BAR) ## won't work + Definition of `EXTRA_RECURSIVE_TARGETS' in a Makefile.am with SUBDIRS defined should be *recursively* propageted into all Makefiles in all the $(SUBDIRS). Thus, if `Makefile.am' contains: SUBDIRS = sub EXTRA_RECURSIVE_TARGETS = foo then the generated `sub/Makefile.in' should contain the definition `EXTRA_RECURSIVE_TARGETS = foo' too, even if such definition is *not* in `sub/Makefile.am'. + "Leaf" Makefiles (which don't define SUBDIRS) should not contain the recursion code (like the one in `lib/subdirs.am'), but should still be able to properly cope with `foo-local' targets, if they have inherited `foo' in `EXTRA_RECURSIVE_TARGETS' from their upper-level Makefiles. Thus, with the following setup: $ cat Makefile.am SUBDIRS = sub EXTRA_RECURSIVE_TARGETS = foo $ cat sub/Makefile.am foo-local: touch bar running `make' in the top-level directory should create the file `sub/bar'. + It should be possible to define `EXTRA_RECURSIVE_TARGETS' to unrelated and inconsistent values in Makefiles that do not share a "parent" Makefile through `SUBDIRS'. This would be a very unusual setup, though, and thus supporting it is quite low-priority. + All the `foo' recursive targets and their associated `foo-local' targets should proably be declared as .PHONY. Unresolved questions: + How to cope with explicit definition of `EXTRA_RECURSIVE_TARGETS' in sub-Makefiles? Should we add the contents of this definition to the contents inherited from upper-level Makefile, and then propagate this combined content to the lower-level Makefiles? And if yes, do we need to properly remove duplicates? Or it would be better to just error out, thus reserving the `EXTRA_RECURSIVE_TARGETS' for the top-level (or isolated) Makefiles? (For simplicitly's sake, I'd go with this last behaviour). + What would be the best plan to improve consistency between the recursive targets defined by the user and those defined automatically/internally by automake? Should we even care about consistency here? -*-*-*- An amended version of the testcases for the just-sketched design is contained in the attached patch; compared to the previous version, these testcases present both semantic changes and various bugfixes. Comments welcome! Regards, Stefano
From 60f1384c4d39ffc8bf537a32bd76f840e34ca613 Mon Sep 17 00:00:00 2001 From: Stefano Lattarini <stefano.lattar...@gmail.com> Date: Wed, 6 Oct 2010 02:37:30 +0200 Subject: [PATCH] New tests on planned feature "user recursive targets" * tests/user-recurs-cond1.test: New test. * tests/user-recurs-cond2.test: New test. * tests/user-recurs-envclean.test: likewise. * tests/user-recurs-indir.test: Likewise. * tests/user-recurs-k1.test: Likewise. * tests/user-recurs-k2.test: Likewise. * tests/user-recurs-many.test: Likewise. * tests/user-recurs-nested.test: Likewise. * tests/user-recurs-no-subdirs.test: Likewise. * tests/user-recurs-no-top-level.test: Likewise. * tests/user-recurs-not-nested.test: Likewise. * tests/user-recurs-only-dot.test: Likewise. * tests/user-recurs-order.test: Likewise. * tests/user-recurs-override.test: Likewise. * tests/user-recurs-phony.test: Likewise. * tests/Makefile.am (TESTS, XFAIL_TESTS): Updated. --- tests/Makefile.am | 30 ++++++++++ tests/Makefile.in | 30 ++++++++++ tests/user-recurs-cond1.test | 77 +++++++++++++++++++++++++ tests/user-recurs-cond2.test | 82 ++++++++++++++++++++++++++ tests/user-recurs-envclean.test | 53 +++++++++++++++++ tests/user-recurs-indir.test | 108 +++++++++++++++++++++++++++++++++++ tests/user-recurs-k1.test | 89 ++++++++++++++++++++++++++++ tests/user-recurs-k2.test | 91 +++++++++++++++++++++++++++++ tests/user-recurs-many.test | 71 +++++++++++++++++++++++ tests/user-recurs-nested.test | 87 ++++++++++++++++++++++++++++ tests/user-recurs-no-subdirs.test | 60 +++++++++++++++++++ tests/user-recurs-no-top-level.test | 56 ++++++++++++++++++ tests/user-recurs-not-nested.test | 105 ++++++++++++++++++++++++++++++++++ tests/user-recurs-only-dot.test | 50 ++++++++++++++++ tests/user-recurs-order.test | 65 +++++++++++++++++++++ tests/user-recurs-override.test | 67 +++++++++++++++++++++ tests/user-recurs-phony.test | 63 ++++++++++++++++++++ 17 files changed, 1184 insertions(+), 0 deletions(-) create mode 100755 tests/user-recurs-cond1.test create mode 100755 tests/user-recurs-cond2.test create mode 100755 tests/user-recurs-envclean.test create mode 100755 tests/user-recurs-indir.test create mode 100755 tests/user-recurs-k1.test create mode 100755 tests/user-recurs-k2.test create mode 100755 tests/user-recurs-many.test create mode 100755 tests/user-recurs-nested.test create mode 100755 tests/user-recurs-no-subdirs.test create mode 100755 tests/user-recurs-no-top-level.test create mode 100755 tests/user-recurs-not-nested.test create mode 100755 tests/user-recurs-only-dot.test create mode 100755 tests/user-recurs-order.test create mode 100755 tests/user-recurs-override.test create mode 100755 tests/user-recurs-phony.test diff --git a/tests/Makefile.am b/tests/Makefile.am index 2755253..f33bf1c 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -21,6 +21,21 @@ all.test \ auxdir2.test \ cond17.test \ gcj6.test \ +user-recurs-cond1.test \ +user-recurs-cond2.test \ +user-recurs-envclean.test \ +user-recurs-indir.test \ +user-recurs-k1.test \ +user-recurs-k2.test \ +user-recurs-many.test \ +user-recurs-nested.test \ +user-recurs-no-subdirs.test \ +user-recurs-no-top-level.test \ +user-recurs-not-nested.test \ +user-recurs-only-dot.test \ +user-recurs-order.test \ +user-recurs-override.test \ +user-recurs-phony.test \ txinfo5.test include $(srcdir)/parallel-tests.am @@ -752,6 +767,21 @@ unused.test \ upc.test \ upc2.test \ upc3.test \ +user-recurs-cond1.test \ +user-recurs-cond2.test \ +user-recurs-envclean.test \ +user-recurs-indir.test \ +user-recurs-k1.test \ +user-recurs-k2.test \ +user-recurs-many.test \ +user-recurs-nested.test \ +user-recurs-no-subdirs.test \ +user-recurs-no-top-level.test \ +user-recurs-not-nested.test \ +user-recurs-only-dot.test \ +user-recurs-order.test \ +user-recurs-override.test \ +user-recurs-phony.test \ vala.test \ vala1.test \ vala2.test \ diff --git a/tests/Makefile.in b/tests/Makefile.in index 2699f0a..ee6d262 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -277,6 +277,21 @@ all.test \ auxdir2.test \ cond17.test \ gcj6.test \ +user-recurs-cond1.test \ +user-recurs-cond2.test \ +user-recurs-envclean.test \ +user-recurs-indir.test \ +user-recurs-k1.test \ +user-recurs-k2.test \ +user-recurs-many.test \ +user-recurs-nested.test \ +user-recurs-no-subdirs.test \ +user-recurs-no-top-level.test \ +user-recurs-not-nested.test \ +user-recurs-only-dot.test \ +user-recurs-order.test \ +user-recurs-override.test \ +user-recurs-phony.test \ txinfo5.test parallel_tests = \ @@ -1019,6 +1034,21 @@ unused.test \ upc.test \ upc2.test \ upc3.test \ +user-recurs-cond1.test \ +user-recurs-cond2.test \ +user-recurs-envclean.test \ +user-recurs-indir.test \ +user-recurs-k1.test \ +user-recurs-k2.test \ +user-recurs-many.test \ +user-recurs-nested.test \ +user-recurs-no-subdirs.test \ +user-recurs-no-top-level.test \ +user-recurs-not-nested.test \ +user-recurs-only-dot.test \ +user-recurs-order.test \ +user-recurs-override.test \ +user-recurs-phony.test \ vala.test \ vala1.test \ vala2.test \ diff --git a/tests/user-recurs-cond1.test b/tests/user-recurs-cond1.test new file mode 100755 index 0000000..39d5203 --- /dev/null +++ b/tests/user-recurs-cond1.test @@ -0,0 +1,77 @@ +#! /bin/sh +# Copyright (C) 2010 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 user-defined recursive targets works with +# conditionally-defined $(SUBDIRS). + +. ./defs || Exit 1 + +set -e + +cat >> configure.in << 'END' +AC_CONFIG_FILES([sub1/Makefile sub2/Makefile]) +AM_CONDITIONAL([COND_GOOD], [:]) +AM_CONDITIONAL([COND_BAD], [false]) +AC_OUTPUT +END + +mkdir sub1 sub2 + +cat > Makefile.am <<'END' +EXTRA_RECURSIVE_TARGETS = foo +DIST_SUBDIRS = sub1 sub2 + +SUBDIRS = +if COND_GOOD + SUBDIRS += sub1 +else + SUBDIRS += nonexistent +endif +if COND_BAD + SUBDIRS += sub2 +else + foo-local:; : > foo +endif + +all-local: foo +check-local: + test -f foo + test -f sub1/foo + test ! -r sub2/foo +END + +cat > sub1/Makefile.am <<'END' +foo-local: + : > $@ +CLEANFILES = foo +END + +cat > sub2/Makefile.am <<'END' +foo-local: + @echo 'ERROR: target "$@" in sub2/Makefile should not be run' >&2 + @exit 1 +END + +$ACLOCAL +$AUTOCONF +$AUTOMAKE + +./configure + +$MAKE check +$MAKE distcheck + +: diff --git a/tests/user-recurs-cond2.test b/tests/user-recurs-cond2.test new file mode 100755 index 0000000..6dbc64b --- /dev/null +++ b/tests/user-recurs-cond2.test @@ -0,0 +1,82 @@ +#! /bin/sh +# Copyright (C) 2010 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 user-defined recursive targets works with +# conditionally-defined $(EXTRA_RECURSIVE_TARGETS). + +. ./defs || Exit 1 + +set -e + +cat >> configure.in << 'END' +AC_CONFIG_FILES([sub/Makefile]) +AM_CONDITIONAL([COND_GOOD], [:]) +AM_CONDITIONAL([COND_BAD], [false]) +AC_OUTPUT +END + +mkdir sub1 sub2 + +cat > Makefile.am <<'END' +SUBDIRS = sub + +if COND_GOOD +EXTRA_RECURSIVE_TARGETS = foo +bar: +else !COND_GOOD +EXTRA_RECURSIVE_TARGETS = bar +foo: +endif !COND_GOOD + +if COND_BAD +EXTRA_RECURSIVE_TARGETS += baz +else !COND_BAD +baz: +endif !COND_BAD + +foo-local:; : > foo +bar-local:; : > bar +baz-local:; : > baz + +all-local: foo bar quux + +check-local: + test -f foo + test -f sub/foo + test ! -r bar + test ! -r sub/bar + test ! -r baz + test ! -r sub/baz +END + +cat > sub/Makefile.am <<'END' +## Declare this targets and associated rules in a different way than done +## in top-level Makefile.am. +foo-local bar-local baz-local: + touch `echo $@ | sed 's/-local$$//'` +CLEANFILES = foo +END + +$ACLOCAL +$AUTOCONF +$AUTOMAKE + +./configure + +$MAKE check +$MAKE distcheck + +: diff --git a/tests/user-recurs-envclean.test b/tests/user-recurs-envclean.test new file mode 100755 index 0000000..e5b1155 --- /dev/null +++ b/tests/user-recurs-envclean.test @@ -0,0 +1,53 @@ +#! /bin/sh +# Copyright (C) 2010 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 setting `EXTRA_RECURSIVE_TARGETS' from the environment do +# not cause user recursion machinery to be activated. + +. ./defs || Exit 1 + +set -e + +cat >> configure.in << 'END' +AC_CONFIG_FILES([sub/Makefile]) +AC_OUTPUT +END + +mkdir sub + +cat > Makefile.am <<'END' +SUBDIRS = sub +END + +cat > sub/Makefile.am <<'END' +foo-local: + : > bar1 +foo: + : > bar2 +END + +$ACLOCAL +$AUTOCONF +$AUTOMAKE + +./configure + +EXTRA_RECURSIVE_TARGETS=foo $MAKE # sanity check +EXTRA_RECURSIVE_TARGETS=foo $MAKE foo && Exit 1 +test ! -r sub/bar1 +test ! -r sub/bar2 + +: diff --git a/tests/user-recurs-indir.test b/tests/user-recurs-indir.test new file mode 100755 index 0000000..a0c3a1c --- /dev/null +++ b/tests/user-recurs-indir.test @@ -0,0 +1,108 @@ +#! /bin/sh +# Copyright (C) 2010 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 user recursion works with various types of indirections: +# make macros, AC_SUBST'd strings, automake-time file inclusions, +# automake conditionals... + +. ./defs || Exit 1 + +set -e + +cat >> configure.in <<'END' +AC_CONFIG_FILES([ + sub1/Makefile + sub1/subsub/Makefile + sub2/Makefile + sub2/subsub/Makefile +]) +AC_SUBST([ac__FOO_LOCAL], [foo-local]) +AM_CONDITIONAL([COND], [:]) +AM_CONDITIONAL([COND_BAD], [false]) +AC_OUTPUT +END + +mkdir sub1 sub1/subsub sub2 sub2/subsub sub2/subsub/subsubsub + +cat > Makefile.am <<'END' +EXTRA_RECURSIVE_TARGETS = foo +SUBDIRS = sub1 sub2 + +am__FOO_LOCAL = foo-local +$(am__FOO_LOCAL): + : > foo +CLEANFILES = foo + +all-local: foo +check-local: + test -f foo + test -f sub1/foo + test -f sub1/subsub/foo + test -f sub2/foo + test -f sub2/subsub/foo + test ! -r sub2/subsub/bar +END + +cat > sub1/Makefile.am <<'END' +SUBDIRS = subsub +...@ac__foo_local@: + : > foo +CLEANFILES = foo +END + +cat > sub1/subsub/Makefile.am <<'END' +e = +f$(e)o$(e)o$(e)-$(e)l$(e)o$(e)c$(e)a$(e)l: + : > foo +CLEANFILES = foo +END + +cat > sub2/Makefile.am <<'END' +include $(srcdir)/bar.am +include $(srcdir)/baz.am +CLEANFILES = foo +END + +cat > sub2/bar.am <<'END' +SUBDIRS = subsub +END + +cat > sub2/baz.am <<'END' +foo-local: + : > foo +END + +cat > sub2/subsub/Makefile.am <<'END' +if COND +foo-local: + : > foo +else !COND +foo-local: + : > bar +endif !COND +CLEANFILES = foo +END + +$ACLOCAL +$AUTOCONF +$AUTOMAKE + +./configure + +$MAKE check +$MAKE distcheck + +: diff --git a/tests/user-recurs-k1.test b/tests/user-recurs-k1.test new file mode 100755 index 0000000..05ebe5b --- /dev/null +++ b/tests/user-recurs-k1.test @@ -0,0 +1,89 @@ +#! /bin/sh +# Copyright (C) 2010 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 user recursion works with `make -k'. +# Please keep this in sync with syster test `user-recurs-k2.test'. + +. ./defs || Exit 1 + +set -e + +cat >> configure.in <<'END' +AC_CONFIG_FILES([ + sub1/Makefile + sub1/subsub1/Makefile + sub2/Makefile + sub2/subsub2/Makefile + sub3/Makefile +]) +FAIL='@echo "FAIL $@ in `pwd`"; exit 1' +PASS='@echo "PASS $@ in `pwd`"; : > foo' +AC_SUBST([FAIL]) +AC_SUBST([PASS]) +AC_OUTPUT +END + +mkdir sub1 sub1/subsub1 sub2 sub2/subsub2 sub3 + +cat > Makefile.am <<'END' +SUBDIRS = sub1 . sub2 sub3 +EXTRA_RECURSIVE_TARGETS = foo +foo-local:; @FAIL@ +END + +cat > sub1/Makefile.am <<'END' +SUBDIRS = subsub1 +foo-local:; @PASS@ +END + +cat > sub1/subsub1/Makefile.am <<'END' +foo-local:; @FAIL@ +END + +cat > sub2/Makefile.am <<'END' +SUBDIRS = subsub2 +foo-local:; @FAIL@ +END + +cat > sub2/subsub2/Makefile.am <<'END' +foo-local:; @PASS@ +END + +cat > sub3/Makefile.am <<'END' +foo-local:; @PASS@ +END + +$ACLOCAL +$AUTOCONF +$AUTOMAKE + +./configure + +cat > exp <<END +./sub1/foo +./sub2/subsub2/foo +./sub3/foo +END + +$MAKE -k foo || : # don't trust the exit status of `make -k' + +find . -name foo > t || { cat t; Exit 1; } +LC_ALL=C sort t > got +cat exp +cat got +diff exp got + +: diff --git a/tests/user-recurs-k2.test b/tests/user-recurs-k2.test new file mode 100755 index 0000000..68bc8f6 --- /dev/null +++ b/tests/user-recurs-k2.test @@ -0,0 +1,91 @@ +#! /bin/sh +# Copyright (C) 2010 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 user recursion works with `make --keep-going'. +# Please keep this in sync with syster test `user-recurs-k1.test'. + +required=GNUmake +. ./defs || Exit 1 + +set -e + +cat >> configure.in <<'END' +AC_CONFIG_FILES([ + sub1/Makefile + sub1/subsub1/Makefile + sub2/Makefile + sub2/subsub2/Makefile + sub3/Makefile +]) +FAIL='@echo "FAIL $@ in `pwd`"; exit 1' +PASS='@echo "PASS $@ in `pwd`"; : > foo' +AC_SUBST([FAIL]) +AC_SUBST([PASS]) +AC_OUTPUT +END + +mkdir sub1 sub1/subsub1 sub2 sub2/subsub2 sub3 + +cat > Makefile.am <<'END' +SUBDIRS = sub1 . sub2 sub3 +EXTRA_RECURSIVE_TARGETS = foo +foo-local:; @FAIL@ +END + +cat > sub1/Makefile.am <<'END' +SUBDIRS = subsub1 +foo-local:; @PASS@ +END + +cat > sub1/subsub1/Makefile.am <<'END' +foo-local:; @FAIL@ +END + +cat > sub2/Makefile.am <<'END' +SUBDIRS = subsub2 +foo-local:; @FAIL@ +END + +cat > sub2/subsub2/Makefile.am <<'END' +foo-local:; @PASS@ +END + +cat > sub3/Makefile.am <<'END' +foo-local:; @PASS@ +END + +$ACLOCAL +$AUTOCONF +$AUTOMAKE + +./configure + +cat > exp <<END +./sub1/foo +./sub2/subsub2/foo +./sub3/foo +END + +# Trust the exit status of `make --keep-going' for GNU make. +$MAKE --keep-going foo && Exit 1 + +find . -name foo > t || { cat t; Exit 1; } +LC_ALL=C sort t > got +cat exp +cat got +diff exp got + +: diff --git a/tests/user-recurs-many.test b/tests/user-recurs-many.test new file mode 100755 index 0000000..813f652 --- /dev/null +++ b/tests/user-recurs-many.test @@ -0,0 +1,71 @@ +#! /bin/sh +# Copyright (C) 2010 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 many user-defined recursive targets can be supported +# at once, and their list properly extended. + +. ./defs || Exit 1 + +set -e + +cat >> configure.in <<'END' +AC_CONFIG_FILES([sub/Makefile]) +AM_CONDITIONAL([COND_GOOD], [:]) +AM_CONDITIONAL([COND_BAD], [false]) +AC_OUTPUT +END + +mkdir sub + +cat > Makefile.am <<'END' +## NOTE: extra white spaces in the line below: on purpose. +EXTRA_RECURSIVE_TARGETS = foo \ + bar +## NOTE: leading tab and trailing spaces in the line above: on purpose. +EXTRA_RECURSIVE_TARGETS += quux +SUBDIRS = sub + +quux-local bar-local: + touch `echo $@ | sed 's/-local$$//'` +CLEANFILES = quux bar + +all-local: foo bar quux +check-local: + ls -l . sub # for debugging + test -f quux + test -f bar + test ! -r foo + test -f sub/bar + test -f sub/foo + test ! -r sub/quux +END + +cat > sub/Makefile.am <<'END' +foo-local bar-local: + touch `echo $@ | sed 's/-local$$//'` +CLEANFILES = foo bar +END + +$ACLOCAL +$AUTOCONF +$AUTOMAKE + +./configure + +$MAKE check +$MAKE distcheck + +: diff --git a/tests/user-recurs-nested.test b/tests/user-recurs-nested.test new file mode 100755 index 0000000..9ba2350 --- /dev/null +++ b/tests/user-recurs-nested.test @@ -0,0 +1,87 @@ +#! /bin/sh +# Copyright (C) 2010 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 user recursion can be made to work with nested uses +# of $(SUBDIRS). + +. ./defs || Exit 1 + +set -e + +cat >> configure.in <<'END' +AC_CONFIG_FILES([ + sub1/Makefile + sub1/sub2/Makefile + sub1/sub2/sub3/Makefile +]) +AC_OUTPUT +END + +mkdir sub1 sub1/sub2 sub1/sub2/sub3 + +cat > Makefile.am <<'END' +EXTRA_RECURSIVE_TARGETS = foo +SUBDIRS = sub1 + +foo-local: + cp sub1/foo foo +MOSTLYCLEANFILES = foo + +.PHONY: test +test: + echo 'It works!' > exp + diff exp foo + diff exp sub1/foo + diff exp sub1/sub2/sub3/foo + rm -f exp + +all-local: foo +check-local: test +END + +cat > sub1/Makefile.am <<'END' +EXTRA_RECURSIVE_TARGETS = foo +SUBDIRS = sub2 +foo-local: + cp sub2/sub3/foo foo +MOSTLYCLEANFILES = foo +END + +# Here we lack definiton of `EXTRA_RECURSIVE_TARGETS' variable and of +# "foo-local" and "foo" targets, but this shouldn't stop "foo" recursion +# into subdirectory `sub3'. +cat > sub1/sub2/Makefile.am <<'END' +SUBDIRS = sub3 +END + +cat > sub1/sub2/sub3/Makefile.am <<'END' +foo-local: + echo 'It works!' > $@ +MOSTLYCLEANFILES = foo +END + +$ACLOCAL +$AUTOCONF +$AUTOMAKE + +./configure + +$MAKE foo +$MAKE test + +$MAKE distcheck + +: diff --git a/tests/user-recurs-no-subdirs.test b/tests/user-recurs-no-subdirs.test new file mode 100755 index 0000000..e40032e --- /dev/null +++ b/tests/user-recurs-no-subdirs.test @@ -0,0 +1,60 @@ +#! /bin/sh +# Copyright (C) 2010 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 user recursion can be made to work even when $(SUBDIRS) +# is empty or undefined. + +. ./defs || Exit 1 + +set -e + +cat >> configure.in <<'END' +AC_OUTPUT +END + +$ACLOCAL +$AUTOCONF + +cat > Makefile.am <<'END' +all-local: foo +foo-local: + : > bar +MOSTLYCLEANFILES = bar +check-local: test +.PHONY: test +test: + test -f bar +EXTRA_RECURSIVE_TARGETS = foo +END + +$AUTOMAKE +./configure +$MAKE foo +$MAKE test +$MAKE distcheck + +$MAKE distclean +test ! -r bar # sanity check + +# Now try with empty but defined $(SUBDIRS). +echo SUBDIRS = >> Makefile.am +$AUTOMAKE +./configure +$MAKE foo +$MAKE test +$MAKE distcheck + +: diff --git a/tests/user-recurs-no-top-level.test b/tests/user-recurs-no-top-level.test new file mode 100755 index 0000000..b635238 --- /dev/null +++ b/tests/user-recurs-no-top-level.test @@ -0,0 +1,56 @@ +#! /bin/sh +# Copyright (C) 2010 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 user recursion works even for targets that don't exist +# in the top-level Makefile. + +. ./defs || Exit 1 + +set -e + +cat >> configure.in <<'END' +AC_CONFIG_FILES([sub/Makefile]) +AC_OUTPUT +END + +mkdir sub + +cat > Makefile.am <<'END' +SUBDIRS = sub +EXTRA_RECURSIVE_TARGETS = foo-bar +all-local: foo-bar +check-local: + test -f sub/foo-bar +END + +cat > sub/Makefile.am <<'END' +foo-bar-local: + : > $@ +MOSTLYCLEANFILES = foo-bar +END + +$ACLOCAL +$AUTOCONF +$AUTOMAKE + +./configure + +$MAKE foo-bar +test -f sub/foo-bar + +$MAKE distcheck + +: diff --git a/tests/user-recurs-not-nested.test b/tests/user-recurs-not-nested.test new file mode 100755 index 0000000..b292f80 --- /dev/null +++ b/tests/user-recurs-not-nested.test @@ -0,0 +1,105 @@ +#! /bin/sh +# Copyright (C) 2010 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 user-defined recursive rules works; this is the simpler case +# when no "nested" definitions of $(SUBDIRS) are used. + +. ./defs || Exit 1 + +set -e + +cat >> configure.in <<'END' +AC_CONFIG_FILES([ + sub1/Makefile + sub2/Makefile +dnl ## There's deliberately no `sub3/Makefile'. + sub3/subsub/Makefile + sub4/Makefile + sub4/subsub/Makefile +]) +AC_OUTPUT +END + +mkdir sub1 sub2 sub3 sub4 sub3/subsub sub4/subsub + +cat > Makefile.am <<'END' +SUBDIRS = sub1 sub2 sub3 sub3/subsub sub4/subsub +EXTRA_RECURSIVE_TARGETS = foo + +foo-local: + echo _rootdir_ >foo +MOSTLYCLEANFILES = foo + +.PHONY: test +test: + grep _rootdir_ foo + grep :sub1: sub1/foo + grep ,sub1, sub1/bar + test ! -r sub2/foo + test ! -r sub3/foo + grep %sub3/subsub% sub3/subsub/quux + test ! -r sub3/subsub/foo + grep =sub3/subsub4= sub4/subsub/foo + +all-local: foo +check-local: test +END + +# A "foo-local" target with dependencies shouldn't cause problems. +cat > sub1/Makefile.am <<'END' +foo-local: bar + sed 's/,/:/g' bar >foo +bar: + echo ,sub1, >bar +MOSTLYCLEANFILES = foo bar +END + +# The lack of a "foo" target here shouldn't cause any error in +# automake nor in make. +: > sub2/Makefile.am + +# The lack of file "sub3/Makefile.am" shouldn't cause any problem either. +: # just don't create it + +# A "foo-local" creating a file != "foo" shouldn't cause any problem. +cat > sub3/subsub/Makefile.am <<'END' +foo-local: + echo %sub3/subsub% >quux +MOSTLYCLEANFILES = quux +END + +# No "foo-local" nor "foo" target here ... +: > sub4/Makefile.am +# ... should not cause errors, nor cause the "foo-local" target here +# not to be executed. +cat > sub4/subsub/Makefile.am <<'END' +foo-local: + echo =sub4/subsub= >foo +MOSTLYCLEANFILES = foo +END + +$ACLOCAL +$AUTOCONF +$AUTOMAKE + +./configure + +$MAKE foo +$MAKE test + +$MAKE distcheck + +: diff --git a/tests/user-recurs-only-dot.test b/tests/user-recurs-only-dot.test new file mode 100755 index 0000000..c784a2b --- /dev/null +++ b/tests/user-recurs-only-dot.test @@ -0,0 +1,50 @@ +#! /bin/sh +# Copyright (C) 2010 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 user-defined recursive rules works when $(SUBDIRS) contains +# only an current directory `.'. + +. ./defs || Exit 1 + +set -e + +cat >> configure.in << 'END' +AC_OUTPUT +END + +cat > Makefile.am <<'END' +SUBDIRS = . +EXTRA_RECURSIVE_TARGETS = foo +foo-local: + : > foo +MOSTLYCLEANFILES = foo +all-local: foo +check-local: + test -f foo +END + +$ACLOCAL +$AUTOCONF +$AUTOMAKE + +./configure + +$MAKE foo +test -f foo + +$MAKE distcheck + +: diff --git a/tests/user-recurs-order.test b/tests/user-recurs-order.test new file mode 100755 index 0000000..390a345 --- /dev/null +++ b/tests/user-recurs-order.test @@ -0,0 +1,65 @@ +#! /bin/sh +# Copyright (C) 2010 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 user recursion respect $(SUBDIRS) order. + +. ./defs || Exit 1 + +set -e + +cat >> configure.in << 'END' +AC_CONFIG_FILES([ + sub1/Makefile + sub2/Makefile + sub3/Makefile +]) +AC_OUTPUT +END + +mkdir sub1 sub2 sub3 + +cat > Makefile.am <<'END' +SUBDIRS = sub1 . sub3 sub2 +EXTRA_RECURSIVE_TARGETS = foo +foo-local: + echo '.' >> $(top_builddir)/got +.PHONY: test +test: + @(echo sub1 && echo . && echo sub3 && echo sub2) > exp + cat exp + cat got + diff exp got +all-local: foo +check-local: test +MOSTLYCLEANFILES = got exp +END + +for i in 1 2 3; do + echo "foo-local:; echo sub$i >> \$(top_builddir)/got" +done + +$ACLOCAL +$AUTOCONF +$AUTOMAKE + +./configure + +$MAKE foo +$MAKE test + +$MAKE distcheck + +: diff --git a/tests/user-recurs-override.test b/tests/user-recurs-override.test new file mode 100755 index 0000000..c3940d7 --- /dev/null +++ b/tests/user-recurs-override.test @@ -0,0 +1,67 @@ +#! /bin/sh +# Copyright (C) 2010 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 override of user-defined recursive targets work as +# expected. + +. ./defs || Exit 1 + +set -e + +cat >> configure.in << 'END' +AC_CONFIG_FILES([sub/Makefile]) +AC_OUTPUT +END + +cat > Makefile.am <<'END' +SUBDIRS = sub +EXTRA_RECURSIVE_TARGETS = foo bar +all-local: foo bar +foo: + : > foo.out +MOSTLYCLEANFILES = foo.out +check-local: + test -f foo.out + test ! -r sub/foo.out + test -f sub/bar.out + test ! -r sub/baz.out +END + +mkdir sub +cat > sub/Makefile.am <<'END' +foo-local foo: + : > foo.out +bar: + : > bar.out +bar-local: + : > baz.out +MOSTLYCLEANFILES = bar.out +END + +$ACLOCAL +$AUTOCONF + +AUTOMAKE_fails -Woverride +#FIXME: grep stderr for a proper error message here... + +$AUTOMAKE -Wno-override + +./configure + +$MAKE check +$MAKE distcheck + +: diff --git a/tests/user-recurs-phony.test b/tests/user-recurs-phony.test new file mode 100755 index 0000000..6547013 --- /dev/null +++ b/tests/user-recurs-phony.test @@ -0,0 +1,63 @@ +#! /bin/sh +# Copyright (C) 2010 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 user-defined recursive targets and their associate +# local targets are declared as phony. + +. ./defs || Exit 1 + +set -e + +cat >> configure.in << 'END' +AC_CONFIG_FILES([sub/Makefile]) +AC_OUTPUT +END + +cat > Makefile.am <<'END' +SUBDIRS = sub +EXTRA_RECURSIVE_TARGETS = foo +foo-local: + echo 'GOOD!' > foo + echo 'GOOD!' > foo-local +END + +mkdir sub +cat > sub/Makefile.am <<'END' +foo-local: + echo 'GOOD!' > foo + echo 'GOOD!' > foo-local +END + +files='foo foo-local sub/foo sub/foo-local' + +for f in $files; do + echo 'bad :-(' > $f +done + +$ACLOCAL +$AUTOCONF +$AUTOMAKE + +./configure + +$MAKE foo + +for f in $files; do + cat $f # for debugging + grep 'GOOD!' $f +done + +: -- 1.7.1