Merge branch 'yacc-quote-fix'
[automake.git] / tests / subdir8.test
blobf0c7c491bd6eb5ac8f811128949cdb329e2e1696
1 #! /bin/sh
2 # Copyright (C) 2003-2012 Free Software Foundation, Inc.
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.
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.
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/>.
17 # Test to make sure that adding a new directory works, even from
18 # subdirectories. The sister test `subdir5.test' makes sure it works
19 # when make is run from the top-level directory.
20 # PR automake/46
22 . ./defs || Exit 1
24 cat >> configure.in << 'END'
25 m4_include([confiles.m4])
26 MORE_DEFS
27 AC_OUTPUT
28 END
30 echo 'AC_CONFIG_FILES([sub/Makefile])' > confiles.m4
32 cat > Makefile.am << 'END'
33 SUBDIRS = sub
34 ACLOCAL_AMFLAGS = -I m4
35 END
37 mkdir sub
39 : > sub/Makefile.am
41 mkdir m4
42 echo 'AC_DEFUN([MORE_DEFS], [])' > m4/moredefs.m4
44 $ACLOCAL -I m4
45 $AUTOCONF
46 $AUTOMAKE
47 ./configure
48 $MAKE
50 # Now add new directories.
52 # The first step users typically do when adding a new subdir is
53 # editing configure.in. That is already tested by subdir5.test,
54 # though, so here we try to just edit a file that is included by
55 # configure.in, without touching configure.in itself.
57 mkdir sub/maude
58 cat > sub/maude/Makefile.am << 'END'
59 include_HEADERS = foo.h
60 END
62 : > sub/maude/foo.h
64 echo 'SUBDIRS = maude' >> sub/Makefile.am
66 mkdir maude
67 : > maude/Makefile.am
69 # Update confiles.m4 *after* updating sub/Makefile.am; subdir5.test do
70 # it in the other way: it updates configure.in before Makefile.am.
71 # We sleep here because modified configure dependencies must be newer
72 # than config.status.
73 $sleep
74 echo 'AC_CONFIG_FILES([maude/Makefile sub/maude/Makefile])' >> confiles.m4
76 # We want a simple rebuild from sub/ to create sub/maude/Makefile
77 # and maude/Makefile automatically.
78 cd sub
79 $MAKE
80 cd ..
81 grep '^SUBDIRS = *maude *$' sub/Makefile.in
82 grep '^SUBDIRS = *maude *$' sub/Makefile
83 test -f maude/Makefile
84 test -f sub/maude/Makefile
86 # Make sure the dependencies of aclocal.m4 or honored at least from
87 # the top-level directory.
88 echo 'AC_DEFUN([MORE_DEFS], [AC_SUBST([GREPME])])' > m4/moredefs.m4
89 $MAKE
91 for ext in '.in' ''; do
92 for d in . maude sub sub/maude; do
93 grep '^GREPME =' $d/Makefile$ext
94 done
95 done