libtool/tests/link-order.at
Alexandre Oliva 31327f332d * config/ltmain.m4sh (link mode): Add to tmp_libs paths for libtool dep
libs in reverse order as well.
* Makefile.am, tests/testsuite.at, tests/link-order.at: New test.
2005-04-14 11:59:10 +00:00

89 lines
2.9 KiB
Plaintext

# Hand crafted tests for GNU Libtool. -*- Autotest -*-
# Copyright 2005 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
# link-order.test - make sure that library linking order matches
AT_BANNER([Libtool link order test.])
AT_SETUP([Link order test.])
: ${LIBTOOL=${abs_top_builddir}/libtool}
: ${EGREP='grep -E'}
eval `$LIBTOOL --config | grep ECHO=`
prefix_old=`pwd`/old
prefix_new=`pwd`/new
mkdir src $prefix_old $prefix_new $prefix_old/lib $prefix_new/lib
AT_DATA(src/c.c,
[[int c = 1;
]])
$LIBTOOL --mode=compile $CC $CFLAGS -c src/c.c -o src/c.lo
$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o src/libcee.la src/c.lo -rpath $prefix_old/lib
$LIBTOOL --mode=install cp src/libcee.la $prefix_old/lib/libcee.la
for i in old new; do
rm -rf src
mkdir src
AT_DATA(src/a_$i.c,
[[extern int c;
extern int b_$i();
int a_$i() { return c + b_$i(); }
]])
AT_DATA(src/b_$i.c,
[[extern int c;
int b_$i() { return 1 + c; }
]])
prefix=`eval echo \\$prefix_$i`
$LIBTOOL --mode=compile $CC $CFLAGS -c src/a_$i.c -o src/a.lo
$LIBTOOL --mode=compile $CC $CFLAGS -c src/b_$i.c -o src/b.lo
$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o src/libb.la src/b.lo \
-L$prefix_old/lib -lcee -rpath $prefix/lib
$LIBTOOL --mode=link $CC $CFLAGS -o src/liba.la src/a.lo \
src/libb.la -L$prefix_old/lib -lcee -rpath $prefix/lib
$LIBTOOL --mode=install cp src/libb.la $prefix/lib/libb.la
$LIBTOOL --mode=install cp src/liba.la $prefix/lib/liba.la
done
# Do not error if we do not relink (e.g. static-only systems)
AT_CHECK([$LIBTOOL --mode=install cp src/liba.la $prefix/lib/liba.la >mylog 2>&1;
if $EGREP relinking mylog; then
$EGREP ' -L.*\/new\/lib -lb -L.*\/old\/lib -lcee' mylog
else :;
fi], [0], [ignore], [ignore], [echo "wrong link order"])
for i in old new; do
AT_DATA(src/main_$i.c,
[[extern int a_$i();
int main(void) { return a_$i() != 3; }
]])
prefix=`eval echo \\$prefix_$i`
$LIBTOOL --mode=compile $CC $CFLAGS -c src/main_$i.c -o src/main_$i.lo
AT_CHECK($LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o src/main_$i src/main_$i.lo -L$prefix/lib -la,
[0], [ignore], [ignore])
AT_CHECK(src/main_$i, [0],,,
[AT_CHECK(if test "X$host" != "X$build"; then exit 77; fi)])
done
AT_CLEANUP