1 #######################################################################
2 # Process this file wth autoconf to produce a configure script.
3 #######################################################################
6 AC_INIT(xdrfile, 1.0, [gmx-users@gromacs.org])
7 AC_CONFIG_SRCDIR(src/xdrfile.c)
8 AC_CONFIG_AUX_DIR(config)
11 AM_INIT_AUTOMAKE(tar-ustar)
12 AC_PREFIX_DEFAULT(/usr/local/gentop)
14 AM_CONFIG_HEADER(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="4:0:0"
18 AC_SUBST(SHARED_VERSION_INFO)
20 # MPI builds on aix break with shared libs, so they are disabled by default.
23 #######################################################################
24 # Simple options and makefile variables
25 #######################################################################
28 AC_ARG_ENABLE(fortran,
29 [ --Enable-fortran use fortran (default on sgi,ibm,sun,axp)],,
30 [case "${host_cpu}-${host_os}" in
31 sparc*-solaris* | alpha*-* | rs6000*-aix* | powerpc*-aix* | mips*-irix*) enable_fortran=yes ;;
32 *) enable_fortran=no ;;
34 AM_CONDITIONAL([GMX_FORTRAN],[test "$enable_fortran" = "yes"])
35 if test "$enable_fortran" = "yes"; then
36 AC_DEFINE(GMX_FORTRAN,,[Use Fortran innerloops])
38 # always use CC for linking:
39 AC_SUBST(F77LINK,"\$(LINK)")
42 AC_ARG_ENABLE(all-static,
43 [ --enable-all-static make completely static binaries],, enable_all_static=no)
44 # Dont add the -all-static flag until after the compiler test.
48 ############################################################
49 # Add some debug info: Who is building, and on what machine?
50 ############################################################
51 AC_DEFINE_UNQUOTED([BUILD_TIME],["`date`"],[Date and time for build])
52 AC_DEFINE_UNQUOTED([BUILD_USER],["`whoami`@`hostname`"],[User doing build])
53 AC_DEFINE_UNQUOTED([BUILD_MACHINE],["`uname -srm`"],[Hardware and OS version for build host])
57 ############################################################
59 ############################################################
61 # normally we use the default compiler, but on alpha/linux we try the compaq ones first
62 case "${host_cpu}-${host_os}" in
65 f77_names="fort f77 g77"
68 cc_names="cc icc xlc gcc"
69 f77_names="f77 ifort xlf xlf77 cf77 fl32 g77 fort77 f90 xlf90 pgf77 cf77 fort fort77 pgf90"
72 # the (non-mpi) c compiler, which is also used for programs executed during build stage
73 AC_PROG_CC( $cc_names )
74 # Check for environment variable CC_FOR_BUILD before overwriting it
75 if test -z "$CC_FOR_BUILD"; then
78 AC_SUBST(CC_FOR_BUILD)
80 if test "$enable_fortran" = "yes"; then
81 AC_PROG_F77( $f77_names )
82 if test -z "$F77"; then
83 AC_MSG_ERROR([No fortran compiler found])
89 # if we are using mpi, also get an MPICC. We cannot set that in the PROG_CC macro
90 # above, since autoconf checks that the created file can be executed. This would
91 # fail on platforms where MPI executables can only be run through a batchqueue.
93 if test "$enable_mpi" = "yes"; then
94 AC_CHECK_PROGS(MPICC, mpxlc mpicc mpcc hcc, $CC)
95 # now change the normal cc to the MPI one - see the comment above.
97 AC_MSG_CHECKING([whether the MPI cc command works]) # be paranoid
98 AC_TRY_LINK([#include <mpi.h>],[int argc; char **argv; MPI_Init(&argc,&argv);],
99 AC_MSG_RESULT([yes]),AC_MSG_ERROR([Cannot compile and link MPI code with $CC]))
100 AC_DEFINE(GMX_MPI,,[Make a parallel version of GENTOP using MPI])
102 # on the cray xt3 we have to tell autoconf that we
103 # are actually cross-compiling even if the architecture
104 # of host and target are the same. so we enforce
105 # cross-compilation if __QK_USER__ is defined
106 AC_MSG_CHECKING([for catamount])
108 #if defined __QK_USER__
115 AC_DEFINE(GMX_CRAY_XT3,[],[Enable special hacks for Cray XT3])
116 AC_DEFINE(GMX_NO_SYSTEM,[],[Ignore calls to system(3)])
117 AC_DEFINE(GMX_NO_NICE,[],[Ignore calls to nice(3)])
118 AC_DEFINE(GMX_BROKEN_CALLOC,[],[Don't use calloc(3)])
119 extra_LDFLAGS="$extra_LDFLAGS -lgmalloc -lacml"
123 # end of "$enable_mpi" = "yes"
126 if test "$enable_threads" = "yes"; then
127 AC_MSG_CHECKING([for pthreads])
129 AC_DEFINE([GMX_THREAD_PTHREAD],,[Use pthreads for Gromacs multithreading])
130 # ACX_PTHREAD([],AC_MSG_ERROR([Cannot compile with pthreads; use --disable-threads])
135 AH_TEMPLATE([F77_OR_C_FUNC],
136 [Set to F77_FUNC(name,NAME) if Fortran used, otherwise 'name' for C.])
137 AH_TEMPLATE([F77_OR_C_FUNC_],
138 [Set to F77_FUNC_(name,NAME) if Fortran used, otherwise 'name' for C.])
142 if test "$enable_fortran" = "yes"; then
143 AC_F77_LIBRARY_LDFLAGS
145 AC_DEFINE([F77_OR_C_FUNC(name,NAME)],[F77_FUNC(name,NAME)])
146 AC_DEFINE([F77_OR_C_FUNC_(name,NAME)],[F77_FUNC_(name,NAME)])
148 AC_DEFINE([F77_OR_C_FUNC(name,NAME)],[name])
149 AC_DEFINE([F77_OR_C_FUNC_(name,NAME)],[name])
156 if test "$enable_cpu_optimization" = "yes"; then
167 # Check integer endian
169 AC_C_BIGENDIAN([AC_DEFINE([GMX_INTEGER_BIG_ENDIAN],,[Integer byte order is big endian.])],[],[
170 AC_MSG_ERROR([Cannot determine endian in compiled output])])
171 # Little endian implied if GMX_INTEGER_BIG_ENDIAN not defined in source.
174 # Check integer sizes, set to zero if e.g. long long is not supported.
177 AC_CHECK_SIZEOF(long int)
178 AC_CHECK_SIZEOF(long long int)
182 # Make sure size_t can hold pointers.
183 # On some Nec machines, you reportedly need to specify a flag for size_t to be 64 bits wide.
185 AC_MSG_CHECKING([that size_t can hold pointers])
189 ],[int chk[sizeof(size_t)-sizeof(int *)+1];],AC_MSG_RESULT([yes]),[
190 AC_MSG_ERROR([size_t is smaller than int*. Check if your compiler needs a flag to make it 64 bit.])])
195 # Check floating-point format and endian
211 ############################################################################
212 # Checks for libraries.
213 ############################################################################
215 # Don't add math library for intel compilers
216 if $CC -V 2>&1 | grep 'Intel Corporation' > /dev/null 2>&1; then
217 AC_MSG_NOTICE([Using built-in math library with intel compiler])
219 AC_CHECK_LIB(m,sqrt,,AC_MSG_ERROR([No math library found]))
223 # Disable MASS support for now.
228 # check for xtc headers
230 cygwin* | mingw*) # use our own xdr stuff for cygwin/mingw
231 GMXLIB_LIBOBJS="$GMXLIB_LIBOBJS gmx_system_xdr.lo"
234 AC_CHECK_HEADERS([rpc/rpc.h])
235 AC_CHECK_HEADERS([rpc/xdr.h],,,
237 # include <rpc/rpc.h>
240 AC_CHECK_LIB(nsl,xdr_float)
245 #error NO rpc.h header
250 #error No xdr.h header
252 ],[ XDR *xd; float f; xdr_float(xd,&f);],[have_xdr="yes"])
254 if test "$have_xdr" != "yes"; then
255 AC_DEFINE(GMX_INTERNAL_XDR,,[Use our own instead of system XDR libraries])
256 GMXLIB_LIBOBJS="${GMXLIB_LIBOBJS} gmx_system_xdr.lo"
257 AC_MSG_WARN([Couldn't find XDR headers and/or libraries - using our own])
263 # Checks for additional and/or optional functions or libraries.
269 AC_CHECK_FUNCS(strcasecmp)
270 AC_CHECK_FUNCS(strdup)
271 # check for bool (must come late, since CFLAGS/includes might affect it)
272 AC_CHECK_TYPES([bool])
276 # And collect the f77 libs to the linker - on Solaris, f77 stuff must go first,
277 # and we need -L/usr/ucblib to find libucb... (stupid OS)
278 # On e.g. ibm the mass libraries must come before -lm...
279 case "${host_cpu}-${host_os}" in
282 LDFLAGS="$LDFLAGS -L/usr/ucblib"
284 *) LIBS="$LIBS $FLIBS" ;;
288 # add the Accelerate framework if enabled above.
289 # LDFLAGS might have been set in the CPU optimization, so we cant assign it directly before that.
290 LDFLAGS="$LDFLAGS $extra_LDFLAGS"
297 ########################################################################
298 # Checks for header files and types
299 ########################################################################
301 AC_CHECK_HEADERS([limits.h strings.h unistd.h],,AC_MSG_ERROR([Include headers not found]))
302 AC_CHECK_HEADERS(unistd.h)
305 # Checks for typedefs, structures, and compiler characteristics.
316 # Test stuff for ia64 assembly
318 # Nothing to test right now.
325 # Check integer endian
327 AC_C_BIGENDIAN([AC_DEFINE([GMX_INTEGER_BIG_ENDIAN],,[Integer byte order is big endian.])],[],[
328 AC_MSG_ERROR([Cannot determine endian in compiled output])])
329 # Little endian implied if GMX_INTEGER_BIG_ENDIAN not defined in source.
333 case "${host_cpu}" in
335 # Check if inline assembly works
336 AC_MSG_CHECKING(if the compiler supports gcc inline assembly)
337 AC_TRY_LINK([],[float f;int i; asm("fld %1\nfistpl %0\n" : "=m" (*&i) : "f" (f));],[AC_MSG_RESULT(yes)
338 AC_DEFINE(GMX_X86_GCC_INLINE_ASM,,[Enable x86 gcc inline assembly])],[AC_MSG_RESULT(no)])
339 # Check for MSVC inline assembly
340 AC_MSG_CHECKING(if the compiler supports MSVC inline assembly)
341 AC_TRY_LINK([],[float f;int i; _asm { fld f } ; _asm { fistpl i };],[AC_MSG_RESULT(yes)
342 AC_DEFINE(GMX_X86_MSVC_INLINE_ASM,,[Enable x86 MSVC inline assembly])],[AC_MSG_RESULT(no)])
352 ########################################################################
354 ########################################################################
358 AC_SUBST(INCLUDES) # should be automatic, but doesnt seem to be?
359 AC_SUBST(GMXLIB_LIBOBJS)
360 AC_SUBST(MDLIB_LIBOBJS)
361 AC_SUBST(GMXANA_LIBOBJS)
363 # To tell libraries apart, we use four versions of the name. For instance, libgmx:
364 # libgmx single prec, no mpi.
365 # libgmx_d double prec, no mpi.
366 # libgmx_mpi single prec, mpi.
367 # libgmx_mpi_d double prec, mpi.
368 # However, the non-suffixed names are linked to the _mpi and/or _d suffixed
369 # ones upon installation if that is the only version available.
371 if test "$enable_mpi" = "yes"; then
374 if test "$enable_float" = "no"; then
375 LIBSUFFIX="${LIBSUFFIX}_d"
379 # Unless the user has explicitly requested a prefix/suffix/transform, we
380 # use _d on double precision files. Don't add anything for mpi, but at the
381 # end we tell the user it is possible and smart to do in some cases!
382 if test "$program_transform_name" = "s,x,x,"; then
383 name_transform_provided=no;
384 if test "$enable_float" = "no"; then
385 program_transform_name="s,\$\$,_d,"
388 name_transform_provided=yes;
392 # Use a variable for RPM - this way it can be
393 # overridden with make RPM=rpm3 rpm
398 if test "$enable_all_static" = "yes"; then
399 LDFLAGS="$LDFLAGS -all-static"
402 # we have asm source, so this is necessary for automake 1.6
409 AC_CONFIG_FILES([ Makefile ])
410 AC_CONFIG_FILES([ include/Makefile ])
411 AC_CONFIG_FILES([ src/Makefile ])
421 #########################################################
422 # Echo some important info, to avoid stupid mistakes
425 if test "$enable_float" = "no" -a "$name_transform_provided" = "no"; then
427 echo "* You are compiling a double precision version of Gromacs -"
428 echo " program names will be suffixed with _d to avoid overwriting single"
429 echo " precision files. You can override it with --program-suffix"
432 if test "$name_transform_provided" = "no" -a "$enable_mpi" = "yes"; then
434 echo "* Seems you are compiling with MPI support. You can install the MPI-"
435 echo " enabled programs with suffixed names to have both MPI and non-MPI"
436 echo " versions. This is useful e.g. on supercomputers where you usually"
437 echo " cannot run MPI-linked programs on the login node."
438 echo " Set a suffix with e.g. --program-suffix=_mpi (or _mpi_d for double)."
439 echo " You only need MPI for mdrun, so if you already have non-MPI stuff"
440 echo " installed you can issue make mdrun; make install-mdrun."