Index: Portfile
===================================================================
--- Portfile	(revision 143520)
+++ Portfile	(working copy)
@@ -10,7 +10,7 @@
 
 github.setup        root-mirror root 5-34-34 v
 version             5.34.34
-revision            1
+revision            2
 
 set version_major   [lindex [split ${version} .] 0]
 
@@ -50,6 +50,8 @@
 select.group        root
 select.file         ${filespath}/${name}
 
+patchfiles-append   patch-math-mathmore-src-GSLMultiFit.h.diff
+
 post-patch {
 #   reinplace "s|-lfreetype| \`freetype-config --libs\`|g" ${worksrcpath}/config/root-config.in
     reinplace "s|\"/usr/include\"|\"${prefix}/include /usr/include\"|g" ${worksrcpath}/configure
@@ -187,7 +189,7 @@
 
 universal_variant   no
 
-default_variants    +ssl +xml +minuit2 +tmva +roofit +graphviz +opengl +soversion +http
+default_variants    +ssl +xml +gsl +minuit2 +tmva +roofit +graphviz +opengl +soversion +http
 
 # Since ROOT 5.34.15 the cocoa backend is default on OSX 10.8 or newer
 # We also make it default on 10.7
Index: files/patch-math-mathmore-src-GSLMultiFit.h.diff
===================================================================
--- files/patch-math-mathmore-src-GSLMultiFit.h.diff	(nonexistent)
+++ files/patch-math-mathmore-src-GSLMultiFit.h.diff	(working copy)
@@ -0,0 +1,77 @@
+From 850a56cad37733694a6858314e30e3dafbacc220 Mon Sep 17 00:00:00 2001
+From: Pere Mato <pere.mato@cern.ch>
+Date: Tue, 15 Dec 2015 11:58:24 +0100
+Subject: [PATCH] Fix for ROOT-7776 - Integrate GSL 2.0 in ROOT.
+
+---
+ math/mathmore/src/GSLMultiFit.h | 40 ++++++++++++++++++++++++++--------------
+ 1 file changed, 26 insertions(+), 14 deletions(-)
+
+diff --git a/math/mathmore/src/GSLMultiFit.h b/math/mathmore/src/GSLMultiFit.h
+index a1cb348..e2570a0 100644
+--- math/mathmore/src/GSLMultiFit.h
++++ math/mathmore/src/GSLMultiFit.h
+@@ -31,6 +31,7 @@
+ #include "gsl/gsl_matrix.h"
+ #include "gsl/gsl_multifit_nlin.h"
+ #include "gsl/gsl_blas.h"
++#include "gsl/gsl_version.h"
+ #include "GSLMultiFitFunctionWrapper.h"
+ 
+ #include "Math/IFunction.h"
+@@ -127,20 +128,24 @@ class GSLMultiFit {
+    int Iterate() { 
+       if (fSolver == 0) return -1; 
+       return gsl_multifit_fdfsolver_iterate(fSolver); 
+-   }
+-
+-   /// parameter values at the minimum 
+-   const double * X() const { 
+-      if (fSolver == 0) return 0; 
+-      gsl_vector * x =  gsl_multifit_fdfsolver_position(fSolver);       
+-      return x->data; 
+    } 
+ 
+-   /// gradient value at the minimum 
+-   const double * Gradient() const { 
+-      if (fSolver == 0) return 0; 
+-      gsl_multifit_gradient(fSolver->J, fSolver->f,fVec);       
+-      return fVec->data; 
++   /// parameter values at the minimum
++   const double * X() const {
++      if (fSolver == 0) return 0;
++      gsl_vector * x =  gsl_multifit_fdfsolver_position(fSolver);
++      return x->data;
++   }
++
++   /// gradient value at the minimum
++   const double * Gradient() const {
++      if (fSolver == 0) return 0;
++#if GSL_MAJOR_VERSION  > 1
++      fType->gradient(fSolver->state, fVec);
++#else
++      gsl_multifit_gradient(fSolver->J, fSolver->f,fVec);
++#endif
++      return fVec->data;
+    }
+ 
+    /// return covariance matrix of the parameters
+@@ -150,9 +155,16 @@ class GSLMultiFit {
+       unsigned int npar = fSolver->fdf->p; 
+       fCov = gsl_matrix_alloc( npar, npar ); 
+       static double kEpsrel = 0.0001;
++#if GSL_MAJOR_VERSION > 1
++      gsl_matrix* J = gsl_matrix_alloc(npar,npar);
++      gsl_multifit_fdfsolver_jac (fSolver, J);
++      int ret = gsl_multifit_covar(J, kEpsrel, fCov);
++      gsl_matrix_free(J);
++#else
+       int ret = gsl_multifit_covar(fSolver->J, kEpsrel, fCov);
+-      if (ret != GSL_SUCCESS) return 0; 
+-      return fCov->data; 
++#endif
++      if (ret != GSL_SUCCESS) return 0;
++      return fCov->data;
+    }
+ 
+    /// test gradient (ask from solver gradient vector)
Index: files/root5
===================================================================
--- files/root5	(revision 143520)
+++ files/root5	(working copy)
@@ -28,6 +28,14 @@
 libexec/root5/bin/thisroot.sh
 libexec/root5/bin/xpdtest
 -
+-
+-
+-
+-
+-
+-
+-
+-
 libexec/root5/share/man/man1/cint.1.gz
 libexec/root5/share/man/man1/g2root.1.gz
 libexec/root5/share/man/man1/g2rootold.1.gz
