#!/bin/ksh93 # # The standard driver for SML/NJ under the new runtime system # CMD=${.sh.file##*/} # # for /bin/ksh, disable reading user's environment file # unset ENV ############################################################################# # # BEGIN SITE SPECIFIC STUFF # ############################################################################# # # SITE SPECIFIC CONFIGURATION INFO # # the path of the directory in which executables (like this file) are kept. if [[ -z ${SMLNJ_HOME} ]] ; then BIN_DIR="@CLIENT_BASEDIR@/lib/smlnj/bin" if [[ ! -d ${BIN_DIR} ]]; then BIN_DIR="${.sh.file%/*}" [[ ${BIN_DIR:0:1} == '/' ]] || \ { cd "${BIN_DIR}" ; cmddir="${PWD}" ; cd "${OLDPWD}" ; } fi else [[ -z ${CM_PATHCONFIG} ]] && \ export CM_PATHCONFIG="${SMLNJ_HOME}/lib/pathconfig" BIN_DIR="${SMLNJ_HOME}/bin" fi # the path of the directory in which the runtime system executables are kept. RUN_DIR="${BIN_DIR}/.run" # the path of the directory in which the heap images are kept. HEAP_DIR="${BIN_DIR}/.heap" # the following could be replaced with some site specific code . "${BIN_DIR}/.arch-n-opsys" ############################################################################# # # END SITE SPECIFIC STUFF # ############################################################################# # special shortcut for frequent use (and for Linux' binfmt) if [[ ${CMD} == 'sml' && $1 =~ ^\.?\.?/ ]] ; then [[ ${1##*.} =~ ^(fm|sml|sig|fun)$ ]] || { HEAP="@SMLload=$1" ; shift ; } fi ALLOC= # # Process command line arguments # while (( $# )); do arg="$1" case "$arg" in @SMLrun=*) shift RUN="${arg:8}" ;; @SMLload=*) shift HEAP="${arg}" ;; @SMLappl) shift if (( $# == 0 )); then print -u2 "${CMD}: missing argument for @SMLappl option" exit 1 fi APPL="$1" shift ;; @SMLversion) print "${CMD} 110.79" exit 0 ;; @SMLsuffix) print "${HEAP_SUFFIX}" exit 0 ;; @SMLalloc=*) shift ALLOC="${arg}" ;; *) break ;; esac done # # Try to figure out the CPU's cache size and set the allocation area # size accordingly. This is majorly important for Celeron systems # which suffer badly when the allocation area is too big. # if [[ -z ${ALLOC} ]] ; then typeset C= L X I T Z smbios -t SMB_TYPE_PROCESSOR | while read L X I Z ; do [[ $X == 'Cache:' ]] || continue [[ $L == 'L1' ]] && C[1]=$I && continue [[ $L == 'L2' ]] && C[2]=$I && continue [[ $L == 'L3' ]] && C[3]=$I && continue done I=${C[3]} [[ -z $I || ! $I =~ ^[0-9]+$ ]] && I=${C[2]} [[ -z $I || ! $I =~ ^[0-9]+$ ]] && I=${C[1]} if [[ $I =~ ^[0-9]+$ ]]; then smbios -i $I | while read L X Z T ; do [[ $L == 'Installed' && $X == 'Size:' ]] && C[0]=$Z && break done fi [[ -z ${C[0]} ]] && I=524288 || I=${C[0]} typeset -i I if (( I > 1048576 )); then kb=1024 elif (( I > 262144 )); then kb=512 else kb=256 fi ALLOC="@SMLalloc=${kb}" fi if [[ -z ${RUN} ]]; then # Construct the runtime system path from the ARCH and OS RUN="${RUN_DIR}/run.${ARCH}-${OPSYS}" if [[ ! -x ${RUN} ]]; then [[ -n ${ALT_OPSYS} ]] && RUN="${RUN_DIR}/run.${ARCH}-${ALT_OPSYS}" if [[ ! -x ${RUN} ]]; then print -u2 "${CMD}: cannot find runtime system ${RUN}" exit 1 fi fi fi if [[ -z ${HEAP} ]]; then # Construct the heap image path from the APPL and ARCH [[ -z ${APPL} ]] && APPL="${CMD}" HEAP="@SMLload=${HEAP_DIR}/${APPL}" fi # run the sucker! exec "${RUN}" @SMLcmdname="$0" "${HEAP}" ${ALLOC} "$@"