From 70fc9b7ea2458afd593709a262e96324cecdd48c Mon Sep 17 00:00:00 2001 From: nealcrook Date: Tue, 22 Nov 2016 21:42:19 +0000 Subject: [PATCH] bcpl is a script to automate the build process. The first FUZIX shell script!! Expand README to describe its use and caveats. --- Applications/BCPL/README | 10 ++++++ Applications/BCPL/bcpl | 68 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100755 Applications/BCPL/bcpl diff --git a/Applications/BCPL/README b/Applications/BCPL/README index f5a736a1..d1c3af1d 100644 --- a/Applications/BCPL/README +++ b/Applications/BCPL/README @@ -76,6 +76,16 @@ Where OCODE is the (hard-coded) name of the output file produced by the compiler and INTCODE is the (hard-coded) name of the output file produced by the code generator. +The makefile takes care of the generation of run-time.i codegen.i and b.i +and there is a handy script 'bcpl' that performs the four-step sequence above +that transforms a .b file into a .i file, allowing you to do this: + +$ bcpl hello.b +$ icintv hello.o + +In FUZIX, scripts are spotted and by the shell, not by the kernel, so you +must be running /bin/sh and *not* /bin/ssh (the confusingly-named simple shell) +in order for bcpl (or any other script) to work. icint vs icintv --------------- diff --git a/Applications/BCPL/bcpl b/Applications/BCPL/bcpl new file mode 100755 index 00000000..090f4797 --- /dev/null +++ b/Applications/BCPL/bcpl @@ -0,0 +1,68 @@ +#!/bin/sh +# +# bcpl "compiler" +# +# usage: +# bcpl myprog.b +# +# generates file myprog.i which is BCPL INTCODE for myprog.b +# +# run the program like this: +# +# icint myprog.i +# +# +# dependencies: +# +# - expects to find the INTCODE Interpreter (icint) on the path +# - expects to find b.i and codegen.i and run-time.i in location defined +# by LIBS or, failing that, in the cwd. +# +# Working around FUZIX sh limitations: +# - no kernel #! support, so line 1 here is ignored; this script is processed +# by the shell itself, so you must be running sh and not ssh to have any +# chance +# - no support for "!" in the shell, so negation must be after the test: +# [ ! -f "foo" ] rather than ! [ -f "foo" ] +# - basename needs old-style invocation + +LIBS=/usr/src/BCPL + +if [ "$#" -ne 1 ] || [ ! -f "$1" ]; then + echo "" + echo "Generate INTCODE from BCPL source. Usage:" + echo "" + echo " bcpl myprog.b" + echo " icintv myprog.i" + echo "" + exit 1 +fi + +if [ ! -f "$LIBS/b.i" ]; then + if [ ! -f "./b.i" ]; then + echo "**** Error: Could not find $LIBS/b.i or ./b.i required for compilation" + exit 1 + fi + LIBS=./ +fi + + +src=$1 +exe=`basename $src b` +exe=${exe}i + +icintv $LIBS/b.i <$src +if [ "$?" != "0" ]; then + echo "**** Error: Compilation failed for $src" + exit 1 +fi + +icintv $LIBS/codegen.i $exe +# tidy up +rm -f OCODE INTCODE -- 2.34.1