Imported Upstream version 2.4.2
[platform/upstream/libtool.git] / tests / indirect_deps.at
1 # indirect_deps.at -- support for link_all_deplibs=no   -*- Autotest -*-
2
3 #   Copyright (C) 2007, 2008 Free Software Foundation, Inc.
4 #   Written by Ralf Wildenhues, 2007.
5 #
6 #   This file is part of GNU Libtool.
7 #
8 # GNU Libtool is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU General Public License as
10 # published by the Free Software Foundation; either version 2 of
11 # the License, or (at your option) any later version.
12 #
13 # GNU Libtool is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with GNU Libtool; see the file COPYING.  If not, a copy
20 # can be downloaded from  http://www.gnu.org/licenses/gpl.html,
21 # or obtained by writing to the Free Software Foundation, Inc.,
22 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 ####
24
25 AT_SETUP([indirect convenience])
26 AT_KEYWORDS([libtool])
27
28 AT_DATA([a.c], [[
29 #include <math.h>
30 int a () { return 0; }
31 double ad (double x) { return sin (x); }
32 ]])
33 AT_DATA([b.c], [[
34 extern int a ();
35 extern double ad (double);
36 int b () { return a () + (int) ad (0.0); }
37 ]])
38 AT_DATA([c.c], [[
39 extern int b ();
40 int c () { return b (); }
41 ]])
42 AT_DATA([m.c], [[
43 extern int c ();
44 int main () { return c (); }
45 ]])
46
47 LDFLAGS="$LDFLAGS -no-undefined"
48 for file in a.c b.c c.c; do
49   $LIBTOOL --mode=compile --tag=CC $CC $CPPFLAGS $CFLAGS -c $file
50 done
51 $CC $CPPFLAGS $CFLAGS -c m.c
52
53 # liba is an indirect dependency of libd and of libconv.
54 $LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS -o liba.la a.lo -rpath /nowhere -lm
55 $LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS -o libb.la b.lo liba.la -rpath /nowhere
56 $LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS -o libconv.la c.lo libb.la
57 $LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS -o libd.la libconv.la -rpath /nowhere
58
59 for st in '' -static; do
60   AT_CHECK([$LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS $st -o m1$EXEEXT m.$OBJEXT libd.la],
61            [], [ignore], [ignore])
62   AT_CHECK([$LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS $st -o m2$EXEEXT m.$OBJEXT libconv.la],
63            [], [ignore], [ignore])
64   LT_AT_EXEC_CHECK([./m1])
65   LT_AT_EXEC_CHECK([./m2])
66 done
67
68 AT_CLEANUP
69
70
71 AT_SETUP([indirect uninstalled])
72 AT_KEYWORDS([libtool])
73
74 AT_DATA([a.c], [[
75 int a () { return 0; }
76 ]])
77 AT_DATA([b.c], [[
78 extern int a ();
79 int b () { return a (); }
80 ]])
81 AT_DATA([c.c], [[
82 extern int b ();
83 int c () { return b (); }
84 ]])
85
86 AT_DATA([m1.c], [[
87 extern int b ();
88 int main () { return b (); }
89 ]])
90 AT_DATA([m2.c], [[
91 extern int c ();
92 int main () { return c (); }
93 ]])
94
95 mkdir a b c
96 LDFLAGS="$LDFLAGS -no-undefined"
97 for file in a.c b.c c.c; do
98   $LIBTOOL --mode=compile --tag=CC $CC $CPPFLAGS $CFLAGS -c $file
99 done
100 for file in m1.c m2.c; do
101   $CC $CPPFLAGS $CFLAGS -c $file
102 done
103
104 for st in '' -static; do
105   $LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS -o a/liba.la a.lo -rpath /nowherea
106   $LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS -o b/libb.la b.lo a/liba.la -rpath /nowhereb
107   $LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS -o c/libcee.la c.lo b/libb.la -rpath /nowherec
108
109   AT_CHECK([$LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS $st -o m1$EXEEXT m1.$OBJEXT b/libb.la],
110            [], [ignore], [ignore])
111   AT_CHECK([$LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS $st -o m2$EXEEXT m2.$OBJEXT c/libcee.la],
112            [], [ignore], [ignore])
113   LT_AT_EXEC_CHECK([./m1])
114   LT_AT_EXEC_CHECK([./m2])
115 done
116
117 AT_CLEANUP