Imported Upstream version 2.4.2
[platform/upstream/libtool.git] / tests / destdir.at
1 # destdir.at -- test various DESTDIR issues                   -*- Autotest -*-
2
3 #   Copyright (C) 2006, 2007 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_BANNER([DESTDIR tests])
26
27 # Common setup for the next few tests.
28 m4_pushdef([_LT_DIRSETUP],
29 [# DESTDIR installs do not work with relink at install time.
30 AT_XFAIL_IF([eval `$LIBTOOL --config | grep '^fast_install='`
31            case $fast_install in no) :;; *) false;; esac])
32 LDFLAGS="$LDFLAGS -no-undefined"
33 if test -n "$we_are_on_a_safe_system"; then # let's read shorter cmdlines.
34   DESTDIR=/tmp/dest
35   prefix=/tmp/inst
36   rm -rf $DESTDIR $prefix
37 else
38   DESTDIR=`pwd`/dest
39   prefix=`pwd`/inst
40 fi
41 libdir=$prefix/lib
42 bindir=$prefix/bin
43 $mkdir_p src $prefix $DESTDIR $DESTDIR$prefix
44 eval `$LIBTOOL --config | $EGREP '^(FGREP|OBJDUMP)='`
45 ])
46
47
48 AT_SETUP([Simple DESTDIR install])
49 AT_KEYWORDS([libtool])
50
51 # A program that depends upon a library, both in the same package.
52 _LT_DIRSETUP
53 cd src
54 echo 'int a() { return 0; }' > a.c
55 $LIBTOOL --mode=compile $CC $CPPFLAGS $CFLAGS -c a.c
56 $LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o liba.la a.lo -rpath $libdir
57 echo 'extern int a(); int main() { return a(); }' > m.c
58 $CC $CPPFLAGS $CFLAGS -c m.c
59 $LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o m$EXEEXT m.$OBJEXT liba.la
60 mkdir $DESTDIR$libdir $DESTDIR$bindir
61 AT_CHECK([$LIBTOOL --mode=install cp liba.la $DESTDIR$libdir/liba.la],
62          [], [ignore], [ignore])
63 AT_CHECK([$LIBTOOL --mode=install cp m$EXEEXT $DESTDIR$bindir/m$EXEEXT],
64          [], [ignore], [ignore])
65 $LIBTOOL --mode=clean rm -f liba.la m
66 LT_AT_MVDIR(["$DESTDIR$libdir"], ["$libdir"])
67 LT_AT_MVDIR(["$DESTDIR$bindir"], ["$bindir"])
68 # We ignore failure on purpose here: we may not be root.
69 AT_CHECK([$LIBTOOL --mode=finish $libdir], [ignore], [ignore], [ignore])
70 LT_AT_EXEC_CHECK([$bindir/m$EXEEXT])
71
72 AT_CLEANUP
73
74
75 AT_SETUP([DESTDIR with in-package deplibs])
76 AT_KEYWORDS([libtool])
77
78 # A program that depends upon a library that depends upon another
79 # library, all in the same package.  Use two deplibs, one in $libdir
80 # and one in another directory.
81 _LT_DIRSETUP
82 cd src
83 echo 'int a1dep() { return 0; }' > a1dep.c
84 $LIBTOOL --mode=compile $CC $CPPFLAGS $CFLAGS -c a1dep.c
85 $LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o liba1dep.la a1dep.lo -rpath $libdir
86 echo 'int a2dep() { return 0; }' > a2dep.c
87 $LIBTOOL --mode=compile $CC $CPPFLAGS $CFLAGS -c a2dep.c
88 $LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o liba2dep.la a2dep.lo -rpath ${libdir}2
89 echo 'extern int a1dep(), a2dep(); int a() { return a1dep() + a2dep(); }' > a.c
90 $LIBTOOL --mode=compile $CC $CPPFLAGS $CFLAGS -c a.c
91 $LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o liba.la a.lo -rpath $libdir liba1dep.la liba2dep.la
92 echo 'extern int a(); int main() { return a(); }' > m.c
93 $CC $CPPFLAGS $CFLAGS -c m.c
94 $LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o m$EXEEXT m.$OBJEXT liba.la
95 mkdir $DESTDIR$libdir $DESTDIR${libdir}2 $DESTDIR$bindir
96 AT_CHECK([$LIBTOOL --mode=install cp liba1dep.la $DESTDIR$libdir/liba1dep.la],
97          [], [ignore], [ignore])
98 AT_CHECK([$LIBTOOL --mode=install cp liba2dep.la $DESTDIR${libdir}2/liba2dep.la],
99          [], [ignore], [ignore])
100 AT_CHECK([$LIBTOOL --mode=install cp liba.la $DESTDIR$libdir/liba.la],
101          [], [ignore], [ignore])
102 AT_CHECK([$LIBTOOL --mode=install cp m$EXEEXT $DESTDIR$bindir/m$EXEEXT],
103          [], [ignore], [ignore])
104 $LIBTOOL --mode=clean rm -f liba1dep.la liba2dep.la liba.la m
105 LT_AT_MVDIR(["$DESTDIR$libdir"], ["$libdir"])
106 LT_AT_MVDIR(["$DESTDIR${libdir}2"], ["${libdir}2"])
107 LT_AT_MVDIR(["$DESTDIR$bindir"], ["$bindir"])
108 # We ignore failure on purpose here: we may not be root.
109 AT_CHECK([$LIBTOOL --mode=finish $libdir ${libdir}2], [ignore], [ignore], [ignore])
110
111 # put false libraries in the DESTDIR paths: if the installed program
112 # refers to them, that is a bug.
113 mkdir $DESTDIR$libdir $DESTDIR${libdir}2 $DESTDIR$bindir
114 for lib in a1dep a2dep a; do
115   case $lib in
116   a2dep) ldir=${libdir}2;;
117   *)     ldir=$libdir;;
118   esac
119   echo "int this_should_not_be_linked_against () { return 0; }" > $lib.c
120   $LIBTOOL --mode=compile $CC $CPPFLAGS $CFLAGS -c $lib.c
121   # Note the rpath argument includes $DESTDIR: the installed false libs
122   # should be functional (i.e., not need `libtool --mode=finish').
123   $LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o lib$lib.la $lib.lo -rpath $DESTDIR$ldir
124   $LIBTOOL --mode=install cp lib$lib.la $DESTDIR$ldir/lib$lib.la
125 done
126
127 LT_AT_EXEC_CHECK([$bindir/m$EXEEXT])
128
129 # TODO: make this more portable:
130 if test "$OBJDUMP" != false && ($OBJDUMP -p $bindir/m$EXEEXT) >/dev/null 2>&1; then
131   AT_CHECK([$OBJDUMP -p $bindir/m$EXEEXT | $EGREP -i "R(UN)?PATH.*$DESTDIR"], [1])
132   . $libdir/liba.la
133   set x $library_names
134   lname=$2
135   if test -n "$lname"; then
136     AT_CHECK([$OBJDUMP -p $libdir/$lname | $EGREP -i "R(UN)?PATH.*$DESTDIR"], [1])
137   fi
138 fi
139
140 AT_CLEANUP
141
142 m4_popdef([_LT_DIRSETUP])