tests: avoid yet another spurious environment influence
[platform/upstream/automake.git] / t / remake11.sh
1 #! /bin/sh
2 # Copyright (C) 2010-2012 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 # Test remake rules in deeply nested subdirectories, and with a lot
18 # of files.  This is basically a mild stress test, ensuring that rebuild
19 # rules don't break in obvious ways in a slightly "heavier than usual"
20 # setup.
21
22 . ./defs || Exit 1
23
24 ocwd=`pwd` || Exit 1
25
26 magic1=::MagicStringOne::
27 magic2=__MagicStringTwo__
28
29 echo "AC_SUBST([FOO], [$magic1])" >> configure.ac
30
31 echo "@FOO@" > bar.in
32 echo "AC_CONFIG_FILES([bar])" >> configure.ac
33 d=; unset d # Avoid unduly interferences from the environment.
34 for i in 0 1 2 3 4 5 6 7 8 9; do
35   d=${d+"$d/"}sub$i
36   echo "SUBDIRS = sub$i" > Makefile.am
37   echo "AC_CONFIG_FILES([$d/Makefile])" >> "$ocwd"/configure.ac
38   echo "AC_CONFIG_FILES([$d/bar])" >> "$ocwd"/configure.ac
39   mkdir sub$i
40   cd sub$i
41   echo "$d: @FOO@" > bar.in
42 done
43 echo AC_OUTPUT >> "$ocwd"/configure.ac
44 : > Makefile.am
45 unset d i
46 bottom=`pwd`
47
48 cd "$ocwd"
49
50 makefiles_am_list=`find . -name Makefile.am | LC_ALL=C sort`
51 makefiles_list=`echo "$makefiles_am_list" | sed 's/\.am$//'`
52 bar_in_list=`find . -name bar.in | LC_ALL=C sort`
53 bar_list=`echo "$bar_in_list" | sed 's/\.in$//'`
54
55 cat configure.ac # For debugging.
56
57 $ACLOCAL
58 $AUTOMAKE
59 $AUTOCONF
60
61 ./configure
62
63 for f in configure config.status $makefiles_list $bar_list; do
64   $FGREP "$magic1" $f
65 done
66
67 $sleep
68 sed "s/$magic1/$magic2/" configure.ac >configure.tmp
69 mv -f configure.tmp configure.ac
70
71 cd "$bottom"
72 $MAKE
73 cd "$ocwd"
74
75 for f in configure config.status $makefiles_list $bar_list; do
76   $FGREP "$magic2" $f
77 done
78 $FGREP "$magic1" configure config.status $makefiles_list $bar_list && Exit 1
79
80 $MAKE distcheck
81
82 :