Skip to content

Instantly share code, notes, and snippets.

@martialboniou
Created December 16, 2011 12:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martialboniou/1485836 to your computer and use it in GitHub Desktop.
Save martialboniou/1485836 to your computer and use it in GitHub Desktop.
sbcl easy install
#!/bin/zsh
BINDIR="${HOME}/.tools/bin"
QUICKLISPDIRNAME=".quicklisp"
WORKINGLISPDIR="${HOME}/Dynamics/sbcl"
EMACS_CL=emacs
() {
[[ -a "${HOME}/.emacs.d/data/.launched" ]]\
&& which emacs-cl > /dev/null 2>&1\
&& EMACS_CL=emacs-cl
}
sbcl_install() {
which sbcl > /dev/null 2>&1\
|| ([[ "`uname`" = "Darwin" ]] && brew install sbcl || apt-get install sbcl)
}
goto_clbuild() {
cd "${WORKINGLISPDIR}/clbuild2" && [[ -x ./clbuild ]]
}
quicklisp_install() {
cd $HOME\
&& curl -O http://beta.quicklisp.org/quicklisp.lisp\
&& [[ "`awk 'NR==1,NF==1' quicklisp.lisp`" = ";;;;" ]]
&& sbcl --load quicklisp.lisp --eval "\
(progn\
(quicklisp-quickstart:install :path \"${QUICKLISPDIRNAME}/\")\
(ql:add-to-init-file)\
(quit)"
}
clbuild2_install() {
cd $WORKINGLISPDIR\
&& git clone git://gitorious.org/clbuild2/clbuild2.git\
&& cd clbuild2
&& () {
local sedi
[[ "`uname`" = "Darwin" ]] && "/usr/bin/sed -i ''" || "sed -i"
$(echo "$sedi 's/^\(qldir=\).*/\1\"\$(echo ~\/${QUICKLISPDIRNAME})\"/' internal/ql.sh")
$(echo "$sedi 's/\(\"~\/\).*\(\/slime-helper\)/\1${QUICKLISPDIRNAME}\2/' internal/slime.sh")
}
}
clbuild_binary_install() {
# for a specific emacs, create a script named 'clbuild' to start a different emacs:
echo "#!/bin/sh\n# clbuild2 is a build engine for Common Lisp\n# ensure Emacs boots in minimal context: eg. to start slime, run: clbuild slime\nEMACS=\"${EMACS_CL}\" ${WORKINGLISPDIR}/clbuild2/clbuild \"$@\"" > ${BINDIR}/clbuild
chmod 750 ${BINDIR}/clbuild
}
quickload_examples() {
goto_clbuild && echo "No clbuild found" && return 1
echo "Installing some packages now...\n"
echo "elephant: object persistence" && ./clbuild quickload elephant
echo "alexandria: universal utilities" && ./clbuild quickload alexandria
echo "fset: functional oriented sets" && ./clbuild quickload fset
echo "aserve: simple web server (required by Practical Common Lisp tutorials)"\
&& ./clbuild quickload aserve
return 0
}
slime_test() {
rehash
which ${EMACS_CL} > /dev/null 2>&1\
|| (echo "specific emacs launcher named ${EMACS_CL} not found"\
&& return 1)
which clbuild > /dev/null 2>&1\
|| (echo "clbuild is not in your path; add ${BINDIR}"
&& return 1)
clbuild slime
return 0
}
conf_lisp_setup() {
# as clbuild overrides .sbclrc, add ASDF path to 'conf.lisp':
goto_clbuild && echo "(pushnew (truename \"~/.sbcl/systems\") asdf:*central-registry* :test #'equal)" > conf.lisp
}
### NOTE: you may get a ASDF:SOURCE-REGISTRY error: don't worry and pass it by typing 0
default_install() {
sbcl_install && quicklisp_install && clbuild2_install && conf_lisp_setup
}
complete_install() {
default_install && clbuild_binary_install && rehash
}
complete_install_and_play() {
complete_install && quickload_examples && slime_test
}
default_install
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment