Created
August 9, 2018 19:39
-
-
Save jl2/b219a3973cbd4338f707a87c53be8c1c to your computer and use it in GitHub Desktop.
This file contains 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
(defun create-makefile (package-name | |
&key | |
(entry "main") | |
(directory (format nil "~~/src/lisp/~a/" package-name)) | |
(binary-name package-name) | |
(extra-buildapp-flags "--compress-core") | |
(manifest-file-name "manifest.txt") | |
(quicklisp-setup "~/quicklisp/setup.lisp")) | |
"Create a Makefile for building an executable image from a Common Lisp package." | |
(let* ((lisp-files (mapcar #'file-namestring (uiop:directory-files directory "*.lisp"))) | |
(asd-files (mapcar #'file-namestring (uiop:directory-files directory "*.asd"))) | |
(asd-file-name (format nil "~a~a.asd" directory package-name)) | |
(asd-file (with-input-from-file (ins asd-file-name) (read ins))) | |
(makefile-name (format nil "~aMakefile" directory)) | |
(dependencies (mapcar #'string-downcase (getf asd-file :depends-on)))) | |
(with-output-to-file (outs makefile-name :if-exists :supersede) | |
(declare (type stream outs)) | |
(format outs "~a: ~a ~{~a ~} ~{~a ~}~%" binary-name manifest-file-name lisp-files asd-files) | |
(format outs " buildapp --output ~a ~a --manifest-file ~a ~{--load-system ~a ~} --load-system ~a --entry '~a:~a'~%" | |
binary-name | |
extra-buildapp-flags | |
manifest-file-name | |
dependencies | |
package-name | |
package-name | |
entry) | |
(format outs "~%~%~a: ~{~a ~}~%" manifest-file-name asd-files) | |
(format outs " sbcl --no-userinit --no-sysinit --non-interactive --load ~a ~{--eval '(ql:quickload :~a)' ~} --eval '(ql:write-asdf-manifest-file \"~a~a\")'~%" | |
quicklisp-setup | |
dependencies | |
directory | |
manifest-file-name) | |
(format outs "~%~%clean:~% rm -Rf ~a ~a *.fasl~%~%.PHONY: clean" manifest-file-name binary-name)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment