#!/bin/sh

case "$1" in
    @*) HEAP_IMAGE=sml ;;
    ?*) HEAP_IMAGE=$1; shift ;;
    *) HEAP_IMAGE=sml ;;
esac

cmddir=`dirname $0`
cmddir=`cd $cmddir; pwd`

bin=../../bin
[ -x "$bin/.arch-n-opsys" ] || bin="$cmddir/$bin"

eval `$bin/.arch-n-opsys`

heapdir=`dirname $HEAP_IMAGE`
[ -f "$heapdir/$HEAP_IMAGE.$HEAP_SUFFIX" ] || heapdir="$cmddir/$heapdir"
HEAP_IMAGE=`cd $heapdir; pwd`/$HEAP_IMAGE

LIB_DIR=${HEAP_IMAGE}.lib
LPC=${LIB_DIR}/local_pathconfig

rm -f $LPC
cp ../../config/extrapathconfig $LPC

CM_PATHCONFIG=$LIB_DIR/pathconfig CM_LOCAL_PATHCONFIG=$LPC \
    $bin/sml @SMLload=$HEAP_IMAGE "$@"
