-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
78 lines (56 loc) · 1.69 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
CC := emcc
CXX := emcc
CXXFLAGS += -std=c++11 -Oz
OUTDIR := out
WOFF2_DIR := woff2
OBJDIR := $(OUTDIR)/obj
DISTDIR := dist/
.DEFAULT_GOAL := wasm
# brotli
BROTLI_DIR := $(WOFF2_DIR)/brotli
BROTLI_LIB_A := $(BROTLI_DIR)/libbrotli.a
$(BROTLI_LIB_A):
CC=$(CC) $(MAKE) -C $(BROTLI_DIR) lib
# woff2
WOFF2_SRC_DIR = $(WOFF2_DIR)/src
WOFF2_SRC_FILES := font.cc \
glyph.cc \
normalize.cc \
table_tags.cc \
transform.cc \
variable_length.cc \
woff2_common.cc \
woff2_dec.cc \
woff2_enc.cc \
woff2_out.cc
WOFF2_SRCS := $(addprefix $(WOFF2_SRC_DIR)/, $(WOFF2_SRC_FILES))
WOFF2_OBJS := $(addprefix $(OBJDIR)/, $(notdir $(WOFF2_SRCS:%.cc=%.o)))
WOFF2_DEPS := $(WOFF2_OBJS:%.o=%.d)
WOFF2_LIB_A := $(OBJDIR)/libwoff2.a
-include $(WOFF2_DEPS)
$(WOFF2_LIB_A): dirs $(WOFF2_OBJS)
emar crs $(WOFF2_LIB_A) $(WOFF2_OBJS)
$(OBJDIR)/%.o: $(WOFF2_DIR)/src/%.cc
emcc -c -MMD $(CXXFLAGS) -I$(BROTLI_DIR)/c/include -I$(WOFF2_DIR)/include -o $@ $<
# wasm
FFI_JS := $(DISTDIR)/ffi.js
FFI_OBJS := $(FFI_SRCS:%.cc=%.o)
wasm: $(WOFF2_LIB_A) $(BROTLI_LIB_A) ffi.cc
emcc $(CXXFLAGS) -I$(WOFF2_DIR)/include ffi.cc -o $(DISTDIR)/ffi.js $(WOFF2_LIB_A) $(BROTLI_LIB_A) \
-s WASM=1 \
-s ALLOW_MEMORY_GROWTH=1 \
-s MODULARIZE=1 \
-s EXPORT_NAME='createModule' \
-s EXPORTED_FUNCTIONS='["_malloc", "_free", "_get_max_compressed_size", "_ttf_to_woff2", "_get_uncompressed_size", "_woff2_to_ttf"]' \
-s EXPORTED_RUNTIME_METHODS='["ccall", "cwrap"]' \
-s ENVIRONMENT='web,worker' \
-s SINGLE_FILE=0
$(OBJDIR)/%.o: %.cc
emcc -c -MMD $(CXXFLAGS) -I$(BROTLI_DIR)/c/include -I$(WOFF2_DIR)/include -o $@ $<
# others
.PHONY: clean
dirs:
@mkdir -p $(OBJDIR)
clean:
$(MAKE) -C $(BROTLI_DIR) clean
@rm -rf $(OUTDIR)