test harness: improve catching of usage errors in script 'test-driver'
[platform/upstream/automake.git] / t / remake-subdir.sh
1 #! /bin/sh
2 # Copyright (C) 2011-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 remake rules works from subdirectories, even with non-GNU
18 # make implementations.
19 # See also the other similar tests 'remake-subdir*.sh', and the
20 # related test 'aclocal5.sh'.
21
22 . test-init.sh
23
24 if using_gmake; then
25   remake=$MAKE
26 else
27   remake="$MAKE Makefile"
28 fi
29
30 magic1='::MagicString::One::'
31 magic2='__MagicString__Two__'
32
33 debug_info ()
34 {
35   grep -i magic configure Makefile.in Makefile sub/Makefile.in sub/Makefile
36 }
37
38 cat >> configure.ac <<'END'
39 AC_CONFIG_FILES([sub/Makefile])
40 AC_SUBST([MAGIC], [magic])
41 AC_OUTPUT
42 END
43
44 cat > Makefile.am <<'END'
45 SUBDIRS = sub
46 END
47
48 mkdir sub
49 : > sub/Makefile.am
50
51 $ACLOCAL
52 $AUTOCONF
53 $AUTOMAKE
54
55 ./configure
56 $MAKE
57 debug_info
58
59 $sleep
60 sed "s|magic|$magic1|" configure.ac > t
61 mv -f t configure.ac
62 cd sub
63 $remake
64 cd ..
65 debug_info
66 $FGREP $magic1 configure
67 $FGREP $magic1 Makefile
68 $FGREP $magic1 sub/Makefile
69
70 $sleep
71 cd sub
72 echo MAGIC = $magic2 >> Makefile.am
73 $remake
74 cd ..
75 debug_info
76 $FGREP $magic2 sub/Makefile
77 $FGREP $magic2 sub/Makefile.in
78 $FGREP $magic1 sub/Makefile sub/Makefile.in && exit 1
79 $FGREP $magic2 Makefile Makefile.in && exit 1
80
81 :