2 # Copyright (C) 2011-2013 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)
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.
26 cat > configure.ac <<END
28 AM_INIT_AUTOMAKE([foreign -Wall -Werror])
29 AC_CONFIG_FILES([Makefile sub/Makefile])
30 AC_SUBST([MAGIC], [magic])
34 echo SUBDIRS = 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"
45 cat > bin/automake <<END
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
54 echo automake has run > "\$sentinel"
57 exec $AUTOMAKE \${1+"\$@"}
59 chmod a+x bin/automake
61 cat > bin/aclocal <<END
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
70 echo aclocal has run > "\$sentinel"
73 exec $ACLOCAL \${1+"\$@"}
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.
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
95 # Sanity check: Makefile doesn't get updated uselessly.
96 run_make ACLOCAL=false AUTOMAKE=false AUTOCONF=false
99 sed "s|magic|magic2|" configure.ac > t
103 run_make Makefile AUTOMAKE="$AUTOMAKE" ACLOCAL="$ACLOCAL"
108 grep -i magic configure Makefile.in Makefile sub/Makefile.in sub/Makefile
110 $FGREP magic2 configure
111 $FGREP magic2 Makefile
112 $FGREP magic2 sub/Makefile