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

# @configure_input@

revision='$Revision: 1.11 $'
version=`set - ${revision}; echo ${2}`
version="R compilation 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 COMPILE [options] files

Compile the specified files for subsequent collection into a shared
library using \`R CMD SHLIB'.  Currently, C, C++, and FORTRAN files
(with extensions \`.c', \`.cc' or \`.cpp' or \`.C', and \`.f',
respectively, are supported.

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

Other options of the form \`-DMACRO' or \`VAR=VALUE' are passed on to
the compilation.

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

MAKE=${MAKE-@MAKE@}
makefiles="-f ${R_HOME}/etc/Makeconf"
if test -r Makevars; then
  makefiles="-f Makevars ${makefiles}"
fi

objs=
while test -n "${1}"; do
  case ${1} in
    -h|--help)
      echo "${usage}"; exit 0 ;;
    -v|--version)
      echo "${version}"; exit 0 ;;
    *.[cfC]|*.cc|*.cpp)
      objs="${objs} `echo ${1} | sed 's/\.[^\.][^\.]*$/.o/'`" ;;
    -D*|*=*)
      MAKEFLAGS="${MAKEFLAGS} ${1}" ;;
    *)
      echo "ERROR: don't know how to compile \`${1}'"
      exit 1
      ;;
  esac
  shift
done

${MAKE} ${makefiles} ${MAKEFLAGS} ${objs}

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