2024-04-15 19:22:58 +00:00
|
|
|
CFLAGS ?= -Wall -g
|
2024-04-16 12:03:12 +00:00
|
|
|
GDBRUN = gdb --batch --ex run --ex bt --ex q --args
|
2024-04-19 12:14:39 +00:00
|
|
|
BUILD_TARGETS = $(foreach ex,$(wildcard ex*.c),$(subst .c,,$(ex)))
|
2024-04-15 19:22:58 +00:00
|
|
|
|
2024-04-15 23:59:15 +00:00
|
|
|
.PHONY: all
|
|
|
|
all: build test
|
2024-04-15 19:16:14 +00:00
|
|
|
|
2024-04-19 12:14:39 +00:00
|
|
|
.PHONY: echo
|
|
|
|
echo:
|
|
|
|
@echo BUILD_TARGETS=$(BUILD_TARGETS)
|
|
|
|
|
2024-04-15 23:59:15 +00:00
|
|
|
.PHONY: clean
|
2024-04-15 19:16:14 +00:00
|
|
|
clean:
|
2024-04-16 12:03:12 +00:00
|
|
|
rm -f $(BUILD_TARGETS)
|
2024-04-15 19:22:58 +00:00
|
|
|
|
2024-04-15 23:59:15 +00:00
|
|
|
.PHONY: build
|
2024-04-16 12:03:12 +00:00
|
|
|
build: $(BUILD_TARGETS)
|
|
|
|
|
|
|
|
.PHONY: gtest
|
|
|
|
gtest:
|
2024-04-19 12:14:39 +00:00
|
|
|
@$(foreach bt, $(BUILD_TARGETS), make .gtest.$(bt) &&) \
|
2024-04-17 12:22:20 +00:00
|
|
|
printf '\ngYAY\n'
|
2024-04-15 23:59:15 +00:00
|
|
|
|
2024-04-18 22:49:10 +00:00
|
|
|
.gtest.%:
|
2024-04-19 12:14:39 +00:00
|
|
|
@test_argv=$$(cat .$*.argv 2>/dev/null || echo) && \
|
2024-04-18 22:49:10 +00:00
|
|
|
printf '\n==> %s\n' "$*" && $(GDBRUN) ./$*
|
|
|
|
|
2024-04-15 23:59:15 +00:00
|
|
|
.PHONY: test
|
2024-04-15 19:22:58 +00:00
|
|
|
test:
|
2024-04-19 12:14:39 +00:00
|
|
|
@$(foreach bt, $(BUILD_TARGETS), make .test.$(bt) &&) \
|
2024-04-17 12:22:20 +00:00
|
|
|
printf '\nYAY\n'
|
2024-04-18 22:49:10 +00:00
|
|
|
|
|
|
|
.test.%:
|
2024-04-19 12:14:39 +00:00
|
|
|
@test_argv=$$(cat .$*.argv 2>/dev/null || echo) && \
|
|
|
|
printf '\n==> %s\n' "$*" && ./$* $$test_argv
|