# -*- 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 73669 2010-11-21 04:56:12Z ryandesign@macports.org $

PortSystem                  1.0
PortGroup                   qt4 1.0

name                        PlasmaShop
version                     3.0-127
revision                    1
categories                  devel
platforms                   darwin
maintainers                 ryandesign
license                     GPL-3+
homepage                    http://alcugs.almlys.org/PlasmaShop

description                 tool for inspecting and manipulating Plasma game files

long_description            ${name} is a tool for inspecting and manipulating \
                            the files that make up games based on the Plasma \
                            engine, such as Myst Online: URU Live. It can do \
                            many age-related tasks that lie outside of what \
                            the PRP Blender Plugin can do: create PAK files, \
                            decompyle/compile Python scripts, sum age files, \
                            etc.

fetch.type                  hg
hg.url                      http://uru.zrax.net/hg/PlasmaShop/
hg.tag                      4c278eea53d1

depends_lib-append          port:libhsplasma

set files_being_patched     {
                            QScintilla/Qt4/qscintilla.pro
                            config
                            src/3rdParty/qticonloader.cpp
                            src/PlasmaShop/PlasmaShop.pro
                            src/PrpShop/PrpShop.pro
                            src/VaultShop/VaultShop.pro
                            }

post-extract {
    # DOS to UNIX line endings so we can patch properly.
    foreach file ${files_being_patched} {
        reinplace "s|\r||g" ${worksrcpath}/${file}
    }
}

patchfiles                  patch-prefix.diff patch-config.diff

variant universal {}
if {[variant_isset universal]} {
    set archflags ${configure.universal_cflags}
} else {
    set archflags ${configure.cc_archflags}
}

post-patch {
    foreach file ${files_being_patched} {
        reinplace "s|@PREFIX@|${prefix}|g" ${worksrcpath}/${file}
        reinplace "s|@APPLICATIONS_DIR@|${applications_dir}|g" ${worksrcpath}/${file}
    }
    reinplace "s|@CFLAGS@|${configure.cflags} ${archflags}|g" ${worksrcpath}/config
    reinplace "s|@CXXFLAGS@|${configure.cxxflags} ${archflags}|g" ${worksrcpath}/config
    reinplace "s|@LDFLAGS@|${configure.ldflags} ${archflags}|g" ${worksrcpath}/config
}

configure.cmd               ${qt_qmake_cmd}
configure.pre_args

configure.universal_args-delete --disable-dependency-tracking

# http://forum.guildofwriters.com/viewtopic.php?f=86&t=4145#p40027
use_parallel_build          no

platform darwin {
    if {${os.major} < 10} {
        set font Monaco
    } else {
        set font Menlo
    }
    post-patch {
        reinplace "s|@FONT@|${font}|g" ${worksrcpath}/config
    }
    
    # http://www.ogre3d.org/forums/viewtopic.php?t=9949#p71474
    configure.cflags-append     -DGL_GLEXT_LEGACY
    configure.cxxflags-append   -DGL_GLEXT_LEGACY
}

livecheck.type              regex
livecheck.url               ${hg.url}
livecheck.version           [lindex [split ${version} -] 1]
livecheck.regex             {rev (\d+)}
