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