#! /bin/sh
# $Id: mkcamlp4.sh.tpl,v 2.0 1998/12/01 08:20:42 ddr Exp $

OLIB=/usr/lib/ocaml
LIB=/usr/lib/camlp4

INTERFACES=
OPTS=
for i in $*; do
    j=`basename $i .cmi`
    if test "$j.cmi" = "$i"; then
	first="`expr "$j" : '\(.\)' | tr 'a-z' 'A-Z'`"
	rest="`expr "$j" : '.\(.*\)'`"
	INTERFACES="$INTERFACES $first$rest"
    else
	OPTS="$OPTS $i"
    fi
done

CRC=crc_$$
set -e
trap 'rm -f $CRC.ml $CRC.cmi $CRC.cmo' 0 2
$LIB/extract_crc -I $OLIB $INTERFACES > $CRC.ml
echo "let _ = Dynlink.add_available_units crc_unit_list" >> $CRC.ml
ocamlc -I $LIB odyl.cma camlp4.cma $CRC.ml $OPTS odyl.cmo -linkall
rm -f $CRC.ml $CRC.cmi $CRC.cmo
