-
Notifications
You must be signed in to change notification settings - Fork 104
/
Makefile
231 lines (191 loc) · 7.37 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
# SubtitleOctopus.js - Makefile
# make - Build Dependencies and the SubtitleOctopus.js
BASE_DIR:=$(dir $(realpath $(firstword $(MAKEFILE_LIST))))
DIST_DIR:=$(BASE_DIR)dist/libraries
export LDFLAGS = -O3 -flto -s ENVIRONMENT=web,webview,worker -s NO_EXIT_RUNTIME=1 -s STRICT_JS=1
export CFLAGS = -O3 -flto -s USE_PTHREADS=0
export CXXFLAGS = $(CFLAGS)
export PKG_CONFIG_PATH = $(DIST_DIR)/lib/pkgconfig
export EM_PKG_CONFIG_PATH = $(PKG_CONFIG_PATH)
all: subtitleoctopus
subtitleoctopus: dist
.PHONY: all subtitleoctopus dist
include functions.mk
# FriBidi
build/lib/fribidi/configure: lib/fribidi $(wildcard $(BASE_DIR)build/patches/fribidi/*.patch)
$(call PREPARE_SRC_PATCHED,fribidi)
cd build/lib/fribidi && $(RECONF_AUTO)
$(DIST_DIR)/lib/libfribidi.a: build/lib/fribidi/configure
cd build/lib/fribidi && \
$(call CONFIGURE_AUTO) --disable-debug && \
$(JSO_MAKE) -C lib/ fribidi-unicode-version.h && \
$(JSO_MAKE) -C lib/ install && \
$(JSO_MAKE) install-pkgconfigDATA
# Expat
build/lib/expat/configured: lib/expat
$(call PREPARE_SRC_VPATH,expat)
touch build/lib/expat/configured
$(DIST_DIR)/lib/libexpat.a: build/lib/expat/configured
cd build/lib/expat && \
$(call CONFIGURE_CMAKE,$(BASE_DIR)lib/expat/expat) \
-DEXPAT_BUILD_DOCS=off \
-DEXPAT_SHARED_LIBS=off \
-DEXPAT_BUILD_EXAMPLES=off \
-DEXPAT_BUILD_FUZZERS=off \
-DEXPAT_BUILD_TESTS=off \
-DEXPAT_BUILD_TOOLS=off \
&& \
$(JSO_MAKE) install
# Brotli
build/lib/brotli/configured: lib/brotli $(wildcard $(BASE_DIR)build/patches/brotli/*.patch)
$(call PREPARE_SRC_PATCHED,brotli)
touch build/lib/brotli/configured
$(DIST_DIR)/lib/libbrotlidec.a: $(DIST_DIR)/lib/libbrotlicommon.a
$(DIST_DIR)/lib/libbrotlicommon.a: build/lib/brotli/configured
cd build/lib/brotli && \
$(call CONFIGURE_CMAKE) && \
$(JSO_MAKE) install
# Normalise static lib names
cd $(DIST_DIR)/lib/ && \
for lib in *-static.a ; do mv "$$lib" "$${lib%-static.a}.a" ; done
# Freetype without Harfbuzz
build/lib/freetype/configure: lib/freetype $(wildcard $(BASE_DIR)build/patches/freetype/*.patch)
$(call PREPARE_SRC_PATCHED,freetype)
cd build/lib/freetype && $(RECONF_AUTO)
build/lib/freetype/build_hb/dist_hb/lib/libfreetype.a: $(DIST_DIR)/lib/libbrotlidec.a build/lib/freetype/configure
cd build/lib/freetype && \
mkdir -p build_hb && \
cd build_hb && \
$(call CONFIGURE_AUTO,..) \
--prefix="$$(pwd)/dist_hb" \
--with-brotli=yes \
--without-harfbuzz \
&& \
$(JSO_MAKE) install
# Harfbuzz
build/lib/harfbuzz/configure: lib/harfbuzz $(wildcard $(BASE_DIR)build/patches/harfbuzz/*.patch)
$(call PREPARE_SRC_PATCHED,harfbuzz)
cd build/lib/harfbuzz && $(RECONF_AUTO)
$(DIST_DIR)/lib/libharfbuzz.a: build/lib/freetype/build_hb/dist_hb/lib/libfreetype.a build/lib/harfbuzz/configure
cd build/lib/harfbuzz && \
EM_PKG_CONFIG_PATH=$(PKG_CONFIG_PATH):$(BASE_DIR)build/lib/freetype/build_hb/dist_hb/lib/pkgconfig \
CFLAGS="-DHB_NO_MT $(CFLAGS)" \
CXXFLAGS="-DHB_NO_MT $(CFLAGS)" \
$(call CONFIGURE_AUTO) \
--with-freetype \
&& \
cd src && \
$(JSO_MAKE) install-libLTLIBRARIES install-pkgincludeHEADERS install-pkgconfigDATA
# Freetype with Harfbuzz
$(DIST_DIR)/lib/libfreetype.a: $(DIST_DIR)/lib/libharfbuzz.a $(DIST_DIR)/lib/libbrotlidec.a
cd build/lib/freetype && \
EM_PKG_CONFIG_PATH=$(PKG_CONFIG_PATH):$(BASE_DIR)build/lib/freetype/build_hb/dist_hb/lib/pkgconfig \
$(call CONFIGURE_AUTO) \
--with-brotli=yes \
--with-harfbuzz \
&& \
$(JSO_MAKE) install
# Fontconfig
build/lib/fontconfig/configure: lib/fontconfig $(wildcard $(BASE_DIR)build/patches/fontconfig/*.patch)
$(call PREPARE_SRC_PATCHED,fontconfig)
cd build/lib/fontconfig && $(RECONF_AUTO)
$(DIST_DIR)/lib/libfontconfig.a: $(DIST_DIR)/lib/libharfbuzz.a $(DIST_DIR)/lib/libexpat.a $(DIST_DIR)/lib/libfribidi.a $(DIST_DIR)/lib/libfreetype.a build/lib/fontconfig/configure
cd build/lib/fontconfig && \
$(call CONFIGURE_AUTO) \
--disable-docs \
--with-default-fonts=/fonts \
&& \
$(JSO_MAKE) -C src/ install && \
$(JSO_MAKE) -C fontconfig/ install && \
$(JSO_MAKE) install-pkgconfigDATA
# libass
build/lib/libass/configured: lib/libass
cd lib/libass && $(RECONF_AUTO)
$(call PREPARE_SRC_VPATH,libass)
touch build/lib/libass/configured
$(DIST_DIR)/lib/libass.a: $(DIST_DIR)/lib/libfontconfig.a $(DIST_DIR)/lib/libharfbuzz.a $(DIST_DIR)/lib/libexpat.a $(DIST_DIR)/lib/libfribidi.a $(DIST_DIR)/lib/libfreetype.a $(DIST_DIR)/lib/libbrotlidec.a build/lib/libass/configured
cd build/lib/libass && \
$(call CONFIGURE_AUTO,../../../lib/libass) \
--disable-asm \
--enable-fontconfig \
&& \
$(JSO_MAKE) install
# SubtitleOctopus.js
OCTP_DEPS = \
$(DIST_DIR)/lib/libfribidi.a \
$(DIST_DIR)/lib/libbrotlicommon.a \
$(DIST_DIR)/lib/libbrotlidec.a \
$(DIST_DIR)/lib/libfreetype.a \
$(DIST_DIR)/lib/libexpat.a \
$(DIST_DIR)/lib/libharfbuzz.a \
$(DIST_DIR)/lib/libfontconfig.a \
$(DIST_DIR)/lib/libass.a
src/subtitles-octopus-worker.bc: $(OCTP_DEPS) all-src
.PHONY: all-src
all-src:
$(MAKE) -C src all
# Dist Files
EMCC_COMMON_ARGS = \
$(LDFLAGS) \
-s AUTO_NATIVE_LIBRARIES=0 \
-s EXPORTED_FUNCTIONS="['_main', '_malloc']" \
-s DEFAULT_LIBRARY_FUNCS_TO_INCLUDE="['\$$Browser']" \
-s EXPORTED_RUNTIME_METHODS="['ccall', 'cwrap', 'getValue', 'FS_createPreloadedFile', 'FS_createPath']" \
--embed-file assets/fonts.conf \
-s ALLOW_MEMORY_GROWTH=1 \
-s NO_FILESYSTEM=0 \
--memory-init-file=0 \
--no-heap-copy \
-o $@
dist: src/subtitles-octopus-worker.bc dist/js/subtitles-octopus-worker.js dist/js/subtitles-octopus-worker-legacy.js dist/js/subtitles-octopus.js dist/js/COPYRIGHT dist/js/default.woff2
dist/js/subtitles-octopus-worker.js: src/subtitles-octopus-worker.bc src/pre-worker.js src/SubOctpInterface.js src/post-worker.js
mkdir -p dist/js
emcc src/subtitles-octopus-worker.bc $(OCTP_DEPS) \
--pre-js src/pre-worker.js \
--post-js src/SubOctpInterface.js \
--post-js src/post-worker.js \
-s WASM=1 \
-s EVAL_CTORS=1 \
$(EMCC_COMMON_ARGS)
dist/js/subtitles-octopus-worker-legacy.js: src/subtitles-octopus-worker.bc src/polyfill.js src/pre-worker.js src/SubOctpInterface.js src/post-worker.js
mkdir -p dist/js
emcc src/subtitles-octopus-worker.bc $(OCTP_DEPS) \
--pre-js src/polyfill.js \
--pre-js src/pre-worker.js \
--post-js src/SubOctpInterface.js \
--post-js src/post-worker.js \
-s WASM=0 \
-s LEGACY_VM_SUPPORT=1 \
-s MIN_CHROME_VERSION=27 \
-s MIN_SAFARI_VERSION=60005 \
--closure=0 \
$(EMCC_COMMON_ARGS)
dist/js/subtitles-octopus.js: dist/license/all src/subtitles-octopus.js
mkdir -p dist/js
awk '1 {print "// "$$0}' dist/license/all | cat - src/subtitles-octopus.js > $@
dist/license/all:
@#FIXME: allow -j in toplevel Makefile and reintegrate licence extraction into this file
make -j "$$(nproc)" -f Makefile_licence all
dist/js/COPYRIGHT: dist/license/all
cp "$<" "$@"
dist/js/default.woff2:
cp assets/default.woff2 "$@"
# Clean Tasks
clean: clean-dist clean-libs clean-octopus
clean-dist:
rm -frv dist/libraries/*
rm -frv dist/js/*
rm -frv dist/license/*
clean-libs:
rm -frv dist/libraries build/lib
clean-octopus:
cd src && git clean -fdX
git-checkout:
git submodule sync --recursive && \
git submodule update --init --recursive
SUBMODULES := brotli expat fontconfig freetype fribidi harfbuzz libass
git-smreset: $(addprefix git-, $(SUBMODULES))
$(foreach subm, $(SUBMODULES), $(eval $(call TR_GIT_SM_RESET,$(subm))))
server: # Node http server npm i -g http-server
http-server
.PHONY: clean clean-dist clean-libs clean-octopus git-checkout git-smreset server