#! /bin/sh -e ":"; exec sbcl --script "$0" "$@" # -*-lisp-*- (require 'sb-executable) (let* ((args (cdr *posix-argv*)) (prog (pathname-name *load-pathname*)) (cmd (pop args))) (labels ((moan (message &rest arguments) (format *error-output* "~A: ~?~%" prog message arguments)) (die (message &rest arguments) (apply #'moan message arguments) (exit :code 1))) (cond ((not cmd) (format *error-output* "Usage: ~A build SOURCE SOURCE ...~%~ ~0~ ~:*~A link OUTPUT FASL FASL ...~%" prog) (exit :code 1)) ((string= cmd "build") (let ((rc 0)) (dolist (file args) (unless (handler-case (compile-file file :verbose nil :print nil) (error (cond) (moan "failed to compile `~A':~%~8T~A" file cond))) (setf rc 1))) (exit :code rc))) ((string= cmd "link") (let ((out (pop args))) (handler-case (sb-executable:make-executable out args) (error (cond) (die "failed to make executable:~%~8T~A" cond))))) (t (die "unknown command `~A'" cmd)))))