diff --git a/configure b/configure index 82340662a283287a344ecb1d7ad49141a61e9e07..7be91dfb0111e3157591414f52f435d9f0bb85a0 100755 --- a/configure +++ b/configure @@ -7087,6 +7087,9 @@ fi if test "$(echo "$program_name" | tr 'A-Z' 'a-z')" != "$(echo "$program_name" | tr 'A-Z' 'a-z' | sed 's/-patch$//')" ; then as_fn_error $? "$program_name is not a valid program name (should not terminate with -patch)" "$LINENO" 5 fi +if test "$(echo "$program_name" | tr 'A-Z' 'a-z')" != "$(echo "$program_name" | tr 'A-Z' 'a-z' | sed 's/-config$//')" ; then + as_fn_error $? "$program_name is not a valid program name (should not terminate with -config)" "$LINENO" 5 +fi { $as_echo "$as_me:${as_lineno-$LINENO}: **** PLUMED will be installed using the following paths:" >&5 $as_echo "$as_me: **** PLUMED will be installed using the following paths:" >&6;} diff --git a/configure.ac b/configure.ac index 60f629bd8f68237129687e5915c8490fb744bca1..1c38b511f57a2435b80590a3e608f7268811d4ed 100644 --- a/configure.ac +++ b/configure.ac @@ -775,6 +775,9 @@ fi if test "$(echo "$program_name" | tr '[A-Z]' '[a-z]')" != "$(echo "$program_name" | tr '[A-Z]' '[a-z]' | sed 's/-patch$//')" ; then AC_MSG_ERROR([$program_name is not a valid program name (should not terminate with -patch)]) fi +if test "$(echo "$program_name" | tr '[A-Z]' '[a-z]')" != "$(echo "$program_name" | tr '[A-Z]' '[a-z]' | sed 's/-config$//')" ; then + AC_MSG_ERROR([$program_name is not a valid program name (should not terminate with -config)]) +fi AC_MSG_NOTICE([**** PLUMED will be installed using the following paths:]) AC_MSG_NOTICE([**** prefix: $prefix]) diff --git a/scripts/config.sh b/scripts/config.sh new file mode 100755 index 0000000000000000000000000000000000000000..2f68e6b2b64fe2d7d68ec9772dad352ff1ee3221 --- /dev/null +++ b/scripts/config.sh @@ -0,0 +1,90 @@ +#! /bin/bash + +MANUAL="\ + +Options: + -h, --help + print this help and exit + -q, --quiet + don't write anything, just return true of false + show + dump a full configuration file + has [word1 [word2]..] + check if plumed has features words + module [word1 [word2]..] + check if plumed has enables modules words + +Examples: + +Check if plumed as xdrfile enabled +> plumed config has xdrfile +Check if plumed as xdrfile AND zlib enabled +> plumed config has xdrfile zlib +Check if plumed as module colvar active +> plumed config module colvar +" + +configfile="$(cat "$PLUMED_ROOT"/src/config/config.txt)" + +quiet=no +list=no +checklist="" +for opt +do + case "$opt" in + (--help|-h) echo "$MANUAL" ; exit ;; + (--description) + echo "inquire plumed about how it was configure" + exit 0 + ;; + (--quiet|-q) quiet=yes ;; + (--version|-v) action=version ;; + (show) + echo "$configfile" + exit 0 + ;; + (has) action=has ;; + (module) action=module ;; + (*) + checklist="$checklist $opt" + esac +done + +if test -z "$checklist" && ( test "$action" = show || test "$action" = has || test "$action" = module) +then + test "$quiet" = no && echo "nothing to do" + exit 1 +fi + +case $action in +(has|module) + retval=0 + for check in $checklist + do + + ff=$( + echo "$configfile" | + awk -v action="$action" -v check="$check" '{ if($1==action && $2==check){ print $3;exit } }' + ) + + if test "$ff" = on ; then + test "$quiet" = no && echo "$check on" + elif test "$ff" = off ; then + test "$quiet" = no && echo "$check off" + retval=1 + else + test "$quiet" = no && echo "$check not found" + retval=1 + fi + + done + + exit $retval + ;; +(version) + long=$(echo "$configfile" | grep -v \# | awk '{ if($1=="version" && $2=="long") print $3 }') + git=$(echo "$configfile" | grep -v \# | awk '{ if($1=="version" && $2=="git") print $3 }') + echo "Version: $long (git: $git)" + ;; +esac + diff --git a/src/core/CLToolMain.cpp b/src/core/CLToolMain.cpp index e5eb16190b36e104c2b4de80f6d4c14cd3c0bd28..198d49d40b9281a472c45c19a83a219fabc520db 100644 --- a/src/core/CLToolMain.cpp +++ b/src/core/CLToolMain.cpp @@ -243,8 +243,12 @@ int CLToolMain::run(int argc, char **argv,FILE*in,FILE*out,Communicator& pc){ plumed_massert(out==stdout,"shell tools can only work on stdin"); string cmd=config::getEnvCommand()+" \""+root+"/scripts/"+command+".sh\""; for(int j=i+1;j<argc;j++) cmd+=string(" ")+argv[j]; - system(cmd.c_str()); - return 0; + int r=system(cmd.c_str()); +// this is necessary since system seems to return numbers which are multiple +// of 256. this would make the interpretation by the shell wrong +// I just return 1 in case of failure and 0 in case of success + if(r!=0) return 1; + else return 0; } string msg="ERROR: unknown command " + command + ". Use 'plumed help' for help"; diff --git a/src/lib/Makefile b/src/lib/Makefile index 7a36b5297f70783fd7c032701dc05d893216be4d..d9c18b2f48fbf48bf0e41d7ff64adc2aa17a7453 100644 --- a/src/lib/Makefile +++ b/src/lib/Makefile @@ -177,6 +177,8 @@ endif cp install/plumed "$(DESTDIR)$(bindir)/$(program_name)" # patch file for cross compiling cp install/plumed-patch "$(DESTDIR)$(bindir)/$(program_name)-patch" +# config file for cross compiling + cp install/plumed-patch "$(DESTDIR)$(bindir)/$(program_name)-config" # copy include files for cmake and make # we leave it in src/lib/ for backward compatibility cp install/Plumed.cmake* "$(DESTDIR)$(libdir)/$(program_name)/src/lib/" @@ -225,6 +227,7 @@ endif @echo $(includedir)/$(program_name) @echo $(bindir)/$(program_name) @echo $(bindir)/$(program_name)-patch + @echo $(bindir)/$(program_name)-config ifdef SOEXT @echo $(libdir)/lib$(program_name).$(SOEXT) @echo $(libdir)/lib$(program_name)Kernel.$(SOEXT) @@ -238,6 +241,7 @@ endif ifeq ($(program_can_run),no) @echo "WARNING: $(program_name) executable will not run on this machine" @echo "WARNING: to patch an MD code use 'plumed-patch'" + @echo "WARNING: to verify configuration use 'plumed-config'" @echo "WARNING: a few other command line tools are avalable as $(libdir)/$(program_name)/plumed-*" else ifeq ($(program_can_run_mpi),no) @echo "WARNING: $(program_name) executable will not run on this machine" @@ -257,6 +261,7 @@ uninstall: @echo "$(DESTDIR)$(includedir)/$(program_name)" @echo "$(DESTDIR)$(bindir)/$(program_name)" @echo "$(DESTDIR)$(bindir)/$(program_name)-patch" + @echo "$(DESTDIR)$(bindir)/$(program_name)-config" @echo "$(DESTDIR)$(libdir)/lib$(program_name).$(SOEXT)" @echo "$(DESTDIR)$(libdir)/lib$(program_name)Kernel.$(SOEXT)" ../maketools/confirm_uninstall @@ -266,6 +271,7 @@ uninstall: rm -fr "$(DESTDIR)$(includedir)/$(program_name)" rm -f "$(DESTDIR)$(bindir)/$(program_name)" rm -f "$(DESTDIR)$(bindir)/$(program_name)-patch" + rm -f "$(DESTDIR)$(bindir)/bin/$(program_name)-config" rm -f "$(DESTDIR)$(libdir)/lib$(program_name).$(SOEXT)" rm -f "$(DESTDIR)$(libdir)/lib$(program_name)Kernel.$(SOEXT)"