#!/bin/bash # # JoeyBuild # Copyright (C) 2018-2023 Scott Duensing # # 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. # M_SDL2_TAG=97a5e744497ff7cc93edc5119d67cad3ee86dd57 M_TRIPLE="x86_64-linux-gnu" source ${G_EHOME}/helpers/SDL2.helper source ${G_EHOME}/helpers/GCC.helper function architectures() { echo "i386 x86_64" } function assemble() { local ARCH=$1 local PASS=$2 local LOG=$3 local AFILES=(${*:4}) setCompiler ${ARCH} ${PASS} assembleGCC ${ARCH} ${PASS} ${LOG} "${AFILES[@]}" unSetCompiler } function buildJoeyLib() { local ARCH=$1 local PASS=$2 export CFLAGS="-Wall -static-libgcc -D_REENTRANT_ -I${G_INSTALLED}/include -c" export LDFLAGS="-lm -ldl -lpthread" if [[ "${ARCH}" == "i386" ]]; then export CFLAGS="-m32 ${CFLAGS}" fi if [[ "${PASS}" == "debug" ]]; then export CFLAGS="-DJOEY_DEBUG ${CFLAGS}" fi setCompiler ${ARCH} ${PASS} buildJoeyLibSDL2 ${PASS} unSetCompiler } function compile() { local ARCH=$1 local PASS=$2 local LOG=$3 local CFILES=(${*:4}) if [[ "${ARCH}" == "i386" ]]; then export CFLAGS="-m32 -Wall -D_REENTRANT_" else export CFLAGS="-Wall -D_REENTRANT_" fi setCompiler ${ARCH} ${PASS} compileGCC ${ARCH} ${PASS} ${LOG} "${CFILES[@]}" unSetCompiler } function enabled() { echo 1 } function friendlyName() { echo "Linux" } function install() { local ARCH=$1 local PASS=$2 if [[ "${ARCH}" == "i386" ]]; then export CFLAGS="-m32" fi # Do not call setCompiler here! buildSDL2 ${M_SDL2_TAG} ${M_TRIPLE} } function link() { local ARCH=$1 local PASS=$2 local LOG=$3 local OFILES=(${*:4}) if [[ "${ARCH}" == "i386" ]]; then export CFLAGS="-m32" else export CFLAGS= fi export LDFLAGS="-lm -ldl -lpthread" setCompiler ${ARCH} ${PASS} linkGCC Linux ${ARCH} ${PASS} "" "" ${LOG} "${OFILES[@]}" unSetCompiler } function package() { local ARCH=$1 local PASS=$2 local LOG=$3 local DFILES=(${*:4}) packageGCC Linux ${ARCH} ${PASS} ${LOG} "${DFILES[@]}" } function setCompiler() { local ARCH=$1 local PASS=$2 export CC=${M_TRIPLE}-gcc export LD=${M_TRIPLE}-gcc export AR=${M_TRIPLE}-ar } function unSetCompiler() { export CC= export LD= export AR= export LDFLAGS= export CFLAGS= }