1997-04-02 03:18:28 +08:00
|
|
|
#! /bin/sh
|
2003-10-15 05:46:13 +08:00
|
|
|
# demo-hardcode.test - check to see what the system linker hardcodes
|
|
|
|
|
Since defs can change (path to grep for example) when it is made
for a different host, it can't be shipped. That also means that
defs will always be generated in the build tree, so each test case
can have the srcdir discovery factored away into tests/defs.in:
* Makefile.am (EXTRA_DIST): s/defs/defs.in/g
* tests/Makefile.am (defs): New rule to remake defs from the
parent directory's Makefile.
* tests/cdemo-conf.test, tests/cdemo-exec.test,
tests/cdemo-make.test, tests/cdemo-shared.test,
tests/cdemo-static.test, tests/demo-conf.test,
tests/demo-deplibs.test, tests/demo-exec.test,
tests/demo-hardcode.test, tests/demo-inst.test,
tests/demo-make.test, tests/demo-nofast.test,
tests/demo-noinst-link.test, tests/demo-nopic.test,
tests/demo-pic.test, tests/demo-relink.test,
tests/demo-shared.test, tests/demo-static.test,
tests/demo-unst.test, tests/depdemo-conf.test,
tests/depdemo-exec.test, tests/depdemo-inst.test,
tests/depdemo-make.test, tests/depdemo-nofast.test,
tests/depdemo-relink.test, tests/depdemo-shared.test,
tests/depdemo-static.test, tests/depdemo-unst.test,
tests/f77demo-conf.test, tests/f77demo-exec.test,
tests/f77demo-make.test, tests/f77demo-shared.test,
tests/f77demo-static.test, tests/link-2.test, tests/link.test,
tests/mdemo-conf.test, tests/mdemo-dryrun.test,
tests/mdemo-exec.test, tests/mdemo-inst.test,
tests/mdemo-make.test, tests/mdemo-shared.test,
tests/mdemo-static.test, tests/mdemo-unst.test,
tests/mdemo2-conf.test, tests/mdemo2-exec.test,
tests/mdemo2-make.test, tests/nomode.test, tests/pdemo-conf.test,
tests/pdemo-exec.test, tests/pdemo-inst.test,
tests/pdemo-make.test, tests/quote.test, tests/sh.test,
tests/suffix.test, tests/tagdemo-conf.test,
tests/tagdemo-exec.test, tests/tagdemo-make.test,
tests/tagdemo-shared.test, tests/tagdemo-static.test,
tests/tagtrace.test: Removed srcdir discovery boilerplate...
* tests/defs.in: ...and put it here.
2004-09-23 21:07:15 +08:00
|
|
|
# Copyright (C) 2003, 2004 Free Software Foundation, Inc.
|
2003-10-15 05:46:13 +08:00
|
|
|
# This is free software; see the source for copying conditions. There is NO
|
|
|
|
# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
# 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 of the License, 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, a copy can be downloaded from
|
|
|
|
# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free
|
2005-04-22 18:10:31 +08:00
|
|
|
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
|
|
# MA 02110-1301, USA.
|
1997-04-02 03:18:28 +08:00
|
|
|
|
Since the bootstrap process requires that several of the rules for
files generated in doc and tests already lived in
$top_srcdir/Makefile.am, along with proxy rules in sub-Makefiles,
this changeset consolidates almost everything into the top
Makefile.am, simplifying things considerably:
* doc/Makefile.am, tests/Makefile.am: Removed. All rules moved...
* Makefile.am: ...to here and adjusted to run from $top_builddir.
Some reformatting to group rules and declarations by purpose, and
simplify with respect to removing much of the make recursion.
Add `doc/PLATFORMS', `doc/fdl.texi' and `doc/notes.texi'.
`defs.in' and `defs.m4sh' are in directory `tests'.
(uninstall-hook): Don't forget to uninstall libtoolize's libltdl
source tree.
* bootstrap: Simplified dirty makefile management, and bootstrap
file creation in light of having only a single pertinent
Makefile.
* configure.ac (CONF_SUBDIRS): Add tests/ prefix to each subdir to
compensate.
(DIST_MAKEFILE_LIST): Adjust.
(AC_CONFIG_FILES): Remove doc/Makefile and tests/Makefile.
* tests/defs.m4sh (LIBTOOL, scripts): Adjust paths.
* tests/cdemo-conf.test, tests/cdemo-exec.test,
tests/cdemo-make.test, tests/cdemo-shared.test,
tests/cdemo-static.test, tests/cdemo-undef.test,
tests/demo-conf.test, tests/demo-deplibs.test,
tests/demo-exec.test, tests/demo-hardcode.test,
tests/demo-inst.test, tests/demo-make.test,
tests/demo-nofast.test, tests/demo-noinst-link.test,
tests/demo-nopic.test, tests/demo-pic.test,
tests/demo-relink.test, tests/demo-shared.test,
tests/demo-static.test, tests/demo-unst.test,
tests/depdemo-conf.test, tests/depdemo-exec.test,
tests/depdemo-inst.test, tests/depdemo-make.test,
tests/depdemo-nofast.test, tests/depdemo-relink.test,
tests/depdemo-shared.test, tests/depdemo-static.test,
tests/depdemo-unst.test, tests/f77demo-conf.test,
tests/f77demo-exec.test, tests/f77demo-make.test,
tests/f77demo-shared.test, tests/f77demo-static.test,
tests/link-2.test, tests/link.test, tests/mdemo-conf.test,
tests/mdemo-dryrun.test, tests/mdemo-exec.test,
tests/mdemo-inst.test, tests/mdemo-make.test,
tests/mdemo-shared.test, tests/mdemo-static.test,
tests/mdemo-unst.test, tests/mdemo2-conf.test,
tests/mdemo2-exec.test, tests/mdemo2-make.test, tests/nomode.test,
tests/objectlist.test, tests/pdemo-conf.test,
tests/pdemo-exec.test, tests/pdemo-inst.test,
tests/pdemo-make.test, tests/quote.test, tests/sh.test,
tests/suffix.test, tests/tagdemo-conf.test,
tests/tagdemo-exec.test, tests/tagdemo-make.test,
tests/tagdemo-shared.test, tests/tagdemo-static.test,
tests/tagdemo-undef.test, tests/tagtrace.test (func_cd,
func_require): Adjust paths..
2005-04-13 20:24:35 +08:00
|
|
|
. tests/defs || exit 1
|
1997-04-02 03:18:28 +08:00
|
|
|
|
2003-10-15 05:46:13 +08:00
|
|
|
func_require "demo-inst" "$prefix/lib/libhello.la"
|
1997-04-02 03:18:28 +08:00
|
|
|
|
2003-10-15 05:46:13 +08:00
|
|
|
func_mkprefixdir
|
Since the bootstrap process requires that several of the rules for
files generated in doc and tests already lived in
$top_srcdir/Makefile.am, along with proxy rules in sub-Makefiles,
this changeset consolidates almost everything into the top
Makefile.am, simplifying things considerably:
* doc/Makefile.am, tests/Makefile.am: Removed. All rules moved...
* Makefile.am: ...to here and adjusted to run from $top_builddir.
Some reformatting to group rules and declarations by purpose, and
simplify with respect to removing much of the make recursion.
Add `doc/PLATFORMS', `doc/fdl.texi' and `doc/notes.texi'.
`defs.in' and `defs.m4sh' are in directory `tests'.
(uninstall-hook): Don't forget to uninstall libtoolize's libltdl
source tree.
* bootstrap: Simplified dirty makefile management, and bootstrap
file creation in light of having only a single pertinent
Makefile.
* configure.ac (CONF_SUBDIRS): Add tests/ prefix to each subdir to
compensate.
(DIST_MAKEFILE_LIST): Adjust.
(AC_CONFIG_FILES): Remove doc/Makefile and tests/Makefile.
* tests/defs.m4sh (LIBTOOL, scripts): Adjust paths.
* tests/cdemo-conf.test, tests/cdemo-exec.test,
tests/cdemo-make.test, tests/cdemo-shared.test,
tests/cdemo-static.test, tests/cdemo-undef.test,
tests/demo-conf.test, tests/demo-deplibs.test,
tests/demo-exec.test, tests/demo-hardcode.test,
tests/demo-inst.test, tests/demo-make.test,
tests/demo-nofast.test, tests/demo-noinst-link.test,
tests/demo-nopic.test, tests/demo-pic.test,
tests/demo-relink.test, tests/demo-shared.test,
tests/demo-static.test, tests/demo-unst.test,
tests/depdemo-conf.test, tests/depdemo-exec.test,
tests/depdemo-inst.test, tests/depdemo-make.test,
tests/depdemo-nofast.test, tests/depdemo-relink.test,
tests/depdemo-shared.test, tests/depdemo-static.test,
tests/depdemo-unst.test, tests/f77demo-conf.test,
tests/f77demo-exec.test, tests/f77demo-make.test,
tests/f77demo-shared.test, tests/f77demo-static.test,
tests/link-2.test, tests/link.test, tests/mdemo-conf.test,
tests/mdemo-dryrun.test, tests/mdemo-exec.test,
tests/mdemo-inst.test, tests/mdemo-make.test,
tests/mdemo-shared.test, tests/mdemo-static.test,
tests/mdemo-unst.test, tests/mdemo2-conf.test,
tests/mdemo2-exec.test, tests/mdemo2-make.test, tests/nomode.test,
tests/objectlist.test, tests/pdemo-conf.test,
tests/pdemo-exec.test, tests/pdemo-inst.test,
tests/pdemo-make.test, tests/quote.test, tests/sh.test,
tests/suffix.test, tests/tagdemo-conf.test,
tests/tagdemo-exec.test, tests/tagdemo-make.test,
tests/tagdemo-shared.test, tests/tagdemo-static.test,
tests/tagdemo-undef.test, tests/tagtrace.test (func_cd,
func_require): Adjust paths..
2005-04-13 20:24:35 +08:00
|
|
|
func_cd "tests/demo"
|
1997-09-15 22:12:49 +08:00
|
|
|
|
1997-04-02 03:21:43 +08:00
|
|
|
# Check to make sure we have a dynamic library.
|
2003-10-15 05:46:13 +08:00
|
|
|
func_get_config "library_names" "cat ./libhello.la"
|
|
|
|
test -z "$library_names" \
|
|
|
|
&& func_skip "Exiting: demo/libhello.la is not a shared library"
|
1997-04-02 03:18:28 +08:00
|
|
|
|
2003-10-15 05:46:13 +08:00
|
|
|
func_make "hardcode"
|
1997-04-02 03:18:28 +08:00
|
|
|
|
2005-04-17 15:58:12 +08:00
|
|
|
# Extra tools we might need
|
|
|
|
: ${DUMPSTABS=dumpstabs}
|
|
|
|
|
1997-04-02 03:18:28 +08:00
|
|
|
# Suck in all the hardcode_* variable settings.
|
2003-10-15 05:46:13 +08:00
|
|
|
func_msg "Finding libtool.m4's guesses at hardcoding values"
|
|
|
|
func_get_config 'hardcode_direct
|
|
|
|
hardcode_minus_L
|
|
|
|
hardcode_shlibpath_var
|
2003-11-22 22:09:14 +08:00
|
|
|
hardcode_libdir_flag_spec' "./libtool --config" ": fatal"
|
1997-04-02 03:18:28 +08:00
|
|
|
|
|
|
|
echo "= Searching for hardcoded library directories in each program"
|
|
|
|
for file in hc-*; do
|
|
|
|
case "$file" in
|
2003-10-15 05:46:13 +08:00
|
|
|
hc-direct) expected="$hardcode_direct" ;;
|
1997-04-02 03:18:28 +08:00
|
|
|
hc-libpath) expected="$hardcode_shlibpath_var" ;;
|
2003-10-15 05:46:13 +08:00
|
|
|
hc-minusL) expected="$hardcode_minus_L" ;;
|
1997-10-15 02:33:24 +08:00
|
|
|
|
|
|
|
hc-libflag)
|
|
|
|
if test -n "$hardcode_libdir_flag_spec"; then
|
|
|
|
expected=yes
|
|
|
|
else
|
|
|
|
expected=unsupported
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
|
1997-04-02 03:18:28 +08:00
|
|
|
*)
|
|
|
|
continue
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
1997-09-15 22:12:49 +08:00
|
|
|
# Discover whether the objdir really was hardcoded.
|
1997-04-02 03:21:43 +08:00
|
|
|
hardcoded=no
|
1997-10-20 02:53:23 +08:00
|
|
|
|
2005-04-17 15:58:12 +08:00
|
|
|
# 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; then
|
|
|
|
if $DUMPSTABS -d $file 2>/dev/null | $FGREP "$objdir" >/dev/null 2>&1; then
|
|
|
|
hardcoded=yes
|
|
|
|
else
|
|
|
|
hardcoded=no
|
|
|
|
fi
|
1997-10-20 02:53:23 +08:00
|
|
|
# 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.
|
2005-04-18 18:19:22 +08:00
|
|
|
elif cat $file | (tr '\000-\037\200-\377' '\n' || cat) 2>/dev/null \
|
|
|
|
| $FGREP "$objdir" > /dev/null 2>&1; then
|
1997-04-02 03:21:43 +08:00
|
|
|
hardcoded=yes
|
Don't assume that egrep and fgrep exist. POSIX 1003.1-2001 no
longer requires them; you're supposed to use grep -E and grep -F
instead. Also, don't assume that "test -a" works, since POSIX
doesn't require it.
* libtool.m4 (AC_LIBTOOL_SYS_DYNAMIC_LINKER, _LT_AC_LANG_C_CONFIG,
_LT_AC_LANG_CXX_CONFIG, AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE,
AC_LIBTOOL_PROG_LD_SHLIBS):
egrep -> grep, when that makes no difference.
* libtoolize.in: Likewise.
* ltdl.m4 (AC_LTDL_SYMBOL_USCORE): Likewise.
* ltmain.in: Likewise.
* demo/Makefile.am (hc-direct): Likewise.
* pdemo/Makefile.am (hc-direct): Likewise.
* tests/build-relink.test, tests/build-relink2.test,
tests/cdemo-conf.test, tests/cdemo-shared.test,
tests/cdemo-static.test, tests/demo-conf.test,
tests/demo-nofast.test, tests/demo-shared.test,
tests/demo-static.test, tests/depdemo-conf.test,
tests/depdemo-nofast.test, tests/depdemo-shared.test,
tests/depdemo-static.test, tests/hardcode.test,
tests/mdemo-conf.test, tests/mdemo-shared.test,
tests/mdemo-static.test, tests/pdemo-conf.test,
tests/tagdemo-conf.test, tests/tagdemo-shared.test,
tests/tagdemo-static.test: Likewise.
* libtool.m4 (AC_PROG_EGREP):
New macro, defined if Autoconf doesn't define.
(AC_PATH_TOOL_PREFIX, AC_PROG_LD_GNU): Use it.
(AC_PROG_LD, AC_PROG_NM, AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE):
Use shell pattern matching rather than egrep.
(AC_LIBTOOL_CONFIG): Set lt_EGREP and EGREP.
* demo/Makefile.am (SET_HARDCODE_FLAGS): Use sed instead of egrep.
* pdemo/Makefile.am (SET_HARDCODE_FLAGS): Likewise.
* tests/defs (EGREP, FGREP): New vars.
* ltmain.in: egrep -> $EGREP
* tests/assign.test, tests/demo-exec.test, tests/demo-inst.test,
tests/pdemo-exec.test, tests/pdemo-inst.test, tests/sh.test:
Likewise.
* tests/hardcode.test: fgrep -> $FGREP
* tests/f77demo-exec.test: test -a -> test &&
2002-11-19 17:42:39 +08:00
|
|
|
elif $FGREP "$objdir" $file > /dev/null 2>&1; then
|
1997-10-20 02:53:23 +08:00
|
|
|
# We retry fgrep without tr, in case the above lead to a false negative.
|
1997-04-02 03:21:43 +08:00
|
|
|
hardcoded=yes
|
Don't assume that egrep and fgrep exist. POSIX 1003.1-2001 no
longer requires them; you're supposed to use grep -E and grep -F
instead. Also, don't assume that "test -a" works, since POSIX
doesn't require it.
* libtool.m4 (AC_LIBTOOL_SYS_DYNAMIC_LINKER, _LT_AC_LANG_C_CONFIG,
_LT_AC_LANG_CXX_CONFIG, AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE,
AC_LIBTOOL_PROG_LD_SHLIBS):
egrep -> grep, when that makes no difference.
* libtoolize.in: Likewise.
* ltdl.m4 (AC_LTDL_SYMBOL_USCORE): Likewise.
* ltmain.in: Likewise.
* demo/Makefile.am (hc-direct): Likewise.
* pdemo/Makefile.am (hc-direct): Likewise.
* tests/build-relink.test, tests/build-relink2.test,
tests/cdemo-conf.test, tests/cdemo-shared.test,
tests/cdemo-static.test, tests/demo-conf.test,
tests/demo-nofast.test, tests/demo-shared.test,
tests/demo-static.test, tests/depdemo-conf.test,
tests/depdemo-nofast.test, tests/depdemo-shared.test,
tests/depdemo-static.test, tests/hardcode.test,
tests/mdemo-conf.test, tests/mdemo-shared.test,
tests/mdemo-static.test, tests/pdemo-conf.test,
tests/tagdemo-conf.test, tests/tagdemo-shared.test,
tests/tagdemo-static.test: Likewise.
* libtool.m4 (AC_PROG_EGREP):
New macro, defined if Autoconf doesn't define.
(AC_PATH_TOOL_PREFIX, AC_PROG_LD_GNU): Use it.
(AC_PROG_LD, AC_PROG_NM, AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE):
Use shell pattern matching rather than egrep.
(AC_LIBTOOL_CONFIG): Set lt_EGREP and EGREP.
* demo/Makefile.am (SET_HARDCODE_FLAGS): Use sed instead of egrep.
* pdemo/Makefile.am (SET_HARDCODE_FLAGS): Likewise.
* tests/defs (EGREP, FGREP): New vars.
* ltmain.in: egrep -> $EGREP
* tests/assign.test, tests/demo-exec.test, tests/demo-inst.test,
tests/pdemo-exec.test, tests/pdemo-inst.test, tests/sh.test:
Likewise.
* tests/hardcode.test: fgrep -> $FGREP
* tests/f77demo-exec.test: test -a -> test &&
2002-11-19 17:42:39 +08:00
|
|
|
elif (sed -e '1!d' $file | grep 'unsupported') >/dev/null 2>&1; then
|
1997-04-02 03:21:43 +08:00
|
|
|
hardcoded=unsupported
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Check the result.
|
|
|
|
case "$hardcoded" in
|
|
|
|
yes)
|
1997-04-02 03:18:28 +08:00
|
|
|
if test $expected = yes; then
|
1997-09-15 22:12:49 +08:00
|
|
|
echo "$objdir was hardcoded in \`$file', as libtool expected"
|
1997-04-02 03:18:28 +08:00
|
|
|
else
|
1997-09-15 22:12:49 +08:00
|
|
|
echo "$objdir was hardcoded in \`$file', which fooled libtool" 1>&2
|
2003-10-15 05:46:13 +08:00
|
|
|
exit_status=1
|
1997-04-02 03:18:28 +08:00
|
|
|
fi
|
1997-04-02 03:21:43 +08:00
|
|
|
;;
|
|
|
|
|
|
|
|
no)
|
1997-04-02 03:19:30 +08:00
|
|
|
if test $expected = no; then
|
1997-09-15 22:12:49 +08:00
|
|
|
echo "$objdir was not hardcoded in \`$file', as libtool expected"
|
1997-04-02 03:19:30 +08:00
|
|
|
else
|
1997-09-15 22:12:49 +08:00
|
|
|
echo "$objdir was not hardcoded in \`$file', which fooled libtool" 1>&2
|
2003-10-15 05:46:13 +08:00
|
|
|
exit_status=1
|
1997-04-02 03:18:28 +08:00
|
|
|
fi
|
1997-04-02 03:21:43 +08:00
|
|
|
;;
|
|
|
|
|
|
|
|
unsupported)
|
|
|
|
if test $expected = unsupported; then
|
|
|
|
echo "\`$file' was not linked properly, as libtool expected"
|
|
|
|
else
|
|
|
|
echo "\`$file' was not linked properly, which fooled libtool" 1>&2
|
2003-10-15 05:46:13 +08:00
|
|
|
exit_status=1
|
1997-04-02 03:21:43 +08:00
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
1997-04-02 03:18:28 +08:00
|
|
|
done
|
|
|
|
|
2003-10-15 05:46:13 +08:00
|
|
|
exit $exit_status
|