# -*- 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 87080 2011-11-10 01:02:51Z ryandesign@macports.org $

PortSystem                  1.0
PortGroup                   cmake 1.0

name                        libhsplasma
version                     0.0-20111023
categories                  devel
platforms                   darwin
maintainers                 ryandesign
license                     GPL-3+
homepage                    http://code.google.com/p/libhsplasma/

description                 library for reading Plasma game engine files

long_description            libHSPlasma is a library for reading files used \
                            by the Plasma game engine (created by Headspin, \
                            acquired by Cyan Worlds), such as those in the \
                            games Myst V: End of Ages and Myst Online: URU Live

fetch.type                  git
git.url                     https://github.com/H-uru/libhsplasma.git
git.branch                  7b8df5940eeecfcd91ab3922a65303a0cadf3e24

depends_lib                 port:zlib \
                            port:jpeg \
                            port:openssl \
                            port:python26

patchfiles                  patch-endian.diff

configure.args-append       -DDISABLE_PYTHON:BOOL=OFF \
                            -DPYTHON_EXECUTABLE:FILEPATH=${prefix}/bin/python2.6 \
                            -DPYTHON_LIBRARY:FILEPATH=${prefix}/lib/libpython2.6.dylib

set pyhsplasma              ${frameworks_dir}/Python.framework/Versions/2.6/lib/python2.6/PyHSPlasma.so

post-destroot {
    system "install_name_tool -id ${pyhsplasma} ${destroot}${pyhsplasma}"
}

pre-activate {
    # Oops, libhsplasma 0.0-659_1 and earlier installed this lib directly
    if {[file exists ${pyhsplasma}]} {
        delete ${pyhsplasma}
    }
}

if {[variant_isset debug]} {
    configure.optflags -O1
    configure.cflags-append -ggdb
    configure.cxxflags-append -ggdb
}

variant commdebug description {Debug network communications (high-level)} {
    configure.cflags-append     -DCOMMDEBUG
    configure.cxxflags-append   -DCOMMDEBUG
}

variant commdebug2 description {Debug network communications (low-level)} {
    configure.cflags-append     -DCOMMDEBUG2
    configure.cxxflags-append   -DCOMMDEBUG2
}

livecheck.type              regex
livecheck.url               https://github.com/H-uru/libhsplasma/commits/master.atom
livecheck.version           [regsub {(....)(..)(..)} [lindex [split ${version} -] 1] {\1-\2-\3}]
livecheck.regex             {<updated>([0-9-]+)T}
