Create a gist now

Instantly share code, notes, and snippets.

@ttsuki /multilib.sh
Last active Jun 12, 2017

What would you like to do?
Alternative x265/build/msys/multilib.sh (link statically libstdc++)
#!/bin/bash
set -eu
PREFIX=$HOME/x265
MAKEFLAGS=-j16
rm -rf build
mkdir -p build/{10bit,12bit}
cd build
# build 10bit static library.
cd 10bit
cmake -G 'Unix Makefiles' -DCMAKE_TOOLCHAIN_FILE=../../toolchain-x86_64-w64-mingw32.cmake ../../../../source -DHIGH_BIT_DEPTH=ON -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=OFF
make ${MAKEFLAGS}
cp libx265.a ../libx265_main10.a
cd ..
# build 12bit static library.
cd 12bit
cmake -G 'Unix Makefiles' -DCMAKE_TOOLCHAIN_FILE=../../toolchain-x86_64-w64-mingw32.cmake ../../../../source -DHIGH_BIT_DEPTH=ON -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=OFF -DMAIN12=ON
make ${MAKEFLAGS}
cp libx265.a ../libx265_main12.a
cd ..
# build 8bit static library
cmake -G 'Unix Makefiles' -DCMAKE_TOOLCHAIN_FILE=../toolchain-x86_64-w64-mingw32.cmake ../../../source -DCMAKE_INSTALL_PREFIX="$PREFIX" -DEXTRA_LIB="x265_main10.a;x265_main12.a" -DEXTRA_LINK_FLAGS=-L. -DLINKED_10BIT=ON -DLINKED_12BIT=ON
make ${MAKEFLAGS} x265-static
# rename the 8bit library, then combine all three into libx265.a using GNU ar
mv libx265.a libx265_main.a
x86_64-w64-mingw32-ar -M <<EOF
CREATE libx265.a
ADDLIB libx265_main.a
ADDLIB libx265_main10.a
ADDLIB libx265_main12.a
SAVE
END
EOF
# build all-in shared library and cli.
sed -i CMakeFiles/x265-shared.dir/link.txt -e 's/g++.exe/g++.exe -static -static-libgcc -static-libstdc++/'
sed -i CMakeFiles/cli.dir/link.txt -e 's/g++.exe/g++.exe -static -static-libgcc -static-libstdc++/'
sed -i CMakeFiles/x265-shared.dir/linklibs.rsp -e 's/-Wl,-Bdynamic//'
sed -i CMakeFiles/cli.dir/linklibs.rsp -e 's/-Wl,-Bdynamic//'
make ${MAKEFLAGS}
cd ..
echo Do \'make -C build install\' to install.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment