#!/bin/sh
#
# COPYRIGHT (c) 2019 The Fellowship of SML/NJ (http://www.smlnj.org)
# All rights reserved.
#
# script to compile using the batch compiler
# usage:
#	cmb-make [ <sml-cmd> ] <flags> ...
#
# Do a batch compiler of the compiler; the optional <sml-cmd> argument specifes
# the path to the SML compiler to use for the build.
#

set -x

# for now, we use 32-bits as the default size, but this will change
#
SIZE_OPT="-32"
SML=sml
ARGS=""
# Process command-line arguments
#
while [ "$#" != "0" ] ; do
    arg=$1; shift
    case $arg in
    -32) SIZE_OPT=$arg ;;
    -64) SIZE_OPT=$arg ;;
    -C*) ARGS="$ARGS $arg" ;;
    -D*) ARGS="$ARGS $arg" ;;
    *)  SML=$arg
	break
	;;
    esac
done

exec $SML $SIZE_OPT $ARGS $@ -DNO_PLUGINS '$smlnj/cmb.cm' <<XXXX
CMB.make();
XXXX
