From 2e5983457a7e68ef9089acf42d80be836ba15c01 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Wed, 7 Feb 1996 19:03:38 +0000 Subject: [PATCH] * configure.in: Look for --enable-shared. Change the value of BFDLIB when linking against a shared library on SunOS. * configure: Rebuild. * configure.host: If using a shared BFD library, try to pass a reasonable -rpath option when linking. * Makefile.in (BFDLIB): Set to @BFDLIB@. --- ld/ChangeLog | 14 ++++++++++ ld/Makefile.in | 24 ++++++++++------- ld/configure | 69 ++++++++++++++++++++++++++++++++++------------- ld/configure.host | 47 ++++++++++++++++++++++++++++++-- ld/configure.in | 26 ++++++++++++++++++ 5 files changed, 151 insertions(+), 29 deletions(-) diff --git a/ld/ChangeLog b/ld/ChangeLog index cf6ba988863..c63e46327c3 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,17 @@ +Wed Feb 7 14:01:33 1996 Ian Lance Taylor + + * configure.in: Look for --enable-shared. Change the value of + BFDLIB when linking against a shared library on SunOS. + * configure: Rebuild. + * configure.host: If using a shared BFD library, try to pass a + reasonable -rpath option when linking. + * Makefile.in (BFDLIB): Set to @BFDLIB@. + +Tue Feb 6 12:29:14 1996 Doug Evans + + * emulparams/elf64_sparc.sh (ARCH): Change to `sparc:v9'. + * emultempl/generic.em: Strip `:foo' from ${ARCH}. + Mon Feb 5 16:25:30 1996 Ian Lance Taylor Support for building bfd and opcodes as shared libraries, based on diff --git a/ld/Makefile.in b/ld/Makefile.in index 1b70cf6b153..75c8d9a2a1f 100644 --- a/ld/Makefile.in +++ b/ld/Makefile.in @@ -62,6 +62,7 @@ AR = ar AR_FLAGS = qv CC = @CC@ CFLAGS = @CFLAGS@ +HLDFLAGS = @HLDFLAGS@ MAKEINFO = makeinfo TEXI2DVI = texi2dvi RANLIB = ranlib @@ -187,8 +188,8 @@ ALL_CFLAGS = $(INCLUDES) @HDEFINES@ $(CFLAGS) .c.o: $(CC) -c $(ALL_CFLAGS) $< -# for self hosting -BFDLIB = ../bfd/libbfd.a +BFDDEP = ../bfd/libbfd.a +BFDLIB = @BFDLIB@ LIBIBERTY = ../libiberty/libiberty.a ALL_EMULATIONS = ea29k.o ealpha.o earmaoutl.o earmaoutb.o \ @@ -198,10 +199,10 @@ ALL_EMULATIONS = ea29k.o ealpha.o earmaoutl.o earmaoutb.o \ eh8300h.o eh8500.o eh8500b.o eh8500c.o eh8500m.o eh8500s.o \ ehp300bsd.o ehp3hpux.o ehppaelf.o ei386aout.o ei386bsd.o \ ei386coff.o ei386go32.o ei386linux.o ei386lynx.o ei386mach.o \ - ei386nbsd.o ei386nw.o elnk960.o em68k4knbsd.o em68kaout.o em68kcoff.o \ - em68kelf.o em68klynx.o em68knbsd.o em88kbcs.o emipsbig.o emipsbsd.o \ - emipsidt.o emipsidtl.o emipslit.o enews.o ens32knbsd.o eppcnw.o \ - eriscix.o esa29200.o eshl.o esh.o esparclynx.o esparcnbsd.o \ + ei386nbsd.o ei386nw.o elnk960.o em68k4knbsd.o em68kaout.o em68kaux.o \ + em68kcoff.o em68kelf.o em68klynx.o em68knbsd.o em88kbcs.o emipsbig.o \ + emipsbsd.o emipsidt.o emipsidtl.o emipslit.o enews.o ens32knbsd.o \ + eppcnw.o eriscix.o esa29200.o eshl.o esh.o esparclynx.o esparcnbsd.o \ est2000.o esun3.o esun4.o evanilla.o evax.o evsta.o \ ez8001.o ez8002.o ei386pe.o earmpe.o eelf32b4300.o eelf32l4300.o \ eaixppc.o eaixrs6.o eppcmacos.o edelta68.o eppcpe.o @@ -266,7 +267,7 @@ ldlex.c: ldlex.l # These all start with e so 'make clean' can find them. -GENSCRIPTS = $(SHELL) $(srcdir)/genscripts.sh ${srcdir} ${libdir} @host_alias@ @target_alias@ ${EMUL} "@NATIVE_LIB_DIRS@" +GENSCRIPTS = $(SHELL) $(srcdir)/genscripts.sh ${srcdir} ${libdir} @host@ @target@ @target_alias@ ${EMUL} "@NATIVE_LIB_DIRS@" GEN_DEPENDS = $(srcdir)/genscripts.sh $(srcdir)/emultempl/stringify.sed esun4.c: $(srcdir)/emulparams/sun4.sh \ @@ -374,6 +375,9 @@ egld960.c: $(srcdir)/emulparams/gld960.sh \ egld960coff.c: $(srcdir)/emulparams/gld960coff.sh \ $(srcdir)/emultempl/gld960c.em $(srcdir)/scripttempl/i960.sc ${GEN_DEPENDS} ${GENSCRIPTS} gld960coff +em68kaux.c: $(srcdir)/emulparams/m68kaux.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/m68kaux.sc ${GEN_DEPENDS} + ${GENSCRIPTS} m68kaux em68kcoff.c: $(srcdir)/emulparams/m68kcoff.sh \ $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/m68kcoff.sc ${GEN_DEPENDS} ${GENSCRIPTS} m68kcoff @@ -522,8 +526,8 @@ erce.c: $(srcdir)/emulparams/rce.sh \ ${GENSCRIPTS} rce # end-sanitize-rce -$(LD_PROG): $(OFILES) $(BFDLIB) $(LIBIBERTY) - $(CC) $(CFLAGS) $(LDFLAGS) -o $(LD_PROG) $(OFILES) $(BFDLIB) $(LIBIBERTY) $(EXTRALIBS) +$(LD_PROG): $(OFILES) $(BFDDEP) $(LIBIBERTY) + $(CC) $(HLDFLAGS) $(CFLAGS) $(LDFLAGS) -o $(LD_PROG) $(OFILES) $(BFDLIB) $(LIBIBERTY) $(EXTRALIBS) # The generated emulation files mostly have the same dependencies. $(EMULATION_OFILES): ../bfd/bfd.h sysdep.h config.h $(INCDIR)/bfdlink.h \ @@ -573,6 +577,8 @@ check: site.exp r=`pwd`; export r; \ srcroot=`cd ${srcdir}; pwd` ; export srcroot ; \ EXPECT=${EXPECT} ; export EXPECT ; \ + LD_LIBRARY_PATH=$$r/../bfd:$$r/../opcodes:$$LD_LIBRARY_PATH; \ + export LD_LIBRARY_PATH; \ if [ -f $$r/../expect/expect ] ; then \ TCL_LIBRARY=$${srcroot}/../tcl/library ; \ export TCL_LIBRARY ; \ diff --git a/ld/configure b/ld/configure index 9b8cf2cf530..2d367efe6db 100755 --- a/ld/configure +++ b/ld/configure @@ -1,7 +1,7 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated automatically using autoconf version 2.6 +# Generated automatically using autoconf version 2.7 # Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc. # # This configure script is free software; the Free Software Foundation @@ -13,6 +13,8 @@ ac_default_prefix=/usr/local # Any additions from configure.in: ac_help="$ac_help --enable-targets alternative target configurations" +ac_help="$ac_help + --enable-shared build shared BFD library" # Initialize some variables set by options. # The variables have the same names as the options, with @@ -332,7 +334,7 @@ EOF verbose=yes ;; -version | --version | --versio | --versi | --vers) - echo "configure generated by autoconf version 2.6" + echo "configure generated by autoconf version 2.7" exit 0 ;; -with-* | --with-*) @@ -528,6 +530,15 @@ if test "${enable_targets+set}" = set; then *) enable_targets=$enableval ;; esac fi +# Check whether --enable-shared or --disable-shared was given. +if test "${enable_shared+set}" = set; then + enableval="$enable_shared" + case "${enableval}" in + yes) shared=true ;; + no) shared=false ;; + *) { echo "configure: error: bad value ${enableval} for BFD shared option" 1>&2; exit 1; } ;; +esac +fi @@ -645,8 +656,10 @@ fi if test "$program_transform_name" = s,x,x,; then program_transform_name= else - # Double any \ or $. - echo 's,\\,\\\\,g; s,\$,$$,g' > conftestsed + # Double any \ or $. echo might interpret backslashes. + cat <<\EOF_SED > conftestsed +s,\\,\\\\,g; s,\$,$$,g +EOF_SED program_transform_name="`echo $program_transform_name|sed -f conftestsed`" rm -f conftestsed fi @@ -745,6 +758,22 @@ fi + +# For most hosts we can use a simple definition to pick up the BFD and +# opcodes libraries. However, if we are building shared libraries, we +# need to handle some hosts specially. +BFDLIB='-L../bfd -lbfd' +if test "${shared}" = "true"; then + case "${host}" in + *-*-sunos*) + # On SunOS, we must link against the name we are going to install, + # not -lbfd, since SunOS does not support SONAME. + BFDLIB='-L../bfd -l`echo bfd | sed '"'"'$(program_transform_name)'"'"'`' + ;; + esac +fi + + echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then @@ -760,7 +789,7 @@ else # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. cat > conftest.$ac_ext < Syntax Error @@ -774,7 +803,7 @@ else rm -rf conftest* CPP="${CC-cc} -E -traditional-cpp" cat > conftest.$ac_ext < Syntax Error @@ -807,7 +836,7 @@ if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF @@ -842,7 +871,7 @@ if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&6 else cat > conftest.$ac_ext < #include <$ac_hdr> @@ -928,14 +957,14 @@ done # Two versions of opendir et al. are in -ldir and -lx on SCO Xenix. if test $ac_header_dirent = dirent.h; then echo $ac_n "checking for -ldir""... $ac_c" 1>&6 -ac_lib_var=`echo dir | tr './+' '__p'` +ac_lib_var=`echo dir | tr '.-/+' '___p'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-ldir $LIBS" cat > conftest.$ac_ext <&6 -ac_lib_var=`echo x | tr './+' '__p'` +ac_lib_var=`echo x | tr '.-/+' '___p'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-lx $LIBS" cat > conftest.$ac_ext <> confdefs.h <<\EOF #define USE_BINARY_FOPEN 1 EOF @@ -1013,7 +1042,7 @@ if eval "test \"`echo '$''{'bfd_cv_decl_needed_free'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < @@ -1180,7 +1209,7 @@ do echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; -version | --version | --versio | --versi | --vers | --ver | --ve | --v) - echo "$CONFIG_STATUS generated by autoconf version 2.6" + echo "$CONFIG_STATUS generated by autoconf version 2.7" exit 0 ;; -help | --help | --hel | --he | --h) echo "\$ac_cs_usage"; exit 0 ;; @@ -1191,10 +1220,12 @@ done ac_given_srcdir=$srcdir trap 'rm -fr `echo "Makefile config.h:config.in" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 +EOF +cat >> $CONFIG_STATUS < conftest.subs <<\CEOF +sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g; + s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF $ac_vpsub $extrasub s%@CFLAGS@%$CFLAGS%g @@ -1234,10 +1265,12 @@ s%@build_cpu@%$build_cpu%g s%@build_vendor@%$build_vendor%g s%@build_os@%$build_os%g s%@CC@%$CC%g +s%@HLDFLAGS@%$HLDFLAGS%g s%@HDEFINES@%$HDEFINES%g s%@HOSTING_CRT0@%$HOSTING_CRT0%g s%@HOSTING_LIBS@%$HOSTING_LIBS%g s%@NATIVE_LIB_DIRS@%$NATIVE_LIB_DIRS%g +s%@BFDLIB@%$BFDLIB%g s%@CPP@%$CPP%g s%@EMUL@%$EMUL%g s%@EMULATION_OFILES@%$EMULATION_OFILES%g diff --git a/ld/configure.host b/ld/configure.host index e324be291e9..8d43d7eea7b 100644 --- a/ld/configure.host +++ b/ld/configure.host @@ -80,11 +80,16 @@ i[345]86-*-lynxos*) HOSTING_LIBS='`if [ -f ../gcc/libgcc.a ] ; then echo ../gcc/libgcc.a ; else gcc -print-libgcc-file-name; fi` -lc -lm /lib/initn.o' ;; -mips-dec-bsd*) +mips*-dec-bsd*) HOSTING_CRT0=/usr/lib/crt0.o ;; -mips-sgi-irix4*) +mips*-sgi-irix4*) + HOSTING_CRT0=/usr/lib/crt1.o + HOSTING_LIBS='`if [ -f ../gcc/libgcc.a ] ; then echo ../gcc/libgcc.a ; else gcc -print-libgcc-file-name; fi` -lc /usr/lib/crtn.o' + ;; + +mips*-sgi-irix5*) HOSTING_CRT0=/usr/lib/crt1.o HOSTING_LIBS='`if [ -f ../gcc/libgcc.a ] ; then echo ../gcc/libgcc.a ; else gcc -print-libgcc-file-name; fi` -lc /usr/lib/crtn.o' ;; @@ -126,3 +131,41 @@ sparc-*-solaris2*) ;; esac + +HLDFLAGS= +# If we have shared libraries, try to set rpath reasonably. +if test "${shared}" = "true"; then + case "${host}" in + *-*-irix5*) + HLDFLAGS='-Wl,-rpath,$(libdir)' + ;; + *-*-linux*aout*) + ;; + *-*-linux*) + HLDFLAGS='-Wl,-rpath,$(libdir)' + ;; + *-*-sysv4* | *-*-solaris*) + HLDFLAGS='-R $(libdir)' + ;; + esac +fi + +# On SunOS, if the linker supports the -rpath option, use it to +# prevent ../bfd and ../opcodes from being included in the run time +# search path. +case "${host}" in + *-*-sunos*) + echo 'main () { }' > conftest.c + ${CC} -o conftest -Wl,-rpath= conftest.c >/dev/null 2>conftest.t + if grep 'unrecognized' conftest.t >/dev/null 2>&1; then + : + elif grep 'No such file' conftest.t >/dev/null 2>&1; then + : + elif test "${shared}" = "true"; then + HLDFLAGS='-Wl,-rpath=$(libdir)' + else + HLDFLAGS='-Wl,-rpath=' + fi + rm -f conftest.t conftest.c conftest + ;; +esac diff --git a/ld/configure.in b/ld/configure.in index 4913982a4dc..4444fcebf78 100644 --- a/ld/configure.in +++ b/ld/configure.in @@ -11,6 +11,13 @@ AC_ARG_ENABLE(targets, no) enable_targets= ;; *) enable_targets=$enableval ;; esac])dnl +AC_ARG_ENABLE(shared, +[ --enable-shared build shared BFD library], +[case "${enableval}" in + yes) shared=true ;; + no) shared=false ;; + *) AC_MSG_ERROR([bad value ${enableval} for BFD shared option]) ;; +esac])dnl AC_CONFIG_HEADER(config.h:config.in) @@ -30,16 +37,35 @@ AC_ARG_PROGRAM AC_PROG_CC AC_SUBST(CFLAGS) +AC_SUBST(HLDFLAGS) AC_SUBST(HDEFINES) AC_SUBST(HOSTING_CRT0) AC_SUBST(HOSTING_LIBS) AC_SUBST(NATIVE_LIB_DIRS) +# For most hosts we can use a simple definition to pick up the BFD and +# opcodes libraries. However, if we are building shared libraries, we +# need to handle some hosts specially. +BFDLIB='-L../bfd -lbfd' +if test "${shared}" = "true"; then + case "${host}" in + *-*-sunos*) + # On SunOS, we must link against the name we are going to install, + # not -lbfd, since SunOS does not support SONAME. + BFDLIB='-L../bfd -l`echo bfd | sed '"'"'$(program_transform_name)'"'"'`' + ;; + esac +fi +AC_SUBST(BFDLIB) + AC_CHECK_HEADERS(string.h strings.h stdlib.h unistd.h) AC_CHECK_FUNCS(sbrk) +AC_HEADER_DIRENT BFD_BINARY_FOPEN +BFD_NEED_DECLARATION(free) + # target-specific stuff: # Canonicalize the secondary target names.