#!/bin/sh

# small script to apply patches to submodules

# enable static build of lua_sandbox
# if ! grep STATIC lib/lua_sandbox/src/CMakeLists.txt > /dev/null; then
# 	cd lib/lua_sandbox && patch -p1 < ../../build/lua_sandbox.patch && cd -
# fi

# if grep 'static const.*lzlib' lib/luazen/src/luazen.c > /dev/null; then
# 	cd lib/luazen && patch -p1 < ../../build/luazen_build.patch && cd -
# fi

# should be fixed in ff2669fa0c351bcea846627a2d1493b99ccd525e
# if grep 'print_out' lib/milagro-crypto-c/test/test_rsa_sign_WWW_ZZZ.c > /dev/null; then
# 	cd lib/milagro-crypto-c && patch -p1 < ../../build/milagro.patch && cd -
# fi

# TODO: patch randombytes to work in emscripten
# using float emscripten_random(void)
# https://kripken.github.io/emscripten-site/docs/api_reference/emscripten.h.html#c.emscripten_random
# if ! [ -r lib/luazen/src/randombytes.h ]; then
# 	cp src/randombytes.c src/randombytes.h lib/luazen/src
# fi

# cd lib/jemalloc && \
# 	git checkout -- . && patch < ../../build/jemalloc_static.patch && cd -
