安装 Emscripten 工具链:
git clone --depth 1 https://github.com/cntrump/emscripten-toolchain.git
cd emscripten-toolchain
./install.sh /opt/local
添加 Emscripten 到 PATH 系统环境变量中:
export PATH=/opt/local/emsdk/emscripten:$PATH
开始编译 OpenSSL:
git clone --depth 1 -b OpenSSL_1_1_1n https://github.com/openssl/openssl.git
cd openssl
emconfigure ./Configure linux-generic64 --prefix=$(pwd)/../system
sed -i'.bak' 's|^CROSS_COMPILE.*$|CROSS_COMPILE=|g' Makefile
emmake make -j build_generated libssl.a libcrypto.a
mkdir -p ../system/include
mkdir -p ../system/lib
# 复制 include 和 lib
cp -a include/openssl ../system/include
cp libssl.a libcrypto.a ../system/lib