89 lines
1.6 KiB
Makefile
89 lines
1.6 KiB
Makefile
|
|
# vim: noexpandtab tabstop=4 :
|
|
|
|
buildtype ?= release
|
|
|
|
optionset = buildtypes/${buildtype}.txt
|
|
|
|
prefix = bin/${buildtype}-buildtype
|
|
|
|
default: ${prefix}/13
|
|
|
|
on_error ?= do_nothing
|
|
ifeq ($(on_error), do_nothing)
|
|
on_error_command =
|
|
else ifeq ($(on_error), open_editor)
|
|
on_error_command += || ($$EDITOR ${*}.c; false)
|
|
else
|
|
$(error "invalid on_error option!");
|
|
endif
|
|
|
|
.PRECIOUS: %/
|
|
|
|
%/:
|
|
@mkdir -p $@
|
|
|
|
srclist.mk:
|
|
@echo "searching for source files ..."
|
|
@find -name '*.c*' -! -path '*/bin/*' -! -path '*/junk/*' \
|
|
| sed 's/.cpp$$/.c/g;s/^/srcs += /g' \
|
|
| sort -Vu > ${@}
|
|
|
|
include srclist.mk
|
|
|
|
.PRECIOUS: %.c
|
|
|
|
%.c: %.cpp zog.py | bin/
|
|
@echo "preprocessing ${<} ..."
|
|
@./zog.py -i $< --snippet-directory=bin -o $@
|
|
|
|
${prefix}/%.o ${prefix}/%.d: %.c ${optionset} | ${prefix}/%/
|
|
@echo "compiling (${buildtype}) ${*}.c ..."
|
|
@gcc -c @${optionset} $< -MD -MF ${prefix}/${*}.d -o ${prefix}/${*}.o $(on_error_command)
|
|
|
|
objs = $(patsubst %.c,${prefix}/%.o,${srcs})
|
|
|
|
${prefix}/13: ${objs} ${optionset} | ${prefix}/
|
|
@echo "linking (${buildtype})"
|
|
@gcc @${optionset} ${objs} -o ${@} -lm
|
|
|
|
args += --echo
|
|
args += --color
|
|
|
|
#args += --no-init
|
|
|
|
args += --custom-init-path ./examples/init.txt
|
|
|
|
#args += -c '1'
|
|
|
|
#args += ./examples/sandbox.txt
|
|
|
|
args += --test-interactive-using-input-file ./examples/sandbox-interactive.txt
|
|
|
|
run: ${prefix}/13
|
|
$< ${args}
|
|
|
|
valrun: ${prefix}/13
|
|
valgrind --exit-on-first-error=yes --error-exitcode=1 -- $< ${args}
|
|
|
|
valrun-leak: ${prefix}/13
|
|
valgrind --exit-on-first-error=yes --error-exitcode=1 --leak-check=full -- $< ${args}
|
|
|
|
include $(patsubst %.c,${prefix}/%.d,${srcs})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|