From 330c717f53c10ce1fc9c3205654a621d1883e320 Mon Sep 17 00:00:00 2001
From: Giovanni Bussi <giovanni.bussi@gmail.com>
Date: Sun, 14 Jul 2013 23:27:12 +0200
Subject: [PATCH] Added "has" tools

Added more ways to check if tools are installed. Now also
plumed --has-matheval
is allowed
---
 src/config/Config.cpp.in | 17 +++++++++++++++++
 src/config/Config.h      |  4 ++++
 src/core/CLToolMain.cpp  |  5 ++++-
 3 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/src/config/Config.cpp.in b/src/config/Config.cpp.in
index c683fa7be..475d3c79c 100644
--- a/src/config/Config.cpp.in
+++ b/src/config/Config.cpp.in
@@ -41,6 +41,23 @@ std::string getMakefile(){
   return std::string(conf,conf+std::strlen(conf));
 }
 
+bool hasMatheval(){
+#if __PLUMED_HAS_MATHEVAL
+      return true;
+#else
+      return false;
+#endif
+}
+
+bool hasDlopen(){
+#if __PLUMED_HAS_DLOPEN
+      return true;
+#else
+      return false;
+#endif
+}
+
+
 }
 }
 
diff --git a/src/config/Config.h b/src/config/Config.h
index 623854ea0..c5fd8f75a 100644
--- a/src/config/Config.h
+++ b/src/config/Config.h
@@ -33,6 +33,10 @@ std::string getPlumedRoot();
 
 std::string getMakefile();
 
+bool hasMatheval();
+
+bool hasDlopen();
+
 }
 }
 
diff --git a/src/core/CLToolMain.cpp b/src/core/CLToolMain.cpp
index 902e29a27..4f6787877 100644
--- a/src/core/CLToolMain.cpp
+++ b/src/core/CLToolMain.cpp
@@ -118,6 +118,8 @@ int CLToolMain::run(int argc, char **argv,FILE*in,FILE*out,Communicator& pc){
     } else if(a=="--has-mpi"){
       if(Communicator::initialized()) return 0;
       else return 1;
+    } else if(a=="--has-matheval"){
+      return (config::hasMatheval()?0:1);
     } else if(a=="--no-mpi"){
 // this is ignored, as it is parsed in main
       if(i>1){
@@ -176,7 +178,8 @@ int CLToolMain::run(int argc, char **argv,FILE*in,FILE*out,Communicator& pc){
         "  plumed [command] -h       : to print help for a specific command\n"
         "Options:\n"
         "  [help|-h|--help]          : to print this help\n"
-        "  [--has-mpi]               : fails if plumed is running with MPI\n"
+        "  [--has-mpi]               : fails if plumed is running without MPI\n"
+        "  [--has-matheval]          : fails if plumed is compiled without matheval\n"
         "  [--load LIB]              : loads a shared object (typically a plugin library)\n"
         "  [--standalone-executable] : tells plumed not to look for commands implemented as scripts\n"
         "Commands:\n";
-- 
GitLab