[source]
tar = "https://github.com/AlisterT/openjazz/archive/refs/tags/20240919.tar.gz"
blake3 = "c419066dd7bf50510c5ef0746fc47450ab8f5a17a0010a1bc0ad67d0e63538da"

[build]
template = "custom"
dependencies = [
    "liborbital",
    "libiconv",
    "sdl1",
    "zlib",
]
script = """
export CFLAGS="${CFLAGS} -I${COOKBOOK_SYSROOT}/include"
export CXXFLAGS="${CXXFLAGS} -I${COOKBOOK_SYSROOT}/include"
export DATAPATH="/usr/share/games/openjazz/"

COOKBOOK_CONFIGURE="cmake"
COOKBOOK_CONFIGURE_FLAGS=(
    -DCMAKE_BUILD_TYPE=Release
    -DCMAKE_CROSSCOMPILING=ON
    -DCMAKE_CXX_COMPILER="${TARGET}-g++"
    -DCMAKE_C_COMPILER="${TARGET}-gcc"
    -DCMAKE_INSTALL_PREFIX="/"
    -DCMAKE_VERBOSE_MAKEFILE=ON
    -DLEGACY_SDL=ON
    -DSDL_LIBRARY="-lSDL -lorbital"
    -DNETWORK=ON
    "${COOKBOOK_SOURCE}"
)

cookbook_configure

ASSETS_DIR="${COOKBOOK_STAGE}${DATAPATH}"
INSTALL_DIR="${COOKBOOK_STAGE}/usr/games"
ICON_DIR="${COOKBOOK_STAGE}/usr/share/icons/apps"
MAN_ROOT="${COOKBOOK_STAGE}/usr/share/man"
mkdir -p "${ASSETS_DIR}" "${INSTALL_DIR}" "${ICON_DIR}" "${MAN_ROOT}"

cp -v "${COOKBOOK_SOURCE}/res/unix/OpenJazz.png" "${ICON_DIR}"
# TODO: Man pages need to be compiled
# cp -v "${COOKBOOK_SOURCE}/res/unix/OpenJazz.6" "${MAN_ROOT}/man6"
mv OpenJazz "${INSTALL_DIR}"
"""
