454 lines
12 KiB
Bash
Executable file
454 lines
12 KiB
Bash
Executable file
#!/bin/bash -xe
|
|
|
|
#
|
|
# Singe 2
|
|
# Copyright (C) 2006-2024 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 Licens
|
|
# 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.
|
|
#
|
|
|
|
|
|
G_BUILDROOT=${PWD}
|
|
G_BUILDDIR=.builddir
|
|
G_TARGET=
|
|
G_GENERATED=
|
|
|
|
|
|
function buildAll() {
|
|
local OS=$1
|
|
local ARCH=$2
|
|
local COMMON=
|
|
|
|
# Activate toolchain for this platform.
|
|
source <(../toolchains/toolchains.sh use ${ARCH} ${OS})
|
|
|
|
G_TARGET=${G_BUILDROOT}/${G_BUILDDIR}/${OS}/${ARCH}
|
|
G_GENERATED=${G_TARGET}/generated
|
|
COMMON="-DCMAKE_INSTALL_PREFIX=${G_TARGET} -DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_FILE}"
|
|
# Add CMAKE_BUILD_TYPE to COMMON
|
|
|
|
export LDFLAGS="-L${G_TARGET}/lib ${LDFLAGS}"
|
|
export CFLAGS="-I${G_TARGET}/include ${CFLAGS}"
|
|
export CXXFLAGS="-I${G_TARGET}/include ${CXXFLAGS}"
|
|
export LD_LIBRARY_PATH="${G_TARGET}/lib"
|
|
export PKG_CONFIG_LIBDIR="${G_TARGET}/lib/pkgconfig"
|
|
|
|
mkdir -p ${G_GENERATED}
|
|
|
|
if [[ 0 == 1 ]]; then
|
|
pushd thirdparty/SDL2
|
|
clearAndEnterBuild
|
|
cmake ${COMMON} \
|
|
-DSDL_SHARED=off \
|
|
-DSDL_STATIC=on \
|
|
..
|
|
make install
|
|
popd
|
|
|
|
pushd thirdparty/SDL2_image
|
|
clearAndEnterBuild
|
|
cmake ${COMMON} \
|
|
-DBUILD_SHARED_LIBS=off \
|
|
-DSDL2IMAGE_DEPS_SHARED=off \
|
|
-DSDL2IMAGE_SAMPLES=off \
|
|
-DSDL2IMAGE_TESTS=off \
|
|
-DSDL2IMAGE_VENDORED=on \
|
|
-DSDL2IMAGE_AVIF=off \
|
|
-DSDL2IMAGE_JXL=off \
|
|
-DSDL2IMAGE_TIF=off \
|
|
-DSDL2IMAGE_WEBP=on \
|
|
-DSDL2_DIR=${G_TARGET}/lib/cmake/SDL2 \
|
|
..
|
|
make install
|
|
popd
|
|
#if [[ "${OS}" == "windows" ]]; then
|
|
# mv ${G_TARGET}/lib/libjxl_dec-static.a ${G_TARGET}/lib/libjxl_dec.a
|
|
#fi
|
|
|
|
pushd thirdparty/SDL2_mixer
|
|
clearAndEnterBuild
|
|
cmake ${COMMON} \
|
|
-DBUILD_SHARED_LIBS=off \
|
|
-DSDL2MIXER_CMD=off \
|
|
-DSDL2MIXER_DEPS_SHARED=off \
|
|
-DSDL2MIXER_VENDORED=on \
|
|
-DSDL2MIXER_SAMPLES=off \
|
|
-DSDL2_DIR=${G_TARGET}/lib/cmake/SDL2 \
|
|
-DWAVPACK_ENABLE_ASM=no \
|
|
..
|
|
make install
|
|
popd
|
|
|
|
pushd thirdparty/SDL2_ttf
|
|
clearAndEnterBuild
|
|
cmake ${COMMON} \
|
|
-DBUILD_SHARED_LIBS=off \
|
|
-DSDL2TTF_VENDORED=on \
|
|
-DSDL2TTF_HARFBUZZ=off \
|
|
-DSDL2TTF_SAMPLES=off \
|
|
-DSDL2_DIR=${G_TARGET}/lib/cmake/SDL2 \
|
|
..
|
|
make install
|
|
popd
|
|
|
|
pushd thirdparty/bzip2
|
|
clearAndEnterBuild
|
|
cmake ${COMMON} \
|
|
-DENABLE_SHARED_LIB=off \
|
|
-DENABLE_STATIC_LIB=on \
|
|
-DENABLE_LIB_ONLY=on \
|
|
..
|
|
make install
|
|
popd
|
|
|
|
pushd thirdparty/xz
|
|
clearAndEnterBuild
|
|
cmake ${COMMON} \
|
|
-DBUILD_SHARED_LIBS=off \
|
|
-DBUILD_TESTING=off \
|
|
..
|
|
make install
|
|
popd
|
|
|
|
pushd thirdparty/zlib
|
|
clearAndEnterBuild
|
|
../configure \
|
|
--prefix=${G_TARGET} \
|
|
--static
|
|
make install
|
|
popd
|
|
if [[ "${OS}" == "windows" ]]; then
|
|
mv ${G_TARGET}/lib/libzlibstatic.a ${G_TARGET}/lib/libz.a
|
|
fi
|
|
|
|
pushd thirdparty/zstd
|
|
clearAndEnterBuild
|
|
cmake ${COMMON} \
|
|
-DZSTD_BUILD_SHARED=off \
|
|
-DZSTD_BUILD_STATIC=on \
|
|
-DZSTD_BUILD_PROGRAMS=off \
|
|
../build/cmake
|
|
make install
|
|
popd
|
|
|
|
pushd thirdparty/libarchive
|
|
clearAndEnterBuild
|
|
cmake ${COMMON} \
|
|
-DBUILD_SHARED_LIBS=off \
|
|
-DBUILD_TESTING=off \
|
|
-DENABLE_CAT=off \
|
|
-DENABLE_CNG=off \
|
|
-DENABLE_CPIO=off \
|
|
-DENABLE_EXPAT=off \
|
|
-DENABLE_ICONV=off \
|
|
-DENABLE_LIBB2=off \
|
|
-DENABLE_LIBGCC=off \
|
|
-DENABLE_LIBXML2=off \
|
|
-DENABLE_LZ4=off \
|
|
-DENABLE_LZO=off \
|
|
-DENABLE_MBEDTLS=off \
|
|
-DENABLE_NETTLE=off \
|
|
-DENABLE_OPENSSL=off \
|
|
-DENABLE_PCREPOSIX=off \
|
|
-DENABLE_TAR=off \
|
|
-DENABLE_TEST=off \
|
|
-DENABLE_UNZIP=off \
|
|
-DBZIP2_INCLUDE_DIR="${G_TARGET}/include" \
|
|
-DLIBLZMA_INCLUDE_DIR="${G_TARGET}/include" \
|
|
-DZLIB_INCLUDE_DIR="${G_TARGET}/include" \
|
|
-DZSTD_INCLUDE_DIR="${G_TARGET}/include" \
|
|
-DZSTD_LIBRARY="${G_TARGET}/lib/libzstd.a" \
|
|
-DWINDOWS_VERSION=VISTA \
|
|
..
|
|
popd
|
|
|
|
pushd thirdparty/openssl
|
|
clearAndEnterBuild
|
|
# --cross-compile-prefix="${TRIPLE}-" \
|
|
../Configure \
|
|
--prefix="${G_TARGET}" \
|
|
--libdir=lib \
|
|
--with-zlib-include="${G_TARGET}/include" \
|
|
--with-zlib-lib="${G_TARGET}/lib" \
|
|
--with-zstd-include="${G_TARGET}/include" \
|
|
--with-zstd-lib="${G_TARGET}/lib" \
|
|
no-apps \
|
|
no-docs \
|
|
no-dso \
|
|
no-dynamic-engine \
|
|
no-module \
|
|
no-shared \
|
|
no-tests \
|
|
zlib \
|
|
enable-zstd
|
|
make install
|
|
popd
|
|
|
|
lua thirdparty/luasec/src/options.lua -g "${G_TARGET}/include/openssl/ssl.h" > "${G_TARGET}/generated/luasec_options.c"
|
|
mkdir -p "${G_TARGET}/include/luasocket"
|
|
cp -f \
|
|
thirdparty/luasocket/src/*.h \
|
|
"${G_TARGET}/include/luasocket/."
|
|
|
|
pushd thirdparty/ffmpeg
|
|
clearAndEnterBuild
|
|
# https://trac.ffmpeg.org/wiki/CompilationGuide/CrossCompilingForWindows
|
|
../configure \
|
|
--enable-static \
|
|
--disable-shared \
|
|
--disable-debug \
|
|
--disable-muxers \
|
|
--disable-hwaccels \
|
|
--disable-encoders \
|
|
--disable-filters \
|
|
--disable-network \
|
|
--disable-devices \
|
|
--disable-doc \
|
|
--disable-programs \
|
|
--enable-gpl \
|
|
--enable-version3 \
|
|
--extra-ldflags="-L${G_TARGET}/lib" \
|
|
--prefix=${G_TARGET} \
|
|
--arch=${ARCH} \
|
|
--target-os=${CROSS_OS} \
|
|
--cross-prefix=${TRIPLE}- \
|
|
--cc="${CC}" \
|
|
--cxx="${CXX}" \
|
|
--ranlib="${RANLIB}"
|
|
#" -l:libz.a -l:liblzma.a" \
|
|
make install
|
|
popd
|
|
|
|
pushd thirdparty/ffms2
|
|
#libtoolize --force
|
|
#aclocal
|
|
#autoheader
|
|
#automake --force-missing --add-missing
|
|
#autoupdate
|
|
#autoconf
|
|
#./autogen.sh
|
|
#make distclean || true
|
|
clearAndEnterBuild
|
|
../configure \
|
|
--prefix=${G_TARGET} \
|
|
--with-zlib=${G_TARGET} \
|
|
--enable-static \
|
|
--disable-shared \
|
|
--target=${TRIPLE} \
|
|
--host=${TRIPLE} \
|
|
--build=x86_64-linux
|
|
make install-libLTLIBRARIES # This weird target prevents building the command line tools.
|
|
popd
|
|
|
|
# === Known FFMPEG Types ===
|
|
createExtensionHeader ffmpeg > ${G_GENERATED}/extensions.h
|
|
|
|
# === Overlay Font ===
|
|
createEmbeddedImage font
|
|
|
|
# === Window Icon ===
|
|
createEmbeddedImage icon
|
|
|
|
# === Kangaroo Punch Logo ===
|
|
createEmbeddedImage kangarooPunchLogo
|
|
|
|
# === Singe Logo ===
|
|
createEmbeddedImage singeLogo
|
|
|
|
# === Laser Disc ===
|
|
createEmbeddedImage laserDisc
|
|
|
|
# === Magnifying Glass ===
|
|
createEmbeddedImage magnifyingGlass
|
|
|
|
# === "Indexing" Text ===
|
|
createEmbeddedImage indexing
|
|
|
|
# === Singe Framework ===
|
|
createEmbeddedBinary assets/Framework.singe ${G_GENERATED}/Framework_singe.h FRAMEWORK_SINGE_H
|
|
|
|
# === Default Config ===
|
|
createEmbeddedBinary assets/controls.cfg ${G_GENERATED}/controls_cfg.h CONTROLS_CFG_H
|
|
|
|
# === Singe Menu App ===
|
|
createEmbeddedBinary assets/Menu.singe ${G_GENERATED}/Menu_singe.h MENU_SINGE_H
|
|
|
|
# === Singe Menu Font ===
|
|
createEmbeddedBinary assets/FreeSansBold.ttf ${G_GENERATED}/FreeSansBold_ttf.h FREESANSBOLD_TTF_H
|
|
|
|
# === Singe Menu Background Video ===
|
|
ffmpeg -i "assets/Singe Engine Intro.mpg" -filter:v 'crop=ih/3*4:ih' -vf scale=720:480 -c:v libx264 -c:a aac -f matroska ${G_TARGET}/temp1.mkv
|
|
ffmpeg -i assets/180503_01_PurpleGrid.mp4 -filter:v 'crop=ih/3*4:ih' -vf scale=720:480 -c:v libx264 -c:a aac -f matroska ${G_TARGET}/temp2.mkv
|
|
ffmpeg -f concat -safe 0 -i <(echo -e "file ${G_TARGET}/temp1.mkv\nfile ${G_TARGET}/temp2.mkv\n") -c copy ${G_TARGET}/menuBackground.mkv
|
|
createEmbeddedBinary ${G_TARGET}/menuBackground.mkv ${G_GENERATED}/menuBackground_mkv.h MENUBACKGROUND_MKV_H
|
|
rm ${G_TARGET}/temp1.mkv ${G_TARGET}/temp2.mkv ${G_TARGET}/menuBackground.mkv
|
|
|
|
:<<UNUSED
|
|
# === Singe Manual ===
|
|
#libreoffice --headless "-env:UserInstallation=file:///tmp/LibreOffice_Conversion_${USER}" --convert-to pdf:writer_pdf_Export Manual.odt
|
|
documentbuilder makePDFs.docbuilder
|
|
mv /tmp/Manual.pdf ${G_TARGET}/.
|
|
createEmbeddedBinary ${G_TARGET}/Manual.pdf ${G_GENERATED}/Manual_pdf.h MANUAL_H
|
|
rm ${G_TARGET}/Manual.pdf
|
|
UNUSED
|
|
fi
|
|
|
|
pushd ${G_TARGET}
|
|
clearAndEnterBuild
|
|
cmake ${COMMON} ${G_BUILDROOT}
|
|
make
|
|
#upx -9 singe2${SUFFIX}
|
|
mv -f singe2${SUFFIX} ${G_BUILDROOT}/${G_BUILDDIR}/Singe-v2.10-${OS^}-${ARCH}${SUFFIX}
|
|
popd
|
|
}
|
|
|
|
|
|
function clearAndEnterBuild() {
|
|
[[ -d ${G_BUILDDIR} ]] && rm -rf ${G_BUILDDIR}
|
|
mkdir -p ${G_BUILDDIR}
|
|
cd ${G_BUILDDIR}
|
|
}
|
|
|
|
|
|
function createEmbeddedBinary() {
|
|
local BINFILE=$1
|
|
local SOURCEFILE=$2 # This is assumed to be an absolute path
|
|
local BLOCKER=$3
|
|
local FILENAME=$(basename ${BINFILE})
|
|
local DIRNAME=$(dirname ${BINFILE})
|
|
|
|
outputLicense > ${SOURCEFILE}
|
|
outputHeader ${BLOCKER} >> ${SOURCEFILE}
|
|
printf "\n#ifdef EMBED_HERE\n\n" >> ${SOURCEFILE}
|
|
pushd ${DIRNAME}
|
|
xxd -i ${FILENAME} >> ${SOURCEFILE}
|
|
popd
|
|
printf "\n#else // EMBED_HERE\n\n" >> ${SOURCEFILE}
|
|
printf "extern unsigned char ${FILENAME/\./_}[];\n" >> ${SOURCEFILE}
|
|
printf "extern unsigned int ${FILENAME/\./_}_len;\n" >> ${SOURCEFILE}
|
|
printf "\n#endif // EMBED_HERE\n\n" >> ${SOURCEFILE}
|
|
outputFooter ${BLOCKER} >> ${SOURCEFILE}
|
|
}
|
|
|
|
|
|
function createEmbeddedImage() {
|
|
local BASENAME=$1
|
|
|
|
pushd assets
|
|
convert -flatten -background rgba\(0,0,0,0\) ${BASENAME}.xcf ${G_GENERATED}/${BASENAME}.png
|
|
createEmbeddedBinary ${G_GENERATED}/${BASENAME}.png ${G_GENERATED}/${BASENAME}.h ${BASENAME^^}_H
|
|
rm ${G_GENERATED}/${BASENAME}.png
|
|
popd
|
|
}
|
|
|
|
|
|
function createExtensionHeader() {
|
|
local FFMPEG=$1
|
|
local a=
|
|
local c=0
|
|
|
|
outputLicense
|
|
outputHeader FFMPEG_EXTENSIONS_H
|
|
printf "static char *ffmpegExtensions[] = {\n"
|
|
printf "\t"
|
|
getExtensions "${FFMPEG}" | sort | uniq -u | while read a; do
|
|
printf "\"${a}\", "
|
|
c=$((c + 1))
|
|
if [[ ${c} -ge 10 ]]; then
|
|
printf "\n\t"
|
|
c=0
|
|
fi
|
|
done
|
|
printf "0\n};"
|
|
outputFooter FFMPEG_EXTENSIONS_H
|
|
}
|
|
|
|
|
|
function getExtensions() {
|
|
local FFMPEG=$1
|
|
local a=
|
|
local b=
|
|
local c=
|
|
local d=
|
|
local e=
|
|
local f=
|
|
local g=
|
|
|
|
"${FFMPEG}" -demuxers 2> /dev/null | while read a b c; do
|
|
if [[ "${a}x" == "Dx" ]]; then
|
|
"${FFMPEG}" -h demuxer=${b} 2> /dev/null | grep "Common extensions" | while read d e f; do
|
|
g=${f/./}
|
|
echo -e "${g//,/\\n}"
|
|
done
|
|
fi
|
|
done
|
|
}
|
|
|
|
|
|
function outputFooter() {
|
|
local BLOCKER=$1
|
|
|
|
printf "\n#pragma GCC diagnostic pop\n\n\n#endif // ${BLOCKER}\n"
|
|
}
|
|
|
|
|
|
function outputHeader() {
|
|
local BLOCKER=$1
|
|
|
|
printf "\n\n#ifndef ${BLOCKER}\n#define ${BLOCKER}\n\n\n"
|
|
printf "// ===== THIS FILE IS AUTOMATICALLY GENERATED - DO NOT EDIT =====\n\n\n"
|
|
printf "#pragma GCC diagnostic push\n#pragma GCC diagnostic ignored \"-Wunused-variable\"\n"
|
|
}
|
|
|
|
|
|
function outputLicense() {
|
|
cat <<- LICENSE
|
|
/*
|
|
*
|
|
* Singe 2
|
|
* Copyright (C) 2006-2024 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.
|
|
*
|
|
*/
|
|
LICENSE
|
|
}
|
|
|
|
|
|
#***TODO*** SDL2 needs a few dependencies on Linux to make its dynamic loading
|
|
# system happy. No idea the complete list yet.
|
|
#sudo apt-get install -y \
|
|
# libasound-dev
|
|
|
|
|
|
#buildAll linux x86
|
|
buildAll linux x86_64 2>&1 | tee linux-x86_64.log
|
|
#buildAll macos aarch64
|
|
#buildAll macos x86 #***TODO*** Needs older SDL2
|
|
#buildAll macos x86_64 #***TODO*** Needs older SDL2
|
|
#buildAll windows x86
|
|
#buildAll windows x86_64
|