#! /bin/sh
##
## ${R_HOME}/bin/LINK

revision='$Revision: 1.6 $'
version=`set - ${revision}; echo ${2}`
version="R linker front end ${version}

Copyright (C) 2000 The R Core Development Team.
This is free software; see the GNU General Public Licence version 2
or later for copying conditions.  There is NO warranty."

usage="Usage: R CMD LINK [options] linkcmd

Perform the specified linkcmd by passing it through GNU libtool and
setting a few useful R-related options.  Use in particular when creating
executables linked against the R shared library, in which case linkcmd
must contain '-lR' but need not specify its library path.

Options:
  -h, --help            print short help message and exit
  -v, --version         print version info and exit

Currently only is useful when creating executables, and only works if
the C compiler is used for linking.  If FORTRAN code is to be linked, it
needs to be manually ensured that the linker flags for the FORTRAN 77
intrinsic and run-time libraries are present.  C++ is not supported
(yet).

Report bugs to <r-bugs@r-project.org>."

args=
while test -n "${1}"; do
  case ${1} in
    -h|--help)
      echo "${usage}"; exit 0 ;;
    -v|--version)
      echo "${version}"; exit 0 ;;
    *)
      args="${args} ${1}" ;;
  esac
  shift
done

if test -z "${R_HOME}"; then
  echo "Fatal error: R_HOME was not set"
  exit 1
fi

## FIXME: should be `lib' eventually
Rexeclibdir=${R_HOME}/bin
## </FIXME>
linkopts="-avoid-version -rpath ${Rexeclibdir}"

exec ${R_HOME}/bin/libtool --mode=link ${args} ${linkopts}

### Local Variables: ***
### mode: sh ***
### sh-indentation: 2 ***
### End: ***
