maint: Update HACKING
[automake.git] / t / recurs-user2.sh
blob882a0d39517e7dab95ce34c21fb47317e3e50618
1 #! /bin/sh
2 # Copyright (C) 2012-2017 Free Software Foundation, Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2, or (at your option)
7 # any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <https://www.gnu.org/licenses/>.
17 # Check that user recursion can be made to work when $(SUBDIRS) are
18 # not "strictly" nested, as in e.g.:
19 # SUBDIRS = src external/lib external/tests
20 # with no Makefile in 'external'.
22 . test-init.sh
24 cat >> configure.ac <<'END'
25 AC_CONFIG_FILES(
26 sub1/Makefile
27 sub2/Makefile
28 dnl There's deliberately no 'sub3/Makefile'.
29 sub3/subsub/Makefile
30 sub4/Makefile
31 sub4/subsub/Makefile
33 AM_EXTRA_RECURSIVE_TARGETS([foo])
34 AC_OUTPUT
35 END
37 mkdir sub1 sub2 sub3 sub4 sub3/subsub sub4/subsub
39 cat > Makefile.am <<'END'
40 SUBDIRS = sub1 sub2 sub3/subsub sub4 sub4/subsub
42 foo-local:
43 echo _rootdir_ >foo
44 MOSTLYCLEANFILES = foo
46 .PHONY: test
47 test: foo
48 grep _rootdir_ foo
49 grep ':sub1:' sub1/foo
50 grep ',sub1,' sub1/bar
51 test ! -r sub2/foo
52 test ! -r sub3/foo
53 grep '%sub3/subsub%' sub3/subsub/quux
54 test ! -r sub3/subsub/foo
55 test ! -r sub4/foo
56 grep '=sub4/subsub=' sub4/subsub/foo
58 check-local: test
59 END
61 # A 'foo-local' target with dependencies shouldn't cause problems.
62 cat > sub1/Makefile.am <<'END'
63 foo-local: bar
64 sed 's/,/:/g' bar >foo
65 bar:
66 echo ',sub1,' >$@
67 MOSTLYCLEANFILES = foo bar
68 END
70 # The lack of a 'foo' target here shouldn't cause any error in
71 # automake nor in make.
72 : > sub2/Makefile.am
74 # The lack of file 'sub3/Makefile.am' shouldn't cause any problem either.
75 rm -f sub3/Makefile.am
77 # A 'foo-local' creating a file != 'foo' shouldn't cause any problem.
78 cat > sub3/subsub/Makefile.am <<'END'
79 foo-local:
80 echo '%sub3/subsub%' >quux
81 MOSTLYCLEANFILES = quux
82 END
84 # No 'foo-local' nor 'foo' target here ...
85 : > sub4/Makefile.am
86 # ... should not cause errors, nor cause the 'foo-local' target
87 # here not to be executed.
88 cat > sub4/subsub/Makefile.am <<'END'
89 foo-local:
90 echo '=sub4/subsub=' >foo
91 MOSTLYCLEANFILES = foo
92 END
94 $ACLOCAL
95 $AUTOCONF
96 $AUTOMAKE
98 ./configure
100 $MAKE test
101 $MAKE distcheck