OpenWrt packages
Sign in or create your account | Project List | Help
OpenWrt packages Git Source Tree
Root/
| 1 | #! /bin/sh |
| 2 | # |
| 3 | # Part of gforth package for OpenWrt: update Gforth pre-compiled interpreter |
| 4 | # image from installed sources |
| 5 | # |
| 6 | # Copyright (C) 2010 David Kuehling <dvdkhlng TA gmx TOD de> |
| 7 | # |
| 8 | # License: GPLv3+, NO WARRANTY |
| 9 | # |
| 10 | |
| 11 | # Rationale for choice of stack sizes, see Gforth Manual chapter 13.6 |
| 12 | FORTHSIZES="--dictionary-size=1M \ |
| 13 | --data-stack-size=16k \ |
| 14 | --fp-stack-size=15872 \ |
| 15 | --return-stack-size=15360 \ |
| 16 | --locals-stack-size=14848" |
| 17 | |
| 18 | STARTUP="exboot.fs startup.fs @asm_fs@ @disasm_fs@" |
| 19 | |
| 20 | FORTHKFLAGS="--die-on-signal -i @kernel_fi@" |
| 21 | |
| 22 | GFORTH_SHARE_DIR=/usr/share/gforth/@PACKAGE_VERSION@ |
| 23 | GFORTH_LIB_DIR=/usr/lib/gforth/@PACKAGE_VERSION@ |
| 24 | GFORTH_BIN_DIR=/usr/bin |
| 25 | |
| 26 | GFORTH_FI=${GFORTH_LIB_DIR}/gforth.fi |
| 27 | |
| 28 | echo "Creating Gforth interpreter image..." |
| 29 | |
| 30 | mkdir -p $GFORTH_LIB_DIR |
| 31 | |
| 32 | check_writable(){ |
| 33 | if [ -f $GFORTH_FI ] && ! [ -w $GFORTH_FI ]; then |
| 34 | return 1 |
| 35 | elif ! [ -w $GFORTH_LIB_DIR ]; then |
| 36 | return 1 |
| 37 | fi |
| 38 | |
| 39 | return 0 |
| 40 | } |
| 41 | |
| 42 | if ! check_writable; then |
| 43 | cat <<EOF |
| 44 | You do not have permissions to create/modify the |
| 45 | image file: |
| 46 | $GFORTH_FI |
| 47 | |
| 48 | Are you not root? |
| 49 | EOF |
| 50 | exec false |
| 51 | fi |
| 52 | |
| 53 | export libccdir=${GFORTH_LIB_DIR}/libcc-named |
| 54 | export GFORTH="/usr/bin/gforth.real ${FORTHSIZES} ${FORTHKFLAGS} ${STARTUP}" |
| 55 | gforthmi ${GFORTH_FI}.new ${FORTHSIZES} ${FORTHKFLAGS} ${STARTUP} && |
| 56 | mv -f ${GFORTH_FI}.new ${GFORTH_FI} |
| 57 | exit $? |
| 58 | |
| 59 | |
| 60 | |
| 61 |
