Root/gforth/files/gforth-update-image.in

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
12FORTHSIZES="--dictionary-size=1M \
13    --data-stack-size=16k \
14    --fp-stack-size=15872 \
15    --return-stack-size=15360 \
16    --locals-stack-size=14848"
17
18STARTUP="exboot.fs startup.fs @asm_fs@ @disasm_fs@"
19
20FORTHKFLAGS="--die-on-signal -i @kernel_fi@"
21
22GFORTH_SHARE_DIR=/usr/share/gforth/@PACKAGE_VERSION@
23GFORTH_LIB_DIR=/usr/lib/gforth/@PACKAGE_VERSION@
24GFORTH_BIN_DIR=/usr/bin
25
26GFORTH_FI=${GFORTH_LIB_DIR}/gforth.fi
27
28echo "Creating Gforth interpreter image..."
29
30mkdir -p $GFORTH_LIB_DIR
31
32check_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
42if ! 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?
49EOF
50    exec false
51fi
52
53export libccdir=${GFORTH_LIB_DIR}/libcc-named
54export GFORTH="/usr/bin/gforth.real ${FORTHSIZES} ${FORTHKFLAGS} ${STARTUP}"
55gforthmi ${GFORTH_FI}.new ${FORTHSIZES} ${FORTHKFLAGS} ${STARTUP} &&
56mv -f ${GFORTH_FI}.new ${GFORTH_FI}
57exit $?
58
59
60
61

Archive Download this file



interactive