-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
108 lines (71 loc) · 3.16 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
107
CC = cc
LD = cc
EMSDK = /home/pudds/projects/third_party/emsdk
EMS_TOOLCHAIN = $(EMSDK)/emscripten/master/cmake/Modules/Platform/Emscripten.cmake
EMS_MODULE = $(EMSDK)/emscripten/master/cmake/Modules
ASSIMP_OPTS = -DASSIMP_NO_EXPORT=ON -DASSIMP_BUILD_TESTS=OFF
ASSIMP_OPTS := $(ASSIMP_OPTS) -DASSIMP_BUILD_ASSIMP_TOOLS=OFF
ASSIMP_OPTS := $(ASSIMP_OPTS) -DCMAKE_BUILD_TYPE=Release
ASSIMP_OPTS := $(ASSIMP_OPTS) -DASSIMP_BUILD_ZLIB=ON
ASSIMP_OPTS_EMS = $(ASSIMP_OPTS) -DBUILD_SHARED_LIBS=OFF
ASSIMP_OPTS_EMS := $(ASSIMP_OPTS_EMS) -DCMAKE_TOOLCHAIN_FILE="$(EMS_TOOLCHAIN)"
ASSIMP_OPTS_EMS := $(ASSIMP_OPTS_EMS) -DCMAKE_MODULE_PATH="$(EMS_MODULE)"
DIR = build
SRCS = assimp.c aiw.c
OBJS_REL = $(patsubst %.c, $(DIR)/%.o, $(SRCS))
OBJS_DEB = $(patsubst %.c, $(DIR)/%.debug.o, $(SRCS))
OBJS_EMS = $(patsubst %.c, $(DIR)/%.emscripten.o, $(SRCS))
DEPS_REL = assimp.candle/build/assimp_release/contrib/zlib/libzlibstatic.a
DEPS_EMS = assimp.candle/build/assimp_emscripten/lib/libassimp.a \
assimp.candle/build/assimp_emscripten/contrib/zlib/libzlibstatic.a
PLUGIN_SAUCES_REL = $(DIR)/libassimp.so
CFLAGS = -Iassimp/include -Wuninitialized $(PARENTCFLAGS)
CFLAGS_REL = $(CFLAGS) -I$(DIR)/assimp_release/include -O3
CFLAGS_DEB = $(CFLAGS) -I$(DIR)/assimp_release/include -g3
CFLAGS_EMS = $(CFLAGS) -I$(DIR)/assimp_emscripten/include
##############################################################################
all: init $(DIR)/assimp_release/bin/libassimp.so $(DIR)/libs
echo $(DIR)/assimp_release/bin/libassimp.so > $(DIR)/res
$(DIR)/libs: $(DIR)/export.a
echo assimp.candle/$< $(DEPS_REL) > $@
$(DIR)/export.a: $(OBJS_REL)
$(AR) rs $@ $(OBJS_REL)
$(DIR)/%.o: %.c
$(CC) -o $@ -c $< $(CFLAGS_REL)
##############################################################################
$(DIR)/assimp_emscripten/code/libassimp.a:
cmake -B $(DIR)/assimp_emscripten assimp $(ASSIMP_OPTS_EMS)
cmake --build $(DIR)/assimp_emscripten
$(DIR)/assimp_release/bin/libassimp.so:
cmake -B $(DIR)/assimp_release assimp $(ASSIMP_OPTS)
cmake --build $(DIR)/assimp_release
##############################################################################
debug: init $(DIR)/assimp_release/bin/libassimp.so $(DIR)/libs_debug
echo $(DIR)/assimp_release/bin/libassimp.so > $(DIR)/res
$(DIR)/libs_debug: $(DIR)/export_debug.a
echo assimp.candle/$< $(DEPS_REL) > $@
$(DIR)/export_debug.a: $(OBJS_DEB)
$(AR) rs $@ $(OBJS_DEB)
$(DIR)/%.debug.o: %.c
$(CC) -o $@ -c $< $(CFLAGS_DEB)
##############################################################################
emscripten: init $(DIR)/assimp_emscripten/code/libassimp.a $(DIR)/libs_emscripten
echo "" > $(DIR)/res
$(DIR)/libs_emscripten: $(DIR)/export_emscripten.a
echo assimp.candle/$< $(DEPS_EMS) > $@
$(DIR)/export_emscripten.a: $(OBJS_EMS)
emar rs $@ $(OBJS_EMS)
$(DIR)/%.emscripten.o: %.c
emcc -o $@ -c $< $(CFLAGS_EMS)
##############################################################################
init:
mkdir -p $(DIR)
rm -f $(DIR)/res
rm -f $(DIR)/libs
rm -f $(DIR)/libs_debug
rm -f $(DIR)/libs_emscripten
##############################################################################
clean:
-cd $(DIR) && ls | grep -v assimp_release | xargs rm -r
# vim:ft=make
#