-
Notifications
You must be signed in to change notification settings - Fork 1
/
makefile
105 lines (85 loc) · 1.97 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
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
TARGET := emu
BUILDDIR := build-$(TARGET)
# compiler flags, default libs to link against
COMPILEFLAGS := -g -O2 -Wall -W -Ilibihex -I.
CFLAGS :=
CXXFLAGS := -std=c++11 -Wno-c99-designator
ASMFLAGS :=
LDFLAGS :=
LDLIBS := libihex/libihex.a
UNAME := $(shell uname -s)
ARCH := $(shell uname -m)
# switch any platform specific stuff here
# ifeq ($(findstring CYGWIN,$(UNAME)),CYGWIN)
# ...
# endif
ifeq ($(UNAME),Darwin)
CC := clang
CPLUSPLUS := clang++
COMPILEFLAGS += -I/opt/local/include
LDFLAGS += -L/opt/local/lib
LDLIBS +=
OTOOL := otool
endif
ifeq ($(UNAME),Linux)
CC := clang
CPLUSPLUS := clang++
OBJDUMP := objdump
LDLIBS += -lpthread
endif
NOECHO ?= @
CFLAGS += $(COMPILEFLAGS)
CXXFLAGS += $(COMPILEFLAGS)
ASMFLAGS += $(COMPILEFLAGS)
OBJS := \
main.o \
console.o \
\
cpu/cpu.o \
dev/memory.o \
system/system.o
OBJS += \
cpu/cpu6800.o \
cpu/cpu6809.o \
cpu/cpuz80.o \
dev/mc6850.o \
dev/uart16550.o \
system/altair680.o \
system/system09.o \
system/system_kaypro.o
OBJS := $(addprefix $(BUILDDIR)/,$(OBJS))
DEPS := $(OBJS:.o=.d)
.PHONY: all
all: $(BUILDDIR)/$(TARGET) $(BUILDDIR)/$(TARGET).lst
$(BUILDDIR)/$(TARGET): $(OBJS) libihex/libihex.a
$(CPLUSPLUS) $(LDFLAGS) $(OBJS) -o $@ $(LDLIBS)
$(BUILDDIR)/$(TARGET).lst: $(BUILDDIR)/$(TARGET)
ifeq ($(UNAME),Darwin)
$(OTOOL) -Vt $< | c++filt > $@
else
$(OBJDUMP) -Cd $< > $@
endif
libihex/libihex.a:
$(MAKE) -C libihex
clean:
rm -f $(OBJS) $(DEPS) $(TARGET)
$(MAKE) -C libihex clean
spotless:
rm -rf build-*
# makes sure the target dir exists
MKDIR = if [ ! -d $(dir $@) ]; then mkdir -p $(dir $@); fi
$(BUILDDIR)/%.o: %.c
@$(MKDIR)
@echo compiling $<
$(NOECHO)$(CC) $(CFLAGS) -c $< -MD -MT $@ -MF $(@:%o=%d) -o $@
$(BUILDDIR)/%.o: %.cpp
@$(MKDIR)
@echo compiling $<
$(NOECHO)$(CPLUSPLUS) $(CXXFLAGS) -c $< -MD -MT $@ -MF $(@:%o=%d) -o $@
$(BUILDDIR)/%.o: %.S
@$(MKDIR)
@echo compiling $<
$(NOECHO)$(CC) $(ASMFLAGS) -c $< -MD -MT $@ -MF $(@:%o=%d) -o $@
ifeq ($(filter $(MAKECMDGOALS), clean), )
-include $(DEPS)
endif