AMPI #952: update ROMIO to MPICH2-1.4.1p1
[charm.git] / src / libs / ck-libs / ampi / romio / configure.in
blob9fc16f24344cd48ba9fee2c521982ba2dfc78b89
1 # -*- Mode: shell-script -*-
2 # build with
3 # autoconf --localdir=../confdb configure.in
4 # (or wherever the confdb is)
6 AC_PREREQ(2.59)
8 # if this blows up, it's because you forgot to run autoheader
9 AC_INIT(adio/include/romioconf.h.in)
10 # VERSION=1.2.6
11 # AC_MSG_RESULT([Configuring ROMIO Version $VERSION])
12 CONFIGURE_ARGS="$*"
13 if test -n "$CONFIGURE_ARGS" ; then
14     echo "Configuring with args $CONFIGURE_ARGS"
17 AC_CONFIG_HEADER(adio/include/romioconf.h)
19 dnl
20 NOF77=0
21 NOF90=0
22 ARCH=""
23 arch_IRIX=""
24 MPI_IMPL=""
25 MPI_INCLUDE_DIR=""
26 ROMIO_INCLUDE=""
27 TEST_LIBNAME=""
28 FILE_SYSTEM=""
29 # Do not set variables to empty that may be communicated from the
30 # outside environment (e.g., MPI_LIB, MPI_BIN_DIR, LIBNAME)
31 DEBUG=no
32 MIPS=0
33 BITS=0
34 FROM_MPICH=${FROM_MPICH:-no}
35 FROM_MPICH2=${FROM_MPICH2:-no}
36 if test "$FROM_MPICH" = yes -a "$FROM_MPICH2" = yes ; then
37     AC_MSG_WARN([Both FROM_MPICH and FROM_MPICH set to yes; at most one should  be yes])
38     
40 FROM_LAM=${FROM_LAM:-no}
41 if test "$FROM_LAM" = 1 ; then FROM_LAM=yes ; fi
42 CFLAGS=${CFLAGS:-""}
43 LL="lld"
44 AR_LOCAL=""
45 DEFINE_HAVE_MPI_GREQUEST="#undef HAVE_MPI_GREQUEST"
46 HAVE_MPI_INFO=""
47 BUILD_MPI_INFO=""
48 MPI_FINFO1=""
49 MPI_FINFO2=""
50 MPI_FINFO3=""
51 MPI_FINFO4=""
52 MPI_FARRAY1=""
53 MPI_FARRAY2=""
54 MPI_FARRAY3=""
55 MPI_FARRAY4=""
56 MPI_FARRAY5=""
57 MPI_FARRAY6=""
58 MPI_FARRAY7=""
59 DEFS=""
60 ROMIO_LFLAGS=""
61 ROMIO_TCFLAGS=""
62 ROMIO_TCPPFLAGS=""
63 ROMIO_TFFLAGS=""
64 NOPROFILE=0
65 MPIRUN=""
66 FORTRAN_TEST=""
67 MAKE=${MAKE:-"make"}
68 # foll. needed for f77 test programs
69 F77GETARG="call getarg(i,str)"
70 F77IARGC="iargc()"
71 F77MPIOINC=""
72 FTESTDEFINE=""
73 FORTRAN_MPI_OFFSET=""
74 MPIOF_H_INCLUDED=0
75 MPI_OFFSET_KIND1="!"
76 MPI_OFFSET_KIND2="!"
77 TEST_CC=""
78 TEST_F77=""
79 TRY_WEAK_SYMBOLS=1
81 # Error handlers (not used with MPICH2, which provides its own routines)
82 MPIO_EXTRA_OBJECTS="get_errh.o set_errh.o"
83 MPIO_EXTRA_TMP_POBJECTS="get_errh.p set_errh.p"
84 MPIO_EXTRA_REAL_POBJECTS="_get_errh.o _set_errh.o"
86 # Completion routines for MPIO_Requests.  MPI Implementations with
87 # generalized requests do not need these
88 # ioreq_c2f and ioreq_f2c are not MPIO_Requests; rather, they 
89 MPIO_REQOBJECTS="iotest.o iotestall.o iotestany.o iotestsome.o iowait.o iowaitall.o iowaitany.o iowaitsome.o ioreq_c2f.o ioreq_f2c.o"
90 MPIO_REQ_TMP_POBJECTS="iotest.p iowait.p iowaitall.p iowaitany.p iotestall.p iotestany.p iowaitsome.p iotestsome.p"
91 MPIO_REQ_REAL_POBJECTS="_iotest.o _iowait.o _iowaitall.o _iowaitany.o _iotestall.o _iotestany.o _iowaitsome.o _iotestsome.o"
93 have_aio=no
95 known_filesystems="nfs ufs pfs pvfs pvfs2 testfs xfs panfs gridftp lustre bgl bglockless zoidfs"
96 known_mpi_impls="mpich2_mpi mpich_mpi sgi_mpi hp_mpi cray_mpi lam_mpi"
98 # Defaults
99 AC_ARG_ENABLE(aio,[
100 --enable-aio - Request use of asynchronous I/O routines (default)],
102   if test "x$enableval" = "xno" ; then
103     disable_aio=yes
104   else
105     disable_aio=no
106   fi
107 ], disable_aio=no)
108 AC_ARG_ENABLE(echo, 
109 [--enable-echo  - Turn on strong echoing. The default is enable=no.] ,set -x)
110 AC_ARG_ENABLE(f77,
111 [--enable-f77 - Turn on support for Fortran 77 (default)],,enable_f77=yes)
112 AC_ARG_ENABLE(f90,
113 [--enable-f90 - Turn on support for Fortran 90 (default)],,enable_f90=yes)
114 AC_ARG_ENABLE(weak-symbols,
115 [--enable-weak-symbols - Turn on support for weak symbols],,enable_weak_symbols=no)
116 AC_ARG_ENABLE(debug,
117 [--enable-debug - Build a debugging version],,)
118 AC_ARG_WITH(file-system,[
119 --with-file-system=name - Build with support for the named file systems],,)
120 AC_ARG_WITH(pvfs2,[
121 --with-pvfs2=path - Path to installation of PVFS (version 2)],,)
122 AC_ARG_WITH(mpi-impl,[
123 --with-mpi-impl=name - Specify MPI implementation to build ROMIO for],,)
125 AC_ARG_WITH(mpi, [
126 --with-mpi=path   - Path to instalation of MPI (headers, libs, etc)],,)
128 if test "$enable_f77" != "yes" ; then
129    NOF77=1
131 if test "$enable_f90" != "yes" ; then
132    NOF90=1
134 if test "$enable_debug" = "yes" ; then
135     DEBUG=yes
137 if test "$enable_weak_symbols" = "no" ; then
138     TRY_WEAK_SYMBOLS=0
140 MPI=$with_mpi
141 if test -n "$with_mpi"; then
142        CC=$MPI/bin/mpicc
145 FILE_SYSTEM=$with_file_system
147 dnl AC_CONFIG_AUX_DIR(../../../confdb)
148 dnl Set the directory that contains the required install-sh, config.sub,
149 dnl and config.guess .  Make sure that these are updated (in MPICH2, use
150 dnl the top-level confdb files).  This separate directory is used for
151 dnl the moment to allow ROMIO to be separatedly distributed.
152 dnl scripts.
153 AC_CONFIG_AUX_DIR(confdb)
155 # Check if Make is working
156 PAC_PROG_MAKE
158 # Check that an arch was set
159 # If it wasn't set, try to guess using "util/tarch"
161 # Sometimes tarch looses its execute bit (!)
162 if test -s $srcdir/util/tarch -a ! -x $srcdir/util/tarch ; then
163     chmod a+x $srcdir/util/tarch
165 if test -z "$ARCH" -a -x $srcdir/util/tarch ; then
166     AC_MSG_CHECKING(for architecture)
167     ARCH=`$srcdir/util/tarch | sed s/-/_/g`
168     if test -z "$ARCH" ; then
169        AC_MSG_RESULT(Unknown!)
170        AC_MSG_ERROR([Error: Could not guess target architecture, you must 
171 set an architecture type with the environment variable ARCH]) 
172     fi 
173     eval "arch_$ARCH=1"
174     AC_MSG_RESULT($ARCH)
177 # check for valid architecture.  Use __ so that _ALPHA_ does not match
178 # LINUX_ALPHA_
179 #### WE SHOULD REMOVE THIS SOON
180 grep __"$ARCH"_ $srcdir/.config_params > /dev/null 2>&1
181 if test $? != 0 ; then
182    AC_MSG_WARN([Unknown architecture $arch... proceeding anyway])
186 # Find the home directory if not specified
187 if test "X$srcdir" != "X." -a -s $srcdir/mpi-io/Makefile.in ; then 
188     ROMIO_HOME_TRIAL=$srcdir
189 else
190     # Take advantage of autoconf2 features
191     if test -n "$ac_confdir" ; then
192         ROMIO_HOME_TRIAL=$ac_confdir
193     else
194         if test -s configure ; then
195             ROMIO_HOME_TRIAL=`pwd`
196         else
197             ac_confdir=`dirname "$0" 2>/dev/null`
198             if test -n "$ac_confdir" ; then
199                 ROMIO_HOME_TRIAL=$ac_confdir
200             fi
201         fi
202     fi
204 AC_MSG_RESULT([ROMIO home directory is $ROMIO_HOME_TRIAL])
205 ROMIO_HOME=$ROMIO_HOME_TRIAL
207 # get a fully qualified pathname for our build directory
208 top_build_dir=`pwd`
209 # used in romioinstall
210 AC_SUBST(top_build_dir)
213 # Create the "autoconf" style directory names...
214 # Most of these are done for us; add the documentation directories
216 # mandir is the root for the man pages
217 if test -z "$mandir" ; then mandir='${prefix}/man' ; fi
218 AC_SUBST(mandir)
219 if test -z "$docdir" ; then docdir='${prefix}/doc' ; fi
220 AC_SUBST(docdir)
221 if test -z "$htmldir" ; then htmldir='${prefix}/www' ; fi
222 AC_SUBST(htmldir) 
224 # check for valid file system
225 if test -n "$FILE_SYSTEM" ; then
226    # if multiple filesystems are passed in, they are '+'-delimited
227    # we could set the IFS to tokenize FILE_SYSTEM, but the FILE_SYSTEM env var
228    # is used in multiple places in the build system: get rid of the '+'s so we
229    # can use the 'for x in $FILE_SYSTEM ...' idiom 
230    FILE_SYSTEM=`echo $FILE_SYSTEM|sed -e 's/\+/ /g'`
231    for x in $FILE_SYSTEM
232    do
233       found=no
234       # We could also do test -d "ad_$y" to test for known file systems
235       # based on having access to the adio code.  Then adding a file 
236       # system would not require changing configure to change known_filesystems
237       for y in $known_filesystems ; do 
238           if test $x = $y ; then
239               found=yes
240               eval "file_system_`echo $x`=1"
241               break
242           fi
243       done
244       if test "$found" = "no" ; then
245          AC_MSG_WARN([Unknown file system $x... proceeding anyway])
246       fi
247    done
250 # If we are building within a known MPI implementation, we must avoid the
251 # tests about an existing implementation
252 if test "$FROM_MPICH" != no -o "$FROM_MPICH2" != no -o "$FROM_LAM" != no ; then
253     WITHIN_KNOWN_MPI_IMPL=yes
254 else
255     WITHIN_KNOWN_MPI_IMPL=no
257 # check for valid MPI implementation
258 if test -n "$MPI_IMPL" ; then
259    found=no
260    for mpi in $known_mpi_impls ; do
261       if test "${MPI_IMPL}_mpi" = "$mpi" ; then
262           found=yes
263           break
264       fi
265    done
266    if test $found = no ; then
267       AC_MSG_WARN([Unknown MPI implementation $MPI... proceeding anyway])
268    fi
272 if test -n "${with_mpi}" ; then
273         MPI_INCLUDE_DIR="${with_mpi}"/include
274         MPI_LIB_DIR="${with_mpi}"/lib
277 # check for valid MPI include directory if specified
278 if test $WITHIN_KNOWN_MPI_IMPL = no ; then
279    if test -n "$MPI_INCLUDE_DIR"; then
280       if test ! -f "$MPI_INCLUDE_DIR/mpi.h" ; then
281          AC_MSG_ERROR([Include file $MPI_INCLUDE_DIR/mpi.h not found])
282       fi
283    else
284 #     assume that mpi.h is in the default path
285 #     set MPI_INCLUDE_DIR to ".", so that it translates to -I. in the
286 #     compile command. Some compilers complain if it's only -I
287       MPI_INCLUDE_DIR=.
288    fi
289 else 
290    MPI_INCLUDE_DIR=.
293 # check for valid MPI library if specified
294 if test $WITHIN_KNOWN_MPI_IMPL = no ; then
295    if test -n "$MPI_LIB" ; then
296       if test ! -f "$MPI_LIB" ; then
297          AC_MSG_ERROR([MPI library $MPI_LIB not found])
298       fi
299    fi
303 AR="${AR:-ar} cr$AR_LOCAL"
304 if test -z "$RANLIB" ; then
305     AC_PROG_RANLIB
308 # USER_CFLAGS and USER_FFLAGS are used only in test/Makefile.in
309 if test $DEBUG = "yes"; then
310     USER_CFLAGS="$CFLAGS -g"
311     USER_FFLAGS="$FFLAGS -g"
312 else
313     USER_CFLAGS="$CFLAGS -O"
314     USER_FFLAGS="$FFLAGS -O"
317 # Here begin the architecture-specific tests.  
318 # --------------------------------------------------------------------------
319 # We must first select the C and Fortran compilers.  Because of the 
320 # way that the PROG_CC autoconf macro works (and all of the macros that
321 # require it, including CHECK_HEADERS), that macro must occur exactly
322 # once in the configure.in file, at least as of autoconf 2.57 .  
323 # Unfortunately, this requirement is not enforced.  To handle this,
324 # we first case on the architecture; then use PROG_CC, then case on the
325 # architecture again for any arch-specific features.  We also set the
326 # C_DEBUG_FLAG and F77_DEBUG_FLAG in case debugging is selected.
328 # For the MPICH and MPICH2 configures, the compilers will already be
329 # selected, so most of the compiler-selection code will be bypassed.
330 # --------------------------------------------------------------------------
331 # For historical reasons
332 if test -z "$FC" ; then 
333     FC=$F77
336 C_DEBUG_FLAG="-g"
337 F77_DEBUG_FLAG="-g"
338 # C_OPT_FLAG=${CFLAGS:-"-O"}
339 # MPICH1 uses OPTFLAGS and OPTFLAGSC to specify separate optimization
340 # flags for the C compiler (this is better that adding it to the
341 # undifferentiated CFLAGS, at least on input).
342 if test -n "$OPTFLAGS" ; then
343     C_OPT_FLAG="$C_OPT_FLAG $OPTFLAGS"
345 if test -n "$OPTFLAGSC" ; then
346     C_OPT_FLAG="$C_OPT_FLAG $OPTFLAGSC"
348 case $ARCH in 
349      solaris|solaris86)
350      CC=${CC:-cc}
351      F77=${FC:-f77}
352      if test "$CC" != "gcc" ; then
353         C_DEBUG_FLAG="-g -v"
354      fi
355      ;;
356      
357      rs6000)
358      F77=${FC}
359      # Try to use mpcc if no CC specified
360      AC_PROGRAMS_CHECK(CC, mpcc, cc)
361      if test $NOF77 = 0 && test -z "$F77"; then 
362         AC_PROGRAMS_CHECK(F77, mpxlf, f77)
363      fi
364      ;;
366      tflop|tflops)
367      CC=${CC:-pgcc}
368      F77=${FC:-pgf77}
369      CFLAGS="$CFLAGS -cougar -D__PUMA"
370      if test "$CC" = "pgcc" ; then
371          C_OPT_FLAG="-Knoieee -Mvect -O3"
372      fi
373      ;;
374      
375      freebsd|LINUX|netbsd|openbsd|LINUX_ALPHA)
376      CC=${CC:-gcc}
377      # Let the prog_f77 file g77/f77/others
378      F77=${FC} 
379      ;;
381      SX4)
382      CC=${CC:-mpicc}
383      F77=${FC:-mpif90}
384      if test $DEBUG != "yes" ; then
385         USER_FFLAGS="$FFLAGS -Chopt"
386         F77_OPT_FLAG="-Chopt"
387     fi
388     ;;
390     hpux|sppux)
391     C_DEBUG_FLAG="-g +w1"
392     ;;
394     alpha|ALPHA)
395     CC=${CC:-cc}
396     F77=${FC:-f77}
397     dnl CFLAGS="$CFLAGS -g -std1 -warnprotos -verbose"
398     C_DEBUG_FLAG="-g -verbose"
399     ;;
401     CRAY)
402     CC=${CC:-cc}
403     F77=${FC:-f90}
404     NOF77=1
405     CFLAGS="$CFLAGS -D_UNICOS"
406     ;;
408     sgi|IRIX64|IRIX32|IRIXN32)
409     arch_IRIX=1
410     CC=${CC:-cc}
411     F77=${FC:-f77}
412     C_DEBUG_FLAG="-g -fullwarn"
413     ;;
415     sgi5)
416     ;;
418     *)
419     # Fall-through case.  Take FC 
420     F77=${FC:-f77}
421     ;;
422 esac
424 PAC_PROG_CC
426 if test "$NOF77" != 1 ; then
427     # Grrr.   The autoconf test for F77 will abort the configure
428     # if no compiler is found.  We'd prefer to simply turn off
429     # support for Fortran, and/or give a more informative message.
430     PAC_PROG_F77
432 if test "$CC" = "gcc" -a -z "$C_DEBUG_FLAG" ; then
433      C_DEBUG_FLAG="-g -O -Wall -Wstrict-prototypes -Wmissing-prototypes"
435 if test $DEBUG = "yes" ; then
436     CFLAGS="$CFLAGS $C_DEBUG_FLAG"
437 else 
438     CFLAGS="$CFLAGS $C_OPT_FLAG"
440 # ---------------------------------------------------------------------------
441 # Here go the rest of the tests
442 # ---------------------------------------------------------------------------
443 if test -n "$arch_solaris" || test -n "$arch_solaris86" ; then
444     if test -z "$MPI_IMPL" ; then
445         MPI_IMPL=mpich
446         mpi_mpich=1
447     fi
448     if test $MPI_IMPL = "mpich" ; then
449         TEST_CC=mpicc
450         TEST_F77=mpif77
451     else
452         TEST_CC="$CC"
453         TEST_F77="$F77"
454     fi
455     AR="ar cr"
456 # solaris does not have l option to ar
460 if test -n "$arch_rs6000"; then
461     if test -z "$MPI_IMPL" ; then
462         MPI_IMPL=mpich
463         mpi_mpich=1
464     fi
465     AC_DEFINE(AIX,1,[Define for AIX])
466 # assume long long exists.
467     ac_cv_sizeof_long_long=${ac_cv_sizeof_long_long:-8} 
468     MPI_OFFSET_KIND1="      INTEGER MPI_OFFSET_KIND"
469     MPI_OFFSET_KIND2="      PARAMETER (MPI_OFFSET_KIND=8)"
470     MPI_OFFSET_KIND_VAL=8
471 fi    
474 if test -n "$arch_tflop" || test -n "$arch_tflops"; then
475     # TFLOP_FLAGS="-cougar -D__PUMA"
476     AR="xar cr$AR_LOCAL"
477     RANLIB="xranlib"
478     MPI_LIB="$MPI_LIB"
479     if test -z "$MPI_IMPL" ; then
480         MPI_IMPL=mpich
481         mpi_mpich=1
482     fi
483     if test -z "$FILE_SYSTEM" ; then
484         file_system_ufs=1
485         FILE_SYSTEM="ufs"
486     fi
489 if test -n "$arch_freebsd" || test -n "$arch_LINUX" || test -n "$arch_LINUX_ALPHA" || test -n "$arch_netbsd" || test -n "$arch_openbsd" ; then
490     if test -n "$arch_freebsd" || test -n "$arch_netbsd" || test -n "$arch_openbsd"; then
491         ac_cv_sizeof_long_long=${ac_cv_sizeof_long_long:-0}
492         # printf doesn't work properly and no integer*8 as far as I can tell
493     fi
494     # Find the CPP before the header check
495     AC_PROG_CPP
496     if test -z "$MPI_IMPL" ; then
497         MPI_IMPL=mpich
498         mpi_mpich=1
499     fi
500 fi    
502 if test -n "$arch_SX4" ; then
503     have_aio=no
504     AC_DEFINE(SX4,1,[Define for NEC SX4])
505     if test -z "$MPI_IMPL" ; then
506         MPI_IMPL=mpich
507         mpi_mpich=1
508     fi
509     if test -z "$FILE_SYSTEM" ; then
510         file_system_sfs=1
511         file_system_nfs=1
512         FILE_SYSTEM="sfs nfs"
513     fi
514     MPI_OFFSET_KIND1="      INTEGER MPI_OFFSET_KIND"
515     MPI_OFFSET_KIND2="      PARAMETER (MPI_OFFSET_KIND=8)"
516     MPI_OFFSET_KIND_VAL=8
519 if test -n "$arch_hpux" || test -n "$arch_sppux" ; then
520     have_aio=no
521     RANLIB=":"
522     if test -z "$MPI_IMPL"; then
523         if test -f "/opt/mpi/include/mpi.h" ; then
524             echo "assuming that you want to use ROMIO with HP MPI"
525             MPI_IMPL=hp
526         else 
527             echo "assuming that you want to use ROMIO with MPICH"
528             MPI_IMPL=mpich
529         fi            
530     fi
531     if test $MPI_IMPL = "mpich" ; then
532         mpi_mpich=1
533         MPI_LIB="$MPI_LIB -lV3"
534         CC=${CC:-cc -Ae}
535         F77=${FC:-f77 +U77}
536     fi
537     if test $MPI_IMPL = "hp" ; then
538         mpi_hp=1
539         CC=${CC:-mpicc -Ae}
540         F77=${FC:-mpif77 +U77}
541     fi
542     if test $MPI_IMPL = "lam" && test "$FC" != ""; then
543         F77="$F77 +U77"
544     fi
545     FTESTDEFINE="external iargc, getarg"
546     if test -n "$arch_hpux" ; then
547         CFLAGS="$CFLAGS -D_LARGEFILE64_SOURCE"
548         AC_DEFINE(HPUX,1,[Define for HPUX])
549         if test $MPI_IMPL = "hp" ; then
550            F77=${FC:-mpif90 +U77}
551         else
552            F77=${FC:-f90 +U77}
553         fi
554     else
555         AC_DEFINE(SPPUX,1,[Define for SPPUX (Convex)])
556     fi
558     MPI_OFFSET_KIND1="      INTEGER MPI_OFFSET_KIND"
559     MPI_OFFSET_KIND2="      PARAMETER (MPI_OFFSET_KIND=8)"
560     MPI_OFFSET_KIND_VAL=8
561     if test "$CC" != "gcc" ; then
562         ROMIO_TCFLAGS="-Ae"
563     fi
564     if test "$F77" != "g77" ; then
565         ROMIO_TFFLAGS="+U77"
566     fi
569 if test -n "$arch_alpha" || test -n "$arch_ALPHA" ; then
570     if test -z "$MPI_IMPL" ; then
571         MPI_IMPL=mpich
572         mpi_mpich=1
573     fi
575     MPI_OFFSET_KIND1="      INTEGER MPI_OFFSET_KIND"
576     MPI_OFFSET_KIND2="      PARAMETER (MPI_OFFSET_KIND=8)"
577     MPI_OFFSET_KIND_VAL=8
578     LIBS="$LIBS -laio"
579 fi    
581 if test -n "$arch_CRAY" ; then
582     NOF77=1
583     FTESTDEFINE="integer ilen"
584     F77GETARG="call pxfgetarg(i, str, ilen, ierr)"
585     have_aio=no
586     RANLIB=":"
587     AC_DEFINE(CRAY,1,[Define if Cray])
588     if test -z "$MPI_IMPL" || test -n "$mpi_sgi" ; then
589         MPI_IMPL=cray
590         mpi_cray=1
591         mpi_sgi=""
592 # above is to disable configure tests specific to SGI MPI
593         AC_DEFINE(MPISGI,1,[Define if SGI MPI])
594         AC_DEFINE(HAVE_MPI_COMBINERS,1,[Define if MPI supports datatype combiners])
595         AC_DEFINE(NO_MPI_SGI_type_is_contig,1,[Define if no types show contig])
596     fi
597 #       MPISGI needed because of error in Cray's and SGI's 
598 #       MPI_Type_get_contents (does not increment reference count).
599 #       Others needed because MPISGI needed.
601     MPI_OFFSET_KIND1="      INTEGER MPI_OFFSET_KIND"
602     MPI_OFFSET_KIND2="      PARAMETER (MPI_OFFSET_KIND=8)"
603     MPI_OFFSET_KIND_VAL=8
606 if test -n "$arch_sgi" ; then
607     arch_IRIX=1
608     ARCH=IRIX
610 if test -n "$arch_IRIX64" || test -n "$arch_IRIX32" || test -n "$arch_IRIXN32" ; then
611     arch_IRIX=1
613 if test -n "$arch_sgi5" ; then
614     arch_IRIX5=1
615     ARCH=IRIX
618 PAC_GET_SPECIAL_SYSTEM_INFO
620 # special case 'sgi5' for use on MESHINE which is much like an SGI running
621 # irix 5 with r4400 chips, but does not have 'hinv', so above code doesn't
622 # work
623 if test -n "$arch_sgi5"; then
624    osversion=5
625    cputype=4400
626    IRIXARCH="$ARCH_$osversion"
627    IRIXARCH="$IRIXARCH_$cputype"
628 # now set arch_IRIX to 1
629    arch_IRIX=1
630    echo "IRIX-specific architecture is $IRIXARCH"
631    AC_DEFINE(IRIX,1,[Define if IRIX])
634 if test -n "$arch_IRIX"; then
635    if test $osversion = 4 ; then
636         RANLIB="ar ts"
637         if test -n "$mpi_sgi"; then
638             AC_MSG_ERROR([SGI\'s MPI does not work with IRIX 4.x])
639         fi
640    elif test $osversion = 5 ; then
641         if test -n "$mpi_sgi"; then
642             AC_MSG_ERROR([SGI\'s MPI does not work with IRIX 5.x])
643         fi
644    elif test $osversion = 6 ; then
645         if test -z "$MPI_IMPL"; then
646             if test "$FROM_MPICH2" = "yes" ; then
647                 # Building with MPICH2.  Distinguish from MPICH-1
648                 MPI_IMPL=mpich2
649                 mpi_mpich2=1
650             elif test -f "/usr/include/mpi.h" ; then
651                 # removed use of escaped single quotes in messages
652                 # because they confuse Emacs, making it hard to 
653                 # read the files (with emacs :) )
654                 AC_MSG_WARN([assuming that you want to use ROMIO with the SGI MPI])
655                 MPI_IMPL=sgi
656                 mpi_sgi=1
657             else 
658                 AC_MSG_WARN([assuming that you want to use ROMIO with MPICH])
659                 MPI_IMPL=mpich
660                 mpi_mpich=1
661             fi            
662         fi
663         RANLIB=":"
664         AC_DEFINE(AIO_SIGNOTIFY_NONE,1,[Define if no signotify])
665         if test $cputype -ge 5000 ; then
666             MIPS=4
667         else 
668             MIPS=3
669         fi
670    fi
671    if test -n "$mpi_sgi" && test -z "$MPI_LIB" ; then
672        MPI_LIB="-lmpi"
673    fi
674 #  check if pread64 is defined
675    PAC_HAVE_PREAD64
677    if test -z "$FILE_SYSTEM" ; then
678        file_system_nfs=1
679        FILE_SYSTEM="nfs"
680        AC_MSG_CHECKING(for xfs)
681        AC_TRY_COMPILE([
682 #include <aio.h>],
683 [aiocb64_t *t1;],file_system_xfs=1;FILE_SYSTEM="xfs $FILE_SYSTEM";)
684        if test "$file_system_xfs" = 1 ; then 
685           AC_MSG_RESULT(yes)
686        else
687           AC_MSG_RESULT(no)
688           file_system_ufs=1
689           FILE_SYSTEM="ufs $FILE_SYSTEM"
690        fi
691    fi
692    AC_DEFINE(IRIX,1,[Define if IRIX])
693    MPI_OFFSET_KIND1="      INTEGER MPI_OFFSET_KIND"
694    MPI_OFFSET_KIND2="      PARAMETER (MPI_OFFSET_KIND=8)"
695    MPI_OFFSET_KIND_VAL=8
698 AC_HAVE_FUNCS(memalign)
701 # Question: Should ROMIO under MPICH2 ignore the Fortran tests, since 
702 # MPICH2 provides all of the Fortran interface routines?
704 if test $NOF77 = 0 ; then
705     echo "checking Fortran external names"
706     PAC_GET_FORTNAMES
707     if test -n "$WDEF" ; then
708         CFLAGS="$CFLAGS $WDEF"
709     fi
710     dnl PAC_PROG_F77_NAME_MANGLE
711     dnl (need to set the new name format)
712     rm -f test/mpif.h
713     if test "$MPI_INCLUDE_DIR" != "." && test $WITHIN_KNOWN_MPI_IMPL = no ; then
714         if test ! -d test ; then mkdir test ; fi
715         ln -s $MPI_INCLUDE_DIR/mpif.h test
716     fi
717 else 
718     F77=":"
721 AC_C_INLINE
723 # Header files
724 # Find the CPP before the header check
725 AC_PROG_CPP
726 AC_CHECK_HEADERS([unistd.h fcntl.h malloc.h stddef.h sys/types.h])
729 # When compiling ROMIO on Darwin with _POSIX_C_SOURCE defined (such as when
730 # using --enable-strict in MPICH2), sys/types.h does not define u_short and
731 # friends unless _DARWIN_C_SOURCE is also defined (see compat(5) on a Darwin
732 # box).  This would normally be fine, except sys/stat.h defines struct stat to
733 # use u_long, so strict compiles fail.  One option is to also compile with
734 # _DARWIN_C_SOURCE, but this disables much of the strictness that is intended
735 # by _POSIX_C_SOURCE.  Instead we just define our own types if they are not
736 # provided by the system.  This isn't quite as safe as typedef'ing the
737 # replacement types, but it will apply to later configure tests, which is
738 # important.
739 AC_CHECK_TYPE([u_char],[],[AC_DEFINE_UNQUOTED([u_char],[unsigned char],[Define to "unsigned char" if sys/types.h does not define.])])
740 AC_CHECK_TYPE([u_short],[],[AC_DEFINE_UNQUOTED([u_short],[unsigned short],[Define to "unsigned short" if sys/types.h does not define.])])
741 AC_CHECK_TYPE([u_int],[],[AC_DEFINE_UNQUOTED([u_int],[unsigned int],[Define to "unsigned int" if sys/types.h does not define.])])
742 AC_CHECK_TYPE([u_long],[],[AC_DEFINE_UNQUOTED([u_long],[unsigned long],[Define to "unsigned long" if sys/types.h does not define.])])
744 # must come _after_ the above checks for u_char/u_short/u_int/u_long
745 AC_CHECK_HEADERS([sys/attr.h])
747 AC_CHECK_SIZEOF(int)
748 AC_CHECK_SIZEOF(void *)
749 AC_CACHE_CHECK([for int large enough for pointers],
750 pac_cv_int_hold_pointer,[
751 if test "$ac_cv_sizeof_int" = "0" -o \
752         "$ac_cv_sizeof_void_p" = "0" ; then
753     pac_cv_int_hold_pointer=unknown
754 elif test "$ac_cv_sizeof_int" -lt "$ac_cv_sizeof_void_p" ; then
755     pac_cv_int_hold_pointer=no
756 else
757     pac_cv_int_hold_pointer=yes
760 if test "$pac_cv_int_hold_pointer" != yes ; then
761     AC_DEFINE(INT_LT_POINTER,1,[Define if int smaller than pointer])
762     dnl Switch to a conforming name (start with HAVE or USE)
763     AC_DEFINE(HAVE_INT_LT_POINTER,1,[Define if int smaller than pointer])
766 # LL is the printf-style format name for output of a MPI_Offset.
767 # We have to match this to the type that we use for MPI_Offset.
768 AC_CHECK_SIZEOF(long long)
769 if test "$ac_cv_sizeof_long_long" != 0 ; then
770     if test "$ac_cv_sizeof_long_long" = "8" ; then
771        AC_DEFINE(HAVE_LONG_LONG_64,1,[Define if long long is 64 bits])
772        MPI_OFFSET_TYPE="long long"
773        DEFINE_MPI_OFFSET="typedef long long MPI_Offset;"
774        FORTRAN_MPI_OFFSET="integer*8"
775        LL="lld"
776     elif test "$ac_cv_sizeof_long_long" = "$ac_cv_sizeof_int" ; then
777        MPI_OFFSET_TYPE="int"
778        DEFINE_MPI_OFFSET="typedef int MPI_Offset;"
779        FORTRAN_MPI_OFFSET="integer"
780        AC_DEFINE(MPI_OFFSET_IS_INT,1,[Define if MPI_Offset is int])
781        LL="d"
782        MPI_OFFSET_KIND1="!"
783        MPI_OFFSET_KIND2="!"
784     else
785        echo "defining MPI_Offset as long in C and integer in Fortran" 
786        MPI_OFFSET_TYPE="long"
787        DEFINE_MPI_OFFSET="typedef long MPI_Offset;"
788        FORTRAN_MPI_OFFSET="integer"
789        LL="ld"
790        MPI_OFFSET_KIND1="!"
791        MPI_OFFSET_KIND2="!"
792     fi
793 else
794     echo "defining MPI_Offset as long in C and integer in Fortran" 
795     MPI_OFFSET_TYPE="long"
796     DEFINE_MPI_OFFSET="typedef long MPI_Offset;"
797     FORTRAN_MPI_OFFSET="integer"
798     LL="ld"
799     MPI_OFFSET_KIND1="!"
800     MPI_OFFSET_KIND2="!"
805 if test -n "$ac_cv_sizeof_long_long"; then
806    if test $WITHIN_KNOWN_MPI_IMPL = no ; then
807        PAC_MPI_LONG_LONG_INT
808    else
809        AC_DEFINE(HAVE_MPI_LONG_LONG_INT,1,[Define if supports long long int])
810    fi
813 if test -n "$OFFSET_KIND" -a "A$MPI_OFFSET_KIND1" = "A!" ; then 
814   MPI_OFFSET_KIND1="        INTEGER MPI_OFFSET_KIND"
815   MPI_OFFSET_KIND2="        PARAMETER (MPI_OFFSET_KIND=$OFFSET_KIND)"
816   MPI_OFFSET_KIND_VAL=$OFFSET_KIND
817 else
818  if test "$FORTRAN_MPI_OFFSET" = "integer*8" && test "A$MPI_OFFSET_KIND2" = "A!" && test $NOF77 = 0 && test $NOF90 = 0 ; then
819    PAC_MPI_OFFSET_KIND
820  fi
822   if test "$FORTRAN_MPI_OFFSET" = "integer" && test "A$MPI_OFFSET_KIND2" = "A!" && test $NOF77 = 0 && test $NOF90 = 0 ; then
823    PAC_MPI_OFFSET_KIND_4BYTE
824   fi
827 # Test that we can use the FORTRAN_MPI_OFFSET type.  If the environment
828 # is a strict Fortran 90/95 or later compiler, the "integer*8" format
829 # may not work.
830 if test "$NOF77" = 0 ; then
831     rm -f conftest*
832     ac_cv_f77_offset_type_works=no
833     AC_MSG_CHECKING([that we can use $FORTRAN_MPI_OFFSET to declare MPI_DISPLACMENT_CURRENT])
834     cat >conftest.f <<EOF
835         program main
836         $FORTRAN_MPI_OFFSET j
837         end
839     if $F77 -o conftest$EXEEXT conftest.f >>config.log 2>&1 && test -x conftest$EXEEXT ; then
840         ac_cv_f77_offset_type_works=yes
841     fi
842     rm -f conftest*
843     AC_MSG_RESULT($ac_cv_f77_offset_type_works)
845     if test "$ac_cv_f77_offset_type_works" != "yes" -a -n "$MPI_OFFSET_KIND_VAL"; then
846         AC_MSG_CHECKING([whether we can use KIND with the selected F77 compiler $F77])
847         ac_cv_f77_allows_offset_kind=no
848         rm -f conftest*
849         cat >conftest.f <<EOF
850         program main
851         integer (kind=$MPI_OFFSET_KIND_VAL) j
852         end
854         if $F77 -o conftest$EXEEXT conftest.f >>config.log 2>&1 && test -x conftest$EXEEXT ; then
855             ac_cv_f77_allows_offset_kind=yes
856         fi
857         rm -f conftest*
858         AC_MSG_RESULT($ac_cv_f77_allows_offset_kind)
859         if test "$ac_cv_f77_allows_offset_kind" ; then
860              FORTRAN_MPI_OFFSET="integer (kind=$MPI_OFFSET_KIND_VAL)"
861         else
862              AC_MSG_WARN([Could not find a way to declare an integer type corresponding to MPI_Offset in Fortran.])
863         fi
864     fi
868 # check if MPI_Info functions are defined in the MPI implementation
869 if test $WITHIN_KNOWN_MPI_IMPL = no ; then
870    PAC_MPI_INFO
871 else
872    AC_DEFINE(HAVE_MPI_INFO,1,[Define if MPI Info is available])
873    HAVE_MPI_INFO="#define HAVE_MPI_INFO"
874    MPI_FINFO1="!"
875    MPI_FINFO2="!"
876    MPI_FINFO3="!"
877    MPI_FINFO4="!"
878 fi   
880 if test -n "$mpi_sgi"; then
881 dnl   if test -z "$HAVE_MPI_INFO" ; then
882 dnl      PAC_CHECK_MPI_SGI_INFO_NULL  # is MPI_INFO_NULL defined in mpi.h?
883 dnl   fi
884    PAC_TEST_MPI_SGI_type_is_contig
885    PAC_TEST_MPI_COMBINERS
886    PAC_TEST_MPI_HAVE_OFFSET_KIND
889 # check if darray and subarray constructors are defined in the MPI 
890 # implementation 
891 if test $WITHIN_KNOWN_MPI_IMPL = no ; then
892    PAC_MPI_DARRAY_SUBARRAY
894 if test $FROM_MPICH2 = yes ; then
895    dnl Made this a message instead of a warning because the warning is
896    dnl likely to confuse users.
897    AC_MSG_RESULT([Overriding Array test for MPICH2])
898    unset BUILD_MPI_ARRAY
899    AC_DEFINE(HAVE_MPI_DARRAY_SUBARRAY,1,[Define if Darray is available])
900    HAVE_MPI_DARRAY_SUBARRAY="#define HAVE_MPI_DARRAY_SUBARRAY"
901    MPI_FARRAY1="!"
902    MPI_FARRAY2="!"
903    MPI_FARRAY3="!"
904    MPI_FARRAY4="!"
905    MPI_FARRAY5="!"
906    MPI_FARRAY6="!"
907    MPI_FARRAY7="!"
908 fi   
911 # Test for weak symbol support...
912 # We can't put # in the message because it causes autoconf to generate
913 # incorrect code
914 HAVE_WEAK_SYMBOLS=0
915 if test -n "$arch_hpux" || test -n "$arch_sppux" ; then
916 # multiple secondary definitions not allowed by HP compilers
917 # Fortran interface for HP already uses one secondary defn. 
918 # therefore, do not use this method for profiling interface.
919 # build profiling interface explicitly.
920    TRY_WEAK_SYMBOLS=0
922 if test $TRY_WEAK_SYMBOLS = 1 ; then
923   AC_MSG_CHECKING([for weak symbol support])
924   AC_TRY_LINK([
925 extern int PFoo(int);
926 #pragma weak PFoo = Foo
927 int Foo(int a) { return a; }
928 ],[return PFoo(1);],has_pragma_weak=1)
929   #
930   # Some systems (Linux ia64 and ecc, for example), support weak symbols
931   # only within a single object file!  This tests that case.
932   # Note that there is an extern int PFoo declaration before the
933   # pragma.  Some compilers require this in order to make the weak symbol
934   # extenally visible.  
935 if test "$has_pragma_weak" = 1 ; then
936     AC_MSG_RESULT([pragma weak])
937     AC_MSG_CHECKING([that weak symbols are visible to other files])
938     rm -f conftest*
939     cat >>conftest1.c <<EOF
940 extern int PFoo(int);
941 #pragma weak PFoo = Foo
942 int Foo(int);
943 int Foo(int a) { return a; }
945     cat >>conftest2.c <<EOF
946 extern int PFoo(int);
947 int main(int argc, char **argv) {
948 return PFoo(0);}
950     ac_link2='${CC-cc} -o conftest$EXEEXT $CFLAGS $CPPFLAGS $LDFLAGS conftest1.c conftest2.c $LIBS >conftest.out 2>&1'
951     if eval $ac_link2 ; then
952         AC_MSG_RESULT(yes)
953         AC_MSG_CHECKING([that the compiler correctly implements weak symbols])
954         # The gcc 3.4.x compiler accepts the pragma weak, but does not
955         # correctly implement it on systems where the loader doesn't 
956         # support weak symbols (e.g., cygwin).  This is a bug in gcc, but it
957         # it is one that *we* have to detect.
958         rm -f conftest*
959         cat >>conftest1.c <<EOF
960 extern int PFoo(int);
961 #pragma weak PFoo = Foo
962 int Foo(int);
963 int Foo(int a) { return a; }
965     cat >>conftest2.c <<EOF
966 extern int Foo(int);
967 int PFoo(int a) { return a+1;}
968 int main(int argc, char **argv) {
969 return Foo(0);}
971         if eval $ac_link2 ; then
972             AC_MSG_RESULT(yes)
973             has_pragma_weak=1
974         else 
975             AC_MSG_RESULT(no)
976             echo "$ac_link2" >> config.log
977             echo "Failed program was" >> config.log
978             cat conftest1.c >>config.log
979             cat conftest2.c >>config.log
980             if test -s conftest.out ; then cat conftest.out >> config.log ; fi
981             has_pragma_weak=0
982         fi
983     else
984       echo "$ac_link2" 1>&AC_FD_CC
985       echo "Failed program was" 1>&AC_FD_CC
986       cat conftest1.c 1>&AC_FD_CC
987       cat conftest2.c 1>&AC_FD_CC
988       if test -s conftest.out ; then cat conftest.out 1>&AC_FD_CC ; fi
989       AC_MSG_RESULT(no)
990       has_pragma_weak=0
991     fi
992     rm -f conftest*
993   fi
994   if test "$has_pragma_weak" = 1 ; then
995     HAVE_WEAK_SYMBOLS=1
996     AC_DEFINE(HAVE_PRAGMA_WEAK,1,[Define if pragma weak available])
997   else
998     AC_TRY_LINK([
999 extern int PFoo(int);
1000 #pragma _HP_SECONDARY_DEF Foo PFoo
1001 int Foo(int a) { return a; }
1002 ],[return PFoo(1);],has_pragma_hp_secondary=1)
1003     if test "$has_pragma_hp_secondary" = 1 ; then 
1004         AC_MSG_RESULT([pragma _HP_SECONDARY_DEF])
1005         HAVE_WEAK_SYMBOLS=1
1006         AC_DEFINE(HAVE_PRAGMA_HP_SEC_DEF,1,[Define for HP weak pragma])
1007     else
1008         AC_TRY_LINK([
1009 extern int PFoo(int);
1010 #pragma _CRI duplicate PFoo as Foo
1011 int Foo(int a) { return a; }
1012 ],[return PFoo(1);],has_pragma_cri_duplicate=1)
1013         if test "$has_pragma_cri_duplicate" = 1 ; then
1014             AC_MSG_RESULT([pragma _CRI duplicate x as y])
1015             HAVE_WEAK_SYMBOLS=1
1016             AC_DEFINE(HAVE_PRAGMA_CRI_DUP,1,[Define for CRAY weak dup])
1017         else    
1018             AC_MSG_RESULT(no)
1019         fi
1020     fi
1021   fi
1023 if test "$HAVE_WEAK_SYMBOLS" = 1 ; then
1024     AC_DEFINE(HAVE_WEAK_SYMBOLS,1,[Define if weak symbols available])
1026 AC_SUBST(HAVE_WEAK_SYMBOLS)
1031 # Check whether the MPI Offset type is compatible with struct flock
1032 AC_MSG_CHECKING([whether struct flock compatible with MPI_Offset])
1033 AC_TRY_COMPILE([#include <fcntl.h>],
1034 [struct flock l;
1035  $MPI_OFFSET_TYPE a=1;
1036  l.l_start = a; 
1037  l.l_len   = a;
1038 ],pac_cv_struct_flock_and_mpi_offset=yes,pac_cv_struct_flock_and_mpi_offset=no)
1039 AC_MSG_RESULT($pac_cv_struct_flock_and_mpi_offset)
1040 # FIXME: We should look for struct flock64 and the F_SETLK64/F_GETLK64
1041 # ADIOI_Set_lock could use these instead.
1042 if test "$pac_cv_struct_flock_and_mpi_offset" = no ; then
1043     AC_MSG_CHECKING([whether struct flock compatible with int])
1044     AC_TRY_COMPILE([#include <fcntl.h>],
1045 [struct flock l;
1046  int a=1;
1047  l.l_start = a; 
1048  l.l_len   = a;
1049 ],pac_cv_struct_flock_and_int=yes,pac_cv_struct_flock_and_int=no)
1050     AC_MSG_RESULT($pac_cv_struct_flock_and_int)
1051     if test "$pac_cv_struct_flock_and_int" = yes ; then
1052         AC_DEFINE(NEEDS_INT_CAST_WITH_FLOCK,1,[Define if l_start and l_len data should be cast as int])
1053     fi
1054     # FIXME.  Solaris header files define off_t as a UNION if 64bit file
1055     # sizes are selected.  Gah!
1059 # if FILE_SYSTEM is not set above, use ufs and nfs as default
1061 if test -z "$FILE_SYSTEM" ; then
1062     file_system_ufs=1
1063     file_system_nfs=1
1064     FILE_SYSTEM="ufs nfs"
1067 # no matter what, always build testfs
1068 file_system_testfs=1
1069 FILE_SYSTEM="testfs $FILE_SYSTEM"
1071 # An attempt to "do the right thing" with as little help from the end-user as
1072 # possible:
1073 # - if 'with-pvfs2' given, use that to find pvfs2-config.  complain if we
1074 #   cannot find it, as this is probably what the user would expect
1075 # - if we can find 'pvfs2-config' in our path, we can use it to set CFLAGS,
1076 #   LIBS, and LDFLAGS accordingly
1077 # - as a fallback, use CFLAGS, LIBS, and LDFLAGS passed in by the user
1078 # - don't do any of this if --with-file-system was given and did not include
1079 #   'pvfs2': i.e. don't surprise the user with pvfs support.
1081 AC_PATH_PROG(PVFS2_CONFIG, pvfs2-config, notfound, [${with_pvfs2}/bin:$PATH])
1082 if test $PVFS2_CONFIG != "notfound" ; then
1083         if test -n "${with_pvfs2}" -o -n "${file_system_pvfs2}" ; then
1084                 # the user either told us where pvfs is or asked for it in
1085                 # --with-file-system (or both)
1086                 CFLAGS="$CFLAGS $( $PVFS2_CONFIG --cflags)"
1087                 LIBS="$LIBS $( $PVFS2_CONFIG --libs)"
1088                 FILE_SYSTEM="pvfs2 $FILE_SYSTEM"
1089                 file_system_pvfs2=1
1090         fi
1093 if test "$PVFS2_CONFIG" = "notfound" -a -n "$with_pvfs2" ; then
1094         AC_MSG_ERROR([pvfs2-config not found in $with_pvfs2])
1098 # Print list of configured file systems
1100 # TODO: REMOVE BAD ONES FROM THE LIST SOMEHOW?
1102 AC_MSG_CHECKING([configured file systems])
1103 AC_MSG_RESULT([$FILE_SYSTEM])
1105 if test -n "$file_system_nfs" ; then
1106     AC_DEFINE(ROMIO_NFS,1,[Define for ROMIO with NFS])
1107     AC_MSG_WARN([File locks may not work with NFS.  See the Installation and
1108 users manual for instructions on testing and if necessary fixing this])
1111 if test -n "$file_system_panfs"; then
1112     AC_DEFINE(ROMIO_PANFS,1,[Define for ROMIO with PANFS])
1114 if test -n "$file_system_ufs"; then
1115     AC_DEFINE(ROMIO_UFS,1,[Define for ROMIO with UFS])
1117 if test -n "$file_system_bgl"; then     
1118     AC_DEFINE(ROMIO_BGL,1,[Define for ROMIO with BGL])
1120 if test -n "$file_system_bglockless"; then
1121     if test x"$file_system_bgl" = x ; then
1122             AC_MSG_ERROR("bglockless requested without bgl")
1123     fi
1124     AC_DEFINE(ROMIO_BGLOCKLESS,1,[Define for lock-free ROMIO with BGL])
1126 if test -n "$file_system_hfs"; then
1127     AC_DEFINE(ROMIO_HFS,1,[Define for ROMIO with HFS])
1129 if test -n "$file_system_sfs"; then
1130     AC_DEFINE(ROMIO_SFS,1,[Define for ROMIO with SFS])
1133 if test -n "$file_system_pfs"; then
1134     AC_DEFINE(ROMIO_PFS,1,[Define for ROMIO with PFS])
1137 if test -n "$file_system_testfs"; then
1138     AC_DEFINE(ROMIO_TESTFS,1,[Define for ROMIO with TESTFS])
1141 # Verify presence of lustre/lustre_user.h
1143 if test -n "$file_system_lustre"; then
1144     AC_CHECK_HEADERS(lustre/lustre_user.h,
1145         AC_DEFINE(ROMIO_LUSTRE,1,[Define for ROMIO with LUSTRE]),
1146         AC_MSG_ERROR([LUSTRE support requested but cannot find lustre/lustre_user.h header file])                                        
1147     )
1150 if test -n "$file_system_xfs"; then
1151     AC_DEFINE(ROMIO_XFS,1,[Define for ROMIO with XFS])
1152     # Check for memalign value
1153     AC_CACHE_CHECK([for memory alignment needed for direct I/O],
1154     pac_cv_memalignval,
1155     [
1156     rm -f confmemalignval
1157     rm -f /tmp/romio_tmp.bin
1158     AC_TRY_RUN([
1159 #include <stdio.h>
1160 #include <unistd.h>
1161 #include <fcntl.h>
1162 #include <stdio.h>
1163 int main(int argc, char **argv) { 
1164         struct dioattr st;
1165         int fd = open("/tmp/romio_tmp.bin", O_RDWR | O_CREAT, 0644);
1166         FILE *f=fopen("confmemalignval","w");
1167         if (fd == -1) exit(1);
1168         if (!f) exit(1);
1169         fcntl(fd, F_DIOINFO, &st);
1170         fprintf( f, "%u\n", st.d_mem);
1171         exit(0);
1172         }
1173         ],
1174         pac_cv_memalignval=`cat confmemalignval`,
1175         pac_cv_memalignval="unknown",pac_cv_memalignval="unknown"
1176     )
1177     rm -f confmemalignval
1178     rm -f /tmp/romio_tmp.bin
1179     ])
1180     if test -n "$pac_cv_memalignval" -a "$pac_cv_memalignval" != 0 -a \
1181         "$pac_cv_memalignval" != "unknown" ; then
1182         CFLAGS="$CFLAGS -DXFS_MEMALIGN=$pac_cv_memalignval"
1183     else
1184         AC_MSG_RESULT(assuming 128 for memory alignment)
1185         CFLAGS="$CFLAGS -DXFS_MEMALIGN=128"
1186     fi
1190 # Verify presence of pvfs.h, issue with int64
1192 if test -n "$file_system_pvfs"; then
1193     CPPFLAGS="$CPPFLAGS $CFLAGS"
1194     AC_CHECK_HEADERS(pvfs.h,
1195         AC_DEFINE(ROMIO_PVFS,1,[Define for ROMIO with PVFS]),
1196         AC_MSG_ERROR([PVFS support requested but cannot find pvfs.h header file])
1197         )
1198     # Check for missing int64_t (intel version 8 compiler and -no-gcc
1199     # selected)
1200     AC_MSG_CHECKING([that pvfs.h can be compiled])
1201     AC_TRY_COMPILE([
1202 #include <pvfs.h>
1203         ],[
1204         ],pvfs_header_ok=yes,pvfs_header_ok=no
1205     )
1206     AC_MSG_RESULT($pvfs_header_ok)
1207     if test "$pvfs_header_ok" = no -a "$ac_cv_sizeof_long_long" = 8 ; then
1208         AC_MSG_CHECKING([if pvfs.h can be compiled if we define int64_t])
1209         # Try again, but with int64_t
1210         AC_TRY_COMPILE([
1211             typedef long long int int64_t;
1212 #include <pvfs.h>
1213             ],[
1214             ],
1215             pvfs_header_ok="yes with int64 definition"
1216         )
1217         AC_MSG_RESULT($pvfs_header_ok)
1218     fi
1219     if test "$pvfs_header_ok" = "yes with int64 definition" ; then
1220         AC_DEFINE(ROMIO_PVFS_NEEDS_INT64_DEFINITION,1,[Define if int64_t must be defined for PVFS])
1221     fi
1222     if test "$pvfs_header_ok" != "no" ; then
1223         AC_DEFINE(ROMIO_PVFS,1,[Define for ROMIO with PVFS])
1224         AC_DEFINE(HAVE_PVFS_SUPER_MAGIC, 1, [Define if PVFS_SUPER_MAGIC defined.])
1225     else
1226         AC_MSG_WARN(missing or broken pvfs.h header file; disabling ROMIO PVFS support)
1227     fi
1232 if test -n "$file_system_zoidfs"; then
1233         AC_CHECK_HEADERS(zoidfs.h,
1234                 AC_DEFINE(ROMIO_ZOIDFS,1,[Define for ROMIO with ZoidFD]),
1235                 AC_MSG_ERROR([ZoidFS support requested but cannot find zoidfs.h header file])
1236         )
1240 # Verify presence of pvfs2.h
1242 if test -n "$file_system_pvfs2"; then
1243     CPPFLAGS="$CPPFLAGS $CFLAGS"
1244     AC_CHECK_HEADERS(pvfs2.h,
1245         AC_DEFINE(ROMIO_PVFS2,1,[Define for ROMIO with PVFS2])
1246         AC_DEFINE(HAVE_PVFS2_SUPER_MAGIC, 1, [Define if PVFS2_SUPER_MAGIC defined.]),
1247         AC_MSG_ERROR([PVFS2 support requested but cannot find pvfs2.h header file])                                        
1248     )
1251 # layout change after pvfs-2.6.3:
1252 if test -n "$file_system_pvfs2"; then
1253     AC_COMPILE_IFELSE([
1254         AC_LANG_SOURCE([
1255 #include <stdlib.h>
1256 #include "pvfs2.h"
1257           int main(int argc, char **argv) { 
1258               PVFS_object_ref ref;
1259               PVFS_sys_attr attr;
1260               PVFS_sys_create(NULL, ref, attr, NULL, NULL, NULL, NULL); 
1261           return 0; }
1262        ])],
1263        , AC_DEFINE(HAVE_PVFS2_CREATE_WITHOUT_LAYOUT, 1, 
1264                 [Define if PVFS_sys_create does not have layout parameter])
1265        )
1269 if test -n "$file_system_gridftp"; then
1270         AC_DEFINE(ROMIO_GRIDFTP, 1, [Define for ROMIO with gridftp])
1273 if test -n "$file_system_bgl"; then
1274     SYSDEP_INC=-I${prefix}/include
1275 else
1276     SYSDEP_INC=
1278 # Check for presence and characteristics of async. I/O calls if
1279 # not disabled.
1281 # Some systems need pthreads to get AIO to work.  However, we don't want
1282 # to add pthreads just because it is there, as that can cause problems
1283 # with some implementations of pthreads and compilers (e.g., gcc version 3
1284 # would fail if there was an int a[100000] on the stack if the application
1285 # was *linked* with pthreads, but would succeed if the application was
1286 # *not linked* with pthreads.
1288 if test "x$disable_aio" = "xno" ; then
1289     AC_SEARCH_LIBS(aio_write,aio rt,aio_write_found=yes,aio_write_found=no)
1290     if test "$aio_write_found" = no ; then
1291         # If not found, try finding pthread_create first, and if
1292         # found, try the test again.
1293         AC_SEARCH_LIBS(pthread_create,pthread,foundPTHREAD=yes,foundPTHREAD=no)
1294         if test "$foundPTHREAD" = yes ; then
1295             AC_SEARCH_LIBS(aio_write,aio rt,aio_write_found=yes,aio_write_found=no)
1296         fi
1297     fi
1300 if test "x$disable_aio" = "xno" -a -n "$aio_write_found" ; then
1301     AC_CHECK_HEADERS(signal.h)
1302     # Just because aio.h is found by CPP doesn't mean that we can use it
1303     # We try to compile it, not just read it.
1304     AC_MSG_CHECKING([if aio.h exists and can be compiled])
1305     AC_TRY_COMPILE([
1306 #include <sys/types.h>
1307 #include <aio.h>],
1308 [],have_aio_h=yes,have_aio_h=no)
1309     AC_MSG_RESULT($have_aio_h)
1310     if test "$have_aio_h" = yes ; then
1311         AC_DEFINE(HAVE_AIO_H,1,[Define if aio.h exists and can be compiled])
1312     fi
1314     AC_MSG_CHECKING([if sys/aio.h exists and can be compiled])
1315     AC_TRY_COMPILE([
1316 #include <sys/types.h>
1317 #include <sys/aio.h>],
1318 [],have_sys_aio_h=yes,have_sys_aio_h=no)
1319     AC_MSG_RESULT($have_sys_aio_h)
1320     if test "$have_sys_aio_h" = yes ; then
1321         AC_DEFINE(HAVE_SYS_AIO_H,1,[Define if sys/aio.h exists and can be compiled])
1322     fi
1323     if test "$have_aio_h" = "no" -a "$have_sys_aio_h" = "no" ; then
1324         disable_aio=yes
1325     fi
1328 if test "$have_aio_h" = "yes" -o "$have_sys_aio_h" = "yes" -o "x$disable_aio" = "xno"; then
1330     # Check that aio is available (many systems appear to have aio
1331     # either installed improperly or turned off).
1332     # The test is the following: if not cross compiling, try to run a 
1333     # program that includes a *reference* to aio_write but does not call it
1334     # If the libraries are not set up correctly, then this will fail.
1336     AC_MSG_CHECKING([whether aio routines can be used])
1337     # Include aio.h and the aiocb struct (since we'll need these to 
1338     # actually use the aio_write interface).  Note that this will 
1339     # fail for some pre-POSIX implementations of the aio interface 
1340     # (an old IBM interface needs an fd argument as well)
1341     AC_TRY_RUN([
1342 #include <sys/types.h>
1343 #ifdef HAVE_SIGNAL_H
1344 #include <signal.h>
1345 #endif
1346 #ifdef HAVE_AIO_H
1347 #include <aio.h>
1348 #endif
1349 #ifdef HAVE_SYS_AIO_H
1350 #include <sys/aio.h>
1351 #endif
1352         int main(int argc, char **argv)
1353         {
1354             struct aiocb *aiocbp;
1355             if (argc > 10) aio_write(aiocbp);
1356             return 0;
1357         }
1358         ],
1359         aio_runs=yes
1360         AC_MSG_RESULT(yes),
1361         aio_runs=no
1362         AC_MSG_RESULT(no),
1363         aio_runs=no
1364         AC_MSG_RESULT(no: aio routines disabled when cross compiling)
1365     )
1366     if test "$aio_runs" != "no" ; then
1367         AC_DEFINE(ROMIO_HAVE_WORKING_AIO, 1, Define if AIO calls seem to work)
1368     fi
1369     
1370     # now about that old IBM interface...
1371     # modern AIO interfaces have the file descriptor in the aiocb structure,
1372     # and will set ROMIO_HAVE_STRUCT_AIOCB_WITH_AIO_FILDES.  Old IBM
1373     # implementations pass the file descriptor as an argument to aio_write and
1374     # aio_read.  AIO still works on these platforms, but we have to test with
1375     # two-argument aio_write to avoid a false negative.  no need to worry about
1376     # the two-argument vs. one-argument aio_write and aio_read: ROMIO already
1377     # uses ROMIO_HAVE_STRUCT_AIOCB_WITH_AIO_FILDES to call aio_write and
1378     # aio_read correctly
1380     AC_MSG_CHECKING([for obsolete two-argument aio_write])
1381     AC_TRY_RUN([
1382 #include <sys/types.h>
1383 #ifdef HAVE_SIGNAL_H
1384 #include <signal.h>
1385 #endif
1386 #ifdef HAVE_AIO_H
1387 #include <aio.h>
1388 #endif
1389 #ifdef HAVE_SYS_AIO_H
1390 #include <sys/aio.h>
1391 #endif
1392         int main(int argc, char **argv)
1393         {
1394                 int fd;
1395                 struct aiocb *aiocbp;
1396                 if (argc > 10) aio_write(fd, aiocbp);
1397                 return 0;
1398         }
1399         ],
1400         aio_two_arg_write=yes
1401         AC_MSG_RESULT(yes),
1402         aio_two_arg_write=no 
1403         AC_MSG_RESULT(no),
1404         aio_two_arg_write=no
1405         AC_MSG_RESULT(no: cannot test when cross-compiling)
1406     )
1408     if test "$aio_two_arg_write" != "no" -a "$aio_runs" != "yes" ; then
1409         AC_DEFINE(ROMIO_HAVE_WORKING_AIO, 1, Define if AIO calls seem to work)
1410         AC_DEFINE(ROMIO_HAVE_AIO_CALLS_NEED_FILEDES, 1, Define if AIO calls need file descriptor)
1411     fi
1413     AC_MSG_CHECKING([for obsolete two-argument aio_suspend])
1414     AC_TRY_RUN([
1415 #include <sys/types.h>
1416 #ifdef HAVE_SIGNAL_H
1417 #include <signal.h>
1418 #endif
1419 #ifdef HAVE_AIO_H
1420 #include <aio.h>
1421 #endif
1422 #ifdef HAVE_SYS_AIO_H
1423 #include <sys/aio.h>
1424 #endif
1425         int main(int argc, char **argv)
1426         {
1427                 struct aiocb *aiocbp;
1428                 if (argc > 10) aio_suspend(1, &aiocbp);
1429                 return 0;
1430         }
1431         ],
1432         aio_two_arg_suspend=yes
1433         AC_MSG_RESULT(yes),
1434         aio_two_arg_suspend=no 
1435         AC_MSG_RESULT(no),
1436         aio_two_arg_suspend=no
1437         AC_MSG_RESULT(no: cannot test when cross compiling)
1438     )
1440     if test "$aio_two_arg_suspend" != "no" -a "$aio_runs" != "yes" ; then
1441         AC_DEFINE(ROMIO_HAVE_AIO_SUSPEND_TWO_ARGS, 1, Define if aio_suspend needs two arguments)
1442     fi
1444     AC_MSG_CHECKING([for aio_fildes member of aiocb structure])
1445     AC_TRY_COMPILE([
1446 #ifdef HAVE_SIGNAL_H
1447 #include <signal.h>
1448 #endif
1449 #ifdef HAVE_SYS_TYPES_H
1450 #include <sys/types.h>
1451 #endif
1452 #ifdef HAVE_AIO_H
1453 #include <aio.h>
1454 #endif
1455 #ifdef HAVE_SYS_AIO_H
1456 #include <sys/aio.h>
1457 #endif
1458         ],[
1459         struct aiocb a;
1460         a.aio_fildes = 0;
1461         ],
1462         AC_MSG_RESULT(yes)
1463         AC_DEFINE(ROMIO_HAVE_STRUCT_AIOCB_WITH_AIO_FILDES, 1, [Define if aiocb has aio_fildes member]),
1464         AC_MSG_RESULT(no)
1465     )
1466     AC_MSG_CHECKING(for aio_whence member of aiocb structure)
1467     AC_TRY_COMPILE([
1468 #ifdef HAVE_SIGNAL_H
1469 #include <signal.h>
1470 #endif
1471 #ifdef HAVE_SYS_TYPES_H
1472 #include <sys/types.h>
1473 #endif
1474 #ifdef HAVE_AIO_H
1475 #include <aio.h>
1476 #endif
1477 #ifdef HAVE_SYS_AIO_H
1478 #include <sys/aio.h>
1479 #endif
1480 #include <sys/types.h>
1481 #include <unistd.h>
1482         ],[
1483         struct aiocb a;
1484         a.aio_whence = SEEK_SET;
1485         ],
1486         AC_MSG_RESULT(yes)
1487         AC_DEFINE(ROMIO_HAVE_STRUCT_AIOCB_WITH_AIO_WHENCE, 1, [Define if aiocb has aio_whence member]),
1488         AC_MSG_RESULT(no)
1489     )
1490     AC_MSG_CHECKING(for aio_handle member of aiocb structure)
1491     AC_TRY_COMPILE([
1492 #ifdef HAVE_SIGNAL_H
1493 #include <signal.h>
1494 #endif
1495 #ifdef HAVE_SYS_TYPES_H
1496 #include <sys/types.h>
1497 #endif
1498 #ifdef HAVE_AIO_H
1499 #include <aio.h>
1500 #endif
1501 #ifdef HAVE_SYS_AIO_H
1502 #include <sys/aio.h>
1503 #endif
1504         ],[
1505         struct aiocb a;
1506         aio_handle_t h;
1508         a.aio_handle = h;
1509         ],
1510         AC_MSG_RESULT(yes)
1511         AC_DEFINE(ROMIO_HAVE_STRUCT_AIOCB_WITH_AIO_HANDLE, 1, [Define if aiocb has aio_handle member]),
1512         AC_MSG_RESULT(no)
1513     )
1514     AC_MSG_CHECKING(for aio_reqprio member of aiocb structure)
1515     AC_TRY_COMPILE([
1516 #ifdef HAVE_SIGNAL_H
1517 #include <signal.h>
1518 #endif
1519 #ifdef HAVE_SYS_TYPES_H
1520 #include <sys/types.h>
1521 #endif
1522 #ifdef HAVE_AIO_H
1523 #include <aio.h>
1524 #endif
1525 #ifdef HAVE_SYS_AIO_H
1526 #include <sys/aio.h>
1527 #endif
1528         ],[
1529         struct aiocb a;
1531         a.aio_reqprio = 0;
1532         ],
1533         AC_MSG_RESULT(yes)
1534         AC_DEFINE(ROMIO_HAVE_STRUCT_AIOCB_WITH_AIO_REQPRIO, 1, [Define if aiocb has aio_reqprio member]),
1535         AC_MSG_RESULT(no)
1536     )   
1537     AC_MSG_CHECKING(for aio_sigevent member of aiocb structure)
1538     AC_TRY_COMPILE([
1539 #ifdef HAVE_SIGNAL_H
1540 #include <signal.h>
1541 #endif
1542 #ifdef HAVE_SYS_TYPES_H
1543 #include <sys/types.h>
1544 #endif
1545 #ifdef HAVE_AIO_H
1546 #include <aio.h>
1547 #endif
1548 #ifdef HAVE_SYS_AIO_H
1549 #include <sys/aio.h>
1550 #endif
1551         ],[
1552         struct aiocb a;
1554         a.aio_sigevent.sigev_signo = 0;
1555         ],
1556         AC_MSG_RESULT(yes)
1557         AC_DEFINE(ROMIO_HAVE_STRUCT_AIOCB_WITH_AIO_SIGEVENT, 1, [Define if aiocb has aio_sigevent member]),
1558         AC_MSG_RESULT(no)
1559     )
1560         
1563 # End of aio-related tests
1566 # Check for statfs (many) and specifically f_fstypename field (BSD)
1568 AC_CHECK_HEADERS(sys/vfs.h sys/param.h sys/mount.h sys/statvfs.h)
1569 AC_MSG_CHECKING([whether struct statfs properly defined])
1570 AC_TRY_COMPILE([
1571 #ifdef HAVE_SYS_VFS_H
1572 #include <sys/vfs.h>
1573 #endif
1574 #ifdef HAVE_SYS_STATVFS_H
1575 #include <sys/statvfs.h>
1576 #endif
1577 #ifdef HAVE_SYS_PARAM_H
1578 #include <sys/param.h>
1579 #endif
1580 #ifdef HAVE_SYS_MOUNT_H
1581 #include <sys/mount.h>
1582 #endif
1583     ],[
1584     struct statfs f;
1585     ],
1586     pac_cv_have_statfs=yes,pac_cv_have_statfs=no
1588 AC_MSG_RESULT($pac_cv_have_statfs)
1589 # At this point, we could check for whether defining 
1590 # __SWORD_TYPE as sizet_t or int/long (size of pointer)
1591 # would help.  FIXME
1593 if test "$pac_cv_have_statfs" = yes ; then
1594     AC_DEFINE(HAVE_STRUCT_STATFS,1,[Define if struct statfs can be compiled])
1596           
1597 AC_MSG_CHECKING([for f_fstypename member of statfs structure])
1598 AC_TRY_COMPILE([
1599 #include <sys/param.h>
1600 #include <sys/mount.h>
1601 #include <string.h>
1602     ],[
1603     struct statfs f;
1604     memset(&f, 0, sizeof(f));
1605     strncmp("nfs", f.f_fstypename, 3);
1606     ],
1607     pac_cv_have_statfs_f_fstypename=yes,
1608     pac_cv_have_statfs_f_fstypename=no
1610 AC_MSG_RESULT($pac_cv_have_statfs_f_fstypename)
1611 if test $pac_cv_have_statfs_f_fstypename = yes ; then
1612     AC_DEFINE(ROMIO_HAVE_STRUCT_STATFS_WITH_F_FSTYPENAME, 1,[Define if statfs has f_fstypename])
1616 # Check for stat and st_fstype field (NEC SX4)
1618 AC_CHECK_HEADERS(sys/stat.h sys/types.h unistd.h)
1619 AC_CHECK_FUNCS(stat,
1620     AC_DEFINE(HAVE_STAT, 1, Define if stat function is present)
1621     AC_MSG_CHECKING([for st_fstype member of stat structure])
1622     AC_TRY_COMPILE([
1623 #ifdef HAVE_SYS_TYPES_H
1624 #include <sys/types.h>
1625 #endif
1626 #ifdef HAVE_SYS_STAT_H
1627 #include <sys/stat.h>
1628 #endif
1629 #ifdef HAVE_UNISTD_H
1630 #include <unistd.h>
1631 #endif
1632         ],[
1633         struct stat s;
1635         s.st_fstype = NULL;
1636         ],
1637         AC_MSG_RESULT(yes)
1638         AC_DEFINE(ROMIO_HAVE_STRUCT_STAT_WITH_ST_FSTYPE, 1, Define if struct stat has a st_fstype member),
1639         AC_MSG_RESULT(no)
1640     )
1644 # Check for statvfs and f_basetype field (Solaris, Irix, AIX, etc.)
1646 AC_CHECK_HEADERS(sys/types.h sys/statvfs.h sys/vfs.h)
1647 AC_CHECK_FUNCS(statvfs,
1648     AC_DEFINE(HAVE_STATVFS, 1, Define if statvfs function is present)
1649     AC_MSG_CHECKING([for f_basetype member of statvfs structure])
1650     AC_TRY_COMPILE([
1651 #ifdef HAVE_SYS_TYPES_H
1652 #include <sys/types.h>
1653 #endif
1654 #ifdef HAVE_SYS_VFS_H
1655 #include <sys/vfs.h>
1656 #endif
1657 #ifdef HAVE_SYS_STATVFS_H
1658 #include <sys/statvfs.h>
1659 #endif
1660         ], [[
1661         struct statvfs foo;
1663         foo.f_basetype[0] = 'a';
1664         ]],
1665         AC_MSG_RESULT(yes)
1666         AC_DEFINE(ROMIO_HAVE_STRUCT_STATVFS_WITH_F_BASETYPE, 1, defined if struct statvfs has a f_basetype member),
1667         AC_MSG_RESULT(no)
1668     )
1672 # Check for large file support.  Make sure that we can use the off64_t 
1673 # type (in some cases, it is an array, and the ROMIO code isn't prepared for
1674 # that).
1676 AC_CHECK_HEADERS(unistd.h)
1677 if test "$ac_cv_header_unistd_h" = "yes" ; then
1678     AC_CACHE_CHECK([for large file defines],ac_cv_has_large_file_defines,[
1679     AC_TRY_COMPILE([
1680 #include <unistd.h>
1681         ], [
1682 #ifndef _LFS64_LARGEFILE
1683 #error no largefile defines
1684 #endif
1685         ],ac_cv_has_large_file_defines=yes,ac_cv_has_large_file_defines=no)])
1686     if test "$ac_cv_has_large_file_defines" = "yes" ; then
1687         # See if we can use them
1688     AC_CACHE_CHECK([whether off64_t is an scalar type],ac_cv_off64_t_scalar,[
1689     AC_TRY_COMPILE([
1690 #define _LARGEFILE64_SOURCE
1691 #define _FILE_OFFSET_BITS 64
1692 #include <sys/types.h>
1693 #include <unistd.h>
1694 ],[off64_t a = 3;],ac_cv_off64_t_scalar=yes,ac_cv_off64_t_scalar=no)])
1696         if test "$ac_cv_off64_t_scalar" = "yes" ; then
1697             CFLAGS="${CFLAGS} -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64"
1698         fi
1699     fi
1703 ####################################################################
1704 # We're about to mess with CC etc.  No more feature tests past here,
1705 # because we may set CC to something that does not yet exist!
1706 ####################################################################
1708 if test -n "$mpi_mpich"; then
1709    if test -z "$arch_SX4" ; then
1710       MPIOF_H_INCLUDED=1
1711    fi
1712    if test "$FROM_MPICH2" = no; then
1713       AC_DEFINE(NEEDS_MPI_TEST,1,[Define if mpi_test needed])
1714       AC_DEFINE(MPICH,1,[Define if using MPICH])
1715    fi
1718 if test -n "$mpi_sgi"; then
1719    AC_DEFINE(MPISGI,1,[Define if SGI MPI])
1722 if test -n "$mpi_lam"; then
1723    AC_DEFINE(MPILAM,1,[Define if using LAM/MPI])
1726 if test -n "$mpi_hp"; then
1727    AC_DEFINE(MPIHP,1,[Define if using HP MPI])
1728    if test "$NOF77" = 0; then
1729       PAC_CHECK_MPIOF_H
1730    fi
1733 AC_CHECK_FUNCS(strerror)
1734 if test -z "$srcdir" -o "$srcdir" = "." ; then srcdir="$ROMIO_HOME" ; fi
1735 AC_SUBST(srcdir)
1736 # The master_top_srcdir is the location of the source for the building
1737 # package.  This is used only as part of the MPICH2 build, including 
1738 # the documentation targets mandoc, htmldoc, and latexdoc
1739 if test -z "$master_top_srcdir" ; then
1740     if test "$FROM_MPICH2" = yes ; then
1741         AC_MSG_WARN([Could not determine master_top_srcdir])
1742     fi
1744 AC_SUBST(master_top_srcdir)
1746 # Get the master builddir (which may be imported from above)
1747 if test -z "$master_top_builddir" ; then
1748     master_top_builddir=`pwd`
1750 export master_top_builddir
1751 AC_SUBST(master_top_builddir)
1752 # Make sure the alternate spelling is used until we clean up all of the code
1753 master_topbuild_dir=$master_top_builddir
1754 export master_topbuild_dir
1755 AC_SUBST(master_topbuild_dir)
1757 # The following definitions are needed within adio/common/status_setb.c
1758 if test "$FROM_MPICH" = yes ; then
1759    AC_DEFINE(MPICH,1,[Define if compiling within MPICH])
1760 elif test "$FROM_MPICH2" = yes ; then 
1761    AC_DEFINE(ROMIO_INSIDE_MPICH2,1,[Define if compiling within MPICH2])
1762 elif test "$FROM_MPILAM" = yes ; then
1763    AC_DEFINE(MPILAM,1,[Define if compiling within LAM/MPI])
1766 if test "$FROM_MPICH2" = no -a "$FROM_MPICH" = no ; then 
1767     if test -z "$LIBNAME"; then
1768         LIBNAME="$top_build_dir/lib/libmpio.a"
1769     fi
1770     #
1771     if test ! -d $top_build_dir/lib ; then 
1772         mkdir $top_build_dir/lib
1773     fi
1774 else
1775     MPILIBNAME=${MPILIBNAME:-mpich}
1776     if test -z "$LIBNAME" ; then
1777         if test -d "$master_top_builddir/lib" ; then
1778             LIBNAME=$master_top_builddir/lib/lib${MPILIBNAME}.a
1779         else
1780             LIBNAME="$ROMIO_HOME/lib${MPILIBNAME}.a"
1781         fi
1782     fi
1784 if test "$FROM_MPICH2" != no ; then
1785     # use the error handlers from MPICH2
1786     MPIO_EXTRA_OBJECTS=
1787     MPIO_EXTRA_TMP_POBJECTS=
1788     MPIO_EXTRA_REAL_POBJECTS=
1789     # Use generalized request to get the multiple-completion routines
1790     MPIO_REQOBJECTS=
1791     MPIO_REQ_TMP_POBJECTS=
1792     MPIO_REQ_REAL_POBJECTS=
1794 AC_SUBST(MPIO_EXTRA_OBJECTS)
1795 AC_SUBST(MPIO_EXTRA_TMP_POBJECTS)
1796 AC_SUBST(MPIO_EXTRA_REAL_POBJECTS)
1797 AC_SUBST(MPIO_REQOBJECTS)
1798 AC_SUBST(MPIO_REQ_TMP_POBJECTS)
1799 AC_SUBST(MPIO_REQ_REAL_POBJECTS)
1801 # Use DOCTEXT instead of doctext
1802 AC_CHECK_PROGS(DOCTEXT,doctext,true)
1803 AC_SUBST(DOCTEXT)
1805 if test $NOF77 = 1 ; then
1806    F77=":"
1807 else
1808    FORTRAN_TEST="fperf fcoll_test fmisc pfcoll_test" 
1811 if test $WITHIN_KNOWN_MPI_IMPL = no ; then
1812    PAC_TEST_MPI
1813    PAC_NEEDS_FINT
1814 else
1815    NEEDS_MPI_FINT=""
1818 if test "$MPI_INCLUDE_DIR" = "." ; then
1819    ROMIO_INCLUDE="-I../include"
1820 else 
1821    ROMIO_INCLUDE="-I../include -I$MPI_INCLUDE_DIR"
1824 TEST_LIBNAME=$LIBNAME
1825 MPIRUN=mpirun
1827 # if MPICH, use mpicc in test programs
1829 if test "$FROM_MPICH" = yes ; then
1830    MPICH_HOME=`dirname $ROMIO_HOME`
1831    if test -z "$MPI_BIN_DIR" ; then MPI_BIN_DIR=$MPICH_HOME/bin ; fi
1832    TEST_CC=$MPI_BIN_DIR/mpicc
1833    MPI_LIB=""
1834    ROMIO_INCLUDE=""
1835    USER_CFLAGS=""
1836    USER_FFLAGS=""
1837    TEST_LIBNAME=""
1838    MPIRUN=$MPI_BIN_DIR/mpirun
1839    if test -n "$arch_SX4" || test -n "$arch_hpux" ; then
1840       TEST_F77=$MPI_BIN_DIR/mpif90
1841    else
1842       TEST_F77=$MPI_BIN_DIR/mpif77
1843    fi
1844    CC=$MPI_BIN_DIR/mpicc
1845    # A later test will insert the mpi2-other/info and array directories based
1846    # on the value of BUILD_MPI_xxxx.  This lets MPICH2 turn these off,
1847    # since MPICH2 provides these routines elsewhere
1848    EXTRA_DIRS="mpi-io/fortran"
1849    # Some older implementations of the ADI do not include the 
1850    # MPID_Status_set_bytes routine.   This uses either the 
1851    # environment variable ADI3_WITHOUT_SET_BYTES or the
1852    # with arg --without-setbytes
1853    if test "$ADI2_WITHOUT_SET_BYTES" != yes -a \
1854            "$with_setbytes" != no ; then
1855        AC_DEFINE(HAVE_STATUS_SET_BYTES,1,[Define if have MPIR_Status_set_bytes])
1856    fi
1857 elif test $FROM_LAM = yes ; then
1858    # LAM does have the status set bytes functionality
1859    AC_DEFINE(HAVE_STATUS_SET_BYTES,1,[Define if have MPIR_Status_set_bytes])
1860         
1861    # Used in the tests/ subdirectory for after ROMIO is built
1862    TEST_CC=mpicc
1863    TEST_F77=mpif77
1864    MPIRUN=mpirun 
1865    MPI_LIB=
1866    ROMIO_INCLUDE=
1867    USER_CFLAGS=
1868    USER_FFLAGS=
1869    TEST_LIBNAME=
1870    EXTRA_DIRS="mpi-io/fortran mpi2-other/info mpi2-other/info/fortran mpi2-other/array mpi2-other/array/fortran"
1871 elif test $FROM_MPICH2 = yes ; then
1872    # For now, separate the mpich2 from mpich cases
1873    MPICH_HOME=`dirname $ROMIO_HOME`
1874    MPICH_HOME=`dirname $MPICH_HOME`
1875    MPICH_HOME=`dirname $MPICH_HOME`
1876    if test -z "$MPI_BIN_DIR" ; then MPI_BIN_DIR=$MPICH_HOME/bin ; fi
1877    # No special compiler script.
1878    # BUT we need the include paths
1879    # CC="$CC -I${use_top_srcdir}/src/include -I${top_build_dir}/src/include"
1880    # TEST_CC="$CC"
1881    # MPI_LIB="$LIBNAME"
1882    # To allow ROMIO to work with the LIBTOOL scripts, we want to 
1883    # work directly with the CC, not the mpicc, compiler.
1884    # Note that in the "FROM_MPICH2" case, the CPPFLAGS and INCLUDES are already
1885    # properly set
1886    #CC=${top_build_dir}/bin/mpicc
1887    #
1888    # set the compilers to the ones in MPICH2 bin directory (master_top_builddir/bin)
1889    TEST_CC=${master_top_builddir}/bin/mpicc
1890    TEST_F77=${master_top_builddir}/bin/mpif77
1891    ROMIO_INCLUDE=""
1892    USER_CFLAGS=""
1893    USER_FFLAGS=""
1894    TEST_LIBNAME=""
1895    MPIRUN=${master_top_builddir}/bin/mpiexec
1896    #
1897    # Turn off the building of the Fortran interface and the Info routines
1898    EXTRA_DIRS=""
1899    AC_DEFINE(HAVE_STATUS_SET_BYTES,1,[Define if status_set_bytes available])
1900    DEFINE_HAVE_MPI_GREQUEST="#define HAVE_MPI_GREQUEST 1"
1901    AC_DEFINE(HAVE_MPIU_FUNCS,1,[Define if MPICH2 memory tracing macros defined])
1905 # feature tests:  we can't test features if building as part of MPICH because
1906 # we don't yet have an implementation against which we can test
1908 if test $WITHIN_KNOWN_MPI_IMPL = no ; then
1909    PAC_TEST_MPIR_STATUS_SET_BYTES
1910    PAC_TEST_MPI_GREQUEST
1911    PAC_TEST_MPIU_FUNCS
1912    AC_DEFINE(PRINT_ERR_MSG,1,[Define for printing error messages])
1915 if test -z "$TEST_CC" ; then
1916    TEST_CC="$CC"
1918 if test -z "$TEST_F77" ; then
1919    TEST_F77="$F77"
1922 AC_CHECK_FUNCS(strdup)
1923 if test "$ac_cv_func_strdup" = "yes" ; then
1924     # Do we need to declare strdup?
1925     PAC_FUNC_NEEDS_DECL([#include <string.h>],strdup)
1927 AC_CHECK_FUNCS(snprintf)
1928 if test "$ac_cv_func_snprintf" = "yes" ; then
1929     # Do we need to declare snprintf?
1930     PAC_FUNC_NEEDS_DECL([#include <stdio.h>],snprintf)
1932 AC_CHECK_FUNCS(lstat)
1933 if test "$ac_cv_func_lstat" = "yes" ; then
1934     # Do we need to declare lstat?
1935     PAC_FUNC_NEEDS_DECL([#include <unistd.h>],lstat)
1937 AC_CHECK_FUNCS(readlink)
1938 if test "$ac_cv_func_readlink" = "yes" ; then
1939     # Do we need to declare readlink?
1940     PAC_FUNC_NEEDS_DECL([#include <unistd.h>],readlink)
1942 AC_CHECK_FUNCS(fsync)
1943 if test "$ac_cv_func_fsync" = "yes" ; then
1944     # Do we need to declare fsync?
1945     PAC_FUNC_NEEDS_DECL([#include <unistd.h>],fsync)
1947 AC_CHECK_FUNCS(ftruncate)
1948 if test "$ac_cv_func_ftruncate" = "yes" ; then
1949     # Do we need to declare ftruncate?
1950     PAC_FUNC_NEEDS_DECL([#include <unistd.h>],ftruncate)
1953 AC_CHECK_FUNCS(lseek64)
1954 if test "$ac_cv_func_lseek64" = "yes" ; then
1955     PAC_FUNC_NEEDS_DECL([#include <unistd.h>],lseek64)
1958 # Create the directory lists for the Makefile
1959 FILE_SYS_DIRS=""
1960 for dir in $FILE_SYSTEM ; do
1961     FILE_SYS_DIRS="$FILE_SYS_DIRS adio/ad_$dir"
1962 done
1963 EXTRA_SRC_DIRS=""
1964 GLUE_DIR=""
1965 if test "$FROM_MPICH2" = yes -o "${MPI_IMPL}_mpi" = "mpich2_mpi"; then
1966     GLUE_DIR="mpi-io/glue/mpich2"
1967 elif test "$FROM_MPICH" = yes -o "${MPI_IMPL}_mpi" = "mpich_mpi"; then
1968     GLUE_DIR="mpi-io/glue/mpich1"
1969 else
1970     GLUE_DIR="mpi-io/glue/default"
1972 if test "$BUILD_MPI_INFO" = 1 ; then
1973     EXTRA_SRC_DIRS="$EXTRA_SRC_DIRS mpi2-other/info"
1974     if test "$NOF77" = 0 -a "$FROM_MPICH2" != yes ; then
1975         EXTRA_SRC_DIRS="$EXTRA_SRC_DIRS mpi2-other/info/fortran"
1976     fi
1978 if test "$BUILD_MPI_ARRAY" = 1 ; then
1979     EXTRA_SRC_DIRS="$EXTRA_SRC_DIRS mpi2-other/array"
1980     if test "$NOF77" = 0 -a "$FROM_MPICH2" != yes ; then
1981         EXTRA_SRC_DIRS="$EXTRA_SRC_DIRS mpi2-other/array/fortran"
1982     fi
1984 if test "$NOF77" = 0 -a "$FROM_MPICH2" != yes ; then
1985    EXTRA_SRC_DIRS="$EXTRA_SRC_DIRS mpi-io/fortran"
1987 AC_SUBST(EXTRA_SRC_DIRS)
1988 AC_SUBST(FILE_SYS_DIRS)
1989 AC_SUBST(GLUE_DIR)
1992 CFLAGS="$CFLAGS -DHAVE_ROMIOCONF_H"
1995 if test -n "$MPIOF_H_INCLUDED"; then
1996    F77MPIOINC=""
1997 else 
1998    F77MPIOINC="include 'mpiof.h'"
2001 AC_CHECK_HEADERS(unistd.h,
2002         AC_MSG_CHECKING([for large file defines])
2003         AC_TRY_COMPILE([
2004                 #include <unistd.h>
2005                 ], [
2006                 #ifndef _LFS64_LARGEFILE
2007                 #error no largefile defines
2008                 #endif
2009                 ],
2010                 CFLAGS="${CFLAGS} -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64"
2011                 AC_MSG_RESULT(yes),
2012                 AC_MSG_RESULT(none) )
2013         )
2016 # for BlueGene, this routine helps us know how much memory is left, and if we
2017 # need to fall back to less memory-intensive algorithms
2018 AC_CHECK_HEADERS(spi/kernel_interface.h)
2019 AC_CHECK_FUNCS(Kernel_GetMemorySize)
2021                 
2022 echo "setting SYSDEP_INC to $SYSDEP_INC"
2023 AC_SUBST(SYSDEP_INC)
2025 AC_C_RESTRICT
2026 PAC_C_GNU_ATTRIBUTE
2028 echo "setting CC to $CC"
2029 echo "setting F77 to $F77"
2030 echo "setting TEST_CC to $TEST_CC"
2031 echo "setting TEST_F77 to $TEST_F77"
2032 echo "setting CFLAGS to $CFLAGS"
2033 echo "setting USER_CFLAGS to $USER_CFLAGS"
2034 echo "setting USER_FFLAGS to $USER_FFLAGS"
2036 AC_SUBST(ARCH)
2037 AC_SUBST(FILE_SYSTEM)
2038 AC_SUBST(CC)
2039 AC_SUBST(CPPFLAGS)
2040 AC_SUBST(CFLAGS)
2041 AC_SUBST(USER_CFLAGS)
2042 AC_SUBST(USER_FFLAGS)
2043 AC_SUBST(MIPS)
2044 AC_SUBST(BITS)
2045 AC_SUBST(AR)
2046 AC_SUBST(AR_FLAGS)
2047 AC_SUBST(RANLIB)
2048 AC_SUBST(MPI_INCLUDE_DIR)
2049 AC_SUBST(MPI_LIB)
2050 AC_SUBST(F77)
2051 AC_SUBST(NOF77)
2052 AC_SUBST(NOPROFILE)
2053 AC_SUBST(MAKE)
2054 AC_SUBST(arch_IRIX)
2055 AC_SUBST(ROMIO_HOME)
2056 AC_SUBST(LIBNAME)
2057 AC_SUBST(TEST_LIBNAME)
2058 AC_SUBST(LL)
2059 AC_SUBST(F77GETARG)
2060 AC_SUBST(F77IARGC)
2061 AC_SUBST(F77MPIOINC)
2062 AC_SUBST(FTESTDEFINE)
2063 AC_SUBST(FORTRAN_MPI_OFFSET)
2064 AC_SUBST(FROM_MPICH)
2065 AC_SUBST(FROM_MPICH2)
2066 AC_SUBST(FROM_LAM)
2067 AC_SUBST(WITHIN_KNOWN_MPI_IMPL)
2068 AC_SUBST(NEEDS_MPI_FINT)
2069 AC_SUBST(HAVE_MPI_INFO)
2070 AC_SUBST(BUILD_MPI_INFO)
2071 AC_SUBST(HAVE_MPI_DARRAY_SUBARRAY)
2072 AC_SUBST(BUILD_MPI_ARRAY)
2073 AC_SUBST(DEFINE_MPI_OFFSET)
2074 AC_SUBST(DEFINE_HAVE_MPI_GREQUEST)
2075 AC_SUBST(MPI_OFFSET_TYPE)
2076 AC_SUBST(MPI_FINFO1)
2077 AC_SUBST(MPI_FINFO2)
2078 AC_SUBST(MPI_FINFO3)
2079 AC_SUBST(MPI_FINFO4)
2080 AC_SUBST(MPI_FARRAY1)
2081 AC_SUBST(MPI_FARRAY2)
2082 AC_SUBST(MPI_FARRAY3)
2083 AC_SUBST(MPI_FARRAY4)
2084 AC_SUBST(MPI_FARRAY5)
2085 AC_SUBST(MPI_FARRAY6)
2086 AC_SUBST(MPI_FARRAY7)
2087 AC_SUBST(MPI_OFFSET_KIND1)
2088 AC_SUBST(MPI_OFFSET_KIND2)
2089 AC_SUBST(MPIO_REQOBJECTS)
2090 AC_SUBST(TEST_CC)
2091 AC_SUBST(TEST_F77)
2092 AC_SUBST(ROMIO_INCLUDE)
2093 AC_SUBST(ROMIO_LFLAGS)
2094 AC_SUBST(ROMIO_TCFLAGS)
2095 AC_SUBST(ROMIO_TCPPFLAGS)
2096 AC_SUBST(ROMIO_TFFLAGS)
2097 AC_SUBST(MPIRUN)
2098 AC_SUBST(FORTRAN_TEST)
2100 dnl Dependency handling
2101 AC_SUBST(MAKE_DEPEND_C)
2103 dnl Support shared libraries
2104 if test -z "$ENABLE_SHLIB" ; then
2105    ENABLE_SHLIB=none
2107 AC_SUBST(ENABLE_SHLIB)
2108 AC_SUBST(CC_SHL)
2109 AC_SUBST(LIBTOOL)
2110 # Remove the .a from the library file name (so that we can use .so or
2111 # other appropriate suffix)
2112 SHLIBNAME=`echo $LIBNAME | sed 's/\.a$//'`
2113 AC_SUBST(SHLIBNAME)
2115 if test ! -d adio ; then mkdir adio ; fi
2116 if test ! -d adio/include ; then mkdir adio/include ; fi
2117 if test ! -d mpi2-other ; then mkdir mpi2-other ; fi
2118 if test ! -d mpi-io ; then mkdir mpi-io ; fi
2119 if test ! -d mpi-io/glue ; then mkdir mpi-io/glue ; fi
2121 # Make sure we remove any configuration file incase there is out-of-date data.
2122 # We remove the version in include in case this is a vpath build
2123 rm -f adio/include/romioconf.h ${use_top_srcdir}/src/mpi/romio/adio/include/romioconf.h ${use_top_srcdir}/adio/include/romioconf.h
2125 # Create makefiles for all of the adio devices.  Only the ones that 
2126 # are active will be called by the top level ROMIO make
2127 AC_OUTPUT_COMMANDS([chmod 755 util/romioinstall test/runtests])
2128 AC_OUTPUT(Makefile localdefs mpi-io/Makefile mpi2-other/info/Makefile \
2129                    mpi2-other/array/Makefile adio/common/Makefile \
2130                    test/Makefile test/misc.c test/large_file.c \
2131                    test/runtests test-internal/Makefile util/romioinstall \
2132                    include/mpio.h \
2133                    include/mpiof.h \
2134                    adio/ad_nfs/Makefile adio/ad_ufs/Makefile \
2135                    adio/ad_bgl/Makefile \
2136                    adio/ad_bglockless/Makefile \
2137                    adio/ad_panfs/Makefile \
2138                    adio/ad_xfs/Makefile \
2139                    adio/ad_sfs/Makefile adio/ad_pfs/Makefile \
2140                    adio/ad_testfs/Makefile adio/ad_pvfs/Makefile \
2141                    adio/ad_pvfs2/Makefile \
2142                    adio/ad_gridftp/Makefile \
2143                    adio/ad_lustre/Makefile \
2144                    adio/ad_zoidfs/Makefile \
2145                    mpi-io/fortran/Makefile mpi2-other/info/fortran/Makefile \
2146                    mpi2-other/array/fortran/Makefile test/fmisc.f \
2147                    test/fcoll_test.f test/pfcoll_test.f test/fperf.f \
2148                    mpi-io/glue/mpich2/Makefile \
2149                    mpi-io/glue/mpich1/Makefile \
2150                    mpi-io/glue/default/Makefile common/dataloop/Makefile )
2152 rm -f *.o
2154 if test $FROM_MPICH = no -a $FROM_MPICH2 = no ; then
2155    AC_MSG_RESULT([Configure done. Now type make.])
2157 dnl PAC_SUBDIR_CACHE_CLEANUP
2158 exit 0