3 $(shell (test -f
"hist/$(1)_impl" && grep
-q
$(2) "hist/$(1)_impl") || echo
$(2) > "hist/$(1)_impl")
8 $(if
$(findstring all,$(MAKECMDGOALS
)),\
10 $(filter step
%, $(MAKECMDGOALS
))),\
18 # TODO: In theory cl-launch should be able to build standalone executable using
19 # MKCL unfortunately the executable crashes on startup
20 STANDALONE_EXE
= sbcl clisp ccl ecl cmucl
22 ROOT_DIR
:= $(shell dirname
$(realpath
$(lastword
$(MAKEFILE_LIST
))))
23 SOURCES_LISP
:= src
/env.lisp src
/core.lisp src
/stepA_mal.lisp
24 SOURCES
:= src
/utils.lisp src
/types.lisp src
/reader.lisp src
/printer.lisp
$(SOURCES_LISP
)
26 # Record the Common Lisp implementation used for all steps built in this
27 # invocation This is used in the targets to rebuild the step if the
28 # implementation changes
29 $(foreach step
, $(call steps
), $(call record_lisp
,$(patsubst step
%,%,$(step
)),$(LISP
)))
31 .PRECIOUS
: hist
/%_impl
38 # CL_LAUNCH_VERSION is only defined while building it. We change to the
39 # directory of the CL_LAUNCH_FILE in --wrap script so that the script can find the dumped
40 # image even if invoked from some directory different from where it
42 step
% : src
/step
%.lisp src
/utils.lisp src
/types.lisp src
/env.lisp src
/printer.lisp src
/reader.lisp src
/core.lisp hist
/%_impl
45 @echo
"=============================================================="
46 @echo
"WARNING: This build might fail since GNU Clisp does not have bundled version of asdf (yet)"
47 @echo
"Please do something like below to make it work"
48 @echo
"(mkdir -p ~/common-lisp/ && cd ~/common-lisp && git clone -b release https://gitlab.common-lisp.net/asdf/asdf.git && cd asdf && make)"
49 @echo
"=============================================================="
52 ifneq ($(filter $(LISP
),$(STANDALONE_EXE
)),)
53 cl-launch
--wrap
'if [ -z "$$CL_LAUNCH_VERSION" ] ; then cd "$$(dirname $$CL_LAUNCH_FILE)" ; fi' --verbose
--lisp
$(LISP
) --source-registry
$(ROOT_DIR
) --system
$@
--dump
'!' -o
$@
--entry
'mal:main'
54 else ifeq ($(LISP
),abcl
)
55 echo
-n
'#!/bin/sh\ncd `dirname $$0` ; $(ABCL) --noinform --noinit --nosystem --load run-abcl.lisp -- $@ $$@' > $@
57 else ifeq ($(LISP
),mkcl
)
58 $(MKCL
) -eval
'(progn (require "asdf") (push *default-pathname-defaults* asdf:*central-registry*) (asdf:load-system "$@") (quit))'
59 echo
-n
'#!/bin/sh\ncd `dirname $$0` ; $(MKCL) -q -load run-mkcl.lisp -- $@ $$@' > $@
61 else ifeq ($(LISP
),allegro
)
62 cl-launch
--wrap
'if [ -z "$$CL_LAUNCH_VERSION" ] ; then cd "$$(dirname $$CL_LAUNCH_FILE)" ; fi' --verbose
--lisp
$(LISP
) --source-registry
$(ROOT_DIR
) --system
$@
--dump images
/$@.
$(LISP
).image
-o
$@
--entry
'mal:main'
64 @echo
"Unsupported Lisp implementation $(LISP)"
69 find .
-maxdepth
1 -name
'step*' -executable
-delete
70 rm -f
*.lib
*.fas
[l
] images
/* hist
/*_impl
74 @printf
"%5s %5s %5s %s\n" `grep -E "^[[:space:]]*;|^[[:space:]]*$$" $^ | wc` "[comments/blanks]"
76 stats-lisp
: $(SOURCES_LISP
)
78 @printf
"%5s %5s %5s %s\n" `grep -E "^[[:space:]]*;|^[[:space:]]*$$" $^ | wc` "[comments/blanks]"