Building OpenCV static libs
I think that is possible to build the whole OpenCV libs as a big static lib. But it is highly recommended to build the single and separated static libs for a fined granulated compilation. There are also parts of OpenCV project that compiling with Emscripten are very hard to build. And what about if you want use only a set of OpenCV functions? The final .js or .wasm file will be too big.
Example opencv-em
We did this script opencv-em to build a set of static libs that we need for a project. It build the static libs and pack the needed include directories.
Step build description
We have set up a shell build script. We used cmake for the compilation because the existent CMakeLists.txt in the OpenCV project directory, this simplify things a lot:
cmake .. -GNinja -DCMAKE_TOOLCHAIN_FILE=$EM_TOOLCHAIN $OPENCV_CONF $OPENCV_INTRINSICS -DCMAKE_CXX_FLAGS="$EM_FLAGS" -DCMAKE_C_FLAGS="$EM_FLAGS"
we used Ninja as a compiler but you can use make.
-DCMAKE_TOOLCHAIN_FILE=$EM_TOOLCHAIN
This define the toolchain in this case Emscripten:
EM_TOOLCHAIN="$EMSCRIPTEN/cmake/Modules/Platform/Emscripten.cmake"
You need of course to install Emscripten with emsdk.
OPENCV_CONF is the variable where you define which libs to build and the necessary files to include and to exclude (that is very important!)
Note also that compilation may vary in base of Emscripten and OpenCV version!
Downloads
If you want you can downloads the libs in the releases page. Read the Emscripten and OpenCV version used.