lisp-take-1/makefile
Zander Thannhauser 44fb99b663 .
- macros work in the new way (the "right" way?)
- added test.py script, with basic test cases. Need to fill out new test
  builtins.
2024-12-02 19:33:23 -06:00

80 lines
1.4 KiB
Makefile

# vim: noexpandtab tabstop=4 :
buildtype ?= release
optionset = buildtypes/${buildtype}.txt
prefix = bin/${buildtype}-buildtype
default: ${prefix}/12
on_error ?= do_nothing
ifeq ($(on_error), do_nothing)
on_error_command =
else ifeq ($(on_error), open_editor)
on_error_command += || ($$EDITOR $<; false)
else
$(error "invalid on_error option!");
endif
.PRECIOUS: %/
%/:
@mkdir -p $@
srclist.mk:
find -name '*.c' -! -path '*/junk/*' | sed "s/^/srcs += /" | sort -V > ${@}
include srclist.mk
${prefix}/%.o ${prefix}/%.d: %.c ${optionset} | ${prefix}/%/
@echo "compiling (${buildtype}) ${<} ..."
@gcc -c @${optionset} $< -MD -MF ${prefix}/${*}.d -o ${prefix}/${*}.o $(on_error_command)
objs = $(patsubst %.c,${prefix}/%.o,${srcs})
${prefix}/12: ${objs} ${optionset} | ${prefix}/${1}/
@echo "linking (${buildtype}) ${1}"
@gcc @${optionset} ${objs} -o ${@}
#args += --garbage-collection-minimum 100B
#args += --garbage-collection-run-every 100B
#args += --garbage-collection-process-limit 200B
#args += --garbage-collection-dotout /tmp/
#args += --macro-expansion-dotout /tmp/
#args += --evaluation-dotout /tmp/
args += --verbose
args += ./examples/sandbox.txt
run: ${prefix}/12
$< ${args}
valrun: ${prefix}/12
valgrind --exit-on-first-error=yes --error-exitcode=1 -- $< ${args}
valrun-leak: ${prefix}/12
valgrind --exit-on-first-error=yes --error-exitcode=1 --leak-check=full -- $< ${args}
include $(patsubst %.c,${prefix}/%.d,${srcs})