singe/singe/buildRelease.sh
2020-05-04 18:52:25 -05:00

166 lines
5.8 KiB
Bash
Executable file

#!/bin/bash -e
#
# Singe 2
# Copyright (C) 2006-2020 Scott Duensing <scott@kangaroopunch.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
source source.inc.sh
G_L="-------------------------------------------------------------------------------"
function doBuild() {
local TARGET=$1
local OSNAME=$2
local OSARCH=$3
local EXT=$4
local SOURCE=
local I=
local OFILES=""
local O=
# Override this
QMAKE_CFLAGS="-isystem ../../thirdparty-build/${OSNAME}/${OSARCH}/installed/include -isystem ../../singe/thirdparty/arg_parser -isystem ../../singe/thirdparty/manymouse"
pushd "${SOURCE_DIR}/.." &> /dev/null
mkdir -p build
cd build
[[ -d temp ]] && rm -rf temp
mkdir -p temp
cd temp
for I in ${SOURCES}; do
if [[ ${I:0:1} == "/" ]]; then
SOURCE="${I}"
else
SOURCE="${SOURCE_DIR}/${I}"
fi
O=`basename ${SOURCE}`
O=${O%.*}.o
OFILES="${OFILES} ${O}"
echo "Compiling ${SOURCE}..."
${CROSS}-${CCOMPILER} ${QMAKE_CFLAGS} ${EXTRA_CFLAGS} -c "${SOURCE}" -o ${O}
done
TARGET="${SOURCE_DIR}/../build/${TARGET}${EXT}"
[[ -e "${TARGET}" ]] && rm "${TARGET}"
echo "Linking ${TARGET}..."
# The grep nonsense hides a warning we don't care about.
${CROSS}-${CPPCOMPILER} -o "${TARGET}" ${OFILES} ${EXTRA_OFILES} "-L${SOURCE_DIR}/../thirdparty-build/${OSNAME}/${OSARCH}/installed/lib" ${EXTRA_LD_FLAGS} 2>&1 | grep -v loslib || true
echo "Compressing ${TARGET}..."
${CROSS}-strip "${TARGET}"
upx -9 "${TARGET}"
cd ..
rm -rf temp
popd &> /dev/null
}
# Find Singe version
G_VERSION=$(grep VERSION_STRING singe.h | cut -d '"' -f 2)
# 32 Bit Linux
echo -e "${G_L}\nLinux i386\n${G_L}"
CROSS="x86_64-linux-gnu"
CCOMPILER="gcc"
CPPCOMPILER="g++"
EXTRA_CFLAGS="-m32 -O2"
EXTRA_OFILES=""
EXTRA_LD_FLAGS="-m32 -l:everything.a -lpthread -lXv -lX11 -lXext -lm -ldl -lrt"
doBuild Singe-${G_VERSION}-Linux-i386 linux 32
# 64 Bit Linux
echo -e "${G_L}\nLinux x86_64\n${G_L}"
CROSS="x86_64-linux-gnu"
CCOMPILER="gcc"
CPPCOMPILER="g++"
EXTRA_CFLAGS="-O2"
EXTRA_OFILES=""
EXTRA_LD_FLAGS="-l:everything.a -lpthread -lXv -lX11 -lXext -lm -ldl -lrt"
doBuild Singe-${G_VERSION}-Linux-x86_64 linux 64
# 32 Bit Windows
echo -e "${G_L}\nWindows i686\n${G_L}"
CROSS="i686-w64-mingw32"
CCOMPILER="gcc"
CPPCOMPILER="g++"
EXTRA_CFLAGS="-O2 -DLUASOCKET_INET_PTON"
EXTRA_OFILES="/tmp/singe.res"
EXTRA_LD_FLAGS="-mwindows -static -lmingw32 -l:everything.a -lm -lbcrypt -ldinput8 -ldxguid -ldxerr8 -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lsetupapi -lversion -luuid -lws2_32 -Dmain=SDL_main"
xcf2png icon.xcf -o /tmp/icon.png
icotool -c -o /tmp/icon.ico /tmp/icon.png
${CROSS}-windres singe.rc -O coff -o /tmp/singe.res
doBuild Singe-${G_VERSION}-Windows-i686 mingw 32 .exe
rm /tmp/icon.ico
rm /tmp/icon.png
rm /tmp/singe.res
# 64 Bit Windows
echo -e "${G_L}\nWindows x86_64\n${G_L}"
CROSS="x86_64-w64-mingw32"
CCOMPILER="gcc"
CPPCOMPILER="g++"
EXTRA_CFLAGS="-O2 -DLUASOCKET_INET_PTON"
EXTRA_OFILES="/tmp/singe.res"
EXTRA_LD_FLAGS="-mwindows -static -lmingw32 -l:everything.a -lm -lbcrypt -ldinput8 -ldxguid -ldxerr8 -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lsetupapi -lversion -luuid -lws2_32 -Dmain=SDL_main"
xcf2png icon.xcf -o /tmp/icon.png
icotool -c -o /tmp/icon.ico /tmp/icon.png
${CROSS}-windres singe.rc -O coff -o /tmp/singe.res
doBuild Singe-${G_VERSION}-Windows-x86_64 mingw 64 .exe
rm /tmp/icon.ico
rm /tmp/icon.png
rm /tmp/singe.res
# 32 Bit Raspbian
echo -e "${G_L}\nLinux armv6\n${G_L}"
SYSROOT="/opt/cross/pi/buster"
CROSS="/opt/cross/pi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf"
CCOMPILER="gcc"
CPPCOMPILER="g++"
EXTRA_CFLAGS="-O2 --sysroot ${SYSROOT}"
EXTRA_OFILES=""
EXTRA_LD_FLAGS="--sysroot ${SYSROOT} -l:everything.a -Wl,-rpath-link,${SYSROOT}/opt/vc/lib -L${SYSROOT}/opt/vc/lib -lbcm_host -lasound -lpthread -lm -ldl -lsndio -lmmal_core -lmmal_util -lmmal_vc_client -lvdpau -ldrm -lgbm -lX11 -lsamplerate"
doBuild Singe-${G_VERSION}-Pi-armv6 pi 32
# 32 Bit macOS
echo -e "${G_L}\nmacOS i386\n${G_L}"
CROSS="i386-apple-darwin15"
CCOMPILER="clang"
CPPCOMPILER="clang++"
EXTRA_CFLAGS="-O2"
EXTRA_LD_FLAGS="-Wl,-no_pie -stdlib=libc++ -leverything -lm -liconv -Wl,-framework,CoreAudio -Wl,-framework,AudioUnit -Wl,-framework,AudioToolbox -Wl,-framework,ForceFeedback -lobjc -Wl,-framework,CoreVideo -Wl,-framework,Cocoa -Wl,-framework,Carbon -Wl,-framework,IOKit -Wl,-weak_framework,QuartzCore -Wl,-weak_framework,Metal"
O_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET}
export MACOSX_DEPLOYMENT_TARGET=10.8
doBuild Singe-${G_VERSION}-macOS-i386 mac 32
export MACOSX_DEPLOYMENT_TARGET=${O_MACOSX_DEPLOYMENT_TARGET}
# 64 Bit macOS
echo -e "${G_L}\nmacOS x86_64\n${G_L}"
CROSS="x86_64-apple-darwin15"
CCOMPILER="clang"
CPPCOMPILER="clang++"
EXTRA_CFLAGS="-O2"
EXTRA_LD_FLAGS="-stdlib=libc++ -leverything -lm -liconv -Wl,-framework,CoreAudio -Wl,-framework,AudioUnit -Wl,-framework,AudioToolbox -Wl,-framework,ForceFeedback -lobjc -Wl,-framework,CoreVideo -Wl,-framework,Cocoa -Wl,-framework,Carbon -Wl,-framework,IOKit -Wl,-weak_framework,QuartzCore -Wl,-weak_framework,Metal"
O_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET}
export MACOSX_DEPLOYMENT_TARGET=10.8
doBuild Singe-${G_VERSION}-macOS-x86_64 mac 64
export MACOSX_DEPLOYMENT_TARGET=${O_MACOSX_DEPLOYMENT_TARGET}