36 lines
725 B
Makefile
36 lines
725 B
Makefile
CFLAGS ?= -Wall -g
|
|
GDBRUN = gdb --batch --ex run --ex bt --ex q --args
|
|
BUILD_TARGETS = $(foreach ex,$(wildcard ex*.c),$(subst .c,,$(ex)))
|
|
|
|
.PHONY: all
|
|
all: build test
|
|
|
|
.PHONY: echo
|
|
echo:
|
|
@echo BUILD_TARGETS=$(BUILD_TARGETS)
|
|
|
|
.PHONY: clean
|
|
clean:
|
|
rm -f $(BUILD_TARGETS)
|
|
|
|
.PHONY: build
|
|
build: $(BUILD_TARGETS)
|
|
|
|
.PHONY: gtest
|
|
gtest:
|
|
@$(foreach bt, $(BUILD_TARGETS), make .gtest.$(bt) &&) \
|
|
printf '\ngYAY\n'
|
|
|
|
.gtest.%:
|
|
@test_argv=$$(cat .$*.argv 2>/dev/null || echo) && \
|
|
printf '\n==> %s\n' "$*" && $(GDBRUN) ./$*
|
|
|
|
.PHONY: test
|
|
test:
|
|
@$(foreach bt, $(BUILD_TARGETS), make .test.$(bt) &&) \
|
|
printf '\nYAY\n'
|
|
|
|
.test.%:
|
|
@test_argv=$$(cat .$*.argv 2>/dev/null || echo) && \
|
|
printf '\n==> %s\n' "$*" && ./$* $$test_argv
|