From 991bf65af6357b003de8920b5a98bab58a353d6e Mon Sep 17 00:00:00 2001 From: Scott Duensing Date: Tue, 16 Apr 2019 19:13:38 -0500 Subject: [PATCH] Working on Windows and IIgs build systems. --- buildPCDeps.sh | 185 +++++++++++++++++++++++++++++++++++ joeylib/build-IIgs.helper.sh | 119 +++++++++++----------- joeylib/build-PC.helper.sh | 91 +++++++++++++++++ joeylib/build-PC.sh | 92 ++++++++++------- 4 files changed, 394 insertions(+), 93 deletions(-) create mode 100755 buildPCDeps.sh create mode 100644 joeylib/build-PC.helper.sh diff --git a/buildPCDeps.sh b/buildPCDeps.sh new file mode 100755 index 0000000..0103072 --- /dev/null +++ b/buildPCDeps.sh @@ -0,0 +1,185 @@ +#!/bin/bash -e + +function clearBuild() { + if [ -d ${JOEY}/SDL2/build ]; then + rm -rf ${JOEY}/SDL2/build + fi + mkdir -p ${JOEY}/SDL2/build +} + + +function clearInstalled() { + if [ -d ${JOEY}/SDL2/installed ]; then + rm -rf ${JOEY}/SDL2/installed + fi + mkdir -p ${JOEY}/SDL2/installed +} + + +function checkFiles() { + if [ ! -d SDL ]; then + hg clone http://hg.libsdl.org/SDL + cd SDL + #hg up release-2.0.9 + cd .. + fi + if [ ! -d libmodplug ]; then + git clone https://github.com/Konstanty/libmodplug.git + cd libmodplug + libtoolize --force + aclocal + autoheader + automake --force-missing --add-missing + autoconf + cd .. + fi + if [ ! -d SDL_mixer ]; then + hg clone http://hg.libsdl.org/SDL_mixer + cd SDL_mixer + #hg up release-2.0.4 + cd .. + fi +} + + +function doBuild() { + clearBuild + cd build + ../SDL/configure \ + --target="${CROSS}" \ + --host="${CROSS}" \ + --build=x86_64-linux \ + --enable-static \ + --disable-shared \ + --prefix=${PREFIX} + make + make install + cd .. + + clearBuild + cd build + ../libmodplug/configure \ + --target="${CROSS}" \ + --host="${CROSS}" \ + --build=x86_64-linux \ + --enable-static \ + --disable-shared \ + --prefix=${PREFIX} + make + make install + cd .. + + clearBuild + cd build + MODPLUG_CFLAGS="-I${PREFIX}/include -DMODPLUG_STATIC" \ + MODPLUG_LIBS="-L${PREFIX}/lib -lmodplug -lstdc++ -lm" \ + ../SDL_mixer/configure \ + --target="${CROSS}" \ + --host="${CROSS}" \ + --build=x86_64-linux \ + --enable-static \ + --disable-shared \ + --prefix=${PREFIX} \ + --with-sdl-prefix=${PREFIX} \ + --disable-music-cmd \ + --disable-music-wave \ + --enable-music-mod-modplug \ + --disable-music-mod-modplug-shared \ + --disable-music-mod-mikmod \ + --disable-music-midi \ + --disable-music-ogg \ + --disable-music-flac \ + --disable-music-opus \ + --disable-music-mp3 \ + --disable-music-mp3-mpg123 + make + make install + cd .. +} + + +ARCH=$1 + +if [ "${ARCH}x" == "x" ]; then + echo "$0 [arch | \"all\"] | [reset]" + echo '(Where "arch" is linux32, linux64, windows32, windows64, macos32, or macos64.)' + exit 0 +fi + +set -x + +mkdir -p ${JOEY}/SDL2 +pushd ${JOEY}/SDL2 + +checkFiles + +if [ "${ARCH}x" == "resetx" ]; then + clearInstalled +fi + +if [ "${ARCH}x" == "allx" ] || [ "${ARCH}x" == "linux64x" ]; then + TARGET=${JOEY}/joeylib/joeylib/lib/linux/x64 + PREFIX=${JOEY}/SDL2/installed/linux/x64 + CROSS=x86_64-linux-gnu + export CC="${CROSS}-gcc" + export CXX="${CROSS}-g++" + doBuild +fi + +if [ "${ARCH}x" == "allx" ] || [ "${ARCH}x" == "linux32x" ]; then + TARGET=${JOEY}/joeylib/joeylib/lib/linux/x86 + PREFIX=${JOEY}/SDL2/installed/linux/x86 + CROSS=x86_64-linux-gnu + export CC="${CROSS}-gcc -m32" + export CXX="${CROSS}-g++ -m32" + doBuild +fi + +if [ "${ARCH}x" == "allx" ] || [ "${ARCH}x" == "windows64x" ]; then + TARGET=${JOEY}/joeylib/joeylib/lib/windows/x64 + PREFIX=${JOEY}/SDL2/installed/windows/x64 + CROSS=x86_64-w64-mingw32 + export CC="${CROSS}-gcc -static-libgcc" + export CXX="${CROSS}-g++ -static-libstdc++" +doBuild +fi + +if [ "${ARCH}x" == "allx" ] || [ "${ARCH}x" == "windows32x" ]; then + TARGET=${JOEY}/joeylib/joeylib/lib/windows/x86 + PREFIX=${JOEY}/SDL2/installed/windows/x86 + CROSS=i686-w64-mingw32 + export CC="${CROSS}-gcc -static-libgcc" + doBuild +fi + +if [ "${ARCH}x" == "allx" ] || [ "${ARCH}x" == "macos64x" ]; then + TARGET=${JOEY}/joeylib/joeylib/lib/macos/x64 + PREFIX=${JOEY}/SDL2/installed/macos/x64 + CROSS=x86_64-apple-darwin15 + export CC="o64-clang" + doBuild +fi + +if [ "${ARCH}x" == "allx" ] || [ "${ARCH}x" == "macos32x" ]; then + TARGET=${JOEY}/joeylib/joeylib/lib/macos/x86 + PREFIX=${JOEY}/SDL2/installed/macos/x86 + CROSS=i386-apple-darwin15 + export CC="o32-clang" + doBuild +fi + +#if [ "${ARCH}x" == "allx" ] || [ "${ARCH}x" == "raspbian" ]; then + #***FIX*** + #TARGET=${JOEY}/joeylib/joeylib/pi/raspbian + #PREFIX=${JOEY}/SDL2/installed/pi/raspbian + #CROSS=arm-linux-gnueabihf + #export CC="${CROSS}-gcc -static-libgcc --sysroot=${JOEY}/sdks/pi/raspbian -I${PREFIX}/include -L${PREFIX}/lib" + #doBuild +#fi + +export CXX="" +export CC="" +rm -rf build +popd +set +x + diff --git a/joeylib/build-IIgs.helper.sh b/joeylib/build-IIgs.helper.sh index 59f6b6d..2539f27 100755 --- a/joeylib/build-IIgs.helper.sh +++ b/joeylib/build-IIgs.helper.sh @@ -1,57 +1,56 @@ # --- HERE BE DRAGONS --- -TARGET=${JOEY}/sdks/iix/IIgs/out/${PROJECT} -GSTARGET=31:/out/${PROJECT} -CADIUS=${JOEY}/sdks/iix/cadius-git/bin/release/cadius -VOL=Import -WORK=/tmp/IIgs -IMPORT=${WORK}/import.po +function buildIIgs() { + TARGET=${JOEY}/sdks/iix/IIgs/out/${PROJECT} + GSTARGET=31:/out/${PROJECT} + CADIUS=${JOEY}/sdks/iix/cadius-git/bin/release/cadius + VOL=Import + WORK=/tmp/IIgs + IMPORT=${WORK}/import.po -# Clean up target and working directories -if [ -d ${TARGET} ]; then - rm -rf ${TARGET} -fi -mkdir -p ${TARGET} - -if [ -d ${WORK} ]; then - rm -rf ${WORK} -fi -mkdir -p ${WORK} - -# We temporarily need a local copy of the joey header -cp -f ${JOEY}/dist/joey.h . - -# Make a list of files to compile, iterate over them -CFILES=($(ls -1 *.c)) -OFILES="" -for F in "${CFILES[@]}"; do - O=${F%.*} - # If this file is named 'main' we don't add it to the link list until later - if [ "${O}" != "main" ]; then - OFILES="${OFILES} ${GSTARGET}/${O}" + # Clean up target and working directories + if [ -d ${TARGET} ]; then + rm -rf ${TARGET} fi - echo "Compiling ${F}..." - iix compile ${F} keep=${GSTARGET}/${O} -done -# Be sure 'main' is first in the link list -OFILES="${GSTARGET}/main ${OFILES} ${GSTARGET}/joeylib" + mkdir -p ${TARGET} -# Clean up -rm joey.h + if [ -d ${WORK} ]; then + rm -rf ${WORK} + fi + mkdir -p ${WORK} -# We need a local copy of joeylib to link -cp -f ${JOEY}/dist/IIgs/joeylib#b20000 ${TARGET}/joeylib -iix chtyp -t lib ${GSTARGET}/joeylib + # We temporarily need a local copy of the joey header + cp -f ${JOEY}/dist/joey.h . -# Link our program and create a map file -iix -DKeepType=S16 link +L ${OFILES} keep=${GSTARGET}/${PROJECT}#b30000 > ${PROJECT}.map + # Make a list of files to compile, iterate over them + CFILES=($(ls -1 *.c)) + OFILES="" + for F in "${CFILES[@]}"; do + O=${F%.*} + # If this file is named 'main' we don't add it to the link list until later + if [ "${O}" != "main" ]; then + OFILES="${OFILES} ${GSTARGET}/${O}" + fi + echo "Compiling ${F}..." + iix compile ${F} keep=${GSTARGET}/${O} + done + # Be sure 'main' is first in the link list + OFILES="${GSTARGET}/main ${OFILES} ${GSTARGET}/joeylib" -# Create a disassembly and linker input listing -iix dumpobj +D ${GSTARGET}/${PROJECT}#b30000 &> ${PROJECT}.dis || true -echo ${OFILES} > ${PROJECT}.lnk + # Clean up + rm joey.h + + # We need a local copy of joeylib to link + cp -f ${JOEY}/dist/IIgs/joeylib#b20000 ${TARGET}/joeylib + iix chtyp -t lib ${GSTARGET}/joeylib + + # Link our program and create a map file + iix -DKeepType=S16 link +L ${OFILES} keep=${GSTARGET}/${PROJECT}#b30000 > ${PROJECT}.map + + # Create a disassembly and linker input listing + iix dumpobj +D ${GSTARGET}/${PROJECT}#b30000 &> ${PROJECT}.dis || true + echo ${OFILES} > ${PROJECT}.lnk -# Did they ask for GSPlus to be executed? -if [ ! -z $1 ]; then # Be sure our work directories exists mkdir -p ${WORK}/{data,source} @@ -75,16 +74,22 @@ if [ ! -z $1 ]; then done done - # Launch GSPlus - pushd ${JOEY}/sdks/iix/gsplus - ./gsplus -resizeable -config IIgsTest.cfg || true - popd - - # Extract and display the results of the run - ${CADIUS} extractfile ${IMPORT} ${VOL}/JLSTATS ${WORK}/. > /dev/null - if [ -e ${WORK}/JLSTATS#040000 ]; then - echo "" - cat ${WORK}/JLSTATS#040000 | tr "\r" "\n" 2> /dev/null - echo "" + mkdir -p ${JOEY}/builds/${PROJECT}/IIgs/ + cp ${IMPORT} ${JOEY}/builds/${PROJECT}/IIgs/${PROJECT}.po + + # Did they ask for GSPlus to be executed? + if [ ! -z $1 ]; then + # Launch GSPlus + pushd ${JOEY}/sdks/iix/gsplus + ./gsplus -resizeable -config IIgsTest.cfg || true + popd + + # Extract and display the results of the run + ${CADIUS} extractfile ${IMPORT} ${VOL}/JLSTATS ${WORK}/. > /dev/null + if [ -e ${WORK}/JLSTATS#040000 ]; then + echo "" + cat ${WORK}/JLSTATS#040000 | tr "\r" "\n" 2> /dev/null + echo "" + fi fi -fi +} diff --git a/joeylib/build-PC.helper.sh b/joeylib/build-PC.helper.sh new file mode 100644 index 0000000..d158b89 --- /dev/null +++ b/joeylib/build-PC.helper.sh @@ -0,0 +1,91 @@ +# --- HERE BE DRAGONS --- + +TARGET=${JOEY}/builds/${PROJECT} +WORK=/tmp/PC + + +function doPCBuild() { + + local OSNAME=$1 + local OSARCH=$2 + + local DEST=${TARGET}/${OSNAME}/${OSARCH} + local G_CFLAGS="-Wall -D_REENTRANT_ -I${JOEY}/dist" + + # 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} ${OFILES} ${JOEY}/dist/${OSNAME}/${OSARCH}/libjoeylib.a -lstdc++ ${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="" + doPCBuild linux x86 +} + + +function buildLinux64() { + CC="gcc" + CFLAGS="" + LDFLAGS="-lm -lpthread -ldl" + doPCBuild linux x64 +} + + +function buildWindows32() { + CC="i686-w64-mingw32-gcc" + CFLAGS="" + LDFLAGS="-lgdi32 -lwinmm -limm32 -lversion -lole32 -loleaut32 -lsetupapi" + doPCBuild windows x86 +} + + +function buildWindows64() { + CC="x86_64-w64-mingw32-gcc" + CFLAGS="" + LDFLAGS="-lgdi32 -lwinmm -limm32 -lversion -lole32 -loleaut32 -lsetupapi" + doPCBuild windows x64 +} + + +function buildmacOS32() { + CC="o32-clang" + CFLAGS="" + LDFLAGS="" + doPCBuild macos x86 +} + + +function buildmacOS64() { + CC="o64-clang" + CFLAGS="" + LDFLAGS="" + doPCBuild macos x64 +} diff --git a/joeylib/build-PC.sh b/joeylib/build-PC.sh index e28e2a5..6fda1e4 100755 --- a/joeylib/build-PC.sh +++ b/joeylib/build-PC.sh @@ -35,47 +35,67 @@ function doBuild() { fi } -CC="gcc" -CFLAGS="" -LDFLAGS="" -DIST="${JOEY}/dist/linux/x64" -INSTALLED="${JOEY}/SDL2/installed/linux/x64/lib" -doBuild +ARCH=$1 -CC="gcc" -CFLAGS="-m32" -LDFLAGS="" -DIST="${JOEY}/dist/linux/x86" -INSTALLED="${JOEY}/SDL2/installed/linux/x86/lib" -doBuild +if [ "${ARCH}x" == "x" ]; then + echo "$0 [arch | \"all\"]" + echo '(Where "arch" is linux32, linux64, windows32, windows64, macos32, or macos64.)' + exit 0 +fi -CC="x86_64-w64-mingw32-gcc" -CFLAGS="" -LDFLAGS="" -DIST="${JOEY}/dist/windows/x64" -INSTALLED="${JOEY}/SDL2/installed/windows/x64/lib" -doBuild +if [ "${ARCH}x" == "allx" ] || [ "${ARCH}x" == "linux64x" ]; then + CC="gcc" + CFLAGS="" + LDFLAGS="" + DIST="${JOEY}/dist/linux/x64" + INSTALLED="${JOEY}/SDL2/installed/linux/x64/lib" + doBuild +fi -CC="i686-w64-mingw32-gcc" -CFLAGS="" -LDFLAGS="" -DIST="${JOEY}/dist/windows/x86" -INSTALLED="${JOEY}/SDL2/installed/windows/x86/lib" -doBuild +if [ "${ARCH}x" == "allx" ] || [ "${ARCH}x" == "linux32x" ]; then + CC="gcc" + CFLAGS="-m32" + LDFLAGS="" + DIST="${JOEY}/dist/linux/x86" + INSTALLED="${JOEY}/SDL2/installed/linux/x86/lib" + doBuild +fi -CC="o32-clang" -CFLAGS="" -LDFLAGS="" -DIST="${JOEY}/dist/macos/x86" -INSTALLED="${JOEY}/SDL2/installed/macos/x86/lib" -doBuild +if [ "${ARCH}x" == "allx" ] || [ "${ARCH}x" == "windows64x" ]; then + CC="x86_64-w64-mingw32-gcc" + CFLAGS="" + LDFLAGS="" + DIST="${JOEY}/dist/windows/x64" + INSTALLED="${JOEY}/SDL2/installed/windows/x64/lib" + doBuild +fi -CC="o64-clang" -CFLAGS="" -LDFLAGS="" -DIST="${JOEY}/dist/macos/x64" -INSTALLED="${JOEY}/SDL2/installed/macos/x64/lib" -doBuild +if [ "${ARCH}x" == "allx" ] || [ "${ARCH}x" == "windows32x" ]; then + CC="i686-w64-mingw32-gcc" + CFLAGS="" + LDFLAGS="" + DIST="${JOEY}/dist/windows/x86" + INSTALLED="${JOEY}/SDL2/installed/windows/x86/lib" + doBuild +fi + +if [ "${ARCH}x" == "allx" ] || [ "${ARCH}x" == "macos32x" ]; then + CC="o32-clang" + CFLAGS="" + LDFLAGS="" + DIST="${JOEY}/dist/macos/x86" + INSTALLED="${JOEY}/SDL2/installed/macos/x86/lib" + doBuild +fi + +if [ "${ARCH}x" == "allx" ] || [ "${ARCH}x" == "macos64x" ]; then + CC="o64-clang" + CFLAGS="" + LDFLAGS="" + DIST="${JOEY}/dist/macos/x64" + INSTALLED="${JOEY}/SDL2/installed/macos/x64/lib" + doBuild +fi cp -f ${JOEY}/joeylib/joeylib/src/joey.h ${JOEY}/dist/. cp -f ${JOEY}/joeylib/joeylib/joey.pri ${JOEY}/dist/.