# $Id: Portfile 68311 2010-05-31 22:48:09Z ryandesign@macports.org $

PortSystem                  1.0
PortGroup                   archcheck 1.0

name                        glib2-devel
conflicts                   glib2
set my_name                 glib
version                     2.25.7
set branch                  [join [lrange [split ${version} .] 0 1] .]
categories                  devel
maintainers                 ryandesign
license                     GPLv2
homepage                    http://www.gtk.org/
platforms                   darwin
dist_subdir                 glib2
distname                    ${my_name}-${version}
use_bzip2                   yes
use_parallel_build          yes

description                 Library with data structure functions and other constructs

long_description            Glib is a library which includes support routines \
                            for C, such as lists, trees, hashes, memory \
                            allocation, and many other things.

master_sites                gnome:sources/${my_name}/${branch}/ \
                            ftp://ftp.gtk.org/pub/${my_name}/${branch}/

checksums                   md5     ac4867b9450f8bf5f1075336a32a1a88 \
                            sha1    8423e1f5346ecc629e85adfe5498c2545de421ef \
                            rmd160  7c16e4c4e133aee02625c6e5dfb430736b4de33e

# ${prefix}/include/glib-2.0/glib/gi18n.h requires -I${prefix}/include to find libintl.h
# See http://trac.macports.org/changeset/27148
patchfiles                  patch-configure.in.diff \
                            patch-glib-2.0.pc.in.diff \
                            patch-glib_gunicollate.c.diff \
                            patch-gi18n.h.diff \
                            patch-gio_xdgmime_xdgmime.c.diff

depends_build               port:pkgconfig

depends_lib                 port:gettext \
                            port:libiconv \
                            port:zlib \
                            path:bin/perl:perl5 \
                            bin:python:python_select

archcheck.files             lib/libintl.dylib \
                            lib/libiconv.dylib \
                            lib/libz.dylib

use_autoconf                yes

# -lresolv is needed at least on Tiger PPC.
configure.ldflags-append    -lresolv \
                            -bind_at_load

configure.cflags-append     -fstrict-aliasing

configure.args              --enable-static

configure.perl              ${prefix}/bin/perl
configure.env-append        PERL_PATH=${configure.perl}

post-patch {
    reinplace "s|data_dirs = \"/usr|data_dirs = \"${prefix}/share:/usr|g" ${worksrcpath}/glib/gutils.c
    reinplace "s|path = \"/bin|path = \"${prefix}/bin:/bin|g" ${worksrcpath}/glib/gutils.c ${worksrcpath}/glib/gspawn.c
    reinplace "s|@@PREFIX@@|${prefix}|g" ${worksrcpath}/gio/xdgmime/xdgmime.c
}

post-configure {
    system "ed - ${worksrcpath}/config.h < ${filespath}/config.h.ed"
}

platform darwin {
    patchfiles-append patch-child-test.c.diff
}

test.run                    yes
test.target                 check

post-destroot {
    file delete ${destroot}${prefix}/lib/charset.alias

    set docdir ${prefix}/share/doc/${name}
    xinstall -d ${destroot}${docdir}
    xinstall -m 644 -W ${worksrcpath} AUTHORS COPYING ChangeLog HACKING NEWS \
        README ${destroot}${docdir}
}

livecheck.type              regex
livecheck.url               http://ftp.gnome.org/pub/GNOME/sources/${my_name}/${branch}/?C=M&O=D
livecheck.regex             ${my_name}-(\[0-9.\]+)\\.tar
