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