-
Notifications
You must be signed in to change notification settings - Fork 50
/
Makefile
64 lines (47 loc) · 1.19 KB
/
Makefile
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
EXEC = as_exec
CC ?= gcc
CFLAGS = -Wall -std=gnu99 -g
# For optimized gotos this speeds things up:
# care must be taken that the compiler doesn't try to "optimize" the indirect
# jumps by sharing them between all opcodes. Such optimizations can be disabled
# on gcc by using the -fno-crossjumping flag.
CFLAGS += -fno-crossjumping
GIT_HOOKS := .git/hooks/applied
.PHONY: all
all: $(GIT_HOOKS) $(EXEC)
$(GIT_HOOKS):
@scripts/install-git-hooks
@echo
OBJS = \
vm.o \
as.o \
opcode.o \
driver.o \
elf.o \
hash.o
deps := $(OBJS:%.o=.%.o.d)
$(EXEC): $(OBJS)
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
%.o: %.c opcode.h
$(CC) $(CFLAGS) -c -o $@ -MMD -MF [email protected] $<
TEST_SRCS = $(wildcard tests/*.s)
TEST_DONE = $(TEST_SRCS:.s=.done)
PASS_COLOR = \e[32;01m
NO_COLOR = \e[0m
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
PRINTF = printf
else
PRINTF = env printf
endif
tests/%.done: tests/%.s
@./$(EXEC) $< && $(PRINTF) "*** $< *** $(PASS_COLOR)[ Verified ]$(NO_COLOR)\n"
check: $(EXEC) $(TEST_DONE)
@$(RM) $(TEST_DONE)
test: $(EXEC)
@python tests/runner.py
clean:
$(RM) $(EXEC) $(OBJS) $(deps) opcode.h
opcode.h: scripts/gen_opcode.py opcode.def
@python scripts/gen_opcode.py $@
-include $(deps)