149 lines
4.6 KiB
Bash
149 lines
4.6 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 ---
|
|
|
|
|
|
|
|
function doPCBuild() {
|
|
|
|
local TARGET=
|
|
|
|
if [[ -z ${RESULTS} ]]; then
|
|
TARGET=${JOEY}/builds/${PROJECT}
|
|
else
|
|
TARGET=${RESULTS}
|
|
fi
|
|
|
|
local WORK=/tmp/PC
|
|
|
|
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 (JoeyLib listed twice on purpose.)
|
|
${CC} -o ${DEST}/${PROJECT}${EXT} ${OFILES} \
|
|
${JOEY}/dist/${OSNAME}/${OSARCH}/libjoeylib.a ${LDFLAGS} ${JOEY}/dist/${OSNAME}/${OSARCH}/libjoeylib.a
|
|
|
|
# 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="-mwindows -static -Wl,--start-group -lmingw32 -lgdi32 -lwinmm -limm32 -lversion -lole32 -loleaut32 -lsetupapi -lstdc++ -Wl,--end-group"
|
|
doPCBuild windows i386 '.exe'
|
|
}
|
|
|
|
|
|
function buildWindows64() {
|
|
CC="x86_64-w64-mingw32-gcc"
|
|
CFLAGS=""
|
|
LDFLAGS="-mwindows -static -Wl,--start-group -lmingw32 -lgdi32 -lwinmm -limm32 -lversion -lole32 -loleaut32 -lsetupapi -lstdc++ -Wl,--end-group"
|
|
doPCBuild windows x64 '.exe'
|
|
}
|
|
|
|
|
|
function buildmacOSA64() {
|
|
export MACOSX_DEPLOYMENT_TARGET="${MACOSX_APPLE_DEPLOYMENT_TARGET}"
|
|
export MACOSX_DARWIN="${MACOSX_APPLE_DARWIN}"
|
|
export PATH="${MACOSX_APPLE_PATH}:${JOEYPATH}"
|
|
export LD_LIBRARY_PATH="${MACOSX_APPLE_PATH}/../lib"
|
|
CC="oa64-clang"
|
|
CFLAGS=""
|
|
LDFLAGS="-lm -liconv -Wl,-framework,CoreAudio -Wl,-framework,AudioToolbox -Wl,-weak_framework,CoreHaptics -Wl,-weak_framework,GameController -Wl,-framework,ForceFeedback -lobjc -Wl,-framework,CoreVideo -Wl,-framework,Cocoa -Wl,-framework,Carbon -Wl,-framework,IOKit -Wl,-weak_framework,QuartzCore"
|
|
doPCBuild macOS a64 ''
|
|
export LD_LIBRARY_PATH=
|
|
}
|
|
|
|
|
|
function buildmacOSX32() {
|
|
export MACOSX_DEPLOYMENT_TARGET="${MACOSX_INTEL_DEPLOYMENT_TARGET}"
|
|
export MACOSX_DARWIN="${MACOSX_INTEL_DARWIN}"
|
|
export PATH="${MACOSX_INTEL_PATH}:${JOEYPATH}"
|
|
export LD_LIBRARY_PATH="${MACOSX_INTEL_PATH}/../lib"
|
|
CC="o32-clang"
|
|
CFLAGS=""
|
|
LDFLAGS="-lm -liconv -Wl,-framework,CoreAudio -Wl,-framework,AudioToolbox -Wl,-framework,ForceFeedback -lobjc -Wl,-framework,CoreVideo -Wl,-framework,Cocoa -Wl,-framework,Carbon -Wl,-framework,IOKit -Wl,-weak_framework,QuartzCore"
|
|
doPCBuild macOS i386 ''
|
|
export LD_LIBRARY_PATH=
|
|
}
|
|
|
|
|
|
function buildmacOSX64() {
|
|
export MACOSX_DEPLOYMENT_TARGET="${MACOSX_INTEL_DEPLOYMENT_TARGET}"
|
|
export MACOSX_DARWIN="${MACOSX_INTEL_DARWIN}"
|
|
export PATH="${MACOSX_INTEL_PATH}:${JOEYPATH}"
|
|
export LD_LIBRARY_PATH="${MACOSX_INTEL_PATH}/../lib"
|
|
CC="o64-clang"
|
|
CFLAGS=""
|
|
LDFLAGS="-lm -liconv -Wl,-framework,CoreAudio -Wl,-framework,AudioToolbox -Wl,-framework,ForceFeedback -lobjc -Wl,-framework,CoreVideo -Wl,-framework,Cocoa -Wl,-framework,Carbon -Wl,-framework,IOKit -Wl,-weak_framework,QuartzCore"
|
|
doPCBuild macOS x64 ''
|
|
export LD_LIBRARY_PATH=
|
|
}
|