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