Index: Portfile
===================================================================
--- Portfile	(revision 104608)
+++ Portfile	(working copy)
@@ -3,15 +3,15 @@
 
 PortSystem          1.0
 
-categories          math science
 name                shogun
-version             0.9.3
-revision            1
+version             2.1.0
 set branch          [join [lrange [split ${version} .] 0 1] .]
+revision            0
+categories-append   science
+platforms           darwin
 license             GPL-3
-maintainers         jameskyle
 
-platforms           darwin
+maintainers         jameskyle openmaintainer
 
 description         The machine learning toolbox's focus is on large scale \
                     kernel methods
@@ -23,165 +23,247 @@
 
 homepage            http://shogun-toolbox.org
 master_sites        ${homepage}/archives/shogun/releases/${branch}/sources/
+
 use_bzip2           yes
 
-checksums           md5     99afbb304d524335fc181c553047cb51 \
-                    sha1    d559dff3e11f777a23f00278d78d259ad896b829 \
-                    rmd160  9638a6b747a1177b048720b8999c60f33c7df5ef
+checksums           rmd160  5fece569be7d95bbe9ad406f1b5e10f06f4ac20e \
+                    sha256  6c47941a98d506d7b1e21d5bfd511f8684a2e1f371accd4756cdc8821916a63b
 
 worksrcdir          ${name}-${version}/src
 
-patchfiles          swig_version.patch
+patchfiles          patch-src_configure.diff
 
-depends_build       port:bzip2 \
-                    port:gsed
+post-patch {
+    reinplace "s|@@MAKEDEPEND@@|${configure.cc} -MM|g" ${worksrcpath}/configure
+}
 
-depends_lib         port:swig-python \
+depends_lib         port:hdf5-18 \
+                    port:json-c \
+                    port:libxml2 \
+                    port:readline \
                     port:atlas \
-                    port:readline \
+                    port:arpack \
+                    port:eigen3 \
+                    port:lp_solve \
                     port:glpk \
-                    port:python26 \
-                    port:py26-numpy \
-                    port:hdf5-18
+                    port:lzo2 \
+                    port:snappy \
+                    port:gzip \
+                    port:bzip2 \
+                    port:xz
 
 universal_variant   no
 
-set python_prefix   ${prefix}/Library/Frameworks/Python.framework/Versions/2.6
-configure.args      --disable-svm-light \
-                    --libs=${prefix}/lib \
-                    --install-path=${prefix} \
-                    --includes=${prefix}/include \
-                    --destdir=${destroot} \
-                    --includes=${python_prefix}/include/python2.6 \
-                    --python=${python_prefix}/bin/python2.6 \
-                    --pydir=${python_prefix}/lib/python2.6/site-packages \
-                    --disable-doxygen \
-                    --disable-hdf5
-
 pre-fetch {
-  if {[ regexp {^[2-8]} ${os.major}]} {
-    return -code error "Shogun is only supported on leopard or above"
-  }
+    if {${os.major} <= 8} {
+        return -code error "Shogun is only supported on Leopard or above"
+    }
 }
 
-proc lremove {list elem} {
-    set index [lsearch -exact $list $elem]
-    return [lreplace $list $index $index]
+# Define compilers variants
+variant gcc45 conflicts gcc46 gcc47 gcc48 clang33 description {Compile with gcc 4.5} {
+    configure.compiler      macports-gcc-4.5
+    depends_lib-append      port:gcc45
+    configure.args-append   --ldflags=-lgfortran
 }
 
-# Interfaces are added by a comma delimited argument list to --interfaces.
-# We check for variants and then build this list accordingly
-set interfaces "libshogun libshogunui cmdline python python_modular"
+variant gcc46 conflicts gcc45 gcc47 gcc48 clang33 description {Compile with gcc 4.6} {
+    configure.compiler      macports-gcc-4.6
+    depends_lib-append      port:gcc46
+    configure.args-append   --ldflags=-lgfortran
+}
 
-if {[variant_isset r]} {lappend interfaces "r"}
-if {[variant_isset octave]} {lappend interfaces "octave,octave_modular"}
-if {[variant_isset elwms]  && !([variant_isset python] &&
-    [variant_isset octave] &&   [variant_isset r])} {
-  return -code error "Must set python and both r and octave variants to build elwms interface"
-} elseif {[variant_isset elwms]} {
-  lappend interfaces "elwms"
+variant gcc47 conflicts gcc45 gcc46 gcc48 clang33 description {Compile with gcc 4.7} {
+    configure.compiler      macports-gcc-4.7
+    depends_lib-append      port:gcc47
+    configure.args-append   --ldflags=-lgfortran
 }
 
-# remove python interface if necessary before appending to args
-if {[variant_isset no_python26] && ![variant_isset python25]} {
-    set interfaces [lremove ${interfaces} "python"]
-    set interfaces [lremove ${interfaces} "python_modular"]
-    depends_lib-delete port:swig-python
+variant gcc48 conflicts gcc45 gcc46 gcc47 clang33 description {Compile with gcc 4.8} {
+    configure.compiler      macports-gcc-4.8
+    depends_lib-append      port:gcc48
+    configure.args-append   --ldflags=-lgfortran
 }
 
-#if {[variant_isset matlab]} {lappend interfaces "matlab"}
-set interfaces [join $interfaces ","]
+variant clang33 conflicts gcc45 gcc46 gcc47 gcc48 description {Compile with clang 3.3} {
+    configure.compiler      macports-clang-3.3
+    depends_lib-append      port:clang-3.3 \
+                            port:gcc47
+    configure.args-delete   --disable-cpudetection
+    configure.args-append   --enable-cpudetection \
+                            --ldflags=-lgfortran
+    configure.env-append    POSTLINKFLAGS="-L${prefix}/lib/gcc47"
+}
 
-configure.args-append --interfaces=$interfaces
+if {![variant_isset gcc45] && ![variant_isset gcc46] &&
+    ![variant_isset gcc48] && ![variant_isset clang33]
+} then {
+    default_variants +gcc47
+}
 
-variant elwms description {Build elwms interface. requires python plus  one other interface} {}
+# Define python variants
+set pythons_suffixes {26 27}
 
-variant python25 requires no_python26 description {Build Python 2.5 API} {
-    configure.args-append \
-        --includes=${prefix}/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5 \
-        --python=${prefix}/Library/Frameworks/Python.framework/Versions/2.5/bin/python \
-        --pydir=${prefix}/Library/Frameworks/Python.framework/Versions/2.5/site-packages
-    depends_lib-append port:python25 \
-                       port:py25-numpy
+set pythons_ports {}
+foreach s ${pythons_suffixes} {
+    lappend pythons_ports python${s}
 }
 
-variant hmm_parallel description {Enable parallel structures in hmm training} {
-  configure.args-append --enable-hmm-parallel
+proc python_prefix {} {
+    global prefix pythons_suffixes
+    foreach s ${pythons_suffixes} {
+        if {[variant_isset python${s}]} {
+            set p ${prefix}/bin/python[string index ${s} 0].[string index ${s} 1]
+            return [file normalize [exec ${p} -c "import sys; print(sys.prefix)"]]
+        }
+    }
+    error "Python support not enabled."
 }
 
-variant no_python26 description {Do not build Python 2.6 API} {
-  configure.args-delete \
-  --includes=${python_prefix}/include/python2.6 \
-  --python=${python_prefix}/bin/python2.6 \
-  --pydir=${python_prefix}/lib/python2.6/site-packages
+foreach s ${pythons_suffixes} {
+    set p python${s}
+    set v [string index ${s} 0].[string index ${s} 1]
+    set i [lsearch -exact ${pythons_ports} ${p}]
+    set c [lreplace ${pythons_ports} ${i} ${i}]
+    eval [subst {
+        variant ${p} description "Use Python ${v} for python bindings" conflicts ${c} {
+            depends_lib-append      port:${p} \
+                                    port:py${s}-numpy \
+                                    port:swig-python
+            set py_prefix \[python_prefix\]
+            configure.args-append   --python=${prefix}/bin/python${v} \
+                                    --pydir=\${py_prefix}/lib/python${v}/site-packages \
+                                    --includes=\${py_prefix}/include/python${v}
+            post-patch {
+                reinplace "s|^PYTHON=python$|PYTHON=${prefix}/bin/python${v}|g" ${worksrcpath}/configure
+            }
+        }
+    }]
+}
 
-
-  depends_lib-delete port:python26 \
-                     port:py26-numpy
-
+variant perl description {Build the Perl API} {
+    depends_lib-append  port:swig-perl
 }
 
 variant r description {Build the R API} {
-    depends_lib-append port:swig-r
+    depends_lib-append  port:swig-r
 }
 
 variant octave description {Build the Octave API} {
-    depends_lib-append port:swig-octave
+    depends_lib-append  port:swig-octave
 }
 
-variant no_glpk description {Disable glpk support} {
-    configure.args-append --disable-glpk
-     depends_lib-delete port:glpk
+variant java description {Build the Java API} {
+    depends_lib-append  port:swig-java
 }
 
-#variant matlab description {Build the Matlab API} {}
-# variant doc description {Install the documentation for shogun} {
-#   depends_build-append port:texlive \
-#                        path:bin/dot:graphviz \
-#                        port:doxygen
-#
-#   configure.args-delete --disable-doxygen
-# }
+variant csharp description {Build the C# API} {
+    depends_lib-append  port:swig-csharp
+}
 
-variant gcc43 conflicts gcc44 gcc45 gcc46 gcc47 description {build with gcc 4.3} {}
-variant gcc44 conflicts gcc43 gcc45 gcc46 gcc47 description {build with gcc 4.4} {}
-variant gcc45 conflicts gcc43 gcc44 gcc46 gcc47 description {build with gcc 4.5} {}
-variant gcc46 conflicts gcc43 gcc44 gcc45 gcc47 description {build with gcc 4.6} {}
-variant gcc47 conflicts gcc43 gcc44 gcc45 gcc46 description {build with gcc 4.7} {}
+variant lua description {Build the Lua API} {
+    depends_lib-append  port:swig-lua
+}
 
-if {[variant_isset gcc43]} {
-    set gccversion 4.3
-} elseif {[variant_isset gcc44]} {
-    set gccversion 4.4
-} elseif {[variant_isset gcc45]} {
-    set gccversion 4.5
-} elseif {[variant_isset gcc46]} {
-    set gccversion 4.6
-} else {
-    default_variants +gcc47
-    set gccversion 4.7
+variant ruby description {Build the Ruby API} {
+    depends_lib-append  port:swig-ruby
 }
 
-set gccnumber [join [split ${gccversion} .] ""]
+variant elwms description {Build the elwms (eierlegende wollmilchsau) interface. Requires python plus one other interface} {
+}
 
-depends_lib-append      port:gcc${gccnumber}
-configure.cc            ${prefix}/bin/gcc-mp-${gccversion}
-configure.compiler      macports-gcc-${gccversion}
-configure.args-append   --cc=${prefix}/bin/gcc-mp-${gccversion} \
-                        --cxx=${prefix}/bin/g++-mp-${gccversion}
+variant hmm_parallel description {Enable parallel structures in hmm training} {
+    configure.args-delete --disable-hmm-parallel
+    configure.args-append --enable-hmm-parallel
+}
 
-pre-configure {
-  reinplace "s|@@PREFIX@@|${prefix}|g" ${worksrcpath}/configure
-  reinplace "s|= $\{_libdir\}/$\{_pydir\}|= $\{_pydir\}|g" ${worksrcpath}/configure
+proc lremove {list elem} {
+    set index [lsearch -exact $list $elem]
+    return [lreplace $list $index $index]
 }
-post-destroot {
-  if {[variant_isset doc]} {
-    system "cd ${worksrcpath}/../doc && make"
-    file mkdir ${destroot}${prefix}/share/doc/${name}
-    file copy ${worksrcpath}/../doc ${destroot}${prefix}/share/doc/${name}/doc
 
-  }
+# Interfaces are added by a comma delimited argument list to --interfaces.
+# We check for variants and then build this list accordingly
+set interfaces "cmdline_static"
+
+if {[variant_isset python26] || [variant_isset python27]} {
+    lappend interfaces "python_modular"
 }
 
-livecheck.url http://www.shogun-toolbox.org
-livecheck.regex {SHOGUN Version ([0-9.]+).*}
+if {[variant_isset perl]} {
+    lappend interfaces "perl_modular"
+}
+
+if {[variant_isset r]} {
+    lappend interfaces "r_modular"
+}
+
+if {[variant_isset octave]} {
+    lappend interfaces "octave_modular"
+}
+
+if {[variant_isset java]} {
+    lappend interfaces "java_modular"
+}
+
+if {[variant_isset csharp]} {
+    lappend interfaces "csharp_modular"
+}
+
+if {[variant_isset lua]} {
+    lappend interfaces "lua_modular"
+}
+
+if {[variant_isset ruby]} {
+    lappend interfaces "ruby_modular"
+}
+
+if {[variant_isset elwms] && !(([variant_isset python26] || [variant_isset python27]) && [variant_isset octave] && [variant_isset r])} {
+    return -code error "Must set python2x and both r and octave variants to build elwms interface"
+} elseif {[variant_isset elwms]} {
+    lappend interfaces "elwms_static"
+}
+
+configure.args-append \
+                    --enable-hdf5 \
+                    --enable-json \
+                    --enable-xml \
+                    --enable-readline \
+                    --enable-largefile \
+                    --disable-spinlocks \
+                    --enable-lapack \
+                    --enable-arpack \
+                    --disable-mosek \
+                    --disable-superlu \
+                    --disable-nlopt \
+                    --enable-eigen3 \
+                    --disable-cplex \
+                    --enable-lpsolve \
+                    --enable-glpk \
+                    --enable-lzo \
+                    --enable-snappy \
+                    --enable-gzip \
+                    --enable-bzip2 \
+                    --enable-lzma \
+                    --enable-bigstates \
+                    --enable-hmmcache \
+                    --enable-svm-light \
+                    --disable-logcache \
+                    --enable-shortrealkernelcache \
+                    --enable-logsum-array \
+                    --disable-hmm-parallel \
+                    --disable-doxygen \
+                    --enable-optimization \
+                    --disable-cpudetection \
+                    --includes=${prefix}/include \
+                    --libs=${prefix}/lib \
+                    --destdir=${destroot} \
+                    --prefix=${prefix}
+
+set interfaces [join $interfaces ","]
+
+configure.args-append --interfaces=$interfaces
+
+livecheck.type      regex
+livecheck.url       http://www.shogun-toolbox.org
+livecheck.regex     {SHOGUN ([0-9.]+)}
Index: files/patch-src_configure.diff
===================================================================
--- files/patch-src_configure.diff	(revision 0)
+++ files/patch-src_configure.diff	(working copy)
@@ -0,0 +1,46 @@
+--- configure.orig	2013-03-28 23:54:09.000000000 +0400
++++ configure	2013-03-30 23:32:20.000000000 +0400
+@@ -16,7 +16,7 @@
+ # some hopefully reasonable defaults
+ LDD=ldd
+ POSTLINKCMD="true"
+-MAKEDEPEND="gcc -MM"
++MAKEDEPEND="@@MAKEDEPEND@@"
+ MAKEDEPENDOPTS=""
+ SRCDIR="`dirname $0`"
+ LIBRARY_PATH=LD_LIBRARY_PATH
+@@ -184,7 +184,7 @@
+ DEFINES_SWIG=
+ PRELINKFLAGS=
+ LINKFLAGS=
+-POSTLINKFLAGS=
++test "$POSTLINKFLAGS" && POSTLINKFLAGS="$POSTLINKFLAGS"
+ 
+ INCLUDES_STATIC_INTERFACES=
+ LINKFLAGS_STATIC_INTEFACES=
+@@ -4003,7 +4003,7 @@
+ }
+ EOF
+ 		echocheck "lpsolve Developer Files"
+-		LPSOLVELINKFLAGS="-L /usr/lib/lp_solve -llpsolve55"
++		LPSOLVELINKFLAGS="-llpsolve55"
+ 		if cc_check $LPSOLVELINKFLAGS
+ 		then
+ 			echores "yes"
+@@ -5011,6 +5011,7 @@
+ 		if test "$_readline" = yes || test "$_readline" = auto;
+ 		then
+ cat > $TMPC << EOF
++#include <stdio.h>
+ #include <readline/readline.h>
+ int main(void) { return 0; }
+ EOF
+@@ -5274,7 +5275,7 @@
+ CONFDIR			= ${_confdir}
+ INCDIR			= ${_incdir}
+ LIBDIR			= ${_libdir}
+-PYDIR			= ${_libdir}/${_pydir}
++PYDIR			= ${_pydir}
+ OCTDIR			= ${_octdir}
+ RDIR			= ${_rdir}
+ EOF
Index: files/swig_version.patch
===================================================================
--- files/swig_version.patch	(revision 104608)
+++ files/swig_version.patch	(working copy)
@@ -1,12 +0,0 @@
---- configure.old	2010-06-29 10:41:05.000000000 -0700
-+++ configure	2010-06-29 10:42:07.000000000 -0700
-@@ -2864,7 +2864,8 @@
- 				die "swig did not return version information"
- 			fi
- 			if [ `echo $_swig_version | cut -f 2 -d '.'` -ge 4 ] || \
--				[ `echo $_swig_version | cut -f 3 -d '.'` -ge 29 ]
-+				[ `echo $_swig_version | cut -f 3 -d '.'` -ge 29 ] || \
-+        [ `echo $_swig_version | cut -f 1 -d '.'` -ge 2 ]
- 			then
- 				echores "`${SWIG} -version 2>&1 | grep Version | cut -f 3 -d ' '`"
- 
