-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMakefile
More file actions
78 lines (59 loc) · 1.57 KB
/
Copy pathMakefile
File metadata and controls
78 lines (59 loc) · 1.57 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
ARCH=$(shell uname -m)
ifeq ($(BITS),)
ifeq ($(ARCH),x86_64)
BITS=64
else ifeq ($(ARCH),i686)
BITS=32
else
$(error Unsupported architecture $(ARCH))
endif
endif
CXXFLAGS=-m$(BITS) -O2 -g -Wall -pthread $(if $(DEBUG),-DDEBUG=$(DEBUG)) -DHOST_BITS=$(BITS)
ASFLAGS=-m$(BITS) -g
LDFLAGS=-m$(BITS)
ifeq ($(shell uname),Darwin)
else
LDFLAGS += -pthread
endif
SRCS=bemu.cpp bcpu.cpp bdecode.cpp bt.cpp bclock.cpp bconsole.cpp
ASMSRCS=bt_helper_$(BITS).S
OBJECTS=$(SRCS:.cpp=.o) $(ASMSRCS:.S=.o)
GEN_H=instructions.h
DEPFILES=$(SRCS:%.cpp=.%.d)
BEMU=bemu
UASM=uasm/uasm
TESTS=sancheck litmus bench1 bench2 bench3 bench4 supervisor align qsort timer trap trap2 jmptab
TESTS_BIN=$(TESTS:%=tests/%.bin)
all: $(BEMU) $(TESTS_BIN) $(DEPFILES)
$(BEMU): $(OBJECTS)
$(CXX) -o $@ $(LDFLAGS) $(filter-out .config/%,$^)
$(UASM): CXXFLAGS += -w
$(UASM):
uasm: $(UASM)
$(OBJECTS): instructions.h .config/CXX .config/CPPFLAGS .config/CXXFLAGS
x86.h: instructions.h
$(BEMU): .config/LDFLAGS
$(ASMSRCS:.S=.o): .config/ASFLAGS
instructions.h: insts.pl
perl $< -cxx > $@
clean:
rm -f $(OBJECTS) $(BEMU)
rm -f tests/*.bin tests/*.map tests/*.sym
rm -f $(UASM) uasm/uasm.o $(GEN_H)
%.bin: %.uasm $(UASM)
$(UASM) $<
run-%: tests/%.bin
./bemu $(BEMUOPTS) $<
run-os: BEMUOPTS += -o clock,tty
run-lab8: BEMUOPTS += -o clock,tty
run-timer: BEMUOPTS += -o clock
test: $(TESTS_BIN) $(UASM) $(BEMU)
./run-tests.sh
TAGS: $(SRCS) $(ASMSRCS)
etags $^
tags: TAGS
check-syntax:
$(CC) $(CCFLAGS) -Wall -Wextra -fsyntax-only $(CHK_SOURCES)
.phony: CLEAN tags check-syntax uasm
include Makefile.lib
-include $(DEPFILES)