Fixed bug http://bugzilla.gromacs.org/show_bug.cgi?id=564 by adding a call to a routi...
[gromacs/rigid-bodies.git] / configure.ac
blobff1ca8f34e9528be2169cfa09bafaf92b78afdd0
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 # always use CC for linking:
55 AC_SUBST(F77LINK,"\$(LINK)")
61 ### MPI or not
62 AC_ARG_ENABLE(mpi,
63               [AC_HELP_STRING([--enable-mpi],
64                               [Compile for parallel runs using MPI]
65                               [(instead of threads)])],,enable_mpi=no)
68 ### MPI environment
69 AC_ARG_ENABLE(mpi-environment,
70               [AC_HELP_STRING([--enable-mpi-environment=VAR],
71                               [Only start parallel runs when VAR is set])],,
72 [case "${host_cpu}" in
73   mips*-irix*) enable_mpi_environment="MPI_ENVIRONMENT" ;;
74   *) enable_mpi_environment=no ;;
75 esac])
76 if test "$enable_mpi_environment" != "no"; then
77   AC_DEFINE_UNQUOTED(GMX_CHECK_MPI_ENV,"$enable_mpi_environment",[If defined, only start MPI runs when this variable is set])
80 ### MPI_IN_PLACE
81 AC_ARG_ENABLE(mpi-in-place,
82               [AC_HELP_STRING([--disable-mpi-in-place],
83                               [Disable MPI_IN_PLACE. For MPI implementations]
84                               [that have broken support for it ]
85                               [(some versions of MPICH, for example).])],, enable_mpi_in_place=yes)
89 AC_ARG_ENABLE(debug,
90               [AC_HELP_STRING([--enable-debug],
91                               [Add -g to other command line arguments])],,enable_debug=no)
93 ### IA32 assembly code
94 AC_ARG_ENABLE(ia32_sse,
95               [AC_HELP_STRING([--disable-ia32-sse],
96                               [Don't build SSE/SSE2 assembly loops on ia32])],,enable_ia32_sse=yes)
98 case "${host_cpu}-${host_vendor}" in
99    i?86-*) ;;
100    *) enable_ia32_sse=no ;;
101 esac
103 ### AMD64 assembly code
104 AC_ARG_ENABLE(x86_64_sse,
105               [AC_HELP_STRING([--disable-x86-64-sse],
106                               [Don't build SSE assembly loops on X86_64])],,enable_x86_64_sse=yes)
107 case "${host_cpu}-${host_vendor}" in
108    x86_64-* | amd64-*) ;;
109    i?86-apple) ;;
110    *) enable_x86_64_sse=no ;;
111 esac
114 ### Altivec on powerpc (motorola)
115 AC_ARG_ENABLE(ppc_altivec,
116               [AC_HELP_STRING([--disable-ppc-altivec],
117                               [Don't build Altivec loops on PowerPC])],,enable_ppc_altivec=undef)
118 # Power3/4/5 running AIX does not support altivec. We identify this with vendor=IBM.
119 # IBM powerpc 970 boxes run linux, and have vendor=unknown.
120 if test "$enable_ppc_altivec" = "undef"; then
121   case "${host_cpu}-${host_vendor}" in
122     ppc*-ibm* | powerpc*-ibm*) enable_ppc_altivec=no ;;
123     ppc*-* | powerpc*-*) enable_ppc_altivec=yes ;; 
124     *) enable_ppc_altivec=no ;;
125   esac
128 ###################################
129 ## Detect buggy version of gcc
130 ###################################
131 AC_ARG_ENABLE(gcc41_check,
132               [AC_HELP_STRING([--disable-gcc41-check],
133                               [Disable the check for buggy gcc 4.1])],,enable_gcc41_check=yes)
137 ### ia64 assembly code
138 AC_ARG_ENABLE(ia64_asm,
139               [AC_HELP_STRING([--enable-ia64-asm],
140                               [Build assembly loops on ia64])],,enable_ia64_asm=no)
141 case "${host_cpu}" in
142    ia64) ;;
143    *) enable_ia64_asm=no ;;
144 esac
147 # IBM Power6-specific optimization
148 AC_ARG_ENABLE(power6,
149              [AC_HELP_STRING([--enable-power6],
150                              [Use IBM Pwr6/PPC440/PPC450-specific F77 kernels])],,enable_power6=no)
151 if test "$enable_power6" = "yes"; then
152   AC_DEFINE(GMX_POWER6,,[Enable IBM Pwr6/PPC440/PPC450-specific F77 kernels])
155 AC_ARG_ENABLE(bluegene,
156               [AC_HELP_STRING([--enable-bluegene],
157                               [Build assembly intrinsics kernels on bluegene])],,enable_bluegene=no)
160 ### Optimize for host cpu version
161 AC_ARG_ENABLE(cpu-optimization,     
162               [AC_HELP_STRING([--disable-cpu-optimization],
163                               [No detection or tuning flags for cpu version])],, enable_cpu_optimization=yes)
166 ### Do software 1/sqrt(x)                                                                                                            
167 AC_ARG_ENABLE(software-invsqrt,
168               [AC_HELP_STRING([--disable-software-invsqrt],
169                               [No software 1/sqrt (disabled on sgi,ibm,ia64)])],,
170 [case "${host_cpu}-${host_os}" in
171   mips*-irix* | rs6000*-aix* | powerpc*-aix | ia64*-*) enable_software_invsqrt=no ;;
172   *) enable_software_invsqrt=yes ;;
173 esac])
174 if test "$enable_software_invsqrt" = "yes"; then
175   AC_DEFINE(GMX_SOFTWARE_INVSQRT,,[Use the GROMACS sGMX_INTERNAL_XDRsqrt(x)])
176   PKG_CFLAGS="$PKG_CFLAGS -DGMX_SOFTWARE_INVSQRT"
178 AM_CONDITIONAL([GMX_SOFTWARE_INVSQRT],[test "$enable_software_invsqrt" = "yes"])
180 AC_ARG_ENABLE(fahcore,
181               [AC_HELP_STRING([--enable-fahcore],
182                               [Create a library with mdrun functionality])],, enable_fahcore=no)
186 # The four options below used to improve code scheduling, but the newest CPUs can usually rearrange
187 # instructions dynamically at runtime, so they might not make much difference now:
190 AC_ARG_ENABLE(all-static,
191               [AC_HELP_STRING([--enable-all-static],
192                               [Make completely static binaries])],, enable_all_static=no)
193 # Dont add the -all-static flag until after the compiler test.
196 # FFT libraries - only use one...
197 AC_ARG_WITH(fft,
198             [AC_HELP_STRING([--with-fft=@<:@fftw3/fftw2/mkl(>=6.0)/fftpack@:>@],
199                             [FFT library to use. fftw3 is default, fftpack built in.])],,
200                              with_fft=fftw3)
202 AC_ARG_ENABLE(fftw-measure,
203             [AC_HELP_STRING([--disable-fftw-measure],
204                             [Dont optimize FFTs. This produces binary exactly]
205                             [reproducible runs (as the -reprod flag to mdrun),]
206                             [and if you are using FFTW on x86 and specified its]
207                             [--enable-sse/sse2 flag (NOT default in FFTW!) the]
208                             [kernels used are close-to-optimal anyway.])],,
209                              enable_fftw_measure=yes)
212 AC_ARG_ENABLE(threads,
213               [AC_HELP_STRING([--disable-threads],    
214                               [Disable parallel runs using threads])],,enable_threads=yes)
217 ### Use external BLAS/LAPACK libraries if the user wants to.
219 AC_ARG_WITH(external_blas,
220             [AC_HELP_STRING([--with-external-blas],
221                             [Use system BLAS library (add to LIBS). Automatic on OS X.])],,
223 # default action - check if we are on OS X
224 case "${host_vendor}-${host_os}" in
225   apple-darwin*) with_external_blas="yes" ; extra_LDFLAGS="-framework Accelerate" ;;
226   *)             with_external_blas="no"  ;;
227 esac
229 AM_CONDITIONAL([GMX_EXTERNAL_BLAS], [test "$with_external_blas" = "yes"])
232 AC_ARG_WITH(external_lapack,
233             [AC_HELP_STRING([--with-external-lapack],
234                             [Use system LAPACK library (add to LIBS). Automatic on OS X.])],,
236 # default action - check if we are on OS X
237 case "${host_vendor}-${host_os}" in
238   apple-darwin*) with_external_lapack="yes" ; extra_LDFLAGS="-framework Accelerate" ;;
239   *)             with_external_lapack="no"  ;;
240 esac
242 AM_CONDITIONAL([GMX_EXTERNAL_LAPACK], [test "$with_external_lapack" = "yes"])
247 AC_ARG_WITH(qmmm_gaussian,
248               [AC_HELP_STRING([--without-qmmm-gaussian],
249                               [Use modified Gaussian0x for QM-MM (see website)])],,with_qmmm_gaussian=yes)
250 if test "$with_qmmm_gaussian" = "yes"; then
251   AC_DEFINE(GMX_QMMM_GAUSSIAN,,[Use (modified) Gaussian0x for QM-MM calculations])
255 AC_ARG_WITH(qmmm_gamess,
256               [AC_HELP_STRING([--without-qmmm-gamess],
257                               [Use modified Gamess-UK for QM-MM (see website)])],,with_qmmm_gamess=no)
258 if test "$with_qmmm_gamess" = "yes"; then
259   AC_DEFINE(GMX_QMMM_GAMESS,,[Use (modified) Gamess-UK for QM-MM calculations])
263 AC_ARG_WITH(qmmm_mopac,
264               [AC_HELP_STRING([--without-qmmm-mopac],
265                               [Use modified Mopac 7 for QM-MM (see website)])],,with_qmmm_mopac=no)
266 if test "$with_qmmm_mopac" = "yes"; then
267   AC_DEFINE(GMX_QMMM_MOPAC,,[Use (modified) Mopac 7 for QM-MM calculations])
271 AC_ARG_WITH(qmmm_orca,
272               [AC_HELP_STRING([--without-qmmm-orca],
273                               [Use ORCA for QM-MM])],,with_qmmm_orca=no)
274 if test "$with_qmmm_orca"="yes"; then
275   AC_DEFINE(GMX_QMMM_ORCA,,[Use ORCA for QM-MM calculations])
279 AC_ARG_WITH(dlopen,
280             [AC_HELP_STRING([--without-dlopen],
281                             [do not compile with dlopen, needed to read VMD]
282                             [supported file formats])],,with_dlopen=yes)
286 ############################################################
287 # Add some debug info: Who is building, and on what machine?
288 ############################################################
289 AC_DEFINE_UNQUOTED([BUILD_TIME],["`date`"],[Date and time for build])
290 AC_DEFINE_UNQUOTED([BUILD_USER],["`whoami`@`hostname`"],[User doing build])
291 AC_DEFINE_UNQUOTED([BUILD_MACHINE],["`uname -srm`"],[Hardware and OS version for build host])
294 ############################################################
295 # Checks for requirements for version information generation
296 ############################################################
297 generate_version=no
298 if test -d $srcdir/.git ; then
299     AC_CHECK_PROG(have_git, git, yes, no)
300     if test "$have_git" = "yes" ; then
301         AC_MSG_CHECKING(for a recent enough git)
302         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
303             AC_MSG_RESULT(yes)
304             generate_version=yes
305             AC_DEFINE(USE_VERSION_H,,[Use generated version info])
306         else
307             AC_MSG_RESULT(no)
308         fi
309     fi
310     if test "$generate_version" = "no" ; then
311         AC_MSG_WARN([No compatible git version found, won't be able to generate proper development version information.])
312     fi
314 AM_CONDITIONAL([USE_VERSION_H],[test "$generate_version" = "yes"])
317 ############################################################
318 # Checks for programs
319 ############################################################
321 # normally we use the default compiler, but on alpha/linux we try the compaq ones first
322 case "${host_cpu}-${host_os}" in
323   alpha*-linux*)
324     cc_names="ccc cc gcc"
325     f77_names="fort f77 gfortran g77"
326     ;;
327   *) 
328     cc_names="cc icc xlc gcc"
329     f77_names="f77 ifort xlf xlf77 cf77 fl32 gfortran g77 fort77 f90 xlf90 pgf77 cf77 fort fort77 pgf90"
330     ;;
331 esac
332 # the (non-mpi) c compiler, which is also used for programs executed during build stage
333 AC_PROG_CC( $cc_names )
334 # Check for environment variable CC_FOR_BUILD before overwriting it
335 if test -z "$CC_FOR_BUILD"; then
336   CC_FOR_BUILD=$CC
339 if test "$enable_gcc41_check" = "yes"; then
340     if $CC --version 2>&1 | grep 'gcc.* 4\.1' > /dev/null 2>&1; then
341         AC_MSG_ERROR([Uh-oh. Your compilers appears to be GCC version 4.1, which unfortunately produces]
342 [buggy code at high optimimzation levels. It would be a good idea to update or]
343 [use a different compiler. If you are ABSOLUTELY sure what you are doing, you]
344 [can override this check with --disable-gcc41-check.])
345     fi
350 AC_SUBST(CC_FOR_BUILD) 
352 if test "$enable_fortran" = "yes" -o "$enable_power6" = "yes"; then 
353   AC_PROG_F77( $f77_names )
354   if test -z "$F77"; then
355     AC_MSG_ERROR([No fortran compiler found])
356   fi
359 AM_PROG_AS( $CC )
361 # if we are using mpi, also get an MPICC. We cannot set that in the PROG_CC macro
362 # above, since autoconf checks that the created file can be executed. This would
363 # fail on platforms where MPI executables can only be run through a batchqueue.
365 if test "$enable_mpi" = "yes"; then
366   enable_threads="no"
367   AC_CHECK_PROGS(MPICC, mpxlc mpicc mpcc hcc, $CC)
368 # now change the normal cc to the MPI one - see the comment above.
369   CC=$MPICC
370   CXX=$MPICC
371   AC_MSG_CHECKING([whether the MPI cc command works]) # be paranoid
372   AC_TRY_LINK([#include <mpi.h>],[int argc; char **argv; MPI_Init(&argc,&argv);],
373 AC_MSG_RESULT([yes]),AC_MSG_ERROR([Cannot compile and link MPI code with $CC]))
374   AC_DEFINE(GMX_MPI,,[Make a parallel version of GROMACS using MPI])
375   AC_DEFINE(GMX_LIB_MPI,,[Use a real MPI library])
376   PKG_CFLAGS="$PKG_CFLAGS -DGMX_LIB_MPI"
378   if test "$enable_mpi_in_place" = "yes"; then
379     # not all MPIs support MPI_IN_PLACE:
380     AC_MSG_CHECKING([for MPI_IN_PLACE in collective operations])
381     AC_TRY_COMPILE([
382 #include <mpi.h>
383 void test(void)
385     void *buf;
386     MPI_Allreduce(MPI_IN_PLACE, buf, 10, MPI_FLOAT, MPI_SUM, MPI_COMM_WORLD);
388     ],,[
389         AC_MSG_RESULT([yes])
390         AC_DEFINE(MPI_IN_PLACE_EXISTS,[],[MPI_IN_PLACE available for collective operations])
391     ],[
392         AC_MSG_RESULT([no])
393     ]) 
394   fi
396 # on the cray xt3 we have to tell autoconf that we 
397 # are actually cross-compiling even if the architecture
398 # of host and target are the same. so we enforce 
399 # cross-compilation if __QK_USER__ is defined
400   AC_MSG_CHECKING([for catamount])
401   AC_TRY_COMPILE([
402 #if defined __QK_USER__
403 #else
404 #error not catamount
405 #endif
406 ],,[
407   AC_MSG_RESULT([yes])
408   cross_compiling=yes 
409   AC_DEFINE(GMX_CRAY_XT3,[],[Enable special hacks for Cray XT3])
410   PKG_CFLAGS="$PKG_CFLAGS -DGMX_CRAY_XT3"
411   AC_DEFINE(GMX_NO_SYSTEM,[],[Ignore calls to system(3)])
412   AC_DEFINE(GMX_NO_NICE,[],[Ignore calls to nice(3)])
413   AC_DEFINE(GMX_BROKEN_CALLOC,[],[Don't use calloc(3)])
414   extra_LDFLAGS="$extra_LDFLAGS -lgmalloc -lacml"
416   AC_MSG_RESULT([no])
418 # end of "$enable_mpi" = "yes"
422 AH_TEMPLATE([F77_OR_C_FUNC],
423             [Set to F77_FUNC(name,NAME) if Fortran used, otherwise 'name' for C.])
424 AH_TEMPLATE([F77_OR_C_FUNC_],
425             [Set to F77_FUNC_(name,NAME) if Fortran used, otherwise 'name' for C.])
429 if test "$enable_fortran" = "yes" -o "$enable_power6" = "yes"; then
430   AC_F77_LIBRARY_LDFLAGS
431   AC_F77_WRAPPERS
432   AC_DEFINE([F77_OR_C_FUNC(name,NAME)],[F77_FUNC(name,NAME)])
433   AC_DEFINE([F77_OR_C_FUNC_(name,NAME)],[F77_FUNC_(name,NAME)])
434 else
435   AC_DEFINE([F77_OR_C_FUNC(name,NAME)],[name])
436   AC_DEFINE([F77_OR_C_FUNC_(name,NAME)],[name])
441 AC_PROG_CPP
442 # Needed by libtool scripts?
443 AC_PROG_EGREP
444 AC_PROG_LN_S
446 if test "$enable_cpu_optimization" = "yes"; then
447   ACX_DETECT_GMXCPU
448 else
449   gmxcpu=""
451 ACX_COMPILER_MAXOPT
454 # We've postponed the threads check because we need to check with the right
455 # compilers/flags
456 SAVED_LIBS="$LIBS"
457 if test "$enable_threads" = "yes"; then 
458   if test "$enable_mpi" = "yes"; then
459     AC_MSG_ERROR([Cannot use both threads and MPI - yet.])
460   fi
461   if test "$with_fft" = "fftw2"; then
462     AC_MSG_ERROR([fftw2 can't be used with threads. Use fftw3 or mkl.])
463   fi 
464   AC_CHECK_HEADERS(unistd.h)
465   AC_CHECK_HEADERS(sys/time.h)
466   AC_CHECK_HEADERS(sched.h)
467   AC_CHECK_FUNCS(sysconf)
469   # for now we just assume pthreads
470   ACX_PTHREAD(,AC_MSG_ERROR([Cannot find POSIX threads - required for thread support using configure!]))
471   LIBS="$PTHREAD_LIBS $LIBS"
472   CFLAGS="$CFLAGS $PTHREAD_CFLAGS -I$srcdir/include"
473   CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS -I$srcdir/include"
474   CC="$PTHREAD_CC "
475   AC_DEFINE(THREAD_PTHREADS,,[Use pthreads for multithreading])
477   # profiling
478   AC_ARG_ENABLE(tmpi-profiling,
479               [AC_HELP_STRING([--enable-tmpi-profiling],
480               [Enables profiling of thread_mpi calls and wait times])],,
481               enable_tmpi_profiling=no)
482   if test "x$enable_tmpi_profiling" = "xyes"; then
483     AC_DEFINE(TMPI_PROFILE,,[Enable profiling for call and wait times])
484   fi
486   # check the atomics
487   AC_MSG_CHECKING(if atomic operations are supported)
488   CFLAGS_RET="$CFLAGS"
489   CXXFLAGS_RET="$CXXFLAGS"
490   CFLAGS="$CFLAGS -I$srcdir/include -DTMPI_CHECK_ATOMICS"
491   CXXFLAGS="$CXXFLAGS -I$srcdir/include -DTMPI_CHECK_ATOMICS"
492   # this sets a variable 'tmpi_atomics' to 'yes' if there are atomics. 
493   AC_COMPILE_IFELSE([#include "thread_mpi/atomic.h" ],
494                       [AC_MSG_RESULT(yes); tmpi_atomics=yes],
495                       [AC_MSG_WARN(
496 [No atomics.
498 This compiler+CPU combination doesn't have working atomics.
499 Thread support will be unbearably slow: disable threads.
501 Atomics should work on all but the most obscure CPU+compiler combinations;
502 if your system is not obscure -- like, for example, x86 with gcc --  please
503 contact the developers.
504 ]); tmpi_atomics=no])
505   CFLAGS="$CFLAGS_RET"
506   CXXFLAGS="$CXXFLAGS_RET"
508   AC_DEFINE(GMX_THREADS,,[Use threads for parallelization])
509   PKG_CFLAGS="$PKG_CFLAGS -DGMX_THREADS"
510   AC_DEFINE(GMX_MPI,,[Make a parallel version of GROMACS using MPI])
511   AM_CONDITIONAL(THREAD_PARALLEL,true)
512 else
513   AM_CONDITIONAL(THREAD_PARALLEL,false)
515 LIBS="$SAVED_LIBS"
519 #############
520 # Check integer endian
521 #############
522 AC_C_BIGENDIAN([AC_DEFINE([GMX_INTEGER_BIG_ENDIAN],,[Integer byte order is big endian.])],[],[
523 AC_MSG_ERROR([Cannot determine endian in compiled output])])
524 # Little endian implied if GMX_INTEGER_BIG_ENDIAN not defined in source.
526 #############
527 # Make sure size_t can hold pointers.
528 # On some Nec machines, you reportedly need to specify a flag for size_t to be 64 bits wide.
529 #############
530 AC_MSG_CHECKING([that size_t can hold pointers])
531 AC_TRY_COMPILE([
532 #include <stdlib.h>
533 #include <stddef.h>
534 ],[int chk[sizeof(size_t)-sizeof(int *)+1];],AC_MSG_RESULT([yes]),[
535    AC_MSG_ERROR([size_t is smaller than int*. Check if your compiler needs a flag to make it 64 bit.])])
538 #############
539 # Check that SIGUSR1 is defined
540 #############
541 AC_MSG_CHECKING([for SIGUSR1])
542 AC_TRY_COMPILE([#include <signal.h>],[int i=SIGUSR1;],[
543 AC_MSG_RESULT([yes])
544 AC_DEFINE(HAVE_SIGUSR1,,[SIGUSR1 supported and defined])
545 ],AC_MSG_RESULT([no]))
547 #############
548 # Check if pipes are supported
549 #############
550 AC_MSG_CHECKING([for pipes])
551 AC_TRY_COMPILE([#include <stdio.h>],[
552 FILE *pipe=popen("/tmp/pipe","r");
554 AC_MSG_RESULT([yes])
555 AC_DEFINE(HAVE_PIPES,,[Pipes (popen/pclose) supported])
556 ],AC_MSG_RESULT([no]))
560 #############
561 # Check floating-point format and endian
562 #############
563 ACX_FLOAT_FORMAT
566 AC_PROG_INSTALL
567 AC_PROG_LN_S
568 AC_PROG_MAKE_SET
569 AC_LIBTOOL_WIN32_DLL
570 AC_PROG_LIBTOOL
571 AC_SYS_LARGEFILE
573 # Use our own version of AC_FUNC_FSEEKO from autoconf 2.63 instead
574 # of the broken one we might get from autoconf 2.61.
575 ACX_FUNC_FSEEKO_FIXED
580 ############################################################################
581 # Checks for libraries.
582 ############################################################################
584 # Don't add math library for intel compilers
585 if $CC -V 2>&1 | grep 'Intel Corporation' > /dev/null 2>&1; then
586   AC_MSG_NOTICE([Using built-in math library with intel compiler])
587 else
588   AC_CHECK_LIB(m,sqrt,,AC_MSG_ERROR([No math library found]))
591 #####
592 # Disable MASS support for now.
593 #####
595 #save current LIBS
596 SAVED_LIBS="$LIBS"
598 #set empty defaults
599 PKG_FFT=""
600 FFT_LIBS=""
601 case "$with_fft" in
602 fftw2)
603   if test "$enable_float" = "yes"; then
604     sizeof_real=4
605   else
606     sizeof_real=8
607   fi
608   ACX_CHECK_FFTW2(fftw,$sizeof_real)
609   ACX_CHECK_FFTW2(rfftw,$sizeof_real)
610   FFT_LIBS="-lfftw -lrfftw"
612   case ${ac_fftw_savedprefix} in
613    d) AC_DEFINE(FFTW2_NAME_DFFTW,,[Use the d prefix on fftw2 includes]) ;;
614    s) AC_DEFINE(FFTW2_NAME_SFFTW,,[Use the s prefix on fftw2 includes]) ;;
615    *) AC_DEFINE(FFTW2_NAME_FFTW,,[Dont use any prefix on fftw2 includes]) ;;
616   esac
618   AC_DEFINE(GMX_FFT_FFTW2,,[Use FFTW2 FFT library])
620   ;; #  end of fftw2 check
622 fftw3) # Much simpler check than fftw2
623 # Check for header <fftw3.h> AC_CHECK_HEADERS doesnt work, since we must
624 # use mpicc to get includes - cpp isnt always the same compiler.
625 AC_MSG_CHECKING([for fftw3.h])
626 AC_TRY_COMPILE([#include<fftw3.h>],,[
627 # ok, look for library file too
628 AC_MSG_RESULT(yes)
629 if test "$enable_float" = "yes"; then
630   AC_CHECK_LIB([fftw3f],main,,AC_MSG_ERROR([Cannot find fftw3f library]))
631   PKG_FFT="fftw3f"
632   FFT_LIBS="-lfftw3f"
633 else
634   AC_CHECK_LIB([fftw3],main,,AC_MSG_ERROR([Cannot find fftw3 library]))
635   PKG_FFT="fftw3"
636   FFT_LIBS="-lfftw3"
638   AC_DEFINE(GMX_FFT_FFTW3,,[Use FFTW3 FFT library])
640 # not ok, echo a warning
641 AC_MSG_ERROR(
642 [Cannot find the default external FFT library (fftw3).
643 Other alternatives are 'fftw2', or 'mkl' for Intel MKL.
644 You are STRONGLY recommended to use one of these - fftw is free.
646 Use CPPFLAGS and LDFLAGS if the library is installed in a 
647 non-standard location. (see FAQ at http://www.gromacs.org)
648                                                           
649 If you dont care about performance you can also specify 'fftpack'
650 to use a slower set of FFTs built into Gromacs. 
651 (Just install FFTW3 unless you really know what you are doing).
654   ;;
656 mkl*)
657 ###########
658 # Intel Math Kernel Library version 6 and later.
659 ##########
660 AC_MSG_CHECKING([for mkl_dfti.h])
661 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.]\
663 ## Check for library
664 #  AC_CHECK_LIB([guide],main,,AC_MSG_ERROR([Cannot find libguide (Intel MKL)]))
665 #  AC_CHECK_LIB([mkl],DftiComputeForward,,
666 #    AC_MSG_ERROR([Cannot find Intel Math Kernel Library >= 6.0]))
667   # first check for older MKLs
668   AC_CHECK_LIB([mkl],DftiComputeForward,,[have_mkl="no"])
669   if test "$have_mkl" = "no"; then
670     # we assume it's a new MKL
671     LIBS="$LIBS -liomp5 -lmkl_sequential -lmkl_core"
672     LMKL=" -liomp5 -lmkl_sequential -lmkl_core"
673     AC_CHECK_LIB([mkl_intel_lp64],DftiComputeForward,,[have_mkl10_64="no"])
674     FFT_LIBS="$LMKL -lmkl_intel_lp64"
675     if test "$have_mkl10_64" = "no"; then
676       AC_CHECK_LIB([mkl_intel],DftiComputeForward,,[have_mkl10_32="no"])
677       FFT_LIBS="$LMKL -lmkl_intel"
678       if test "$have_mkl10_32" = "no"; then
679         AC_MSG_ERROR([Cannot find Intel Math Kernel Library >= 6.0])
680       fi
681     fi
682   fi
683   AC_DEFINE(GMX_FFT_MKL,,[Use Intel MKL FFT library])
684   AC_SUBST(LMKL)
685   ;;
687 fftpack | no)
688   AC_MSG_WARN([The built-in FFTPACK routines are slow.
689 Are you sure you don't want to use FFTW? It is free and much faster...])
690   AC_DEFINE(GMX_FFT_FFTPACK,,[Use Built-in FFTPACK FFT library])
691   ;;
693   AC_MSG_ERROR([Unknown FFT library])
694   ;;
695 esac
696 #restore LIBS from before fft check
697 LIBS="$SAVED_LIBS"
699 #only fftw3 has support for pkg-config
700 AC_SUBST(PKG_FFT)
701 if test -z "${PKG_FFT}"; then
702   AC_SUBST(PKG_FFT_LIBS,"$FFT_LIBS")
703 else
704   AC_SUBST(PKG_FFT_LIBS,"")
706 #flag for Makefile
707 AC_SUBST(FFT_LIBS)
709 if test "$enable_fftw_measure" != "yes"; then
710    AC_DEFINE(GMX_DISABLE_FFTW_MEASURE,,[Do not optimize FFTW setups (not needed with SSE FFT kernels)])
713 ######
714 # check for xtc headers
715 case "${host_os}" in
716 cygwin* | mingw*)   # use our own xdr stuff for cygwin/mingw
717   ;;
719   AC_CHECK_HEADERS([rpc/rpc.h])
720   AC_CHECK_HEADERS([rpc/xdr.h],,,
721 [#if HAVE_RPC_RPC_H
722 # include <rpc/rpc.h>
723 #endif
725   AC_CHECK_LIB(nsl,xdr_float)
726   AC_TRY_LINK([
727 #if HAVE_RPC_RPC_H
728 #include<rpc/rpc.h> 
729 #else
730 #error NO rpc.h header
731 #endif
732 #if HAVE_RPC_XDR_H
733 #include<rpc/xdr.h>
734 #else
735 #error No xdr.h header
736 #endif
737 ],[ XDR *xd; float f; xdr_float(xd,&f);],[have_xdr="yes"])
739   if test "$have_xdr" != "yes"; then
740     AC_DEFINE(GMX_INTERNAL_XDR,,[Use our own instead of system XDR libraries])  
741     PKG_CFLAGS="$PKG_CFLAGS -DGMX_INTERNAL_XDR"
742     AC_MSG_WARN([Couldn't find XDR headers and/or libraries - using our own])
743   fi
744   ;;
745 esac
748 ########################################################################
749 # Checks for header files and types
750 ########################################################################
752 AC_CHECK_HEADERS([limits.h unistd.h],,AC_MSG_ERROR([Include headers not found]))
753 AC_CHECK_HEADERS(unistd.h)
754 AC_CHECK_HEADERS(sys/types.h)
755 AC_CHECK_HEADERS(sys/time.h)
756 AC_CHECK_HEADERS(dirent.h,,[AC_MSG_WARN(
758 ********************************************************************
759 * WARNING! We could not find the header file dirent.h              *
760 *                                                                  *
761 * Without this header, we will not be able to scan directories for *
762 * files, which completely breaks pdb2gmx. You will still be able   *
763 * to run simulations, but you cannot prepare input data.           *
764 * dirent.h is part of the POSIX 2001-1 standard, and should be     *
765 * present on all UNIX-like systems, CygWin, and MinGW.             *
766 ********************************************************************])])
767 ## NOTE: On native windows we do not use configure.ac
768 AC_CHECK_HEADERS(regex.h,,[AC_MSG_WARN(
769 [No regex.h found.
770 Regular expression matching in selections will be disabled.
771 Selections still work, but the default groups can differ from
772 those obtained with regular expressions enabled.
773 Consider installing the regular expression library from GNU libc.])])
777 #####
778 # Checks for additional and/or optional functions or libraries.
779 #AC_FUNC_MALLOC
780 AC_FUNC_MEMCMP
781 AC_TYPE_SIGNAL
782 AC_TYPE_OFF_T
783 AC_FUNC_VPRINTF
784 AM_WITH_DMALLOC
785 AC_CHECK_FUNCS(strcasecmp)
786 AC_CHECK_FUNCS(strdup)
787 AC_CHECK_FUNCS(gettimeofday)
788 AC_CHECK_FUNCS(cbrt)
789 AC_CHECK_FUNCS(isnan)
790 AC_CHECK_FUNCS(_isnan)
791 AC_CHECK_FUNCS(isfinite)
792 AC_CHECK_FUNCS(_isfinite)
793 AC_CHECK_FUNCS(fsync)
794 AC_CHECK_FUNCS(fileno)
796 # check for bool (must come late, since CFLAGS/includes might affect it)
797 AC_CHECK_TYPES([bool])
798 AC_SEARCH_LIBS(posix_memalign, c, AC_DEFINE(HAVE_POSIX_MEMALIGN, 1, Define to 1 if you have the posix_memalign function))
799 AC_SEARCH_LIBS(memalign, c, AC_DEFINE(HAVE_MEMALIGN, 1, Define to 1 if you have the memalign function))
800 AC_CHECK_FUNCS(_aligned_malloc)
801 #AC_SEARCH_LIBS(_aligned_malloc, c, AC_DEFINE(HAVE__ALIGNED_MALLOC, 1, Define to 1 if you have the _aligned_malloc function))
808 #############
809 # Check integer sizes, set to zero if e.g. long long is not supported.
810 # (Note: this must come *after* type checks for the corresponding types!)
811 #############
812 AC_CHECK_SIZEOF(int)
813 AC_CHECK_SIZEOF(long int)
814 AC_CHECK_SIZEOF(long long int)
815 AC_CHECK_SIZEOF(off_t)
816 AC_CHECK_SIZEOF(void*)
820 # Apple OS X is a bit strange/braindead in that it always reports itself as i386, both for
821 # 32 and 64 bit builds (even with the 64 bit kernel!).
823 # To get the SSE support right we check for the size of void * that we detected above...
824 case "${host_vendor}-${host_os}" in
825   apple-darwin*)
826   if test $ac_cv_sizeof_voidp = 8; then
827      enable_ia32_sse=no;
828   else
829      enable_x86_64_sse=no;
830   fi
831   ;;
832   *) ;;
833 esac
838 #####
839 # Look for X
840 AC_PATH_XTRA
841 if test "$no_x" != "yes"; then
842   AM_CONDITIONAL(USE_X11,true)
843 else
844   AM_CONDITIONAL(USE_X11,false)
847 # GNU Scientific Library or not
848 AC_ARG_WITH(gsl,
849  [AC_HELP_STRING([--with-gsl],[Link to the GNU scientific library, ]
850                  [enables extra functions in analysis])],,with_gsl=no)
852 ######
853 PKG_GSL=""
854 GSL_LIBS=""
855 if test "$with_gsl" = "yes"; then
856   SAVED_LIBS="$LIBS"
857   AC_CHECK_HEADERS([gsl/gsl_version.h],[
858 # header found, check for libraries 
859   AC_CHECK_LIB(gslcblas,main,[
860 # gslcblas library found, check main lib
861   AC_CHECK_LIB(gsl,main,[
862 # everything need for gsl found
863   GSL_LIBS="-lgsl -lgslcblas"
864 #gsl has pkg-config support
865   PKG_GSL="gsl"
866   AC_DEFINE(HAVE_LIBGSL,1,[Do we have libgsl])
867   ],[:],[-lgslcblas])])])
868   LIBS="$SAVED_LIBS"
871 AC_SUBST(PKG_GSL)
872 AC_SUBST(GSL_LIBS)
874 AC_ARG_WITH(xml,
875  [AC_HELP_STRING([--without-xml],[do not link to the xml2 library,] 
876                  [disallows the use of certain file formats])],,with_xml=yes)
878 #########
879 # Check for libxml2, but it is optional, so dont stop
880 # if it isnt there.
881 PKG_XML=""
882 XML_LIBS=""
883 if test "$with_xml" = "yes"; then
884    SAVED_LIBS="$LIBS"
885    ac_save_CPPFLAGS="$CPPFLAGS"
886    CPPFLAGS="$ac_save_CPPFLAGS -I/usr/include/libxml2"
887    AC_CHECK_HEADERS([libxml/parser.h],AC_CHECK_LIB(xml2,main))
888    if test "$ac_cv_lib_xml2_main" = "yes"; then
889      INCLUDES="$INCLUDES -I/usr/include/libxml2"
890      PKG_XML="libxml-2.0"
891      XML_LIBS="-lxml2"
892      if test "$enable_all_static" = "yes"; then
893        LDFLAGS_RET=$LDFLAGS
894        LDFLAGS="-static $LDFLAGS"
895        LIBS_RET="$LIBS"
896        LIBS="$LIBS -lz"
897        AC_MSG_CHECKING(for broken libxml2)
898        AC_TRY_RUN([
899 #include <libxml/parser.h>
900 main() {
901   xmlInitParser();
902   return 0;
904        AC_MSG_RESULT([no]),[AC_MSG_RESULT([yes])
905        AC_MSG_ERROR([Your libxml2 is broken for static linking, recompile it without threads or build gromacs without libxml])],[-lz])
906        LDFLAGS=$LDFLAGS_RET
907        LIBS="$LIBS_RET"
908      fi
909    fi
910 # restore CPPFLAGS
911    CPPFLAGS="$ac_save_CPPFLAGS"
912    LIBS="$SAVED_LIBS"
914 AC_SUBST(PKG_XML)
915 AC_SUBST(XML_LIBS)
917 #### 
918 # And collect the f77 libs to the linker - on Solaris, f77 stuff must go first,
919 # and we need -L/usr/ucblib to find libucb... (stupid OS)
920 # On e.g. ibm the mass libraries must come before -lm... 
921 case "${host_cpu}-${host_os}" in
922   *-solaris*) 
923     LIBS="$FLIBS $LIBS" 
924     LDFLAGS="$LDFLAGS -L/usr/ucblib"
925     ;;
926   *) LIBS="$LIBS $FLIBS" ;;
927 esac
930 # add the Accelerate framework if enabled above.
931 # LDFLAGS might have been set in the CPU optimization, so we cant assign it directly before that.
932 LDFLAGS="$LDFLAGS $extra_LDFLAGS"
939 #####
940 # Checks for typedefs, structures, and compiler characteristics.
941 AC_C_CONST
942 AC_TYPE_SIZE_T
943 AC_STRUCT_TM
944 AC_C_INLINE
945 AC_C_RESTRICT
947 # AC_TYPE_UID_T is broken on Mac OS X, so use generic tests instead
948 AC_CHECK_TYPES([uid_t],[],[AC_DEFINE(uid_t, int, [Define to `int' if <sys/types.h> doesn't define.])],[[#include <sys/types.h>]])
949 AC_CHECK_TYPES([gid_t],[],[AC_DEFINE(gid_t, int, [Define to `int' if <sys/types.h> doesn't define.])],[[#include <sys/types.h>]])
951 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>]])
953     
956 # Test stuff for ia32 and x86_64 assembly, and add objects/libraries.
957 if test "$enable_ia32_sse" = "yes" -o "$enable_x86_64_sse" = "yes"; then
958   AC_MSG_CHECKING([whether your compiler can handle assembly files (*.s)])
960 # Use 64-bit registers (rsp/rbp) on x86_64
962 if test "$enable_x86_64_sse" = "yes"; then
963 cat > conftestasm.s << EOF
964 checkasm:
965         mov     %rsp, %rbp
966         ret
968 else
969 cat > conftestasm.s << EOF
970 checkasm:
971         movl    %esp, %ebp
972         ret
975   if AC_TRY_COMMAND($CC $CFLAGS -c conftestasm.s); then
976     if test -f conftestasm.o; then
977       AC_MSG_RESULT([yes])
978     else
979       AC_MSG_RESULT([no])
980       AC_MSG_ERROR([Upgrade your compiler (or disable assembly loops).])
981     fi
982   else
983     AC_MSG_RESULT([no])
984     AC_MSG_ERROR([Upgrade your compiler (or disable assembly loops).])
985   fi
987 # ok, cc understands assembly.
989 # If we are using double precision we need SSE2
990   if test "$enable_float" = "no"; then
991 #   test SSE2 on ia32:
992     if test "$enable_ia32_sse" = "yes"; then
993       AC_MSG_CHECKING([whether as fully supports ia32 SSE2])
994 cat > conftest.s << EOF
995 checkasm:
996         emms
997         movapd 32(%esi,%edx,8),%xmm4
998         emms
999         ret
1001       if AC_TRY_COMMAND($CC $CFLAGS -c conftest.s); then
1002         AC_MSG_RESULT([yes])
1003       else
1004         AC_MSG_RESULT([no])
1005         AC_MSG_ERROR([Upgrade to a more recent binutils (or disable assembly loops).])
1006       fi
1007       AC_DEFINE([GMX_IA32_SSE2],,[Double-precision SSE2 instructions on ia32])
1008     fi
1009 #   test SSE2 on X86_64:
1010     if test "$enable_x86_64_sse" = "yes"; then
1011       AC_MSG_CHECKING([whether as fully supports X86_64 SSE2])
1012 cat > conftest.s << EOF
1013 checkasm:
1014         emms
1015         movapd 32(%rsi,%rdx,8),%xmm4
1016         emms
1017         ret
1019       if AC_TRY_COMMAND($CC $CFLAGS -c conftest.s); then
1020         AC_MSG_RESULT([yes])
1021       else
1022         AC_MSG_RESULT([no])
1023         AC_MSG_ERROR([Upgrade to a more recent binutils (or disable assembly loops).])
1024       fi
1025       AC_DEFINE([GMX_X86_64_SSE2],,[Double-precision SSE2 instructions on X86_64])
1026     fi
1027   else
1028 # end of double precision testing, now do single.
1029     if test "$enable_ia32_sse" = "yes"; then
1030       AC_MSG_CHECKING([whether as fully supports ia32 SSE])
1031 cat > conftest.s << EOF
1032 checkasm:
1033         emms
1034         movaps 32(%esi,%edx,8),%xmm4
1035         emms
1036         ret
1038       if AC_TRY_COMMAND($CC $CFLAGS -c conftest.s); then
1039         AC_MSG_RESULT([yes])
1040       else
1041         AC_MSG_RESULT([no])
1042         AC_MSG_ERROR([Upgrade to a more recent binutils (or disable assembly loops).])
1043       fi
1044       AC_DEFINE([GMX_IA32_SSE],,[Single-precision SSE instructions on ia32])
1045     fi
1046 #   test SSE2 on X86_64:
1047     if test "$enable_x86_64_sse" = "yes"; then
1048       AC_MSG_CHECKING([whether as fully supports X86_64 SSE instructions])
1049 cat > conftest.s << EOF
1050 checkasm:
1051         emms
1052         movaps 32(%rsi,%rdx,8),%xmm4
1053         emms
1054         ret
1056       if AC_TRY_COMMAND($CC $CFLAGS -c conftest.s); then
1057         AC_MSG_RESULT([yes])
1058       else
1059         AC_MSG_RESULT([no])
1060         AC_MSG_ERROR([Upgrade to a more recent binutils (or disable assembly loops).])
1061       fi
1062       AC_DEFINE([GMX_X86_64_SSE],,[Single-precision SSE instructions on X86_64])
1063     fi
1064   fi
1068 # Test stuff for ia64 assembly
1070 # Nothing to test right now.
1073   
1076 # Test altivec support.
1078 if test "$enable_ppc_altivec" = "yes"; then
1079   if test "$enable_float" = "no"; then
1080     AC_MSG_WARN([PowerPC Altivec loops can only be used in single precision - disabling])
1081     enable_ppc_altivec=no
1082   else 
1083     # On FSF (vanilla) GCC we must include altivec.h, and on apple we 
1084     # should NOT do it after using -faltivec. Go figure...
1085     case "${host_os}" in
1086     darwin*)                            
1087         # do nothing on Apple systems
1088        ;;
1089     *)
1090         AC_CHECK_HEADERS([altivec.h])
1091        ;;
1092     esac
1094     AC_MSG_CHECKING([whether the compiler supports altivec extensions])
1095     AC_TRY_COMPILE([],[
1096 #ifndef __VEC__
1097 choke_me
1098 #endif
1100     AC_MSG_RESULT([yes])
1101     AC_DEFINE([GMX_PPC_ALTIVEC],,[Use PowerPC Altivec inner loops])],[
1102       AC_MSG_RESULT([no])
1103       AC_MSG_WARN([no altivec support found - On recent PowerPC CPUs]
1104 [you can get a huge performance gain by using an altivec-enabled compiler.]
1105 [On OS X, you need GCC>=3.3, or the IBM compilers. If you are using standard]
1106 [GCC, you need at least version 4.0])
1107       enable_ppc_altivec=no])
1108   fi  
1111 if test "$enable_ia64_asm" = "yes"; then
1112   AC_DEFINE(GMX_IA64_ASM,,[Use ia64 assembly tuned for Itanium2])
1113   AC_DEFINE(DISABLE_WATER_NLIST,,[Turn off all water neighborlist optimization])
1114   AC_DEFINE(DISABLE_WATERWATER_NLIST,,[Turn off water-water neighborlist optimization only])
1117 if test "$enable_bluegene" = "yes"; then
1118   AC_DEFINE(GMX_BLUEGENE,,[Use assembly intrinsics kernels for BlueGene])
1121 if test "$enable_fortran" = "yes"; then
1122   AC_DEFINE(GMX_FORTRAN,,[Enable Fortran support])
1126 # Add the appropriate assembly loops 
1128 AM_CONDITIONAL([GMX_IA32_SSE],[test "$enable_ia32_sse" = "yes" -a "$enable_float" = "yes"])
1129 AM_CONDITIONAL([GMX_IA32_SSE2],[test "$enable_ia32_sse" = "yes" -a "$enable_float" = "no"])
1130 AM_CONDITIONAL([GMX_X86_64_SSE],[test "$enable_x86_64_sse" = "yes" -a "$enable_float" = "yes"])
1131 AM_CONDITIONAL([GMX_X86_64_SSE2],[test "$enable_x86_64_sse" = "yes" -a "$enable_float" = "no"])
1132 AM_CONDITIONAL([GMX_FORTRAN],[test "$enable_fortran" = "yes"])
1133 AM_CONDITIONAL([GMX_PPC_ALTIVEC],[test "$enable_ppc_altivec" = "yes" -a "$enable_float" = "yes"])
1134 AM_CONDITIONAL([GMX_IA64_ASM],[test "$enable_ia64_asm" = "yes"])
1135 AM_CONDITIONAL([GMX_BLUEGENE],[test "$enable_bluegene" = "yes"])
1136 AM_CONDITIONAL([GMX_POWER6],[test "$enable_power6" = "yes"])
1139 #############
1140 # Check integer endian
1141 #############
1142 AC_C_BIGENDIAN([AC_DEFINE([GMX_INTEGER_BIG_ENDIAN],,[Integer byte order is big endian.])],[],[
1143 AC_MSG_ERROR([Cannot determine endian in compiled output])])
1144 # Little endian implied if GMX_INTEGER_BIG_ENDIAN not defined in source.
1148 case "${host_cpu}" in
1149    i?86) 
1150          # Check if inline assembly works
1151          AC_MSG_CHECKING(if the compiler supports gcc inline assembly)
1152       AC_TRY_LINK([],[float f;int i; asm("fld %1\nfistpl %0\n" : "=m" (*&i) : "f" (f));],[AC_MSG_RESULT(yes)
1153 AC_DEFINE(GMX_X86_GCC_INLINE_ASM,,[Enable x86 gcc inline assembly])],[AC_MSG_RESULT(no)])
1154          # Check for MSVC inline assembly
1155      AC_MSG_CHECKING(if the compiler supports MSVC inline assembly)
1156       AC_TRY_LINK([],[float f;int i; _asm { fld f } ; _asm { fistpl i };],[AC_MSG_RESULT(yes)
1157 AC_DEFINE(GMX_X86_MSVC_INLINE_ASM,,[Enable x86 MSVC inline assembly])],[AC_MSG_RESULT(no)])
1158         ;;              
1159    *) ;;
1160 esac
1163 ############
1164 # Check dlopen
1165 ###########
1166 if test "$with_dlopen" = "yes"; then
1167       AC_MSG_CHECKING(if dlopen supported)
1168       CFLAGS_RET=$CFLAGS
1169       #LDFLAGS="$lt_cv_dlopen_libs $LDFLAGS" #can't make the macro, which is getting lt_cv_dlopen_libs, to work
1170       LDFLAGS_RET=$LDFLAGS
1171       if test "$enable_all_static" = "yes"; then  #make sure we test also whether it works static
1172          LDFLAGS="$LDFLAGS -static"
1173       fi
1174       CFLAGS="-I$srcdir/include -DGMX_DLOPEN $CFLAGS"
1175       AC_TRY_LINK([#include "$srcdir/src/gmxlib/vmddlopen.c"],,[AC_MSG_RESULT([yes])\
1176         AC_DEFINE(GMX_DLOPEN,,[Compile with dlopen])],AC_MSG_RESULT([no]))
1177       CFLAGS=$CFLAGS_RET
1178       LDFLAGS=$LDFLAGS_RET
1184 ########################################################################
1185 # Final output stage
1186 ########################################################################
1187 AS="$CC"
1188 AC_SUBST(ASFLAGS)
1189 AC_SUBST(AS)
1190 AC_SUBST(INCLUDES)          # should be automatic, but doesnt seem to be?
1192 # To tell libraries apart, we use four versions of the name. For instance, libgmx:
1193 # libgmx                single prec, no mpi.
1194 # libgmx_d              double prec, no mpi.
1195 # libgmx_mpi            single prec, mpi.
1196 # libgmx_mpi_d          double prec, mpi.
1197 # However, the non-suffixed names are linked to the _mpi and/or _d suffixed
1198 # ones upon installation if that is the only version available.
1200 AC_ARG_VAR(
1201   [LIBSUFFIX],
1202   [To tell libraries apart, a suffix can be used. This is normally done
1203    automatically during ./configure (_d|_mpi|_mpi_d). But with this
1204    variable you can overwrite it
1205   ]
1207 if test -z "${LIBSUFFIX}" ; then
1208   if test "$enable_mpi" = "yes"; then
1209     LIBSUFFIX="_mpi"
1210   fi
1211   if test "$enable_float" = "no"; then
1212     LIBSUFFIX="${LIBSUFFIX}_d"
1213   fi
1215 AC_SUBST(LIBSUFFIX)
1217 # Unless the user has explicitly requested a prefix/suffix/transform, we
1218 # use _d on double precision files. Don't add anything for mpi, but at the
1219 # end we tell the user it is possible and smart to do in some cases!
1220 if test "$program_transform_name" = "s,x,x,"; then
1221   name_transform_provided=no;
1222   if test "$enable_float" = "no"; then
1223     program_transform_name="s,\$\$,_d,"
1224   fi
1225 else
1226   name_transform_provided=yes;
1230 # Use a variable for RPM - this way it can be 
1231 # overridden with make RPM=rpm3 rpm
1232 RPM=rpm
1233 AC_SUBST(RPM)
1235 if test "$enable_fahcore" = "yes"; then  
1236   CPPFLAGS="$CPPFLAGS -I\$(top_srcdir)/../corewrap -include swindirect.h -DFULLINDIRECT -DUSE_FAH_XDR"  
1237   if test "$enable_mpi" = "yes"; then 
1238     CFLAGS="$CFLAGS -DMPI"  
1239   fi
1241 AM_CONDITIONAL([GMX_FAHCORE],[test "$enable_fahcore" = "yes"])
1244 if test "$enable_all_static" = "yes"; then
1245   LDFLAGS="$LDFLAGS -all-static"
1248 # we have asm source, so this is necessary for automake 1.6
1249 CCAS=$CC
1250 CCASFLAGS=$CFLAGS
1252 AC_SUBST(CCAS)
1253 AC_SUBST(CCASFLAGS)
1254 AC_SUBST(PKG_CFLAGS)
1256 AC_CONFIG_FILES([ Makefile ])
1257 AC_CONFIG_FILES([ src/Makefile ])
1258 AC_CONFIG_FILES([ src/gmxlib/Makefile ])
1259 AC_CONFIG_FILES([ src/gmxlib/libgmx${LIBSUFFIX}.pc:src/gmxlib/libgmx.pc.in ])
1260 AC_CONFIG_FILES([ src/gmxlib/gmx_blas/Makefile ])
1261 AC_CONFIG_FILES([ src/gmxlib/gmx_lapack/Makefile ])
1262 AC_CONFIG_FILES([ src/gmxlib/selection/Makefile ])
1263 AC_CONFIG_FILES([ src/gmxlib/statistics/Makefile ])
1264 AC_CONFIG_FILES([ src/gmxlib/trajana/Makefile ])
1265 AC_CONFIG_FILES([ src/gmxlib/thread_mpi/Makefile ])
1266 AC_CONFIG_FILES([ src/gmxlib/nonbonded/Makefile ])
1267 AC_CONFIG_FILES([ src/gmxlib/nonbonded/nb_kernel_c/Makefile ])
1268 AC_CONFIG_FILES([ src/gmxlib/nonbonded/nb_kernel_ia32_sse/Makefile ])
1269 AC_CONFIG_FILES([ src/gmxlib/nonbonded/nb_kernel_ia32_sse2/Makefile ])
1270 AC_CONFIG_FILES([ src/gmxlib/nonbonded/nb_kernel_x86_64_sse/Makefile ])
1271 AC_CONFIG_FILES([ src/gmxlib/nonbonded/nb_kernel_x86_64_sse2/Makefile ])
1272 AC_CONFIG_FILES([ src/gmxlib/nonbonded/nb_kernel_ppc_altivec/Makefile ])
1273 AC_CONFIG_FILES([ src/gmxlib/nonbonded/nb_kernel_ia64_single/Makefile ])
1274 AC_CONFIG_FILES([ src/gmxlib/nonbonded/nb_kernel_ia64_double/Makefile ])
1275 AC_CONFIG_FILES([ src/gmxlib/nonbonded/nb_kernel_bluegene/Makefile ])
1276 AC_CONFIG_FILES([ src/gmxlib/nonbonded/nb_kernel_power6/Makefile ])
1277 AC_CONFIG_FILES([ src/gmxlib/nonbonded/nb_kernel_f77_single/Makefile ])
1278 AC_CONFIG_FILES([ src/gmxlib/nonbonded/nb_kernel_f77_double/Makefile ])
1279 AC_CONFIG_FILES([ include/Makefile ])
1280 AC_CONFIG_FILES([ include/types/Makefile ])
1281 AC_CONFIG_FILES([ include/thread_mpi/Makefile ])
1282 AC_CONFIG_FILES([ include/thread_mpi/atomic/Makefile ])
1283 AC_CONFIG_FILES([ src/mdlib/Makefile ])
1284 AC_CONFIG_FILES([ src/mdlib/libmd${LIBSUFFIX}.pc:src/mdlib/libmd.pc.in ])
1285 AC_CONFIG_FILES([ src/kernel/Makefile ])
1286 AC_CONFIG_FILES([ src/kernel/libgmxpreprocess${LIBSUFFIX}.pc:src/kernel/libgmxpreprocess.pc.in ])
1287 AC_CONFIG_FILES([ src/tools/Makefile ])
1288 AC_CONFIG_FILES([ src/tools/libgmxana${LIBSUFFIX}.pc:src/tools/libgmxana.pc.in ])
1289 AC_CONFIG_FILES([ src/ngmx/Makefile ])
1290 AC_CONFIG_FILES([ src/contrib/Makefile ])
1291 AC_CONFIG_FILES([ scripts/Makefile ])
1292 AC_CONFIG_FILES([ admin/Makefile ])
1293 AC_CONFIG_FILES([ share/Makefile ])
1294 AC_CONFIG_FILES([ share/tutor/Makefile ])
1295 AC_CONFIG_FILES([ share/tutor/gmxdemo/Makefile ])
1296 AC_CONFIG_FILES([ share/tutor/nmr1/Makefile ])
1297 AC_CONFIG_FILES([ share/tutor/nmr2/Makefile ])
1298 AC_CONFIG_FILES([ share/tutor/water/Makefile ])
1299 AC_CONFIG_FILES([ share/tutor/mixed/Makefile ])
1300 AC_CONFIG_FILES([ share/tutor/methanol/Makefile ])
1301 AC_CONFIG_FILES([ share/tutor/speptide/Makefile ])
1302 AC_CONFIG_FILES([ share/template/Makefile ])
1303 AC_CONFIG_FILES([ share/top/Makefile ])
1304 AC_CONFIG_FILES([ share/top/gmx.ff/Makefile ])
1305 AC_CONFIG_FILES([ share/top/gmx2.ff/Makefile ])
1306 AC_CONFIG_FILES([ share/top/encadv.ff/Makefile ])
1307 AC_CONFIG_FILES([ share/top/encads.ff/Makefile ])
1308 AC_CONFIG_FILES([ share/top/oplsaa.ff/Makefile ])
1309 AC_CONFIG_FILES([ share/top/gromos43a1.ff/Makefile ])
1310 AC_CONFIG_FILES([ share/top/gromos43a2.ff/Makefile ])
1311 AC_CONFIG_FILES([ share/top/gromos45a3.ff/Makefile ])
1312 AC_CONFIG_FILES([ share/top/gromos53a5.ff/Makefile ])
1313 AC_CONFIG_FILES([ share/top/gromos53a6.ff/Makefile ])
1314 AC_CONFIG_FILES([ share/top/charmm27.ff/Makefile ])
1315 AC_CONFIG_FILES([ share/top/amber94.ff/Makefile ])
1316 AC_CONFIG_FILES([ share/top/amber96.ff/Makefile ])
1317 AC_CONFIG_FILES([ share/top/amberGS.ff/Makefile ])
1318 AC_CONFIG_FILES([ share/top/amber99.ff/Makefile ])
1319 AC_CONFIG_FILES([ share/top/amber99sb.ff/Makefile ])
1320 AC_CONFIG_FILES([ share/top/amber99sb-ildn.ff/Makefile ])
1321 AC_CONFIG_FILES([ share/top/amber03.ff/Makefile ])
1322 AC_CONFIG_FILES([ share/html/Makefile ])
1323 AC_CONFIG_FILES([ share/html/images/Makefile ])
1324 AC_CONFIG_FILES([ share/html/online/Makefile ])
1325 AC_CONFIG_FILES([ man/Makefile man/man1/Makefile man/man7/Makefile ])
1326 AC_CONFIG_FILES([ Doxyfile ])
1327 AC_OUTPUT
1335 #########################################################
1336 # Echo some important info, to avoid stupid mistakes
1339 if test "$enable_float" = "no" -a "$name_transform_provided" = "no"; then
1340   echo ""
1341   echo "* You are compiling a double precision version of Gromacs -"
1342   echo "  program names will be suffixed with _d to avoid overwriting single"
1343   echo "  precision files. You can override it with --program-suffix"
1346 if test "$name_transform_provided" = "no" -a "$enable_mpi" = "yes"; then
1347   echo ""
1348   echo "* Seems you are compiling with MPI support. You can install the MPI-"
1349   echo "  enabled programs with suffixed names to have both MPI and non-MPI"
1350   echo "  versions. This is useful e.g. on supercomputers where you usually"
1351   echo "  cannot run MPI-linked programs on the login node."
1352   echo "  Set a suffix with e.g. --program-suffix=_mpi (or _mpi_d for double)."
1353   echo "  You only need MPI for mdrun, so if you already have non-MPI stuff"
1354   echo "  installed you can issue make mdrun; make install-mdrun."
1355   echo ""
1356   echo "  WARNING:"
1357   echo "  There are known problems with some MPI implementations:"
1358   echo "             OpenMPI version < 1.4.1" 
1359   echo "             MVAPICH2 version <= 1.4.1"
1362 if test "$enable_shared" = "no"; then
1363   echo ""
1364   echo "* On most platforms you can save 10X space with dynamic libraries, although"
1365   echo "  the binaries might be less portable. Why not try --enable-shared ?"
1366 fi  
1369 if test "$tmpi_atomics" = "no"; then
1370   echo ""
1371   echo "* This compiler+CPU combination doesn't have working atomic operations."
1372   echo "  Thread support will be unbearably slow: the default number of threads"
1373   echo "  is set to 1."
1374   echo "  Atomics should work on all but the most obscure CPU+compiler"
1375   echo "  combinations; if your system is not obscure (like, for example, x86"
1376   echo "  with gcc) please contact the developers."
1377   echo ""