jumpforth/Makefile

37 lines
961 B
Makefile

SHELL = /bin/bash
TARGET = jumpforth
SOURCES = $(TARGET).S
EXTRA_DEPS = startup.4th
all: $(TARGET)
$(TARGET): $(SOURCES) $(EXTRA_DEPS)
gcc -m32 -nostdlib -static -o $@ $(filter-out $(EXTRA_DEPS),$^)
clean: test-clean
$(RM) $(TARGET)
TEST_RESULTS := $(patsubst %.4th,%.act,$(wildcard test/*.4th))
.PHONY: test $(TEST_RESULTS)
test: $(TEST_RESULTS)
test-clean:
$(RM) $(TEST_RESULTS)
test-refresh: $(TEST_RESULTS)
@for act in $^; do \
exp="$${act%.act}.exp"; \
if ! diff -q "$$exp" "$$act" >/dev/null; then \
echo "Refreshing $$exp"; cp -- "$$act" "$$exp"; \
fi; \
done
.PHONY: $(TEST_RESULTS)
$(TEST_RESULTS): %.act: %.4th $(TARGET)
@printf '%s … ' $(notdir $<) && \
{ ./$(TARGET) < $< >& $@; echo exit-code: $$? >> $@; } && \
if [[ ! -e $(@:%.act=%.exp) ]]; then echo '(new)'; cp $@ $(@:%.act=%.exp); \
elif diff -q $(@:%.act=%.exp) $@ >/dev/null; then echo '✓'; \
else echo '✗'; diff -u $(@:%.act=%.exp) $@; :; fi