# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0

# Upstream doesn't release tarballs anymore or tag their releases in svn so we
# make our own tarballs now using the make-tarballs.sh script in the files dir.

name                alienarena
categories          games
maintainers         {ryandesign @ryandesign}
license             GPL-2+

description         retro sci-fi old school deathmatch game similar to Quake \
                    III and Unreal Tournament

long_description    Alien Arena combines some of the very best aspects of \
                    such games as Quake III and Unreal Tournament and wraps \
                    them up with a retro alien theme, while adding tons of \
                    original ideas to make the game quite unique. Alien Arena \
                    is a furious frag fest with arenas ranging from the \
                    small, to the massive. With a large built-in player base, \
                    it's never hard to find a good match going on, at any \
                    hour of the day. The community is friendly, as well as \
                    prolific. Dozens of maps, models, and various accessories \
                    have been created by community members to add on to the \
                    game experience.

homepage            http://red.planetarena.org
master_sites        macports_distfiles
use_xz              yes

platform darwin {
    # TODO: verify minimum OS version
    if {${os.major} < 9} {
        # 10.4.11:
        # ld: common symbols not allowed with MH_DYLIB output format with the -multi_module option
        # The usual advice is to use -fno-common (e.g. https://gcc.gnu.org/ml/gcc/2005-06/msg00378.html)
        # but this leads to several "multiple definitions of symbol" errors.
        known_fail  yes
        pre-fetch {
            ui_error "Alien Arena requires Mac OS X 10.5 or greater at the moment."
            return -code error "incompatible Mac OS X version"
        }
    }
}

if {${name} eq ${subport}} {
    version                     7.71.1-20200830-r5669
    revision                    1
    checksums                   rmd160  ee169cfcbce868535b2d381c0c573a17d160ebcb \
                                sha256  c9083aeddfa7e70850db9f8ac7aa408e7387d2ccc66970226106b27d719c0c93 \
                                size    3183432

    PortGroup                   muniversal 1.0
    
    depends_build               port:autoconf-archive \
                                port:pkgconfig
    
    depends_lib                 port:curl \
                                port:freetype \
                                path:include/turbojpeg.h:libjpeg-turbo \
                                port:libogg \
                                port:libvorbis \
                                port:mesa \
                                port:ode \
                                port:openal-soft \
                                port:xorg-libX11 \
                                port:xorg-libXxf86dga \
                                port:xorg-libXxf86vm \
                                port:zlib
    
    depends_run                 port:alienarena-data
    
    post-extract {
        # autoreconf complains if this directory doesn't exist.
        file mkdir ${worksrcpath}/data1
    }

    patchfiles                  patch-configure.ac.diff \
                                patch-source-Makefile.am.diff
    
    post-patch {
        # The @PREFIX@ placeholder is present in configure.ac as shipped by the
        # developers. They mistakenly applied a MacPorts patch (that added that
        # placeholder to use MacPorts openal-soft instead of Apple's OpenAL
        # framework) that was never meant for upstream consumption.
        reinplace "s|@PREFIX@|${prefix}|g" ${worksrcpath}/configure.ac
    }
    
    # The distfile contains a configure script but none of the supporting files.
    # Also, we patch configure.ac and source/Makefile.am.
    use_autoreconf              yes
    autoreconf.args             -fvi
    
    configure.args              --disable-silent-rules \
                                --with-system-libode \
                                --with-xf86dga \
                                --with-xf86vm \
                                --with-zlib \
                                --without-data1pkg \
                                --x-includes=${prefix}/include \
                                --x-libraries=${prefix}/lib
    
    variant debug description {Enable debugging symbols} {
        configure.args-append   --enable-debugging-symbols
        configure.optflags      -O0
    }
    
    notes "
To play Alien Arena, type:

${name}

To run your own dedicated Alien Arena server, use:

${name}-ded
"
    
    # TODO
    livecheck.type              none
} else {
    livecheck.type              none
}

subport alienarena-data {
    version                     7.71.1-20191015-r5663
    revision                    0
    checksums                   rmd160  b7f817ca8a2fe61387d7c4092155708f65a65d2f \
                                sha256  d7dee24f8c89db48b7b2ac0daae8a9e8497503debed716ba4732fa4e48433e70 \
                                size    779223968

    license                     Restrictive
    supported_archs             noarch
    platforms                   any
    
    description                 Assets for the Alien Arena game
    
    long_description            {*}${description}
    
    distname                    ${subport}-${version}
    worksrcdir                  {*}${worksrcdir}/data1
}
