-
Notifications
You must be signed in to change notification settings - Fork 14
/
embuild.sh
executable file
·61 lines (51 loc) · 1.39 KB
/
embuild.sh
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
#!/usr/bin/env bash
#
# Wrapper script for emscripten build.
#
set -eu
make_wrapper_script() {
local toolname emtoolname path
toolname="$1"
emtoolname="$2"
path="$EM_CACHE/bin/asmjs-local-emscripten-$toolname"
(echo "#!/usr/bin/env bash"
echo "exec $emtoolname \"\$@\"") > "$path"
chmod a+rx "$path"
}
DEFAULT_CACHE_DIR=$(em-config CACHE)
export EM_CACHE=$PWD/emscripten_cache
export EM_FROZEN_CACHE=
export PKG_CONFIG_PATH=$EM_CACHE/pkg
export PATH="$EM_CACHE/bin:$PATH"
export CFLAGS="-fexceptions -sSUPPORT_LONGJMP=emscripten"
export LDFLAGS="-flto -sASYNCIFY -sENVIRONMENT=web -lidbfs.js -Wl,-u,ntohs $CFLAGS"
# The first time creating the cache directory, we make a copy of the
# one already installed on the system, to avoid having to rebuild all
# the system libraries.
if [ ! -e $EM_CACHE ]; then
cp -R "$DEFAULT_CACHE_DIR" "$EM_CACHE"
fi
mkdir -p $EM_CACHE/pkg $EM_CACHE/bin
echo "
prefix=/
exec_prefix=/
libdir=/
includedir=/
Name: sdl2
Description: sdl2
Version: 2.20.0
Requires:
Conflicts:
Libs: -sUSE_SDL=2
Cflags: -sUSE_SDL=2
" > $PKG_CONFIG_PATH/sdl2.pc
make_wrapper_script ar emar
make_wrapper_script gcc emcc
make_wrapper_script g++ em++
make_wrapper_script ld emcc
make_wrapper_script nm emnm
make_wrapper_script ranlib emranlib
if [ ! -e configure ] || [ ! -e Makefile ]; then
./autogen.sh --host=asmjs-local-emscripten
fi
exec make "$@"