#TODO: null pointer crash
[source]
tar = "https://github.com/crawl/crawl/releases/download/0.34.1/stone_soup-0.34.1-nodeps.tar.xz"
patches = [
    "redox.patch"
]

[build]
template = "custom"
dependencies = [
    "lua54",
    "luajit",
    "ncursesw",
    "pcre",
    "sqlite3",
    "zlib",
]
script = """
DYNAMIC_INIT
# Copy source to build directory
rsync -av --delete "${COOKBOOK_SOURCE}/" ./

cd source
MAKEFLAGS=(
    USE_PCRE=y
    USE_LUAJIT=y
    EXTERNAL_FLAGS="${CPPFLAGS}"
    EXTERNAL_LDFLAGS="${LDFLAGS}"
    EXTRA_LIBS="-llua"
    NO_TRY_LLD=y
    NO_TRY_GOLD=y
    V=1
    CC="${CC}"
    CXX="${CXX}"
    PKGCONFIG="${PKG_CONFIG}"
    STRIP="$STRIP"
)
mkdir -pv "${COOKBOOK_STAGE}/usr/games/crawl"
"${COOKBOOK_MAKE}" install install-xdg-data -j"$COOKBOOK_MAKE_JOBS" "${MAKEFLAGS[@]}" DESTDIR="$COOKBOOK_STAGE/usr/games/crawl"
mv "${COOKBOOK_STAGE}/usr/games/crawl/share" "${COOKBOOK_STAGE}/usr/share"
sed -i "s|Exec=|Exec=/usr/games/crawl|g" "${COOKBOOK_STAGE}/usr/share/applications/org.develz.Crawl_console.desktop"
"""
