#! /bin/sh # icc custom ld script; fiddles with the ld commandline. This is done # by shifting through the entire argument list. If we like the arg, we # append it to the end of the arglist via 'set'. If not, we don't # append anything, and the arg is shifted out of existence. # Written by Dan Nelson with some modifications # by Alexander Leidinger . # C++ support by Marius Strobl . PREFIX=@@PREFIX@@ i=0 argc=$# while [ $i -lt $argc ] ; do val=$1 shift if [ "$val" == "-CPLUSPLUS" ] ; then cplusplus=1 elif [ "$val" == "-BOOTSTRAPSTLPORT" ] ; then bootstrapstlport=1 else set -- "$@" "$val" fi i=$(($i+1)) done i=0 argc=$# # prepend "-m elf_i386" to the commandline set -- "$@" -m elf_i386 while [ $i -lt $argc ] ; do val=$1 shift case $val in # there was also "-lirc", but in a test -lirc works here -limf|\ ${PREFIX}/intel/compiler60/ia32/lib/icrt.link|\ -Qy\ ) # libs that have Linux lib dependencies # possibly unneeded .link file? # obsolete flag unset val ;; -lcprts|-lunwind) # only needed when compiling c++ source, depend on libc_r if [ ! "$cplusplus" ] ; then unset val fi ;; -lc) if [ "$cplusplus" ] ; then if [ "$bootstrapstlport" ] ; then val=-lc_r else unset val set -- "$@" -lc_r -lstlport_icc fi fi ;; /lib/ld-linux.so.2) # switch it val=/usr/libexec/ld-elf.so.1 ;; -L/usr/lib) # remove this, and replace with FreeBSD's lib paths unset val set -- "$@" -L/usr/libexec/elf -L/usr/libexec -L/usr/lib \ -L${PREFIX}/lib ;; ${PREFIX}/intel/compiler60/ia32/lib/crtxi.o) # switch it val=/usr/lib/crtbegin.o ;; ${PREFIX}/intel/compiler60/ia32/lib/crtxn.o) # switch it good val=/usr/lib/crtend.o ;; -Bdynamic) # Force libcprts, libcxa and libunwind to static linkage, # since the dynamic versions have linux glibc # dependencies. This might not fully work, as when it # does call libc stuff it could fail. I haven't been able # to make it happen though. # ibcprts and libunwind are only needed when compiling c++ # source, else we remove the superfluous -Bdynamic. case $1 in -lcxa) val=-Bstatic ;; -lcprts|-lunwind) if [ "$cplusplus" ] ; then val=-Bstatic else unset val fi ;; *) ;; esac ;; -Bstatic) # remove superfluous -Bstatic not followed by a library case $1 in -limf|-lirc) unset val ;; -lcprts|-lunwind) if [ ! "$cplusplus" ] ; then unset val fi ;; *) ;; esac ;; *) ;; esac # append our new $val to the end of argv, if it still exists. if [ ${#val} -gt 0 ] ; then set -- "$@" "$val" fi i=$(($i+1)) done # run FreeBSD's ld with our new args exec ${PREFIX}/intel/compiler60/ia32/bin/real/ld "$@"