# 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 $<; 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}/13: ${objs} ${optionset} | ${prefix}/${1}/ @echo "linking (${buildtype}) ${1}" @gcc @${optionset} ${objs} -o ${@} -lm #args += --echo args += --echo-rainbow #args += --no-init args += --custom-init-path ./examples/init.txt #args += -c '1' args += ./examples/sandbox.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})