#!/bin/bash # # determine the LOGON root directory, assuming this script resides in a # `bin' sub-directory that is shared across platforms. # if [ -z "${LOGONROOT}" ]; then path=$(dirname $0) if [ "${path#./}" != "${path}" ]; then path="$(pwd)/${path#./}" fi if [ "${path#/}" = "${path}" ]; then if [ "${path}" = "." ]; then path="$(pwd)"; else path="$(pwd)/${path}" fi fi LOGONROOT="${path%/bin}"; export LOGONROOT; fi # # include a shared set of shell functions and global parameters, including the # architecture identifier .LOGONOS. # . ${LOGONROOT}/etc/library.bash; # # to give developers to test (easily) using a binary external to the LOGON # tree, avoid adding our own ACE-specific shard libraries to LD_LIBRARY_PATH. # if [ -n "${LOGONACE}" ]; then # # if need be, drop any initial command-line options specific to this script # while [ "${1}" == "--32" -o "${1}" == "--stable" \ -o "${1}" == "--annotate" -o "${1}" == "--compile" \ -o "${1}" == "--erg" -o "${1}" == "--terg" \ -o "${1}" == "--size" -o "${1}" == "--duration" ]; do shift 1; done exec ${LOGONACE} "$@" fi # # _fix_me_ # rework option parsing (in the style of `bin/logon'). (21-jun13; oe) # # # at this point, parse the options that modify our own behaviour # while [ "${1}" == "--32" -o "${1}" == "--stable" \ -o "${1}" == "--annotate" -o "${1}" == "--compile" \ -o "${1}" == "--erg" -o "${1}" == "--terg" \ -o "${1}" == "--size" -o "${1}" == "--duration" ]; do case "${1}" in --32) echo "ace: 32-bit environments are not support." exit 1; ;; --stable) binary=${LOGONROOT}/lingo/answer/bin/${LOGONOS}/sace; shift 1; ;; --erg) grammar=${LOGONROOT}/lingo/erg/erg.dat; config=${LOGONROOT}/lingo/erg/ace/config.tdl; shift 1; ;; --terg) grammar=${LOGONROOT}/lingo/terg/erg.dat; config=${LOGONROOT}/lingo/terg/ace/config.tdl; shift 1; ;; --annotate) binary=${LOGONROOT}/lingo/answer/bin/${LOGONOS}/fftb; # # while the Answer Full-Forest Treebanker lacks an `--ld-library-path' # option, we need to dance a complicated dance: for cross-distribution # compatibility, the LOGON tree bundles dynamic libraries from the build # environment and then invokes binaries with LD_LIBRARY_PATH pointing to # those libraries. in this case, however, the treebanker binary wants # to invoke a web browser (to launch at the right URL), which on systems # that are newer than the build environment may cause an error (because # LD_LIBRARY_PATH may lead the spawned browser to incompatible versions # of dynamic libraries). hence, dynamically generate a script to be # called, preserving the original LD_LIBRARY_PATH. # browser=${LOGONROOT}/lingo/answer/bin/browser; echo "#!/bin/sh" > ${browser}; echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" >> ${browser}; echo "exec firefox \"\$@\"" >> ${browser}; chmod +x ${LOGONROOT}/lingo/answer/bin/browser; shift 1; ;; --compile) compile="yes"; shift 1; ;; --size) ulimit -d $[$2 * 1024]; ulimit -v $[$2 * 1024]; shift 2; ;; --duration) ulimit -t $2; shift 2; ;; esac done [ -x "${binary}" ] || binary=${LOGONROOT}/lingo/answer/bin/${LOGONOS}/ace; # # set up dynamic linker search path, so as to find our shared libraries # LOGONOS=linux.x86.64; if [ "${LOGONOS%%.*}" == "linux" ]; then if [ -z "${LD_LIBRARY_PATH}" ]; then LD_LIBRARY_PATH=${LOGONROOT}/lingo/answer/lib/${LOGONOS}; else LD_LIBRARY_PATH=${LOGONROOT}/lingo/answer/lib/${LOGONOS}:${LD_LIBRARY_PATH}; fi export LD_LIBRARY_PATH; fi if [ -n "${compile}" ]; then if [ -f "${config}" -a -n "${grammar}" ]; then exec ${binary} -G ${grammar} -g ${config} "$@"; else echo "answer: missing or invalid grammar information for \`--compile'."; exit 1; fi fi if [ -z "${grammar}" ]; then exec ${binary} "$@" else # # _fix_me_ # we should avoid re-generating the grammar image more than once, i.e. wrap # the flock(1) around any testing for its existence; later. (22-jun-13; oe) # if [ ! -f "${grammar}" -a -f ${config} ]; then flock -x -w 30 ${config} -c \ "${binary} -G ${grammar} -g ${config}" > /dev/null 2>&1; fi exec ${binary} -g ${grammar} "$@"; fi