-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
104 lines (83 loc) · 2.06 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
DEBUG ?= 0
name := portable68k
objects := 68k 68kexception main results tester
INC := . lib/
INC_PARAM = $(foreach d, $(INC), -I$d)
ifeq ($(OS),Windows_NT)
platform := win
delete = del $(subst /,\,$1)
else
uname := $(shell uname -a)
ifeq ($(uname),)
platform := win
delete = del $(subst /,\,$1)
else ifneq ($(findstring Msys,$(uname)),)
platform := win
# Msys blocks win native del function
delete = rm -f $1
else ifneq ($(findstring MINGW,$(uname)),)
platform := win
delete = del $(subst /,\,$1)
else ifneq ($(findstring Windows,$(uname)),)
platform := win
delete = del $(subst /,\,$1)
else ifneq ($(findstring CYGWIN,$(uname)),)
platform := win
delete = del $(subst /,\,$1)
else ifneq ($(findstring Darwin,$(uname)),)
platform := osx
delete = rm -f $1
else
platform := x
delete = rm -f $1
endif
endif
ifeq ($(compiler),)
ifeq ($(platform),win)
compiler := gcc
else ifeq ($(platform),osx)
compiler := gcc-mp-4.7
else
compiler := gcc
endif
endif
c := $(compiler) -std=gnu99
cpp := $(subst cc,++,$(compiler)) -std=gnu++0x
flags := $(INC_PARAM)
link := -static -static-libgcc -static-libstdc++
ifeq ($(DEBUG), 0)
flags += -O3 -fomit-frame-pointer
link += -s
else
flags += -O0 -g -Wall
endif
compile = \
$(strip \
$(if $(filter %.c,$<), \
$(c) $(flags) $1 -c $< -o $@, \
$(if $(filter %.cpp,$<), \
$(cpp) $(flags) $1 -c $< -o $@ \
) \
) \
)
%.o: $<; $(call compile)
all: build;
obj/main.o: main.cpp
obj/results.o: results.cpp
obj/tester.o: tester.cpp
obj/step68k.o: step68k.cpp
obj/ctsim.o: ctsim.cpp
obj/68k.o: 68k/68k.cpp
obj/68kexception.o: 68k/exception.cpp
objects := $(patsubst %,obj/%.o,$(objects))
$(objects): | obj
obj:
mkdir obj
out:
mkdir out
build: $(objects) | out
$(cpp) -o out/$(name) $(objects) $(link)
$(cpp) -o out/step68k obj/step68k.o obj/68k.o obj/68kexception.o \
obj/results.o obj/ctsim.o $(link)
clean:
-@$(call delete,obj/*.o)