Merge branch 'micro' into maint
[platform/upstream/automake.git] / t / remake-deeply-nested.sh
1 #! /bin/sh
2 # Copyright (C) 2010-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 # 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 . test-init.sh
23
24 ocwd=$(pwd) || fatal_ "getting current working directory"
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 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
47 bottom=$(pwd) || fatal_ "getting current working directory"
48
49 cd "$ocwd"
50
51 makefiles_am_list=$(find . -name Makefile.am | LC_ALL=C sort)
52 makefiles_list=$(echo "$makefiles_am_list" | sed 's/\.am$//')
53 bar_in_list=$(find . -name bar.in | LC_ALL=C sort)
54 bar_list=$(echo "$bar_in_list" | sed 's/\.in$//')
55
56 cat configure.ac # For debugging.
57
58 $ACLOCAL
59 $AUTOMAKE
60 $AUTOCONF
61
62 ./configure
63
64 for f in configure config.status $makefiles_list $bar_list; do
65   $FGREP "$magic1" $f
66 done
67
68 $sleep
69 sed "s/$magic1/$magic2/" configure.ac >configure.tmp
70 mv -f configure.tmp configure.ac
71
72 cd "$bottom"
73 $MAKE
74 cd "$ocwd"
75
76 for f in configure config.status $makefiles_list $bar_list; do
77   $FGREP "$magic2" $f
78 done
79 $FGREP "$magic1" configure config.status $makefiles_list $bar_list && exit 1
80
81 $MAKE distcheck
82
83 :