Merge branch 'docs-recursion' into maint
[platform/upstream/automake.git] / t / subdir-add-pr46.sh
1 #! /bin/sh
2 # Copyright (C) 2001-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 to make sure that adding a new directory works.
18 # This test runs 'make' from the top-level directory, the sister test
19 # 'subdir8.test' do it from a subdirectory.
20 # PR automake/46
21
22 . ./defs || Exit 1
23
24 cat >> configure.ac << 'END'
25 AC_OUTPUT
26 END
27
28 : > Makefile.am
29
30 $ACLOCAL
31 $AUTOCONF
32 $AUTOMAKE
33 ./configure
34 $MAKE
35
36 # Now add new directories.
37
38 # First we add a new directory by modifying configure.ac directly.
39 # We update configure.ac *before* updating sub/Makefile.am; subdir8.test
40 # does it in the other way: it updates confiles.m4 (which is m4_included
41 # by configure.ac there) after Makefile.am.
42
43 # Modified configure dependencies must be newer than config.status.
44 $sleep
45 sed <configure.ac >configure.tmp -e '/^AC_OUTPUT$/i\
46 AC_CONFIG_FILES([maude/Makefile])\
47 m4_include([confile.m4])\
48 ' # Last newline required by older OpenBSD sed.
49 mv -f configure.tmp configure.ac
50
51 cat configure.ac # For debugging.
52
53 : > confile.m4
54
55 mkdir maude
56
57 cat > maude/Makefile.am << 'END'
58 include_HEADERS = foo.h
59 END
60
61 : > maude/foo.h
62
63 echo 'SUBDIRS = maude' >> Makefile.am
64
65 # We want a simple rebuild to create maude/Makefile automatically.
66 $MAKE
67 grep '^SUBDIRS = *maude *$' Makefile.in
68 grep '^SUBDIRS = *maude *$' Makefile
69 test -f maude/Makefile
70
71 # Then we add a new directory by modifying a file included (through
72 # 'm4_include') by configure.ac.
73 mkdir maude2
74 # Modified configure dependencies must be newer than config.status.
75 $sleep
76 cat >> confile.m4 << 'END'
77 AC_CONFIG_FILES([maude2/Makefile])
78 AC_SUBST([GREPME])
79 END
80 : > maude2/Makefile.am
81 echo 'SUBDIRS += maude2' >> Makefile.am
82
83 # We want a simple rebuild to create maude2/Makefile and update
84 # all other Makefiles automatically.
85 $MAKE
86 grep '^SUBDIRS =.* maude2' Makefile.in
87 grep '^SUBDIRS =.* maude2' Makefile
88
89 for ext in '.in' ''; do
90   for d in . maude maude2; do
91     grep '^GREPME =' $d/Makefile$ext
92   done
93 done
94
95 :