Merge branch 'yacc-quote-fix'
[automake.git] / tests / remake-subdir-long-time.test
blob0eee5a01e5b7835ce45d168b4b062e47e1292ffc
1 #! /bin/sh
2 # Copyright (C) 2011-2012 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 <http://www.gnu.org/licenses/>.
17 # Check that remake rules from subdirectories do not hang or cycle
18 # endlessly, even with build systems that takes several seconds to
19 # rebuild the Makefiles.
20 # This test tries to ensure a long-enough rebuild time by introducing
21 # an explicit delay in the build process.
22 # Suggestion by Ralf Wildenhues.
24 . ./defs || Exit 1
26 cat > configure.in <<END
27 AC_INIT([$me], [1.0])
28 AM_INIT_AUTOMAKE([foreign -Wall -Werror])
29 AC_CONFIG_FILES([Makefile sub/Makefile])
30 AC_SUBST([MAGIC], [magic])
31 AC_OUTPUT
32 END
34 echo SUBDIRS = sub > Makefile.am
35 mkdir sub
36 : > sub/Makefile.am
38 # Both aclocal and automake are expected to run one and just one time.
39 # Create and use wrappers that will verify that.
41 ocwd=`pwd` || fatal_ "cannot get current working directory"
43 mkdir bin
45 cat > bin/automake <<END
46 #!/bin/sh
47 set -e
48 PATH='$PATH'; export PATH
49 sentinel='$ocwd/automake-has-run'
50 if test -f "\$sentinel"; then
51 echo "Automake has been run more than one time" >&2
52 exit 1
53 else
54 echo automake has run > "\$sentinel"
56 $sleep; $sleep;
57 exec $AUTOMAKE \${1+"\$@"}
58 END
59 chmod a+x bin/automake
61 cat > bin/aclocal <<END
62 #!/bin/sh
63 set -e
64 PATH='$PATH'; export PATH
65 sentinel='$ocwd/aclocal-has-run'
66 if test -f "\$sentinel"; then
67 echo "Aclocal has been run more than one time" >&2
68 exit 1
69 else
70 echo aclocal has run > "\$sentinel"
72 $sleep; $sleep;
73 exec $ACLOCAL \${1+"\$@"}
74 END
75 chmod a+x bin/aclocal
77 # Just to be sure.
78 cp bin/automake bin/automake-$APIVERSION
79 cp bin/aclocal bin/aclocal-$APIVERSION
81 PATH=$ocwd/bin$PATH_SEPARATOR$PATH; export PATH
83 AUTOMAKE=automake ACLOCAL=aclocal; export AUTOMAKE ACLOCAL
85 $ACLOCAL # Should use or just-defined wrapper.
86 $AUTOMAKE # Likewise.
87 $AUTOCONF
89 # Sanity check: the wrappers have been used.
90 test -f automake-has-run
91 test -f aclocal-has-run
92 rm -f automake-has-run aclocal-has-run
94 ./configure
95 # Sanity check: Makefile doesn't get updated uselessly.
96 ACLOCAL=false AUTOMAKE=false AUTOCONF=false $MAKE -e
98 $sleep
99 sed "s|magic|magic2|" configure.in > t
100 mv -f t configure.in
102 cd sub
103 AUTOMAKE="$AUTOMAKE" ACLOCAL="$ACLOCAL" $MAKE -e Makefile
104 cd ..
106 # For debugging.
107 ls -l . sub
108 grep -i magic configure Makefile.in Makefile sub/Makefile.in sub/Makefile
109 # Sanity checks.
110 $FGREP magic2 configure
111 $FGREP magic2 Makefile
112 $FGREP magic2 sub/Makefile