This is the release 1.0 version
[gromacs/libxdrfile.git] / configure.ac
blob4c5e705f9ffb94a6e7b3252c208dc8cf7424272f
1 #######################################################################
2 # Process this file wth autoconf to produce a configure script.
3 #######################################################################
4  
5 AC_PREREQ(2.50)
6 AC_INIT(xdrfile, 1.0, [gmx-users@gromacs.org])
7 AC_CONFIG_SRCDIR(src/xdrfile.c)
8 AC_CONFIG_AUX_DIR(config)
9 AC_CANONICAL_HOST
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.
21 AC_DISABLE_SHARED
23 #######################################################################
24 # Simple options and makefile variables
25 #######################################################################
27 ### Fortran or not
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 ;;
33  esac])
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 ############################################################
58 # Checks for programs
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
63   alpha*-linux*)
64     cc_names="ccc cc gcc"
65     f77_names="fort f77 g77"
66     ;;
67   *) 
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"
70     ;;
71 esac
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
76   CC_FOR_BUILD=$CC
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])
84   fi
87 AM_PROG_AS( $CC )
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.
96   CC=$MPICC
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])
107   AC_TRY_COMPILE([
108 #if defined __QK_USER__
109 #else
110 #error not catamount
111 #endif
112 ],,[
113   AC_MSG_RESULT([yes])
114   cross_compiling=yes 
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"
121   AC_MSG_RESULT([no])
123 # end of "$enable_mpi" = "yes"
126 if test "$enable_threads" = "yes"; then
127    AC_MSG_CHECKING([for pthreads])
128    AC_MSG_RESULT([yes])
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
144   AC_F77_WRAPPERS
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)])
147 else
148   AC_DEFINE([F77_OR_C_FUNC(name,NAME)],[name])
149   AC_DEFINE([F77_OR_C_FUNC_(name,NAME)],[name])
154 AC_PROG_CPP
156 if test "$enable_cpu_optimization" = "yes"; then
157   ACX_DETECT_GMXCPU
158 else
159   gmxcpu=""
161 ACX_COMPILER_MAXOPT
166 #############
167 # Check integer endian
168 #############
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.
173 #############
174 # Check integer sizes, set to zero if e.g. long long is not supported.
175 #############
176 AC_CHECK_SIZEOF(int)
177 AC_CHECK_SIZEOF(long int)
178 AC_CHECK_SIZEOF(long long int)
181 #############
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.
184 #############
185 AC_MSG_CHECKING([that size_t can hold pointers])
186 AC_TRY_COMPILE([
187 #include <stdlib.h>
188 #include <stddef.h>
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.])])
194 #############
195 # Check floating-point format and endian
196 #############
197 ACX_FLOAT_FORMAT
200 AC_PROG_INSTALL
201 AC_PROG_LN_S
202 AC_PROG_MAKE_SET
203 AC_LIBTOOL_WIN32_DLL
204 AC_PROG_LIBTOOL
205 AC_SYS_LARGEFILE
206 AC_FUNC_FSEEKO
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])
218 else
219   AC_CHECK_LIB(m,sqrt,,AC_MSG_ERROR([No math library found]))
222 #####
223 # Disable MASS support for now.
224 #####
227 ######
228 # check for xtc headers
229 case "${host_os}" in
230 cygwin* | mingw*)   # use our own xdr stuff for cygwin/mingw
231   GMXLIB_LIBOBJS="$GMXLIB_LIBOBJS gmx_system_xdr.lo"
232   ;;
234   AC_CHECK_HEADERS([rpc/rpc.h])
235   AC_CHECK_HEADERS([rpc/xdr.h],,,
236 [#if HAVE_RPC_RPC_H
237 # include <rpc/rpc.h>
238 #endif
240   AC_CHECK_LIB(nsl,xdr_float)
241   AC_TRY_LINK([
242 #if HAVE_RPC_RPC_H
243 #include<rpc/rpc.h> 
244 #else
245 #error NO rpc.h header
246 #endif
247 #if HAVE_RPC_XDR_H
248 #include<rpc/xdr.h>
249 #else
250 #error No xdr.h header
251 #endif
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])
258   fi
259   ;;
260 esac
262 #####
263 # Checks for additional and/or optional functions or libraries.
264 #AC_FUNC_MALLOC
265 AC_FUNC_MEMCMP
266 AC_TYPE_SIGNAL
267 AC_FUNC_VPRINTF
268 AM_WITH_DMALLOC
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])
274 ######
275 #### 
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
280   *-solaris*) 
281     LIBS="$FLIBS $LIBS" 
282     LDFLAGS="$LDFLAGS -L/usr/ucblib"
283     ;;
284   *) LIBS="$LIBS $FLIBS" ;;
285 esac
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)
304 #####
305 # Checks for typedefs, structures, and compiler characteristics.
306 AC_C_CONST
307 AC_TYPE_SIZE_T
308 AC_STRUCT_TM
309 AC_TYPE_UID_T
310 AC_C_INLINE
311     
316 # Test stuff for ia64 assembly
318 # Nothing to test right now.
324 #############
325 # Check integer endian
326 #############
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
334    i?86) 
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)])
343         ;;              
344    *) ;;
345 esac
352 ########################################################################
353 # Final output stage
354 ########################################################################
355 AS="$CC"
356 AC_SUBST(ASFLAGS)
357 AC_SUBST(AS)
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
372   LIBSUFFIX="_mpi"
374 if test "$enable_float" = "no"; then
375   LIBSUFFIX="${LIBSUFFIX}_d"
377 AC_SUBST(LIBSUFFIX) 
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,"
386   fi
387 else
388   name_transform_provided=yes;
392 # Use a variable for RPM - this way it can be 
393 # overridden with make RPM=rpm3 rpm
394 RPM=rpm
395 AC_SUBST(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
403 CCAS=$CC
404 CCASFLAGS=$CFLAGS
406 AC_SUBST(CCAS)
407 AC_SUBST(CCASFLAGS)
409 AC_CONFIG_FILES([ Makefile ])
410 AC_CONFIG_FILES([ include/Makefile ])
411 AC_CONFIG_FILES([ src/Makefile ])
413 AC_OUTPUT
421 #########################################################
422 # Echo some important info, to avoid stupid mistakes
425 if test "$enable_float" = "no" -a "$name_transform_provided" = "no"; then
426   echo ""
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
433   echo ""
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."
443 echo ""