Debian Codegraph @

emscripten/Makefile

raw symbols SCIP
1 #
2 # Copyright (C) 2014-2017 Eitan Isaacson
3 # Copyright (C) 2016-2017 Alberto Pettarin
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, see: <http://www.gnu.org/licenses/>.
17 #
18
19 # NOTE: variables specific to espeak-ng + emscripten starts with "EM_"
20
21 # NOTE: set to 1 to debug or to speed emscripten up while developing.
22 # If the EM_DEBUG environment variable is set,
23 # the value specified here will be ignored.
24 EM_DEBUG ?= 0
25 ifneq ($(EM_DEBUG), 1)
26 CXXFLAGS+=-O3
27 endif
28
29
30
31 ###############################################################################
32 # WARNING: modify code below this line at your own risk!
33 ###############################################################################
34
35 # NOTE: sanity check
36 ifndef EMSCRIPTEN
37 $(error EMSCRIPTEN var not set. You must use emmake to run this Makefile!)
38 endif
39
40 # NOTE: in the emscripten virtual FS,
41 # this is the location of the eSpeak-ng data files,
42 # if we configure with "./configure --prefix=/usr"
43 EM_VIRTUAL_PATH_ESPEAKNG_DATA=/usr/share/espeak-ng-data
44
45 # NOTE: emmake will replace EMSCRIPTEN with the actual root directory
46 # of the emscripten tools inside the emscripten SDK directory
47 EM_WEBIDL_BINDER=python $(EMSCRIPTEN)/tools/webidl_binder.py
48 EM_FILE_PACKAGER=python $(EMSCRIPTEN)/tools/file_packager.py
49
50 # NOTE: libespeak-ng.so (Linux) or libespeak-ng.dylib (macOS) compiled to LLVM IR code
51 EM_LIBESPEAKNG_SO=$(wildcard ../src/.libs/libespeak-ng.so)
52 EM_LIBESPEAKNG_DYLIB=$(wildcard ../src/.libs/libespeak-ng.dylib)
53 ifneq ($(EM_LIBESPEAKNG_DYLIB),)
54 EM_LIBESPEAKNG=$(EM_LIBESPEAKNG_DYLIB)
55 else ifneq ($(EM_LIBESPEAKNG_SO),)
56 EM_LIBESPEAKNG=$(EM_LIBESPEAKNG_SO)
57 endif
58
59 # NOTE: glue code files
60 EM_GLUE_PREFIX=glue
61 EM_GLUE_IDL=espeakng_glue.idl
62 EM_GLUE_OBJ=espeakng_glue.o
63 EM_GLUE_CPP=espeakng_glue.cpp
64 EM_GLUE_AUTOGEN_CPP=glue.cpp
65 EM_GLUE_AUTOGEN_JS=glue.js
66
67 # NOTE: preload espeak-ng-data directory...
68 EM_DATA_DIR=../espeak-ng-data
69 # NOTE: ... but exclude these subdirectories/files
70 EM_EXCLUDE_DATA=../espeak-ng-data/mbrola_ph ../espeak-ng-data/phondata-manifest
71
72 # NOTE: pre/post JS files
73 EM_PRE_JS=pre.js
74 EM_POST_JS=post.js
75
76 # NOTE: output files
77 EM_ESPEAKNG_DATA_PACKAGE_JS=espeakng_data_package.js
78 EM_WORKER_DATA=js/espeakng.worker.data
79 EM_WORKER_JS=js/espeakng.worker.js
80 EM_PTHREAD_MAIN_JS=js/pthread-main.js
81
82 # NOTE: intermediate objects
83 EM_ALL_PRE_JS=$(EM_PRE_JS) $(EM_ESPEAKNG_DATA_PACKAGE_JS)
84 EM_ALL_POST_JS=$(EM_GLUE_AUTOGEN_JS) $(EM_POST_JS)
85
86 # NOTE: compile without async, i.e. with synchronous output
87 #
88 # ./emconfigure ./configure --prefix=/usr --without-async
89 # ./emmake make
90 CXXFLAGS+=-DESPEAK_DATA_PATH=\"$(EM_VIRTUAL_PATH_ESPEAKNG_DATA)\"
91 CXXFLAGS+=-I ./ -I ../ -I ../src/include/espeak-ng
92
93 # NOTE: so far, pthread is not supported in any browser
94 # except Firefox Nightly.
95 # If we want to enable pthread in the future,
96 # we must append "-s USE_PTHREADS=1" to CXXFLAGS
97 # and pass that to emconfigure and emmake.
98 # If enabled, js/pthread-main.js will be created as well.
99 #
100 #CXXFLAGS+=-s USE_PTHREADS=1
101
102 # NOTE: extra flags for emscripten
103 EM_CXXFLAGS=-s RESERVED_FUNCTION_POINTERS=2 --memory-init-file 0 -s FORCE_FILESYSTEM=1 -s WASM=0 -s ERROR_ON_UNDEFINED_SYMBOLS=0
104
105
106
107 ###############################################################################
108 # NOTE: actual targets
109 ###############################################################################
110
111 all: $(EM_WORKER_JS)
112
113 $(EM_WORKER_DATA):
114 $(EM_FILE_PACKAGER) $@ \
115 --js-output=$(EM_ESPEAKNG_DATA_PACKAGE_JS) \
116 --preload $(EM_DATA_DIR)@$(EM_VIRTUAL_PATH_ESPEAKNG_DATA) \
117 $(patsubst %,--exclude %,$(EM_EXCLUDE_DATA))
118
119 $(EM_ESPEAKNG_DATA_PACKAGE_JS): $(EM_WORKER_DATA)
120
121 $(EM_GLUE_AUTOGEN_CPP): $(EM_GLUE_IDL)
122 $(EM_WEBIDL_BINDER) $(EM_GLUE_IDL) $(EM_GLUE_PREFIX)
123
124 $(EM_GLUE_AUTOGEN_JS): $(EM_GLUE_AUTOGEN_CPP)
125
126 $(EM_GLUE_OBJ): $(EM_GLUE_CPP)
127
128 $(EM_WORKER_JS): $(EM_GLUE_AUTOGEN_CPP) $(EM_GLUE_OBJ) $(EM_ALL_PRE_JS) $(EM_ALL_POST_JS)
129 ifeq ($(EM_LIBESPEAKNG),)
130 $(error Unable to find ../src/.libs/libespeak-ng .so or .dylib. Aborting!)
131 endif
132 $(CXX) $(CXXFLAGS) \
133 $(EM_CXXFLAGS) \
134 $(EM_GLUE_OBJ) \
135 $(EM_LIBESPEAKNG) \
136 $(patsubst %,--pre-js %,$(EM_ALL_PRE_JS)) \
137 $(patsubst %,--post-js %,$(EM_ALL_POST_JS)) \
138 -o $@
139
140 clean-intermediate:
141 rm -f *.o *.out *.pkl $(EM_GLUE_AUTOGEN_CPP) $(EM_GLUE_AUTOGEN_JS) $(EM_ESPEAKNG_DATA_PACKAGE_JS)
142
143 clean: clean-intermediate
144 rm -f $(EM_WORKER_DATA) $(EM_WORKER_JS) $(EM_PTHREAD_MAIN_JS)
145
146 help:
147 echo "Available targets: all clean clean-intermediate help"
148