Imported Upstream version 2.4.2
[platform/upstream/libtool.git] / tests / inherited_flags.at
1 # inherited_flags.at -- test inherited_linker_flags          -*- Autotest -*-
2 #
3 #   Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
4 #   Written by Peter O'Garman, 2005
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
26 AT_SETUP([inherited_linker_flags])
27 AT_KEYWORDS([libtool])
28
29 AT_DATA([foo.c],
30 [
31 int foo() { return 1;}
32 ])
33
34 AT_DATA([bar.c],
35 [
36 int bar() { return 1;}
37 ])
38
39 AT_DATA([baz.c],
40 [
41 int baz() { return 1;}
42 ])
43
44 AT_DATA([both.c],
45 [
46 int both() { return 1;}
47 ])
48
49 AT_DATA([main.c],
50 [
51 int main() { return 0;}
52 ])
53
54 $LIBTOOL --mode=compile --tag=CC $CC $CPPFLAGS $CFLAGS -c -o foo.lo foo.c
55 $LIBTOOL --mode=compile --tag=CC $CC $CPPFLAGS $CFLAGS -c -o bar.lo bar.c
56 $LIBTOOL --mode=compile --tag=CC $CC $CPPFLAGS $CFLAGS -c -o baz.lo baz.c
57 $LIBTOOL --mode=compile --tag=CC $CC $CPPFLAGS $CFLAGS -c -o both.lo both.c
58 $LIBTOOL --mode=compile --tag=CC $CC $CPPFLAGS $CFLAGS -c -o main.lo main.c
59 $LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS -o libfoo.la foo.lo -rpath /nonexistent -no-undefined
60 $LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS -o libbar.la bar.lo -rpath /nonexistent -no-undefined
61 $LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS -o libboth.la both.lo -rpath /nonexistent -no-undefined
62
63
64 mv libfoo.la libfoo.la.bak
65 sed -e 's/^inherited_linker_flags.*/inherited_linker_flags=-llt_inlikely_existing_lib/g' < libfoo.la.bak > libfoo.la
66 rm libfoo.la.bak
67
68 mv libbar.la libbar.la.bak
69 sed -e 's/^inherited_linker_flags.*/inherited_linker_flags=-llt_unlikely_existing_lib/g' < libbar.la.bak > libbar.la
70 rm libbar.la.bak
71
72 mv libboth.la libboth.la.bak
73 sed -e "s/^inherited_linker_flags.*/inherited_linker_flags='-llt_inlikely_existing_lib -llt_unlikely_existing_lib'/g" < libboth.la.bak > libboth.la
74 rm libboth.la.bak
75
76 AT_CHECK([$LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS -o libbaz.la baz.lo -no-undefined -rpath /nonexistent ./libfoo.la ./libbar.la],
77          [ignore],[stdout],[ignore])
78 # We used to grep for
79 # 'llt_[[ui]]nlikely_existing_lib.*llt_[[ui]]nlikely_existing_lib'
80 # here.  This fails on win32/MSVC because the generated command lines have a
81 # different syntax.  So drop the first `l'.
82 AT_CHECK([$LIBTOOL --features | grep 'disable shared libraries' && (exit 77)], [1], [ignore])
83 AT_CHECK([grep 'lt_[[ui]]nlikely_existing_lib.*lt_[[ui]]nlikely_existing_lib' stdout],
84          [0],[ignore],[ignore])
85 AT_CHECK([$LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS -o main$EXEEXT main.lo -no-undefined -rpath /nonexistent  ./libfoo.la ./libbar.la],
86         [ignore],[stdout],[ignore])
87 AT_CHECK([grep 'lt_[[ui]]nlikely_existing_lib.*lt_[[ui]]nlikely_existing_lib' stdout],
88          [0],[ignore],[ignore])
89
90 # now check for duplicates
91 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],
92          [ignore],[stdout],[ignore])
93 AT_CHECK([grep 'lt_inlikely_existing_lib.*lt_inlikely_existing_lib' stdout],
94          [1],[ignore],[ignore])
95 AT_CHECK([grep 'lt_unlikely_existing_lib.*lt_unlikely_existing_lib' stdout],
96          [1],[ignore],[ignore])
97 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],
98         [ignore],[stdout],[ignore])
99 AT_CHECK([grep 'lt_inlikely_existing_lib.*lt_inlikely_existing_lib' stdout],
100          [1],[ignore],[ignore])
101 AT_CHECK([grep 'lt_unlikely_existing_lib.*lt_unlikely_existing_lib' stdout],
102          [1],[ignore],[ignore])
103
104 mv libboth.la libboth.la.bak
105 sed "s/^inherited_linker_flags.*/inherited_linker_flags='-framework Cocoa -framework ApplicationServices'/" < libboth.la.bak > libboth.la
106 rm libboth.la.bak
107
108 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],
109          [], [stdout], [ignore])
110 AT_CHECK([grep Cocoa.ltframework stdout], [1], [], [])
111 AT_CHECK([grep ' -framework Cocoa' stdout], [0], [ignore], [])
112
113 AT_CLEANUP