#!/bin/sh
# $Id: linker 615 2010-09-30 15:49:42Z florenz@TU-BERLIN.DE $

# throw away OCS_DL_PATH 
shift

#echo $*

# get arguments
ofile=$1; shift
struct=$1; shift
comno=$1; shift
objs=""
libs=""
params=""


while  [ $# -ge 1 ] && [ $1 != -libs ]
do
  objs="$objs $1"
  shift
done

if [ $1 = -libs ]
then
  shift
  while  [ $# -ge 1 ] && [ $1 != -params ]
  do
    libs="$libs -I$1 -L$1 -l$2"
    shift
    shift
  done
fi

if [ $1 = -params ]
then
  shift
  parms="$*"
fi

#echo "$LD -o $ofile -Dinit=init_A$struct -Dcommand=__A${struct}_$comno \
#  ${OPAL_BASE}/_oasystart.c $objs $libs $params"
exec $LD -o $ofile -Dinit=init_A$struct -Dcommand=__A${struct}_$comno \
  ${OPAL_BASE}/_oasystart.c $objs $libs $params
