# -*- 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 79971 2011-07-01 02:02:35Z ryandesign@macports.org $

PortSystem              1.0
PortGroup               muniversal 1.0
PortGroup               archcheck 1.0

name                    freetype
version                 2.4.5
revision                1
categories              print graphics
maintainers             ryandesign
license                 FreeType GPL-2
homepage                http://freetype.sourceforge.net/
use_bzip2               yes
platforms               darwin
use_parallel_build      yes

description \
    A software font engine

long_description \
    FreeType2 is a software font engine that is designed to \
    be small, efficient, highly customizable and portable while \
    capable of producing high-quality output (glyph images). \
    It can be used in graphics libraries, display servers, font \
    conversion tools, text image generation tools, and many \
    other products as well.

master_sites \
    http://download.savannah.gnu.org/releases/freetype/ \
    sourceforge

set docdistfile \
    ${name}-doc-${version}

distfiles-append \
    [suffix ${docdistfile}]

checksums \
    [suffix ${distname}] \
        sha1    edc5217f1a0e3bec37f9846bb5203e8d005cf470 \
        rmd160  ec6719f2f851ebdb7135030ffd481d9ca53a54c1 \
    [suffix ${docdistfile}] \
        sha1    45e817127d98a7685c94f3189029489eba1a74ca \
        rmd160  7c6e46a0d7df532f384cdd88026e5616225b4d83

patchfiles \
    patch-detect.mk.diff \
    patch-src_base_ftrfork.c.diff \
    patch-modules.cfg.diff

depends_lib             port:zlib \
                        port:bzip2

archcheck.files         lib/libz.dylib \
                        lib/libbz2.dylib

# See http://trac.macports.org/ticket/18232
configure.cppflags-delete   -I${prefix}/include
configure.cppflags-append   -isystem${prefix}/include

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

platform macosx {
    if {${os.major} < 9} {
        configure.args-append \
            --with-old-mac-fonts
    }
}

set docdir              ${prefix}/share/doc/${name}

post-destroot {
    xinstall -m 0755 -d ${destroot}${docdir}
    
    xinstall -m 0644 -W ${worksrcpath} \
        ChangeLog \
        README \
        ${destroot}${docdir}
    xinstall -m 0644 -W ${worksrcpath}/docs \
        CHANGES \
        FTL.TXT \
        GPLv2.TXT \
        LICENSE.TXT \
        PROBLEMS \
        TODO \
        formats.txt \
        raster.txt \
        ${destroot}${docdir}
    
    xinstall -m 0755 -d ${destroot}${docdir}/html
    xinstall -m 0644 -W ${worksrcpath}/docs ft2faq.html ${destroot}${docdir}/html
    foreach dir {design glyphs reference tutorial} {
        copy ${worksrcpath}/docs/${dir} ${destroot}${docdir}/html
    }
}

if { ${os.arch}=="i386" } {
    if { ${os.major}>=10 } {
        set merger_configure_env(ppc) CC_BUILD=${configure.cc}
    }
    set merger_configure_env(ppc64)   CC_BUILD=${configure.cc}
} else {
    set merger_configure_env(i386)    CC_BUILD=${configure.cc}
    set merger_configure_env(x86_64)  CC_BUILD=${configure.cc}
}

livecheck.type          regex
livecheck.url           ${homepage}index2.html
livecheck.regex         {FreeType ([0-9.]+) has been released}
