-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
40 lines (32 loc) · 1.08 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
all: encoder.wasm
PKG_VERSION=`git describe --tags | cut -c2-`
vendor/lame/dist/lib/libmp3lame.a:
cd vendor/lame && \
emconfigure ./configure --prefix="$(shell pwd)/vendor/lame/dist" --disable-shared \
--disable-gtktest --disable-analyzer-hooks --disable-decoder --disable-frontend CFLAGS="-O2" && \
emmake make -j4 && \
emmake make install
clean: clean-lame clean-wasm clean-release
encoder.wasm: vendor/lame/dist/lib/libmp3lame.a src/encoder.c
mkdir -p dist && \
emcc $^ -s WASM=1 -O2 \
-s ASSERTIONS=0 \
-s TOTAL_STACK=65536 \
-s TOTAL_MEMORY=2097152 \
-s EXPORTED_FUNCTIONS="['_malloc', '_free']" \
-Ivendor/lame/dist/include \
-o dist/encoder.js && \
cp src/*.js dist/
release: encoder.wasm
mkdir -p release && \
cd release && \
cp -r ../dist mp3enc-wasm-${PKG_VERSION} && \
tar -czvf mp3enc-wasm-${PKG_VERSION}.tar.gz mp3enc-wasm-${PKG_VERSION} && \
zip -r mp3enc-wasm-${PKG_VERSION}.zip mp3enc-wasm-${PKG_VERSION} && \
rm -rf mp3enc-wasm-${PKG_VERSION}
clean-lame:
cd vendor/lame && rm -rf dist && make clean
clean-wasm:
rm -rf dist
clean-release:
rm -rf release