diff options
Diffstat (limited to 'configure.in')
-rw-r--r-- | configure.in | 135 |
1 files changed, 100 insertions, 35 deletions
diff --git a/configure.in b/configure.in index 5f06f04..3e59662 100644 --- a/configure.in +++ b/configure.in @@ -157,7 +157,7 @@ dnl HDF_CXX: whether C++ is enabled. Default no. dnl CXX: C++ compiler. dnl HDF5_HL: whether high-level library is enabled. Default is yes. dnl GPFS: whether gpfs is enabled. Default no. -dnl LINUX_LFS: whether LINUX_LFS is enabled. Default no. +dnl LARGEFILE: whether largefile support is enabled. Default yes. dnl INSTRUMENT: whether INSTRUMENT is enabled. No default set here. dnl CODESTACK: whether CODESTACK is enabled. Default no. dnl HAVE_DMALLOC: whether system has dmalloc support. Default no. @@ -177,7 +177,7 @@ AC_SUBST(HDF_CXX) HDF_CXX=no AC_SUBST(CXX) HDF_CXX=no AC_SUBST(HDF5_HL) HDF5_HL=yes AC_SUBST(GPFS) GPFS=no -AC_SUBST(LINUX_LFS) LINUX_LFS=no +AC_SUBST(LARGEFILE) LARGEFILE=yes AC_SUBST(INSTRUMENT) AC_SUBST(CODESTACK) CODESTACK=no AC_SUBST(HAVE_DMALLOC) HAVE_DMALLOC=no @@ -1260,42 +1260,107 @@ case "$host" in esac dnl ---------------------------------------------------------------------- -dnl Test for 64bit stuff before the data types and their sizes. The -dnl result could effect the outcome of the sizeof macros below. +dnl Test for Largefile support. dnl -case "$host_cpu-$host_vendor-$host_os" in - *linux*) - dnl ---------------------------------------------------------------------- - dnl Enable large file support on linux? Store the result in the LINUX_LFS - dnl variable for posterity - AC_ARG_ENABLE([linux-lfs], - [AC_HELP_STRING([--enable-linux-lfs], - [Enable support for large (64-bit) - files on Linux. [default=check]])]) - - LINUX_LFS="no" - case "X-$enable_linux_lfs" in - X-yes) - LINUX_LFS=yes - ;; - X-no) - ;; - X-|*) - MAJOR_VER="`uname -r | cut -d '.' -f1`" - MINOR_VER="`uname -r | cut -d '.' -f2`" +AC_MSG_CHECKING([if configure should try to set up large file support]) + +AC_ARG_ENABLE([largefile], + [AC_HELP_STRING([--disable-largefile], + [omit support for large files])]) + +dnl If largefile support is enabled, then set up appropriate compiler options. +if test "$enable_largefile" != no; then + AC_MSG_RESULT(yes) + + dnl Check for needed compiler options. This check is pulled drectly + dnl from autoconf's AC_SYS_LARGEFILE macro, as of Autoconf v2.65. + AC_CACHE_CHECK([for special C compiler options needed for large files], + ac_cv_sys_largefile_CC, + [ac_cv_sys_largefile_CC=no + if test "$GCC" != yes; then + ac_save_CC=$CC + while :; do + # IRIX 6.2 and later do not support large files by default, + # so use the C compiler's -n32 option if that helps. + AC_LANG_CONFTEST([AC_LANG_PROGRAM([_AC_SYS_LARGEFILE_TEST_INCLUDES])]) + AC_COMPILE_IFELSE([], [break]) + CC="$CC -n32" + AC_COMPILE_IFELSE([], [ac_cv_sys_largefile_CC=' -n32'; break]) + break + done + CC=$ac_save_CC + rm -f conftest.$ac_ext + fi]) + if test "$ac_cv_sys_largefile_CC" != no; then + CC=$CC$ac_cv_sys_largefile_CC + fi - if test ${MAJOR_VER} -gt 2 -o ${MAJOR_VER} -eq 2 -a ${MINOR_VER} -ge 4; then - LINUX_LFS="yes" - fi - ;; - esac + dnl Use the macro _AC_SYS_LARGEFILE_MACRO_VALUE to test defines + dnl that might need to be set for largefile support to behave + dnl correctly. This macro is defined in acsite.m4 and overrides + dnl the version provided by Autoconf (as of v2.65). The custom + dnl macro additionally adds the appropriate defines to AM_CPPFLAGS + dnl so that later configure checks have them visible. + + dnl Check for _FILE_OFFSET_BITS + _AC_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64, + ac_cv_sys_file_offset_bits, + [Number of bits in a file offset, on hosts where this is settable.], + [_AC_SYS_LARGEFILE_TEST_INCLUDES]) + + dnl Check for _LARGE_FILES + if test $ac_cv_sys_file_offset_bits = unknown; then + _AC_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1, + ac_cv_sys_large_files, + [Define for large files, on AIX-style hosts.], + [_AC_SYS_LARGEFILE_TEST_INCLUDES]) + fi - AC_MSG_CHECKING([for large file support mode on Linux]) - if test "X$LINUX_LFS" = "Xyes"; then - AC_MSG_RESULT([enabled]) - AM_CPPFLAGS="-D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE $AM_CPPFLAGS" - else - AC_MSG_RESULT([disabled]) + dnl Now actually test to see if we can create large files after we've + dnl checked for any needed defines. + AC_MSG_CHECKING([if large (64-bit) files are supported on this system.]) + AC_CACHE_VAL([hdf5_cv_have_lfs], + [AC_TRY_RUN([ + #include <stdio.h> + #include <unistd.h> + #include <stdlib.h> + #include <fcntl.h> + #define BIG_FILE (off_t)0x80000000UL + int main(void) { + int fd; + if ((fd=open("test.conf", O_RDWR|O_TRUNC|O_CREAT, 0666)) < 0) exit(1); + if (lseek(fd, BIG_FILE, SEEK_SET)!=BIG_FILE) exit(1); + if (5!=write(fd, "hello", (size_t)5)) exit(1); + if (lseek(fd, 2*BIG_FILE, SEEK_SET) != 2*BIG_FILE) exit(1); + if (5!=write(fd, "hello", (size_t)5)) exit(1); + if (unlink("test.conf") < 0) exit(1); + exit(0); + } + ],[hdf5_cv_have_lfs=yes],[hdf5_cv_have_lfs=no],)]) + + if test "X${hdf5_cv_have_lfs}" = "Xyes"; then + AC_MSG_RESULT([yes]) + LARGEFILE="yes" + fi + if test "X${hdf5_cv_have_lfs}" = "Xno"; then + AC_MSG_RESULT([no]) + LARGEFILE="no" + fi + +else + LARGEFILE="no" + AC_MSG_RESULT(no) +fi + +dnl ---------------------------------------------------------------------- +dnl Add necessary defines for Linux Systems. +dnl +case "$host_cpu-$host_vendor-$host_os" in + *linux*) + dnl If largefile support is enabled, then make available various + dnl LFS-related routines using the following _LARGEFILE*_SOURCE macros. + if test "X$LARGEFILE" != "Xno"; then + AM_CPPFLAGS="-D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE $AM_CPPFLAGS" fi dnl Add POSIX support on Linux systems, so <features.h> defines |