#!/bin/sh
#
# A script for building a library.
#

usage="llldr name cpp_link_p target_dir elab_function rtname src_dir {objname src_dir}* -l {option}*"

if [ $# -lt 5 ]
then
  echo $usage
  exit 1
fi

name=$1
cpplinkp=$2
tdir=$3
elabfun=$4
rtname=$5
rtdir=$6

shift;shift;shift;shift;shift;shift

objects=""

while [ $# != 0 -a "x$1" != "x-l" ]
do
  objects="$objects $2/$1.o"
  shift;shift
done

options=""

if [ "x$1" = "x-l" ]
then
  shift
  options=$*
fi


if [ "$cpplinkp" = "yes" ]
then
  cmd="g++"
else
  cmd="gcc"
fi
rm -f $tdir/$name.so.1.0
$cmd -shared $objects $options -o $tdir/$name.so.1.0

