tests: cosmetic changes in t/extra-sources.sh
[platform/upstream/automake.git] / t / recurs-user-deeply-nested.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 recursion on user-defined targets can be made to work
18 # with "deeply" nested uses of $(SUBDIRS).
19
20 . test-init.sh
21
22 cat >> configure.ac <<'END'
23 AC_CONFIG_FILES([
24     sub1/Makefile
25     sub1/sub2/Makefile
26     sub1/sub2/sub3/Makefile
27     sub1/sub2/sub3/sub4/Makefile
28 ])
29 AM_EXTRA_RECURSIVE_TARGETS([foo])
30 AC_OUTPUT
31 END
32
33 dirs='sub1 sub1/sub2 sub1/sub2/sub3 sub1/sub2/sub3/sub4'
34
35 mkdir $dirs
36
37 cat > Makefile.am <<'END'
38 SUBDIRS = sub1
39
40 foo-local:
41         cp sub1/foo foo
42 MOSTLYCLEANFILES = foo
43
44 .PHONY: test
45 test:
46         echo 'It works!' > exp
47         diff exp foo
48         diff exp sub1/foo
49         test ! -f sub1/sub2/foo
50         test ! -f sub1/sub2/sub3/foo
51         diff exp sub1/sub2/sub3/sub4/foo
52         rm -f exp
53
54 all-local: foo
55 check-local: test
56 END
57
58 cat > sub1/Makefile.am <<'END'
59 SUBDIRS = sub2
60 foo-local:
61         test ! -f sub2/sub3/foo
62         cp sub2/sub3/sub4/foo foo
63 MOSTLYCLEANFILES = foo
64 END
65
66 # Here we deliberately lack an explicit definition the 'foo-local'
67 # target; that shouldn't stop 'foo' recursion into subdirectory
68 # 'sub3/sub4'.
69 echo SUBDIRS = sub3 > sub1/sub2/Makefile.am
70 echo SUBDIRS = sub4 > sub1/sub2/sub3/Makefile.am
71
72 cat > sub1/sub2/sub3/sub4/Makefile.am <<'END'
73 foo-local:
74         echo 'It works!' > foo
75 MOSTLYCLEANFILES = foo
76 END
77
78 $ACLOCAL
79 $AUTOCONF
80 $AUTOMAKE
81
82 for d in $dirs; do
83   $FGREP foo-am $d/Makefile.in || exit 1
84   case $d in
85     */sub4);;
86     *) $FGREP foo-recursive $d/Makefile.in || exit 1;;
87   esac
88 done
89
90 ./configure
91
92 $MAKE foo
93 $MAKE test
94
95 $MAKE distcheck
96
97 :