1 # static.at -- test flags for sysrooting -*- Autotest -*-
3 # Copyright (C) 2009 Free Software Foundation, Inc.
4 # Written by Paolo Bonzini, 2009
6 # This file is part of GNU Libtool.
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.
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.
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.
25 m4_define([SYSROOT_TEST], [
27 AT_KEYWORDS([libtool sysroot])
29 gcc_sysroot=`$CC --print-sysroot 2> /dev/null`
33 AT_CHECK([test -n "$gcc_sysroot" || exit 77])
35 # Detect installation prefix for the compiler
37 for i in crt0.o crt1.o crt2.o crti.o; do
38 j=`$CC --print-file-name $i 2> /dev/null`
39 test $? = 0 || continue
42 prefix=`echo "$j" | sed "s,^$gcc_sysroot\\(.*\\)/lib/$i\$,\\1,"`
46 AT_CHECK([test -n "$prefix" || exit 77])
48 sysroot=`pwd`/sys-root
50 # difficult to use AS_DIRNAME inside the AT_CHECK macro, so
51 # encapsulate as a shell function.
57 (cd "$gcc_sysroot" && find ".$prefix/bin" ".$prefix/include" ".$prefix/lib" \! -type d) | \
59 dir=`local_dirname "$sysroot/$file"`
60 test -d "$dir" || mkdir -p "$dir"
61 rm -f "$sysroot/$file"
62 ln -s "$gcc_sysroot/$file" "$sysroot/$file" || \
63 cp "$gcc_sysroot/$file" "$sysroot/$file"
66 LDFLAGS="$LDFLAGS --sysroot=$sysroot -no-undefined"
67 configure_options="$configure_options --with-sysroot=$sysroot --prefix=$prefix"
70 if test "$shlibpath_var" = PATH; then
71 configure_options="$configure_options --libdir=/$prefix/bin"
74 AT_CHECK([mkdir lib1 lib2 prog])
76 # Build and install package 1.
77 AT_DATA([lib1/configure.ac],
78 [[AC_INIT([lib1], [1.0])
79 AM_INIT_AUTOMAKE([foreign])
81 AC_CONFIG_SRCDIR([lib1.c])
86 AT_DATA([lib1/Makefile.am],
87 [[lib_LTLIBRARIES = lib1.la
88 lib1_la_SOURCES = lib1.c
89 lib1_la_LDFLAGS = -rpath $(libdir)
92 AT_DATA([lib1/lib1.c],
95 char *f(const char *s)
102 LT_AT_BOOTSTRAP([], [-I $abs_top_srcdir/libltdl/m4], [ignore],
103 [--add-missing], [], [], [all])
105 AT_CHECK([$MAKE install DESTDIR=$sysroot], [0], [ignore], [ignore])
106 AT_CHECK([test -f "$sysroot/$prefix/lib/lib1.la"])
107 AT_CHECK([grep -F "$sysroot" "$sysroot/$prefix/lib/lib1.la"], [1])
110 # Build and install package 2.
111 AT_DATA([lib2/configure.ac],
112 [[AC_INIT([lib2], [1.0])
113 AM_INIT_AUTOMAKE([foreign])
115 AC_CONFIG_SRCDIR([lib2.c])
117 sysroot=$with_sysroot
122 AT_DATA([lib2/Makefile.am],
123 [[lib_LTLIBRARIES = lib2.la
124 lib2_la_SOURCES = lib2.c
125 lib2_la_LDFLAGS = -rpath $(libdir)
126 lib2_la_LIBADD = $2]1[$3
129 AT_DATA([lib2/lib2.c],
133 extern char *f(const char *s);
134 char *g(const char *s)
143 LT_AT_BOOTSTRAP([], [-I $abs_top_srcdir/libltdl/m4], [ignore],
144 [--add-missing], [], [], [all])
146 AT_CHECK([$MAKE install DESTDIR=$sysroot], [0], [ignore], [ignore])
147 AT_CHECK([test -f $sysroot/$prefix/lib/lib2.la])
148 AT_CHECK([grep -F "$sysroot" "$sysroot/$prefix/lib/lib2.la"], [1])
151 # Build and install a program.
152 AT_DATA([prog/configure.ac],
153 [[AC_INIT([prog], [1.0])
154 AM_INIT_AUTOMAKE([foreign])
156 AC_CONFIG_SRCDIR([prog.c])
158 sysroot=$with_sysroot
163 AT_DATA([prog/Makefile.am],
164 [[bin_PROGRAMS = prog
165 prog_SOURCES = prog.c
169 AT_DATA([prog/prog.c],
173 extern char *g(const char *s);
176 char *q = g("hello world");
183 LT_AT_BOOTSTRAP([], [-I $abs_top_srcdir/libltdl/m4], [ignore],
184 [--add-missing], [], [], [all])
186 AT_CHECK([$MAKE install DESTDIR=$sysroot], [0], [ignore], [ignore])
187 AT_CHECK([test -f $sysroot/$prefix/bin/prog$EXEEXT])
188 AT_CHECK([grep -F "$sysroot" "$sysroot/$prefix/bin/prog$EXEEXT"], [1])
189 AT_CHECK([grep "'.*=" $sysroot/$prefix/lib/lib2.la], [0], [ignore])
190 AT_CHECK([./libtool --mode=finish $sysroot/$prefix/lib/lib@<:@12@:>@.la], [0], [ignore])
191 AT_CHECK([grep "'.*=" $sysroot/$prefix/lib/lib@<:@12@:>@.la], [1])
194 # 1) pass absolute .la files
195 # 2) pass absolute -L
196 # 2) pass relative .la files
202 AT_BANNER([sysroot tests])
203 SYSROOT_TEST([-L=.../lib -l], [-L=$(libdir) -l], [])
204 SYSROOT_TEST([-L SYSROOT/.../lib -l], [-L$(sysroot)$(libdir) -l], [])
205 SYSROOT_TEST([SYSROOT/.../*.la], [$(sysroot)$(libdir)/lib], [.la])
207 dnl This one does not make sense.
208 dnl SYSROOT_TEST([=.../*.la], [=$(libdir)/lib], [.la])