1 # duplicate_deps.at -- preserve duplicate convenience deps -*- Autotest -*-
3 # Copyright (C) 2006-2008, 2011-2019, 2021-2024 Free Software
5 # Written by Ralf Wildenhues, 2006
7 # This file is part of GNU Libtool.
9 # GNU Libtool is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation; either version 2 of
12 # the License, or (at your option) any later version.
14 # GNU Libtool is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with GNU Libtool. If not, see <https://www.gnu.org/licenses/>.
23 AT_SETUP([preserve duplicate convenience deps])
24 AT_KEYWORDS([libtool])
26 # --preserve-dup-deps should work for convenience archives.
28 # Create a circular dependency of liba and libb:
29 # a1 pulls in b1, that pulls in a2.
32 int a1 () { return b1 (); }
35 int a2 () { return 0; }
39 int b1 () { return a2 (); }
43 int main () { return a1 (); }
46 for file in a1.c a2.c b1.c; do
47 $LIBTOOL --mode=compile $CC $CPPFLAGS $CFLAGS -c $file
49 $CC $CPPFLAGS $CFLAGS -c main.c
50 $LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS -o liba.la a1.lo a2.lo
52 # This could be worked around by adding liba.la to libb.la
53 # (in that case all objects from liba would be merged into
54 # libb.a as well, possibly renamed.)
55 $LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS -o libb.la b1.lo liba.la
56 AT_CHECK([$LIBTOOL --mode=link --tag=CC \
57 $CC $CFLAGS $LDFLAGS -o main$EXEEXT main.$OBJEXT liba.la libb.la],
58 [0], [ignore], [ignore])
59 LT_AT_EXEC_CHECK([./main])
61 # Forgo the workaround and create a true circular dependency.
62 $LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS -o libb.la b1.lo
63 # Some systems find all symbols anyway; skip this test on such systems.
64 AT_CHECK([$LIBTOOL --mode=link --tag=CC \
65 $CC $CFLAGS $LDFLAGS -o main$EXEEXT main.$OBJEXT liba.la libb.la liba.la \
67 [1], [ignore], [ignore])
68 # Other systems need special treatment, so preserve-dup-deps flag is used.
69 AT_CHECK([$LIBTOOL --mode=link --preserve-dup-deps --tag=CC \
70 $CC $CFLAGS $LDFLAGS -o main$EXEEXT main.$OBJEXT liba.la libb.la liba.la],
71 [0], [ignore], [ignore])