Merge branch 'msvc' into maint
[platform/upstream/automake.git] / tests / subdir5.test
1 #! /bin/sh
2 # Copyright (C) 2001, 2002, 2003, 2004, 2009, 2010, 2011 Free Software
3 # Foundation, Inc.
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2, or (at your option)
8 # any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18 # Test to make sure that adding a new directory works.
19 # This test runs `make' from the top-level directory, subdir8.test
20 # do it from a subdirectory.
21 # PR automake/46
22
23 # This test assumes that the `make' utility is able to start
24 # over and reload Makefiles which have been remade (a non-POSIX feature).
25 # See also the related test subdir8.test.
26 required='GNUmake gcc'
27 . ./defs || Exit 1
28
29 set -e
30
31 cat >> configure.in << 'END'
32 AC_PROG_CC
33 AM_PROG_CC_C_O
34 AC_OUTPUT
35 END
36
37 cat > Makefile.am << 'END'
38 bin_PROGRAMS = wish
39 wish_SOURCES = a.c
40 END
41
42 cat > a.c << 'END'
43 #include <stdio.h>
44 int main ()
45 {
46    printf ("hi liver!\n");
47    return 0;
48 }
49 END
50
51 $ACLOCAL
52 $AUTOCONF
53 $AUTOMAKE --include-deps --copy --add-missing
54 ./configure
55 $MAKE
56
57 # Now add new directories.
58
59 # First we add a new directory by modifying configure.in directly.
60 # We update configure.in *before* updating sub/Makefile.am; subdir8.test
61 # does it in the other way: it updates confiles.m4 (which is m4_included
62 # by configure.in there) after Makefile.am.
63
64 # Modified configure dependencies must be newer than config.status.
65 $sleep
66 sed <configure.in >configure.tmp -e '/^AC_OUTPUT$/i\
67 AC_CONFIG_FILES([maude/Makefile])\
68 m4_include([confile.m4])\
69 ' # last newline required by older OpenBSD sed
70 mv -f configure.tmp configure.in
71
72 cat configure.in # might be useful for debugging
73
74 : > confile.m4
75
76 mkdir maude
77
78 cat > maude/Makefile.am << 'END'
79 include_HEADERS = foo.h
80 END
81
82 : > maude/foo.h
83
84 echo 'SUBDIRS = maude' >> Makefile.am
85
86 # We want a simple rebuild to create maude/Makefile automatically.
87 $MAKE
88 grep '^SUBDIRS = *maude *$' Makefile.in
89 grep '^SUBDIRS = *maude *$' Makefile
90 test -f maude/Makefile
91
92 # Then we add a new directory by modifying a file included (through
93 # `m4_include') by configure.in.
94 mkdir maude2
95 # Modified configure dependencies must be newer than config.status.
96 $sleep
97 cat >> confile.m4 << 'END'
98 AC_CONFIG_FILES([maude2/Makefile])
99 AC_SUBST([GREPME])
100 END
101 : > maude2/Makefile.am
102 echo 'SUBDIRS += maude2' >> Makefile.am
103
104 # We want a simple rebuild to create maude2/Makefile and update
105 # all other Makefiles automatically.
106 $MAKE
107 grep '^SUBDIRS =.* maude2' Makefile.in
108 grep '^SUBDIRS =.* maude2' Makefile
109
110 for ext in '.in' ''; do
111   for d in . maude maude2; do
112     grep '^GREPME =' $d/Makefile$ext
113   done
114 done
115
116 :