61 lines
1.1 KiB
Makefile
61 lines
1.1 KiB
Makefile
|
|
# vim: noexpandtab tabstop=4 :
|
|
|
|
buildtype ?= release
|
|
|
|
buildtype_options = buildtypes/${buildtype}.txt
|
|
|
|
prefix = bin/${buildtype}-buildtype
|
|
|
|
objs = $(patsubst %.c,${prefix}/%.o,$(srcs))
|
|
|
|
default: ${prefix}/pegrep
|
|
|
|
srclist.mk:
|
|
find -name '*.c' -! -path '*/junk/*' | sed 's/^/srcs += /' | sort -V > $@
|
|
|
|
include srclist.mk
|
|
|
|
.PRECIOUS: %/
|
|
|
|
%/:
|
|
@mkdir -p $@
|
|
|
|
${prefix}/pegrep: ${buildtype_options} ${objs} | ${prefix}/
|
|
@echo "${buildtype}: linking ${@} ..."
|
|
@gcc @${buildtype_options} ${objs} -o $@ -lm
|
|
|
|
${prefix}/%.o ${prefix}/%.d: %.c ${buildtype_options} | ${prefix}/%/
|
|
@echo "${buildtype}: compiling ${*}.c ..."
|
|
@gcc -c @${buildtype_options} $< -MD -MF ${prefix}/${*}.d -o ${prefix}/${*}.o # || (${EDITOR} $<; false)
|
|
|
|
# env += UBSAN_OPTIONS='halt_on_error=1,print_stacktrace=1'
|
|
|
|
run: ${prefix}/pegrep
|
|
${env} $< ${args}
|
|
|
|
gdbrun: ${prefix}/pegrep
|
|
gdb --args $< ${args}
|
|
|
|
valrun: ${prefix}/pegrep
|
|
valgrind --gen-suppressions=yes -- $< ${args}
|
|
|
|
valrun-leak: ${prefix}/pegrep
|
|
valgrind --leak-check=full --gen-suppressions=yes -- $< ${args}
|
|
|
|
include $(patsubst %.c,${prefix}/%.d,$(srcs))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|