--- Portfile.orig	2013-07-12 11:37:06.000000000 +0100
+++ Portfile	2013-07-14 15:21:24.000000000 +0100
@@ -2,44 +2,52 @@
 # $Id$
 
 PortSystem      1.0
+PortGroup       github 1.0
 
 name            raxml
-version         7.2.9
+version         7.6.6
+github.setup    stamatak standard-RAxML 88d5f2bb66f4a5177aa52bc77ca3fc951da99ea8
 description     Estimation of phylogenetic trees
 long_description        RAxML is a program for sequential and parallel estimation of\
         phylogenetic trees written by Alexandros Stamatakis. By default the Pthreads\
-        implementation will be installed, use -pthreads +mpi for the MPI variant.
+        implementation will be installed, use -pthreads +mpi for the MPI variant. The\
+        SSE3 and AVX capability of your CPU will be detected and set automatically.
+
 license         GPL-2+
 maintainers     gmail.com:mattoates
-categories      science
-homepage        http://sco.h-its.org/exelixis
+categories      science biology
+homepage        http://www.exelixis-lab.org/
 platforms       darwin
-master_sites    ${homepage}/software/
-distfiles       RAxML-${version}.tar.bz2
-checksums       md5     028b70c7c96900e1f70cdc2c2acab449 \
-                sha1    a038b72e197434d7fa8a7c35687b70adb4b0750b
-use_bzip2       yes
 
-patchfiles      Makefiles.patch
+checksums       sha256  15ee8094370872f8ed0292544fdadaeedf4e7c43c25dc96a1815f289243f2211 \
+                rmd160  88c41e384cfaba128065cb1e99686223061573b9
 
 use_configure   no
 
 #Strings used by the variant options
 set HPCm ""
 set HPCb ""
-set SSEm ""
-set SSEb ""
+set EXTm ""
+set EXTb ""
+
+#Use the HYBRID implementation
+variant hybrid conflicts pthreads,mpi description {Hybrid MPI implementation} {
+        depends_lib-append port:openmpi
+        set HPCm ".HYBRID"
+        set HPCb "-HYBRID"
+        configure.cc    ${prefix}/bin/openmpicc
+}
 
 #Use the MPI implementation
-variant mpi conflicts pthreads description {MPI implementation} {
-        depends_lib port:openmpi
+variant mpi conflicts pthreads,hybrid description {MPI implementation} {
+        depends_lib-append port:openmpi
         set HPCm ".MPI"
         set HPCb "-MPI"
         configure.cc    ${prefix}/bin/openmpicc
 }
 
 #Use the pthreads implementation (default)
-variant pthreads conflicts mpi description {Pthreads implementation} {
+variant pthreads conflicts hybrid,mpi description {Pthreads implementation} {
         set HPCm ".PTHREADS"
         set HPCb "-PTHREADS"
 }
@@ -48,17 +56,27 @@
     default_variants        +pthreads
 }
 
-#For Intel machines add SSE as a variant and use it by default with pthreads
+#For Intel machines add SSE and AVX as a variant and use it by default with pthreads
 if {$build_arch == "i386" || $build_arch == "x86_64"} {
 
-variant sse3 description {Use the SSE3 extended instruction set from Intel since 2004} {
-        set SSEm ".SSE3"
-        set SSEb "-SSE3"
+variant sse3 conflicts avx description {Use the SSE3 extended instruction set from Intel since 2004} {
+        set EXTm ".SSE3"
+        set EXTb "-SSE3"
+}
+
+variant avx conflicts sse3 description {Use the ATX extended instruction set from Intel i7 (sandy bridge) and AMD Bulldozer} {
+        set EXTm ".AVX"
+        set EXTb "-AVX"
 }
 
 if {![catch {sysctl hw.optional.sse3} result] && $result == 1} {
-    default_variants-append  +sse3
+    if {![catch {sysctl hw.optional.avx1_0} result] && $result == 1} {
+        default_variants-append  +avx
+    } else {
+        default_variants-append  +sse3
+    }
 }
+
 } else {
     post-patch {
         reinplace "s/-msse//" ${worksrcpath}/Makefile.gcc \
@@ -73,11 +91,11 @@
 
 #Make sure we are using the correct Makefile for this variant combo
 pre-build {
-        build.pre_args  -f Makefile${SSEm}${HPCm}.gcc
+        build.pre_args  -f Makefile${EXTm}${HPCm}.gcc
         build.args-append CC="${configure.cc}"
 }
 
 #We only need the single raxml binary
 destroot {
-        copy ${worksrcpath}/raxmlHPC${HPCb}${SSEb} ${destroot}${prefix}/bin/raxml
+        copy ${worksrcpath}/raxmlHPC${HPCb}${EXTb} ${destroot}${prefix}/bin/raxml
 }
