2020-06-07 21:31:55 +00:00
|
|
|
#!/bin/bash -e
|
2018-07-05 18:55:53 +00:00
|
|
|
|
2020-06-07 21:31:55 +00:00
|
|
|
prefix_dir=$PWD/mingw_prefix
|
|
|
|
mkdir -p "$prefix_dir"
|
|
|
|
ln -snf . "$prefix_dir/usr"
|
|
|
|
ln -snf . "$prefix_dir/local"
|
|
|
|
|
|
|
|
wget="wget -nc --progress=bar:force"
|
2022-09-27 13:13:02 +00:00
|
|
|
gitclone="git clone --depth=10 --recursive"
|
2020-06-07 21:31:55 +00:00
|
|
|
commonflags="--disable-static --enable-shared"
|
|
|
|
|
|
|
|
export PKG_CONFIG_SYSROOT_DIR="$prefix_dir"
|
|
|
|
export PKG_CONFIG_LIBDIR="$PKG_CONFIG_SYSROOT_DIR/lib/pkgconfig"
|
2018-07-05 18:55:53 +00:00
|
|
|
|
2020-06-30 17:40:22 +00:00
|
|
|
# -posix is Ubuntu's variant with pthreads support
|
|
|
|
export CC=$TARGET-gcc-posix
|
|
|
|
export CXX=$TARGET-g++-posix
|
2018-07-05 18:55:53 +00:00
|
|
|
export AR=$TARGET-ar
|
|
|
|
export NM=$TARGET-nm
|
|
|
|
export RANLIB=$TARGET-ranlib
|
|
|
|
|
2020-06-07 21:31:55 +00:00
|
|
|
export CFLAGS="-O2 -pipe -Wall -D_FORTIFY_SOURCE=2"
|
|
|
|
export LDFLAGS="-fstack-protector-strong"
|
|
|
|
|
2022-09-27 13:13:02 +00:00
|
|
|
fam=x86_64
|
|
|
|
[[ "$TARGET" == "i686-"* ]] && fam=x86
|
|
|
|
cat >"$prefix_dir/crossfile" <<EOF
|
|
|
|
[built-in options]
|
|
|
|
buildtype = 'release'
|
|
|
|
wrap_mode = 'nodownload'
|
2022-06-06 18:40:28 +00:00
|
|
|
[binaries]
|
|
|
|
c = '${CC}'
|
|
|
|
cpp = '${CXX}'
|
|
|
|
ar = '${AR}'
|
|
|
|
strip = '${TARGET}-strip'
|
|
|
|
pkgconfig = 'pkg-config'
|
|
|
|
windres = '${TARGET}-windres'
|
2023-06-08 22:45:43 +00:00
|
|
|
dlltool = '${TARGET}-dlltool'
|
2022-06-06 18:40:28 +00:00
|
|
|
[host_machine]
|
|
|
|
system = 'windows'
|
2022-09-27 13:13:02 +00:00
|
|
|
cpu_family = '${fam}'
|
|
|
|
cpu = '${TARGET%%-*}'
|
2022-06-06 18:40:28 +00:00
|
|
|
endian = 'little'
|
|
|
|
EOF
|
|
|
|
|
2020-06-07 21:31:55 +00:00
|
|
|
function builddir () {
|
|
|
|
[ -d "$1/builddir" ] && rm -rf "$1/builddir"
|
|
|
|
mkdir -p "$1/builddir"
|
|
|
|
pushd "$1/builddir"
|
|
|
|
}
|
|
|
|
|
|
|
|
function makeplusinstall () {
|
2022-09-27 13:13:02 +00:00
|
|
|
if [ -f build.ninja ]; then
|
|
|
|
ninja
|
|
|
|
DESTDIR="$prefix_dir" ninja install
|
|
|
|
else
|
|
|
|
make -j$(nproc)
|
|
|
|
make DESTDIR="$prefix_dir" install
|
|
|
|
fi
|
2020-06-07 21:31:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function gettar () {
|
|
|
|
name="${1##*/}"
|
|
|
|
[ -d "${name%%.*}" ] && return 0
|
|
|
|
$wget "$1"
|
|
|
|
tar -xaf "$name"
|
|
|
|
}
|
|
|
|
|
|
|
|
## iconv
|
|
|
|
if [ ! -e "$prefix_dir/lib/libiconv.dll.a" ]; then
|
2022-06-13 19:41:44 +00:00
|
|
|
ver=1.17
|
2020-06-07 21:31:55 +00:00
|
|
|
gettar "https://ftp.gnu.org/pub/gnu/libiconv/libiconv-${ver}.tar.gz"
|
|
|
|
builddir libiconv-${ver}
|
|
|
|
../configure --host=$TARGET $commonflags
|
|
|
|
makeplusinstall
|
|
|
|
popd
|
|
|
|
fi
|
|
|
|
|
|
|
|
## zlib
|
|
|
|
if [ ! -e "$prefix_dir/lib/libz.dll.a" ]; then
|
2023-05-27 17:20:56 +00:00
|
|
|
ver=1.2.13
|
2022-06-13 19:36:35 +00:00
|
|
|
gettar "https://zlib.net/fossils/zlib-${ver}.tar.gz"
|
2020-06-07 21:31:55 +00:00
|
|
|
pushd zlib-${ver}
|
2022-09-27 13:13:02 +00:00
|
|
|
make -fwin32/Makefile.gcc clean
|
2020-06-07 21:31:55 +00:00
|
|
|
make -fwin32/Makefile.gcc PREFIX=$TARGET- SHARED_MODE=1 \
|
|
|
|
DESTDIR="$prefix_dir" install \
|
|
|
|
BINARY_PATH=/bin INCLUDE_PATH=/include LIBRARY_PATH=/lib
|
|
|
|
popd
|
|
|
|
fi
|
|
|
|
|
|
|
|
## ffmpeg
|
|
|
|
if [ ! -e "$prefix_dir/lib/libavcodec.dll.a" ]; then
|
|
|
|
[ -d ffmpeg ] || $gitclone https://github.com/FFmpeg/FFmpeg.git ffmpeg
|
|
|
|
builddir ffmpeg
|
|
|
|
../configure --pkg-config=pkg-config --target-os=mingw32 \
|
|
|
|
--enable-cross-compile --cross-prefix=$TARGET- --arch=${TARGET%%-*} \
|
|
|
|
$commonflags \
|
2022-09-27 13:13:02 +00:00
|
|
|
--disable-{doc,programs,muxers,encoders,devices}
|
2020-06-07 21:31:55 +00:00
|
|
|
makeplusinstall
|
|
|
|
popd
|
|
|
|
fi
|
|
|
|
|
2020-09-25 16:23:05 +00:00
|
|
|
## shaderc
|
|
|
|
if [ ! -e "$prefix_dir/lib/libshaderc_shared.dll.a" ]; then
|
2020-06-30 17:40:22 +00:00
|
|
|
if [ ! -d shaderc ]; then
|
|
|
|
$gitclone https://github.com/google/shaderc.git
|
|
|
|
(cd shaderc && ./utils/git-sync-deps)
|
|
|
|
fi
|
|
|
|
builddir shaderc
|
|
|
|
cmake .. -DCMAKE_SYSTEM_NAME=Windows \
|
|
|
|
-DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF \
|
|
|
|
-DSHADERC_SKIP_TESTS=ON -DCMAKE_INSTALL_PREFIX=/
|
|
|
|
makeplusinstall
|
|
|
|
popd
|
2020-09-25 16:23:05 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
## spirv-cross
|
|
|
|
if [ ! -e "$prefix_dir/lib/libspirv-cross-c-shared.dll.a" ]; then
|
|
|
|
[ -d SPIRV-Cross ] || $gitclone https://github.com/KhronosGroup/SPIRV-Cross
|
|
|
|
builddir SPIRV-Cross
|
2020-06-30 17:40:22 +00:00
|
|
|
cmake .. -DCMAKE_SYSTEM_NAME=Windows \
|
|
|
|
-DSPIRV_CROSS_SHARED=ON -DSPIRV_CROSS_{CLI,STATIC}=OFF
|
|
|
|
makeplusinstall
|
|
|
|
popd
|
|
|
|
fi
|
|
|
|
|
2022-06-06 18:43:35 +00:00
|
|
|
## libplacebo
|
|
|
|
if [ ! -e "$prefix_dir/lib/libplacebo.dll.a" ]; then
|
|
|
|
[ -d libplacebo ] || $gitclone https://code.videolan.org/videolan/libplacebo.git
|
|
|
|
builddir libplacebo
|
2022-09-27 13:13:02 +00:00
|
|
|
meson .. --cross-file "$prefix_dir/crossfile"
|
|
|
|
makeplusinstall
|
2022-06-06 18:43:35 +00:00
|
|
|
popd
|
|
|
|
fi
|
|
|
|
|
2020-06-07 21:31:55 +00:00
|
|
|
## freetype2
|
|
|
|
if [ ! -e "$prefix_dir/lib/libfreetype.dll.a" ]; then
|
2023-05-27 17:20:56 +00:00
|
|
|
ver=2.13.0
|
2023-06-13 07:59:35 +00:00
|
|
|
gettar "https://mirror.netcologne.de/savannah/freetype/freetype-${ver}.tar.xz"
|
2020-06-07 21:31:55 +00:00
|
|
|
builddir freetype-${ver}
|
2022-09-27 13:13:02 +00:00
|
|
|
meson .. --cross-file "$prefix_dir/crossfile"
|
2020-06-07 21:31:55 +00:00
|
|
|
makeplusinstall
|
|
|
|
popd
|
|
|
|
fi
|
|
|
|
|
|
|
|
## fribidi
|
|
|
|
if [ ! -e "$prefix_dir/lib/libfribidi.dll.a" ]; then
|
2023-05-27 17:20:56 +00:00
|
|
|
ver=1.0.13
|
2020-06-07 21:31:55 +00:00
|
|
|
gettar "https://github.com/fribidi/fribidi/releases/download/v${ver}/fribidi-${ver}.tar.xz"
|
|
|
|
builddir fribidi-${ver}
|
2022-09-27 13:13:02 +00:00
|
|
|
meson .. --cross-file "$prefix_dir/crossfile" \
|
|
|
|
-D{tests,docs}=false
|
2020-06-07 21:31:55 +00:00
|
|
|
makeplusinstall
|
|
|
|
popd
|
|
|
|
fi
|
|
|
|
|
2020-11-15 16:29:06 +00:00
|
|
|
## harfbuzz
|
|
|
|
if [ ! -e "$prefix_dir/lib/libharfbuzz.dll.a" ]; then
|
2023-05-27 17:20:56 +00:00
|
|
|
ver=7.3.0
|
2020-11-15 16:29:06 +00:00
|
|
|
gettar "https://github.com/harfbuzz/harfbuzz/releases/download/${ver}/harfbuzz-${ver}.tar.xz"
|
|
|
|
builddir harfbuzz-${ver}
|
2022-09-27 13:13:02 +00:00
|
|
|
meson .. --cross-file "$prefix_dir/crossfile" \
|
|
|
|
-Dtests=disabled
|
2020-11-15 16:29:06 +00:00
|
|
|
makeplusinstall
|
|
|
|
popd
|
|
|
|
fi
|
|
|
|
|
2020-06-07 21:31:55 +00:00
|
|
|
## libass
|
|
|
|
if [ ! -e "$prefix_dir/lib/libass.dll.a" ]; then
|
|
|
|
[ -d libass ] || $gitclone https://github.com/libass/libass.git
|
|
|
|
builddir libass
|
|
|
|
[ -f ../configure ] || (cd .. && ./autogen.sh)
|
|
|
|
../configure --host=$TARGET $commonflags
|
|
|
|
makeplusinstall
|
|
|
|
popd
|
|
|
|
fi
|
|
|
|
|
2020-06-30 17:40:22 +00:00
|
|
|
## luajit
|
|
|
|
if [ ! -e "$prefix_dir/lib/libluajit-5.1.a" ]; then
|
2022-09-27 13:13:02 +00:00
|
|
|
ver=2.1.0-beta3
|
2020-06-30 17:40:22 +00:00
|
|
|
gettar "http://luajit.org/download/LuaJIT-${ver}.tar.gz"
|
|
|
|
pushd LuaJIT-${ver}
|
2022-09-27 13:13:02 +00:00
|
|
|
hostcc=cc
|
2020-06-30 17:40:22 +00:00
|
|
|
[[ "$TARGET" == "i686-"* ]] && hostcc="$hostcc -m32"
|
2022-09-27 13:13:02 +00:00
|
|
|
make TARGET_SYS=Windows clean
|
|
|
|
make TARGET_SYS=Windows HOST_CC="$hostcc" CROSS=$TARGET- \
|
2020-06-30 17:40:22 +00:00
|
|
|
BUILDMODE=static amalg
|
|
|
|
make DESTDIR="$prefix_dir" INSTALL_DEP= FILE_T=luajit.exe install
|
2020-06-07 21:31:55 +00:00
|
|
|
popd
|
|
|
|
fi
|
|
|
|
|
|
|
|
## mpv
|
|
|
|
|
2022-09-27 13:13:02 +00:00
|
|
|
[ -z "$1" ] && exit 0
|
2021-11-07 19:29:11 +00:00
|
|
|
|
2022-09-27 13:13:02 +00:00
|
|
|
CFLAGS+=" -I'$prefix_dir/include'"
|
|
|
|
LDFLAGS+=" -L'$prefix_dir/lib'"
|
|
|
|
export CFLAGS LDFLAGS
|
|
|
|
rm -rf build
|
|
|
|
|
2022-11-12 14:27:07 +00:00
|
|
|
meson setup build --cross-file "$prefix_dir/crossfile" \
|
|
|
|
--buildtype debugoptimized \
|
|
|
|
-Dlibmpv=true -Dlua=luajit \
|
|
|
|
-D{shaderc,spirv-cross,d3d11,libplacebo,libplacebo-next}=enabled
|
|
|
|
|
|
|
|
meson compile -C build
|
2022-09-27 13:32:21 +00:00
|
|
|
|
|
|
|
if [ "$2" = pack ]; then
|
|
|
|
mkdir -p artifact
|
|
|
|
echo "Copying:"
|
2023-01-29 06:31:44 +00:00
|
|
|
cp -pv build/generated/mpv.com build/mpv.exe "$prefix_dir/bin/"*.dll artifact/
|
2022-09-27 13:32:21 +00:00
|
|
|
# ship everything and the kitchen sink
|
|
|
|
shopt -s nullglob
|
|
|
|
for file in /usr/lib/gcc/$TARGET/*-posix/*.dll /usr/$TARGET/lib/*.dll; do
|
|
|
|
cp -pv "$file" artifact/
|
|
|
|
done
|
|
|
|
echo "Archiving:"
|
|
|
|
pushd artifact
|
|
|
|
zip -9r "../mpv-git-$(date +%F)-$(git rev-parse --short HEAD)-${TARGET%%-*}.zip" -- *
|
|
|
|
popd
|
|
|
|
fi
|