# $Id: Portfile 92855 2012-05-09 05:37:18Z jmr@macports.org $

PortSystem 1.0

name	        gtk2hs
version		0.10.1
categories	devel graphics
platforms	darwin
maintainers	gwright

description	Portable and native GUI library for Haskell
long_description	\
		gtk2hs is a Haskell binding to GTK, a comprehensive	\
		C GUI library that is portable across many platforms.

homepage	http://www.haskell.org/gtk2hs
master_sites	sourceforge

# Use the same rules as GTK Portfile for setting the default variants
if {[variant_isset no_x11]} {
    default_variants    +quartz
}

if {![variant_isset quartz]} {
    default_variants    +x11
}

checksums	md5     76774b092d4d584bb0a03ded3756d394		\
		sha1    808d8c80026b82dc2b1347055efba82f8847c424	\
		rmd160  c72acd0e2c5471c7757532cfb44c841be8e83f1d

depends_build	port:pkgconfig
depends_lib	port:ghc		\
		port:gtk2		\
		port:gvfs		\
		path:lib/pkgconfig/cairo.pc:cairo	\
		port:librsvg		\
		port:libglade2 		\
		port:gtkglext		\
		port:gtksourceview2

configure.args	--with-hc=${prefix}/bin/ghc	\
		--disable-deprecated-packages	\
		--enable-profiling		\
		--enable-packager-mode		\
		--enable-gtk			\
		--enable-gio			\
		--enable-gconf			\
		--enable-libglade		\
		--enable-gtksourceview2		\
		--enable-cairo			\
		--enable-svg			\
		--enable-opengl			\
		--without-pkgreg

variant no_x11 {
	depends_lib-delete	port:gtkglext
	configure.args-delete	--enable-opengl
}

use_parallel_build no

# Fix gtk.package.conf to allow interoperating with non-MacPorts
# ghc. (MacPorts' ghc adds ${prefix}/lib to the linker path
# automatically.)

post-destroot	{
	          set pkgs {glib gio cairo svgcairo gtk gconf glade gtkglext gtksourceview2 soegtk}
                  if {[variant_isset no_x11]} {
			set pkgs {glib gio cairo svgcairo gtk gconf glade gtksourceview2 soegtk}
		  }
		  foreach pkg ${pkgs} {
			reinplace "s|library-dirs: |library-dirs: \"${prefix}/lib\",|" \
				${destroot}${prefix}/lib/${name}/${pkg}.package.conf
		  }
		}

# Note that the order of package registration is important: certain
# packages must be registered before the packages that depend on them.

post-activate	{ 
	          set pkgs {glib gio cairo svgcairo gtk gconf glade gtkglext gtksourceview2 soegtk}
                  if {[variant_isset no_x11]} {
			set pkgs {glib gio cairo svgcairo gtk gconf glade gtksourceview2 soegtk}
		  }
		  foreach pkg ${pkgs} {
			system "ghc-pkg update ${destroot}${prefix}/lib/${name}/${pkg}.package.conf"
		  }
		}


