# This is the linker host specific file.  This is invoked by the
# autoconf generated configure script.  Putting it in a separate shell
# file lets us skip running autoconf when modifying host specific
# information.

# This file sets the following shell variables:
#  HDEFINES		host specific compiler flags
#  HOSTING_CRT0		crt0.o file used for bootstrapping
#  HOSTING_LIBS		libraries used for bootstrapping
#  NATIVE_LIB_DIRS	library directories to search on this host
#  HLDFLAGS		link flags to use on this host
#  HLDENV		environment variable to set when linking for the host
#  RPATH_ENVVAR		environment variable used to find shared libraries

HDEFINES=
HOSTING_CRT0=/lib/crt0.o
HOSTING_LIBS='`if [ -f ../gcc/libgcc.a ] ; then echo ../gcc/libgcc.a ; else gcc -print-libgcc-file-name; fi` -lc'
NATIVE_LIB_DIRS=

case "${host}" in

alpha-*-linux*)
  HOSTING_CRT0=/usr/lib/crt0.o
  ;;

alpha-*-*)
  HOSTING_CRT0=/usr/ccs/lib/crt0.o
  NATIVE_LIB_DIRS=/usr/ccs/lib
  ;;

i[3456]86-*-bsd* | i[3456]86-*-freebsd* | i[3456]86-*-netbsd*)
  # The new BSD `make' has a bug: it doesn't pass empty arguments in
  # shell commands.  So we need to make this value non-empty in order
  # for the genscripts.sh call to work.  There's nothing magic about
  # the value `/lib'; it's just a dummy.
  NATIVE_LIB_DIRS=/lib
  HOSTING_CRT0=/usr/lib/crt0.o
  ;;

i[3456]86-*-sysv4*)
  HOSTING_CRT0='/usr/ccs/lib/crt1.o /usr/ccs/lib/crti.o /usr/ccs/lib/values-Xa.o `if [ -f ../gcc/crtbegin.o ]; then echo ../gcc/crtbegin.o; else gcc -print-file-name=crtbegin.o; fi`'
  HOSTING_LIBS='`if [ -f ../gcc/libgcc.a ] ; then echo ../gcc/libgcc.a ; else gcc -print-libgcc-file-name; fi` -lc `if [ -f ../gcc/crtend.o ]; then echo ../gcc/crtend.o; else gcc -print-file-name=crtend.o; fi` /usr/ccs/lib/crtn.o'
  NATIVE_LIB_DIRS=/usr/ccs/lib
  ;;

i[3456]86-sequent-ptx* | i[3456]86-sequent-sysv*)
  HOSTING_CRT0='/lib/crt0.o `if [ -f ../gcc/crtbegin.o ]; then echo ../gcc/crtbegin.o; else gcc -print-file-name=crtbegin.o; fi`'
  HOSTING_LIBS='`if [ -f ../gcc/libgcc.a ] ; then echo ../gcc/libgcc.a ; else gcc -print-libgcc-file-name; fi` -lc `if [ -f ../gcc/crtend.o ]; then echo ../gcc/crtend.o; else gcc -print-file-name=crtend.o; fi`'
  ;;

i[3456]86-*-sysv*)
  HOSTING_CRT0='/lib/crt1.o `if [ -f ../gcc/crtbegin.o ]; then echo ../gcc/crtbegin.o; fi`'
  HOSTING_LIBS='`if [ -f ../gcc/libgcc.a ] ; then echo ../gcc/libgcc.a ; else gcc -print-libgcc-file-name; fi` -lc `if [ -f ../gcc/crtend.o ]; then echo ../gcc/crtend.o; fi` /lib/crtn.o'
  ;;

i[3456]86-*-solaris*)
  HOSTING_CRT0='`if [ -f ../gcc/crt1.o ]; then echo ../gcc/crt1.o; else gcc -print-file-name=crt1.o; fi` `if [ -f ../gcc/crti.o ]; then echo ../gcc/crti.o; else gcc -print-file-name=crti.o; fi` /usr/ccs/lib/values-Xa.o `if [ -f ../gcc/crtbegin.o ]; then echo ../gcc/crtbegin.o; else gcc -print-file-name=crtbegin.o; fi`'
  HOSTING_LIBS='`if [ -f ../gcc/libgcc.a ] ; then echo ../gcc/libgcc.a ; else gcc -print-libgcc-file-name; fi` -lc `if [ -f ../gcc/crtend.o ]; then echo ../gcc/crtend.o; else gcc -print-file-name=crtend.o; fi` `if [ -f ../gcc/crtn.o ]; then echo ../gcc/crtn.o; else gcc -print-file-name=crtn.o; fi`'
  NATIVE_LIB_DIRS=/usr/ccs/lib
  ;;

i[3456]86-*-sco* | i[3456]86-*-isc*)
  # In some configurations gcc does not use crtbegin.o and crtend.o.
  # In that case gcc -print-file-name=crtbegin.o will simply print
  # crtbegin.o.  We create dummy crtbegin.o and crtend.o files to
  # handle this.
  echo "int dummy_crtbegin () { return 0; }" > crtbegin.c
  ${CC} -c crtbegin.c -o crtbegin.o
  rm -f crtbegin.c
  echo "int dummy_crteng () { return 0; }" > crtend.c
  ${CC} -c crtend.c -o crtend.o
  rm -f crtend.c
  HOSTING_CRT0='/lib/crt1.o `if [ -f ../gcc/crtbegin.o ]; then echo ../gcc/crtbegin.o; else gcc -print-file-name=crtbegin.o; fi`'
  HOSTING_LIBS='`if [ -f ../gcc/libgcc.a ] ; then echo ../gcc/libgcc.a ; else gcc -print-libgcc-file-name; fi` -lc `if [ -f ../gcc/crtend.o ]; then echo ../gcc/crtend.o; else gcc -print-file-name=crtend.o; fi` /lib/crtn.o'
  ;;

i[3456]86-*-linux*aout* | i[3456]86-*-linuxoldld)
  HOSTING_CRT0=/usr/lib/crt0.o
  ;;

i[3456]86-*-linux*libc1*)
  HOSTING_CRT0='-dynamic-linker /lib/ld-linux.so.1 /usr/lib/crt1.o /usr/lib/crti.o `if [ -f ../gcc/crtbegin.o ]; then echo ../gcc/crtbegin.o; elif [ -f /usr/lib/crtbegin.o ]; then echo /usr/lib/crtbegin.o; else gcc --print-file-name=crtbegin.o; fi`'
  HOSTING_LIBS='`if [ -f ../gcc/libgcc.a ] ; then echo ../gcc/libgcc.a ; else gcc -print-libgcc-file-name; fi` -lc `if [ -f ../gcc/libgcc.a ] ; then echo ../gcc/libgcc.a ; else gcc -print-libgcc-file-name; fi` `if [ -f ../gcc/crtend.o ]; then echo ../gcc/crtend.o; elif [ -f /usr/lib/crtend.o ]; then echo /usr/lib/crtend.o; else gcc --print-file-name=crtend.o; fi` /usr/lib/crtn.o'
  ;;

i[3456]86-*-linux*)
  HOSTING_CRT0='-dynamic-linker `fgrep ld-linux.so \`gcc --print-file-name=specs\` | sed -e "s,.*-dynamic-linker[ 	][ 	]*\(.*/ld-linux.so..\).*,\1,"` `gcc --print-file-name=crt1.o` `gcc --print-file-name=crti.o` `if [ -f ../gcc/crtbegin.o ]; then echo ../gcc/crtbegin.o; else gcc --print-file-name=crtbegin.o; fi`'
  HOSTING_LIBS='`if [ -f ../gcc/libgcc.a ] ; then echo ../gcc/libgcc.a ; else gcc -print-libgcc-file-name; fi` -L`dirname \`gcc --print-file-name=libc.so\`` -lc `if [ -f ../gcc/libgcc.a ] ; then echo ../gcc/libgcc.a ; else gcc -print-libgcc-file-name; fi` `if [ -f ../gcc/crtend.o ]; then echo ../gcc/crtend.o; else gcc --print-file-name=crtend.o; fi` `gcc --print-file-name=crtn.o`'
  ;;

i[3456]86-*-lynxos*)
  HOSTING_CRT0=/lib/init1.o
  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*)
  HOSTING_CRT0=/usr/lib/crt0.o
  ;;

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-irix[56]*)
  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'
  ;;

m68*-*-linux*aout*)
  HOSTING_CRT0=/usr/lib/crt0.o
  ;;

m68*-*-linux*libc1*)
  HOSTING_CRT0='-dynamic-linker /lib/ld-linux.so.1 /usr/lib/crt1.o /usr/lib/crti.o `if [ -f ../gcc/crtbegin.o ]; then echo ../gcc/crtbegin.o; elif [ -f /usr/lib/crtbegin.o ]; then echo /usr/lib/crtbegin.o; else gcc --print-file-name=crtbegin.o; fi`'
  HOSTING_LIBS='`if [ -f ../gcc/libgcc.a ] ; then echo ../gcc/libgcc.a ; else gcc -print-libgcc-file-name; fi` -lc `if [ -f ../gcc/libgcc.a ] ; then echo ../gcc/libgcc.a ; else gcc -print-libgcc-file-name; fi` `if [ -f ../gcc/crtend.o ]; then echo ../gcc/crtend.o; elif [ -f /usr/lib/crtend.o ]; then echo /usr/lib/crtend.o; else gcc --print-file-name=crtend.o; fi` /usr/lib/crtn.o'
  ;;

m68*-*-linux*)
  HOSTING_CRT0='-dynamic-linker /lib/ld.so.1 /usr/lib/crt1.o /usr/lib/crti.o `if [ -f ../gcc/crtbegin.o ]; then echo ../gcc/crtbegin.o; else gcc --print-file-name=crtbegin.o; fi`'
  HOSTING_LIBS='`if [ -f ../gcc/libgcc.a ] ; then echo ../gcc/libgcc.a ; else gcc -print-libgcc-file-name; fi` -lc `if [ -f ../gcc/libgcc.a ] ; then echo ../gcc/libgcc.a ; else gcc -print-libgcc-file-name; fi` `if [ -f ../gcc/crtend.o ]; then echo ../gcc/crtend.o; else gcc --print-file-name=crtend.o; fi` /usr/lib/crtn.o'
  ;;

m68*-*-lynxos*)
  HOSTING_CRT0=/lib/init1.o
  HOSTING_LIBS='`if [ -f ../gcc/libgcc.a ] ; then echo ../gcc/libgcc.a ; else gcc -print-libgcc-file-name; fi` -lc -lm /lib/initn.o'
  ;;

m68*-motorola-sysv)
  HOSTING_CRT0='`if [ -f ../gcc/crt0.o ]; then echo ../gcc/crt0.o; elif [ -f \`gcc -print-file-name=\`crt0.o ]; then echo \`gcc -print-file-name=\`crt0.o; else echo /lib/crt0.o; fi`'
  HOSTING_LIBS='`if [ -f ../gcc/libgcc.a ] ; then echo ../gcc/libgcc.a ; else gcc -print-libgcc-file-name; fi` -lc881 `if [ -f ../gcc/libgcc.a ] ; then echo ../gcc/libgcc.a ; else gcc -print-libgcc-file-name; fi`'
  ;;

m68*-sun-*)
  HOSTING_CRT0='/usr/lib/crt0.o /usr/lib/Fcrt1.o -L/usr/lib/fsoft.o'
  ;;

m88*-*-dgux*)
  HDEFINES=-D__using_DGUX
  HOSTING_CRT0='/lib/crt0.o -X'
  HOSTING_LIBS=/usr/sde/m88kbcs/lib/libc.a
  ;;

m88*-motorola-sysv3)
  HOSTING_CRT0='/lib/crt0.o `if [ -f ../gcc/crtbegin.o ]; then echo ../gcc/crtbegin.o; else gcc -print-file-name=crtbegin.o; fi`'
  HOSTING_LIBS='`if [ -f ../gcc/libgcc.a ] ; then echo ../gcc/libgcc.a ; else gcc -print-libgcc-file-name; fi` -lc `if [ -f ../gcc/crtend.o ]; then echo ../gcc/crtend.o; else gcc -print-file-name=crtend.o; fi` `if [ -f ../gcc/libgcc.a ] ; then echo ../gcc/libgcc.a ; else gcc -print-libgcc-file-name; fi`'
  ;;

romp-*-*)
  HDEFINES=-DNO_VARARGS
  ;;

sparc*-*-solaris2*)
  HOSTING_CRT0='`if [ -f ../gcc/crt1.o ]; then echo ../gcc/crt1.o; else gcc -print-file-name=crt1.o; fi` `if [ -f ../gcc/crti.o ]; then echo ../gcc/crti.o; else gcc -print-file-name=crti.o; fi` /usr/ccs/lib/values-Xa.o `if [ -f ../gcc/crtbegin.o ]; then echo ../gcc/crtbegin.o; else gcc -print-file-name=crtbegin.o; fi`'
  HOSTING_LIBS='`if [ -f ../gcc/libgcc.a ] ; then echo ../gcc/libgcc.a ; else gcc -print-libgcc-file-name; fi` -lc `if [ -f ../gcc/crtend.o ]; then echo ../gcc/crtend.o; else gcc -print-file-name=crtend.o; fi` `if [ -f ../gcc/crtn.o ]; then echo ../gcc/crtn.o; else gcc -print-file-name=crtn.o; fi`'
  NATIVE_LIB_DIRS=/usr/ccs/lib
  ;;

esac

HLDFLAGS=
HLDENV=
RPATH_ENVVAR=LD_LIBRARY_PATH
# If we have shared libraries, try to set rpath reasonably.
if test "${shared}" = "true"; then
  case "${host}" in
  *-*-hpux*)
    HLDFLAGS='-Wl,+s,+b,$(libdir)'
    RPATH_ENVVAR=SHLIB_PATH
    ;;
  *-*-irix[56]*)
    HLDFLAGS='-Wl,-rpath,$(libdir)'
    ;;
  *-*-linux*aout*)
    ;;
  *-*-linux*)
    HLDFLAGS='-Wl,-rpath,$(libdir)'
    ;;
  *-*-solaris*)
    HLDFLAGS='-R $(libdir)'
    ;;
  *-*-sysv4*)
    HLDENV='if test -z "$${LD_RUN_PATH}"; then LD_RUN_PATH=$(libdir); else LD_RUN_PATH=$${LD_RUN_PATH}:$(libdir); fi; export LD_RUN_PATH;'
    ;;
  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 grep 'do not mix' 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
