# Description:  ioquake3 is a free software (GPLv2+) first person shooter engine.
# URL:  http://ioquake3.org
# Maintainer:  z3bra, dev at z3bra dot org
# Depends on:  libsdl2 openal

name=ioq3
version=git-77d6cde1
release=2
source=('http://ftp.gwdg.de/pub/misc/ftp.idsoftware.com/idstuff/quake3/linux/linuxq3apoint-1.32b-3.x86.run' 'ioq3.sh')

gitsource=git://github.com/ioquake/ioq3.git

build() {
    cd $PKGMK_SOURCE_DIR

    if cd $name; then
        git reset --hard
        git pull $gitsource
    else
        git clone $gitsource $name
        cd $name
    fi

    git checkout $sversion

    # Patch Makefile to correct install path
    /bin/sed -i "s:/usr/local/games/quake3:$PKG/opt/quake3:" Makefile

    # Compile ioQuake3
    make

    # Install Files
    make copyfiles

    # Extract Patch Files
    cd "$SRC"
    chmod +x "${SRC}/linuxq3apoint-1.32b-3.x86.run"
    "${SRC}/linuxq3apoint-1.32b-3.x86.run" --tar xf

    # Install Quake 3 Patch Files
    install -m 644 "${SRC}"/baseq3/*.pk3 \
        "${PKG}/opt/quake3/baseq3/"

    # Install Quake 3 Expansion Pack Patch Files
    install -m 644 "${SRC}"/missionpack/*.pk3 \
        "${PKG}/opt/quake3/missionpack/"

    # Install Launcher (Client)
    install -D -m 755 "${SRC}/ioq3.sh" \
        "${PKG}/usr/bin/ioquake3"
}
# vim: set ft=sh ts=4 et:
