RetroArch/retroarch-mingw-build.sh

150 lines
4.0 KiB
Bash
Raw Normal View History

#!/bin/sh
###############
2012-04-22 09:42:22 +00:00
# Build script which builds and packages RetroArch for MinGW 32/64-bit.
# Preferably build on Linux with a cross chain ... :D
##########
####
2011-08-29 14:20:55 +00:00
## Tweak these to suit your environment.
## Not defining the variable will avoid building that target.
2011-08-29 16:47:52 +00:00
## Set MINGW32_BASE and/or MINGW64_BASE to set toolchain prefix:
## E.g.: i486-mingw32-gcc would get prefix "i486-mingw32".
BUILD_32BIT=yes
BUILD_64BIT=yes
BUILD_PHOENIX_GUI=yes
if [ ! -z "$NOBUILD_32BIT" ]; then
BUILD_32BIT=no
fi
2011-08-29 16:47:52 +00:00
if [ ! -z "$NOBUILD_64BIT" ]; then
BUILD_64BIT=no
fi
if [ ! -z "$NOBUILD_PHOENIX_GUI" ]; then
BUILD_PHOENIX_GUI=no
fi
########
die()
{
echo "$@"
exit 1
}
message()
{
echo ""
echo "================================"
echo "$@"
echo "================================"
echo ""
}
if [ ! -f "`which zip`" ]; then
echo "Cannot find 'zip'. Cannot package, quitting ..."
exit 1
fi
if [ ! -f "`which unzip`" ]; then
echo "Cannot find 'unzip'. Cannot unpack, quitting ..."
exit 1
fi
if [ ! -f "`which wget`" ]; then
echo "Cannot find 'wget'. Cannot unpack, quitting ..."
exit 1
fi
do_phoenix_build()
{
message "Build Phoenix GUI"
### Build Phoenix GUI
if [ ! -d "Phoenix" ]; then
2012-04-22 09:42:22 +00:00
git clone git://github.com/Themaister/RetroArch-Phoenix.git Phoenix
cd Phoenix
else
cd Phoenix
git pull origin master
fi
2011-10-14 11:34:27 +00:00
make -f Makefile.win clean || die "Failed to clean ..."
make -f Makefile.win CC="$C_COMPILER" CXX="$CXX_COMPILER" WINDRES="$WINDRES" -j4 all || die "Failed to build ..."
2012-04-22 09:42:22 +00:00
touch retroarch-phoenix.cfg
cp retroarch-phoenix.cfg retroarch-phoenix.exe ../ || die "Failed to copy ..."
cd ..
}
do_build()
{
2012-04-22 09:42:22 +00:00
RetroArch_DIR="$1"
LIBZIPNAME="$2"
BUILDTYPE="$3"
2012-04-22 09:42:22 +00:00
if [ ! -d "$RetroArch_DIR" ]; then
git clone git://github.com/Themaister/RetroArch.git "$RetroArch_DIR"
cd "$RetroArch_DIR"
else
2012-04-22 09:42:22 +00:00
cd "$RetroArch_DIR"
git pull origin master
fi
if [ ! -f "$LIBZIPNAME" ]; then
make -f Makefile.win libs_${BUILDTYPE} || die "Failed to extract"
fi
make -f Makefile.win clean || die "Failed to clean ..."
make -f Makefile.win CC="$C_COMPILER" CXX="$CXX_COMPILER" WINDRES="$WINDRES" -j4 all SLIM=1 || die "Failed to build ..."
make -f Makefile.win CC="$C_COMPILER" CXX="$CXX_COMPILER" WINDRES="$WINDRES" dist_${BUILDTYPE} SLIM=1 || die "Failed to dist ..."
2012-04-22 09:42:22 +00:00
if [ -z "`find . | grep "retroarch-win"`" ]; then
die "Did not find build ..."
fi
if [ "$BUILD_PHOENIX_GUI" = "yes" ]; then
do_phoenix_build
fi
2012-04-22 09:42:22 +00:00
ZIP_BASE="`find . | grep "retroarch-win" | head -n1`"
ZIP_SLIM="`echo $ZIP_BASE | sed -e 's|\.zip|-slim.zip|'`"
ZIP_FULL="`echo $ZIP_BASE | sed -e 's|\.zip|-full.zip|'`"
if [ "$BUILD_PHOENIX_GUI" = "yes" ]; then
2012-04-22 09:42:22 +00:00
zip "$ZIP_BASE" retroarch-phoenix.exe retroarch-phoenix.cfg
fi
mv -v "$ZIP_BASE" "../$ZIP_SLIM" || die "Failed to move final build ..."
make -f Makefile.win clean || die "Failed to clean ..."
make -f Makefile.win CC="$C_COMPILER" CXX="$CXX_COMPILER" WINDRES="$WINDRES" HAVE_D3D9=1 -j4 all || die "Failed to build ..."
make -f Makefile.win CC="$C_COMPILER" CXX="$CXX_COMPILER" WINDRES="$WINDRES" HAVE_D3D9=1 dist_${BUILDTYPE} || die "Failed to dist ..."
if [ "$BUILD_PHOENIX_GUI" = "yes" ]; then
2012-04-22 09:42:22 +00:00
zip "$ZIP_BASE" retroarch-phoenix.exe retroarch-phoenix.cfg
fi
cp -v "$ZIP_BASE" "../$ZIP_FULL" || die "Failed to move final build ..."
mv -v "$ZIP_BASE" ..
zip "../$ZIP_BASE" *.dll retroarch-redist-version || die "Failed to build full/redist ..."
cd ..
}
2011-08-29 16:47:52 +00:00
if [ "$BUILD_32BIT" = yes ]; then
message "Building for 32-bit!"
C_COMPILER="${MINGW32_BASE}-gcc -msse"
CXX_COMPILER="${MINGW32_BASE}-g++ -msse"
WINDRES=${MINGW32_BASE}-windres
do_build "RetroArch-w32" "RetroArch-win32-libs.zip" "x86"
fi
2011-08-29 16:47:52 +00:00
if [ "$BUILD_64BIT" = yes ]; then
message "Building for 64-bit!"
C_COMPILER=${MINGW64_BASE}-gcc
CXX_COMPILER=${MINGW64_BASE}-g++
WINDRES=${MINGW64_BASE}-windres
do_build "RetroArch-w64" "RetroArch-win64-libs.zip" "x86_64"
fi
message "Built successfully! :)"