visualboyadvance-m/tools/win/msys2-builder

169 lines
4.6 KiB
Bash
Executable File

#!/bin/sh
set -e
case "$1" in
-32)
shift
if [ "$MSYSTEM" != MINGW32 ]; then
OPWD=$PWD
export MSYSTEM=MINGW32
. /etc/profile || :
cd "$OPWD"
fi
;;
-64)
shift
if [ "$MSYSTEM" != MINGW64 ]; then
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
BUILD_ROOT="$HOME/vbam-build-msys2-i686"
;;
MINGW64)
export HOST_SYSTEM=x86_64-w64-mingw32
sys_base=/mingw64
BUILD_ROOT="$HOME/vbam-build-msys2-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
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#;}
CMAKE_BASE_ARGS="-G 'MSYS Makefiles' -DCMAKE_IGNORE_PATH='$ignore_msys_paths'"
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
)
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
"
. "${0%/*}/../builder/mingw.sh"
set_host_env() {
ln -sf "$BUILD_ROOT/host" "$BUILD_ROOT/root"
OPWD=$PWD
MSYSTEM=MSYS . /etc/profile || :
eval "$BUILD_ENV"
cd "$OPWD"
}
unset_host_env() {
ln -sf "$BUILD_ROOT/target" "$BUILD_ROOT/root"
OPWD=$PWD
MSYSTEM=$OMSYSTEM . /etc/profile || :
eval "$BUILD_ENV"
cd "$OPWD"
}
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 "$@"