134 lines
3.4 KiB
Bash
134 lines
3.4 KiB
Bash
#
|
|
# JoeyLib
|
|
# Copyright (C) 2018-2019 Scott Duensing <scott@kangaroopunch.com>
|
|
#
|
|
# This software is provided 'as-is', without any express or implied
|
|
# warranty. In no event will the authors be held liable for any damages
|
|
# arising from the use of this software.
|
|
#
|
|
# Permission is granted to anyone to use this software for any purpose,
|
|
# including commercial applications, and to alter it and redistribute it
|
|
# freely, subject to the following restrictions:
|
|
#
|
|
# 1. The origin of this software must not be misrepresented; you must not
|
|
# claim that you wrote the original software. If you use this software
|
|
# in a product, an acknowledgment in the product documentation would be
|
|
# appreciated but is not required.
|
|
# 2. Altered source versions must be plainly marked as such, and must not be
|
|
# misrepresented as being the original software.
|
|
# 3. This notice may not be removed or altered from any source distribution.
|
|
#
|
|
|
|
# --- HERE BE DRAGONS ---
|
|
|
|
TARGET=${JOEY}/builds/${PROJECT}
|
|
WORK=/tmp/PC
|
|
|
|
|
|
function doPCBuild() {
|
|
|
|
local OSNAME=$1
|
|
local OSARCH=$2
|
|
local EXT=$3
|
|
|
|
local DEST=${TARGET}/${OSNAME}/${OSARCH}
|
|
local G_CFLAGS="-Wall -D_REENTRANT_ -I${JOEY}/dist"
|
|
|
|
echo '-------------------------------------------------------------------------------'
|
|
echo "Building ${OSNAME} ${OSARCH}"
|
|
echo '-------------------------------------------------------------------------------'
|
|
|
|
# Clean up target and working directories
|
|
if [ -d ${DEST} ]; then
|
|
rm -rf ${DEST}
|
|
fi
|
|
mkdir -p ${DEST}
|
|
if [ -d ${WORK} ]; then
|
|
rm -rf ${WORK}
|
|
fi
|
|
mkdir -p ${WORK}
|
|
|
|
# Make a list of files to compile, iterate over them
|
|
CFILES=($(ls -1 *.c))
|
|
OFILES=""
|
|
for F in "${CFILES[@]}"; do
|
|
O=${F%.*}
|
|
OFILES="${OFILES} ${WORK}/${O}.o"
|
|
echo "Compiling ${F}..."
|
|
${CC} ${CFLAGS} ${G_CFLAGS} -c ${F} -o ${WORK}/${O}.o
|
|
done
|
|
|
|
# Link source & JoeyLib
|
|
${CC} -o ${DEST}/${PROJECT}${EXT} ${OFILES} ${JOEY}/dist/${OSNAME}/${OSARCH}/libjoeylib.a ${LDFLAGS}
|
|
|
|
# Copy game data
|
|
mkdir -p ${DEST}/data
|
|
for F in "${DATA[@]}"; do
|
|
cp -f ${F} ${DEST}/data/.
|
|
done
|
|
}
|
|
|
|
|
|
function buildLinux32() {
|
|
CC="gcc"
|
|
CFLAGS="-m32"
|
|
LDFLAGS="-m32 -lstdc++ -lm -ldl -lpthread"
|
|
doPCBuild linux i386 ''
|
|
}
|
|
|
|
|
|
function buildLinux64() {
|
|
CC="gcc"
|
|
CFLAGS=""
|
|
LDFLAGS="-lstdc++ -lm -ldl -lpthread"
|
|
doPCBuild linux x64 ''
|
|
}
|
|
|
|
|
|
function buildWindows32() {
|
|
CC="i686-w64-mingw32-gcc"
|
|
CFLAGS=""
|
|
LDFLAGS="-lgdi32 -lwinmm -limm32 -lversion -lole32 -loleaut32 -lsetupapi -static -lstdc++"
|
|
doPCBuild windows i386 '.exe'
|
|
}
|
|
|
|
|
|
function buildWindows64() {
|
|
CC="x86_64-w64-mingw32-gcc"
|
|
CFLAGS=""
|
|
LDFLAGS="-lgdi32 -lwinmm -limm32 -lversion -lole32 -loleaut32 -lsetupapi -static -lstdc++"
|
|
doPCBuild windows x64 '.exe'
|
|
}
|
|
|
|
|
|
function buildmacOSA64() {
|
|
export MACOSX_DEPLOYMENT_TARGET="${MACOSX_APPLE_DEPLOYMENT_TARGET}"
|
|
export MACOSX_DARWIN="${MACOSX_APPLE_DARWIN}"
|
|
export PATH="${JOEYPATH}:${MACOSX_APPLE_PATH}"
|
|
CC="oa64-clang"
|
|
CFLAGS=""
|
|
LDFLAGS=""
|
|
doPCBuild macos a64 ''
|
|
}
|
|
|
|
|
|
function buildmacOSX32() {
|
|
export MACOSX_DEPLOYMENT_TARGET="${MACOSX_INTEL_DEPLOYMENT_TARGET}"
|
|
export MACOSX_DARWIN="${MACOSX_INTEL_DARWIN}"
|
|
export PATH="${JOEYPATH}:${MACOSX_INTEL_PATH}"
|
|
CC="o32-clang"
|
|
CFLAGS=""
|
|
LDFLAGS=""
|
|
doPCBuild macos i386 ''
|
|
}
|
|
|
|
|
|
function buildmacOSX64() {
|
|
export MACOSX_DEPLOYMENT_TARGET="${MACOSX_INTEL_DEPLOYMENT_TARGET}"
|
|
export MACOSX_DARWIN="${MACOSX_INTEL_DARWIN}"
|
|
export PATH="${JOEYPATH}:${MACOSX_INTEL_PATH}"
|
|
CC="o64-clang"
|
|
CFLAGS=""
|
|
LDFLAGS=""
|
|
doPCBuild macos x64 ''
|
|
}
|