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