Merge branch 'minor'
[automake.git] / t / libtool9.sh
bloba4c392661acd1bf0845ae79cb29dff85449f6969
1 #! /bin/sh
2 # Copyright (C) 2005-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 # Make sure xxx_LINK is defined for each target that requires specific
18 # flags.
19 # Quite similar to 'libtool7.sh', using AM_LDFLAGS in addition to
20 # xxx_LDFLAGS.
22 required='cc libtoolize'
23 . test-init.sh
25 cat >> configure.ac << 'END'
26 AC_PROG_CC
27 AM_PROG_AR
28 AC_LIBTOOL_DLOPEN
29 AM_PROG_LIBTOOL
30 AC_OUTPUT
31 END
33 cat > Makefile.am << 'END'
34 AM_LDFLAGS = -module
35 lib_LTLIBRARIES = libmod1.la mod2.la
36 libmod1_la_SOURCES = mod1.c
37 libmod1_la_LDFLAGS =
38 libmod1_la_LIBADD = -dlopen mod2.la
39 mod2_la_SOURCES = mod2.c
41 bin_PROGRAMS = prg prg2
42 prg_SOURCES = prg.c
43 prg_LDADD = -dlopen libmod1.la -dlpreopen mod2.la
44 prg_CPPFLAGS = -DXYZ=1
45 prg2_SOURCES = prg.c
46 prg2_CFLAGS =
48 print:
49 @echo 1BEG: $(prg_DEPENDENCIES) :END1
50 @echo 2BEG: $(libmod1_la_DEPENDENCIES) :END2
51 @echo 3BEG: $(libmod1_la_LINK) :END3
52 @echo 4BEG: $(mod2_la_LINK) :END4
53 @echo 5BEG: $(prg_LINK) :END5
54 @echo 6BEG: $(prg2_LINK) :END6
56 END
58 mkdir liba
60 cat > mod1.c << 'END'
61 int mod1 (void)
63 return 1;
65 END
67 cat > mod2.c << 'END'
68 int mod2 (void)
70 return 2;
72 END
74 cat > prg.c << 'END'
75 int main (void)
77 return 0;
79 END
81 libtoolize --force --copy
82 $ACLOCAL
83 $AUTOCONF
84 $AUTOMAKE --add-missing --copy
86 ./configure
87 run_make -M -- print \
88 LDFLAGS=ldflags \
89 AM_LDFLAGS=am_ldflags \
90 libmod1_la_LDFLAGS=lm1_la_ldflags \
91 CFLAGS=cflags \
92 AM_CFLAGS=am_cflags \
93 prg2_CFLAGS=prg2_cflags
95 grep '1BEG: libmod1.la mod2.la :END1' output
96 grep '2BEG: mod2.la :END2' output
97 grep '3BEG:.* am_cflags cflags .*lm1_la_ldflags ldflags.* :END3' output
98 grep '3BEG: .*am_ldflags.* :END3' output && exit 1
99 grep '4BEG: :END4' output
100 grep '5BEG: :END5' output
101 grep '6BEG:.* prg2_cflags cflags .*am_ldflags ldflags.* :END6' output
102 grep '6BEG: .*am_cflags.* :END6' output && exit 1
104 $MAKE