Merge branch 'minor'
[automake.git] / t / subpkg.sh
blob6ffee36c4600f452bb265267bbdb287c66af6d01
1 #! /bin/sh
2 # Copyright (C) 2002-2017 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 <https://www.gnu.org/licenses/>.
17 # Check subpackage handling.
19 required=cc
20 . test-init.sh
22 mkdir m4
24 cat >m4/foo.m4 <<'EOF'
25 AC_DEFUN([FOO],[
26 AC_REQUIRE([AC_PROG_CC])
27 AC_OUTPUT
29 EOF
31 cat >>configure.ac <<'END'
32 AC_CONFIG_MACRO_DIR([m4])
33 AC_CONFIG_SUBDIRS([lib])
34 FOO
35 END
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
43 # It's ok to override distdir.
44 distdir = subpack-1
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 EOF
52 cat >LDADD.c <<'EOF'
53 int lib (void);
54 int main (void)
56 return lib ();
58 EOF
60 mkdir lib
61 mkdir lib/src
63 cat >lib/configure.ac <<'EOF'
64 AC_INIT([lib], [2.3])
65 AM_INIT_AUTOMAKE([subdir-objects])
66 AC_CONFIG_MACRO_DIR([../m4])
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
83 EOF
85 cat >lib/src/x.c <<'EOF'
86 #include <config.h>
87 int lib (void)
89 return 0;
91 EOF
93 $ACLOCAL
94 $AUTOCONF -Werror -Wall
95 $AUTOMAKE -Wno-override
97 cd lib
98 $ACLOCAL
99 $FGREP 'm4_include([../m4/foo.m4])' aclocal.m4
100 $AUTOCONF
101 $AUTOHEADER
102 $AUTOMAKE -Wno-override --add-missing
103 cd ..
105 ./configure >stdout || { cat stdout; exit 1; }
106 cat stdout
107 $FGREP "checking whether $CC understands -c and -o together" stdout
109 $MAKE
110 $MAKE distcheck
111 test ! -e subpack-1 # Make sure distcheck cleans up after itself.
112 test -f subpack-1.tar.gz