164880Sphk#! /bin/sh 2130678Sphk# build-relink.test - check to see whether shlibpath overrides runpath 364880Sphk 464880Sphk# Test script header. 564880Sphkneed_prefix=yes 664880Sphkif test -z "$srcdir"; then 764880Sphk srcdir=`echo "$0" | sed 's%/[^/]*$%%'` 864880Sphk test "$srcdir" = "$0" && srcdir=. 964880Sphk test "${VERBOSE+set}" != "set" && VERBOSE=yes 1064880Sphkfi 1164880Sphk. $srcdir/defs || exit 1 1264880Sphk 1364880Sphk# Check that things are built. 1464880Sphkif test -f $prefix/lib/libhello.la && cd ../demo && test -f libhello.la; then : 1564880Sphkelse 1664880Sphk echo "You must run demo-inst.test before $0" 1>&2 1764880Sphk exit 77 1864880Sphkfi 1964880Sphk 2064880Sphk# Check to make sure we have a dynamic library. 2164880Sphklibrary_names=NONE 2264880Sphkeval `grep '^library_names=' ./libhello.la 2>/dev/null` 2364880Sphk 2464880Sphkif test "$library_names" = NONE; then 2564880Sphk echo "library_names not set in ../demo/libhello.la" 1>&2 2664880Sphk exit 1 2764880Sphkelif test -z "$library_names"; then 2864880Sphk echo "= Exiting: ../demo/libhello.la is not a shared library" 2964880Sphk exit 77 3064880Sphkfi 3165515Sphk 32101069Srwatson# Unfortunately, we need access to libtool internals for this test. 3365515Sphkobjdir=NONE 3464880Sphkeval `grep '^objdir=' ./libtool 2>/dev/null` 3564880Sphkif test "$objdir" = NONE; then 3676166Smarkm echo "objdir not set in ../demo/libtool" 1>&2 3764880Sphk exit 1 3876166Smarkmfi 3976166Smarkm 40101069Srwatsonshlibpath_overrides_runpath=NONE 4164880Sphkeval `grep '^shlibpath_overrides_runpath=' ./libtool 2>/dev/null` 4276166Smarkmif test "$shlibpath_overrides_runpath" = NONE; then 4365515Sphk echo "shlibpath_overrides_runpath not set in ../demo/libtool" 1>&2 4476166Smarkm exit 1 4564880Sphkfi 4665515Sphk 4765515Sphkhardcode_action=NONE 4864880Sphkeval `grep '^hardcode_action=' ./libtool 2>/dev/null` 4964880Sphkif test "$hardcode_action" = NONE; then 50130585Sphk echo "hardcode_action not set in ../demo/libtool" 1>&2 51130585Sphk exit 1 5265515Sphkfi 5365515Sphk 5465515Sphkhardcode_direct=NONE 5565515Sphkeval `grep '^hardcode_direct=' ./libtool 2>/dev/null` 5665515Sphkif test "$hardcode_direct" = NONE; then 5765515Sphk echo "hardcode_direct not set in ../demo/libtool" 1>&2 5865515Sphk exit 1 5965515Sphkfi 6065515Sphk 6169767Sphkhardcode_into_libs=NONE 6269767Sphkeval `grep '^hardcode_into_libs=' ./libtool 2>/dev/null` 6365515Sphkif test "$hardcode_into_libs" = NONE; then 6465515Sphk echo "hardcode_into_libs not set in ../demo/libtool" 1>&2 6565515Sphk exit 1 6665515Sphkfi 6765515Sphk 6865515Sphk./hell # so that it links on-demand if needed 6965515Sphk 7065515Sphkecho "removing libhello.la from ../demo" 7165515Sphkrm -f libhello.la $objdir/libhello.* 7265515Sphk 7365515Sphkecho "running ../demo/hell" 7465515Sphkif ./hell; then 7565515Sphk : 7665515Sphkelif test "x,$hardcode_action,$hardcode_direct" = x,relink,yes; then 7765515Sphk echo "Ok, uninstalled programs fail after uninstalled libraries are removed" 7865515Sphk echo "This works in other configurations, but not in this particular one" 7965515Sphkelse 8065515Sphk echo "= Exiting: ../demo/hell does not run, maybe libhello was not installed" 8165515Sphk exit 1 8265515Sphkfi 8365515Sphk 8465515Sphkecho "linking a broken ../demo/libhello.la" 8565515Sphkif $make libhello.la libhello_la_OBJECTS=hello.lo; then 8665515Sphk : 8765515Sphkelse 8865515Sphk echo "= Exiting: cannot link broken libhello.la" 8965515Sphk exit 1 9065515Sphkfi 9165515Sphkrm -f libhello.la 9265515Sphk 9365515Sphkecho "running ../demo/hell with broken libhello.la" 9465515Sphkif (./hell) 2>&1; then 9565515Sphk echo "= Exiting: ../demo/hell runs even though libhello.la is incomplete" 9665515Sphk echo "shlibpath_overrides_runpath should be set to no" 97130585Sphk exit 1 9865515Sphkelse 9965515Sphk echo "Failed, as expected" 10065515Sphkfi 10165515Sphk 10265515Sphkif test "x$hardcode_action" = xrelink; then 10365515Sphk echo "= Exiting: install-time relinking is required" 10465515Sphk exit 0 10565515Sphkfi 10665515Sphk 10765515Sphkif test "$shlibpath_overrides_runpath" != yes; then 10865515Sphk rm -f $objdir/lt-hell$EXEEXT || exit 1 10965515Sphk cp $objdir/hell$EXEEXT $objdir/lt-hell$EXEEXT || exit 1 11065515Sphk echo "running ../demo/hell with installed libhello.la" 11165515Sphk if ./hell; then 11265515Sphk echo "Worked, as expected" 11365515Sphk else 11465515Sphk echo "shlibpath_overrides_runpath should be set to yes" 11565515Sphk status=1 11665515Sphk fi 11765515Sphk rm -f $objdir/lt-hell$EXEEXT 11865515Sphkfi 11965515Sphk 12065515Sphkexit $status 12165515Sphk