forked from zeux/meshoptimizer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
96 lines (68 loc) · 2.57 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
.SUFFIXES:
MAKEFLAGS+=-r
config=debug
files=demo/pirate.obj
BUILD=build/$(config)
LIBRARY_SOURCES=$(wildcard src/*.cpp)
LIBRARY_OBJECTS=$(LIBRARY_SOURCES:%=$(BUILD)/%.o)
DEMO_SOURCES=$(wildcard demo/*.c demo/*.cpp) tools/objparser.cpp
DEMO_OBJECTS=$(DEMO_SOURCES:%=$(BUILD)/%.o)
ENCODER_SOURCES=tools/meshencoder.cpp tools/objparser.cpp
ENCODER_OBJECTS=$(ENCODER_SOURCES:%=$(BUILD)/%.o)
OBJECTS=$(LIBRARY_OBJECTS) $(DEMO_OBJECTS) $(ENCODER_OBJECTS)
LIBRARY=$(BUILD)/libmeshoptimizer.a
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),iphone)
IPHONESDK=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk
CFLAGS+=-arch armv7 -arch arm64 -isysroot $(IPHONESDK)
CXXFLAGS+=-arch armv7 -arch arm64 -isysroot $(IPHONESDK) -stdlib=libc++
LDFLAGS+=-arch armv7 -arch arm64 -L $(IPHONESDK)/usr/lib -mios-version-min=7.0
endif
ifeq ($(config),trace)
CXXFLAGS+=-DTRACE=2
endif
ifeq ($(config),release)
CXXFLAGS+=-O3 -DNDEBUG
endif
ifeq ($(config),coverage)
CXXFLAGS+=-coverage
LDFLAGS+=-coverage
endif
ifeq ($(config),sanitize)
CXXFLAGS+=-fsanitize=address,undefined -fno-sanitize-recover=all
LDFLAGS+=-fsanitize=address,undefined
endif
ifeq ($(config),analyze)
CXXFLAGS+=--analyze
endif
all: $(EXECUTABLE)
test: $(EXECUTABLE)
$(EXECUTABLE) $(files)
check: $(EXECUTABLE)
$(EXECUTABLE)
dev: $(EXECUTABLE)
$(EXECUTABLE) -d $(files)
format:
clang-format -i $(LIBRARY_SOURCES) $(DEMO_SOURCES)
meshencoder: $(ENCODER_OBJECTS) $(LIBRARY)
$(CXX) $^ $(LDFLAGS) -o $@
js/decoder.js: src/vertexcodec.cpp src/indexcodec.cpp js/decoder-post.js
emcc $(filter %.cpp,$^) -Os -DNDEBUG -s EXPORTED_FUNCTIONS='["_meshopt_decodeVertexBuffer", "_meshopt_decodeIndexBuffer", "_malloc", "_free"]' -s ALLOW_MEMORY_GROWTH=1 -s MALLOC=emmalloc -s TOTAL_STACK=65536 -s TOTAL_MEMORY=1048576 -s MODULARIZE=1 -s SINGLE_FILE=1 -s EXPORT_NAME=MeshoptDecoder --closure 1 --post-js js/decoder-post.js -o $@
sed -i '1s;^;// This file is part of meshoptimizer library and is distributed under the terms of MIT License.\n// Copyright (C) 2016-2019, by Arseny Kapoulkine ([email protected]);' $@
$(EXECUTABLE): $(DEMO_OBJECTS) $(LIBRARY)
$(CXX) $^ $(LDFLAGS) -o $@
$(LIBRARY): $(LIBRARY_OBJECTS)
ar rcs $@ $^
$(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