Imported Upstream version 2.4.2
[platform/upstream/libtool.git] / tests / duplicate_deps.at
1 # duplicate_deps.at -- preserve duplicate convenience deps    -*- Autotest -*-
2
3 #   Copyright (C) 2006, 2007, 2008 Free Software Foundation, Inc.
4 #   Written by Ralf Wildenhues, 2006
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([preserve duplicate convenience deps])
26 AT_KEYWORDS([libtool])
27
28 # --preserve-dup-deps should work for convenience archives.
29
30 # Create a circular dependency of liba and libb:
31 # a1 pulls in b1, that pulls in a2.
32 cat >a1.c <<\EOF
33 extern int b1 ();
34 int a1 () { return b1 (); }
35 EOF
36 cat >a2.c <<\EOF
37 int a2 () { return 0; }
38 EOF
39 cat >b1.c <<\EOF
40 extern int a2 ();
41 int b1 () { return a2 (); }
42 EOF
43 cat >main.c <<\EOF
44 extern int a1 ();
45 int main () { return a1 (); }
46 EOF
47
48 for file in a1.c a2.c b1.c; do
49   $LIBTOOL --mode=compile $CC $CPPFLAGS $CFLAGS -c $file
50 done
51 $CC $CPPFLAGS $CFLAGS -c main.c
52 $LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS -o liba.la a1.lo a2.lo
53
54 # This could be worked around by adding liba.la to libb.la
55 # (in that case all objects from liba would be merged into
56 # libb.a as well, possibly renamed.)
57 $LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS -o libb.la b1.lo liba.la
58 AT_CHECK([$LIBTOOL --mode=link --tag=CC \
59           $CC $CFLAGS $LDFLAGS -o main$EXEEXT main.$OBJEXT liba.la libb.la],
60           [0], [ignore], [ignore])
61 LT_AT_EXEC_CHECK([./main])
62
63 # Forgo the workaround and create a true circular dependency.
64 $LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS -o libb.la b1.lo
65 # Some systems find all symbols anyway; skip this test on such systems.
66 AT_CHECK([$LIBTOOL --mode=link --tag=CC \
67           $CC $CFLAGS $LDFLAGS -o main$EXEEXT main.$OBJEXT liba.la libb.la liba.la \
68           && exit 77],
69           [1], [ignore], [ignore])
70 # Other systems need special treatment, which currently fails.
71 AT_XFAIL_IF([:])
72 AT_CHECK([$LIBTOOL --mode=link --preserve-dup-deps --tag=CC \
73           $CC $CFLAGS $LDFLAGS -o main$EXEEXT main.$OBJEXT liba.la libb.la liba.la],
74           [0], [ignore], [ignore])
75
76 AT_CLEANUP