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
|
|
|
|
|
2017-08-23 21:15:05 +03:00
|
|
|
LISP ?= sbcl
|
|
|
|
ABCL ?= abcl
|
2017-08-24 16:28:17 +03:00
|
|
|
MKCL ?= mkcl
|
2017-08-23 21:15:05 +03:00
|
|
|
|
2017-08-24 16:28:17 +03:00
|
|
|
# TODO: In theory cl-launch should be able to build standalone executable using
|
|
|
|
# MKCL unfortunately the executable crashes on startup
|
2017-08-23 21:15:05 +03:00
|
|
|
STANDALONE_EXE = sbcl clisp ccl ecl cmucl
|
|
|
|
|
2016-11-15 21:54:49 +03:00
|
|
|
ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
|
2016-11-22 14:55:16 +03:00
|
|
|
SOURCES_LISP := src/env.lisp src/core.lisp src/stepA_mal.lisp
|
|
|
|
SOURCES := src/utils.lisp src/types.lisp src/reader.lisp src/printer.lisp $(SOURCES_LISP)
|
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-22 14:55:16 +03:00
|
|
|
step% : src/step%.lisp src/utils.lisp src/types.lisp src/env.lisp src/printer.lisp src/reader.lisp src/core.lisp hist/%_impl
|
2017-08-23 21:15:05 +03:00
|
|
|
|
|
|
|
ifeq ($(LISP),clisp)
|
|
|
|
@echo "=============================================================="
|
|
|
|
@echo "WARNING: This build might fail since GNU Clisp does not have bundled version of asdf (yet)"
|
|
|
|
@echo "Please do something like below to make it work"
|
|
|
|
@echo "(mkdir -p ~/common-lisp/ && cd ~/common-lisp && git clone -b release https://gitlab.common-lisp.net/asdf/asdf.git && cd asdf && make)"
|
|
|
|
@echo "=============================================================="
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ($(filter $(LISP),$(STANDALONE_EXE)),)
|
|
|
|
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'
|
|
|
|
else ifeq ($(LISP),abcl)
|
2016-11-20 22:41:55 +03:00
|
|
|
echo -n '#!/bin/sh\ncd `dirname $$0` ; $(ABCL) --noinform --noinit --nosystem --load run-abcl.lisp -- $@ $$@' > $@
|
|
|
|
chmod +x $@
|
2017-08-24 16:28:17 +03:00
|
|
|
else ifeq ($(LISP),mkcl)
|
|
|
|
$(MKCL) -eval '(progn (require "asdf") (push *default-pathname-defaults* asdf:*central-registry*) (asdf:load-system "$@") (quit))'
|
|
|
|
echo -n '#!/bin/sh\ncd `dirname $$0` ; $(MKCL) -q -load run-mkcl.lisp -- $@ $$@' > $@
|
|
|
|
chmod +x $@
|
|
|
|
else ifeq ($(LISP),allegro)
|
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'
|
2017-08-24 16:28:17 +03:00
|
|
|
else
|
|
|
|
@echo "Unsupported Lisp implementation $(LISP)"
|
|
|
|
@exit 1
|
2016-11-20 22:41:55 +03:00
|
|
|
endif
|
2016-11-02 13:10:01 +03:00
|
|
|
|
|
|
|
clean:
|
2017-08-23 21:19:52 +03:00
|
|
|
find . -maxdepth 1 -name 'step*' -executable -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]"
|