#! /bin/sh

# qld: the Q linker program

# USAGE: qld --help | --version | -o PROGNAME [-dlopen MODULE ...]

# DESCRIPTION: Links the interpreter's main (in libqmain.la) against the
# specified user modules. You need to do this to make your modules work on
# systems lacking shared library support. You'll also want to do this to link
# against a static module which is useful, e.g., to facilitate module
# debugging.

# The specified options are simply passed on to the libtool program, thus you
# can actually use any option recognized in libtool's link mode. The
# interpreter executable is written to the specified PROGNAME (no default, so
# the -o option must *always* be specified).

case "$1" in
-h|--help)
  cat <<EOF
Usage: qld --help | --version | -o progname [-dlopen module ...]
Options:
--help, -h		Print this list.
--version, -V		Display version information and copyright notices.

All other options are passed on to libtool which does the actual processing.
The interpreter executable is written to the specified progname (-o option, no
default). Try
	/usr/local/lib/q/libtool --help --mode=link
for help on libtool link options.
EOF
  ;;
-V|--version)
  cat <<EOF
Q module linker version 7.11 (sparc64-portbld-freebsd8.0)
Copyright (c) 2000-2008 by Albert Graef

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

Type \`qld --help' for help.

Libtool version (/usr/local/lib/q/libtool):
EOF
  /usr/local/lib/q/libtool --version
  ;;
*)
  echo /usr/local/lib/q/libtool --quiet --mode=link cc -dlpreopen force "$@" -lqmain
  /usr/local/lib/q/libtool --quiet --mode=link cc -dlpreopen force "$@" -lqmain && rm -R .libs
  ;;
esac
