diff --git a/macports/Portfile.in b/macports/Portfile.in
index 1a02df19c9947614363f048bc00ea552d26f4a93..c810cde80ed33e21e5eef92fea8d9307d6becf55 100644
--- a/macports/Portfile.in
+++ b/macports/Portfile.in
@@ -35,12 +35,9 @@ homepage            http://www.plumed.org/
 # sure that even if the user has that package already installed plumed is
 # not going to use it.
 configure.args-append \
-               --disable-matheval \
-               --disable-xdrfile \
+               --disable-libsearch \
                --disable-molfile-plugins \
-               --disable-zlib \
-               --disable-mpi \
-               --disable-gsl
+               --disable-mpi 
 
 # Hardcode path for libplumedKernel.dylib.
 # This allows to patch MD codes using the --runtime option but using as
@@ -57,24 +54,22 @@ if {[mpi_variant_isset]} {
 }
 
 variant matheval description {Enable libmatheval} {
-  configure.args-replace --disable-matheval --enable-matheval
-# this is needed due to a problem with libmatheval:
-  depends_lib-append port:flex
+  configure.ldflags-append -lmatheval
   depends_lib-append port:libmatheval
 }
 
 variant xdrfile description {Enable xdrfile} {
-  configure.args-replace --disable-xdrfile --enable-xdrfile
+  configure.ldflags-append -lxdrfile
   depends_lib-append port:xdrfile
 }
 
 variant zlib description {Enable zlib} {
-  configure.args-replace --disable-zlib --enable-zlib
+  configure.ldflags-append -lz
   depends_lib-append port:zlib
 }
 
 variant gsl description {Enable gsl} {
-  configure.args-replace --disable-gsl --enable-gsl
+  configure.ldflags-append -lgsl
   depends_lib-append port:gsl
 }