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