# -*- 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 117557 2014-03-03 17:08:49Z devans@macports.org $

PortSystem                  1.0
PortGroup                   bitbucket 1.0
PortGroup                   muniversal 1.0

bitbucket.setup             libgd gd-libgd 2.1.0 libgd-
revision                    6
name                        gd2
categories                  graphics
maintainers                 ryandesign
license                     gd
homepage                    http://www.libgd.org/
platforms                   darwin
use_parallel_build          yes

description                 GD creates PNG and JPEG images, among other formats

long_description            gd is a graphics library. It allows your code to \
                            quickly draw images complete with lines, arcs, \
                            text, multiple colors, cut and paste from other \
                            images, and flood fills, and write out the result \
                            as a .PNG file. This is particularly useful in \
                            World Wide Web applications, where .PNG is the \
                            format used for inline images. gd is not a paint \
                            program. If you are looking for a paint program, \
                            you are looking in the wrong place. If you are not \
                            a programmer, you are looking in the wrong place.

bitbucket.tarball_from      downloads
use_xz                      yes

checksums                   rmd160  3fcdf88e1ca653ffd40ddba607dbc317ca87bf63 \
                            sha256  fa6665dfe3d898019671293c84d77067a3d2ede50884dbcb6df899d508370e5a

depends_build               port:gettext

depends_lib                 port:expat \
                            port:freetype \
                            port:fontconfig \
                            port:jpeg \
                            port:libiconv \
                            port:libpng \
                            port:tiff \
                            port:libvpx \
                            port:zlib

patchfiles                  patch-src-gdft.c.diff

configure.args-append       --with-freetype=${prefix} \
                            --with-fontconfig=${prefix} \
                            --with-jpeg=${prefix} \
                            --with-png=${prefix} \
                            --with-tiff=${prefix} \
                            --with-vpx=${prefix} \
                            --with-zlib=${prefix} \
                            --without-x \
                            --without-xpm

configure.cflags-append     -DDEFAULT_FONTPATH=\\\"/System/Library/Fonts:/Library/Fonts\\\"

post-configure {
    if {[variant_isset universal]} {
        set dirs {}
        foreach arch ${universal_archs_to_use} {
            lappend dirs ${worksrcpath}-${arch}
        }
    } else {
        set dirs ${worksrcpath}
    }
    foreach dir ${dirs} {
        reinplace -E {s|-arch [a-z0-9_]+||g} \
            ${dir}/config/gdlib-config
    }
}

variant x11 conflicts no_x11 {
    depends_lib-append      port:xpm
    configure.args-delete   --without-x \
                            --without-xpm
    configure.args-append   --with-xpm=${prefix} \
                            --x-includes=${prefix}/include \
                            --x-libraries=${prefix}/lib
}

variant no_x11 conflicts x11 description {Legacy compatibility variant} {}

if {[variant_isset no_x11]} {
    default_variants -x11
} else {
    default_variants +x11
}

livecheck.regex             >[join ${bitbucket.tag_prefix}](.+)${extract.suffix}<
