2 # demo-hardcode.test - check to see what the system linker hardcodes
4 # Copyright (C) 2003, 2004 Free Software Foundation, Inc.
5 # Written by Gary V. Vaughan, 2003
7 # This file is part of GNU Libtool.
9 # GNU Libtool is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation; either version 2 of
12 # the License, or (at your option) any later version.
14 # GNU Libtool is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with GNU Libtool; see the file COPYING. If not, a copy
21 # can be downloaded from http://www.gnu.org/licenses/gpl.html,
22 # or obtained by writing to the Free Software Foundation, Inc.,
23 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 .
tests
/defs ||
exit 1
28 func_require
"demo-inst" "$prefix/lib/libhello.la"
33 # Check to make sure we have a dynamic library.
34 func_get_config
"library_names" "cat ./libhello.la"
35 test -z "$library_names" \
36 && func_skip
"Exiting: demo/libhello.la is not a shared library"
40 # Extra tools we might need
41 : ${DUMPSTABS=dumpstabs}
43 # Suck in all the hardcode_* variable settings.
44 func_msg
"Finding libtool.m4's guesses at hardcoding values"
45 func_get_config
'hardcode_direct
47 hardcode_shlibpath_var
48 hardcode_libdir_flag_spec' "./libtool --config" ": fatal"
50 echo "= Searching for hardcoded library directories in each program"
53 hc-direct
) expected
="$hardcode_direct" ;;
54 hc-libpath
) expected
="$hardcode_shlibpath_var" ;;
55 hc-minusL
) expected
="$hardcode_minus_L" ;;
58 if test -n "$hardcode_libdir_flag_spec"; then
70 # Discover whether the objdir really was hardcoded.
73 # Solaris cc may store the command line in a debugging section,
74 # which leads to false positives. Unfortunately, Solaris strip
75 # is not capable to remove the section (unlike GNU binutils strip).
76 # So we use dumpstabs if it seems to work.
77 if { $DUMPSTABS -d $file; } >/dev
/null
2>&1; then
78 if $DUMPSTABS -d $file 2>/dev
/null |
$FGREP "$objdir" >/dev
/null
2>&1; then
83 # At least AIX fgrep doesn't work for binary files, and AIX also
84 # doesn't have strings(1), so we need this strange conversion
85 # (which only works on ASCII).
86 # AIX fgrep also has a limited line length, so we turn unprintable
87 # characters into newlines.
88 elif cat $file |
(tr '\000-\037\200-\377' '\n' ||
cat) 2>/dev
/null \
89 |
$FGREP "$objdir" > /dev
/null
2>&1; then
91 elif $FGREP "$objdir" $file > /dev
/null
2>&1; then
92 # We retry fgrep without tr, in case the above lead to a false negative.
94 elif (sed -e '1!d' $file |
grep 'unsupported') >/dev
/null
2>&1; then
101 if test $expected = yes; then
102 echo "$objdir was hardcoded in \`$file', as libtool expected"
104 echo "$objdir was hardcoded in \`$file', which fooled libtool" 1>&2
110 if test $expected = no
; then
111 echo "$objdir was not hardcoded in \`$file', as libtool expected"
113 echo "$objdir was not hardcoded in \`$file', which fooled libtool" 1>&2
119 if test $expected = unsupported
; then
120 echo "\`$file' was not linked properly, as libtool expected"
122 echo "\`$file' was not linked properly, which fooled libtool" 1>&2