# -*- 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 108252 2013-07-17 08:23:29Z ryandesign@macports.org $

PortSystem          1.0

name                harfbuzz
version             0.9.19
categories          graphics
platforms           darwin
maintainers         ryandesign openmaintainer
license             MIT

description         OpenType text shaping engine

long_description    HarfBuzz is an ${description}.

homepage            http://www.freedesktop.org/wiki/Software/HarfBuzz
master_sites        http://www.freedesktop.org/software/harfbuzz/release/
use_bzip2           yes

checksums           rmd160  d76e52542ac11ac03c3fb4f49fddf1535bfefab6 \
                    sha256  d2da0f060d47f6ad9de8c8781bb21fa4b9eae8ea1cd1e956b814095baa002f35

depends_build       port:pkgconfig

configure.args      --disable-silent-rules

if {${name} eq ${subport}} {
    depends_lib-append \
                    path:lib/pkgconfig/cairo.pc:cairo \
                    port:freetype \
                    path:lib/pkgconfig/glib-2.0.pc:glib2 \
                    port:graphite2
    
    configure.args-append \
                    --with-cairo \
                    --with-freetype \
                    --with-glib \
                    --with-graphite2 \
                    --without-icu
    
    post-destroot {
        set docdir ${prefix}/share/doc/${name}
        xinstall -d ${destroot}${docdir}
        xinstall -m 644 -W ${worksrcpath} \
                    AUTHORS \
                    COPYING \
                    ChangeLog \
                    NEWS \
                    README \
                    THANKS \
                    TODO \
                    ${destroot}${docdir}
    }
    
    livecheck.type  regex
    livecheck.url   [lindex ${master_sites} 0]
    livecheck.regex [suffix ${name}-(\[0-9.\]+)]
} else {
    livecheck.type  none
}

subport harfbuzz-icu {
    description     HarfBuzz ICU support library
    
    long_description This library adds support for ICU (the International Components for Unicode) to HarfBuzz.
    
    depends_lib-append \
                    port:harfbuzz \
                    port:icu
    
    configure.args-append \
                    --without-cairo \
                    --without-freetype \
                    --without-glib \
                    --without-graphite2 \
                    --with-icu
    
    destroot.dir    ${worksrcpath}/src
    destroot {
        eval xinstall -W ${destroot.dir}/.libs \
                    [glob ${destroot.dir}/.libs/libharfbuzz-icu.*.dylib] \
                    libharfbuzz-icu.la \
                    ${destroot}${prefix}/lib
        reinplace "s|${destroot.dir}|${prefix}/lib|g" ${destroot}${prefix}/lib/libharfbuzz-icu.la
        copy ${destroot.dir}/.libs/libharfbuzz-icu.dylib ${destroot}${prefix}/lib
        xinstall -m 644 ${destroot.dir}/hb-icu.h ${destroot}${prefix}/include
        xinstall -m 644 ${destroot.dir}/harfbuzz-icu.pc ${destroot}${prefix}/lib/pkgconfig
    }
}
