# $Id: Portfile,v 1.51 2006/07/18 22:09:53 mij Exp $

PortSystem 1.0
name		glib2
version		2.12.0
revision	1
categories	devel
maintainers	mij@opendarwin.org
description	Library with data structure functions and other constructs
homepage	http://www.gtk.org/
platforms	darwin

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	ftp://ftp.gtk.org/pub/gtk/v2.12 \
		gnome:sources/glib/2.12

distname	glib-${portversion}
checksums	md5 ea8c7733ba443e3db04cf7a84060f408 \
		sha1 3a5afb427bf7ea064b47ecd9316603ddd07de1f1 \
		rmd160 05c42ad616b3cb4aec3831d30414516c70142a4f

use_bzip2	yes

depends_build	bin:pkg-config:pkgconfig
depends_lib	lib:libintl.3:gettext

patchfiles	patch-glib__gmain.c patch-glib__gutils.c \
		patch-glib-2.0.pc.in

configure.env	LDFLAGS="-L${prefix}/lib -bind_at_load" \
		CPPFLAGS="-I${prefix}/include" \
		CFLAGS="-O3 -funroll-loops -fstrict-aliasing" 

configure.args   --mandir=${prefix}/share/man

variant puredarwin { depends_run bin:perl:perl5.8 }

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
}

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

platform darwin 6 {
	depends_lib-append lib:libdl:dlcompat
	post-configure {
		reinplace "s|#define HAVE_WCHAR_T 1|#undef HAVE_WCHAR_T|" \
			${worksrcpath}/config.h
	}
}
