Merge branch 'micro' into maint
[platform/upstream/automake.git] / t / recurs-user-indir.sh
1 #! /bin/sh
2 # Copyright (C) 2012-2013 Free Software Foundation, Inc.
3 #
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.
8 #
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.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17 # Check that user recursion works with various types of indirections
18 # *involved in the definition of the '*-local' targets*: make macros,
19 # AC_SUBST'd strings, automake-time file inclusions, automake
20 # conditionals...
21
22 . test-init.sh
23
24 cat >> configure.ac <<'END'
25 AC_CONFIG_FILES([
26     sub1/Makefile
27     sub1/subsub/Makefile
28     sub2/Makefile
29     sub2/subsub/Makefile
30 ])
31 AM_EXTRA_RECURSIVE_TARGETS([foo])
32 AC_SUBST([FOO_LOCAL], [foo-local])
33 AM_CONDITIONAL([COND], [:])
34 AC_OUTPUT
35 END
36
37 mkdir sub1 sub1/subsub sub2 sub2/subsub
38
39 cat > Makefile.am <<'END'
40 SUBDIRS = sub1 sub2
41 AM_FOO_LOCAL = foo-local
42
43 $(AM_FOO_LOCAL):
44         pwd && : > foo
45 CLEANFILES = foo
46
47 all-local: foo
48 check-local:
49         test -f foo
50         test -f sub1/foo
51         test -f sub1/subsub/foo
52         test -f sub2/foo
53         test -f sub2/subsub/foo
54         test ! -r sub2/subsub/bar
55 END
56
57 cat > sub1/Makefile.am <<'END'
58 SUBDIRS = subsub
59 @FOO_LOCAL@:
60         pwd && : > foo
61 CLEANFILES = foo
62 END
63
64 cat > sub1/subsub/Makefile.am <<'END'
65 $(FOO_LOCAL):
66         pwd && : > foo
67 CLEANFILES = foo
68 END
69
70 cat > sub2/Makefile.am <<'END'
71 include $(srcdir)/bar.am
72 include $(srcdir)/baz.am
73 CLEANFILES = foo
74 END
75
76 echo 'SUBDIRS = subsub' > sub2/bar.am
77 echo 'foo-local: ; pwd && : > foo' > sub2/baz.am
78
79 cat > sub2/subsub/Makefile.am <<'END'
80 if COND
81 foo-local:
82         pwd && : > foo
83 CLEANFILES = foo
84 else !COND
85 foo-local:
86         pwd && : > bar
87 endif !COND
88 END
89
90 $ACLOCAL
91 $AUTOCONF
92 $AUTOMAKE
93
94 ./configure
95
96 $MAKE check
97 $MAKE distcheck
98
99 :