Merge branch 'yacc-work' into yl-work-for-master
[platform/upstream/automake.git] / tests / subpkg.test
1 #! /bin/sh
2 # Copyright (C) 2002, 2003, 2004, 2006, 2011, 2012 Free Software
3 # Foundation, Inc.
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2, or (at your option)
8 # any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18 # Check subpackage handling.
19
20 required=cc
21 . ./defs || Exit 1
22
23 mkdir m4
24
25 cat >m4/foo.m4 <<'EOF'
26 AC_DEFUN([FOO],[
27   AC_PROG_CC
28   AC_OUTPUT
29 ])
30 EOF
31
32 cat >>configure.in <<'END'
33 AC_CONFIG_SUBDIRS([lib])
34 FOO
35 END
36
37 cat >Makefile.am <<'EOF'
38 SUBDIRS = lib
39 # Yes, This program is named LDADD.  So what?
40 bin_PROGRAMS = LDADD
41 LDADD_LDADD = lib/liblib.a
42
43 # It's ok to override distdir.
44 distdir = subpack-1
45
46 # Make sure $(distdir) and $(top_distdir) work as expected.
47 dist-hook:
48         test -f $(distdir)/LDADD.c
49         test -f $(top_distdir)/LDADD.c
50
51 ACLOCAL_AMFLAGS = -I m4
52 EOF
53
54 cat >LDADD.c <<'EOF'
55 int lib (void);
56 int main (void)
57 {
58   return lib ();
59 }
60 EOF
61
62 mkdir lib
63 mkdir lib/src
64
65 cat >lib/configure.ac <<'EOF'
66 AC_INIT([lib], [2.3])
67 AM_INIT_AUTOMAKE
68 AM_PROG_AR
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 :