Mark advanced variables/options that are not relevant for the OpenMM build
[gromacs/rigid-bodies.git] / configure.ac
blob034f721e85b3457a35928e10a95f1c6bc1b0f1eb
1 #######################################################################
2 # Process this file wth autoconf to produce a configure script.
3 #######################################################################
4  
5 AC_PREREQ(2.50)
6 AC_INIT(gromacs, 4.5.1, [gmx-users@gromacs.org])
7 AC_CONFIG_SRCDIR(src/gmxlib/3dview.c)
8 AC_CONFIG_AUX_DIR(config)
9 AC_CANONICAL_HOST
11 AM_INIT_AUTOMAKE(tar-ustar)
12 AC_PREFIX_DEFAULT(/usr/local/gromacs)
14 AM_CONFIG_HEADER(src/config.h)
15 dnl This is the version info according to the libtool versioning system.
16 dnl It does *not* correspond to the release number.
17 SHARED_VERSION_INFO="6:0:0"
18 AC_SUBST(SHARED_VERSION_INFO)
20 AC_DISABLE_SHARED
21 PKG_CFLAGS=""
23 #######################################################################
24 # Simple options and makefile variables
25 #######################################################################
27 ### Single/Double
28 AC_ARG_ENABLE(float,
29              [AC_HELP_STRING([--disable-float],
30                              [Use double instead of single precision])],, enable_float=yes)
32 AC_ARG_ENABLE(double,
33              [AC_HELP_STRING([--enable-double],
34                              [Same effect as --disable-float])],, enable_double=no)
35 if test "$enable_double" = "yes"; then
36    enable_float=no;
38 if test "$enable_float" = "no"; then
39   AC_DEFINE(GMX_DOUBLE,,[Compile in double precision])
40   PKG_CFLAGS="$PKG_CFLAGS -DGMX_DOUBLE"
42 AM_CONDITIONAL([GMX_DOUBLE],[test "$enable_float" = "no"])
46 ### Fortran or not
47 AC_ARG_ENABLE(fortran,
48              [AC_HELP_STRING([--enable-fortran],
49                              [Use Fortran kernels])],, 
50 [case "${host_cpu}-${host_os}" in
51   sparc*-solaris* | alpha*-* | rs6000*-aix* | powerpc*-aix* | mips*-irix*) enable_fortran=yes ;;
52   *) enable_fortran=no ;;
53  esac])
54 # Generic fortran kernels will be turned off below if you enable power6-specific optimization!
55 # always use CC for linking:
56 AC_SUBST(F77LINK,"\$(LINK)")
62 ### MPI or not
63 AC_ARG_ENABLE(mpi,
64               [AC_HELP_STRING([--enable-mpi],
65                               [Compile for parallel runs using MPI]
66                               [(instead of threads)])],,enable_mpi=no)
69 ### MPI environment
70 AC_ARG_ENABLE(mpi-environment,
71               [AC_HELP_STRING([--enable-mpi-environment=VAR],
72                               [Only start parallel runs when VAR is set])],,
73 [case "${host_cpu}" in
74   mips*-irix*) enable_mpi_environment="MPI_ENVIRONMENT" ;;
75   *) enable_mpi_environment=no ;;
76 esac])
77 if test "$enable_mpi_environment" != "no"; then
78   AC_DEFINE_UNQUOTED(GMX_CHECK_MPI_ENV,"$enable_mpi_environment",[If defined, only start MPI runs when this variable is set])
81 ### MPI_IN_PLACE
82 AC_ARG_ENABLE(mpi-in-place,
83               [AC_HELP_STRING([--disable-mpi-in-place],
84                               [Disable MPI_IN_PLACE. For MPI implementations]
85                               [that have broken support for it ]
86                               [(some versions of MPICH, for example).])],, enable_mpi_in_place=yes)
90 AC_ARG_ENABLE(debug,
91               [AC_HELP_STRING([--enable-debug],
92                               [Add -g to other command line arguments])],,enable_debug=no)
94 ### IA32 assembly code
95 AC_ARG_ENABLE(ia32_sse,
96               [AC_HELP_STRING([--disable-ia32-sse],
97                               [Don't build SSE/SSE2 assembly loops on ia32])],,enable_ia32_sse=yes)
99 case "${host_cpu}-${host_vendor}" in
100    i?86-*) ;;
101    *) enable_ia32_sse=no ;;
102 esac
104 ### AMD64 assembly code
105 AC_ARG_ENABLE(x86_64_sse,
106               [AC_HELP_STRING([--disable-x86-64-sse],
107                               [Don't build SSE assembly loops on X86_64])],,enable_x86_64_sse=yes)
108 case "${host_cpu}-${host_vendor}" in
109    x86_64-* | amd64-*) ;;
110    i?86-apple) ;;
111    *) enable_x86_64_sse=no ;;
112 esac
115 ### Altivec on powerpc (motorola)
116 AC_ARG_ENABLE(ppc_altivec,
117               [AC_HELP_STRING([--disable-ppc-altivec],
118                               [Don't build Altivec loops on PowerPC])],,enable_ppc_altivec=undef)
119 # Power3/4/5 running AIX does not support altivec. We identify this with vendor=IBM.
120 # IBM powerpc 970 boxes run linux, and have vendor=unknown.
121 if test "$enable_ppc_altivec" = "undef"; then
122   case "${host_cpu}-${host_vendor}" in
123     ppc*-ibm* | powerpc*-ibm*) enable_ppc_altivec=no ;;
124     ppc*-* | powerpc*-*) enable_ppc_altivec=yes ;; 
125     *) enable_ppc_altivec=no ;;
126   esac
129 ###################################
130 ## Detect buggy version of gcc
131 ###################################
132 AC_ARG_ENABLE(gcc41_check,
133               [AC_HELP_STRING([--disable-gcc41-check],
134                               [Disable the check for buggy gcc 4.1])],,enable_gcc41_check=yes)
138 ### ia64 assembly code
139 AC_ARG_ENABLE(ia64_asm,
140               [AC_HELP_STRING([--enable-ia64-asm],
141                               [Build assembly loops on ia64])],,enable_ia64_asm=no)
142 case "${host_cpu}" in
143    ia64) ;;
144    *) enable_ia64_asm=no ;;
145 esac
148 # IBM Power6-specific optimization
149 AC_ARG_ENABLE(power6,
150              [AC_HELP_STRING([--enable-power6],
151                              [Use IBM Pwr6/PPC440/PPC450-specific F77 kernels])],,enable_power6=no)
152 # Turn off generic fortran loops if we are using power6-specific optimization
153 if test "$enable_power6" = "yes"; then
154   enable_fortran=no;
155   AC_DEFINE(GMX_POWER6,,[Enable IBM Pwr6/PPC440/PPC450-specific F77 kernels])
158 AC_ARG_ENABLE(bluegene,
159               [AC_HELP_STRING([--enable-bluegene],
160                               [Build assembly intrinsics kernels on bluegene])],,enable_bluegene=no)
163 ### Optimize for host cpu version
164 AC_ARG_ENABLE(cpu-optimization,     
165               [AC_HELP_STRING([--disable-cpu-optimization],
166                               [No detection or tuning flags for cpu version])],, enable_cpu_optimization=yes)
169 ### Do software 1/sqrt(x)                                                                                                            
170 AC_ARG_ENABLE(software-invsqrt,
171               [AC_HELP_STRING([--disable-software-invsqrt],
172                               [No software 1/sqrt (disabled on sgi,ibm,ia64)])],,
173 [case "${host_cpu}-${host_os}" in
174   mips*-irix* | rs6000*-aix* | powerpc*-aix | ia64*-*) enable_software_invsqrt=no ;;
175   *) enable_software_invsqrt=yes ;;
176 esac])
177 if test "$enable_software_invsqrt" = "yes"; then
178   AC_DEFINE(GMX_SOFTWARE_INVSQRT,,[Use the GROMACS sGMX_INTERNAL_XDRsqrt(x)])
179   PKG_CFLAGS="$PKG_CFLAGS -DGMX_SOFTWARE_INVSQRT"
181 AM_CONDITIONAL([GMX_SOFTWARE_INVSQRT],[test "$enable_software_invsqrt" = "yes"])
183 AC_ARG_ENABLE(fahcore,
184               [AC_HELP_STRING([--enable-fahcore],
185                               [Create a library with mdrun functionality])],, enable_fahcore=no)
189 # The four options below used to improve code scheduling, but the newest CPUs can usually rearrange
190 # instructions dynamically at runtime, so they might not make much difference now:
193 AC_ARG_ENABLE(all-static,
194               [AC_HELP_STRING([--enable-all-static],
195                               [Make completely static binaries])],, enable_all_static=no)
196 # Dont add the -all-static flag until after the compiler test.
199 # FFT libraries - only use one...
200 AC_ARG_WITH(fft,
201             [AC_HELP_STRING([--with-fft=@<:@fftw3/fftw2/mkl(>=6.0)/fftpack@:>@],
202                             [FFT library to use. fftw3 is default, fftpack built in.])],,
203                              with_fft=fftw3)
205 AC_ARG_ENABLE(fftw-measure,
206             [AC_HELP_STRING([--disable-fftw-measure],
207                             [Dont optimize FFTs. This produces binary exactly]
208                             [reproducible runs (as the -reprod flag to mdrun),]
209                             [and if you are using FFTW on x86 and specified its]
210                             [--enable-sse/sse2 flag (NOT default in FFTW!) the]
211                             [kernels used are close-to-optimal anyway.])],,
212                              enable_fftw_measure=yes)
215 AC_ARG_ENABLE(threads,
216               [AC_HELP_STRING([--disable-threads],    
217                               [Disable parallel runs using threads])],,enable_threads=yes)
220 ### Use external BLAS/LAPACK libraries if the user wants to.
222 AC_ARG_WITH(external_blas,
223             [AC_HELP_STRING([--with-external-blas],
224                             [Use system BLAS library (add to LIBS). Automatic on OS X.])],,
226 # default action - check if we are on OS X
227 case "${host_vendor}-${host_os}" in
228   apple-darwin*) with_external_blas="yes" ; extra_LDFLAGS="-framework Accelerate" ;;
229   *)             with_external_blas="no"  ;;
230 esac
232 AM_CONDITIONAL([GMX_EXTERNAL_BLAS], [test "$with_external_blas" = "yes"])
235 AC_ARG_WITH(external_lapack,
236             [AC_HELP_STRING([--with-external-lapack],
237                             [Use system LAPACK library (add to LIBS). Automatic on OS X.])],,
239 # default action - check if we are on OS X
240 case "${host_vendor}-${host_os}" in
241   apple-darwin*) with_external_lapack="yes" ; extra_LDFLAGS="-framework Accelerate" ;;
242   *)             with_external_lapack="no"  ;;
243 esac
245 AM_CONDITIONAL([GMX_EXTERNAL_LAPACK], [test "$with_external_lapack" = "yes"])
250 AC_ARG_WITH(qmmm_gaussian,
251               [AC_HELP_STRING([--without-qmmm-gaussian],
252                               [Use modified Gaussian0x for QM-MM (see website)])],,with_qmmm_gaussian=yes)
253 if test "$with_qmmm_gaussian" = "yes"; then
254   AC_DEFINE(GMX_QMMM_GAUSSIAN,,[Use (modified) Gaussian0x for QM-MM calculations])
258 AC_ARG_WITH(qmmm_gamess,
259               [AC_HELP_STRING([--without-qmmm-gamess],
260                               [Use modified Gamess-UK for QM-MM (see website)])],,with_qmmm_gamess=no)
261 if test "$with_qmmm_gamess" = "yes"; then
262   AC_DEFINE(GMX_QMMM_GAMESS,,[Use (modified) Gamess-UK for QM-MM calculations])
266 AC_ARG_WITH(qmmm_mopac,
267               [AC_HELP_STRING([--without-qmmm-mopac],
268                               [Use modified Mopac 7 for QM-MM (see website)])],,with_qmmm_mopac=no)
269 if test "$with_qmmm_mopac" = "yes"; then
270   AC_DEFINE(GMX_QMMM_MOPAC,,[Use (modified) Mopac 7 for QM-MM calculations])
274 AC_ARG_WITH(qmmm_orca,
275               [AC_HELP_STRING([--without-qmmm-orca],
276                               [Use ORCA for QM-MM])],,with_qmmm_orca=no)
277 if test "$with_qmmm_orca"="yes"; then
278   AC_DEFINE(GMX_QMMM_ORCA,,[Use ORCA for QM-MM calculations])
282 AC_ARG_WITH(dlopen,
283             [AC_HELP_STRING([--without-dlopen],
284                             [do not compile with dlopen, needed to read VMD]
285                             [supported file formats])],,with_dlopen=yes)
289 ############################################################
290 # Add some debug info: Who is building, and on what machine?
291 ############################################################
292 AC_DEFINE_UNQUOTED([BUILD_TIME],["`date`"],[Date and time for build])
293 AC_DEFINE_UNQUOTED([BUILD_USER],["`whoami`@`hostname`"],[User doing build])
294 AC_DEFINE_UNQUOTED([BUILD_MACHINE],["`uname -srm`"],[Hardware and OS version for build host])
297 ############################################################
298 # Checks for requirements for version information generation
299 ############################################################
300 generate_version=no
301 if test -d $srcdir/.git ; then
302     AC_CHECK_PROG(have_git, git, yes, no)
303     if test "$have_git" = "yes" ; then
304         AC_MSG_CHECKING(for a recent enough git)
305         if git --git-dir=$srcdir/.git rev-list -n1 --pretty=format:%cd HEAD | grep "Mon\|Tue\|Wed\|Thu\|Fri\|Sat\|Sun" >/dev/null 2>&1; then
306             AC_MSG_RESULT(yes)
307             generate_version=yes
308             AC_DEFINE(USE_VERSION_H,,[Use generated version info])
309         else
310             AC_MSG_RESULT(no)
311         fi
312     fi
313     if test "$generate_version" = "no" ; then
314         AC_MSG_WARN([No compatible git version found, won't be able to generate proper development version information.])
315     fi
317 AM_CONDITIONAL([USE_VERSION_H],[test "$generate_version" = "yes"])
320 ############################################################
321 # Checks for programs
322 ############################################################
324 # normally we use the default compiler, but on alpha/linux we try the compaq ones first
325 case "${host_cpu}-${host_os}" in
326   alpha*-linux*)
327     cc_names="ccc cc gcc"
328     f77_names="fort f77 g77"
329     ;;
330   *) 
331     cc_names="cc icc xlc gcc"
332     f77_names="f77 ifort xlf xlf77 cf77 fl32 g77 fort77 f90 xlf90 pgf77 cf77 fort fort77 pgf90"
333     ;;
334 esac
335 # the (non-mpi) c compiler, which is also used for programs executed during build stage
336 AC_PROG_CC( $cc_names )
337 # Check for environment variable CC_FOR_BUILD before overwriting it
338 if test -z "$CC_FOR_BUILD"; then
339   CC_FOR_BUILD=$CC
342 if test "$enable_gcc41_check" = "yes"; then
343     if $CC --version 2>&1 | grep 'gcc.* 4\.1' > /dev/null 2>&1; then
344         AC_MSG_ERROR([Uh-oh. Your compilers appears to be GCC version 4.1, which unfortunately produces]
345 [buggy code at high optimimzation levels. It would be a good idea to update or]
346 [use a different compiler. If you are ABSOLUTELY sure what you are doing, you]
347 [can override this check with --disable-gcc41-check.])
348     fi
353 AC_SUBST(CC_FOR_BUILD) 
355 if test "$enable_fortran" = "yes" -o "$enable_power6" = "yes"; then 
356   AC_PROG_F77( $f77_names )
357   if test -z "$F77"; then
358     AC_MSG_ERROR([No fortran compiler found])
359   fi
362 AM_PROG_AS( $CC )
364 # if we are using mpi, also get an MPICC. We cannot set that in the PROG_CC macro
365 # above, since autoconf checks that the created file can be executed. This would
366 # fail on platforms where MPI executables can only be run through a batchqueue.
368 if test "$enable_mpi" = "yes"; then
369   enable_threads="no"
370   AC_CHECK_PROGS(MPICC, mpxlc mpicc mpcc hcc, $CC)
371 # now change the normal cc to the MPI one - see the comment above.
372   CC=$MPICC
373   CXX=$MPICC
374   AC_MSG_CHECKING([whether the MPI cc command works]) # be paranoid
375   AC_TRY_LINK([#include <mpi.h>],[int argc; char **argv; MPI_Init(&argc,&argv);],
376 AC_MSG_RESULT([yes]),AC_MSG_ERROR([Cannot compile and link MPI code with $CC]))
377   AC_DEFINE(GMX_MPI,,[Make a parallel version of GROMACS using MPI])
378   AC_DEFINE(GMX_LIB_MPI,,[Use a real MPI library])
379   PKG_CFLAGS="$PKG_CFLAGS -DGMX_LIB_MPI"
381   if test "$enable_mpi_in_place" = "yes"; then
382     # not all MPIs support MPI_IN_PLACE:
383     AC_MSG_CHECKING([for MPI_IN_PLACE in collective operations])
384     AC_TRY_COMPILE([
385 #include <mpi.h>
386 void test(void)
388     void *buf;
389     MPI_Allreduce(MPI_IN_PLACE, buf, 10, MPI_FLOAT, MPI_SUM, MPI_COMM_WORLD);
391     ],,[
392         AC_MSG_RESULT([yes])
393         AC_DEFINE(MPI_IN_PLACE_EXISTS,[],[MPI_IN_PLACE available for collective operations])
394     ],[
395         AC_MSG_RESULT([no])
396     ]) 
397   fi
399 # on the cray xt3 we have to tell autoconf that we 
400 # are actually cross-compiling even if the architecture
401 # of host and target are the same. so we enforce 
402 # cross-compilation if __QK_USER__ is defined
403   AC_MSG_CHECKING([for catamount])
404   AC_TRY_COMPILE([
405 #if defined __QK_USER__
406 #else
407 #error not catamount
408 #endif
409 ],,[
410   AC_MSG_RESULT([yes])
411   cross_compiling=yes 
412   AC_DEFINE(GMX_CRAY_XT3,[],[Enable special hacks for Cray XT3])
413   PKG_CFLAGS="$PKG_CFLAGS -DGMX_CRAY_XT3"
414   AC_DEFINE(GMX_NO_SYSTEM,[],[Ignore calls to system(3)])
415   AC_DEFINE(GMX_NO_NICE,[],[Ignore calls to nice(3)])
416   AC_DEFINE(GMX_BROKEN_CALLOC,[],[Don't use calloc(3)])
417   extra_LDFLAGS="$extra_LDFLAGS -lgmalloc -lacml"
419   AC_MSG_RESULT([no])
421 # end of "$enable_mpi" = "yes"
425 AH_TEMPLATE([F77_OR_C_FUNC],
426             [Set to F77_FUNC(name,NAME) if Fortran used, otherwise 'name' for C.])
427 AH_TEMPLATE([F77_OR_C_FUNC_],
428             [Set to F77_FUNC_(name,NAME) if Fortran used, otherwise 'name' for C.])
432 if test "$enable_fortran" = "yes" -o "$enable_power6" = "yes"; then
433   AC_F77_LIBRARY_LDFLAGS
434   AC_F77_WRAPPERS
435   AC_DEFINE([F77_OR_C_FUNC(name,NAME)],[F77_FUNC(name,NAME)])
436   AC_DEFINE([F77_OR_C_FUNC_(name,NAME)],[F77_FUNC_(name,NAME)])
437 else
438   AC_DEFINE([F77_OR_C_FUNC(name,NAME)],[name])
439   AC_DEFINE([F77_OR_C_FUNC_(name,NAME)],[name])
444 AC_PROG_CPP
445 # Needed by libtool scripts?
446 AC_PROG_EGREP
447 AC_PROG_LN_S
449 if test "$enable_cpu_optimization" = "yes"; then
450   ACX_DETECT_GMXCPU
451 else
452   gmxcpu=""
454 ACX_COMPILER_MAXOPT
457 # We've postponed the threads check because we need to check with the right
458 # compilers/flags
459 SAVED_LIBS="$LIBS"
460 if test "$enable_threads" = "yes"; then 
461   if test "$enable_mpi" = "yes"; then
462     AC_MSG_ERROR([Cannot use both threads and MPI - yet.])
463   fi
464   if test "$with_fft" = "fftw2"; then
465     AC_MSG_ERROR([fftw2 can't be used with threads. Use fftw3 or mkl.])
466   fi 
467   AC_CHECK_HEADERS(unistd.h)
468   AC_CHECK_HEADERS(sys/time.h)
469   AC_CHECK_HEADERS(sched.h)
470   AC_CHECK_FUNCS(sysconf)
472   # for now we just assume pthreads
473   ACX_PTHREAD(,AC_MSG_ERROR([Cannot find POSIX threads - required for thread support using configure!]))
474   LIBS="$PTHREAD_LIBS $LIBS"
475   CFLAGS="$CFLAGS $PTHREAD_CFLAGS -I$srcdir/include"
476   CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS -I$srcdir/include"
477   CC="$PTHREAD_CC "
478   AC_DEFINE(THREAD_PTHREADS,,[Use pthreads for thread_mpi multithreading])
480   # profiling
481   AC_ARG_ENABLE(tmpi-profiling,
482               [AC_HELP_STRING([--enable-tmpi-profiling],
483               [Enables profiling of thread_mpi calls and wait times])],,
484               enable_tmpi_profiling=no)
485   if test "x$enable_tmpi_profiling" = "xyes"; then
486     AC_DEFINE(TMPI_PROFILE,,[Enable profiling for call and wait times])
487   fi
489   # check the atomics
490   AC_MSG_CHECKING(if atomic operations are supported)
491   CFLAGS_RET="$CFLAGS"
492   CXXFLAGS_RET="$CXXFLAGS"
493   CFLAGS="$CFLAGS -I$srcdir/include -DTMPI_CHECK_ATOMICS"
494   CXXFLAGS="$CXXFLAGS -I$srcdir/include -DTMPI_CHECK_ATOMICS"
495   # this sets a variable 'tmpi_atomics' to 'yes' if there are atomics. 
496   AC_COMPILE_IFELSE([#include "thread_mpi/atomic.h" ],
497                       [AC_MSG_RESULT(yes); tmpi_atomics=yes],
498                       [AC_MSG_WARN(
499 [No atomics.
501 This compiler+CPU combination doesn't have working atomics.
502 Thread support will be unbearably slow: disable threads.
504 Atomics should work on all but the most obscure CPU+compiler combinations;
505 if your system is not obscure -- like, for example, x86 with gcc --  please
506 contact the developers.
507 ]); tmpi_atomics=no])
508   CFLAGS="$CFLAGS_RET"
509   CXXFLAGS="$CXXFLAGS_RET"
511   AC_DEFINE(GMX_THREADS,,[Use threads for parallelization])
512   PKG_CFLAGS="$PKG_CFLAGS -DGMX_THREADS"
513   AC_DEFINE(GMX_MPI,,[Make a parallel version of GROMACS using MPI])
514   AM_CONDITIONAL(THREAD_PARALLEL,true)
515 else
516   AM_CONDITIONAL(THREAD_PARALLEL,false)
518 LIBS="$SAVED_LIBS"
522 #############
523 # Check integer endian
524 #############
525 AC_C_BIGENDIAN([AC_DEFINE([GMX_INTEGER_BIG_ENDIAN],,[Integer byte order is big endian.])],[],[
526 AC_MSG_ERROR([Cannot determine endian in compiled output])])
527 # Little endian implied if GMX_INTEGER_BIG_ENDIAN not defined in source.
529 #############
530 # Make sure size_t can hold pointers.
531 # On some Nec machines, you reportedly need to specify a flag for size_t to be 64 bits wide.
532 #############
533 AC_MSG_CHECKING([that size_t can hold pointers])
534 AC_TRY_COMPILE([
535 #include <stdlib.h>
536 #include <stddef.h>
537 ],[int chk[sizeof(size_t)-sizeof(int *)+1];],AC_MSG_RESULT([yes]),[
538    AC_MSG_ERROR([size_t is smaller than int*. Check if your compiler needs a flag to make it 64 bit.])])
541 #############
542 # Check that SIGUSR1 is defined
543 #############
544 AC_MSG_CHECKING([for SIGUSR1])
545 AC_TRY_COMPILE([#include <signal.h>],[int i=SIGUSR1;],[
546 AC_MSG_RESULT([yes])
547 AC_DEFINE(HAVE_SIGUSR1,,[SIGUSR1 supported and defined])
548 ],AC_MSG_RESULT([no]))
550 #############
551 # Check if pipes are supported
552 #############
553 AC_MSG_CHECKING([for pipes])
554 AC_TRY_COMPILE([#include <stdio.h>],[
555 FILE *pipe=popen("/tmp/pipe","r");
557 AC_MSG_RESULT([yes])
558 AC_DEFINE(HAVE_PIPES,,[Pipes (popen/pclose) supported])
559 ],AC_MSG_RESULT([no]))
563 #############
564 # Check floating-point format and endian
565 #############
566 ACX_FLOAT_FORMAT
569 AC_PROG_INSTALL
570 AC_PROG_LN_S
571 AC_PROG_MAKE_SET
572 AC_LIBTOOL_WIN32_DLL
573 AC_PROG_LIBTOOL
574 AC_SYS_LARGEFILE
576 # Use our own version of AC_FUNC_FSEEKO from autoconf 2.63 instead
577 # of the broken one we might get from autoconf 2.61.
578 ACX_FUNC_FSEEKO_FIXED
583 ############################################################################
584 # Checks for libraries.
585 ############################################################################
587 # Don't add math library for intel compilers
588 if $CC -V 2>&1 | grep 'Intel Corporation' > /dev/null 2>&1; then
589   AC_MSG_NOTICE([Using built-in math library with intel compiler])
590 else
591   AC_CHECK_LIB(m,sqrt,,AC_MSG_ERROR([No math library found]))
594 #####
595 # Disable MASS support for now.
596 #####
598 #save current LIBS
599 SAVED_LIBS="$LIBS"
601 #set empty defaults
602 PKG_FFT=""
603 FFT_LIBS=""
604 case "$with_fft" in
605 fftw2)
606   if test "$enable_float" = "yes"; then
607     sizeof_real=4
608   else
609     sizeof_real=8
610   fi
611   ACX_CHECK_FFTW2(fftw,$sizeof_real)
612   ACX_CHECK_FFTW2(rfftw,$sizeof_real)
613   FFT_LIBS="-lfftw -lrfftw"
615   case ${ac_fftw_savedprefix} in
616    d) AC_DEFINE(FFTW2_NAME_DFFTW,,[Use the d prefix on fftw2 includes]) ;;
617    s) AC_DEFINE(FFTW2_NAME_SFFTW,,[Use the s prefix on fftw2 includes]) ;;
618    *) AC_DEFINE(FFTW2_NAME_FFTW,,[Dont use any prefix on fftw2 includes]) ;;
619   esac
621   AC_DEFINE(GMX_FFT_FFTW2,,[Use FFTW2 FFT library])
623   ;; #  end of fftw2 check
625 fftw3) # Much simpler check than fftw2
626 # Check for header <fftw3.h> AC_CHECK_HEADERS doesnt work, since we must
627 # use mpicc to get includes - cpp isnt always the same compiler.
628 AC_MSG_CHECKING([for fftw3.h])
629 AC_TRY_COMPILE([#include<fftw3.h>],,[
630 # ok, look for library file too
631 AC_MSG_RESULT(yes)
632 if test "$enable_float" = "yes"; then
633   AC_CHECK_LIB([fftw3f],main,,AC_MSG_ERROR([Cannot find fftw3f library]))
634   PKG_FFT="fftw3f"
635   FFT_LIBS="-lfftw3f"
636 else
637   AC_CHECK_LIB([fftw3],main,,AC_MSG_ERROR([Cannot find fftw3 library]))
638   PKG_FFT="fftw3"
639   FFT_LIBS="-lfftw3"
641   AC_DEFINE(GMX_FFT_FFTW3,,[Use FFTW3 FFT library])
643 # not ok, echo a warning
644 AC_MSG_ERROR(
645 [Cannot find the default external FFT library (fftw3).
646 Other alternatives are 'fftw2', or 'mkl' for Intel MKL.
647 You are STRONGLY recommended to use one of these - fftw is free.
649 Use CPPFLAGS and LDFLAGS if the library is installed in a 
650 non-standard location. (see FAQ at http://www.gromacs.org)
651                                                           
652 If you dont care about performance you can also specify 'fftpack'
653 to use a slower set of FFTs built into Gromacs. 
654 (Just install FFTW3 unless you really know what you are doing).
657   ;;
659 mkl*)
660 ###########
661 # Intel Math Kernel Library version 6 and later.
662 ##########
663 AC_MSG_CHECKING([for mkl_dfti.h])
664 AC_TRY_COMPILE([#include<mkl_dfti.h>],,AC_MSG_RESULT(yes),AC_MSG_ERROR([Cannot find mkl_dfti.h header from Intel Math Kernel Library>=6.0.]\
666 ## Check for library
667 #  AC_CHECK_LIB([guide],main,,AC_MSG_ERROR([Cannot find libguide (Intel MKL)]))
668 #  AC_CHECK_LIB([mkl],DftiComputeForward,,
669 #    AC_MSG_ERROR([Cannot find Intel Math Kernel Library >= 6.0]))
670   # first check for older MKLs
671   AC_CHECK_LIB([mkl],DftiComputeForward,,[have_mkl="no"])
672   if test "$have_mkl" = "no"; then
673     # we assume it's a new MKL
674     LIBS="$LIBS -liomp5 -lmkl_sequential -lmkl_core"
675     LMKL=" -liomp5 -lmkl_sequential -lmkl_core"
676     AC_CHECK_LIB([mkl_intel_lp64],DftiComputeForward,,[have_mkl10_64="no"])
677     FFT_LIBS="$LMKL -lmkl_intel_lp64"
678     if test "$have_mkl10_64" = "no"; then
679       AC_CHECK_LIB([mkl_intel],DftiComputeForward,,[have_mkl10_32="no"])
680       FFT_LIBS="$LMKL -lmkl_intel"
681       if test "$have_mkl10_32" = "no"; then
682         AC_MSG_ERROR([Cannot find Intel Math Kernel Library >= 6.0])
683       fi
684     fi
685   fi
686   AC_DEFINE(GMX_FFT_MKL,,[Use Intel MKL FFT library])
687   AC_SUBST(LMKL)
688   ;;
690 fftpack | no)
691   AC_MSG_WARN([The built-in FFTPACK routines are slow.
692 Are you sure you don't want to use FFTW? It is free and much faster...])
693   AC_DEFINE(GMX_FFT_FFTPACK,,[Use Built-in FFTPACK FFT library])
694   ;;
696   AC_MSG_ERROR([Unknown FFT library])
697   ;;
698 esac
699 #restore LIBS from before fft check
700 LIBS="$SAVED_LIBS"
702 #only fftw3 has support for pkg-config
703 AC_SUBST(PKG_FFT)
704 if test -z "${PKG_FFT}"; then
705   AC_SUBST(PKG_FFT_LIBS,"$FFT_LIBS")
706 else
707   AC_SUBST(PKG_FFT_LIBS,"")
709 #flag for Makefile
710 AC_SUBST(FFT_LIBS)
712 if test "$enable_fftw_measure" != "yes"; then
713    AC_DEFINE(GMX_DISABLE_FFTW_MEASURE,,[Do not optimize FFTW setups (not needed with SSE FFT kernels)])
716 ######
717 # check for xtc headers
718 case "${host_os}" in
719 cygwin* | mingw*)   # use our own xdr stuff for cygwin/mingw
720   ;;
722   AC_CHECK_HEADERS([rpc/rpc.h])
723   AC_CHECK_HEADERS([rpc/xdr.h],,,
724 [#if HAVE_RPC_RPC_H
725 # include <rpc/rpc.h>
726 #endif
728   AC_CHECK_LIB(nsl,xdr_float)
729   AC_TRY_LINK([
730 #if HAVE_RPC_RPC_H
731 #include<rpc/rpc.h> 
732 #else
733 #error NO rpc.h header
734 #endif
735 #if HAVE_RPC_XDR_H
736 #include<rpc/xdr.h>
737 #else
738 #error No xdr.h header
739 #endif
740 ],[ XDR *xd; float f; xdr_float(xd,&f);],[have_xdr="yes"])
742   if test "$have_xdr" != "yes"; then
743     AC_DEFINE(GMX_INTERNAL_XDR,,[Use our own instead of system XDR libraries])  
744     PKG_CFLAGS="$PKG_CFLAGS -DGMX_INTERNAL_XDR"
745     AC_MSG_WARN([Couldn't find XDR headers and/or libraries - using our own])
746   fi
747   ;;
748 esac
751 ########################################################################
752 # Checks for header files and types
753 ########################################################################
755 AC_CHECK_HEADERS([limits.h unistd.h],,AC_MSG_ERROR([Include headers not found]))
756 AC_CHECK_HEADERS(unistd.h)
757 AC_CHECK_HEADERS(sys/types.h)
758 AC_CHECK_HEADERS(sys/time.h)
759 AC_CHECK_HEADERS(dirent.h,,[AC_MSG_WARN(
761 ********************************************************************
762 * WARNING! We could not find the header file dirent.h              *
763 *                                                                  *
764 * Without this header, we will not be able to scan directories for *
765 * files, which completely breaks pdb2gmx. You will still be able   *
766 * to run simulations, but you cannot prepare input data.           *
767 * dirent.h is part of the POSIX 2001-1 standard, and should be     *
768 * present on all UNIX-like systems, CygWin, and MinGW.             *
769 ********************************************************************])])
770 ## NOTE: On native windows we do not use configure.ac
771 AC_CHECK_HEADERS(regex.h,,[AC_MSG_WARN(
772 [No regex.h found.
773 Regular expression matching in selections will be disabled.
774 Selections still work, but the default groups can differ from
775 those obtained with regular expressions enabled.
776 Consider installing the regular expression library from GNU libc.])])
780 #####
781 # Checks for additional and/or optional functions or libraries.
782 #AC_FUNC_MALLOC
783 AC_FUNC_MEMCMP
784 AC_TYPE_SIGNAL
785 AC_TYPE_OFF_T
786 AC_FUNC_VPRINTF
787 AM_WITH_DMALLOC
788 AC_CHECK_FUNCS(strcasecmp)
789 AC_CHECK_FUNCS(strdup)
790 AC_CHECK_FUNCS(gettimeofday)
791 AC_CHECK_FUNCS(cbrt)
792 AC_CHECK_FUNCS(isnan)
793 AC_CHECK_FUNCS(_isnan)
794 AC_CHECK_FUNCS(isfinite)
795 AC_CHECK_FUNCS(_isfinite)
796 AC_CHECK_FUNCS(fsync)
797 AC_CHECK_FUNCS(fileno)
799 # check for bool (must come late, since CFLAGS/includes might affect it)
800 AC_CHECK_TYPES([bool])
801 AC_SEARCH_LIBS(posix_memalign, c, AC_DEFINE(HAVE_POSIX_MEMALIGN, 1, Define to 1 if you have the posix_memalign function))
802 AC_SEARCH_LIBS(memalign, c, AC_DEFINE(HAVE_MEMALIGN, 1, Define to 1 if you have the memalign function))
803 AC_CHECK_FUNCS(_aligned_malloc)
804 #AC_SEARCH_LIBS(_aligned_malloc, c, AC_DEFINE(HAVE__ALIGNED_MALLOC, 1, Define to 1 if you have the _aligned_malloc function))
811 #############
812 # Check integer sizes, set to zero if e.g. long long is not supported.
813 # (Note: this must come *after* type checks for the corresponding types!)
814 #############
815 AC_CHECK_SIZEOF(int)
816 AC_CHECK_SIZEOF(long int)
817 AC_CHECK_SIZEOF(long long int)
818 AC_CHECK_SIZEOF(off_t)
819 AC_CHECK_SIZEOF(void*)
823 # Apple OS X is a bit strange/braindead in that it always reports itself as i386, both for
824 # 32 and 64 bit builds (even with the 64 bit kernel!).
826 # To get the SSE support right we check for the size of void * that we detected above...
827 case "${host_vendor}-${host_os}" in
828   apple-darwin*)
829   if test $ac_cv_sizeof_voidp = 8; then
830      enable_ia32_sse=no;
831   else
832      enable_x86_64_sse=no;
833   fi
834   ;;
835   *) ;;
836 esac
841 #####
842 # Look for X
843 AC_PATH_XTRA
844 if test "$no_x" != "yes"; then
845   AM_CONDITIONAL(USE_X11,true)
846 else
847   AM_CONDITIONAL(USE_X11,false)
850 # GNU Scientific Library or not
851 AC_ARG_WITH(gsl,
852  [AC_HELP_STRING([--with-gsl],[Link to the GNU scientific library, ]
853                  [enables extra functions in analysis])],,with_gsl=no)
855 ######
856 PKG_GSL=""
857 GSL_LIBS=""
858 if test "$with_gsl" = "yes"; then
859   SAVED_LIBS="$LIBS"
860   AC_CHECK_HEADERS([gsl/gsl_version.h],[
861 # header found, check for libraries 
862   AC_CHECK_LIB(gslcblas,main,[
863 # gslcblas library found, check main lib
864   AC_CHECK_LIB(gsl,main,[
865 # everything need for gsl found
866   GSL_LIBS="-lgsl -lgslcblas"
867 #gsl has pkg-config support
868   PKG_GSL="gsl"
869   AC_DEFINE(HAVE_LIBGSL,1,[Do we have libgsl])
870   ],[:],[-lgslcblas])])])
871   LIBS="$SAVED_LIBS"
874 AC_SUBST(PKG_GSL)
875 AC_SUBST(GSL_LIBS)
877 AC_ARG_WITH(xml,
878  [AC_HELP_STRING([--without-xml],[do not link to the xml2 library,] 
879                  [disallows the use of certain file formats])],,with_xml=yes)
881 #########
882 # Check for libxml2, but it is optional, so dont stop
883 # if it isnt there.
884 PKG_XML=""
885 XML_LIBS=""
886 if test "$with_xml" = "yes"; then
887    SAVED_LIBS="$LIBS"
888    ac_save_CPPFLAGS="$CPPFLAGS"
889    CPPFLAGS="$ac_save_CPPFLAGS -I/usr/include/libxml2"
890    AC_CHECK_HEADERS([libxml/parser.h],AC_CHECK_LIB(xml2,main))
891    if test "$ac_cv_lib_xml2_main" = "yes"; then
892      INCLUDES="$INCLUDES -I/usr/include/libxml2"
893      PKG_XML="libxml-2.0"
894      XML_LIBS="-lxml2"
895      if test "$enable_all_static" = "yes"; then
896        LDFLAGS_RET=$LDFLAGS
897        LDFLAGS="-static $LDFLAGS"
898        LIBS_RET="$LIBS"
899        LIBS="$LIBS -lz"
900        AC_MSG_CHECKING(for broken libxml2)
901        AC_TRY_RUN([
902 #include <libxml/parser.h>
903 main() {
904   xmlInitParser();
905   return 0;
907        AC_MSG_RESULT([no]),[AC_MSG_RESULT([yes])
908        AC_MSG_ERROR([Your libxml2 is broken for static linking, recompile it without threads or build gromacs without libxml])],[-lz])
909        LDFLAGS=$LDFLAGS_RET
910        LIBS="$LIBS_RET"
911      fi
912    fi
913 # restore CPPFLAGS
914    CPPFLAGS="$ac_save_CPPFLAGS"
915    LIBS="$SAVED_LIBS"
917 AC_SUBST(PKG_XML)
918 AC_SUBST(XML_LIBS)
920 #### 
921 # And collect the f77 libs to the linker - on Solaris, f77 stuff must go first,
922 # and we need -L/usr/ucblib to find libucb... (stupid OS)
923 # On e.g. ibm the mass libraries must come before -lm... 
924 case "${host_cpu}-${host_os}" in
925   *-solaris*) 
926     LIBS="$FLIBS $LIBS" 
927     LDFLAGS="$LDFLAGS -L/usr/ucblib"
928     ;;
929   *) LIBS="$LIBS $FLIBS" ;;
930 esac
933 # add the Accelerate framework if enabled above.
934 # LDFLAGS might have been set in the CPU optimization, so we cant assign it directly before that.
935 LDFLAGS="$LDFLAGS $extra_LDFLAGS"
942 #####
943 # Checks for typedefs, structures, and compiler characteristics.
944 AC_C_CONST
945 AC_TYPE_SIZE_T
946 AC_STRUCT_TM
947 AC_C_INLINE
948 AC_C_RESTRICT
950 # AC_TYPE_UID_T is broken on Mac OS X, so use generic tests instead
951 AC_CHECK_TYPES([uid_t],[],[AC_DEFINE(uid_t, int, [Define to `int' if <sys/types.h> doesn't define.])],[[#include <sys/types.h>]])
952 AC_CHECK_TYPES([gid_t],[],[AC_DEFINE(gid_t, int, [Define to `int' if <sys/types.h> doesn't define.])],[[#include <sys/types.h>]])
954 AC_CHECK_TYPES([sig_atomic_t],[],[AC_DEFINE(sig_atomic_t, int, [Define to `int' (and hope it's atomic) if <signal.h> doesn't define it.])],[[#include <signal.h>]])
956     
959 # Test stuff for ia32 and x86_64 assembly, and add objects/libraries.
960 if test "$enable_ia32_sse" = "yes" -o "$enable_x86_64_sse" = "yes"; then
961   AC_MSG_CHECKING([whether your compiler can handle assembly files (*.s)])
963 # Use 64-bit registers (rsp/rbp) on x86_64
965 if test "$enable_x86_64_sse" = "yes"; then
966 cat > conftestasm.s << EOF
967 checkasm:
968         mov     %rsp, %rbp
969         ret
971 else
972 cat > conftestasm.s << EOF
973 checkasm:
974         movl    %esp, %ebp
975         ret
978   if AC_TRY_COMMAND($CC $CFLAGS -c conftestasm.s); then
979     if test -f conftestasm.o; then
980       AC_MSG_RESULT([yes])
981     else
982       AC_MSG_RESULT([no])
983       AC_MSG_ERROR([Upgrade your compiler (or disable assembly loops).])
984     fi
985   else
986     AC_MSG_RESULT([no])
987     AC_MSG_ERROR([Upgrade your compiler (or disable assembly loops).])
988   fi
990 # ok, cc understands assembly.
992 # If we are using double precision we need SSE2
993   if test "$enable_float" = "no"; then
994 #   test SSE2 on ia32:
995     if test "$enable_ia32_sse" = "yes"; then
996       AC_MSG_CHECKING([whether as fully supports ia32 SSE2])
997 cat > conftest.s << EOF
998 checkasm:
999         emms
1000         movapd 32(%esi,%edx,8),%xmm4
1001         emms
1002         ret
1004       if AC_TRY_COMMAND($CC $CFLAGS -c conftest.s); then
1005         AC_MSG_RESULT([yes])
1006       else
1007         AC_MSG_RESULT([no])
1008         AC_MSG_ERROR([Upgrade to a more recent binutils (or disable assembly loops).])
1009       fi
1010       AC_DEFINE([GMX_IA32_SSE2],,[Double-precision SSE2 instructions on ia32])
1011     fi
1012 #   test SSE2 on X86_64:
1013     if test "$enable_x86_64_sse" = "yes"; then
1014       AC_MSG_CHECKING([whether as fully supports X86_64 SSE2])
1015 cat > conftest.s << EOF
1016 checkasm:
1017         emms
1018         movapd 32(%rsi,%rdx,8),%xmm4
1019         emms
1020         ret
1022       if AC_TRY_COMMAND($CC $CFLAGS -c conftest.s); then
1023         AC_MSG_RESULT([yes])
1024       else
1025         AC_MSG_RESULT([no])
1026         AC_MSG_ERROR([Upgrade to a more recent binutils (or disable assembly loops).])
1027       fi
1028       AC_DEFINE([GMX_X86_64_SSE2],,[Double-precision SSE2 instructions on X86_64])
1029     fi
1030   else
1031 # end of double precision testing, now do single.
1032     if test "$enable_ia32_sse" = "yes"; then
1033       AC_MSG_CHECKING([whether as fully supports ia32 SSE])
1034 cat > conftest.s << EOF
1035 checkasm:
1036         emms
1037         movaps 32(%esi,%edx,8),%xmm4
1038         emms
1039         ret
1041       if AC_TRY_COMMAND($CC $CFLAGS -c conftest.s); then
1042         AC_MSG_RESULT([yes])
1043       else
1044         AC_MSG_RESULT([no])
1045         AC_MSG_ERROR([Upgrade to a more recent binutils (or disable assembly loops).])
1046       fi
1047       AC_DEFINE([GMX_IA32_SSE],,[Single-precision SSE instructions on ia32])
1048     fi
1049 #   test SSE2 on X86_64:
1050     if test "$enable_x86_64_sse" = "yes"; then
1051       AC_MSG_CHECKING([whether as fully supports X86_64 SSE instructions])
1052 cat > conftest.s << EOF
1053 checkasm:
1054         emms
1055         movaps 32(%rsi,%rdx,8),%xmm4
1056         emms
1057         ret
1059       if AC_TRY_COMMAND($CC $CFLAGS -c conftest.s); then
1060         AC_MSG_RESULT([yes])
1061       else
1062         AC_MSG_RESULT([no])
1063         AC_MSG_ERROR([Upgrade to a more recent binutils (or disable assembly loops).])
1064       fi
1065       AC_DEFINE([GMX_X86_64_SSE],,[Single-precision SSE instructions on X86_64])
1066     fi
1067   fi
1071 # Test stuff for ia64 assembly
1073 # Nothing to test right now.
1076   
1079 # Test altivec support.
1081 if test "$enable_ppc_altivec" = "yes"; then
1082   if test "$enable_float" = "no"; then
1083     AC_MSG_WARN([PowerPC Altivec loops can only be used in single precision - disabling])
1084     enable_ppc_altivec=no
1085   else 
1086     # On FSF (vanilla) GCC we must include altivec.h, and on apple we 
1087     # should NOT do it after using -faltivec. Go figure...
1088     case "${host_os}" in
1089     darwin*)                            
1090         # do nothing on Apple systems
1091        ;;
1092     *)
1093         AC_CHECK_HEADERS([altivec.h])
1094        ;;
1095     esac
1097     AC_MSG_CHECKING([whether the compiler supports altivec extensions])
1098     AC_TRY_COMPILE([],[
1099 #ifndef __VEC__
1100 choke_me
1101 #endif
1103     AC_MSG_RESULT([yes])
1104     AC_DEFINE([GMX_PPC_ALTIVEC],,[Use PowerPC Altivec inner loops])],[
1105       AC_MSG_RESULT([no])
1106       AC_MSG_WARN([no altivec support found - On recent PowerPC CPUs]
1107 [you can get a huge performance gain by using an altivec-enabled compiler.]
1108 [On OS X, you need GCC>=3.3, or the IBM compilers. If you are using standard]
1109 [GCC, you need at least version 4.0])
1110       enable_ppc_altivec=no])
1111   fi  
1114 if test "$enable_ia64_asm" = "yes"; then
1115   AC_DEFINE(GMX_IA64_ASM,,[Use ia64 assembly tuned for Itanium2])
1116   AC_DEFINE(DISABLE_WATER_NLIST,,[Turn off all water neighborlist optimization])
1117   AC_DEFINE(DISABLE_WATERWATER_NLIST,,[Turn off water-water neighborlist optimization only])
1120 if test "$enable_bluegene" = "yes"; then
1121   AC_DEFINE(GMX_BLUEGENE,,[Use assembly intrinsics kernels for BlueGene])
1124 if test "$enable_fortran" = "yes"; then
1125   AC_DEFINE(GMX_FORTRAN,,[Enable Fortran support])
1129 # Add the appropriate assembly loops 
1131 AM_CONDITIONAL([GMX_IA32_SSE],[test "$enable_ia32_sse" = "yes" -a "$enable_float" = "yes"])
1132 AM_CONDITIONAL([GMX_IA32_SSE2],[test "$enable_ia32_sse" = "yes" -a "$enable_float" = "no"])
1133 AM_CONDITIONAL([GMX_X86_64_SSE],[test "$enable_x86_64_sse" = "yes" -a "$enable_float" = "yes"])
1134 AM_CONDITIONAL([GMX_X86_64_SSE2],[test "$enable_x86_64_sse" = "yes" -a "$enable_float" = "no"])
1135 AM_CONDITIONAL([GMX_FORTRAN],[test "$enable_fortran" = "yes"])
1136 AM_CONDITIONAL([GMX_PPC_ALTIVEC],[test "$enable_ppc_altivec" = "yes" -a "$enable_float" = "yes"])
1137 AM_CONDITIONAL([GMX_IA64_ASM],[test "$enable_ia64_asm" = "yes"])
1138 AM_CONDITIONAL([GMX_BLUEGENE],[test "$enable_bluegene" = "yes"])
1139 AM_CONDITIONAL([GMX_POWER6],[test "$enable_power6" = "yes"])
1142 #############
1143 # Check integer endian
1144 #############
1145 AC_C_BIGENDIAN([AC_DEFINE([GMX_INTEGER_BIG_ENDIAN],,[Integer byte order is big endian.])],[],[
1146 AC_MSG_ERROR([Cannot determine endian in compiled output])])
1147 # Little endian implied if GMX_INTEGER_BIG_ENDIAN not defined in source.
1151 case "${host_cpu}" in
1152    i?86) 
1153          # Check if inline assembly works
1154          AC_MSG_CHECKING(if the compiler supports gcc inline assembly)
1155       AC_TRY_LINK([],[float f;int i; asm("fld %1\nfistpl %0\n" : "=m" (*&i) : "f" (f));],[AC_MSG_RESULT(yes)
1156 AC_DEFINE(GMX_X86_GCC_INLINE_ASM,,[Enable x86 gcc inline assembly])],[AC_MSG_RESULT(no)])
1157          # Check for MSVC inline assembly
1158      AC_MSG_CHECKING(if the compiler supports MSVC inline assembly)
1159       AC_TRY_LINK([],[float f;int i; _asm { fld f } ; _asm { fistpl i };],[AC_MSG_RESULT(yes)
1160 AC_DEFINE(GMX_X86_MSVC_INLINE_ASM,,[Enable x86 MSVC inline assembly])],[AC_MSG_RESULT(no)])
1161         ;;              
1162    *) ;;
1163 esac
1166 ############
1167 # Check dlopen
1168 ###########
1169 if test "$with_dlopen" = "yes"; then
1170       AC_MSG_CHECKING(if dlopen supported)
1171       CFLAGS_RET=$CFLAGS
1172       #LDFLAGS="$lt_cv_dlopen_libs $LDFLAGS" #can't make the macro, which is getting lt_cv_dlopen_libs, to work
1173       LDFLAGS_RET=$LDFLAGS
1174       if test "$enable_all_static" = "yes"; then  #make sure we test also whether it works static
1175          LDFLAGS="$LDFLAGS -static"
1176       fi
1177       CFLAGS="-I$srcdir/include -DGMX_DLOPEN $CFLAGS"
1178       AC_TRY_LINK([#include "$srcdir/src/gmxlib/vmddlopen.c"],,[AC_MSG_RESULT([yes])\
1179         AC_DEFINE(GMX_DLOPEN,,[Compile with dlopen])],AC_MSG_RESULT([no]))
1180       CFLAGS=$CFLAGS_RET
1181       LDFLAGS=$LDFLAGS_RET
1187 ########################################################################
1188 # Final output stage
1189 ########################################################################
1190 AS="$CC"
1191 AC_SUBST(ASFLAGS)
1192 AC_SUBST(AS)
1193 AC_SUBST(INCLUDES)          # should be automatic, but doesnt seem to be?
1195 # To tell libraries apart, we use four versions of the name. For instance, libgmx:
1196 # libgmx                single prec, no mpi.
1197 # libgmx_d              double prec, no mpi.
1198 # libgmx_mpi            single prec, mpi.
1199 # libgmx_mpi_d          double prec, mpi.
1200 # However, the non-suffixed names are linked to the _mpi and/or _d suffixed
1201 # ones upon installation if that is the only version available.
1203 AC_ARG_VAR(
1204   [LIBSUFFIX],
1205   [To tell libraries apart, a suffix can be used. This is normally done
1206    automatically during ./configure (_d|_mpi|_mpi_d). But with this
1207    variable you can overwrite it
1208   ]
1210 if test -z ${LIBSUFFIX} ; then
1211   if test "$enable_mpi" = "yes"; then
1212     LIBSUFFIX="_mpi"
1213   fi
1214   if test "$enable_float" = "no"; then
1215     LIBSUFFIX="${LIBSUFFIX}_d"
1216   fi
1218 AC_SUBST(LIBSUFFIX)
1220 # Unless the user has explicitly requested a prefix/suffix/transform, we
1221 # use _d on double precision files. Don't add anything for mpi, but at the
1222 # end we tell the user it is possible and smart to do in some cases!
1223 if test "$program_transform_name" = "s,x,x,"; then
1224   name_transform_provided=no;
1225   if test "$enable_float" = "no"; then
1226     program_transform_name="s,\$\$,_d,"
1227   fi
1228 else
1229   name_transform_provided=yes;
1233 # Use a variable for RPM - this way it can be 
1234 # overridden with make RPM=rpm3 rpm
1235 RPM=rpm
1236 AC_SUBST(RPM)
1238 if test "$enable_fahcore" = "yes"; then  
1239   CPPFLAGS="$CPPFLAGS -I\$(top_srcdir)/../corewrap -include swindirect.h -DFULLINDIRECT -DUSE_FAH_XDR"  
1240   if test "$enable_mpi" = "yes"; then 
1241     CFLAGS="$CFLAGS -DMPI"  
1242   fi
1244 AM_CONDITIONAL([GMX_FAHCORE],[test "$enable_fahcore" = "yes"])
1247 if test "$enable_all_static" = "yes"; then
1248   LDFLAGS="$LDFLAGS -all-static"
1251 # we have asm source, so this is necessary for automake 1.6
1252 CCAS=$CC
1253 CCASFLAGS=$CFLAGS
1255 AC_SUBST(CCAS)
1256 AC_SUBST(CCASFLAGS)
1257 AC_SUBST(PKG_CFLAGS)
1259 AC_CONFIG_FILES([ Makefile ])
1260 AC_CONFIG_FILES([ src/Makefile ])
1261 AC_CONFIG_FILES([ src/gmxlib/Makefile ])
1262 AC_CONFIG_FILES([ src/gmxlib/libgmx${LIBSUFFIX}.pc:src/gmxlib/libgmx.pc.in ])
1263 AC_CONFIG_FILES([ src/gmxlib/gmx_blas/Makefile ])
1264 AC_CONFIG_FILES([ src/gmxlib/gmx_lapack/Makefile ])
1265 AC_CONFIG_FILES([ src/gmxlib/selection/Makefile ])
1266 AC_CONFIG_FILES([ src/gmxlib/statistics/Makefile ])
1267 AC_CONFIG_FILES([ src/gmxlib/trajana/Makefile ])
1268 AC_CONFIG_FILES([ src/gmxlib/thread_mpi/Makefile ])
1269 AC_CONFIG_FILES([ src/gmxlib/nonbonded/Makefile ])
1270 AC_CONFIG_FILES([ src/gmxlib/nonbonded/nb_kernel_c/Makefile ])
1271 AC_CONFIG_FILES([ src/gmxlib/nonbonded/nb_kernel_ia32_sse/Makefile ])
1272 AC_CONFIG_FILES([ src/gmxlib/nonbonded/nb_kernel_ia32_sse2/Makefile ])
1273 AC_CONFIG_FILES([ src/gmxlib/nonbonded/nb_kernel_x86_64_sse/Makefile ])
1274 AC_CONFIG_FILES([ src/gmxlib/nonbonded/nb_kernel_x86_64_sse2/Makefile ])
1275 AC_CONFIG_FILES([ src/gmxlib/nonbonded/nb_kernel_ppc_altivec/Makefile ])
1276 AC_CONFIG_FILES([ src/gmxlib/nonbonded/nb_kernel_ia64_single/Makefile ])
1277 AC_CONFIG_FILES([ src/gmxlib/nonbonded/nb_kernel_ia64_double/Makefile ])
1278 AC_CONFIG_FILES([ src/gmxlib/nonbonded/nb_kernel_bluegene/Makefile ])
1279 AC_CONFIG_FILES([ src/gmxlib/nonbonded/nb_kernel_power6/Makefile ])
1280 AC_CONFIG_FILES([ src/gmxlib/nonbonded/nb_kernel_f77_single/Makefile ])
1281 AC_CONFIG_FILES([ src/gmxlib/nonbonded/nb_kernel_f77_double/Makefile ])
1282 AC_CONFIG_FILES([ include/Makefile ])
1283 AC_CONFIG_FILES([ include/types/Makefile ])
1284 AC_CONFIG_FILES([ include/thread_mpi/Makefile ])
1285 AC_CONFIG_FILES([ include/thread_mpi/atomic/Makefile ])
1286 AC_CONFIG_FILES([ src/mdlib/Makefile ])
1287 AC_CONFIG_FILES([ src/mdlib/libmd${LIBSUFFIX}.pc:src/mdlib/libmd.pc.in ])
1288 AC_CONFIG_FILES([ src/kernel/Makefile ])
1289 AC_CONFIG_FILES([ src/kernel/libgmxpreprocess${LIBSUFFIX}.pc:src/kernel/libgmxpreprocess.pc.in ])
1290 AC_CONFIG_FILES([ src/tools/Makefile ])
1291 AC_CONFIG_FILES([ src/tools/libgmxana${LIBSUFFIX}.pc:src/tools/libgmxana.pc.in ])
1292 AC_CONFIG_FILES([ src/ngmx/Makefile ])
1293 AC_CONFIG_FILES([ src/contrib/Makefile ])
1294 AC_CONFIG_FILES([ scripts/Makefile ])
1295 AC_CONFIG_FILES([ admin/Makefile ])
1296 AC_CONFIG_FILES([ share/Makefile ])
1297 AC_CONFIG_FILES([ share/tutor/Makefile ])
1298 AC_CONFIG_FILES([ share/tutor/gmxdemo/Makefile ])
1299 AC_CONFIG_FILES([ share/tutor/nmr1/Makefile ])
1300 AC_CONFIG_FILES([ share/tutor/nmr2/Makefile ])
1301 AC_CONFIG_FILES([ share/tutor/water/Makefile ])
1302 AC_CONFIG_FILES([ share/tutor/mixed/Makefile ])
1303 AC_CONFIG_FILES([ share/tutor/methanol/Makefile ])
1304 AC_CONFIG_FILES([ share/tutor/speptide/Makefile ])
1305 AC_CONFIG_FILES([ share/template/Makefile ])
1306 AC_CONFIG_FILES([ share/top/Makefile ])
1307 AC_CONFIG_FILES([ share/top/gmx.ff/Makefile ])
1308 AC_CONFIG_FILES([ share/top/gmx2.ff/Makefile ])
1309 AC_CONFIG_FILES([ share/top/encadv.ff/Makefile ])
1310 AC_CONFIG_FILES([ share/top/encads.ff/Makefile ])
1311 AC_CONFIG_FILES([ share/top/oplsaa.ff/Makefile ])
1312 AC_CONFIG_FILES([ share/top/gromos43a1.ff/Makefile ])
1313 AC_CONFIG_FILES([ share/top/gromos43a2.ff/Makefile ])
1314 AC_CONFIG_FILES([ share/top/gromos45a3.ff/Makefile ])
1315 AC_CONFIG_FILES([ share/top/gromos53a5.ff/Makefile ])
1316 AC_CONFIG_FILES([ share/top/gromos53a6.ff/Makefile ])
1317 AC_CONFIG_FILES([ share/top/charmm27.ff/Makefile ])
1318 AC_CONFIG_FILES([ share/top/amber94.ff/Makefile ])
1319 AC_CONFIG_FILES([ share/top/amber96.ff/Makefile ])
1320 AC_CONFIG_FILES([ share/top/amberGS.ff/Makefile ])
1321 AC_CONFIG_FILES([ share/top/amber99.ff/Makefile ])
1322 AC_CONFIG_FILES([ share/top/amber99sb.ff/Makefile ])
1323 AC_CONFIG_FILES([ share/top/amber99sb-ildn.ff/Makefile ])
1324 AC_CONFIG_FILES([ share/top/amber03.ff/Makefile ])
1325 AC_CONFIG_FILES([ share/html/Makefile ])
1326 AC_CONFIG_FILES([ share/html/images/Makefile ])
1327 AC_CONFIG_FILES([ share/html/online/Makefile ])
1328 AC_CONFIG_FILES([ man/Makefile man/man1/Makefile man/man7/Makefile ])
1329 AC_CONFIG_FILES([ Doxyfile ])
1330 AC_OUTPUT
1338 #########################################################
1339 # Echo some important info, to avoid stupid mistakes
1342 if test "$enable_float" = "no" -a "$name_transform_provided" = "no"; then
1343   echo ""
1344   echo "* You are compiling a double precision version of Gromacs -"
1345   echo "  program names will be suffixed with _d to avoid overwriting single"
1346   echo "  precision files. You can override it with --program-suffix"
1349 if test "$name_transform_provided" = "no" -a "$enable_mpi" = "yes"; then
1350   echo ""
1351   echo "* Seems you are compiling with MPI support. You can install the MPI-"
1352   echo "  enabled programs with suffixed names to have both MPI and non-MPI"
1353   echo "  versions. This is useful e.g. on supercomputers where you usually"
1354   echo "  cannot run MPI-linked programs on the login node."
1355   echo "  Set a suffix with e.g. --program-suffix=_mpi (or _mpi_d for double)."
1356   echo "  You only need MPI for mdrun, so if you already have non-MPI stuff"
1357   echo "  installed you can issue make mdrun; make install-mdrun."
1358   echo ""
1359   echo "  WARNING:"
1360   echo "  There are known problems with some MPI implementations:"
1361   echo "             OpenMPI version < 1.4.1" 
1362   echo "             MVAPICH2 version <= 1.4.1"
1365 if test "$enable_shared" = "no"; then
1366   echo ""
1367   echo "* On most platforms you can save 10X space with dynamic libraries, although"
1368   echo "  the binaries might be less portable. Why not try --enable-shared ?"
1369 fi  
1372 if test "$tmpi_atomics" = "no"; then
1373   echo ""
1374   echo "* This compiler+CPU combination doesn't have working atomic operations."
1375   echo "  Thread support will be unbearably slow: the default number of threads"
1376   echo "  is set to 1."
1377   echo "  Atomics should work on all but the most obscure CPU+compiler"
1378   echo "  combinations; if your system is not obscure (like, for example, x86"
1379   echo "  with gcc) please contact the developers."
1380   echo ""