Index: Portfile
===================================================================
--- Portfile	(revision 96123)
+++ Portfile	(working copy)
@@ -10,17 +10,26 @@
 categories          science
 maintainers         mmoll openmaintainer
 
-description         HDF5 general purpose library and file format for storing scientific data
-long_description    ${description}
+description         HDF5 general purpose library and file format for storing\
+                    scientific data
+long_description    HDF5 is a data model, library, and file format for storing\
+                    and managing data. It supports an unlimited variety of\
+                    datatypes, and is designed for flexible and efficient I/O\
+                    and for high volume and complex data. HDF5 is portable and\
+                    is extensible, allowing applications to evolve in their use\
+                    of HDF5. The HDF5 Technology suite includes tools and\
+                    applications for managing, manipulating, viewing, and\
+                    analyzing data in the HDF5 format.
 homepage            http://www.hdfgroup.org/HDF5/
 platforms           darwin
 conflicts           hdf5
-master_sites        http://www.hdfgroup.org/ftp/HDF5/current/src \
-                    ftp://ftp.hdfgroup.org/HDF5/current/src/ \
-                    ftp://ftp.hdfgroup.org/HDF5/prev-releases/hdf5-${version}/src/
-checksums           md5     33e105583417eff1c57fff910a53cd6f \
-                    sha1    7d5e5e8caa5970c65e70a5b4ad6787efe0bf70bb \
-                    rmd160  4c1a4160fbac6befa15b2dc039f20858c31db37d
+master_sites \
+    http://www.hdfgroup.org/ftp/HDF5/current/src \
+    ftp://ftp.hdfgroup.org/HDF5/current/src/ \
+    ftp://ftp.hdfgroup.org/HDF5/prev-releases/hdf5-${version}/src/
+checksums \
+    rmd160  4c1a4160fbac6befa15b2dc039f20858c31db37d \
+    sha256  fafe54856b00f0d6531629f66e2c476ab6ee03458803088f270bbfc4a60966c7
 distname            ${realname}-${version}
 use_bzip2           yes
 depends_lib         port:zlib
@@ -28,12 +37,14 @@
 
 configure.args      --with-zlib=yes --enable-filters=all \
                     --enable-production --disable-fortran \
-                    --enable-cxx --enable-shared --enable-static \
-                    --disable-parallel
+                    --disable-cxx --enable-shared --enable-static \
+                    --disable-parallel --disable-threadsafe
 
 # http://mail.hdfgroup.org/pipermail/hdf-forum_hdfgroup.org/2010-March/002682.html
 license             NCSA
 
+default_variants    +cxx
+
 post-configure {
     if {[variant_isset universal]} {
         set dirs {}
@@ -61,55 +72,128 @@
     license                     Noncommercial
 }
 
+variant cxx description {
+    Enable c++ interfance.
+  +cxx is EXPERIMENTAL with +mpich2, +openmpi, or +threadsafe
+} {
+    configure.args-delete       --disable-cxx
+    configure.args-append       --enable-cxx
+}
 
-variant threadsafe description {Enable threadsafety (experimental and un-supported, disables cxx support)} conflicts openmpi {
-    configure.args-delete       --disable-threadsafe --enable-cxx
-    configure.args-append       --enable-threadsafe --disable-cxx
+variant fortran description {
+    Enable fortran bindings. If combined with +openmpi or +mpich2, the\
+    respective MPI package must have been built with fortran support.
+  Must be combined with +gcc44, +gcc45, +gcc46, +mpich2, or +openmpi
+  +fortran is EXPERIMENTAL with +threadsafe
+} {
+    configure.args-delete       --disable-fortran
+    configure.args-append       --enable-fortran 
 }
 
+if {[ variant_isset fortran ] &&
+    !([variant_isset mpich2 ]  ||
+      [variant_isset openmpi ] ||
+      [variant_isset gcc44]    ||
+      [variant_isset gcc45]    ||
+      [variant_isset gcc46]) } {
+    ui_error "+fortran requires +mpich2, +openmpi, or +gccNN"
+    return -code error
+}
+
+variant threadsafe description {
+    Enable threadsafety. 
+  +threadsafe is EXPERIMENTAL with +cxx, +fortran, +mpich2 or +openmpi
+} {
+    configure.args-delete       --disable-threadsafe
+    configure.args-append       --enable-threadsafe --with-pthread
+}
+
+if {[ variant_isset threadsafe ] && ([ variant_isset cxx] ||
+                                     [ variant_isset fortran]) ||
+    ([ variant_isset mpich2 ] || [ variant_isset openmpi ]) &&
+    ([ variant_isset cxx ]    || [ variant_isset threadsafe ])  } {
+    
+    # Tell hdf5-18 to configure in this experimental configuration
+    configure.args-append       --enable-unsupported
+
+    notes {
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+hdf5-18 has been installed in an unsupported "Experimental" mode due to\
+selected variants. See "port variants hdf5-18 | grep EXPERIMENTAL" for more\
+information.
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+    }
+
+    pre-configure {
+        ui_warn {
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+hdf5-18 will been configured in an unsupported "Experimental" mode due to\
+selected variants. See "port variants hdf5-18 | grep EXPERIMENTAL" for more\
+information.
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+    }
+    }
+}
+
 # openmpi conflicts with universal because there is no universal variant for
 # the openmpi port at the moment
-variant openmpi description {Enable Parallel HDF5} conflicts threadsafe universal {
+variant openmpi description { 
+    Enable Parallel HDF5 with openmpi. Uses compiler selected with openmpi.
+  +openmpi is EXPERIMENTAL with +cxx or +threadsafe.
+} conflicts universal mpich2 gcc44 gcc45 gcc46 {
     depends_lib-append          port:openmpi
     configure.cc                ${prefix}/bin/openmpicc
-    configure.args-delete       --disable-parallel --enable-cxx
-    configure.args-append       --enable-parallel --disable-cxx
+    configure.cxx               ${prefix}/bin/openmpicxx
+    configure.fc                ${prefix}/bin/openmpif90
 }
 
+# mpich2 port does not support universal
+variant mpich2 description {
+    Enable Parallel HDF5 with mpich2. Uses compiler selected with mpich2.
+  +mpich2 is EXPERIMENTAL with +cxx or +threadsafe.
+} conflicts universal openmpi gcc44 gcc45 gcc46 {
+    depends_lib-append          path:bin/mpicc:mpich2
+    configure.cc                ${prefix}/bin/mpicc
+    configure.cxx               ${prefix}/bin/mpicxx
+    configure.fc                ${prefix}/bin/mpif90
+}
 
-variant gcc44 description {Enable Fortran bindings (gfortran 4.4)} conflicts threadsafe universal gcc45 gcc46 {
+if {[ variant_isset mpich2 ] || [ variant_isset openmpi ]} {
+    # These are compiler wrappers that already have MP's flags built in.
+    configure.cflags
+    configure.cxxflags
+    configure.ldflags
+    configure.fcflags
+    configure.cc_archflags
+    configure.cxx_archflags
+    configure.fc_archflags
+    configure.ld_archflags
+    configure.args-delete       --disable-parallel
+    configure.args-append       --enable-parallel
+}
+
+variant gcc44 description {
+    Build with MacPorts' gcc44 compiler.
+} conflicts universal gcc45 gcc46 openmpi mpich2 {
     depends_lib-append          port:gcc44 
-    configure.fc                ${prefix}/bin/gfortran-mp-4.4 
-    if { [variant_isset openmpi] } {
-        configure.fcflags-append    -I${prefix}/include/openmpi -L${prefix}/lib -lmpi_f90 -lmpi_f77 -lmpi
-    }
-    configure.args-delete       --disable-fortran
-    configure.args-append       --enable-fortran 
-    configure.post_args LDFLAGS="-L${prefix}/lib"
+    configure.compiler          macports-gcc-4.4
 }
 
-variant gcc45 description {Enable Fortran bindings (gfortran 4.5)} conflicts threadsafe universal gcc44 gcc46 {
+variant gcc45 description {
+    Build with MacPorts' gcc45 compiler.
+} conflicts universal gcc44 gcc46 openmpi mpich2 {
     depends_lib-append          port:gcc45 
-    configure.fc                ${prefix}/bin/gfortran-mp-4.5 
-    if { [variant_isset openmpi] } {
-        configure.fcflags-append    -I${prefix}/include/openmpi -L${prefix}/lib -lmpi_f90 -lmpi_f77 -lmpi
-    }
-    configure.args-delete       --disable-fortran
-    configure.args-append       --enable-fortran 
-    configure.post_args LDFLAGS="-L${prefix}/lib"
+    configure.compiler          macports-gcc-4.5
 }
 
-variant gcc46 description {Enable Fortran bindings (gfortran 4.6)} conflicts threadsafe universal gcc44 gcc45 {
+variant gcc46 description {
+    Build with MacPorts' gcc46 compiler.
+} conflicts universal gcc44 gcc45 openmpi mpich2 {
     depends_lib-append          port:gcc46 
-    configure.fc                ${prefix}/bin/gfortran-mp-4.6 
-    if { [variant_isset openmpi] } {
-        configure.fcflags-append    -I${prefix}/include/openmpi -L${prefix}/lib -lmpi_f90 -lmpi_f77 -lmpi
-    }
-    configure.args-delete       --disable-fortran
-    configure.args-append       --enable-fortran 
-    configure.post_args LDFLAGS="-L${prefix}/lib"
+    configure.compiler          macports-gcc-4.6
 }
 
+
 livecheck.type      regex
 livecheck.url       http://www.hdfgroup.org/HDF5/release/obtain5.html
 livecheck.regex     5-(\[0-9.\]+)
