#! /bin/sh# hardcode.test - check to see what the system linker hardcodes# Test script header.need_prefix=yesif test -z "$srcdir"; thensrcdir=`echo "$0" | sed 's%/[^/]*$%%'`test "$srcdir" = "$0" && srcdir=.test "${VERBOSE+set}" != "set" && VERBOSE=yesfi. $srcdir/defs || exit 1# Extra tools we might need: ${DUMPSTABS=dumpstabs}# Check that things are built.if test -f $prefix/lib/libhello.la && cd ../demo; then :elseecho "You must run demo-inst.test before $0" 1>&2exit 77fi# Unfortunately, we need access to libtool internals for this test.objdir=NONEeval `grep '^objdir=' ./libtool 2>/dev/null`if test "$objdir" = NONE; thenecho "objdir not set in ../demo/libtool" 1>&2exit 1fi# Check to make sure we have a dynamic library.library_names=NONEeval `grep '^library_names=' ./libhello.la 2>/dev/null`if test "$library_names" = NONE; thenecho "library_names not set in ../demo/libhello.la" 1>&2exit 1elif test -z "$library_names"; thenecho "= Exiting: ../demo/libhello.la is not a shared library"exit 0fiecho "= Running $make hardcode in ../demo"$make hardcode || exit 1echo "= Finding libtool.m4's guesses at hardcoding values"status=0hardcode_direct=NONEhardcode_minus_L=NONEhardcode_shlibpath_var=NONEhardcode_libdir_flag_spec=NONE# Suck in all the hardcode_* variable settings.eval `./libtool --config | grep '^hardcode_' 2>/dev/null`if test "$hardcode_direct" = NONE; thenecho "hardcode_direct not set in ../demo/libtool" 1>&2status=1fiif test "$hardcode_minus_L" = NONE; thenecho "hardcode_minus_L not set in ../demo/libtool" 1>&2status=1fiif test "$hardcode_shlibpath_var" = NONE; thenecho "hardcode_shlibpath_var not set in ../demo/libtool" 1>&2status=1fiif test "$hardcode_libdir_flag_spec" = NONE; thenecho "hardcode_libdir_flag_spec not set in ../demo/libtool" 1>&2status=1fitest $status -eq 0 || exit $statusecho "= Searching for hardcoded library directories in each program"for file in hc-*; docase "$file" inhc-direct) expected="$hardcode_direct" ;;hc-libpath) expected="$hardcode_shlibpath_var" ;;hc-minusL) expected="$hardcode_minus_L" ;;hc-libflag)if test -n "$hardcode_libdir_flag_spec"; thenexpected=yeselseexpected=unsupportedfi;;*)continue;;esac# Discover whether the objdir really was hardcoded.hardcoded=no# Solaris cc may store the command line in a debugging section,# which leads to false positives. Unfortunately, Solaris strip# is not capable to remove the section (unlike GNU binutils strip).# So we use dumpstabs if it seems to work.if { $DUMPSTABS -d $file; } >/dev/null 2>&1; thenif $DUMPSTABS -d $file 2>/dev/null | $FGREP "$objdir" >/dev/null 2>&1; thenhardcoded=yeselsehardcoded=nofi# At least AIX fgrep doesn't work for binary files, and AIX also# doesn't have strings(1), so we need this strange conversion# (which only works on ASCII).# AIX fgrep also has a limited line length, so we turn unprintable# characters into newlines.elif cat $file | (tr '\000-\037\200-\377' '\n' || cat) 2>/dev/null \| $FGREP "$objdir" > /dev/null 2>&1; thenhardcoded=yeselif $FGREP "$objdir" $file > /dev/null 2>&1; then# We retry fgrep without tr, in case the above lead to a false negative.hardcoded=yeselif (sed -e '1!d' $file | grep 'unsupported') >/dev/null 2>&1; thenhardcoded=unsupportedfi# Check the result.case "$hardcoded" inyes)if test $expected = yes; thenecho "$objdir was hardcoded in \`$file', as libtool expected"elseecho "$objdir was hardcoded in \`$file', which fooled libtool" 1>&2status=1fi;;no)if test $expected = no; thenecho "$objdir was not hardcoded in \`$file', as libtool expected"elseecho "$objdir was not hardcoded in \`$file', which fooled libtool" 1>&2status=1fi;;unsupported)if test $expected = unsupported; thenecho "\`$file' was not linked properly, as libtool expected"elseecho "\`$file' was not linked properly, which fooled libtool" 1>&2status=1fi;;esacdoneexit $status