-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
87 lines (71 loc) · 2.34 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
# To build for the web, do:
# source ${EMSDK}/emsdk_env.sh && make -j web
# Uncomment the following lines to enable address sanitizer.
# Also replace -O3 with -g for a meaningful call stack.
# ASAN_CFLAGS = -fsanitize=undefined -fsanitize=address -fstack-protector
# ASAN_LINKFLAGS = $(ASAN_CFLAGS) -lstdc++
BUILD_DIR = build
SRC_DIR = src
HOST_CC = /usr/bin/clang
WEB_CC = emcc
CFLAGS = -Iextern -Ibuild -Wall -O3 -std=c11 $(ASAN_CFLAGS)
CPPFLAGS = -Iextern -Ibuild -Wall -O3 -std=c++14 $(ASAN_CFLAGS)
MAC_LIBRARIES = \
-framework Foundation \
-framework Cocoa \
-framework AppKit \
-framework OpenGL \
-lobjc \
$(ASAN_LINKFLAGS)
EXTRA_DEPS = \
extern/par/par_streamlines.h \
$(BUILD_DIR)/shaders.h \
$(SRC_DIR)/demo.h \
$(SRC_DIR)/vmath.h
OBJECTS = \
$(BUILD_DIR)/demo_closed.o \
$(BUILD_DIR)/demo_curves.o \
$(BUILD_DIR)/demo_endcap.o \
$(BUILD_DIR)/demo_gradient.o \
$(BUILD_DIR)/demo_noisy.o \
$(BUILD_DIR)/demo_streamlines.o \
$(BUILD_DIR)/demo_wireframe.o \
$(BUILD_DIR)/common.o \
$(BUILD_DIR)/main_macos.o
JSOBJECTS = \
$(BUILD_DIR)/demo_closed.js.o \
$(BUILD_DIR)/demo_curves.js.o \
$(BUILD_DIR)/demo_endcap.js.o \
$(BUILD_DIR)/demo_gradient.js.o \
$(BUILD_DIR)/demo_noisy.js.o \
$(BUILD_DIR)/demo_streamlines.js.o \
$(BUILD_DIR)/demo_wireframe.js.o \
$(BUILD_DIR)/common.js.o \
$(BUILD_DIR)/main_web.js.o
EM_LINKARGS = \
-s MODULARIZE=1 \
-s 'EXPORT_NAME="Streamlines"' \
-s ERROR_ON_UNDEFINED_SYMBOLS=0 \
-s EXPORTED_FUNCTIONS='["_draw", "_main", "_start"]'
# Desktop target.
streamlines: $(OBJECTS)
$(HOST_CC) $(MAC_LIBRARIES) -o streamlines $^
# Emscripten target.
web: streamlines.js
streamlines.js: $(JSOBJECTS)
$(WEB_CC) -o streamlines.js ${EM_LINKARGS} ${JSOBJECTS} $(CFLAGS)
# Shader tool.
shader_tool: src/shader_tool.c extern/par/par_shaders.h
$(HOST_CC) $(MAC_LIBRARIES) -o shader_tool src/shader_tool.c $(CFLAGS)
clean:
rm -rf $(BUILD_DIR) shader_tool streamlines streamlines.js streamlines.wasm
$(BUILD_DIR):
mkdir -p $@
$(BUILD_DIR)/%.js.o: $(SRC_DIR)/%.c $(EXTRA_DEPS) | $(BUILD_DIR)
$(WEB_CC) -c -o $@ $< $(CFLAGS) $(EM_CARGS)
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c $(EXTRA_DEPS) | $(BUILD_DIR)
$(HOST_CC) -c -o $@ $< $(CFLAGS)
$(BUILD_DIR)/%.h: $(SRC_DIR)/%.glsl shader_tool | $(BUILD_DIR)
./shader_tool $< $@ SHADERS
$(BUILD_DIR)/main_macos.o: $(BUILD_DIR)
$(HOST_CC) -fobjc-arc -c $(CFLAGS) src/main_macos.m -o $@