# -*- 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 106927 2013-06-12 01:37:09Z ryandesign@macports.org $

PortSystem          1.0
PortGroup           cmake 1.0
PortGroup           muniversal 1.0

name                graphite2
version             1.2.3
categories          graphics
platforms           darwin
maintainers         ryandesign openmaintainer
license             LGPL-2.1+

description         a “smart font” system for lesser-known languages

long_description    Graphite is a “smart font” system developed specifically \
                    to handle the complexities of lesser-known languages of \
                    the world.

homepage            http://graphite.sil.org/
master_sites        sourceforge:project/silgraphite/graphite2
extract.suffix      .tgz

checksums           rmd160  273dc9a9644bb05bc6373d4bc5ecc236e26f1b38 \
                    sha256  ef680a003cebc426d7c9bf856d7191775b1dfd585d5dd44712d7d41750b3fcf5

patchfiles          missing-include.patch

# gcc version 4.0.1 (Apple Computer, Inc. build 5370) (from Xcode 2.5 on Tiger) is affected.
# apple-gcc42 @5666.3_10 doesn't contain a c++ compiler so it falls back to the affected Xcode compiler.
# gcc version 4.0.1 (Apple Inc. build 5493) (from Xcode 3.1.4 on Leopard) is not affected.
# Other versions of gcc 4.0 not tested. Later versions of gcc are not affected.
platform darwin 8 {
    post-patch {
        # https://sourceforge.net/tracker/?func=detail&aid=3597386&group_id=66144&atid=513479
        reinplace "s|-fno-stack-protector||g" ${worksrcpath}/src/CMakeLists.txt ${worksrcpath}/tests/CMakeLists.txt
    }
}

post-patch {
    # https://trac.macports.org/ticket/37947
    # https://sourceforge.net/tracker/?func=detail&atid=513479&aid=3606023&group_id=66144
    reinplace "/add_subdirectory(featuremap)/d" ${worksrcpath}/tests/CMakeLists.txt
}

test.run            yes
test.env            DYLD_LIBRARY_PATH=${worksrcpath}/src

pre-test {
    # https://sourceforge.net/tracker/?func=detail&atid=513479&aid=3581750&group_id=66144
    set python_installed_version [strsed [exec python --version 2>@1] {g/Python //}]
    set python_minimum_version 2.6
    if {[vercmp ${python_installed_version} ${python_minimum_version}] < 0} {
        ui_error "Testing ${name} requires Python ${python_minimum_version} or later but your “python” is version ${python_installed_version}."
        return -code error "incompatible python version"
    }
}

# Disable segment caching code on PowerPC where it fails to build.
# https://sourceforge.net/tracker/?func=detail&atid=513479&aid=3593055&group_id=66144
set merger_configure_args(ppc) -DGRAPHITE2_NSEGCACHE:BOOL=ON
set merger_configure_args(ppc64) -DGRAPHITE2_NSEGCACHE:BOOL=ON
if {![variant_isset universal] && [info exists merger_configure_args(${configure.build_arch})]} {
    configure.args-append $merger_configure_args(${configure.build_arch})
}

livecheck.regex     /${name}-(\[0-9.\]+)${extract.suffix}
