Merge branch 'msvc' into maint
[platform/upstream/automake.git] / tests / subdir8.test
1 #! /bin/sh
2 # Copyright (C) 2003, 2004, 2009, 2010, 2011 Free Software Foundation,
3 # 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, even from
19 # subdirectories.  (subdir5.test makes sure it works when make
20 # is run from the top-level directory.)
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 subdir5.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 m4_include([confiles.m4])
35 MORE_DEFS
36 AC_OUTPUT
37 END
38
39 echo 'AC_CONFIG_FILES([sub/Makefile])' > confiles.m4
40
41 cat > Makefile.am << 'END'
42 SUBDIRS = sub
43 ACLOCAL_AMFLAGS = -I m4
44 END
45
46 mkdir sub
47
48 cat > sub/Makefile.am << 'END'
49 bin_PROGRAMS = wish
50 wish_SOURCES = a.c
51 END
52
53 cat > sub/a.c << 'END'
54 #include <stdio.h>
55 int main ()
56 {
57    printf ("hi liver!\n");
58    return 0;
59 }
60 END
61
62 mkdir m4
63 echo 'AC_DEFUN([MORE_DEFS], [])' > m4/moredefs.m4
64
65 $ACLOCAL -I m4
66 $AUTOCONF
67 $AUTOMAKE --copy --add-missing
68 ./configure
69 $MAKE
70
71 # Now add new directories.
72
73 # The first step users typically do when adding a new subdir is
74 # editing configure.in.  That is already tested by subdir5.test,
75 # though, so here we try to just edit a file that is included by
76 # configure.in, without touching configure.in itself.
77
78 mkdir sub/maude
79 cat > sub/maude/Makefile.am << 'END'
80 include_HEADERS = foo.h
81 END
82
83 : > sub/maude/foo.h
84
85 echo 'SUBDIRS = maude' >> sub/Makefile.am
86
87 mkdir maude
88 : > maude/Makefile.am
89
90 # Update confiles.m4 *after* updating sub/Makefile.am; subdir5.test do
91 # it in the other way: it updates configure.in before Makefile.am.
92 # We sleep here because modified configure dependencies must be newer
93 # than config.status.
94 $sleep
95 echo 'AC_CONFIG_FILES([maude/Makefile sub/maude/Makefile])' >> confiles.m4
96
97 # We want a simple rebuild from sub/ to create sub/maude/Makefile
98 # and maude/Makefile automatically.
99 cd sub
100 $MAKE
101 cd ..
102 grep '^SUBDIRS = *maude *$' sub/Makefile.in
103 grep '^SUBDIRS = *maude *$' sub/Makefile
104 test -f maude/Makefile
105 test -f sub/maude/Makefile
106
107 # Make sure the dependencies of aclocal.m4 or honored at least from
108 # the top-level directory.
109 echo 'AC_DEFUN([MORE_DEFS], [AC_SUBST([GREPME])])' > m4/moredefs.m4
110 $MAKE
111
112 for ext in '.in' ''; do
113   for d in . maude sub sub/maude; do
114     grep '^GREPME =' $d/Makefile$ext
115   done
116 done
117
118 :