tests: prune some weed in a non-POSIX test
[platform/upstream/automake.git] / t / subdir-order.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 # The $(SUDBIRS) entries are processed in the order they are specified.
18
19 . test-init.sh
20
21 cat >> configure.ac << 'END'
22 AC_CONFIG_FILES([
23   sub0/Makefile
24   sub1/Makefile
25   sub2/Makefile
26   sub3/Makefile
27   sub3/a/Makefile
28   sub3/b/Makefile
29 ])
30 AC_OUTPUT
31 END
32
33 mkdir sub0 sub1 sub2 sub3 sub3/a sub3/b
34
35 cat > Makefile.am << 'END'
36 SUBDIRS = sub2 sub1 sub3 sub0
37 all-local:
38         test -f sub0/run
39         test -f sub1/run
40         test -f sub2/run
41         test -f sub3/run
42         test -f sub3/a/run
43         test -f sub3/b/run
44         test ! -f run
45         : > run
46
47 CLEANFILES = \
48   run \
49   sub0/run \
50   sub1/run \
51   sub2/run \
52   sub3/run \
53   sub3/a/run \
54   sub3/b/run
55 END
56
57 cat > sub0/Makefile.am << 'END'
58 all-local:
59         test ! -f $(top_builddir)/run
60         test -f $(top_builddir)/sub1/run
61         test -f $(top_builddir)/sub3/run
62         test -f $(top_builddir)/sub3/a/run
63         test -f $(top_builddir)/sub3/b/run
64         test ! -f run
65         : > run
66 END
67
68 cat > sub1/Makefile.am << 'END'
69 all-local:
70         test ! -f $(top_builddir)/run
71         test ! -f $(top_builddir)/sub0/run
72         test -f $(top_builddir)/sub2/run
73         test ! -f $(top_builddir)/sub3/run
74         test ! -f $(top_builddir)/sub3/a/run
75         test ! -f $(top_builddir)/sub3/b/run
76         test ! -f run
77         : > run
78 END
79
80
81 cat > sub2/Makefile.am << 'END'
82 all-local:
83         test ! -f $(top_builddir)/run
84         test ! -f $(top_builddir)/sub0/run
85         test ! -f $(top_builddir)/sub1/run
86         test ! -f $(top_builddir)/sub3/run
87         test ! -f $(top_builddir)/sub3/a/run
88         test ! -f $(top_builddir)/sub3/b/run
89         test ! -f run
90         : > run
91 END
92
93 cat > sub3/Makefile.am << 'END'
94 SUBDIRS = b . a
95 all-local:
96         test ! -f $(top_builddir)/run
97         test ! -f $(top_builddir)/sub0/run
98         test -f $(top_builddir)/sub1/run
99         test ! -f $(top_builddir)/sub3/a/run
100         test -f $(top_builddir)/sub3/b/run
101         test ! -f run
102         : > run
103 END
104
105 cat > sub3/a/Makefile.am << 'END'
106 all-local:
107         test ! -f $(top_builddir)/run
108         test ! -f $(top_builddir)/sub0/run
109         test -f $(top_builddir)/sub1/run
110         test -f $(top_builddir)/sub3/b/run
111         test -f $(top_builddir)/sub3/run
112         test ! -f run
113         : > run
114 END
115
116 cat > sub3/b/Makefile.am << 'END'
117 all-local:
118         test ! -f $(top_builddir)/run
119         test ! -f $(top_builddir)/sub0/run
120         test -f $(top_builddir)/sub1/run
121         test ! -f $(top_builddir)/sub3/b/run
122         test ! -f $(top_builddir)/sub3/run
123         test ! -f run
124         : > run
125 END
126
127 echo dummy: > Makefile
128 if using_gmake; then
129   jobs=-j12
130 elif $MAKE -j12; then
131   jobs=-j12
132 elif $MAKE -j 12; then
133   jobs="-j 12"
134 else
135   jobs=none
136 fi
137 rm -f Makefile
138
139 $ACLOCAL
140 $AUTOCONF
141 $AUTOMAKE -c --add-missing
142
143 ./configure
144
145 for j in '' "$jobs"; do
146   test x"$j" = x"none" && continue
147   $MAKE $j
148   test -f run
149   test -f sub0/run
150   test -f sub1/run
151   test -f sub3/run
152   test -f sub3/a/run
153   test -f sub3/b/run
154   $MAKE clean
155   find . | grep 'run$' && exit 1
156   : # For shells with busted 'set -e'
157 done
158
159 :