#!/bin/sh

# ld replacement for use with condor_compile
# Todd Tannenbaum, Nov 1993
#
# rename the "real" /bin/ld to /bin/ld.real and put this in
# its place.  See the condor_compile README.
# Tested on HPUX and SunOS 4.1.x
# 
# EDIT THE CONDOR_CLIB and CONDOR_RT0 varibles below to point
# to the right path.

ldargs=$*

###############################################
#
# EDIT THE TWO LINES BELOW TO REFLECT WHERE YOU
# INSTALLED libcondor.a AND condor_rt0.o
#
CONDOR_CLIB=/usr/local/condor/lib/libcondor.a
CONDOR_RT0=/usr/local/condor/lib/condor_rt0.o
#
###############################################

if [ A$CONDOR_COMPILE = Ayes ]; then
  case `/bin/uname` in
     HP-UX ) ldargs="-a archive" ;;
     SunOS ) ldargs="-Bstatic" ;;
     * ) echo "ERROR: condor_compile: I do not know how to link for this operating system"
         exit 1 ;;
  esac
  outflag=false
  changeflag=false
  while [ A$1 != A ]
  do
     brokenbase=`/bin/basename $1`
     if [ A$brokenbase = A ]; then
        brokenbase=$1
     fi
     case $brokenbase in
        -lc ) ldargs=`echo $ldargs $CONDOR_CLIB` ;;
        crt0.o ) ldargs=`echo $ldargs $CONDOR_RT0` ;;
        -o ) outflag=true
             ldargs=`echo $ldargs $1` ;;
        * ) if [ $outflag = true ]; then
               ldargs=`echo $ldargs $1'.condor'`
               outflag=false
               changeflag=true
            else
               ldargs=`echo $ldargs $1`
            fi ;;
     esac
     shift
  done
  if [ $changeflag = false ]; then
     ldargs=`echo $ldargs -o a.out.condor`   
  fi
fi

exec /bin/ld.real $ldargs

