Changes to give correct output when running in parallel in vv. Doesen't yet work...
[gromacs/rigid-bodies.git] / configure.ac
bloba50b5dac7e0e52701323a47d13779053f8d3a68b
1 #######################################################################
2 # Process this file wth autoconf to produce a configure script.
3 #######################################################################
4  
5 AC_PREREQ(2.50)
6 AC_INIT(gromacs, 4.0.99_development_20090605, [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="5:0:0"
18 AC_SUBST(SHARED_VERSION_INFO)
20 AC_DISABLE_SHARED
23 #######################################################################
24 # Simple options and makefile variables
25 #######################################################################
28 ### Single/Double
29 AC_ARG_ENABLE(float,
30              [AC_HELP_STRING([--disable-float],
31                              [Use double instead of single precision])],, enable_float=yes)
33 AC_ARG_ENABLE(double,
34              [AC_HELP_STRING([--enable-double],
35                              [Same effect as --disable-float])],, enable_double=no)
36 if test "$enable_double" = "yes"; then
37    enable_float=no;
39 if test "$enable_float" = "no"; then
40   AC_DEFINE(GMX_DOUBLE,,[Compile in double precision])
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 if test "$enable_fortran" = "yes"; then
55   AC_DEFINE(GMX_FORTRAN,,[Enable Fortran support])
57 # Generic fortran kernels will be turned off below if you enable power6-specific optimization!
58 # always use CC for linking:
59 AC_SUBST(F77LINK,"\$(LINK)")
65 ### MPI or not
66 AC_ARG_ENABLE(mpi,
67               [AC_HELP_STRING([--enable-mpi],
68                               [Compile for parallel runs using MPI])],,enable_mpi=no)
71 ### MPI environment
72 AC_ARG_ENABLE(mpi-environment,
73               [AC_HELP_STRING([--enable-mpi-environment=VAR],
74                               [Only start parallel runs when VAR is set])],,
75 [case "${host_cpu}" in
76   mips*-irix*) enable_mpi_environment="MPI_ENVIRONMENT" ;;
77   *) enable_mpi_environment=no ;;
78 esac])
79 if test "$enable_mpi_environment" != "no"; then
80   AC_DEFINE_UNQUOTED(GMX_CHECK_MPI_ENV,"$enable_mpi_environment",[If defined, only start MPI runs when this variable is set])
83 ### MPI_IN_PLACE
84 AC_ARG_ENABLE(mpi-in-place,
85               [AC_HELP_STRING([--disable-mpi-in-place],
86                               [Disable MPI_IN_PLACE. For MPI implementations that have broken support for it (some versions of MPICH, for example).])],, enable_mpi_in_place=yes)
90 AC_ARG_ENABLE(apple_64bit,
91               [AC_HELP_STRING([--enable-apple-64bit],
92                               [Build 64bit binaries for newer Macs])],,enable_apple_64bit=no)
94 AC_ARG_ENABLE(debug,
95               [AC_HELP_STRING([--enable-debug],
96                               [Add -g to other command line arguments])],,enable_debug=no)
98 ### IA32 assembly code
99 AC_ARG_ENABLE(ia32_sse,
100               [AC_HELP_STRING([--disable-ia32-sse],
101                               [Don't build SSE/SSE2 assembly loops on ia32])],,enable_ia32_sse=yes)
102 case "${host_cpu}-${host_vendor}" in
103    i?86-apple)
104       if test "$enable_apple_64bit" = "yes"; then
105         enable_ia32_sse=no;
106       fi
107    ;;
108    i?86-*) ;;
109    *) enable_ia32_sse=no ;;
110 esac
112 ### AMD64 assembly code
113 AC_ARG_ENABLE(x86_64_sse,
114               [AC_HELP_STRING([--disable-x86-64-sse],
115                               [Don't build SSE assembly loops on X86_64])],,enable_x86_64_sse=yes)
116 case "${host_cpu}-${host_vendor}" in
117    x86_64-* | amd64-*) ;;
118    i?86-apple)
119       if test "$enable_apple_64bit" != "yes"; then
120         enable_x86_64_sse=no;
121       fi
122    ;;
123    *) enable_x86_64_sse=no ;;
124 esac
127 ### Altivec on powerpc (motorola)
128 AC_ARG_ENABLE(ppc_altivec,
129               [AC_HELP_STRING([--disable-ppc-altivec],
130                               [Don't build Altivec loops on PowerPC])],,enable_ppc_altivec=undef)
131 # Power3/4/5 running AIX does not support altivec. We identify this with vendor=IBM.
132 # IBM powerpc 970 boxes run linux, and have vendor=unknown.
133 if test "$enable_ppc_altivec" = "undef"; then
134   case "${host_cpu}-${host_vendor}" in
135     ppc*-ibm* | powerpc*-ibm*) enable_ppc_altivec=no ;;
136     ppc*-* | powerpc*-*) enable_ppc_altivec=yes ;; 
137     *) enable_ppc_altivec=no ;;
138   esac
143 ### ia64 assembly code
144 AC_ARG_ENABLE(ia64_asm,
145               [AC_HELP_STRING([--disable-ia64-asm],
146                               [Don't build assembly loops on ia64])],,enable_ia64_asm=yes)
147 case "${host_cpu}" in
148    ia64) ;;
149    *) enable_ia64_asm=no ;;
150 esac
153 # IBM Power6-specific optimization
154 AC_ARG_ENABLE(power6,
155              [AC_HELP_STRING([--enable-power6],
156                              [Use IBM Pwr6/PPC440/PPC450-specific F77 kernels])],,enable_power6=no)
157 # Turn off generic fortran loops if we are using power6-specific optimization
158 if test "$enable_power6" = "yes"; then
159   enable_fortran=no;
162 AC_ARG_ENABLE(bluegene,
163               [AC_HELP_STRING([--enable-bluegene],
164                               [Build assembly intrinsics kernels on bluegene])],,enable_bluegene=no)
167 ### Optimize for host cpu version
168 AC_ARG_ENABLE(cpu-optimization,     
169               [AC_HELP_STRING([--disable-cpu-optimization],
170                               [No detection or tuning flags for cpu version])],, enable_cpu_optimization=yes)
173 ### Do software 1/sqrt(x)                                                                                                            
174 AC_ARG_ENABLE(software-invsqrt,
175               [AC_HELP_STRING([--disable-software-invsqrt],
176                               [No software 1/sqrt (disabled on sgi,ibm,ia64)])],,
177 [case "${host_cpu}-${host_os}" in
178   mips*-irix* | rs6000*-aix* | powerpc*-aix | ia64*-*) enable_software_invsqrt=no ;;
179   *) enable_software_invsqrt=yes ;;
180 esac])
181 if test "$enable_software_invsqrt" = "yes"; then
182   AC_DEFINE(GMX_SOFTWARE_INVSQRT,,[Use the GROMACS software 1/sqrt(x)])
184 AM_CONDITIONAL([GMX_SOFTWARE_INVSQRT],[test "$enable_software_invsqrt" = "yes"])
186 AC_ARG_ENABLE(fahcore,
187               [AC_HELP_STRING([--enable-fahcore],
188                               [Create a library with mdrun functionality])],, enable_fahcore=no)
192 # The four options below used to improve code scheduling, but the newest CPUs can usually rearrange
193 # instructions dynamically at runtime, so they might not make much difference now:
196 AC_ARG_ENABLE(all-static,
197               [AC_HELP_STRING([--enable-all-static],
198                               [Make completely static binaries])],, enable_all_static=no)
199 # Dont add the -all-static flag until after the compiler test.
202 # FFT libraries - only use one...
203 AC_ARG_WITH(fft,
204             [AC_HELP_STRING([--with-fft=@<:@fftw3/fftw2/mkl(>=6.0)/fftpack@:>@],
205                             [FFT library to use. fftw3 is default, fftpack built in.])],,
206                              with_fft=fftw3)
208 AC_ARG_ENABLE(fftw-measure,
209             [AC_HELP_STRING([--disable-fftw-measure],
210                             [Dont optimize FFTs. This produces binary exactly]
211                             [reproducible runs (as the -reprod flag to mdrun),]
212                             [and if you are using FFTW on x86 and specified its]
213                             [--enable-sse/sse2 flag (NOT default in FFTW!) the]
214                             [kernels used are close-to-optimal anyway.])],,
215                              enable_fftw_measure=yes)
218 AC_ARG_ENABLE(threads,
219               [AC_HELP_STRING([--enable-threads],    
220                               [Compile for parallel runs using threads])],,enable_threads=no)
222 # if test "$enable_threads" = "yes"; then
223 #   with_threads=pthreads;
227 ### Use external BLAS/LAPACK libraries if the user wants to.
229 AC_ARG_WITH(external_blas,
230             [AC_HELP_STRING([--with-external-blas],
231                             [Use system BLAS library (add to LIBS). Automatic on OS X.])],,
233 # default action - check if we are on OS X
234 case "${host_vendor}-${host_os}" in
235   apple-darwin*) with_external_blas="yes" ; extra_LDFLAGS="-framework Accelerate" ;;
236   *)             with_external_blas="no"  ;;
237 esac
239 AM_CONDITIONAL([GMX_EXTERNAL_BLAS], [test "$with_external_blas" = "yes"])
242 AC_ARG_WITH(external_lapack,
243             [AC_HELP_STRING([--with-external-lapack],
244                             [Use system LAPACK library (add to LIBS). Automatic on OS X.])],,
246 # default action - check if we are on OS X
247 case "${host_vendor}-${host_os}" in
248   apple-darwin*) with_external_lapack="yes" ; extra_LDFLAGS="-framework Accelerate" ;;
249   *)             with_external_lapack="no"  ;;
250 esac
252 AM_CONDITIONAL([GMX_EXTERNAL_LAPACK], [test "$with_external_lapack" = "yes"])
257 AC_ARG_WITH(qmmm_gaussian,
258               [AC_HELP_STRING([--without-qmmm-gaussian],
259                               [Use modified Gaussian0x for QM-MM (see website)])],,with_qmmm_gaussian=yes)
260 if test "$with_qmmm_gaussian" = "yes"; then
261   AC_DEFINE(GMX_QMMM_GAUSSIAN,,[Use (modified) Gaussian0x for QM-MM calculations])
265 AC_ARG_WITH(qmmm_gamess,
266               [AC_HELP_STRING([--without-qmmm-gamess],
267                               [Use modified Gamess-UK for QM-MM (see website)])],,with_qmmm_gamess=no)
268 if test "$with_qmmm_gamess" = "yes"; then
269   AC_DEFINE(GMX_QMMM_GAMESS,,[Use (modified) Gamess-UK for QM-MM calculations])
273 AC_ARG_WITH(qmmm_mopac,
274               [AC_HELP_STRING([--without-qmmm-mopac],
275                               [Use modified Mopac 7 for QM-MM (see website)])],,with_qmmm_mopac=no)
276 if test "$with_qmmm_mopac" = "yes"; then
277   AC_DEFINE(GMX_QMMM_MOPAC,,[Use (modified) Mopac 7 for QM-MM calculations])
279    
281 ############################################################
282 # Add some debug info: Who is building, and on what machine?
283 ############################################################
284 AC_DEFINE_UNQUOTED([BUILD_TIME],["`date`"],[Date and time for build])
285 AC_DEFINE_UNQUOTED([BUILD_USER],["`whoami`@`hostname`"],[User doing build])
286 AC_DEFINE_UNQUOTED([BUILD_MACHINE],["`uname -srm`"],[Hardware and OS version for build host])
290 ############################################################
291 # Checks for programs
292 ############################################################
294 # normally we use the default compiler, but on alpha/linux we try the compaq ones first
295 case "${host_cpu}-${host_os}" in
296   alpha*-linux*)
297     cc_names="ccc cc gcc"
298     f77_names="fort f77 g77"
299     ;;
300   *) 
301     cc_names="cc icc xlc gcc"
302     f77_names="f77 ifort xlf xlf77 cf77 fl32 g77 fort77 f90 xlf90 pgf77 cf77 fort fort77 pgf90"
303     ;;
304 esac
305 # the (non-mpi) c compiler, which is also used for programs executed during build stage
306 AC_PROG_CC( $cc_names )
307 # Check for environment variable CC_FOR_BUILD before overwriting it
308 if test -z "$CC_FOR_BUILD"; then
309   CC_FOR_BUILD=$CC
311 AC_SUBST(CC_FOR_BUILD) 
313 if test "$enable_fortran" = "yes"; then 
314   AC_PROG_F77( $f77_names )
315   if test -z "$F77"; then
316     AC_MSG_ERROR([No fortran compiler found])
317   fi
320 AM_PROG_AS( $CC )
322 # if we are using mpi, also get an MPICC. We cannot set that in the PROG_CC macro
323 # above, since autoconf checks that the created file can be executed. This would
324 # fail on platforms where MPI executables can only be run through a batchqueue.
326 if test "$enable_mpi" = "yes"; then
327   AC_CHECK_PROGS(MPICC, mpxlc mpicc mpcc hcc, $CC)
328 # now change the normal cc to the MPI one - see the comment above.
329   CC=$MPICC
330   AC_MSG_CHECKING([whether the MPI cc command works]) # be paranoid
331   AC_TRY_LINK([#include <mpi.h>],[int argc; char **argv; MPI_Init(&argc,&argv);],
332 AC_MSG_RESULT([yes]),AC_MSG_ERROR([Cannot compile and link MPI code with $CC]))
333   AC_DEFINE(GMX_MPI,,[Make a parallel version of GROMACS using MPI])
334   AC_DEFINE(GMX_LIB_MPI,,[Use a real MPI library])
336   if test "$enable_mpi_in_place" = "yes"; then
337     # not all MPIs support MPI_IN_PLACE:
338     AC_MSG_CHECKING([for MPI_IN_PLACE in collective operations])
339     AC_TRY_COMPILE([
340 #include <mpi.h>
341 void test(void)
343     void *buf;
344     MPI_Allreduce(MPI_IN_PLACE, buf, 10, MPI_FLOAT, MPI_SUM, MPI_COMM_WORLD);
346     ],,[
347         AC_MSG_RESULT([yes])
348         AC_DEFINE(MPI_IN_PLACE_EXISTS,[],[MPI_IN_PLACE available for collective operations])
349     ],[
350         AC_MSG_RESULT([no])
351     ]) 
352   fi
354 # on the cray xt3 we have to tell autoconf that we 
355 # are actually cross-compiling even if the architecture
356 # of host and target are the same. so we enforce 
357 # cross-compilation if __QK_USER__ is defined
358   AC_MSG_CHECKING([for catamount])
359   AC_TRY_COMPILE([
360 #if defined __QK_USER__
361 #else
362 #error not catamount
363 #endif
364 ],,[
365   AC_MSG_RESULT([yes])
366   cross_compiling=yes 
367   AC_DEFINE(GMX_CRAY_XT3,[],[Enable special hacks for Cray XT3])
368   AC_DEFINE(GMX_NO_SYSTEM,[],[Ignore calls to system(3)])
369   AC_DEFINE(GMX_NO_NICE,[],[Ignore calls to nice(3)])
370   AC_DEFINE(GMX_BROKEN_CALLOC,[],[Don't use calloc(3)])
371   extra_LDFLAGS="$extra_LDFLAGS -lgmalloc -lacml"
373   AC_MSG_RESULT([no])
375 # end of "$enable_mpi" = "yes"
379 AH_TEMPLATE([F77_OR_C_FUNC],
380             [Set to F77_FUNC(name,NAME) if Fortran used, otherwise 'name' for C.])
381 AH_TEMPLATE([F77_OR_C_FUNC_],
382             [Set to F77_FUNC_(name,NAME) if Fortran used, otherwise 'name' for C.])
386 if test "$enable_fortran" = "yes"; then
387   AC_F77_LIBRARY_LDFLAGS
388   AC_F77_WRAPPERS
389   AC_DEFINE([F77_OR_C_FUNC(name,NAME)],[F77_FUNC(name,NAME)])
390   AC_DEFINE([F77_OR_C_FUNC_(name,NAME)],[F77_FUNC_(name,NAME)])
391 else
392   AC_DEFINE([F77_OR_C_FUNC(name,NAME)],[name])
393   AC_DEFINE([F77_OR_C_FUNC_(name,NAME)],[name])
398 AC_PROG_CPP
399 # Needed by libtool scripts?
400 AC_PROG_EGREP
402 if test "$enable_cpu_optimization" = "yes"; then
403   ACX_DETECT_GMXCPU
404 else
405   gmxcpu=""
407 ACX_COMPILER_MAXOPT
410 # We've postponed the threads check because we need to check with the right
411 # compilers/flags 
412 if test "$enable_threads" = "yes"; then 
413   if test "$enable_mpi" = "yes"; then
414     AC_MSG_ERROR([Cannot use both threads and MPI - yet.])
415   fi
416   # for now we just assume pthreads
417   ACX_PTHREAD(,AC_MSG_ERROR([Cannot find POSIX threads - required for thread    support using configure!]))
418   LIBS="$PTHREAD_LIBS $LIBS"
419   CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
420   CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS"
421   CC="$PTHREAD_CC "
422   AC_DEFINE(THREAD_PTHREADS,,[Use pthreads for thread_mpi multithreading])
423   AC_DEFINE(GMX_THREADS,,[Use threads for parallelization])
424   AC_DEFINE(GMX_MPI,,[Make a parallel version of GROMACS using MPI])
425   AM_CONDITIONAL(THREAD_PARALLEL,true)
426 else
427   AM_CONDITIONAL(THREAD_PARALLEL,false)
432 #############
433 # Check integer endian
434 #############
435 AC_C_BIGENDIAN([AC_DEFINE([GMX_INTEGER_BIG_ENDIAN],,[Integer byte order is big endian.])],[],[
436 AC_MSG_ERROR([Cannot determine endian in compiled output])])
437 # Little endian implied if GMX_INTEGER_BIG_ENDIAN not defined in source.
439 #############
440 # Make sure size_t can hold pointers.
441 # On some Nec machines, you reportedly need to specify a flag for size_t to be 64 bits wide.
442 #############
443 AC_MSG_CHECKING([that size_t can hold pointers])
444 AC_TRY_COMPILE([
445 #include <stdlib.h>
446 #include <stddef.h>
447 ],[int chk[sizeof(size_t)-sizeof(int *)+1];],AC_MSG_RESULT([yes]),[
448    AC_MSG_ERROR([size_t is smaller than int*. Check if your compiler needs a flag to make it 64 bit.])])
451 #############
452 # Check that SIGUSR1 is defined
453 #############
454 AC_MSG_CHECKING([for SIGUSR1])
455 AC_TRY_COMPILE([#include <signal.h>],[int i=SIGUSR1;],[
456 AC_MSG_RESULT([yes])
457 AC_DEFINE(HAVE_SIGUSR1,,[SIGUSR1 supported and defined])
458 ],AC_MSG_RESULT([no]))
460 #############
461 # Check if pipes are supported
462 #############
463 AC_MSG_CHECKING([for pipes])
464 AC_TRY_COMPILE([#include <stdio.h>],[
465 FILE *pipe=popen("/tmp/pipe","r");
467 AC_MSG_RESULT([yes])
468 AC_DEFINE(HAVE_PIPES,,[Pipes (popen/pclose) supported])
469 ],AC_MSG_RESULT([no]))
473 #############
474 # Check floating-point format and endian
475 #############
476 ACX_FLOAT_FORMAT
479 AC_PROG_INSTALL
480 AC_PROG_LN_S
481 AC_PROG_MAKE_SET
482 AC_LIBTOOL_WIN32_DLL
483 AC_PROG_LIBTOOL
484 AC_SYS_LARGEFILE
486 # Use our own version of AC_FUNC_FSEEKO from autoconf 2.63 instead
487 # of the broken one we might get from autoconf 2.61.
488 ACX_FUNC_FSEEKO_FIXED
493 ############################################################################
494 # Checks for libraries.
495 ############################################################################
497 # Don't add math library for intel compilers
498 if $CC -V 2>&1 | grep 'Intel Corporation' > /dev/null 2>&1; then
499   AC_MSG_NOTICE([Using built-in math library with intel compiler])
500 else
501   AC_CHECK_LIB(m,sqrt,,AC_MSG_ERROR([No math library found]))
504 #####
505 # Disable MASS support for now.
506 #####
509 case "$with_fft" in
510 fftw2)
511   if test "$enable_float" = "yes"; then
512     sizeof_real=4
513   else
514     sizeof_real=8
515   fi
516   ACX_CHECK_FFTW2(fftw,$sizeof_real)
517   ACX_CHECK_FFTW2(rfftw,$sizeof_real)
519   case ${ac_fftw_savedprefix} in
520    d) AC_DEFINE(FFTW2_NAME_DFFTW,,[Use the d prefix on fftw2 includes]) ;;
521    s) AC_DEFINE(FFTW2_NAME_SFFTW,,[Use the s prefix on fftw2 includes]) ;;
522    *) AC_DEFINE(FFTW2_NAME_FFTW,,[Dont use any prefix on fftw2 includes]) ;;
523   esac
525   AC_DEFINE(GMX_FFT_FFTW2,,[Use FFTW2 FFT library])
527   ;; #  end of fftw2 check
529 fftw3) # Much simpler check than fftw2
530 # Check for header <fftw3.h> AC_CHECK_HEADERS doesnt work, since we must
531 # use mpicc to get includes - cpp isnt always the same compiler.
532 AC_MSG_CHECKING([for fftw3.h])
533 AC_TRY_COMPILE([#include<fftw3.h>],,[
534 # ok, look for library file too
535 AC_MSG_RESULT(yes)
536 if test "$enable_float" = "yes"; then
537   AC_CHECK_LIB([fftw3f],main,,AC_MSG_ERROR([Cannot find fftw3f library]))
538 else
539   AC_CHECK_LIB([fftw3],main,,AC_MSG_ERROR([Cannot find fftw3 library]))
541   AC_DEFINE(GMX_FFT_FFTW3,,[Use FFTW3 FFT library])
543 # not ok, echo a warning
544 AC_MSG_ERROR(
545 [Cannot find the default external FFT library (fftw3).
546 Other alternatives are 'fftw2', or 'mkl' for Intel MKL.
547 You are STRONGLY recommended to use one of these - fftw is free.
549 Use CPPFLAGS and LDFLAGS if the library is installed in a 
550 non-standard location. (see FAQ at http://www.gromacs.org)
551                                                           
552 If you dont care about performance you can also specify 'fftpack'
553 to use a slower set of FFTs built into Gromacs. 
554 (Just install FFTW3 unless you really know what you are doing).
557   ;;
559 mkl*)
560 ###########
561 # Intel Math Kernel Library version 6 and later.
562 ##########
563 AC_MSG_CHECKING([for mkl_dfti.h])
564 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.]\
566 ## Check for library
567 #  AC_CHECK_LIB([guide],main,,AC_MSG_ERROR([Cannot find libguide (Intel MKL)]))
568   AC_CHECK_LIB([mkl],DftiComputeForward,,
569     AC_MSG_ERROR([Cannot find Intel Math Kernel Library >= 6.0]))
571   AC_DEFINE(GMX_FFT_MKL,,[Use Intel MKL FFT library])
572   ;;
574 fftpack | no)
575   AC_MSG_WARN([The built-in FFTPACK routines are slow.
576 Are you sure you don't want to use FFTW? It is free and much faster...])
577   AC_DEFINE(GMX_FFT_FFTPACK,,[Use Built-in FFTPACK FFT library])
578   ;;
580   AC_MSG_ERROR([Unknown FFT library])
581   ;;
582 esac
585 if test "$enable_fftw_measure" != "yes"; then
586    AC_DEFINE(GMX_DISABLE_FFTW_MEASURE,,[Do not optimize FFTW setups (not needed with SSE FFT kernels)])
589 ######
590 # check for xtc headers
591 case "${host_os}" in
592 cygwin* | mingw*)   # use our own xdr stuff for cygwin/mingw
593   ;;
595   AC_CHECK_HEADERS([rpc/rpc.h])
596   AC_CHECK_HEADERS([rpc/xdr.h],,,
597 [#if HAVE_RPC_RPC_H
598 # include <rpc/rpc.h>
599 #endif
601   AC_CHECK_LIB(nsl,xdr_float)
602   AC_TRY_LINK([
603 #if HAVE_RPC_RPC_H
604 #include<rpc/rpc.h> 
605 #else
606 #error NO rpc.h header
607 #endif
608 #if HAVE_RPC_XDR_H
609 #include<rpc/xdr.h>
610 #else
611 #error No xdr.h header
612 #endif
613 ],[ XDR *xd; float f; xdr_float(xd,&f);],[have_xdr="yes"])
615   if test "$have_xdr" != "yes"; then
616     AC_DEFINE(GMX_INTERNAL_XDR,,[Use our own instead of system XDR libraries])  
617     AC_MSG_WARN([Couldn't find XDR headers and/or libraries - using our own])
618   fi
619   ;;
620 esac
623 ########################################################################
624 # Checks for header files and types
625 ########################################################################
627 AC_CHECK_HEADERS([limits.h unistd.h],,AC_MSG_ERROR([Include headers not found]))
628 AC_CHECK_HEADERS(unistd.h)
629 AC_CHECK_HEADERS(sys/types.h)
630 AC_CHECK_HEADERS(sys/time.h)
632 #####
633 # Checks for additional and/or optional functions or libraries.
634 #AC_FUNC_MALLOC
635 AC_FUNC_MEMCMP
636 AC_TYPE_SIGNAL
637 AC_TYPE_OFF_T
638 AC_FUNC_VPRINTF
639 AM_WITH_DMALLOC
640 AC_CHECK_FUNCS(strcasecmp)
641 AC_CHECK_FUNCS(strdup)
642 AC_CHECK_FUNCS(gettimeofday)
643 AC_CHECK_FUNCS(isnan)
644 AC_CHECK_FUNCS(_isnan)
646 # check for bool (must come late, since CFLAGS/includes might affect it)
647 AC_CHECK_TYPES([bool])
653 #############
654 # Check integer sizes, set to zero if e.g. long long is not supported.
655 # (Note: this must come *after* type checks for the corresponding types!)
656 #############
657 AC_CHECK_SIZEOF(int)
658 AC_CHECK_SIZEOF(long int)
659 AC_CHECK_SIZEOF(long long int)
660 AC_CHECK_SIZEOF(off_t)
661 AC_CHECK_SIZEOF(void*)
665 #####
666 # Look for X
667 AC_PATH_XTRA
668 if test "$no_x" != "yes"; then
669   LIBS="$X_LIBS $LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS"
670   INCLUDES="$INCLUDES $X_CFLAGS"
671   AM_CONDITIONAL(USE_X11,true)
672 else
673   AM_CONDITIONAL(USE_X11,false)
676 # GNU Scientific Library or not
677 AC_ARG_WITH(gsl,
678  [  --with-gsl                    Link to the GNU scientific library, enables extra functions in analysis],,with_gsl=no)
680 ######
681 if test "$with_gsl" = "yes"; then
682   ac_save_LDFLAGS="$LDFLAGS"
683   AC_CHECK_HEADERS([gsl/gsl_version.h],[
684 # header found, check for libraries 
685   AC_CHECK_LIB(gslcblas,main,[
686   LDFLAGS="$ac_save_LDFLAGS -lgslcblas"
687 # gslcblas library found, check main lib
688   AC_CHECK_LIB(gsl,main)])])
693 AC_ARG_WITH(xml,
694  [  --without-xml                 do not link to the xml2 library, disallows the use of certain file formats],,with_xml=yes)
696 #########
697 # Check for libxml2, but it is optional, so dont stop
698 # if it isnt there.
699 if test "$with_xml" = "yes"; then
700    ac_save_CPPFLAGS="$CPPFLAGS"
701    CPPFLAGS="$ac_save_CPPFLAGS -I/usr/include/libxml2"
702    AC_CHECK_HEADERS([libxml/parser.h],AC_CHECK_LIB(xml2,main))
703    if test "$ac_cv_lib_xml2_main" = "yes"; then
704      INCLUDES="$INCLUDES -I/usr/include/libxml2"
705    fi
706 # restore CPPFLAGS
707    CPPFLAGS="$ac_save_CPPFLAGS"
710 #### 
711 # And collect the f77 libs to the linker - on Solaris, f77 stuff must go first,
712 # and we need -L/usr/ucblib to find libucb... (stupid OS)
713 # On e.g. ibm the mass libraries must come before -lm... 
714 case "${host_cpu}-${host_os}" in
715   *-solaris*) 
716     LIBS="$FLIBS $LIBS" 
717     LDFLAGS="$LDFLAGS -L/usr/ucblib"
718     ;;
719   *) LIBS="$LIBS $FLIBS" ;;
720 esac
723 # add the Accelerate framework if enabled above.
724 # LDFLAGS might have been set in the CPU optimization, so we cant assign it directly before that.
725 LDFLAGS="$LDFLAGS $extra_LDFLAGS"
732 #####
733 # Checks for typedefs, structures, and compiler characteristics.
734 AC_C_CONST
735 AC_TYPE_SIZE_T
736 AC_STRUCT_TM
737 AC_C_INLINE
739 # AC_TYPE_UID_T is broken on Mac OS X, so use generic tests instead
740 AC_CHECK_TYPES([uid_t],[],[AC_DEFINE(uid_t, int, [Define to `int' if <sys/types.h> doesn't define.])],[[#include <sys/types.h>]])
741 AC_CHECK_TYPES([gid_t],[],[AC_DEFINE(gid_t, int, [Define to `int' if <sys/types.h> doesn't define.])],[[#include <sys/types.h>]])
742     
744 # Test stuff for ia32 and x86_64 assembly, and add objects/libraries.
745 if test "$enable_ia32_sse" = "yes" -o "$enable_x86_64_sse" = "yes"; then
746   AC_MSG_CHECKING([whether your compiler can handle assembly files (*.s)])
748 # Use 64-bit registers (rsp/rbp) on x86_64
750 if test "$enable_x86_64_sse" = "yes"; then
751 cat > conftestasm.s << EOF
752 checkasm:
753         mov     %rsp, %rbp
754         ret
756 else
757 cat > conftestasm.s << EOF
758 checkasm:
759         movl    %esp, %ebp
760         ret
763   if AC_TRY_COMMAND($CC $CFLAGS -c conftestasm.s); then
764     if test -f conftestasm.o; then
765       AC_MSG_RESULT([yes])
766     else
767       AC_MSG_RESULT([no])
768       AC_MSG_ERROR([Upgrade your compiler (or disable assembly loops).])
769     fi
770   else
771     AC_MSG_RESULT([no])
772     AC_MSG_ERROR([Upgrade your compiler (or disable assembly loops).])
773   fi
775 # ok, cc understands assembly.
777 # If we are using double precision we need SSE2
778   if test "$enable_float" = "no"; then
779 #   test SSE2 on ia32:
780     if test "$enable_ia32_sse" = "yes"; then
781       AC_MSG_CHECKING([whether as fully supports ia32 SSE2])
782 cat > conftest.s << EOF
783 checkasm:
784         emms
785         movapd 32(%esi,%edx,8),%xmm4
786         emms
787         ret
789       if AC_TRY_COMMAND($CC $CFLAGS -c conftest.s); then
790         AC_MSG_RESULT([yes])
791       else
792         AC_MSG_RESULT([no])
793         AC_MSG_ERROR([Upgrade to a more recent binutils (or disable assembly loops).])
794       fi
795       AC_DEFINE([GMX_IA32_SSE2],,[Double-precision SSE2 instructions on ia32])
796     fi
797 #   test SSE2 on X86_64:
798     if test "$enable_x86_64_sse" = "yes"; then
799       AC_MSG_CHECKING([whether as fully supports X86_64 SSE2])
800 cat > conftest.s << EOF
801 checkasm:
802         emms
803         movapd 32(%rsi,%rdx,8),%xmm4
804         emms
805         ret
807       if AC_TRY_COMMAND($CC $CFLAGS -c conftest.s); then
808         AC_MSG_RESULT([yes])
809       else
810         AC_MSG_RESULT([no])
811         AC_MSG_ERROR([Upgrade to a more recent binutils (or disable assembly loops).])
812       fi
813       AC_DEFINE([GMX_X86_64_SSE2],,[Double-precision SSE2 instructions on X86_64])
814     fi
815   else
816 # end of double precision testing, now do single.
817     if test "$enable_ia32_sse" = "yes"; then
818       AC_MSG_CHECKING([whether as fully supports ia32 SSE])
819 cat > conftest.s << EOF
820 checkasm:
821         emms
822         movaps 32(%esi,%edx,8),%xmm4
823         emms
824         ret
826       if AC_TRY_COMMAND($CC $CFLAGS -c conftest.s); then
827         AC_MSG_RESULT([yes])
828       else
829         AC_MSG_RESULT([no])
830         AC_MSG_ERROR([Upgrade to a more recent binutils (or disable assembly loops).])
831       fi
832       AC_DEFINE([GMX_IA32_SSE],,[Single-precision SSE instructions on ia32])
833     fi
834 #   test SSE2 on X86_64:
835     if test "$enable_x86_64_sse" = "yes"; then
836       AC_MSG_CHECKING([whether as fully supports X86_64 SSE instructions])
837 cat > conftest.s << EOF
838 checkasm:
839         emms
840         movaps 32(%rsi,%rdx,8),%xmm4
841         emms
842         ret
844       if AC_TRY_COMMAND($CC $CFLAGS -c conftest.s); then
845         AC_MSG_RESULT([yes])
846       else
847         AC_MSG_RESULT([no])
848         AC_MSG_ERROR([Upgrade to a more recent binutils (or disable assembly loops).])
849       fi
850       AC_DEFINE([GMX_X86_64_SSE],,[Single-precision SSE instructions on X86_64])
851     fi
852   fi
856 # Test stuff for ia64 assembly
858 # Nothing to test right now.
862 # Test altivec support.
864 if test "$enable_ppc_altivec" = "yes"; then
865   if test "$enable_float" = "no"; then
866     AC_MSG_WARN([PowerPC Altivec loops can only be used in single precision - disabling])
867     enable_ppc_altivec=no
868   else 
869     # On FSF (vanilla) GCC we must include altivec.h, and on apple we 
870     # should NOT do it after using -faltivec. Go figure...
871     case "${host_os}" in
872     darwin*)                            
873         # do nothing on Apple systems
874        ;;
875     *)
876         AC_CHECK_HEADERS([altivec.h])
877        ;;
878     esac
880     AC_MSG_CHECKING([whether the compiler supports altivec extensions])
881     AC_TRY_COMPILE([],[
882 #ifndef __VEC__
883 choke_me
884 #endif
886     AC_MSG_RESULT([yes])
887     AC_DEFINE([GMX_PPC_ALTIVEC],,[Use PowerPC Altivec inner loops])],[
888       AC_MSG_RESULT([no])
889       AC_MSG_WARN([no altivec support found - On recent PowerPC CPUs]
890 [you can get a huge performance gain by using an altivec-enabled compiler.]
891 [On OS X, you need GCC>=3.3, or the IBM compilers. If you are using standard]
892 [GCC, you need at least version 4.0])
893       enable_ppc_altivec=no])
894   fi  
897 if test "$enable_ia64_asm" = "yes"; then
898   AC_DEFINE(GMX_IA64_ASM,,[Use ia64 assembly tuned for Itanium2])
899   AC_DEFINE(DISABLE_WATER_NLIST,,[Turn off all water neighborlist optimization])
900   AC_DEFINE(DISABLE_WATERWATER_NLIST,,[Turn off water-water neighborlist optimization only])
903 if test "$enable_bluegene" = "yes"; then
904   AC_DEFINE(GMX_BLUEGENE,,[Use assembly intrinsics kernels for BlueGene])
908 # Add the appropriate assembly loops 
910 AM_CONDITIONAL([GMX_IA32_SSE],[test "$enable_ia32_sse" = "yes" -a "$enable_float" = "yes"])
911 AM_CONDITIONAL([GMX_IA32_SSE2],[test "$enable_ia32_sse" = "yes" -a "$enable_float" = "no"])
912 AM_CONDITIONAL([GMX_X86_64_SSE],[test "$enable_x86_64_sse" = "yes" -a "$enable_float" = "yes"])
913 AM_CONDITIONAL([GMX_X86_64_SSE2],[test "$enable_x86_64_sse" = "yes" -a "$enable_float" = "no"])
914 AM_CONDITIONAL([GMX_FORTRAN],[test "$enable_fortran" = "yes"])
915 AM_CONDITIONAL([GMX_PPC_ALTIVEC],[test "$enable_ppc_altivec" = "yes" -a "$enable_float" = "yes"])
916 AM_CONDITIONAL([GMX_IA64_ASM],[test "$enable_ia64_asm" = "yes"])
917 AM_CONDITIONAL([GMX_BLUEGENE],[test "$enable_bluegene" = "yes"])
918 AM_CONDITIONAL([GMX_POWER6],[test "$enable_power6" = "yes"])
921 #############
922 # Check integer endian
923 #############
924 AC_C_BIGENDIAN([AC_DEFINE([GMX_INTEGER_BIG_ENDIAN],,[Integer byte order is big endian.])],[],[
925 AC_MSG_ERROR([Cannot determine endian in compiled output])])
926 # Little endian implied if GMX_INTEGER_BIG_ENDIAN not defined in source.
930 case "${host_cpu}" in
931    i?86) 
932          # Check if inline assembly works
933          AC_MSG_CHECKING(if the compiler supports gcc inline assembly)
934       AC_TRY_LINK([],[float f;int i; asm("fld %1\nfistpl %0\n" : "=m" (*&i) : "f" (f));],[AC_MSG_RESULT(yes)
935 AC_DEFINE(GMX_X86_GCC_INLINE_ASM,,[Enable x86 gcc inline assembly])],[AC_MSG_RESULT(no)])
936          # Check for MSVC inline assembly
937      AC_MSG_CHECKING(if the compiler supports MSVC inline assembly)
938       AC_TRY_LINK([],[float f;int i; _asm { fld f } ; _asm { fistpl i };],[AC_MSG_RESULT(yes)
939 AC_DEFINE(GMX_X86_MSVC_INLINE_ASM,,[Enable x86 MSVC inline assembly])],[AC_MSG_RESULT(no)])
940         ;;              
941    *) ;;
942 esac
949 ########################################################################
950 # Final output stage
951 ########################################################################
952 AS="$CC"
953 AC_SUBST(ASFLAGS)
954 AC_SUBST(AS)
955 AC_SUBST(INCLUDES)          # should be automatic, but doesnt seem to be?
957 # To tell libraries apart, we use four versions of the name. For instance, libgmx:
958 # libgmx                single prec, no mpi.
959 # libgmx_d              double prec, no mpi.
960 # libgmx_mpi            single prec, mpi.
961 # libgmx_mpi_d          double prec, mpi.
962 # However, the non-suffixed names are linked to the _mpi and/or _d suffixed
963 # ones upon installation if that is the only version available.
965 if test "$enable_mpi" = "yes"; then
966   LIBSUFFIX="_mpi"
968 if test "$enable_float" = "no"; then
969   LIBSUFFIX="${LIBSUFFIX}_d"
971 AC_SUBST(LIBSUFFIX) 
973 # Unless the user has explicitly requested a prefix/suffix/transform, we
974 # use _d on double precision files. Don't add anything for mpi, but at the
975 # end we tell the user it is possible and smart to do in some cases!
976 if test "$program_transform_name" = "s,x,x,"; then
977   name_transform_provided=no;
978   if test "$enable_float" = "no"; then
979     program_transform_name="s,\$\$,_d,"
980   fi
981 else
982   name_transform_provided=yes;
986 # Use a variable for RPM - this way it can be 
987 # overridden with make RPM=rpm3 rpm
988 RPM=rpm
989 AC_SUBST(RPM)
991 if test "$enable_fahcore" = "yes"; then  
992   CPPFLAGS="$CPPFLAGS -I\$(top_srcdir)/../corewrap -include swindirect.h -DFULLINDIRECT -DUSE_FAH_XDR"  
993   if test "$enable_mpi" = "yes"; then 
994     CFLAGS="$CFLAGS -DMPI"  
995   fi
997 AM_CONDITIONAL([GMX_FAHCORE],[test "$enable_fahcore" = "yes"])
1000 if test "$enable_all_static" = "yes"; then
1001   LDFLAGS="$LDFLAGS -all-static"
1004 # we have asm source, so this is necessary for automake 1.6
1005 CCAS=$CC
1006 CCASFLAGS=$CFLAGS
1008 AC_SUBST(CCAS)
1009 AC_SUBST(CCASFLAGS)
1011 AC_CONFIG_FILES([ Makefile ])
1012 AC_CONFIG_FILES([ src/Makefile ])
1013 AC_CONFIG_FILES([ src/gmxlib/Makefile ])
1014 AC_CONFIG_FILES([ src/gmxlib/gmx_blas/Makefile ])
1015 AC_CONFIG_FILES([ src/gmxlib/gmx_lapack/Makefile ])
1016 AC_CONFIG_FILES([ src/gmxlib/selection/Makefile ])
1017 AC_CONFIG_FILES([ src/gmxlib/statistics/Makefile ])
1018 AC_CONFIG_FILES([ src/gmxlib/trajana/Makefile ])
1019 AC_CONFIG_FILES([ src/gmxlib/thread_mpi/Makefile ])
1020 AC_CONFIG_FILES([ src/gmxlib/nonbonded/Makefile ])
1021 AC_CONFIG_FILES([ src/gmxlib/nonbonded/nb_kernel_c/Makefile ])
1022 AC_CONFIG_FILES([ src/gmxlib/nonbonded/nb_kernel_ia32_sse/Makefile ])
1023 AC_CONFIG_FILES([ src/gmxlib/nonbonded/nb_kernel_ia32_sse2/Makefile ])
1024 AC_CONFIG_FILES([ src/gmxlib/nonbonded/nb_kernel_x86_64_sse/Makefile ])
1025 AC_CONFIG_FILES([ src/gmxlib/nonbonded/nb_kernel_x86_64_sse2/Makefile ])
1026 AC_CONFIG_FILES([ src/gmxlib/nonbonded/nb_kernel_ppc_altivec/Makefile ])
1027 AC_CONFIG_FILES([ src/gmxlib/nonbonded/nb_kernel_ia64_single/Makefile ])
1028 AC_CONFIG_FILES([ src/gmxlib/nonbonded/nb_kernel_ia64_double/Makefile ])
1029 AC_CONFIG_FILES([ src/gmxlib/nonbonded/nb_kernel_bluegene/Makefile ])
1030 AC_CONFIG_FILES([ src/gmxlib/nonbonded/nb_kernel_power6/Makefile ])
1031 AC_CONFIG_FILES([ src/gmxlib/nonbonded/nb_kernel_f77_single/Makefile ])
1032 AC_CONFIG_FILES([ src/gmxlib/nonbonded/nb_kernel_f77_double/Makefile ])
1033 AC_CONFIG_FILES([ include/Makefile ])
1034 AC_CONFIG_FILES([ include/types/Makefile ])
1035 AC_CONFIG_FILES([ include/thread_mpi/Makefile ])
1036 AC_CONFIG_FILES([ include/thread_mpi/atomic/Makefile ])
1037 AC_CONFIG_FILES([ src/mdlib/Makefile ])
1038 AC_CONFIG_FILES([ src/kernel/Makefile ])
1039 AC_CONFIG_FILES([ src/tools/Makefile ])
1040 AC_CONFIG_FILES([ src/ngmx/Makefile ])
1041 AC_CONFIG_FILES([ src/contrib/Makefile ])
1042 AC_CONFIG_FILES([ scripts/Makefile ])
1043 AC_CONFIG_FILES([ admin/Makefile ])
1044 AC_CONFIG_FILES([ share/Makefile ])
1045 AC_CONFIG_FILES([ share/tutor/Makefile ])
1046 AC_CONFIG_FILES([ share/tutor/gmxdemo/Makefile ])
1047 AC_CONFIG_FILES([ share/tutor/nmr1/Makefile ])
1048 AC_CONFIG_FILES([ share/tutor/nmr2/Makefile ])
1049 AC_CONFIG_FILES([ share/tutor/water/Makefile ])
1050 AC_CONFIG_FILES([ share/tutor/mixed/Makefile ])
1051 AC_CONFIG_FILES([ share/tutor/methanol/Makefile ])
1052 AC_CONFIG_FILES([ share/tutor/speptide/Makefile ])
1053 AC_CONFIG_FILES([ share/template/Makefile ])
1054 AC_CONFIG_FILES([ share/top/Makefile ])
1055 AC_CONFIG_FILES([ share/html/Makefile ])
1056 AC_CONFIG_FILES([ share/html/images/Makefile ])
1057 AC_CONFIG_FILES([ share/html/online/Makefile ])
1058 AC_CONFIG_FILES([ man/Makefile man/man1/Makefile man/man7/Makefile ])
1059 AC_CONFIG_FILES([ Doxyfile ])
1060 AC_OUTPUT
1068 #########################################################
1069 # Echo some important info, to avoid stupid mistakes
1072 if test "$enable_float" = "no" -a "$name_transform_provided" = "no"; then
1073   echo ""
1074   echo "* You are compiling a double precision version of Gromacs -"
1075   echo "  program names will be suffixed with _d to avoid overwriting single"
1076   echo "  precision files. You can override it with --program-suffix"
1079 if test "$name_transform_provided" = "no" -a "$enable_mpi" = "yes"; then
1080   echo ""
1081   echo "* Seems you are compiling with MPI support. You can install the MPI-"
1082   echo "  enabled programs with suffixed names to have both MPI and non-MPI"
1083   echo "  versions. This is useful e.g. on supercomputers where you usually"
1084   echo "  cannot run MPI-linked programs on the login node."
1085   echo "  Set a suffix with e.g. --program-suffix=_mpi (or _mpi_d for double)."
1086   echo "  You only need MPI for mdrun, so if you already have non-MPI stuff"
1087   echo "  installed you can issue make mdrun; make install-mdrun."
1090 if test "$host_vendor" = "apple" -a "$enable_apple_64bit" = "no"; then
1091   echo ""
1092   echo "* Did you know that you can compile a 64-bit version of Gromacs to improve"
1093   echo "  performance on recent Intel Macs? You need to install a 64-bit version"
1094   echo "  of FFTW first (add -m64 to CFLAGS, or download it from the Gromacs site)"
1095   echo "  after which you can simply specify --enable-apple-64bit to this script." 
1098 if test "$enable_shared" = "no"; then
1099   echo ""
1100   echo "* On most platforms you can save 10X space with dynamic libraries, although"
1101   echo "  the binaries might be less portable. Why not try --enable-shared ?"
1102 fi