1# DO NOT EDIT ./configure FILE 2# One should edit configure.ac and the run autoconf in this 3# directory. Also the resulting "configure" is stored on the git, 4# so as to allow people not to install a recent autoconf on their 5# system. 6# If you modify configure.ac, remember to run 7# autoconf and then commit both files to the git repository. 8 9# we require a recent version 10# notice that autoconf is not necessary on user's machine, but only 11# if one has to update configure.ac 12AC_PREREQ([2.68]) 13AC_INIT([PLUMED], [2]) 14 15################################################################## 16# In order to add m4 macros, put then in a m4 directory and include them here. 17# E.g.: 18# m4_include([./m4/m4_ax_openmp.m4]) 19 20################################################################## 21# Here we define a few useful macros 22 23# PLUMED_CONFIG_ENABLE(variablename,optionname,doc,default) 24# notice that variablename and optionname are likely identical, 25# they just need to be different with optionname contains a "-" 26# (not allowed in shell variable names) 27AC_DEFUN([PLUMED_CONFIG_ENABLE], [ 28m4_bpatsubst([$1],-,_)= 29AC_ARG_ENABLE([$1], 30 AS_HELP_STRING([--enable-$1], [enable $2, default: $3]), 31 [case "${enableval}" in 32 (yes) m4_bpatsubst([$1],-,_)=true ;; 33 (no) m4_bpatsubst([$1],-,_)=false ;; 34 (*) AC_MSG_ERROR([wrong argument to --enable-$1]) ;; 35 esac], 36 [case "$3" in 37 (yes) m4_bpatsubst([$1],-,_)=true ;; 38 (no) m4_bpatsubst([$1],-,_)=false ;; 39 esac] 40) 41]) 42 43# PLUMED_CHECK_CXXFLAG(flag) 44# use it to check if a flag is available on this compiler 45AC_DEFUN([PLUMED_CHECK_CXXFLAG], [ 46 save_CXXFLAGS="$CXXFLAGS" 47 CXXFLAGS="$CXXFLAGS $1" 48 AC_MSG_CHECKING([whether $CXX accepts $1]) 49 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], 50 [ 51 AC_LINK_IFELSE([AC_LANG_PROGRAM([])], 52 [AC_MSG_RESULT([yes])], 53 [AC_MSG_RESULT([not linking]); CXXFLAGS="$save_CXXFLAGS"]) 54 ], 55 [AC_MSG_RESULT([no]); CXXFLAGS="$save_CXXFLAGS"] 56 ) 57]) 58 59# PLUMED_CHECK_CFLAG(flag) 60# use it to check if a flag is available on this compiler 61AC_DEFUN([PLUMED_CHECK_CFLAG], [ 62 AC_LANG_PUSH(C) 63 save_CFLAGS="$CFLAGS" 64 CFLAGS="$CFLAGS $1" 65 AC_MSG_CHECKING([whether $CC accepts $1]) 66 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], 67 [ 68 AC_LINK_IFELSE([AC_LANG_PROGRAM([])], 69 [AC_MSG_RESULT([yes])], 70 [AC_MSG_RESULT([not linking]); CCFLAGS="$save_CCFLAGS"]) 71 ], 72 [AC_MSG_RESULT([no]); CCFLAGS="$save_CCFLAGS"] 73 ) 74 AC_LANG_POP 75]) 76 77# PLUMED_CHECK_LDFLAGS(flag) 78# use it to check if a flag is available on this compiler 79AC_DEFUN([PLUMED_CHECK_LDFLAGS], [ 80 save_LDFLAGS="$LDFLAGS" 81 LDFLAGS="$LDFLAGS $1" 82 AC_MSG_CHECKING([whether LDFLAGS can contain $1]) 83 AC_LINK_IFELSE([AC_LANG_PROGRAM([])], 84 [AC_MSG_RESULT([yes])], 85 [AC_MSG_RESULT([no]); LDFLAGS="$save_LDFLAGS"]) 86]) 87 88# PLUMED_SEARCH_LIBS(function,search-libs[,action-if-found][,action-if-not-found][,other-libraries]) 89# same as AC_SEARCH_LIBS, but does not try any library unless $libsearch==true 90# Should be used instead of AC_SEARCH_LIBS in order to make --disable-libsearch work correctly 91AC_DEFUN([PLUMED_SEARCH_LIBS], [ 92 if test "${libsearch}" == true ; then 93 AC_SEARCH_LIBS([$1],[$2],[$3],[$4],[$5]) 94 else 95 AC_SEARCH_LIBS([$1],[],[$3],[$4],[]) 96 fi 97]) 98 99# PLUMED_CHECK_PACKAGE(header,function,define[,library]) 100# first we check if the header is present. if so, we check if the given function can be found. 101# if it cannot be found and the fourth argument (library) has been supplied, we look for it 102# in the library. finally, we set the define flag 103AC_DEFUN([PLUMED_CHECK_PACKAGE], [ 104 found=ko 105 $3=no 106 AC_CHECK_HEADER( [$1],[ 107 PLUMED_SEARCH_LIBS([$2],[$4],[found=ok]) 108 ]) 109 if test $found == ok ; then 110 AC_DEFINE([$3]) 111 $3=yes 112 else 113 AC_MSG_WARN([cannot enable $3]) 114 fi 115]) 116 117# PLUMED_CHECK_CXX_PACKAGE(name,program,define[,library]) 118# Similar to PLUMED_CHECK_PACKAGE but suitable for checking C++ libraries. 119# Name is just a string used in the configure log 120# program is a string containing a short C++ program that should compiled. 121# If present and necessary, library is also linked. 122AC_DEFUN([PLUMED_CHECK_CXX_PACKAGE], [ 123 found=ko 124 $3=no 125 if test "${libsearch}" == true ; then 126 testlibs="$4" 127 else 128 testlibs="" 129 fi 130 for testlib in "" $testlibs 131 do 132 save_LIBS="$LIBS" 133 if test -n "$testlib" ; then 134 AC_MSG_CHECKING([$1 with -l$testlib]) 135 LIBS="-l$testlib $LIBS" 136 else 137 AC_MSG_CHECKING([$1 without extra libs]) 138 fi 139 AC_LINK_IFELSE([AC_LANG_SOURCE([$2])], 140 [found=ok] 141 [AC_MSG_RESULT([yes])], 142 [AC_MSG_RESULT([no])] 143 ) 144 if test $found == ok ; then 145 break 146 fi 147 LIBS="$save_LIBS" 148 done 149 if test $found == ok ; then 150 AC_DEFINE([$3]) 151 $3=yes 152 else 153 AC_MSG_WARN([cannot enable $3]) 154 LIBS="$save_LIBS" 155 fi 156]) 157 158################################################################## 159 160AC_MSG_NOTICE([Optional modules are disabled by default]) 161rm -f src/*.on src/*.off 162 163AC_ARG_ENABLE([modules], 164 AS_HELP_STRING([--enable-modules], [all/none/reset or : separated list such as +crystallization:-bias default: reset]), 165 [ 166 rm -f src/*.on src/*.off 167 if test "${enableval}" == yes ; then 168 enableval=reset 169 fi 170 if test "${enableval}" == no ; then 171 enableval=none 172 fi 173 for modules_mod in `echo "${enableval}" | sed 's/:/ /g' | sed 's/+/ +/g' | sed 's/-/ -/g'` 174 do 175 case "$modules_mod" in 176 (none) 177 AC_MSG_NOTICE([Disabling all optional modules]) 178 rm -f src/*.off src/*.on 179 touch $(grep default-on src/*/module.type | sed "s|/module.type:.*|.off|") ;; 180 (all) 181 AC_MSG_NOTICE([Enabling all optional modules]) 182 rm -f src/*.off src/*.off 183 touch $(grep default-off src/*/module.type | sed "s|/module.type:.*|.on|") ;; 184 (reset) 185 AC_MSG_NOTICE([Resetting modules to default]) 186 rm -f src/*.on src/*.off ;; 187 (-*) 188 modules_mod=`echo "${modules_mod}" | sed "s|-||"` 189 if test ! -f src/$modules_mod/module.type ; then 190 AC_MSG_ERROR([trying to remove module $modules_mod which does not exist]) 191 fi 192 AC_MSG_NOTICE([Disabling module ${modules_mod}]) 193 rm -f src/$modules_mod.on 194 touch src/$modules_mod.off ;; 195 (+*) 196 modules_mod=`echo "${modules_mod}" | sed "s|+||"` 197 if test ! -f src/$modules_mod/module.type ; then 198 AC_MSG_ERROR([trying to add module $modules_mod which does not exist]) 199 fi 200 AC_MSG_NOTICE([Enabling module ${modules_mod}]) 201 rm -f src/$modules_mod.off 202 touch src/$modules_mod.on ;; 203 (*) 204 if test ! -f src/$modules_mod/module.type ; then 205 AC_MSG_ERROR([trying to add module $modules_mod which does not exist]) 206 fi 207 AC_MSG_NOTICE([Enabling module ${modules_mod}]) 208 rm -f src/$modules_mod.off 209 touch src/$modules_mod.on ;; 210 esac 211 done 212 ] 213 , 214 [] 215) 216 217 218# set enable flags for ./configure 219 220# This can be disabled when configuring within a package manager 221# such as macports to make sure that only libraries explicitly 222# listed in LDFLAGS are linked 223PLUMED_CONFIG_ENABLE([libsearch],[search for libraries],[yes]) 224 225# This can be disabled to avoid the extra tests for static patching. 226# In the future, when this is disabled, we could disable the "--static" flag 227# of "plumed patch" 228PLUMED_CONFIG_ENABLE([static-patch],[allow statically linking plumed],[yes]) 229 230PLUMED_CONFIG_ENABLE([doc],[documentation],[yes]) 231PLUMED_CONFIG_ENABLE([pdfdoc],[pdf version of the manual],[no]) 232PLUMED_CONFIG_ENABLE([debug],[debugging],[no]) 233PLUMED_CONFIG_ENABLE([gcov],[gcov to estimate code coverage],[no]) 234PLUMED_CONFIG_ENABLE([basic-warnings],[basic warnings],[yes]) 235PLUMED_CONFIG_ENABLE([fussy],[fussy warnings],[no]) 236PLUMED_CONFIG_ENABLE([debug-glibcxx],[enable boundary check],[no]) 237PLUMED_CONFIG_ENABLE([shared],[shared libs],[yes]) 238PLUMED_CONFIG_ENABLE([dependency-tracking],[dependency tracking],[yes]) 239PLUMED_CONFIG_ENABLE([rpath],[store rpath],[no]) 240PLUMED_CONFIG_ENABLE([absolute-soname],[store absolute soname (Linux only - this is the default behavior on OSX). Only enable for testing!],[no]) 241PLUMED_CONFIG_ENABLE([absolute-install-name],[store absolute relative (OSX only - disable to have a behavior similar to Linux). Only disable for testing!],[yes]) 242PLUMED_CONFIG_ENABLE([loader-path],[use @loader_path to find libplumedKernel.dylib (OSX only)],[yes]) 243PLUMED_CONFIG_ENABLE([bsymbolic],[use -Bsymbolic flag in making shared libraries (Linux only)],[yes]) 244PLUMED_CONFIG_ENABLE([ld-r],[group object files],[yes]) 245PLUMED_CONFIG_ENABLE([ar-cr],[use ar to build libplumedWrapper.a],[yes]) 246PLUMED_CONFIG_ENABLE([static-archive],[try to build libplumed.a for static linking],[yes]) 247PLUMED_CONFIG_ENABLE([asmjit],[enable embedded asmjit],[no]) 248PLUMED_CONFIG_ENABLE([mpi],[search for mpi],[yes]) 249PLUMED_CONFIG_ENABLE([external-lapack],[search for external lapack],[yes]) 250PLUMED_CONFIG_ENABLE([external-blas],[search for external blas],[yes]) 251PLUMED_CONFIG_ENABLE([molfile-plugins],[use molfile_plugins],[yes]) 252PLUMED_CONFIG_ENABLE([external-molfile-plugins],[search for external molfile_plugins],[yes]) 253PLUMED_CONFIG_ENABLE([zlib],[search for zlib],[yes]) 254PLUMED_CONFIG_ENABLE([readdir-r],[search for readdir_r (threadsafe)],[no]) 255PLUMED_CONFIG_ENABLE([cregex],[search for C regular expression],[yes]) 256PLUMED_CONFIG_ENABLE([dlopen],[search for dlopen],[yes]) 257PLUMED_CONFIG_ENABLE([rtld_default],[search for RTLD_DEFAULT macro],[yes]) 258PLUMED_CONFIG_ENABLE([chdir],[search for chdir function],[yes]) 259PLUMED_CONFIG_ENABLE([subprocess],[search for functions needed to manage a subprocess],[yes]) 260PLUMED_CONFIG_ENABLE([getcwd],[search for getcwd function],[yes]) 261PLUMED_CONFIG_ENABLE([execinfo],[search for execinfo],[yes]) 262PLUMED_CONFIG_ENABLE([gsl],[search for gsl],[yes]) 263PLUMED_CONFIG_ENABLE([xdrfile],[search for xdrfile],[yes]) 264PLUMED_CONFIG_ENABLE([boost_graph],[search for boost graph],[no]) 265PLUMED_CONFIG_ENABLE([boost_serialization],[search for boost serialization],[no]) 266PLUMED_CONFIG_ENABLE([fftw],[search for fftw],[yes]) 267PLUMED_CONFIG_ENABLE([python],[search for python],[yes]) 268PLUMED_CONFIG_ENABLE([af_ocl],[search for arrayfire_ocl],[no]) 269PLUMED_CONFIG_ENABLE([af_cuda],[search for arrayfire_cuda],[no]) 270PLUMED_CONFIG_ENABLE([af_cpu],[search for arrayfire_cpu],[no]) 271 272AC_ARG_VAR(SOEXT,[extension of dynamic libraries (so/dylib)]) 273AC_ARG_VAR(STATIC_LIBS,[variables that should be linked statically directly to MD code - configure will add here -ldl if necessary ]) 274AC_ARG_VAR(LDSHARED,[command for linking shared library - configure will use CXX plus the proper flags ]) 275AC_ARG_VAR(PYTHON_BIN,[python executable (e.g. python2.7 or /opt/local/bin/python2.7) - default: search for a python executable]) 276AC_ARG_VAR(BASH_COMPLETION_DIR,[path where bash completion will be installed - default: search with pkg-config]) 277AC_ARG_VAR(MPIEXEC,[command to run mpi programs in tests - default not specified, which means use PLUMED_MPIRUN env var at runtime for backward compatibility]) 278 279 280# by default use -O flag 281# we override the autoconf default (-g) because in release build we do not want to 282# include symbol information (obj files are huge) 283if test -z "$CXXFLAGS" 284then 285 CXXFLAGS=-O3 286fi 287 288# this is a list of common compilers 289compilers="g++ c++ cxx icpc" 290c_compilers="gcc cc icc" 291 292# on OSX, prefer clang++ 293case `(uname)` in 294 (Darwin) 295 compilers="clang++ $compilers" 296 c_compilers="clang $c_compilers" 297 ;; 298esac 299 300# if searching for MPI, try first mpi-like compilers 301if test $mpi == true ; then 302compilers="mpic++ mpicxx mpiicpc openmpic++ openmpicxx $compilers" 303fi 304 305# do the actual search 306AC_PROG_CXX([$compilers]) 307AC_PROG_CC([$c_compilers]) 308 309# also setup Fortran compiler 310# this is optional, and can be used in the late part of this 311# script to verify that fortran can indeed link properly the 312# a c++ library 313AC_PROG_FC 314 315# we use C++ for all the autoconf tests 316AC_LANG(C++) 317 318if test -z "$LDSHARED" ; then 319 LDSHARED="$CXX" 320fi 321 322AC_MSG_NOTICE([Initial CXX: $CXX]) 323AC_MSG_NOTICE([Initial CXXFLAGS: $CXXFLAGS]) 324AC_MSG_NOTICE([Initial CPPFLAGS: $CPPFLAGS]) 325AC_MSG_NOTICE([Initial CFLAGS: $CFLAGS]) 326AC_MSG_NOTICE([Initial LDFLAGS: $LDFLAGS]) 327AC_MSG_NOTICE([Initial LIBS: $LIBS]) 328AC_MSG_NOTICE([Initial STATIC_LIBS: $STATIC_LIBS]) 329AC_MSG_NOTICE([Initial LD: $LD]) 330AC_MSG_NOTICE([Initial LDSHARED: $LDSHARED]) 331AC_MSG_NOTICE([Initial SOEXT: $SOEXT]) 332 333# check C++ flags 334if test $shared == true 335then 336 PLUMED_CHECK_CXXFLAG([-fPIC]) 337 PLUMED_CHECK_CFLAG([-fPIC]) 338fi 339 340if test $basic_warnings == true 341then 342 PLUMED_CHECK_CXXFLAG([-Wall]) 343 PLUMED_CHECK_CXXFLAG([-pedantic]) 344 PLUMED_CHECK_CXXFLAG([-std=c++11]) 345fi 346 347if test $debug == true 348then 349 PLUMED_CHECK_CXXFLAG([-g]) 350fi 351 352if test $gcov == true 353then 354 CXX="$CXX --coverage" 355 LDSHARED="$LDSHARED --coverage" 356 CFLAGS="$CFLAGS --coverage" 357 PLUMED_CHECK_LDFLAGS([--coverage]) 358 STATIC_LIBS="$STATIC_LIBS --coverage" 359fi 360 361if test $fussy == true 362then 363 PLUMED_CHECK_CXXFLAG([-Wextra]) 364 PLUMED_CHECK_CXXFLAG([-Wfloat-equal]) 365 PLUMED_CHECK_CXXFLAG([-Wwrite-strings]) 366 PLUMED_CHECK_CXXFLAG([-Wpointer-arith]) 367 PLUMED_CHECK_CXXFLAG([-Wcast-qual]) 368 PLUMED_CHECK_CXXFLAG([-Wcast-align]) 369 PLUMED_CHECK_CXXFLAG([-Wconversion]) 370 PLUMED_CHECK_CXXFLAG([-Wredundant-delcs]) 371 PLUMED_CHECK_CXXFLAG([-Wvariadic-macros]) 372 PLUMED_CHECK_CXXFLAG([-Wold-style-cast]) 373fi 374 375AC_MSG_CHECKING([whether $CXX declares c++11 support]) 376AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ 377#if __cplusplus <= 199711L 378this_compiler_does_not_support_cxx11 379#endif 380])], 381 [AC_MSG_RESULT([yes])]; 382 support_cxx11=true, 383 [AC_MSG_RESULT([no]) ; 384 support_cxx11=false]) 385 386if test "$support_cxx11" = false 387then 388 AC_MSG_WARN([C++11 support is required as of PLUMED 2.4]) 389 AC_MSG_WARN([Your compiler appears not to support C++11]) 390 AC_MSG_WARN([Please change compiler or make sure that everything works correctly]) 391fi 392 393AC_MSG_CHECKING([whether C++ library supports C++11 exceptions]) 394AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ 395#include <new> 396#include <functional> 397#include <memory> 398#include <system_error> 399#include <ios> 400#include <future> 401// capable to catch: 402void func(void) { 403 try{ 404 } catch(std::bad_array_new_length &) { 405 } catch(std::bad_function_call &) { 406 } catch(std::bad_weak_ptr &) { 407 } catch(std::ios_base::failure &e) { 408 if(e.code().category()==std::generic_category()) {} 409 else if(e.code().category()==std::system_category()) {} 410 else if(e.code().category()==std::iostream_category()) {} 411 else if(e.code().category()==std::future_category()) {} 412 } catch(std::system_error &e) { 413 if(e.code().category()==std::generic_category()) {} 414 else if(e.code().category()==std::system_category()) {} 415 else if(e.code().category()==std::iostream_category()) {} 416 else if(e.code().category()==std::future_category()) {} 417 } 418// capable to throw: 419 auto a=std::bad_array_new_length(); 420 auto b=std::bad_function_call(); 421 auto c=std::bad_weak_ptr(); 422 auto d=std::system_error(10,std::generic_category(),"msg"); 423 auto e=std::system_error(10,std::system_category(),"msg"); 424 auto f=std::system_error(10,std::iostream_category(),"msg"); 425 auto g=std::system_error(10,std::future_category(),"msg"); 426 auto h=std::ios_base::failure("msg",std::error_code(10,std::generic_category())); 427 auto i=std::ios_base::failure("msg",std::error_code(10,std::system_category())); 428 auto j=std::ios_base::failure("msg",std::error_code(10,std::iostream_category())); 429 auto k=std::ios_base::failure("msg",std::error_code(10,std::future_category())); 430} 431])], 432[ 433 AC_MSG_RESULT([yes]); 434 AC_DEFINE([__PLUMED_LIBCXX11]) 435], 436[AC_MSG_RESULT([no]) 437]) 438 439AC_SUBST(disable_dependency_tracking) 440 441if test "$dependency_tracking" = true 442then 443 AC_MSG_CHECKING([whether $CXX can generate dependency file with -MM -MF]) 444 dependency=ko 445 echo "#include \"conftest1.h\"" > conftest.cpp 446 echo "#include \"conftest2.h\"" > conftest1.h 447 echo "/* */" > conftest2.h 448 $CXX $CXXFLAGS -c -MM -MFconftest.d conftest.cpp 1> /dev/null 2> /dev/null 449 grep conftest2 conftest.d 1> /dev/null 2>/dev/null && dependency=ok 450 if test "$dependency" = ok ; then 451 AC_MSG_RESULT([yes]) 452 disable_dependency_tracking=no 453 else 454 AC_MSG_RESULT([no]) 455 disable_dependency_tracking=yes 456 fi 457else 458 disable_dependency_tracking=yes 459fi 460 461if test "$disable_dependency_tracking" = yes ; then 462 AC_MSG_WARN([dependencies tracking disabled - always make clean before make]) 463else 464 AC_MSG_NOTICE([dependency tracking enabled]) 465fi 466 467 468 469 470#### Compulsory libraries #### 471# some of them might be made optional if we find that are not available in some system 472AC_MSG_NOTICE([Now we will check compulsory headers and libraries]) 473AC_CHECK_HEADER([dirent.h], [ ], [AC_MSG_ERROR([compulsory header not found])] ) 474AC_CHECK_FUNC( [readdir], [ ], [AC_MSG_ERROR([compulsory function not found])] ) 475 476# Then check for blas. This is a bit complicated because we want to allow 477# either the version with underscore or the one without 478blas_found= 479lapack_found= 480 481# external lapack can only work with external blas 482# thus, if external blas are disabled also external lapack should be disabled 483if test "$external_blas" == false && test "$external_lapack" == true ; then 484 AC_MSG_NOTICE([Internal blas can only be used with internal lapack]) 485 AC_MSG_NOTICE([Will not search for external lapack]) 486 external_lapack=false 487fi 488 489# first look for blas 490if test "$external_blas" == true ; then 491 AC_MSG_CHECKING([whether dgemv can be linked with no library]) 492 AC_LINK_IFELSE([AC_LANG_CALL([], [dgemv])],[ 493 AC_MSG_RESULT([yes]) 494 blas_found=nounderscore 495 ],[ 496 AC_MSG_RESULT([no]) 497 AC_MSG_CHECKING([whether dgemv_ can be linked with no library]) 498 AC_LINK_IFELSE([AC_LANG_CALL([], [dgemv_])],[ 499 AC_MSG_RESULT([yes]) 500 blas_found=underscore 501 ],[ 502 AC_MSG_RESULT([no]) 503 PLUMED_SEARCH_LIBS([dgemv],[blas],[blas_found=nounderscore],[ 504 PLUMED_SEARCH_LIBS([dgemv_],[blas],[blas_found=underscore]) 505 ]) 506 ]) 507 ]) 508fi 509 510# if not found, then use internal lapack and blas 511if test -z "$blas_found" ; then 512AC_MSG_WARN([using internal lapack and blas, could be inefficient]) 513fi 514 515# if found, also look for external lapack 516if test -n "$blas_found" ; then 517 518AC_DEFINE([__PLUMED_HAS_EXTERNAL_BLAS]) 519 520if test "$external_lapack" == true ; then 521# Then we look for lapack using same underscoring 522case "$blas_found" in 523(underscore) search_for=dsyevr_ ;; 524(nounderscore) search_for=dsyevr ;; 525esac 526PLUMED_SEARCH_LIBS( [$search_for],[lapack],[lapack_found=yes]) 527fi 528 529# if not found, then use internal lapack with external blas 530if test -z "$lapack_found" ; then 531AC_MSG_WARN([using internal lapack, could be inefficient]) 532else 533AC_DEFINE([__PLUMED_HAS_EXTERNAL_LAPACK]) 534fi 535 536fi 537 538# in case external blas have been found, take note of their underscoring 539# notice that this applies also when external blas are used with internal lapack 540# in the latter case, also (internal) lapack names will be underscored consistently 541if test "$blas_found" == nounderscore 542then 543 AC_DEFINE([F77_NO_UNDERSCORE]) 544fi 545 546if test -n "$blas_found" ; then 547 548AC_DEFUN([PLUMED_TEST_SDOT],[ 549#if ! defined(F77_NO_UNDERSCORE) 550#define sdot sdot_ 551#endif 552extern "C"{ 553$1 sdot(int *n, float *dx, int *incx, float *dy, int *incy); 554} 555 556int main(){ 557 int size=5; 558// notice that [[]] is required to cheat autoconf 559 float af[[5]],bf[[5]]; 560 for(unsigned i=0;i<size;i++){ 561 af[[i]]=size; 562 bf[[i]]=size-i; 563 } 564 int inca=1; 565 int incb=1; 566 $1 f=sdot(&size,af,&inca,bf,&incb)-75; 567 if(f*f<1e-10) return 0; 568 else return 1; 569} 570]) 571 572 573AC_MSG_CHECKING([whether sdot returns float]) 574AC_RUN_IFELSE([AC_LANG_SOURCE([PLUMED_TEST_SDOT([float])])], 575 [ sdot_returns_float=yes ; AC_MSG_RESULT([yes]) ], 576 [ sdot_returns_float=no ; AC_MSG_RESULT([no]) ], 577 [ AC_MSG_RESULT([not checked (cross compiling)]) ] 578) 579 580if test "$sdot_returns_float" == no ; 581then 582 583AC_MSG_CHECKING([whether sdot returns double]) 584AC_RUN_IFELSE([AC_LANG_SOURCE([PLUMED_TEST_SDOT([double])])], 585 [ sdot_returns_double=yes ; AC_MSG_RESULT([yes]) ], 586 [ sdot_returns_double=no ; AC_MSG_RESULT([no]) ], 587 [ AC_MSG_RESULT([not checked (cross compiling)]) ] 588) 589 590fi 591 592if test "$sdot_returns_double" = yes ; then 593 AC_MSG_NOTICE([Setting workaround for blas float functions returning double]) 594 AC_DEFINE(__PLUMED_BLAS_RETURNS_FLOAT,double) 595 if test -n "$lapack_found" ; then 596 AC_MSG_NOTICE([Setting workaround for lapack float functions returning double]) 597 AC_DEFINE(__PLUMED_LAPACK_RETURNS_FLOAT,double) 598 fi 599else if test "$sdot_returns_float" = no && test "$sdot_returns_double" = no ; 600then 601 AC_MSG_WARN([There is a problem with your blas implementation]) 602fi 603 604fi 605 606fi 607 608#### End of compulsory libraries #### 609 610#### Optional libraries #### 611AC_MSG_NOTICE([Now we will check for optional headers and libraries]) 612 613############################################################# 614# I add the possibility to completely remove molfile_plugins 615# I would like to be 100% that the molfile module compiles 616# correctly on all machines 617# In case of problem, it is sufficient to configure with 618# ./configure --disable-molfile-plugins 619# GB 620############################################################# 621 622if test $molfile_plugins == true ; then 623 624# Check for molfile_plugins and use internal fallback if not found. TG 625 626# We always have molfile, now 627AC_DEFINE([__PLUMED_HAS_MOLFILE_PLUGINS]) 628 629 if test "$external_molfile_plugins" == true ; then 630 PLUMED_CHECK_PACKAGE([libmolfile_plugin.h],[molfile_dcdplugin_init],[__PLUMED_HAS_EXTERNAL_MOLFILE_PLUGINS],molfile_plugin) 631 if test "$__PLUMED_HAS_EXTERNAL_MOLFILE_PLUGINS" != yes ; then 632 AC_MSG_WARN([using internal molfile_plugins, which only support dcd/xtc/trr/trj/crd files]) 633 else 634 AC_DEFINE([__PLUMED_HAS_EXTERNAL_MOLFILE_PLUGINS]) 635 fi 636 fi 637fi 638 639# this is special and is also attached to STATIC_LIBS 640# this flag should be used also when linking MD engines to allow plumed 641# to be loaded later 642AC_CHECK_LIB([dl],dlopen, [STATIC_LIBS="-ldl $STATIC_LIBS"] [LIBS="-ldl $LIBS"]) 643 644mpi_found=ko 645# optional libraries follow 646if test $mpi == true ; then 647 PLUMED_CHECK_PACKAGE([mpi.h],[MPI_Init],[__PLUMED_HAS_MPI]) 648 if test "$__PLUMED_HAS_MPI" = yes; then 649 mpi_found=ok 650 fi 651else 652 mpi_found=ko 653fi 654 655# search for openmp is automatically disabled by autoconf 656# when configuring with --disable-openmp 657AC_OPENMP 658 659if test $asmjit == true ; then 660 found=ko 661# asmjit calls clock_gettime and thus should be linked to rt on Linux 662 if test `(uname)` = Linux ; then 663 PLUMED_SEARCH_LIBS([clock_gettime],[rt],[found=ok]) 664 else 665 found=ok 666 fi 667 if test "$found" = ok ; then 668 AC_MSG_NOTICE([Enabling embedded asmjit]) 669 AC_DEFINE([__PLUMED_HAS_ASMJIT]) 670 else 671 AC_MSG_WARN([cannot link clock_gettime on this Linux, asmjit will not be enabled]) 672 fi 673fi 674 675 676if test $readdir_r == true ; then 677 PLUMED_CHECK_PACKAGE([dirent.h],[readdir_r],[__PLUMED_HAS_READDIR_R]) 678fi 679if test $cregex == true ; then 680 PLUMED_CHECK_PACKAGE([regex.h],[regcomp],[__PLUMED_HAS_CREGEX]) 681fi 682if test $dlopen == true ; then 683 PLUMED_CHECK_PACKAGE([dlfcn.h],[dlopen],[__PLUMED_HAS_DLOPEN]) 684fi 685 686if test $rtld_default == true ; then 687 PLUMED_CHECK_CXX_PACKAGE([RTLD_DEFAULT],[ 688#include <dlfcn.h> 689int 690main () 691{ 692 void* f=dlsym(RTLD_DEFAULT,"path"); 693 return 0; 694} 695 ], [__PLUMED_HAS_RTLD_DEFAULT]) 696fi 697 698if test $chdir == true ; then 699 PLUMED_CHECK_PACKAGE([unistd.h],[chdir],[__PLUMED_HAS_CHDIR]) 700fi 701 702if test $subprocess == true ; then 703 PLUMED_CHECK_CXX_PACKAGE([subprocess],[ 704/* random program calling all the functions needed to manage a subprocess */ 705#include <cstdio> 706#include <unistd.h> 707#include <csignal> 708 709int 710main () 711{ 712// notice that [[]] is required to cheat autoconf 713 int cp[[2]]; 714 FILE* fp; 715 char* arr[[3]]; 716 arr[[0]]=NULL; 717 arr[[1]]=NULL; 718 arr[[2]]=NULL; 719 arr[[3]]=NULL; 720 if(pipe(cp)>=0) 721 if(fork()>=0) 722 if(close(1)>=0) 723 if(dup(cp[[1]])>=0) { 724 fp=fdopen(cp[[0]],"w"); 725 execv(arr[[0]],arr); 726 } 727 auto p=fork(); 728 kill(p,SIGINT); 729 kill(p,SIGCONT); 730 kill(p,SIGSTOP); 731 return 0; 732} 733 734 ], [__PLUMED_HAS_SUBPROCESS]) 735fi 736 737if test $getcwd == true ; then 738 PLUMED_CHECK_PACKAGE([unistd.h],[getcwd],[__PLUMED_HAS_GETCWD]) 739fi 740 741if test $execinfo == true ; then 742 PLUMED_CHECK_PACKAGE([execinfo.h],[backtrace],[__PLUMED_HAS_EXECINFO]) 743fi 744if test $zlib == true ; then 745 PLUMED_CHECK_PACKAGE([zlib.h],[gzopen],[__PLUMED_HAS_ZLIB],[z]) 746fi 747 748if test $gsl == true ; then 749 found=ko 750 PLUMED_SEARCH_LIBS([cblas_dgemv],[gslcblas], [ 751 AC_CHECK_HEADER( [gsl/gsl_vector.h], [ 752 PLUMED_SEARCH_LIBS([gsl_vector_alloc],[gsl],[found=ok]) 753 ]) 754 ]) 755 if test $found == ok ; then 756 AC_DEFINE([__PLUMED_HAS_GSL]) 757 else 758 AC_MSG_WARN([cannot enable __PLUMED_HAS_GSL]) 759 fi 760fi 761 762if test $xdrfile == true ; then 763 PLUMED_CHECK_PACKAGE([xdrfile/xdrfile_xtc.h],[write_xtc],[__PLUMED_HAS_XDRFILE],[xdrfile]) 764fi 765 766if test $boost_graph == true ; then 767 PLUMED_CHECK_CXX_PACKAGE([boost graph],[ 768#include <boost/graph/graph_utility.hpp> 769#include <boost/graph/adjacency_matrix.hpp> 770int 771main () 772{ 773 boost::adjacency_matrix<boost::directedS> a(1); 774 ; 775 return 0; 776} 777 ], [__PLUMED_HAS_BOOST_GRAPH]) 778fi 779 780if test $boost_serialization == true ; then 781 PLUMED_CHECK_CXX_PACKAGE([boost serialization],[ 782#include <fstream> 783#include <boost/archive/text_oarchive.hpp> 784int main() { 785 std::ofstream ofs("filename"); 786 boost::archive::text_oarchive oa(ofs); 787 return 0; 788} 789 ], [__PLUMED_HAS_BOOST_SERIALIZATION],[boost_serialization boost_serialization-mt]) 790# notice: macports install libraries with -mt suffix 791fi 792 793if test $fftw == true ; then 794 PLUMED_CHECK_PACKAGE([fftw3.h],[fftw_execute],[__PLUMED_HAS_FFTW],[fftw3]) 795fi 796 797if test $python == true ; then 798# if PYTHON_BIN is defined, it is expected to be the full path to python 799# Otherwise, search from a list of names: 800 if test -z "$PYTHON_BIN" ; then 801 AC_CHECK_PROGS([PYTHON_BIN],[python]) 802 fi 803 if test -n "$PYTHON_BIN" 804 then 805 AC_MSG_NOTICE([Python executable is $PYTHON_BIN]) 806 AC_MSG_CHECKING([support for required python modules (python3, setuptools, cython, subprocess, os, shutil)]) 807testimport=" 808from setuptools import setup 809from setuptools import Extension 810import subprocess 811import os 812import os.path 813import sys 814from shutil import copyfile 815from Cython.Build import cythonize 816if sys.version_info < (3,): 817 raise ImportError('PLUMED 2.6 only supports Python 3') 818" 819 if echo "$testimport" | "$PYTHON_BIN" 1>/dev/null 2>/dev/null; then 820 AC_MSG_RESULT([yes]) 821 AC_DEFINE([__PLUMED_HAS_PYTHON]) 822 else 823 AC_MSG_RESULT([no]) 824 AC_MSG_WARN([cannot enable python interface]) 825 PYTHON_BIN= 826 fi 827 else 828 AC_MSG_WARN([cannot enable python interface]) 829 fi 830fi 831 832if test "$af_ocl" == true ; then 833 PLUMED_CHECK_PACKAGE([arrayfire.h],[af_is_double],[__PLUMED_HAS_ARRAYFIRE],[afopencl]) 834fi 835if test "$af_cuda" == true ; then 836 PLUMED_CHECK_PACKAGE([arrayfire.h],[af_is_double],[__PLUMED_HAS_ARRAYFIRE],[afcuda]) 837fi 838if test "$af_cpu" == true ; then 839 PLUMED_CHECK_PACKAGE([arrayfire.h],[af_is_double],[__PLUMED_HAS_ARRAYFIRE],[afcpu]) 840fi 841 842# in non-debug mode, add -DNDEBUG 843if test "$debug" == false ; then 844 AC_MSG_NOTICE([Release mode, adding -DNDEBUG]) 845 AC_DEFINE([NDEBUG]) 846fi 847 848# in debug-glibcxx mode, add -D_GLIBCXX_DEBUG 849if test "$debug_glibcxx" == true ; then 850 AC_MSG_NOTICE([Check boundaries, adding -D_GLIBCXX_DEBUG]) 851 AC_DEFINE([_GLIBCXX_DEBUG]) 852fi 853 854# this is necessary in many MPI implementations 855# I leave it by default, since it seems harmless 856AC_DEFINE([_REENTRANT]) 857 858#### Options for dynamic library to work properly #### 859AC_SUBST(SOEXT) 860AC_SUBST(LDSHARED) 861# these are libraries that should be linked also to MD engines 862AC_SUBST(STATIC_LIBS) 863# python executable 864AC_SUBST(PYTHON_BIN) 865 866AC_SUBST(MPIEXEC) 867 868if test "$shared" == true ; then 869 case `(uname)` in 870 (Darwin) 871 AC_MSG_NOTICE([*** Special settings for dynamic libraries on OSX ***]) 872 AC_MSG_NOTICE([Dynamic library extension is 'dylib']) 873 AC_MSG_NOTICE([LDSHARED needs special flags]) 874 SOEXT=dylib 875 LDSHARED="$LDSHARED -dynamiclib -Wl,-headerpad_max_install_names" 876 if test "$rpath" = true ; then 877 AC_MSG_NOTICE([Switching off rpath on OSX]) 878 rpath=false 879 fi 880 ;; 881 (Linux) 882 AC_MSG_NOTICE([*** Special settings for dynamic libraries on Linux ***]) 883 AC_MSG_NOTICE([Dynamic library extension is 'so']) 884 AC_MSG_NOTICE([LDSHARED and LDFLAGS need special flags]) 885 SOEXT=so 886 LDSHARED="$LDSHARED -shared" 887 PLUMED_CHECK_LDFLAGS([-rdynamic]) 888 if test "$bsymbolic" == true ; then 889 PLUMED_CHECK_LDFLAGS([-Wl,-Bsymbolic]) 890 fi 891 ;; 892 (FreeBSD|DragonFly) 893 AC_MSG_NOTICE([*** Special settings for dynamic libraries on Linux ***]) 894 AC_MSG_NOTICE([Dynamic library extension is 'so']) 895 AC_MSG_NOTICE([LDSHARED and LDFLAGS need special flags]) 896 SOEXT=so 897 LDSHARED="$LDSHARED -shared" 898 PLUMED_CHECK_LDFLAGS([-rdynamic]) 899 if test "$bsymbolic" == true ; then 900 PLUMED_CHECK_LDFLAGS([-Wl,-Bsymbolic]) 901 fi 902 ;; 903 (*) 904 AC_MSG_NOTICE([*** Dynamic library only enabled on OSX and Linux ***]) 905 esac 906fi 907 908# check linking of runtime library 909if test -n "$SOEXT" 910then 911 AC_MSG_NOTICE([Using LDSHARED='$LDSHARED']) 912 AC_MSG_NOTICE([Using LDFLAGS='$LDFLAGS']) 913 AC_MSG_CHECKING([whether LDSHARED can create dynamic libraries]) 914 rm -f conftest.* 915 echo "void f(void){ return;}" > conftest.cpp 916 $CXX $CXXFLAGS $CPPFLAGS -c conftest.cpp 1>/dev/null 2>/dev/null 917 $LDSHARED $LDFLAGS conftest.o -o conftest.$SOEXT 1>/dev/null 2>/dev/null 918 if test -f conftest.$SOEXT 919 then 920 AC_MSG_RESULT([yes]) 921 else 922 AC_MSG_RESULT([no]) 923 AC_MSG_WARN([dynamic library will be disabled]) 924 SOEXT= 925 fi 926 if test -n "$SOEXT" && test "$rpath" = true ; then 927 rm -f conftest.$SOEXT 928 readelf="" 929 AC_CHECK_PROG([readelf],[readelf],[found]) 930 if test "$readelf" == found ; then 931 test_LDSHARED="$LDSHARED -Wl,-R -Wl,/some/random/dir/" 932 $test_LDSHARED $LDFLAGS conftest.o -o conftest.$SOEXT 1>/dev/null 2>/dev/null 933 if readelf -d conftest.$SOEXT | grep RPATH | grep -q /some/random/dir ; then 934 LDSHARED="$LDSHARED -Wl,-R -Wl,\"$LIBRARY_PATH\"" 935 else 936 AC_MSG_WARN([-R option seems not working, disabling rpath]) 937 fi 938 else 939 AC_MSG_WARN([readelf not available, no way to set rpath]) 940 fi 941 fi 942 rm -f conftest.* 943fi 944#### Options for dynamic library to work properly #### 945 946AC_SUBST(make_doc) 947make_doc=no 948if test "$doc" == true 949then 950 951make_doc=yes 952 953### Look for doxygen 954AC_CHECK_PROG([doxygen],[doxygen],[found]) 955if test "$doxygen" == found 956then 957 doxygen_version=`doxygen --version | awk 'BEGIN{FS="."}{if($1>1 || ($1==1 && $2>=8)) print "ok"}'` 958 if test "$doxygen_version" == ok 959 then 960 AC_MSG_NOTICE([Doxygen version is fine]) 961 else 962 AC_MSG_WARN([Doxygen version is <1.8]) 963 make_doc=no 964 fi 965 AC_CHECK_PROG([dot],[dot],[found]) 966 if test "$dot" != found 967 then 968 AC_MSG_WARN([You will not be able to see diagrams in the manual]) 969 fi 970else 971 make_doc=no 972fi 973fi 974 975if test "$make_doc" = yes 976then 977 AC_MSG_NOTICE([Manuals will be generated]) 978else 979 AC_MSG_NOTICE([Manuals will not be generated]) 980fi 981 982AC_SUBST(make_pdfdoc) 983make_pdfdoc="" 984if test "$pdfdoc" == true && test "$make_doc" == yes 985then 986 AC_MSG_NOTICE([A PDF version of the manual will be generated]) 987 make_pdfdoc=yes 988else 989 AC_MSG_NOTICE([A PDF version of the manual will not be generated]) 990 make_pdfdoc=no 991fi 992 993### Look for xxd 994AC_CHECK_PROG([xxd],[xxd],[found]) 995if test "$xxd" != found 996then 997 AC_MSG_ERROR([xxd should be installed for PLUMED to compile properly]) 998fi 999 1000AC_SUBST(program_can_run) 1001program_can_run="" 1002AC_MSG_CHECKING([whether a program can be run on this machine]) 1003AC_RUN_IFELSE([AC_LANG_SOURCE([ 1004#ifdef __PLUMED_HAS_MPI 1005#include <mpi.h> 1006#endif 1007// notice that [[]] is required to cheat autoconf 1008int main(int argc,char*argv[[]]){ 1009#ifdef __PLUMED_HAS_MPI 1010// this emulates what happens when plumed 1011// is compiled with mpi and invoked with --no-mpi 1012 if(argc==10){ 1013 MPI_Init(&argc,&argv); 1014 return MPI_Finalize(); 1015 } 1016#endif 1017 return 0; 1018} 1019])], 1020 [ program_can_run=yes ; AC_MSG_RESULT([yes]) ], 1021 [ program_can_run=no ; AC_MSG_RESULT([no]) ], 1022 [ program_can_run=no ; AC_MSG_RESULT([no (cross compiling)]) ] 1023) 1024 1025if test $mpi_found == ok ; then 1026AC_SUBST(program_can_run_mpi) 1027program_can_run_mpi="" 1028AC_MSG_CHECKING([whether a program compiled with mpi can be run on this machine]) 1029AC_RUN_IFELSE([AC_LANG_SOURCE([ 1030#ifdef __PLUMED_HAS_MPI 1031#include <mpi.h> 1032#endif 1033// notice that [[]] is required to cheat autoconf 1034int main(int argc,char*argv[[]]){ 1035#ifdef __PLUMED_HAS_MPI 1036 MPI_Init(&argc,&argv); 1037 return MPI_Finalize(); 1038#endif 1039 return 0; 1040} 1041])], 1042 [ program_can_run_mpi=yes ; AC_MSG_RESULT([yes]) ], 1043 [ program_can_run_mpi=no ; AC_MSG_RESULT([no]) ], 1044 [ program_can_run_mpi=no ; AC_MSG_RESULT([no (cross compiling)]) ] 1045) 1046fi 1047 1048if test $mpi_found == ok ; then 1049 if test -n "$MPIEXEC" ; then 1050 AC_MSG_NOTICE([Regtest suite will use $MPIEXEC command to run MPI tests]) 1051 else 1052 AC_MSG_NOTICE([Regtest suite will use env var PLUMED_MPIRUN to run MPI tests (default: mpirun)]) 1053 fi 1054fi 1055 1056if test "$SOEXT" == "dylib" ; then 1057 use_absolute_soname=yes 1058else 1059 use_absolute_soname=no 1060fi 1061 1062AC_SUBST(use_absolute_soname) 1063if test "$absolute_soname" == true ; then 1064 if test "$SOEXT" == "dylib" ; then 1065 AC_MSG_WARN([--enable-absolute-soname has no effect on OSX]) 1066 else 1067 AC_MSG_NOTICE([enabling absolute soname. Full path will be hardcoded in plumed library soname]) 1068 use_absolute_soname=yes 1069 fi 1070fi 1071 1072if test "$absolute_install_name" == false ; then 1073 if test "$SOEXT" == "so" ; then 1074 AC_MSG_WARN([--disable-absolute-install-name has no effect on Linux]) 1075 else 1076 AC_MSG_NOTICE([enabling relative install_name. You will have to set DYLD_LIBRARY_PATH yor plumed libraries to be found at runtime]) 1077 use_absolute_soname=no 1078 fi 1079fi 1080 1081AC_SUBST(use_loader_path) 1082if test "$SOEXT" == "dylib" ; then 1083 if test "$loader_path" == true ; then 1084 use_loader_path=yes 1085 else 1086 use_loader_path=no 1087 fi 1088else 1089 use_loader_path=no 1090fi 1091 1092#### This further tests are required to allow linking with non c++ compiler 1093AC_MSG_NOTICE([PLUMED seems to be configured properly!]) 1094AC_MSG_NOTICE([**************************]) 1095AC_SUBST(LD_RO) 1096LD_RO= 1097if test "$ld_r" == true ; then 1098for test_LD_RO in "$($CXX --print-prog-name=ld) -r -o" "$CXX -Wl,-r -o" "ld -r -o" 1099do 1100 AC_MSG_CHECKING([whether C++ objects can be grouped with $test_LD_RO]) 1101 1102 rm -f conftest-* 1103 1104 cat << EOF > conftest-main.cpp 1105 void f(void); 1106 int main(int argc,char**argv){ f(); return 0; } 1107EOF 1108 cat << EOF > conftest-f.cpp 1109 void g(void); 1110 void f(void){ g(); } 1111EOF 1112 cat << EOF > conftest-g.cpp 1113 void g(void){ return; } 1114EOF 1115 1116 $CXX $CXXFLAGS -c conftest-main.cpp 1> /dev/null 2> /dev/null 1117 $CXX $CXXFLAGS -c conftest-f.cpp 1> /dev/null 2> /dev/null 1118 $CXX $CXXFLAGS -c conftest-g.cpp 1> /dev/null 2> /dev/null 1119 1120 $test_LD_RO conftest-both.o conftest-f.o conftest-g.o 1> /dev/null 2> /dev/null 1121 1122 $CXX $CXXFLAGS -o conftest.exe conftest-main.o conftest-both.o 1> /dev/null 2> /dev/null 1123 1124 if test -f conftest.exe 1125 then 1126 AC_MSG_RESULT([yes]) 1127 LD_RO="$test_LD_RO" 1128 break 1129 else 1130 AC_MSG_RESULT([no]) 1131 fi 1132done 1133 1134fi 1135 1136AC_SUBST(AR_CR) 1137AR_CR= 1138if test "$ar_cr" == true ; then 1139for test_AR_CR in "$($CXX --print-prog-name=ar) cr" "ar cr" 1140do 1141 AC_MSG_CHECKING([whether static libraries can be created with $test_AR_CR]) 1142 1143 rm -f conftest-* 1144 1145 cat << EOF > conftest-main.cpp 1146 void f(void); 1147 int main(int argc,char**argv){ f(); return 0; } 1148EOF 1149 cat << EOF > conftest-f.cpp 1150 void g(void); 1151 void f(void){ g(); } 1152EOF 1153 cat << EOF > conftest-g.cpp 1154 void g(void){ return; } 1155EOF 1156 1157 $CXX $CXXFLAGS -c conftest-main.cpp 1> /dev/null 2> /dev/null 1158 $CXX $CXXFLAGS -c conftest-f.cpp 1> /dev/null 2> /dev/null 1159 $CXX $CXXFLAGS -c conftest-g.cpp 1> /dev/null 2> /dev/null 1160 1161 $test_AR_CR conftest-both.a conftest-f.o conftest-g.o 1> /dev/null 2> /dev/null 1162 1163 $CXX $CXXFLAGS -o conftest.exe conftest-main.o conftest-both.a 1> /dev/null 2> /dev/null 1164 1165 if test -f conftest.exe 1166 then 1167 AC_MSG_RESULT([yes]) 1168 AR_CR="$test_AR_CR" 1169 break 1170 else 1171 AC_MSG_RESULT([no]) 1172 fi 1173done 1174 1175fi 1176 1177make_static_archive=no 1178AC_SUBST(make_static_archive) 1179 1180if test "${static_archive}" == true ; then 1181 if test -z "$LD_RO" || test -z "$AR_CR" ; then 1182 AC_MSG_WARN([no way to create a static archive if ld -ro or ar cr do not work]) 1183 static_archive=false 1184 fi 1185fi 1186 1187if test "${static_archive}" == true ; then 1188 AC_MSG_CHECKING([whether static-object constructors can be linked from a static archive]) 1189 1190 magic_token=c1bc476d093a3a5c67b4530e6c54c633593fe9aa 1191 rm -f conftest-* 1192 1193 cat << EOF > conftest-main.cpp 1194 void f(void); 1195 int main(int argc,char**argv){ f(); return 0; } 1196EOF 1197 cat << EOF > conftest-f.cpp 1198 void f(void){ return; } 1199EOF 1200 cat << EOF > conftest-g.cpp 1201#include <iostream> 1202 class g{ 1203 public: 1204 g(){ std::cout<<"$magic_token\n"; } 1205 } init; 1206EOF 1207 1208 $CXX $CXXFLAGS -c conftest-main.cpp 1> /dev/null 2> /dev/null 1209 $CXX $CXXFLAGS -c conftest-f.cpp 1> /dev/null 2> /dev/null 1210 $CXX $CXXFLAGS -c conftest-g.cpp 1> /dev/null 2> /dev/null 1211 1212 $LD_RO conftest-both.o conftest-f.o conftest-g.o 1> /dev/null 2> /dev/null 1213# linking the previously merged objects should work: 1214 $AR_CR conftest-both.a conftest-both.o 1> /dev/null 2> /dev/null 1215# something like the following, instead, should not work: 1216# $AR_CR conftest-both.a conftest-f.o conftest-g.o 1> /dev/null 2> /dev/null 1217# 1218 $CXX $CXXFLAGS -o conftest.exe conftest-main.o conftest-both.a 1> /dev/null 2> /dev/null 1219 if grep -q $magic_token ./conftest.exe ; then 1220 AC_MSG_RESULT([yes]) 1221 make_static_archive=yes 1222 else 1223 AC_MSG_RESULT([no]) 1224 fi 1225fi 1226 1227if test "${static_patch}" == true ; then 1228 1229AC_MSG_NOTICE([I will now check if C++ objects can be linked by C/Fortran compilers]) 1230AC_MSG_NOTICE([This is relevant if you want to use plumed patch --static on a non-C++ code]) 1231 1232for compiler in CC FC 1233do 1234 rm -f conftest.* conftest-main.* 1235 eval compexe=\$$compiler 1236 if test -n "$compexe" ; then 1237 case $compiler in 1238 (CC) 1239 name=C 1240 cat << EOF > conftest-main.c 1241int main(int argc,char**argv){ 1242 return 0; 1243} 1244EOF 1245 $CC -c conftest-main.c 1246 ;; 1247 (FC) 1248 name=FORTRAN 1249 cat << EOF > conftest-main.f90 1250 program main 1251 integer i 1252 end program main 1253EOF 1254 $FC -c conftest-main.f90 1255 ;; 1256 esac 1257 cat << EOF > conftest.cpp 1258#include <iostream> 1259void f(void){ 1260 std::cout<<"ciao";return; 1261} 1262EOF 1263 $CXX $CXXFLAGS -c conftest.cpp 1264# start search: 1265 found= 1266 if test "${libsearch}" == true ; then 1267 testlibs="-lstdc++ -lc++ -lmpi_cxx" 1268 else 1269 testlibs="" 1270 fi 1271 for testlib in "" $testlibs ; do 1272 comment= 1273 test -n "$testlib" && comment=" with library $testlib" 1274 AC_MSG_CHECKING([whether $name can link a C++ object$comment]) 1275 $compexe conftest.o conftest-main.o $LDFLAGS $testlib $LIBS -o conftest.exe 1>/dev/null 2>/dev/null 1276 if test -f conftest.exe 1277 then 1278 found=yes 1279 AC_MSG_RESULT([yes]) 1280 LIBS="$testlib $LIBS" 1281 break 1282 else 1283 AC_MSG_RESULT([no]) 1284 fi 1285 done 1286 if test -z "$found" ; then 1287 AC_MSG_WARN([You might have problems linking $name programs.]) 1288 AC_MSG_WARN([Please add c++ library to LIBS]) 1289 fi 1290 else 1291 AC_MSG_NOTICE([$compiler compiler not configured]) 1292 fi 1293 rm -f conftest.* conftest-main.* 1294done 1295 1296else 1297AC_MSG_NOTICE([Static patching is disabled, thus tests required for static patching will be skipped]) 1298fi 1299 1300if test "$prefix" == NONE 1301then 1302 prefix=/usr/local 1303fi 1304 1305pkgconfig_bin="" 1306 1307AC_PATH_PROGS(pkgconfig_bin,pkg-config) 1308 1309if test -z "$BASH_COMPLETION_DIR" && test -n "$pkgconfig_bin"; then 1310 if test "$prefix" == "$(pkg-config --variable=prefix bash-completion 2>/dev/null)" 1311 then 1312 AC_MSG_NOTICE([bash-completion is installed on the same prefix where plumed will be installed]) 1313 if pkg-config --variable=completionsdir bash-completion 2>/dev/null >/dev/null ; then 1314 BASH_COMPLETION_DIR="$(pkg-config --variable=completionsdir bash-completion 2>/dev/null)" 1315 fi 1316 else 1317 AC_MSG_NOTICE([bash-completion is not installed or it is installed on a different prefix]) 1318 pkgconfig_bin="" 1319 fi 1320fi 1321 1322if test -n "$BASH_COMPLETION_DIR" 1323then 1324 AC_MSG_NOTICE([bash completion for plumed will be installed in $BASH_COMPLETION_DIR]) 1325else 1326 AC_MSG_NOTICE([bash completion for plumed will not be installed]) 1327fi 1328 1329AC_SUBST(BASH_COMPLETION_DIR) 1330 1331AC_ARG_PROGRAM 1332 1333 1334# version modified to work in shell script instead of makefile: 1335program_transform_name_sh=$(echo "${program_transform_name}" | sed 's:\$\$:$:g') 1336program_name=$(echo plumed | sed "$program_transform_name_sh") 1337AC_SUBST(program_name) 1338 1339if test "$(echo "$program_name" | tr '[A-Z]' '[a-z]')" != "$(echo "$program_name" | tr '[A-Z]' '[a-z]' | sed 's/wrapper$//')" ; then 1340 AC_MSG_ERROR([$program_name is not a valid program name (should not terminate with Wrapper)]) 1341fi 1342if test "$(echo "$program_name" | tr '[A-Z]' '[a-z]')" != "$(echo "$program_name" | tr '[A-Z]' '[a-z]' | sed 's/kernel$//')" ; then 1343 AC_MSG_ERROR([$program_name is not a valid program name (should not terminate with Kernel)]) 1344fi 1345if test "$(echo "$program_name" | tr '[A-Z]' '[a-z]')" != "$(echo "$program_name" | tr '[A-Z]' '[a-z]' | sed 's/-patch$//')" ; then 1346 AC_MSG_ERROR([$program_name is not a valid program name (should not terminate with -patch)]) 1347fi 1348if test "$(echo "$program_name" | tr '[A-Z]' '[a-z]')" != "$(echo "$program_name" | tr '[A-Z]' '[a-z]' | sed 's/-config$//')" ; then 1349 AC_MSG_ERROR([$program_name is not a valid program name (should not terminate with -config)]) 1350fi 1351 1352AC_MSG_NOTICE([**** PLUMED will be installed using the following paths:]) 1353AC_MSG_NOTICE([**** prefix: $prefix]) 1354if test "$exec_prefix" = NONE ; then 1355 exec_prefix_='${prefix}' 1356else 1357 exec_prefix_="${exec_prefix}" 1358fi 1359AC_MSG_NOTICE([**** exec_prefix: $exec_prefix_]) 1360AC_MSG_NOTICE([**** bindir: $bindir]) 1361AC_MSG_NOTICE([**** libdir: $libdir]) 1362AC_MSG_NOTICE([**** includedir: $includedir]) 1363AC_MSG_NOTICE([**** datarootdir: $datarootdir]) 1364AC_MSG_NOTICE([**** datadir: $datadir]) 1365AC_MSG_NOTICE([**** docdir: ${datarootdir}/doc/$program_name]) 1366AC_MSG_NOTICE([**** htmldir: $htmldir]) 1367AC_MSG_NOTICE([**** Executable will be named $program_name]) 1368AC_MSG_NOTICE([**** As of PLUMED 2.5, you cannot change paths anymore during "make install"]) 1369AC_MSG_NOTICE([**** Please configure and make clean to change the prefix]) 1370 1371if test -z "$BASH_COMPLETION_DIR" ; then 1372 AC_MSG_WARN([**** Bash completion for plumed will not be installed, please add the following two lines to your bashrc]) 1373 AC_MSG_WARN([**** _$program_name() { eval "\$($program_name --no-mpi completion 2>/dev/null)";}]) 1374 AC_MSG_WARN([**** complete -F _$program_name -o default $program_name]) 1375fi 1376 1377if test $mpi == true; then 1378 if test $mpi_found == ok; then 1379 AC_MSG_NOTICE([**** PLUMED will be compiled using MPI]) 1380 else 1381 AC_MSG_WARN([**** PLUMED will NOT be compiled using MPI because MPI have not been found!]) 1382 fi 1383else 1384 AC_MSG_NOTICE([**** PLUMED will be compiled without MPI]) 1385fi 1386 1387if test $program_can_run == no ; then 1388 AC_MSG_WARN([plumed executable will not run on this machine]) 1389 AC_MSG_WARN([to patch an MD code use 'plumed-patch']) 1390elif test $mpi_found == ok ; then 1391 if test $program_can_run_mpi == no ; then 1392 AC_MSG_WARN([plumed executable will not run on this machine]) 1393 AC_MSG_WARN([unless you invoke it as 'plumed --no-mpi']) 1394 AC_MSG_WARN([all command line tools are thus available as 'plumed --no-mpi name-of-the-tool']) 1395 AC_MSG_WARN([e.g. 'plumed --no-mpi driver']) 1396 AC_MSG_WARN([to patch an MD code use 'plumed --no-mpi patch']) 1397 AC_MSG_WARN([(notice that MPI will be available anyway in the patched code)]) 1398 fi 1399fi 1400 1401AC_SUBST(build_dir) 1402build_dir=`pwd` 1403 1404 1405 1406# This is to replace tags in Makefile.conf.in 1407# saving the result to Makefile.conf 1408AC_CONFIG_FILES([Makefile.conf sourceme.sh]) 1409# This is to have the stamp-h file up to date 1410# The date of this file keeps track of when Makefile.conf and sourceme.sh have been updated 1411AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h]) 1412AC_OUTPUT 1413 1414