forked from NicolasFlamel1/SMAZ-WASM-Wrapper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
executable file
·44 lines (39 loc) · 1.79 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
# Library parameters
NAME = "SMAZ"
CC = "em++"
CFLAGS = -Wall -Wno-writable-strings -D NDEBUG -Oz -finput-charset=UTF-8 -fexec-charset=UTF-8 -funsigned-char -ffunction-sections -fdata-sections -I "./smaz-master/" -s MODULARIZE=1 --memory-init-file=0 -s ABORTING_MALLOC=0 -s ALLOW_MEMORY_GROWTH=1 --closure 1 -flto -fno-rtti -fno-exceptions -s NO_FILESYSTEM=1 -s DISABLE_EXCEPTION_CATCHING=1 -s EXPORTED_FUNCTIONS="['_malloc', '_free']" -s EXPORT_NAME="smaz"
LIBS =
SRCS = "./SMAZ-NPM-Package-master/main.cpp" "./smaz-master/smaz.c"
PROGRAM_NAME = $(subst $\",,$(NAME))
# Make WASM
wasm:
rm -rf "./dist"
mkdir "./dist"
$(CC) $(CFLAGS) -s WASM=1 -s ENVIRONMENT=web -o "./dist/$(PROGRAM_NAME).js" $(SRCS) $(LIBS)
cat "./main.js" >> "./dist/$(PROGRAM_NAME).js"
# Make asm.js
asmjs:
rm -rf "./dist"
mkdir "./dist"
$(CC) $(CFLAGS) -s WASM=0 -s ENVIRONMENT=web -o "./dist/$(PROGRAM_NAME).js" $(SRCS) $(LIBS)
cat "./main.js" >> "./dist/$(PROGRAM_NAME).js"
# Make npm
npm:
rm -rf "./dist"
mkdir "./dist"
$(CC) $(CFLAGS) -s WASM=1 -s BINARYEN_ASYNC_COMPILATION=0 -s SINGLE_FILE=1 -o "./dist/wasm.js" $(SRCS) $(LIBS)
$(CC) $(CFLAGS) -s WASM=0 -s BINARYEN_ASYNC_COMPILATION=0 -s SINGLE_FILE=1 -o "./dist/asm.js" $(SRCS) $(LIBS)
echo "\"use strict\"; const smaz = (typeof WebAssembly !== \"undefined\") ? require(\"./wasm.js\") : require(\"./asm.js\");" > "./dist/index.js"
cat "./main.js" >> "./dist/index.js"
# Make clean
clean:
rm -rf "./master.zip" "./smaz-master" "./SMAZ-NPM-Package-master" "./dist"
# Make dependencies
dependencies:
wget "https://github.com/antirez/smaz/archive/master.zip"
unzip "./master.zip"
rm "./master.zip"
wget "https://github.com/mwcproject/SMAZ-NPM-Package/archive/master.zip"
unzip "./master.zip"
rm "./master.zip"
patch "./smaz-master/smaz.c" < "./SMAZ-NPM-Package-master/smaz.c.diff"