forked from zeux/meshoptimizer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
62 lines (44 loc) · 1.11 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
.SUFFIXES:
MAKEFLAGS+=-r
config=release
files=demo/bunny.obj
BUILD=build/$(config)
SOURCES=$(wildcard src/*.cpp demo/*.c demo/*.cpp)
OBJECTS=$(SOURCES:%=$(BUILD)/%.o)
EXECUTABLE=$(BUILD)/meshoptimizer
CFLAGS=-g -Wall -Wextra -Werror -std=c89
CXXFLAGS=-g -Wall -Wextra -Wno-missing-field-initializers -Werror -std=c++98
LDFLAGS=
ifeq ($(config),release)
CXXFLAGS+=-O3
endif
ifeq ($(config),coverage)
CXXFLAGS+=-coverage
LDFLAGS+=-coverage
endif
ifeq ($(config),sanitize)
CXXFLAGS+=-fsanitize=address,undefined
LDFLAGS+=-fsanitize=address,undefined
endif
ifeq ($(config),analyze)
CXXFLAGS+=--analyze
endif
all: $(EXECUTABLE)
test: $(EXECUTABLE)
$(EXECUTABLE) $(files)
dev: $(EXECUTABLE)
$(EXECUTABLE) -d $(files:demo/bunny.obj=data/kitten.obj data/nyra.obj data/zeuxcg.obj)
format:
clang-format -i $(SOURCES)
$(EXECUTABLE): $(OBJECTS)
$(CXX) $(OBJECTS) $(LDFLAGS) -o $@
$(BUILD)/%.cpp.o: %.cpp
@mkdir -p $(dir $@)
$(CXX) $< $(CXXFLAGS) -c -MMD -MP -o $@
$(BUILD)/%.c.o: %.c
@mkdir -p $(dir $@)
$(CC) $< $(CFLAGS) -c -MMD -MP -o $@
-include $(OBJECTS:.o=.d)
clean:
rm -rf $(BUILD)
.PHONY: all clean format