--- Portfile.orig	2013-02-14 14:36:36.000000000 +0100
+++ Portfile	2013-03-01 11:04:20.000000000 +0100
@@ -3,9 +3,11 @@
 
 PortSystem          1.0
 
+PortGroup           active_variants 1.1
+PortGroup			cmake 1.0
+
 name                vigra
-version             1.8.0
-revision            4
+version             1.9.0
 categories          graphics
 platforms           darwin
 maintainers         gmail.com:benjamin.seppke
@@ -24,50 +26,47 @@
 #universal_variant   no
 worksrcdir          ${name}-${version}
 
-checksums           rmd160  99d781da6e0ca94ce3404e1bcb3adeb9e43a2017 \
-                    sha256  fc3a87d220ce23e79d163c58dd280fd534b81a870d2b140f1d072bbc82c78214
+checksums           rmd160  84e3f1bc985df1ea928e9aa5adc6e0c153cbdd40 \
+                    sha256  8fbdccb553a4925323098ab27b710fbc87d48f37bf81d404994936a31a31cf01
 
-depends_build       port:cmake
+depends_build       port:cmake 
 depends_lib         port:jpeg \
                     port:tiff \
                     port:libpng \
                     port:zlib \
                     port:openexr \
-                    port:fftw-3 \
-                    port:hdf5-18
-
-# correct the INSTALL_NAME_DIR for Python .so modules
-patchfiles          patch-config-VIGRA_ADD_NUMPY_MODULE.cmake.diff
-
-configure.cmd       cmake
+                    port:fftw-3-single \
+                    port:hdf5-18 
 
-configure.args      -DSKIP_BUILD_RPATH=TRUE \
-					-DCMAKE_VERBOSE_MAKEFILE=ON \
-                    -DCMAKE_BUILD_TYPE=Release \
-                    -DCMAKE_SYSTEM_PREFIX_PATH=\"${prefix}\;/usr\" \
-                    -DCMAKE_INSTALL_PREFIX=${prefix} \
-                    -DCMAKE_INSTALL_NAME_DIR=${prefix}/lib \
-                    -DCMAKE_INCLUDE_PATH=${prefix}/include \
-                    -DCMAKE_LIBRARY_PATH=${prefix}/lib \
-                    -DJPEG_INCLUDE_DIR=${prefix}/include \
-                    -DPNG_PNG_INCLUDE_DIR=${prefix}/include \
-                    -DTIFF_INCLUDE_DIR=${prefix}/include \
-                    -Wno-dev \
-                    -DBUILD_SHARED_LIBS=ON
-configure.post_args .
+# Correct the INSTALL_NAME_DIR for Python .so modules 
+# and patch template names in the accumulator-grammar.
+patchfiles          patch-config-VIGRA_ADD_NUMPY_MODULE.cmake.diff \
+		            patch-include-vigra-accumulator-grammar.hxx.diff 
+		            
+# Some additional parameters for cmake. All other params have already been set
+# by the cmake PortGroup
+configure.args-append	-DCMAKE_INSTALL_PREFIX=${prefix} \
+                    	-DWITH_OPENEXR=ON \
+                    	-DBUILD_SHARED_LIBS=ON
+
+# Restrict the usable compilers to clang and llvm
+# (either XCode >4.0 or MacPorts) and select the
+# macports-clang-3.2 if no appropriate compiler
+# is present:
+if {	[string match *llvm*  "${configure.compiler}"] == 0 \
+	 && [string match *clang* "${configure.compiler}"] == 0} {
+    depends_build-append port:clang-3.1
+    configure.compiler macports-clang-3.1
+} 
 
 destroot.env-append DESTDIR=${destroot}
 
 post-destroot {
-    # fix location of documentation to include version.
-    # remove documentation if no variant is set.
-    # for now since NumPy variant does not work, just
-    # move what can be moved and delete the rest.
     if {[variant_isset docs]} {
-        # move documentation to a versioned directory
+        # move documentation to a unversioned directory
         xinstall -m 755 -d ${destroot}${prefix}/share/doc
         move ${destroot}${prefix}/doc/${name} \
-            ${destroot}${prefix}/share/doc/${name}-${version}
+             ${destroot}${prefix}/share/doc/${name}
     }
     # delete whatever is left in the doc directory
     delete ${destroot}${prefix}/doc
@@ -77,13 +76,11 @@
 if {[variant_isset docs]} {
     depends_lib-append port:doxygen
 } else {
-    configure.args-append \
-        -DBUILD_doc=OFF \
-        -DDOXYGEN_DOT_EXECUTABLE= \
-        -DDOXYGEN_DOT_PATH= \
-        -DDOXYGEN_EXECUTABLE=
+    configure.args-append	-DDOXYGEN_DOT_EXECUTABLE= \
+       						-DDOXYGEN_EXECUTABLE=
 }
 
+
 variant valgrind description "Include support for VALGRIND" {}
 if {[variant_isset valgrind]} {
     depends_lib-append port:valgrind
@@ -91,41 +88,30 @@
     configure.args-append -DWITH_VALGRIND=NO
 }
 
-# just like it's done in games/PlasmaClient and other ports that
-# require Boost::Python.
-if {![file exists ${prefix}/lib/libboost_python-mt.dylib]} {
-    # just disable NUMPY bindings via a CMake flag
-    configure.args-append -DWITH_VIGRANUMPY=NO
-
-    pre-fetch {
-        ui_msg "
-****
-**** To get NUMPY bindings, ${name} requires the port 'boost' to
-**** be installed with the variant +python26.  If you want NUMPY
-**** bindings, then please do the following first:
-****
-****     sudo port install boost +python26
-****
-**** and then try installing ${name} again.
-****
-"
-    }
-} else {
-    # assume Python version 2.6, no matter what the user has actually
-    # installed via "port install boost +pythonXY".
-    set python_version "2.6"
-
-    # append cmake flags
-    configure.args-append \
-        -DPYTHON_EXECUTABLE=${prefix}/bin/python${python_version} \
-        -DPYTHON_SPHINX=${prefix}/bin/sphinx-build-${python_version}
-
-    # make sure dependencies are installed
-    set python_version_join [join [split ${python_version} "."] ""]
-    depends_lib-append port:boost \
-        port:python${python_version_join} \
-        port:py${python_version_join}-numpy \
-        port:py${python_version_join}-sphinx
+variant python26 conflicts python27 description "Also build vigranumpy ptyhon26 bindings" {
+   	configure.args-append  	-DPYTHON_EXECUTABLE=${prefix}/bin/python2.6 \
+       						-DPYTHON_SPHINX=${prefix}/bin/sphinx-build-2.6
+	depends_lib-append 	port:boost \
+	        			port:python26 \
+						port:py26-numpy \
+	        			port:py26-sphinx
+	require_active_variants boost python26
+}
+
+variant python27 conflicts python26 description "Also build vigranumpy ptyhon27 bindings" {
+   	configure.args-append  	-DPYTHON_EXECUTABLE=${prefix}/bin/python2.7 \
+       						-DPYTHON_SPHINX=${prefix}/bin/sphinx-build-2.7
+	depends_lib-append 	port:boost \
+	        			port:python27 \
+						port:py27-numpy \
+	        			port:py27-sphinx
+	require_active_variants boost python27
+}
+
+default_variants +python27 
+
+if {   ![variant_isset python26] && ![variant_isset python27] } {
+	configure.args-append -DWITH_VIGRANUMPY=NO	
 }
 
 livecheck.type      regex
