Skip to content

Instantly share code, notes, and snippets.

@commonquail
Last active April 22, 2018 00:36
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 commonquail/4801536c1f74bde502fd735f653049ee to your computer and use it in GitHub Desktop.
Save commonquail/4801536c1f74bde502fd735f653049ee to your computer and use it in GitHub Desktop.
Evaluate, generate intermediate code, and compile to native Common Lisp with sbcl
; Or uncomment to run directly with shebang:
;#!/usr/bin/sbcl --script
(defun main ()
(write-line "Hello, world!"))
src=foo.lisp
obj=$(src:.lisp=.fasl)
bin=foo
.SUFFIXES:
.PHONY: eval
eval:
sbcl --noinform --load $(basename $(src)) --eval '(main)' --eval '(exit)' \
2>/dev/null
%.fasl: %.lisp
sbcl --noinform --eval '(compile-file "$<")' --eval '(exit)' \
2>/dev/null
# Also works and allows for disabling .fasl generation.
# That may be faster for big programs.
#bin/$(bin): $(src)
bin/$(bin): $(obj)
mkdir -p $(dir $@)
sbcl --noinform --load $< --eval "(sb-ext:save-lisp-and-die \"$@\" :toplevel #'main :executable t)" \
2>/dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment