2016-11-15 21:54:49 +03:00
|
|
|
# Helper functions
|
|
|
|
define record_lisp
|
|
|
|
$(shell (test -f "hist/$(1)_impl" && grep -q $(2) "hist/$(1)_impl") || echo $(2) > "hist/$(1)_impl")
|
|
|
|
endef
|
|
|
|
|
|
|
|
define steps
|
|
|
|
$(if $(MAKECMDGOALS),\
|
|
|
|
$(if $(findstring all,$(MAKECMDGOALS)),\
|
|
|
|
stepA_mal,\
|
|
|
|
$(filter step%, $(MAKECMDGOALS))),\
|
|
|
|
stepA_mal)
|
|
|
|
endef
|
|
|
|
|
|
|
|
ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
|
|
|
|
SOURCES_LISP := env.lisp core.lisp stepA_mal.lisp
|
|
|
|
SOURCES := utils.lisp types.lisp reader.lisp printer.lisp $(SOURCES_LISP)
|
2016-11-15 16:51:00 +03:00
|
|
|
LISP ?= sbcl
|
2016-11-20 22:41:55 +03:00
|
|
|
ABCL ?= abcl
|
2016-11-02 13:10:01 +03:00
|
|
|
|
2016-11-15 21:54:49 +03:00
|
|
|
# Record the Common Lisp implementation used for all steps built in this
|
|
|
|
# invocation This is used in the targets to rebuild the step if the
|
|
|
|
# implementation changes
|
|
|
|
$(foreach step, $(call steps), $(call record_lisp,$(patsubst step%,%,$(step)),$(LISP)))
|
2016-11-02 13:10:01 +03:00
|
|
|
|
2016-11-15 21:54:49 +03:00
|
|
|
.PRECIOUS: hist/%_impl
|
2016-11-02 13:10:01 +03:00
|
|
|
.PHONY: stats
|
|
|
|
|
2016-11-15 21:54:49 +03:00
|
|
|
all : stepA_mal
|
|
|
|
|
|
|
|
hist/%_impl: ;
|
|
|
|
|
2016-11-18 14:16:15 +03:00
|
|
|
# CL_LAUNCH_VERSION is only defined while building it. We change to the
|
|
|
|
# directory of the CL_LAUNCH_FILE in --wrap script so that the script can find the dumped
|
|
|
|
# image even if invoked from some directory different from where it
|
|
|
|
# currently resides
|
2016-11-15 21:54:49 +03:00
|
|
|
step% : step%.lisp utils.lisp types.lisp env.lisp printer.lisp reader.lisp core.lisp hist/%_impl
|
2016-11-20 22:41:55 +03:00
|
|
|
ifeq ($(LISP),abcl)
|
|
|
|
echo -n '#!/bin/sh\ncd `dirname $$0` ; $(ABCL) --noinform --noinit --nosystem --load run-abcl.lisp -- $@ $$@' > $@
|
|
|
|
chmod +x $@
|
|
|
|
else
|
2016-11-18 14:16:15 +03:00
|
|
|
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'
|
2016-11-20 22:41:55 +03:00
|
|
|
endif
|
2016-11-02 13:10:01 +03:00
|
|
|
|
|
|
|
clean:
|
|
|
|
find . -name 'step*' -executable -exec git check-ignore \{\} \; -delete
|
2016-11-15 21:54:49 +03:00
|
|
|
rm -f *.lib *.fas[l] images/* hist/*_impl
|
2016-11-02 13:10:01 +03:00
|
|
|
|
|
|
|
stats: $(SOURCES)
|
|
|
|
@wc $^
|
|
|
|
@printf "%5s %5s %5s %s\n" `grep -E "^[[:space:]]*;|^[[:space:]]*$$" $^ | wc` "[comments/blanks]"
|
|
|
|
|
|
|
|
stats-lisp: $(SOURCES_LISP)
|
|
|
|
@wc $^
|
|
|
|
@printf "%5s %5s %5s %s\n" `grep -E "^[[:space:]]*;|^[[:space:]]*$$" $^ | wc` "[comments/blanks]"
|