Imported Upstream version 2.4.2
[platform/upstream/libtool.git] / tests / duplicate_conv.at
1 # duplicate_conv.at -- duplicate convenience archive names   -*- Autotest -*-
2
3 #   Copyright (C) 2006, 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([duplicate convenience archive names])
26 AT_KEYWORDS([libtool])
27
28 eval `$LIBTOOL --config | sed -n '/^reload_cmds=/,/^$/p'`
29
30 # We create two convenience archives with the same name, and _also_
31 # containing an object with the same name.  This is necessary to detect
32 # the failure with both 1.5.22 and HEAD, since the latter does not (did
33 # not?) remove the temporary output directory, thus masking the failure
34 # when all objects have distinct names.
35
36 mkdir a b c
37
38 echo 'int a () { return 0; }' > a/a.c
39 echo 'int a2() { return 0; }' > b/a.c
40 echo 'int b () { return 0; }' > b/b.c
41 echo 'extern int a(), a2(), b(); int c() { return a() + a2() + b(); }' > c.c
42 echo 'extern int c(); int main() { return c(); }' > main.c
43
44 $LIBTOOL --mode=compile --tag=CC $CC $CPPFLAGS $CFLAGS -c a/a.c -o a/a.lo
45 $LIBTOOL --mode=compile --tag=CC $CC $CPPFLAGS $CFLAGS -c b/a.c -o b/a.lo
46 $LIBTOOL --mode=compile --tag=CC $CC $CPPFLAGS $CFLAGS -c b/b.c -o b/b.lo
47 $LIBTOOL --mode=compile --tag=CC $CC $CPPFLAGS $CFLAGS -c c.c
48 $CC $CPPFLAGS $CFLAGS -c main.c
49 $LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS -o a/liba.la a/a.lo
50 $LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS -o b/liba.la b/a.lo b/b.lo
51
52 # Fold into convenience archive.
53 AT_CHECK([$LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS -o libcee.la c.lo a/liba.la b/liba.la],
54          [0], [ignore], [ignore])
55 AT_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o main$EXEEXT main.$OBJEXT ./libcee.la],
56          [0], [ignore], [ignore])
57 LT_AT_EXEC_CHECK([./main],[0],[ignore],[ignore])
58 $LIBTOOL --mode=clean rm -f libcee.la
59
60
61 # FIXME: For this test, we may want to zero out whole_archive_flag_spec;
62 #        OTOH, we'd like to test the other situation, too.
63
64 # Fold into static library.
65 AT_CHECK([$LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS -rpath /foo -static -o libcee.la c.lo a/liba.la b/liba.la],
66          [0], [ignore], [ignore])
67 AT_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o main$EXEEXT main.$OBJEXT ./libcee.la],
68          [0], [ignore], [ignore])
69 LT_AT_EXEC_CHECK([./main],[0],[ignore],[ignore])
70 $LIBTOOL --mode=clean rm -f libcee.la
71
72 # Fold into library.
73 AT_CHECK([$LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS -rpath /foo -o libcee.la c.lo a/liba.la b/liba.la],
74          [0], [ignore], [ignore])
75 AT_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o main$EXEEXT main.$OBJEXT ./libcee.la],
76          [0], [ignore], [ignore])
77 LT_AT_EXEC_CHECK([./main],[0],[ignore],[ignore])
78 $LIBTOOL --mode=clean rm -f libcee.la
79
80 AT_CHECK([test "x$reload_cmds" = xfalse && exit 77], [1])
81
82 # Test whether this works with reloadable objects as well.
83 AT_CHECK([$LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS -o cee.$OBJEXT c.lo a/liba.la b/liba.la],
84          [0], [ignore], [ignore])
85 AT_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o main$EXEEXT main.$OBJEXT cee.$OBJEXT],
86          [0], [ignore], [ignore])
87 LT_AT_EXEC_CHECK([./main],[0],[ignore],[ignore])
88
89 # TODO: test dlpreloading of duplicates (when it is implemented)
90
91 AT_CLEANUP