#!/bin/sh
#######################################################################
#
#	sh-Script <mkshlib>  (by Heinz Seidl)
#
#	-- used to create a shared library (object) on SunOS 4.x.
#	   it automatically supplies the `init.o' file.
#
#######################################################################

[ "$TRACE" != "" ] && set -x

COM=`basename $0`
#fix me: works only if -fPIC comes before the le options
U="USAGE: $COM  [-fpic|-fPIC] <ld - options>"

: ${MKSHLIB_PATH:=/giga/hgs/lib/gcc/sun4/1.95.01/}

LD=$MKSHLIB_PATH/collect
INIT_O=init_PIC.o

OPTIONS=

for ARG in "$@"
do
	case "$ARG" in
	-fpic)  INIT_O=init_pic.o; break;;
	-fPIC)  INIT_O=init_PIC.o; break;;
	esac
done


#
# find the first .o file and prepend $INIT_O
#
while [ "$1" != "" ]
do
	case "$1" in
	-fpic|-fPIC)  shift;;
	*.o)	OPTIONS="$OPTIONS $MKSHLIB_PATH/$INIT_O $@"; break ;;
	*)	OPTIONS="$OPTIONS $1"; shift ;;
	esac
done

#
# Execute the linker
#
set -x
$LD $OPTIONS
