compile: implement library search to support MSVC static linking
[automake.git] / tests / subdir8.test
blob093fac8e8cba7bf353f85e8c9a696e6492bdd697
1 #! /bin/sh
2 # Copyright (C) 2003, 2004, 2009, 2010 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. (subdir5.test makes sure it works when make
19 # is run from the top-level directory.)
20 # PR automake/46
22 # This test assumes that the `make' utility is able to start
23 # over and reload Makefiles which have been remade (a non-POSIX feature).
24 # See also the related test subdir5.test.
25 required='GNUmake gcc'
26 . ./defs || Exit 1
28 set -e
30 cat >> configure.in << 'END'
31 AC_PROG_CC
32 AM_PROG_CC_C_O
33 m4_include([confiles.m4])
34 MORE_DEFS
35 AC_OUTPUT
36 END
38 echo 'AC_CONFIG_FILES([sub/Makefile])' > confiles.m4
40 cat > Makefile.am << 'END'
41 SUBDIRS = sub
42 ACLOCAL_AMFLAGS = -I m4
43 END
45 mkdir sub
47 cat > sub/Makefile.am << 'END'
48 bin_PROGRAMS = wish
49 wish_SOURCES = a.c
50 END
52 cat > sub/a.c << 'END'
53 #include <stdio.h>
54 int main ()
56 printf ("hi liver!\n");
57 return 0;
59 END
61 mkdir m4
62 echo 'AC_DEFUN([MORE_DEFS], [])' > m4/moredefs.m4
64 $ACLOCAL -I m4
65 $AUTOCONF
66 $AUTOMAKE --copy --add-missing
67 ./configure
68 $MAKE
70 # Now add new directories.
72 # We shouldn't need to $sleep here: configure ensures that files
73 # generated by it are newer than configure. Thus, even if
74 # Makefile.in is newer than configure but the updated Makefile.am
75 # below has the same timestamp as Makefile.in, the latter should
76 # be rebuilt due to its dependency on configure.in.
78 # The first step users typically do when adding a new subdir is
79 # editing configure.in. That is already tested by subdir5.test,
80 # though, so here we try to just edit a file that is included by
81 # configure.in, without touching configure.in itself.
83 mkdir sub/maude
84 cat > sub/maude/Makefile.am << 'END'
85 include_HEADERS = foo.h
86 END
88 : > sub/maude/foo.h
90 echo 'SUBDIRS = maude' >> sub/Makefile.am
92 mkdir maude
93 : > maude/Makefile.am
95 # Update confiles.m4 *after* updating sub/Makefile.am; subdir5.test do
96 # it in the other way: it updates configure.in before Makefile.am.
97 echo 'AC_CONFIG_FILES([maude/Makefile sub/maude/Makefile])' >> confiles.m4
99 # We want a simple rebuild from sub/ to create sub/maude/Makefile
100 # and maude/Makefile automatically.
101 cd sub
102 $MAKE
103 cd ..
104 test -f maude/Makefile
105 test -f sub/maude/Makefile
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
112 grep '^GREPME =' Makefile
113 grep '^GREPME =' maude/Makefile
114 grep '^GREPME =' sub/Makefile
115 grep '^GREPME =' sub/maude/Makefile