forked from VCVRack/Rack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
compile.mk
70 lines (52 loc) · 1.29 KB
/
compile.mk
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
ifdef VERSION
FLAGS += -DVERSION=$(VERSION)
endif
# Generate dependency files alongside the object files
FLAGS += -MMD
FLAGS += -g -w # avoid warning messages
# Optimization
FLAGS += -O3 -march=nocona -ffast-math -fno-finite-math-only
FLAGS += -Wall -Wextra -Wno-unused-parameter
ifneq ($(ARCH), mac)
CXXFLAGS += -Wsuggest-override
endif
CXXFLAGS += -std=c++11
ifeq ($(ARCH), lin)
FLAGS += -DARCH_LIN
endif
ifeq ($(ARCH), mac)
FLAGS += -DARCH_MAC
CXXFLAGS += -stdlib=libc++
LDFLAGS += -stdlib=libc++
MAC_SDK_FLAGS = -mmacosx-version-min=10.7
FLAGS += $(MAC_SDK_FLAGS)
LDFLAGS += $(MAC_SDK_FLAGS)
endif
ifeq ($(ARCH), win)
FLAGS += -DARCH_WIN
FLAGS += -D_USE_MATH_DEFINES
endif
OBJECTS += $(patsubst %, build/%.o, $(SOURCES))
DEPS = $(patsubst %, build/%.d, $(SOURCES))
#
# Tests
#
doctest: $(TEST_APP) $(OBJECTS)
$(CXX) $(FLAGS) $(CXXFLAGS) -o $@ $^ $(LDFLAGS)
-include $(DEPS)
# Final targets
$(TARGET): $(MAIN_APP) $(OBJECTS)
$(CXX) $(FLAGS) $(CXXFLAGS) -o $@ $^ $(LDFLAGS)
-include $(DEPS)
build/%.c.o: %.c
@mkdir -p $(@D)
$(CC) $(FLAGS) $(CFLAGS) -c -o $@ $<
build/%.cpp.o: %.cpp
@mkdir -p $(@D)
$(CXX) $(FLAGS) $(CXXFLAGS) -c -o $@ $<
build/%.cc.o: %.cc
@mkdir -p $(@D)
$(CXX) $(FLAGS) $(CXXFLAGS) -c -o $@ $<
build/%.m.o: %.m
@mkdir -p $(@D)
$(CC) $(FLAGS) $(CFLAGS) -c -o $@ $<