visualboyadvance-m/tools/win/msys2-builder

189 lines
5.3 KiB
Plaintext
Raw Normal View History

#!/bin/sh
set -e
case "$1" in
-32)
shift
if [ "$MSYSTEM" != MINGW32 ]; then
unset MSYSTEM_PREFIX MSYSTEM_CARCH MSYSTEM_CHOST MINGW_CHOST MINGW_PREFIX MINGW_PACKAGE_PREFIX CONFIG_SITE ACLOCAL_PATH PKG_CONFIG_PATH
OPWD=$PWD
export MSYSTEM=MINGW32
. /etc/profile || :
cd "$OPWD"
fi
;;
-64)
shift
if [ "$MSYSTEM" != MINGW64 ]; then
unset MSYSTEM_PREFIX MSYSTEM_CARCH MSYSTEM_CHOST MINGW_CHOST MINGW_PREFIX MINGW_PACKAGE_PREFIX CONFIG_SITE ACLOCAL_PATH PKG_CONFIG_PATH
OPWD=$PWD
export MSYSTEM=MINGW64
. /etc/profile || :
cd "$OPWD"
fi
;;
esac
OMSYSTEM=$MSYSTEM
case "$MSYSTEM" in
MINGW32)
export HOST_SYSTEM=i686-w64-mingw32
sys_base=/mingw32
export BUILD_ROOT="$HOME/vbam-build-msys2-i686"
target_bits=32
target_cpu=i686
;;
MINGW64)
export HOST_SYSTEM=x86_64-w64-mingw32
sys_base=/mingw64
export BUILD_ROOT="$HOME/vbam-build-msys2-x86_64"
target_bits=64
target_cpu=x86_64
;;
MSYS)
exec "$0" "$@" -64
;;
*)
echo >&2 'You must be in either the MINGW32 or MINGW64 environment.'
exit 1
;;
esac
# turn on real symlinks
new_msys= replaced=
for part in $MSYS; do
case "$part" in
winsymlinks:*)
new_msys="$new_msys winsymlinks:nativestrict"
replaced=1
;;
*)
new_msys="$new_msys $part"
;;
esac
done
if [ -n "$replaced" ]; then
export MSYS=$new_msys
else
export MSYS="winsymlinks:nativestrict $new_msys"
fi
add cygwin cross build support Put shared code for linux cross builds and cygwin cross builds into builder/mingw-cross.sh . Call wxrc when the build platform is cygwin with files resolved via `cygpath -m` in case the wxrc is a native binary. Add -fpermissive to CXX/OBJCXX flags. Reenable libzvbi support for ffmpeg. Stop building ffmpeg and related dists by default until we fix game recording. Set CMAKE_PREFIX_PATH in cmake args as a FILEPATH type variable. Support xml catalog made with native libxml2 using cygpath in related commands, make cygpath a noop on non-cygwin platforms. Remove gdb and zip from msys2 deps. Add a cygwin installdeps routine using a copy of cyg-apt that it fetches. When creating symlinks in install_dist() fully resolve all symlinks in path parts for the source file, so that host and target binaries are correctly linked. When cp -af fails to preserve permission related data, fall back to cp -rf. When installing libs with a cross suffix, make a symlink for the lib without the cross suffix. Make sure cygwin runs with CYGWIN=winsymlinks:native . Add paths to host gettext executables to cmake args, otherwise it tries to use the target executables and fails on paths. For the pkgconfig bundled glib, turn off win32 platform for the cygwin host build. For gettext, remove --disable-auto-import from link flags. Compile target freetype on cygwin with cmake and manually install the pkgconfig .pc file using sed. Add a relocation type 'aggressive', when a dist is marked with this type, rewrite all '/usr' prefixes to the build root. By default only files that exist in the dist are matched and rewritten. Fix regression in linux build by adding some iconv related flags to the cmake invocation for doxygen and disabling -Werror for xorg dists. When relocating scripts, use the actual resolved root path for host or target. Build libxslt --without-python so that it doesn't try to pick up the msys2 python. Other misc. minor tweaks and cleanups.
2018-05-01 08:09:41 +00:00
PATH_SEP=';'
CMAKE_PREFIX_PATH=
for dir in /lib /bin "$HOST_SYSTEM/lib" "$HOST_SYSTEM/bin"; do
CMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH;$(cygpath -m "$sys_base/$dir")"
done
export CMAKE_PREFIX_PATH="$(cygpath -m "$BUILD_ROOT/root");${CMAKE_PREFIX_PATH%;}"
ignore_msys_paths=
for d in /usr /usr/include /usr/lib; do
ignore_msys_paths="$ignore_msys_paths;$(cygpath -m "$d")"
done
ignore_msys_paths=${ignore_msys_paths#;}
export CMAKE_BASE_ARGS="-G 'MSYS Makefiles' -DCMAKE_IGNORE_PATH='$ignore_msys_paths'"
export TMP_DIR="$BUILD_ROOT/tmp_$$"
BUILD_ENV=$BUILD_ENV$(cat <<'EOF'
# on don't translate prefix and defines by default
export MSYS2_ARG_CONV_EXCL="-D;/usr;/etc"
EOF
)
export BUILD_ENV
DIST_TAR_ARGS="
help2man --exclude ChangeLog
sfml --exclude libs-osx
expat --exclude README.md
libsoxr --exclude inst-check-soxr-lsr
graphviz --exclude COPYING --exclude graphviz.spec
"
add cygwin cross build support Put shared code for linux cross builds and cygwin cross builds into builder/mingw-cross.sh . Call wxrc when the build platform is cygwin with files resolved via `cygpath -m` in case the wxrc is a native binary. Add -fpermissive to CXX/OBJCXX flags. Reenable libzvbi support for ffmpeg. Stop building ffmpeg and related dists by default until we fix game recording. Set CMAKE_PREFIX_PATH in cmake args as a FILEPATH type variable. Support xml catalog made with native libxml2 using cygpath in related commands, make cygpath a noop on non-cygwin platforms. Remove gdb and zip from msys2 deps. Add a cygwin installdeps routine using a copy of cyg-apt that it fetches. When creating symlinks in install_dist() fully resolve all symlinks in path parts for the source file, so that host and target binaries are correctly linked. When cp -af fails to preserve permission related data, fall back to cp -rf. When installing libs with a cross suffix, make a symlink for the lib without the cross suffix. Make sure cygwin runs with CYGWIN=winsymlinks:native . Add paths to host gettext executables to cmake args, otherwise it tries to use the target executables and fails on paths. For the pkgconfig bundled glib, turn off win32 platform for the cygwin host build. For gettext, remove --disable-auto-import from link flags. Compile target freetype on cygwin with cmake and manually install the pkgconfig .pc file using sed. Add a relocation type 'aggressive', when a dist is marked with this type, rewrite all '/usr' prefixes to the build root. By default only files that exist in the dist are matched and rewritten. Fix regression in linux build by adding some iconv related flags to the cmake invocation for doxygen and disabling -Werror for xorg dists. When relocating scripts, use the actual resolved root path for host or target. Build libxslt --without-python so that it doesn't try to pick up the msys2 python. Other misc. minor tweaks and cleanups.
2018-05-01 08:09:41 +00:00
. "${0%/*}/../builder/mingw.sh"
host_env() {
cat <<EOF
unset MSYSTEM_PREFIX MSYSTEM_CARCH MSYSTEM_CHOST MINGW_CHOST MINGW_PREFIX MINGW_PACKAGE_PREFIX CONFIG_SITE ACLOCAL_PATH PKG_CONFIG_PATH
OPWD="\$PWD"
export MSYSTEM=MSYS
. /etc/profile || :
. ~/.bashrc 2>/dev/null || :
$BUILD_ENV
EOF
cd "$OPWD"
host_env_base 2>/dev/null || :
}
target_env() {
cat <<EOF
unset MSYSTEM_PREFIX MSYSTEM_CARCH MSYSTEM_CHOST MINGW_CHOST MINGW_PREFIX MINGW_PACKAGE_PREFIX CONFIG_SITE ACLOCAL_PATH PKG_CONFIG_PATH
OPWD="\$PWD"
export MSYSTEM="\$OMSYSTEM"
. /etc/profile || :
. ~/.bashrc 2>/dev/null || :
$BUILD_ENV
EOF
cd "$OPWD"
target_env_base 2>/dev/null || :
}
table_line_append DIST_PRE_BUILD c2man ":; \
sed -i.bak '/test -d c:\\//,/^fi\$/d' Configure; \
"
table_line_append DIST_PATCHES xmlto 'https://gist.githubusercontent.com/rkitover/55d51ab3d55af510b37872a49670436c/raw/b447beaffc2daa747ba6eaf222f69677c7d4a169/xmlto-0.0.28-mingw.patch'
# FIXME: problems with autopoint that need to be sorted
table_line_remove DISTS flex
table_line_replace DIST_CONFIGURE_TYPES fontconfig autoreconf
table_line_append DIST_PRE_BUILD fontconfig ":; \
sed -i.bak 's|ln -s \\\$(templatedir)|cp -af \$(DESTDIR)/\$(templatedir)|g' conf.d/Makefile.am; \
"
if mime_info_libs=$(table_line DIST_EXTRA_LIBS shared-mime-info); then
table_line_replace DIST_EXTRA_LIBS shared-mime-info "$(puts "$mime_info_libs" | sed 's/-ldl//g; s/-lresolv//g;')"
fi
table_line_remove DIST_CONFIGURE_OVERRIDES unzip
table_line_remove DIST_PRE_BUILD unzip
table_line_replace DIST_MAKE_ARGS unzip '-f win32/Makefile.gcc NOASM=1 CC_CPU_OPT='
table_line_replace DIST_INSTALL_OVERRIDES unzip 'cp -af $(find . -name "*.exe") "$BUILD_ROOT/root/bin"'
table_line_replace DIST_PRE_BUILD unzip ":; \
sed -i.bak 's,#include \"../unzip\\.h\",#include <windows.h>,; \
t; \
s,#include <windows.h>,#include \"../unzip.h\",' win32/win32.c win32/nt.c; \
"
table_line_append DIST_PATCHES zip 'https://gist.githubusercontent.com/rkitover/17e4c90185b7ad533e848b6230a90b8d/raw/434e0f74c872a928e77b93bdbf4ee9a1140fe879/zip-mingw.patch'
table_line_remove DIST_CONFIGURE_OVERRIDES zip
table_line_remove DIST_PRE_BUILD zip
table_line_replace DIST_MAKE_ARGS zip '-f win32/Makefile.gcc'
table_line_replace DIST_INSTALL_OVERRIDES zip 'cp -af *.exe "$BUILD_ROOT/root/bin"'
table_line_replace DIST_POST_BUILD unzip ":; \
mkdir -p \"\$BUILD_ROOT/root/bin\"; \
cp -a \"\$BUILD_ROOT/dists/unzip\"/*.exe \"\$BUILD_ROOT/root/bin\"; \
"
table_line_replace DIST_CONFIGURE_OVERRIDES openssl "$(table_line DIST_CONFIGURE_OVERRIDES openssl | sed 's,^./config ,./Configure Cygwin-x86_64 ,')"
builder "$@"