mwss/Makefile

37 lines
2.3 KiB
Makefile
Raw Normal View History

2024-12-21 22:43:09 +02:00
.DEFAULT_GOAL := all
EMSCR := $(shell command -v emcmake 2> /dev/null)
LLVM_AR := $(shell command -v llvm-ar 2> /dev/null)
emscr:
ifndef EMSCR
$(error "Emscripten is not in PATH.")
endif
ifndef LLVM_AR
$(error "llvm-ar is not in PATH. Consider Emscripten's own binary in emsdk/upstream/bin.")
endif
ogg/libogg.a: emscr
test -e ogg || git clone https://github.com/xiph/ogg
cd ogg && emcmake cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="-sMAYBE_WASM2JS -fPIC" ./ && make -j$(nproc)
vorbis/lib/libvorbis.a: emscr ogg/libogg.a
test -e vorbis || git clone https://github.com/xiph/vorbis
cd vorbis && emcmake cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="-sMAYBE_WASM2JS -I../ogg/include/ -fPIC" -DOGG_INCLUDE_DIR="../ogg/include" -DOGG_LIBRARY="../libogg.a" -DBUILD_TESTING=0 ./ && make -j$(nproc)
FFmpeg/libswscale/libswscale.a: emscr
test -e FFmpeg || git clone https://github.com/FFmpeg/FFmpeg/
cd FFmpeg && git checkout 13129f1af4340944291e0e291cb38d1c1ea3aad2 && ./configure --cc=emcc --enable-cross-compile --target-os=none --arch=x86 --disable-runtime-cpudetect --disable-asm --disable-bzlib --disable-iconv --disable-libxcb --disable-lzma --disable-sdl2 --disable-securetransport --disable-xlib --disable-zlib --disable-network --disable-d3d11va --disable-dxva2 --disable-all --disable-everything --disable-ffmpeg --enable-avcodec --disable-avformat --enable-avutil --disable-avfilter --disable-swresample --enable-swscale --enable-decoder=vp8 --enable-decoder=vp9 --enable-shared --extra-cflags="-sMAYBE_WASM2JS -fPIC" --extra-cxxflags="-sMAYBE_WASM2JS -fPIC" && make -j$(nproc)
llvm-ar d FFmpeg/libswscale/libswscale.a log2_tab.o
llvm-ar d FFmpeg/libavutil/libavutil.a log2_tab.o
llvm-ar d FFmpeg/libavcodec/libavcodec.a reverse.o
wsrA: main.c mongoose.c
cc -s -O3 -D_GNU_SOURCE -o wsrA main.c mongoose.c
support.js: emscr ogg/libogg.a vorbis/lib/libvorbis.a FFmpeg/libswscale/libswscale.a
emcc -o support -fPIC -flto -IFFmpeg -Iogg/include -Ivorbis/include -LFFmpeg/libavcodec -l:libavcodec.a -LFFmpeg/libswscale -l:libswscale.a -LFFmpeg/libavutil -l:libavutil.a -Lvorbis/lib -l:libvorbis.a -Logg -l:libogg.a support.c -pthread -msimd128 -O3 -sMAYBE_WASM2JS -sUSE_PTHREADS=1 -sEXPORT_ALL=1 -sMAIN_MODULE=1 -sTOTAL_MEMORY=128MB
mv support support.js
all: support.js wsrA