Imported Upstream version 2.4.2
[platform/upstream/libtool.git] / tests / shlibpath.at
1 # shlibpath.at -- Test shlibpath settings                     -*- 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([shlibpath_overrides_runpath])
26 AT_KEYWORDS([libtool])
27
28 mkdir sub sub/lib sub/bin
29 echo 'int a () { return 0; }' > a.c
30 echo 'extern int a (); int main () { return a(); }' > m.c
31 $LIBTOOL --mode=compile $CC $CPPFLAGS $CFLAGS -c a.c
32 $LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o liba.la a.lo -rpath `pwd`/sub/lib
33 $LIBTOOL --mode=install cp liba.la `pwd`/sub/lib/liba.la
34 $LIBTOOL --mode=clean rm -f liba.la
35 rm -f sub/lib/liba.la
36
37 $CC $CPPFLAGS $CFLAGS -c m.c
38 AT_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o m$EXEEXT m.$OBJEXT -Lsub/lib -la -R`pwd`/sub/lib],
39          [], [ignore], [ignore])
40 AT_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o m2$EXEEXT m.$OBJEXT -Lsub/lib -la],
41          [], [ignore], [ignore])
42
43 LT_AT_MVDIR([sub], [moved])
44 mkdir sub sub/lib sub/bin
45 echo 'int wrong_lib () { return 0; }' > a.c
46 $LIBTOOL --mode=compile $CC $CPPFLAGS $CFLAGS -c a.c
47 $LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o liba.la a.lo -rpath `pwd`/sub/lib
48 $LIBTOOL --mode=install cp liba.la `pwd`/sub/lib/liba.la
49 $LIBTOOL --mode=clean rm -f liba.la
50
51 eval `$LIBTOOL --config | $EGREP '^(shlibpath_var|shlibpath_overrides_runpath)='`
52
53 # No point checking a system with static libraries:
54 LT_AT_EXEC_CHECK([./m], [1], [ignore], [ignore], [|| exit 1 && exit 77])
55
56 if test "$shlibpath_var" = PATH; then
57   addpath=`pwd`/moved/bin
58 else
59   addpath=`pwd`/moved/lib
60 fi
61 sep=
62 eval test -n \"\$$shlibpath_var\" && sep=:
63 eval $shlibpath_var='$addpath$sep$'$shlibpath_var
64 export $shlibpath_var
65 if test "$shlibpath_overrides_runpath" != no; then
66   LT_AT_EXEC_CHECK([./m], [0], [ignore], [ignore])
67 else
68   LT_AT_EXEC_CHECK([./m], [1], [ignore], [ignore], [|| exit 1])
69 fi
70 # Test that shlibpath_var is effective in adding paths at all:
71 LT_AT_EXEC_CHECK([./m2], [0], [ignore], [ignore])
72
73 AT_CLEANUP