-
Notifications
You must be signed in to change notification settings - Fork 3
/
makefile
106 lines (78 loc) · 2.93 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
106
# This is a makefile for building the emulator on OSX.
#
# make targets:
#
# make -- shorthand for "make debug"
# make debug -- non-optimized wangemu build, and generate tags
# make opt -- optimized wangemu build, and generate tags
# make tags -- make ctags index from files in src/
# make clean -- remove all build products
# make release -- create a "release" directory containing the app bundle and support files
# make dmg -- package the release files into a .dmg disk image
.PHONY: debug opt tags clean release dmg
# Add .d to Make's recognized suffixes.
.SUFFIXES: .c .cpp .mm .d .o
# don't create dependency files for these targets
NODEPS := clean tags
# Find all the source files in the src/ directory
CPP_SOURCES := $(shell find src -name "*.cpp")
C_SOURCES := $(shell find src -name "*.c")
MM_SOURCES := $(shell find src -name "*.mm")
H_SOURCES := $(shell find src -name "*.h")
# These are the dependency files, which make will clean up after it creates them
DEPFILES := $(patsubst %.cpp,%.d,$(CPP_SOURCES)) \
$(patsubst %.c,%.d,$(C_SOURCES)) \
$(patsubst %.mm,%.d,$(MM_SOURCES))
OBJFILES := $(patsubst src/%.cpp,obj/%.o,$(CPP_SOURCES)) \
$(patsubst src/%.c,obj/%.o,$(C_SOURCES)) \
$(patsubst src/%.mm,obj/%.o,$(MM_SOURCES))
# debug build
debug: OPTFLAGS := -g -O0
debug: wangemu tags
# optimized build
opt: OPTFLAGS := -O2
opt: wangemu tags
CXX := `wx-config --cxx`
CXXFLAGS := `wx-config --cxxflags` -fno-common
CXXWARNINGS := -Wall -Wextra -Wshadow -Wformat -Wundef -Wstrict-aliasing=1 \
-Wno-deprecated-declarations \
-Wno-ctor-dtor-privacy -Woverloaded-virtual
LDFLAGS := `wx-config --libs`
# don't create dependencies when we're cleaning, for instance
ifeq (0, $(words $(findstring $(MAKECMDGOALS), $(NODEPS))))
-include $(DEPFILES)
endif
# ===== create the dependency files =====
src/%.d: src/%.cpp
$(CXX) $(CXXFLAGS) -MM -MT '$(patsubst src/%.cpp,obj/%.o,$<)' $< -MF $@
src/%.d: src/%.c
$(CXX) $(CXXFLAGS) -MM -MT '$(patsubst src/%.c,obj/%.o,$<)' $< -MF $@
src/%.d: src/%.mm
$(CXX) $(CXXFLAGS) -MM -MT '$(patsubst src/%.mm,obj/%.o,$<)' $< -MF $@
# ===== build the .o files =====
obj/%.o: src/%.cpp src/%.d
@mkdir -p $(dir $@)
$(CXX) $(OPTFLAGS) $(CXXFLAGS) $(CXXWARNINGS) -o $@ -c $<
obj/%.o: src/%.c src/%.d
@mkdir -p $(dir $@)
$(CXX) $(OPTFLAGS) $(CXXFLAGS) -o $@ -c $<
obj/%.o: src/%.mm src/%.d
@mkdir -p $(dir $@)
$(CXX) $(OPTFLAGS) $(CXXFLAGS) $(CXXWARNINGS) -o $@ -c $<
# ==== link step ====
wangemu: $(OBJFILES)
$(CXX) $(LDFLAGS) $(OBJFILES) -o wangemu
# ==== build ctags index file ====
tags: src/tags
src/tags: $(CPP_SOURCES) $(C_SOURCES) $(H_SOURCES)
(cd src; ctags *.h *.cpp *.c >& /dev/null)
# ===== build a release directory =====
release:
@./make_release
# ===== build the dmg disk image =====
dmg:
@./make_dmg
# ===== clean build products =====
clean:
rm -f src/*.d src/tags obj/*.o *.dmg
rm -rf release