Merge branch 'msvc' into maint
[platform/upstream/automake.git] / tests / remake-subdir-long-time.test
1 #! /bin/sh
2 # Copyright (C) 2011 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 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.
23
24 . ./defs || Exit 1
25
26 set -e
27
28 cat > configure.in <<END
29 AC_INIT([$me], [1.0])
30 AM_INIT_AUTOMAKE([foreign -Wall -Werror])
31 AC_CONFIG_FILES([Makefile sub/Makefile])
32 AC_SUBST([MAGIC], [magic])
33 AC_OUTPUT
34 END
35
36 echo SUBDIRS = sub > Makefile.am
37 mkdir sub
38 : > sub/Makefile.am
39
40 # Both aclocal and automake are expected to run one and just one time.
41 # Create and use wrappers that will verify that.
42
43 ocwd=`pwd` || fatal_ "cannot get current working directory"
44
45 mkdir bin
46
47 cat > bin/automake <<END
48 #!/bin/sh
49 set -e
50 PATH='$PATH'; export PATH
51 sentinel='$ocwd/automake-has-run'
52 if test -f "\$sentinel"; then
53   echo "Automake has been run more than one time" >&2
54   exit 1
55 else
56   echo automake has run > "\$sentinel"
57 fi
58 $sleep; $sleep;
59 exec $AUTOMAKE \${1+"\$@"}
60 END
61 chmod a+x bin/automake
62
63 cat > bin/aclocal <<END
64 #!/bin/sh
65 set -e
66 PATH='$PATH'; export PATH
67 sentinel='$ocwd/aclocal-has-run'
68 if test -f "\$sentinel"; then
69   echo "Aclocal has been run more than one time" >&2
70   exit 1
71 else
72   echo aclocal has run > "\$sentinel"
73 fi
74 $sleep; $sleep;
75 exec $ACLOCAL \${1+"\$@"}
76 END
77 chmod a+x bin/aclocal
78
79 # Just to be sure.
80 cp bin/automake bin/automake-$APIVERSION
81 cp bin/aclocal bin/aclocal-$APIVERSION
82
83 PATH=$ocwd/bin$PATH_SEPARATOR$PATH; export PATH
84
85 AUTOMAKE=automake ACLOCAL=aclocal; export AUTOMAKE ACLOCAL
86
87 $ACLOCAL  # Should use or just-defined wrapper.
88 $AUTOMAKE # Likewise.
89 $AUTOCONF
90
91 # Sanity check: the wrappers have been used.
92 test -f automake-has-run
93 test -f aclocal-has-run
94 rm -f automake-has-run aclocal-has-run
95
96 ./configure
97 # Sanity check: Makefile doesn't get updated uselessly.
98 ACLOCAL=false AUTOMAKE=false AUTOCONF=false $MAKE -e
99
100 $sleep
101 sed "s|magic|magic2|" configure.in > t
102 mv -f t configure.in
103
104 cd sub
105 AUTOMAKE="$AUTOMAKE" ACLOCAL="$ACLOCAL" $MAKE -e Makefile
106 cd ..
107
108 # For debugging.
109 ls -l . sub
110 grep -i magic configure Makefile.in Makefile sub/Makefile.in sub/Makefile
111 # Sanity checks.
112 $FGREP magic2 configure
113 $FGREP magic2 Makefile
114 $FGREP magic2 sub/Makefile
115
116 :