-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
90 lines (70 loc) · 2.68 KB
/
Copy pathMakefile
File metadata and controls
90 lines (70 loc) · 2.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
ifeq ($(OS),Windows_NT)
EXE_EXT := .exe
else
EXE_EXT :=
endif
UCC:=$(shell readlink -f $(shell command -v ucc$(EXE_EXT)))
UCXT:=$(shell readlink -f $(shell command -v ucxt$(EXE_EXT)))
UCC_ARGS:=-c always -b -W no-goto -W no-integer-coercion -W no-shape-to-function
UCXT_ARGS:=-a -fs
VERBOSE ?= 0
PASS:=\e[1m\e[32m[✔️ PASS]\e[0m
FAIL:=\e[1m\e[31m[❌ FAIL]\e[0m
strip_suffix = $(patsubst %.orig,%, $(patsubst %.new,%, $(1)))
.PHONY: all all_clean clean ref fov ss check help
all: fov ss check
help:
@printf "make Build fov, ss, then run all checks (default).\n"
@printf "make fov Build usecode.fov.new/orig bins and .new.ucxt.\n"
@printf "make ss Build usecode.ss.new/orig bins and .new.ucxt.\n"
@printf "make check.fov Diff usecode.fov.new.ucxt against usecode.fov.ref.ucxt.\n"
@printf "make check.ss Diff usecode.ss.new.ucxt against usecode.ss.ref.ucxt.\n"
@printf "make check Run check.fov and check.ss.\n"
@printf "make ref Refresh reference ucxts from current .new.ucxt outputs.\n"
@printf "make clean Remove generated bins and .ucxt (keeps refs).\n"
@printf "make all_clean clean + remove ref ucxts.\n"
all_clean: clean
rm -f usecode.fov.ref.ucxt usecode.ss.ref.ucxt
clean:
rm -f usecode.fov.new.bin usecode.ss.new.bin
rm -f usecode.fov.new.ucxt usecode.ss.new.ucxt
rm -f usecode.fov.orig.bin usecode.ss.orig.bin
rm -f usecode.fov.orig.ucxt usecode.ss.orig.ucxt
fov: build.fov
ss: build.ss
ref: usecode.fov.ref.ucxt usecode.ss.ref.ucxt
check: build.fov build.ss check.fov check.ss
build.%: usecode.%.orig.ucxt usecode.%.new.bin usecode.%.orig.bin usecode.%.new.ucxt
@true
check.% : usecode.%.new.ucxt
@if [ ! -f usecode.$*.ref.ucxt ]; then \
printf "$(FAIL) Reference file usecode.$*.ref.ucxt is missing!\n"; \
exit 1; \
fi
@if [ ! -f usecode.$*.new.ucxt ]; then \
printf "$(FAIL) New file usecode.$*.new.ucxt is missing!\n"; \
exit 1; \
fi
@if [ "$(VERBOSE)" = "1" ]; then \
diff -u usecode.$*.ref.ucxt usecode.$*.new.ucxt; \
diff_status=$$?; \
else \
diff -u usecode.$*.ref.ucxt usecode.$*.new.ucxt > /dev/null 2>&1; \
diff_status=$$?; \
fi; \
if [ $$diff_status -eq 0 ]; then \
printf "$(PASS) ☥ '$*' usecode matches reference.\n"; \
else \
printf "$(FAIL) ☥ '$*' usecode differs from reference!\n"; \
exit 1; \
fi
usecode.%.ref.ucxt : usecode.%.new.ucxt
cp $< $@
usecode.%.new.bin : %/usecode.uc %/include/*.uc $(UCC)
rm -f usecode.$*.new.ucxt
$(UCC) $(UCC_ARGS) -I $* -o $@ $<
usecode.%.orig.bin : ucxt/usecode.%.ucxt $(UCC)
rm -f usecode.$*.orig.ucxt
$(UCC) $(UCC_ARGS) -I $* -o $@ $<
usecode.%.ucxt : usecode.%.bin $(UCXT)
$(UCXT) $(UCXT_ARGS) -$(call strip_suffix,$*) -i$< | sed 's/\r$$//' > $@