automake
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Recursive targets for the user


From: Stefano Lattarini
Subject: Re: Recursive targets for the user
Date: Wed, 6 Oct 2010 02:56:08 +0200
User-agent: KMail/1.13.3 (Linux/2.6.30-2-686; KDE/4.4.4; i686; ; )

Hi Ralf.

I'm resuming this oldish thread by answering to its first post, since
the previous discussion got a little sidetracked (mostly my fault, I
admit)...

On Sunday 01 August 2010, Ralf Wildenhues wrote:
> Somebody suggested to me (was that you, Ludo?) that Automake should
> really allow the user to easily add recursive targets.
> 
> This is fairly trivial to implement, the biggest complication is
> name calling.
> 
> So, here's the deal: currently, Automake has
>   RECURSIVE_TARGETS
>   RECURSIVE_CLEAN_TARGETS
>   AM_RECURSIVE_TARGETS
> 
> where the last is the union of the first and then some more, none
> of them are public interfaces, but at least the latter is used by,
> e.g., coreutils, to prevent invoking more than one of the
> recursive targets at once with parallel make.  Lastly, the deal is
> that each $target requires a non-pubic $target-am rule to actually
> do the work for the directory.
> 
> We cannot easily have Automake-defined variables to which the users
> add to (with +=), so let's have two sets of variables.  Questions:
> 
> 1) What to name them?
>   RECURSIVE_USER_TARGETS
>   RECURSIVE_USER_CLEAN_TARGETS
>   ALL_RECURSIVE_USER_TARGETS
> 
> or have the USER_ before RECURSIVE_?
IIRC, we agreed that the best name would be `EXTRA_RECURSIVE_TARGETS'.
Right?

> 2) Whether to rename the above and reuse the names for the user
> (cleaner interface but backward incompatible)?  So the internal
> one's would be, say,
> 
>   am_RECURSIVE_TARGETS
>   am_RECURSIVE_CLEAN_TARGETS
>   am_ALL_RECURSIVE_TARGETS
Unfortunately, it turned out (well, you found out ;-) that the names 
above (RECURSIVE_TARGETS etc.) are already used by third-party 
packages.  Still, I think that in the long run it would be a good
idea to go ahead with renamings:
  RECURSIVE_TARGETS => am__RECURSIVE_TARGETS
  RECURSIVE_CLEAN_TARGETS => am__RECURSIVE_CLEAN_TARGETS
  AM_RECURSIVE_TARGETS => am__AM_RECURSIVE_TARGETS
and deprecate the old RECURSIVE_TARGETS etc. names (while still 
retaining them until, say, Automake 1.13).  Then we could reuse them
properly -- so that e.g. `RECURSIVE_TARGETS' will be defined as the 
union of $(am__RECURSIVE_TARGETS) and $(EXTRA_RECURSIVE_TARGETS).

WDYT?

> 3) Whether to document the s/$/-am/ rule for the per-directory
> target so it then also holds for user-provided recursive rules.
> (If yes, then we could share the rule code text between both.)
What about getting rid of the old `foo-am' targets altogheter,
substituting them with `foo-local' instead, which is more natural and 
intuitive?  Then we could let the user implement his own recursive 
targets in a uniform fashion w.r.t. automake-generated recursive
targets (and thus also still share the rule code text).

In the meantime, I've written some test cases showing my ideas
about the implementation of recursive user targets (find them 
in the attached, tentative patch).

Comments are very welcome.

Regards,
   Stefano
From 48a85180c0acc25f8cf7b6f57d7d201e72f662cc Mon Sep 17 00:00:00 2001
From: Stefano Lattarini <address@hidden>
Date: Wed, 6 Oct 2010 02:37:30 +0200
Subject: [PATCH] New tests on planned feature "user recursive targets"

* tests/user-recurs-cond.test: New test.
* 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-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                   |   24 +++++++
 tests/Makefile.in                   |   24 +++++++
 tests/user-recurs-cond.test         |   77 ++++++++++++++++++++++
 tests/user-recurs-indir.test        |  122 +++++++++++++++++++++++++++++++++++
 tests/user-recurs-k1.test           |   88 +++++++++++++++++++++++++
 tests/user-recurs-k2.test           |   90 ++++++++++++++++++++++++++
 tests/user-recurs-many.test         |   69 ++++++++++++++++++++
 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-order.test        |   65 ++++++++++++++++++
 tests/user-recurs-override.test     |   60 +++++++++++++++++
 tests/user-recurs-phony.test        |   63 ++++++++++++++++++
 14 files changed, 990 insertions(+), 0 deletions(-)
 create mode 100755 tests/user-recurs-cond.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-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..9e6b745 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -21,6 +21,18 @@ all.test \
 auxdir2.test \
 cond17.test \
 gcj6.test \
+user-recurs-cond.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-order.test \
+user-recurs-override.test \
+user-recurs-phony.test \
 txinfo5.test
 
 include $(srcdir)/parallel-tests.am
@@ -752,6 +764,18 @@ unused.test \
 upc.test \
 upc2.test \
 upc3.test \
+user-recurs-cond.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-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..b08b898 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -277,6 +277,18 @@ all.test \
 auxdir2.test \
 cond17.test \
 gcj6.test \
+user-recurs-cond.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-order.test \
+user-recurs-override.test \
+user-recurs-phony.test \
 txinfo5.test
 
 parallel_tests = \
@@ -1019,6 +1031,18 @@ unused.test \
 upc.test \
 upc2.test \
 upc3.test \
+user-recurs-cond.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-order.test \
+user-recurs-override.test \
+user-recurs-phony.test \
 vala.test \
 vala1.test \
 vala2.test \
diff --git a/tests/user-recurs-cond.test b/tests/user-recurs-cond.test
new file mode 100755
index 0000000..772040c
--- /dev/null
+++ b/tests/user-recurs-cond.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:
+       : > $@
+CLEANFILES = foo
+END
+
+cat > sub2/Makefile.am <<'END'
+foo:
+       @echo ERROR: target foo 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-indir.test b/tests/user-recurs-indir.test
new file mode 100755
index 0000000..2a8fde5
--- /dev/null
+++ b/tests/user-recurs-indir.test
@@ -0,0 +1,122 @@
+#! /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
+    sub2/subsub/subsubsub/Makefile
+])
+AC_SUBST([ac__FOO_LOCAL], [foo-local])
+AM_CONDITIONAL([COND_GOOD], [:])
+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 -f sub2/subsub/subsubsub/bar
+       test ! -r sub2/subsub/subsubsub/foo
+END
+
+cat > sub1/Makefile.am <<'END'
+EXTRA_RECURSIVE_TARGETS = foo
+SUBDIRS = subsub
address@hidden@:
+       : > foo
+CLEANFILES = foo
+END
+
+cat > sub1/subsub/Makefile.am <<'END'
+empty =
+f$(empty)o$(empty)o$(empty):
+       : > $@
+CLEANFILES = foo
+END
+
+cat > sub2/Makefile.am <<'END'
+include $(srcdir)/bar.am
+SUBDIRS = subsub
+include $(srcdir)/baz.am
+CLEANFILES = foo
+END
+
+cat > sub2/bar.am <<'END'
+EXTRA_RECURSIVE_TARGETS = foo
+END
+
+cat > sub2/baz.am <<'END'
+foo-local:
+       : > foo
+END
+
+cat > sub2/subsub/Makefile.am <<'END'
+SUBDIRS = subsubsub
+if COND_BAD
+EXTRA_RECURSIVE_TARGETS = foo
+endif
+if COND_GOOD
+foo-local:
+       : > foo
+endif
+CLEANFILES = foo
+END
+
+cat > sub2/subsub/subsubsub/Makefile.am <<'END'
+foo:
+       @echo ERROR: foo in sub2/subsub/subsubsub should not be run >&2
+       @exit 1
+bar:
+       : > bar
+CLEANFILES = bar
+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..cd5fc9a
--- /dev/null
+++ b/tests/user-recurs-k1.test
@@ -0,0 +1,88 @@
+#! /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
+    sub1/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 = sub1/subsub1
+foo-local:; @PASS@
+END
+
+cat > sub1/subsub1/Makefile.am <<'END'
+foo:; @FAIL@
+END
+
+cat > sub2/Makefile.am <<'END'
+SUBDIRS = sub2/subsub2
+foo-local:; @FAIL@
+END
+
+cat > sub2/subsub2/Makefile.am <<'END'
+foo:; @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 || : # don't trust the exit status of `make -k'
+
+find . -name foo > got || { cat got; Exit 1; }
+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..7eda957
--- /dev/null
+++ b/tests/user-recurs-k2.test
@@ -0,0 +1,90 @@
+#! /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
+    sub1/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 = sub1/subsub1
+foo-local:; @PASS@
+END
+
+cat > sub1/subsub1/Makefile.am <<'END'
+foo:; @FAIL@
+END
+
+cat > sub2/Makefile.am <<'END'
+SUBDIRS = sub2/subsub2
+foo-local:; @FAIL@
+END
+
+cat > sub2/subsub2/Makefile.am <<'END'
+foo:; @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 && Exit 1
+
+find . -name foo > got || { cat got; Exit 1; }
+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..797c25b
--- /dev/null
+++ b/tests/user-recurs-many.test
@@ -0,0 +1,69 @@
+#! /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 sub1 sub2
+
+cat > Makefile.am <<'END'
+EXTRA_RECURSIVE_TARGETS = foo \
+       bar
+## NOTE: leading tab 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
+check-local:
+       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 bar:
+       : > $@
+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..be32dc2
--- /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:
+       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..1ebb100
--- /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..cba7bea
--- /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:
+       : > $@
+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..1ea0e94
--- /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-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..594d8df
--- /dev/null
+++ b/tests/user-recurs-override.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 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
+all-local: foo
+foo: ## *not* foo-local!
+       : > bar
+MOSTLYCLEANFILES = bar
+check-local:
+       test -f bar
+       test ! -r sub/foo
+END
+
+mkdir sub
+cat > sub/Makefile.am <<'END'
+foo:
+       : > $@
+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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]