# -*- 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
# $Id: Portfile 77365 2011-03-28 23:49:09Z ryandesign@macports.org $

PortSystem              1.0

name                    alienarena-data
# Keep version in sync between alienarena and alienarena-data.
version                 7.45-20100726
set version_number      [lindex [split ${version} -] 0]
set version_date        [lindex [split ${version} -] 1]
categories              games
platforms               darwin
maintainers             ryandesign
license                 GPL-2+
supported_archs         noarch

homepage                http://red.planetarena.org/
master_sites            http://icculus.org/alienarena/Files/ \
                        gentoo

dist_subdir             alienarena
worksrcdir              alienarena[join [split ${version_number} .] _]
distname                ${worksrcdir}-Linux${version_date}

# Manually emulate "use_zip yes" because we want to extract specific directories only.
#use_zip                 yes
extract.cmd             [findBinary unzip ${portutil::autoconf::unzip_path}]
extract.suffix          .zip
extract.pre_args        -q
extract.post_args       -d ${extract.dir} ${worksrcdir}/data1/*

checksums               sha1    9c982d097d885af0cbd06bfbe6c4185936c43c4d \
                        rmd160  d20e167c66dec8ec072ecbf5833a4a4b46458a17

platform darwin {
    pre-fetch {
        # 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. http://gcc.gnu.org/ml/gcc/2005-06/msg00378.html)
        # but this leads to several "multiple definitions of symbol" errors.
        # 10.5.8:
        # In file included from client/snd_openal.c:37:
        # client/qal.h:108: error: syntax error before 'pqalcCreateContext'
        if {${os.major} < 10} {
            ui_error "Alien Arena requires Mac OS X 10.6 or greater at the moment."
            return -code error "incompatible Mac OS X version"
        }
    }
}

post-extract {
    # Remove pre-compiled Linux binaries that will be compiled properly by the alienarena port.
    eval delete [glob ${worksrcpath}/data1/*.so]
    
    # Remove config files that will be installed by the alienarena port.
    eval delete [glob ${worksrcpath}/data1/*.cfg]
}

use_configure           no

build {}

destroot {
    xinstall -d ${destroot}${prefix}/share/alienarena
    copy ${worksrcpath}/data1 ${destroot}${prefix}/share/alienarena
}

livecheck.version       ${version_number}
livecheck.type          regex
livecheck.url           ${homepage}aquire.html
livecheck.regex         {Alien Arena ([0-9.]+)}
