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