Last active
September 5, 2024 21:51
-
-
Save commonquail/4801536c1f74bde502fd735f653049ee to your computer and use it in GitHub Desktop.
Evaluate, generate intermediate code, and compile to native Common Lisp with sbcl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Or uncomment to run directly with shebang: | |
;#!/usr/bin/sbcl --script | |
(defun main () | |
(write-line "Hello, world!")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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