Merge branch 'yacc-quote-fix'
[automake.git] / tests / subpkg.test
blob6f85bfaf02ec4ba1148d80b0d8b2751ac550ed6f
1 #! /bin/sh
2 # Copyright (C) 2002-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 # Check subpackage handling.
19 required=cc
20 . ./defs || Exit 1
22 mkdir m4
24 cat >m4/foo.m4 <<'EOF'
25 AC_DEFUN([FOO],[
26 AC_PROG_CC
27 AC_OUTPUT
29 EOF
31 cat >>configure.in <<'END'
32 AC_CONFIG_SUBDIRS([lib])
33 FOO
34 END
36 cat >Makefile.am <<'EOF'
37 SUBDIRS = lib
38 # Yes, This program is named LDADD. So what?
39 bin_PROGRAMS = LDADD
40 LDADD_LDADD = lib/liblib.a
42 # It's ok to override distdir.
43 distdir = subpack-1
45 # Make sure $(distdir) and $(top_distdir) work as expected.
46 dist-hook:
47 test -f $(distdir)/LDADD.c
48 test -f $(top_distdir)/LDADD.c
50 ACLOCAL_AMFLAGS = -I m4
51 EOF
53 cat >LDADD.c <<'EOF'
54 int lib (void);
55 int main (void)
57 return lib ();
59 EOF
61 mkdir lib
62 mkdir lib/src
64 cat >lib/configure.ac <<'EOF'
65 AC_INIT([lib], [2.3])
66 AM_INIT_AUTOMAKE
67 AM_PROG_AR
68 AC_PROG_RANLIB
69 AC_CONFIG_HEADERS([config.h:config.hin])
70 AC_CONFIG_FILES([Makefile])
71 FOO
72 EOF
74 cat >lib/Makefile.am <<'EOF'
75 noinst_LIBRARIES = liblib.a
76 liblib_a_SOURCES = src/x.c
78 dist-hook:
79 test ! -f $(distdir)/LDADD.c
80 test -f $(top_distdir)/LDADD.c
81 test -f $(distdir)/src/x.c
82 test ! -f $(top_distdir)/src/x.c
84 ACLOCAL_AMFLAGS = -I ../m4
85 EOF
87 cat >lib/src/x.c <<'EOF'
88 #include <config.h>
89 int lib (void)
91 return 0;
93 EOF
95 $ACLOCAL -I m4
96 $AUTOCONF
97 $AUTOMAKE -Wno-override
99 cd lib
100 $ACLOCAL -I ../m4
101 $FGREP 'm4_include([../m4/foo.m4])' aclocal.m4
102 $AUTOCONF
103 $AUTOHEADER
104 $AUTOMAKE -Wno-override --add-missing
105 cd ..
107 ./configure
108 $MAKE
109 $MAKE distcheck
110 test ! -d subpack-1 # Make sure distcheck cleans up after itself.
111 test -f subpack-1.tar.gz