# $Id: Portfile 66158 2010-04-06 08:27:29Z ryandesign@macports.org $

PortSystem              1.0
PortGroup               muniversal 1.0
PortGroup               archcheck 1.0

name                    freetype
version                 2.3.12
categories              print graphics
maintainers             ryandesign
license                 freetype/GPLv2
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}] \
        md5     e974a82e5939be8e05ee65f07275d7c5 \
        sha1    ebf0438429c0bedd310059326d91646c3c91016b \
        rmd160  57437a2bc0d85859cff2ca1253b36e64629397a1 \
    [suffix ${docdistfile}] \
        md5     2788beb4e1ee01bad8ed9978c0630e86 \
        sha1    4f3b2d0f04f23d5430dac4252fc225831c29dd18 \
        rmd160  27c3b4f68b9d560060532f1041e9b8c0a574d4f6

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

depends_lib \
    port:zlib

archcheck.files         lib/libz.dylib

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

# Respect build_arch
if {![variant_isset universal]} {
    configure.ldflags-append ${configure.cc_archflags}
}

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}-${version}

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 \
        GPL.TXT \
        LICENSE.TXT \
        PATENTS \
        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
    }
}

variant bytecode description {Include patented TrueType bytecode interpreter} {
    pre-extract {
        ui_warn "The +bytecode variant causes FreeType's TrueType driver to be
compiled with a bytecode interpreter that produces better-looking output
than the default auto-hinting method. However, the methods used by the
bytecode interpreter are patented by Apple Inc. Only use this variant if
you have purchased a license from Apple or live in a country where Apple's
patents to this technology do not apply. For more information, please read:
http://www.freetype.org/patents.html"
    }
    patchfiles-append \
        patch-ftoption.h
    
    post-destroot {
        xinstall -m 0644 -W ${worksrcpath}/docs TRUETYPE ${destroot}${docdir}
    }
}

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}
