forked from jserv/full-stack-hello
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
52 lines (37 loc) · 837 Bytes
/
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
EXEC = as_exec
CC ?= gcc
CFLAGS = -Wall -std=gnu99 -g
.PHONY: all
all: $(EXEC)
OBJS = \
vm.o \
as.o \
opcode.o \
driver.o \
elf.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)