1 # inherited_flags.at -- test inherited_linker_flags -*- Autotest -*-
3 # Copyright (C) 2005-2008, 2011-2019, 2021-2024 Free Software
5 # Written by Peter O'Garman, 2005
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; see the file COPYING. If not, a copy
21 # can be downloaded from http://www.gnu.org/licenses/gpl.html,
22 # or obtained by writing to the Free Software Foundation, Inc.,
23 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27 AT_SETUP([inherited_linker_flags])
28 AT_KEYWORDS([libtool])
32 int foo() { return 1;}
37 int bar() { return 1;}
42 int baz() { return 1;}
47 int both() { return 1;}
52 int main() { return 0;}
55 $LIBTOOL --mode=compile --tag=CC $CC $CPPFLAGS $CFLAGS -c -o foo.lo foo.c
56 $LIBTOOL --mode=compile --tag=CC $CC $CPPFLAGS $CFLAGS -c -o bar.lo bar.c
57 $LIBTOOL --mode=compile --tag=CC $CC $CPPFLAGS $CFLAGS -c -o baz.lo baz.c
58 $LIBTOOL --mode=compile --tag=CC $CC $CPPFLAGS $CFLAGS -c -o both.lo both.c
59 $LIBTOOL --mode=compile --tag=CC $CC $CPPFLAGS $CFLAGS -c -o main.lo main.c
60 $LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS -o libfoo.la foo.lo -rpath /nonexistent -no-undefined
61 $LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS -o libbar.la bar.lo -rpath /nonexistent -no-undefined
62 $LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS -o libboth.la both.lo -rpath /nonexistent -no-undefined
65 mv libfoo.la libfoo.la.bak
66 $SED -e 's/^inherited_linker_flags.*/inherited_linker_flags=-llt_inlikely_existing_lib/g' < libfoo.la.bak > libfoo.la
69 mv libbar.la libbar.la.bak
70 $SED -e 's/^inherited_linker_flags.*/inherited_linker_flags=-llt_unlikely_existing_lib/g' < libbar.la.bak > libbar.la
73 mv libboth.la libboth.la.bak
74 $SED -e "s/^inherited_linker_flags.*/inherited_linker_flags='-llt_inlikely_existing_lib -llt_unlikely_existing_lib'/g" < libboth.la.bak > libboth.la
77 AT_CHECK([$LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS -o libbaz.la baz.lo -no-undefined -rpath /nonexistent ./libfoo.la ./libbar.la],
78 [ignore],[stdout],[ignore])
80 # 'llt_[[ui]]nlikely_existing_lib.*llt_[[ui]]nlikely_existing_lib'
81 # here. This fails on win32/MSVC because the generated command lines have a
82 # different syntax. So drop the first 'l'.
83 AT_CHECK([$LIBTOOL --features | $GREP 'disable shared libraries' && (exit 77)], [1], [ignore])
84 AT_CHECK([$GREP 'lt_[[ui]]nlikely_existing_lib.*lt_[[ui]]nlikely_existing_lib' stdout],
85 [0],[ignore],[ignore])
86 AT_CHECK([$LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS -o main$EXEEXT main.lo -no-undefined -rpath /nonexistent ./libfoo.la ./libbar.la],
87 [ignore],[stdout],[ignore])
88 AT_CHECK([$GREP 'lt_[[ui]]nlikely_existing_lib.*lt_[[ui]]nlikely_existing_lib' stdout],
89 [0],[ignore],[ignore])
91 # now check for duplicates
92 AT_CHECK([$LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS -o libbaz.la baz.lo -no-undefined -rpath /nonexistent ./libfoo.la ./libbar.la ./libboth.la],
93 [ignore],[stdout],[ignore])
94 AT_CHECK([$GREP 'lt_inlikely_existing_lib.*lt_inlikely_existing_lib' stdout],
95 [1],[ignore],[ignore])
96 AT_CHECK([$GREP 'lt_unlikely_existing_lib.*lt_unlikely_existing_lib' stdout],
97 [1],[ignore],[ignore])
98 AT_CHECK([$LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS -o main$EXEEXT main.lo -no-undefined -rpath /nonexistent ./libfoo.la ./libbar.la ./libboth.la],
99 [ignore],[stdout],[ignore])
100 AT_CHECK([$GREP 'lt_inlikely_existing_lib.*lt_inlikely_existing_lib' stdout],
101 [1],[ignore],[ignore])
102 AT_CHECK([$GREP 'lt_unlikely_existing_lib.*lt_unlikely_existing_lib' stdout],
103 [1],[ignore],[ignore])
105 mv libboth.la libboth.la.bak
106 $SED "s/^inherited_linker_flags.*/inherited_linker_flags='-framework Cocoa -framework ApplicationServices'/" < libboth.la.bak > libboth.la
109 AT_CHECK([$LIBTOOL -n --mode=link --tag=CC $CC $CFLAGS $LDFLAGS -framework Cocoa -framework ApplicationServices -o libbaz.la baz.lo libboth.la -no-undefined -rpath /nonexistent],
110 [], [stdout], [ignore])
111 AT_CHECK([$GREP Cocoa.ltframework stdout], [1], [], [])
112 AT_CHECK([$GREP ' -framework Cocoa' stdout], [0], [ignore], [])