1 # duplicate_deps.at -- preserve duplicate convenience deps -*- Autotest -*-
3 # Copyright (C) 2006, 2007 Free Software Foundation, Inc.
4 # Written by Ralf Wildenhues, 2006
6 # This file is part of GNU Libtool.
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.
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.
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.
25 AT_SETUP([preserve duplicate convenience deps])
26 AT_KEYWORDS([libtool])
28 # --preserve-dup-deps should work for convenience archives.
30 # Create a circular dependency of liba and libb:
31 # a1 pulls in b1, that pulls in a2.
34 int a1 () { return b1 (); }
37 int a2 () { return 0; }
41 int b1 () { return a2 (); }
45 int main () { return a1 (); }
48 for file in a1.c a2.c b1.c; do
49 $LIBTOOL --mode=compile $CC $CPPFLAGS $CFLAGS -c $file
51 $CC $CPPFLAGS $CFLAGS -c main.c
52 $LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS -o liba.la a1.lo a2.lo
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 main.$OBJEXT liba.la libb.la],
60 [0], [ignore], [ignore])
61 LT_AT_EXEC_CHECK([./main])
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 main.$OBJEXT liba.la libb.la liba.la \
69 [1], [ignore], [ignore])
70 # Other systems need special treatment, which currently fails.
72 AT_CHECK([$LIBTOOL --mode=link --preserve-dup-deps --tag=CC \
73 $CC $CFLAGS $LDFLAGS -o main main.$OBJEXT liba.la libb.la liba.la],
74 [0], [ignore], [ignore])