diff options
Diffstat (limited to 'gforth/files')
| -rw-r--r-- | gforth/files/gforth-update-image.in | 60 | ||||
| -rw-r--r-- | gforth/files/gforth-wrapper.in | 50 |
2 files changed, 110 insertions, 0 deletions
diff --git a/gforth/files/gforth-update-image.in b/gforth/files/gforth-update-image.in new file mode 100644 index 0000000..5d51434 --- /dev/null +++ b/gforth/files/gforth-update-image.in @@ -0,0 +1,60 @@ +#! /bin/sh +# +# Part of gforth package for OpenWrt: update Gforth pre-compiled interpreter +# image from installed sources +# +# Copyright (C) 2010 David Kuehling <dvdkhlng TA gmx TOD de> +# +# License: GPLv3+, NO WARRANTY +# + +# Rationale for choice of stack sizes, see Gforth Manual chapter 13.6 +FORTHSIZES="--dictionary-size=1M \ + --data-stack-size=16k \ + --fp-stack-size=15872 \ + --return-stack-size=15360 \ + --locals-stack-size=14848" + +STARTUP="exboot.fs startup.fs @asm_fs@ @disasm_fs@" + +FORTHKFLAGS="--die-on-signal -i @kernel_fi@" + +GFORTH_SHARE_DIR=/usr/share/gforth/@PACKAGE_VERSION@ +GFORTH_LIB_DIR=/usr/lib/gforth/@PACKAGE_VERSION@ +GFORTH_BIN_DIR=/usr/bin + +GFORTH_FI=${GFORTH_LIB_DIR}/gforth.fi + +echo "Creating Gforth interpreter image..." + +mkdir -p $GFORTH_LIB_DIR + +check_writable(){ + if [ -f $GFORTH_FI ] && ! [ -w $GFORTH_FI ]; then + return 1 + elif ! [ -w $GFORTH_LIB_DIR ]; then + return 1 + fi + + return 0 +} + +if ! check_writable; then + cat <<EOF + You do not have permissions to create/modify the + image file: + $GFORTH_FI + + Are you not root? +EOF + exec false +fi + +export libccdir=${GFORTH_LIB_DIR}/libcc-named +export GFORTH="/usr/bin/gforth.real ${FORTHSIZES} ${FORTHKFLAGS} ${STARTUP}" +gforthmi ${GFORTH_FI}.new ${FORTHSIZES} ${FORTHKFLAGS} ${STARTUP} && +mv -f ${GFORTH_FI}.new ${GFORTH_FI} +exit $? + + + diff --git a/gforth/files/gforth-wrapper.in b/gforth/files/gforth-wrapper.in new file mode 100644 index 0000000..3bc7d35 --- /dev/null +++ b/gforth/files/gforth-wrapper.in @@ -0,0 +1,50 @@ +#! /bin/sh +# +# Part of gforth package for OpenWrt: Wrapper to call check for and create +# Gforth image before running executable. +# +# Copyright (C) 2010 David Kuehling <dvdkhlng TA gmx TOD de> +# +# License: GPLv3+, NO WARRANTY +# +dirname=$(dirname "$0") +binary=$dirname/$(basename "$0").real + +GFORTH_LIB_DIR=/usr/lib/gforth/@PACKAGE_VERSION@ +GFORTH_FI=$GFORTH_LIB_DIR/gforth.fi + +# try to (re)generate the gforth.fi image file +do_update(){ + $dirname/gforth-update-image &> /dev/null + status=$? + [ $status = 0 ] && return 0 + +cat<<EOF + Gforth image $GFORTH_FI + is missing and regeneration failed: + + '$dirname/gforth-update-image' + aborted with exit code $status. + + Try to re-run 'gforth-update-image' manually to + see what is wrong. Also please report this + problem to <discussion@lists.qi-hardware.com> + and/or <dvdkhlng ta gmx tod de>. + + As a workaround, you can run a kernel-only Gforth + (with reduced functionality), using: + + $binary -i @kernel_fi@ +EOF + + exec false +} + +if ! [ -f "$GFORTH_FI" ]; then + do_update +fi + +# if everything is ok, we'll come here and run the actual Gforth executable +# (gforth.real, gforth-fast.real etc.) +exec "$binary" "$@" + |
