Skip to content

Instantly share code, notes, and snippets.

@gravicappa
Last active June 5, 2016 03:22
Show Gist options
  • Save gravicappa/10015430 to your computer and use it in GitHub Desktop.
Save gravicappa/10015430 to your computer and use it in GitHub Desktop.
Shen-cl builder script
#!/bin/sh
url=http://shenlanguage.org/download/Shen.zip
platforms='clisp sbcl'
sbcl='sbcl --control-stack-size 8'
latest() {
find 'Shen '[0-9]* -type d -maxdepth 0 | sort -V | tail -n 1
}
test -f "Shen.zip" || wget "$url"
unzip -q -n Shen.zip
dir="${1-$(latest)}"
chmod -R +w "$dir"
kl_dir() {
kldir=""
for x in "K Lambda" "KLambda"; do
test -d "$dir/$x" && kldir="$dir/$x"
done
test -z "$kldir" && { echo "Unable to find KLambda files">&2; exit 1;}
echo "$kldir"
}
build_clisp() {
pldir="$dir/Platforms/CLisp/"
cp "$(kl_dir)"/*.kl "$pldir/" || exit 1
awk '
/^\(EXT:SAVEINITMEM/ {
print "(EXT:SAVEINITMEM \"shen-clisp\" :QUIET T :EXECUTABLE T :NORC T"
print " :INIT-FUNCTION '"'"'shen.byteloop)"
next
}
{print}' <"$pldir/install.lsp" >"$pldir/myinst.lsp"
(cd "$pldir" && { echo '(load "myinst.lsp")'; sleep 10;} | clisp)
cp "$pldir/shen-clisp" .
}
build_sbcl() {
pldir="$dir/Platforms/SBCL/"
cp "$(kl_dir)"/*.kl "$pldir/" || exit 1
awk '
/^\(SAVE-LISP-AND-DIE/ {
print "(SAVE-LISP-AND-DIE \"shen-sbcl\" :EXECUTABLE T"
print " :SAVE-RUNTIME-OPTIONS T"
print " :TOPLEVEL '"'"'shen.shen)"
next
}
{print}' <"$pldir/install.lsp" >"$pldir/myinst.lsp"
(cd "$pldir" && { echo '(load "myinst.lsp")';} | $sbcl)
cp "$pldir/shen-sbcl" .
}
for p in $platforms; do build_$p; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment