Imported Upstream version 2.4.2
[platform/upstream/libtool.git] / tests / deplibs-ident.at
1 # deplibs-ident.at -- detecting identical deplibs              -*- Autotest -*-
2
3 #   Copyright (C) 2005, 2007, 2008 Free Software Foundation, Inc.
4 #   Written by Ralf Wildenhues, 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 AT_BANNER([Detecting identical deplibs.])
26
27
28 ## ----------------------------------------------- ##
29 ## Different relative paths within the build tree. ##
30 ## ----------------------------------------------- ##
31
32 AT_SETUP([build tree relpaths])
33 AT_KEYWORDS([libtool])
34
35 mkdir a a/b c
36 echo 'int c() { return 0; }' > c/libcee.c
37 AT_CHECK([$LIBTOOL --mode=compile $CC $CPPFLAGS $CFLAGS -c c/libcee.c -o c/libcee.lo],
38          [0],[ignore],[ignore])
39 AT_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o c/libcee.la c/libcee.lo -rpath /nowhere],
40          [0],[ignore],[ignore])
41
42 depl_1=../c/libcee.la
43 depl_2=`pwd`/c/libcee.la
44 depl_3="-L../c -lcee"
45
46 (
47   cd a
48   for i in 1 2 3; do
49     eval depend_on_c=\"\$depl_$i\"
50     echo "extern int c(void); int a$i() { return c(); }" > liba$i.c
51     AT_CHECK([$LIBTOOL --mode=compile $CC $CPPFLAGS $CFLAGS -c liba$i.c],
52              [0],[ignore],[ignore])
53     AT_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o liba$i.la liba$i.lo $depend_on_c -rpath /nowhere],
54            [0],[ignore],[ignore])
55   done
56 )
57
58 AT_DATA([a/b/b.c],
59 [[extern int a1(void), a2(void), a3(void), c(void);
60 int main() { return a1() + a2() + a3() + c(); }
61 ]])
62
63 (
64   cd a/b
65   AT_CHECK([$CC $CFLAGS -c b.c],[0],[ignore],[ignore])
66   AT_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o b$EXEEXT b.$OBJEXT ../liba1.la ../liba2.la ../liba3.la ../../c/libcee.la -rpath /nowhere],
67            [0],[stdout],[ignore])
68   AT_CHECK([$EGREP 'cee.*cee' stdout], 1, [ignore], [ignore])
69   AT_XFAIL_IF([case $host in
70                  *-*-aix*|hppa*-*-hpux*|*-*-interix*|*-*-openbsd*) false;;
71                  *):;;
72                esac])
73   dnl This is currently broken in libtool
74 )
75
76 AT_CLEANUP