summaryrefslogtreecommitdiff
path: root/ld/genscripts.sh
diff options
context:
space:
mode:
authorDaniel Jacobowitz <dan@debian.org>2003-01-06 16:14:01 +0000
committerDaniel Jacobowitz <dan@debian.org>2003-01-06 16:14:01 +0000
commit0c7183f17cdc00fdaf4cd6ce96c2dc806d43b335 (patch)
tree0ca21b813e3de83ac8a20ad75a529b3d94a4b16d /ld/genscripts.sh
parentad8dc5ea5afadcb9a97d8f597d70c1d345577bdc (diff)
downloadbinutils-redhat-0c7183f17cdc00fdaf4cd6ce96c2dc806d43b335.tar.gz
* Makefile.am (eelf32iq10.c): Fix tab/whitespace mixup.
* Makefile.am (ldmain.o): Add @TARGET_SYSTEM_ROOT_DEFINE@. (GENSCRIPTS): Add @use_sysroot@. * Makefile.in: Regenerated. * configure.host: Move setting of NATIVE_LIB_DIRS to... * configure.tgt: ... here. Use ${target} instead of ${host} for NATIVE_LIB_DIRS. * configure.in: Add --with-sysroot. * configure: Regenerated. * genscripts.sh: Accept use_sysroot option. Set new variables NATIVE and USE_LIBPATH. Prepend "=" to directory names if $use_sysroot. Don't search $tool_lib if $use_sysroot. * ldfile.c (ldfile_add_library_path): Handle leading '='. * ldmain.c (TARGET_SYSTEM_ROOT): Define if not defined. (ld_sysroot): New variable. (main): Initialize ld_sysroot. * ldmain.h (ld_sysroot): New extern. * emultempl/elf32.em: Use NATIVE and USE_LIBPATH instead of searching $EMULATION_LIBPATH. (gld${EMULATION_NAME}_add_sysroot): New function. (gld${EMULATION_NAME}_check_ld_so_conf): Use it. Honor ld_sysroot. (gld${EMULATION_NAME}_after_open): Likewise. Only search environment variables if $NATIVE. * ld.texinfo (Options): Mention "=" prefix in the description of -L. * NEWS: Mention --with-sysroot. * emulparams/elf32bmipn32-defs.sh: Set NATIVE and LIBPATH_SUFFIX instead of setting LIB_PATH. * emulparams/elf32ppc.sh: Likewise. * emulparams/elf64_s390.sh: Likewise. * emulparams/elf64_sparc.sh: Likewise. * emulparams/elf64ppc.sh: Likewise. * emulparams/elf_x86_64.sh: Likewise. * emulparams/elf64_aix.sh: Add "=" prefixes to LIB_PATH. * emulparams/elf64hppa.sh: Add "=" prefixes to LIB_PATH.
Diffstat (limited to 'ld/genscripts.sh')
-rwxr-xr-xld/genscripts.sh71
1 files changed, 54 insertions, 17 deletions
diff --git a/ld/genscripts.sh b/ld/genscripts.sh
index ea99551027..63a7d09226 100755
--- a/ld/genscripts.sh
+++ b/ld/genscripts.sh
@@ -3,12 +3,12 @@
#
# Usage: genscripts.sh srcdir libdir exec_prefix \
# host target target_alias default_emulation \
-# native_lib_dirs this_emulation tool_dir
+# native_lib_dirs use_sysroot this_emulation tool_dir
#
# Sample usage:
# genscripts.sh /djm/ld-devo/devo/ld /usr/local/lib /usr/local \
# sparc-sun-sunos4.1.3 sparc-sun-sunos4.1.3 sparc-sun-sunos4.1.3 sun4 \
-# "" sun3 sparc-sun-sunos4.1.3
+# "" no sun3 sparc-sun-sunos4.1.3
# produces sun3.x sun3.xbn sun3.xn sun3.xr sun3.xu em_sun3.c
srcdir=$1
@@ -19,8 +19,10 @@ target=$5
target_alias=$6
EMULATION_LIBPATH=$7
NATIVE_LIB_DIRS=$8
-EMULATION_NAME=$9
+use_sysroot=$9
shift 9
+EMULATION_NAME=$1
+shift
# Can't use ${1:-$target_alias} here due to an Ultrix shell bug.
if [ "x$1" = "x" ] ; then
tool_lib=${exec_prefix}/${target_alias}/lib
@@ -37,31 +39,66 @@ else
mkdir ldscripts
fi
+# Set some flags for the emultempl scripts. USE_LIBPATH will
+# be set for any libpath-using emulation; NATIVE will be set for a
+# libpath-using emulation where ${host} = ${target}. NATIVE
+# may already have been set by the emulparams file, but that's OK
+# (it'll just get set to "yes" twice).
+
+case " $EMULATION_LIBPATH " in
+ *" ${EMULATION_NAME} "*)
+ if [ "x${host}" = "x${target}" ] ; then
+ NATIVE=yes
+ USE_LIBPATH=yes
+ elif [ "x${use_sysroot}" = "xyes" ] ; then
+ USE_LIBPATH=yes
+ fi
+ ;;
+esac
+
+# If the emulparams file sets NATIVE, make sure USE_LIBPATH is set also.
+if test "x$NATIVE" = "xyes" ; then
+ USE_LIBPATH=yes
+fi
+
# Set the library search path, for libraries named by -lfoo.
# If LIB_PATH is defined (e.g., by Makefile) and non-empty, it is used.
# Otherwise, the default is set here.
#
# The format is the usual list of colon-separated directories.
# To force a logically empty LIB_PATH, do LIBPATH=":".
+#
+# If we are using a sysroot, prefix library paths with "=" to indicate this.
+#
+# If the emulparams file set LIBPATH_SUFFIX, prepend an extra copy of
+# the library path with the suffix applied.
-if [ "x${LIB_PATH}" = "x" ] ; then
- if [ "x${host}" = "x${target}" ] ; then
- case " $EMULATION_LIBPATH " in
- *" ${EMULATION_NAME} "*)
- # Native, and default or emulation requesting LIB_PATH.
- LIB_PATH=${libdir}
- for lib in ${NATIVE_LIB_DIRS}; do
- case :${LIB_PATH}: in
- *:${lib}:*) ;;
- *) LIB_PATH=${LIB_PATH}:${lib} ;;
- esac
- done
+if [ "x${LIB_PATH}" = "x" ] && [ "x${USE_LIBPATH}" = xyes ] ; then
+ if [ x"$use_sysroot" != xyes ] ; then
+ LIB_PATH=${libdir}
+ fi
+ for lib in ${NATIVE_LIB_DIRS}; do
+ # The "=" is harmless if we aren't using a sysroot, but also needless.
+ if [ "x${use_sysroot}" = "xyes" ] ; then
+ lib="=${lib}"
+ fi
+ case :${LIB_PATH}: in
+ *:${lib}:*) ;;
+ ::) LIB_PATH=${lib} ;;
+ *) LIB_PATH=${LIB_PATH}:${lib} ;;
esac
+ done
+ if test -n "$LIBPATH_SUFFIX" ; then
+ LIB_PATH=`echo ${LIB_PATH}: | sed -e s,:,${LIBPATH_SUFFIX}:,g`$LIB_PATH
fi
fi
-# Always search $(tooldir)/lib, aka /usr/local/TARGET/lib.
-LIB_PATH=${tool_lib}:${LIB_PATH}
+
+# Always search $(tooldir)/lib, aka /usr/local/TARGET/lib, except for
+# sysrooted configurations.
+if [ "x${use_sysroot}" != "xyes" ] ; then
+ LIB_PATH=${tool_lib}:${LIB_PATH}
+fi
LIB_SEARCH_DIRS=`echo ${LIB_PATH} | sed -e 's/:/ /g' -e 's/\([^ ][^ ]*\)/SEARCH_DIR(\\"\1\\");/g'`