largefile.m4 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. # Enable large files on systems where this is not the default.
  2. # Copyright 1992-1996, 1998-2012 Free Software Foundation, Inc.
  3. # This file is free software; the Free Software Foundation
  4. # gives unlimited permission to copy and/or distribute it,
  5. # with or without modifications, as long as this notice is preserved.
  6. # The following implementation works around a problem in autoconf <= 2.68;
  7. # AC_SYS_LARGEFILE does not configure for large inodes on Mac OS X 10.5.
  8. m4_version_prereq([2.69], [] ,[
  9. # _AC_SYS_LARGEFILE_TEST_INCLUDES
  10. # -------------------------------
  11. m4_define([_AC_SYS_LARGEFILE_TEST_INCLUDES],
  12. [@%:@include <sys/types.h>
  13. /* Check that off_t can represent 2**63 - 1 correctly.
  14. We can't simply define LARGE_OFF_T to be 9223372036854775807,
  15. since some C++ compilers masquerading as C compilers
  16. incorrectly reject 9223372036854775807. */
  17. @%:@define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
  18. int off_t_is_large[[(LARGE_OFF_T % 2147483629 == 721
  19. && LARGE_OFF_T % 2147483647 == 1)
  20. ? 1 : -1]];[]dnl
  21. ])
  22. # _AC_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE,
  23. # CACHE-VAR,
  24. # DESCRIPTION,
  25. # PROLOGUE, [FUNCTION-BODY])
  26. # --------------------------------------------------------
  27. m4_define([_AC_SYS_LARGEFILE_MACRO_VALUE],
  28. [AC_CACHE_CHECK([for $1 value needed for large files], [$3],
  29. [while :; do
  30. m4_ifval([$6], [AC_LINK_IFELSE], [AC_COMPILE_IFELSE])(
  31. [AC_LANG_PROGRAM([$5], [$6])],
  32. [$3=no; break])
  33. m4_ifval([$6], [AC_LINK_IFELSE], [AC_COMPILE_IFELSE])(
  34. [AC_LANG_PROGRAM([@%:@define $1 $2
  35. $5], [$6])],
  36. [$3=$2; break])
  37. $3=unknown
  38. break
  39. done])
  40. case $$3 in #(
  41. no | unknown) ;;
  42. *) AC_DEFINE_UNQUOTED([$1], [$$3], [$4]);;
  43. esac
  44. rm -rf conftest*[]dnl
  45. ])# _AC_SYS_LARGEFILE_MACRO_VALUE
  46. # AC_SYS_LARGEFILE
  47. # ----------------
  48. # By default, many hosts won't let programs access large files;
  49. # one must use special compiler options to get large-file access to work.
  50. # For more details about this brain damage please see:
  51. # http://www.unix-systems.org/version2/whatsnew/lfs20mar.html
  52. AC_DEFUN([AC_SYS_LARGEFILE],
  53. [AC_ARG_ENABLE(largefile,
  54. [ --disable-largefile omit support for large files])
  55. if test "$enable_largefile" != no; then
  56. AC_CACHE_CHECK([for special C compiler options needed for large files],
  57. ac_cv_sys_largefile_CC,
  58. [ac_cv_sys_largefile_CC=no
  59. if test "$GCC" != yes; then
  60. ac_save_CC=$CC
  61. while :; do
  62. # IRIX 6.2 and later do not support large files by default,
  63. # so use the C compiler's -n32 option if that helps.
  64. AC_LANG_CONFTEST([AC_LANG_PROGRAM([_AC_SYS_LARGEFILE_TEST_INCLUDES])])
  65. AC_COMPILE_IFELSE([], [break])
  66. CC="$CC -n32"
  67. AC_COMPILE_IFELSE([], [ac_cv_sys_largefile_CC=' -n32'; break])
  68. break
  69. done
  70. CC=$ac_save_CC
  71. rm -f conftest.$ac_ext
  72. fi])
  73. if test "$ac_cv_sys_largefile_CC" != no; then
  74. CC=$CC$ac_cv_sys_largefile_CC
  75. fi
  76. _AC_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64,
  77. ac_cv_sys_file_offset_bits,
  78. [Number of bits in a file offset, on hosts where this is settable.],
  79. [_AC_SYS_LARGEFILE_TEST_INCLUDES])
  80. if test $ac_cv_sys_file_offset_bits = unknown; then
  81. _AC_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1,
  82. ac_cv_sys_large_files,
  83. [Define for large files, on AIX-style hosts.],
  84. [_AC_SYS_LARGEFILE_TEST_INCLUDES])
  85. fi
  86. AH_VERBATIM([_DARWIN_USE_64_BIT_INODE],
  87. [/* Enable large inode numbers on Mac OS X. */
  88. #ifndef _DARWIN_USE_64_BIT_INODE
  89. # define _DARWIN_USE_64_BIT_INODE 1
  90. #endif])
  91. fi
  92. ])# AC_SYS_LARGEFILE
  93. ])# m4_version_prereq 2.69
  94. # Enable large files on systems where this is implemented by Gnulib, not by the
  95. # system headers.
  96. # Set the variables WINDOWS_64_BIT_OFF_T, WINDOWS_64_BIT_ST_SIZE if Gnulib
  97. # overrides ensure that off_t or 'struct size.st_size' are 64-bit, respectively.
  98. AC_DEFUN([gl_LARGEFILE],
  99. [
  100. AC_REQUIRE([AC_CANONICAL_HOST])
  101. case "$host_os" in
  102. mingw*)
  103. dnl Native Windows.
  104. dnl mingw64 defines off_t to a 64-bit type already, if
  105. dnl _FILE_OFFSET_BITS=64, which is ensured by AC_SYS_LARGEFILE.
  106. AC_CACHE_CHECK([for 64-bit off_t], [gl_cv_type_off_t_64],
  107. [AC_COMPILE_IFELSE(
  108. [AC_LANG_PROGRAM(
  109. [[#include <sys/types.h>
  110. int verify_off_t_size[sizeof (off_t) >= 8 ? 1 : -1];
  111. ]],
  112. [[]])],
  113. [gl_cv_type_off_t_64=yes], [gl_cv_type_off_t_64=no])
  114. ])
  115. if test $gl_cv_type_off_t_64 = no; then
  116. WINDOWS_64_BIT_OFF_T=1
  117. else
  118. WINDOWS_64_BIT_OFF_T=0
  119. fi
  120. dnl But all native Windows platforms (including mingw64) have a 32-bit
  121. dnl st_size member in 'struct stat'.
  122. WINDOWS_64_BIT_ST_SIZE=1
  123. ;;
  124. *)
  125. dnl Nothing to do on gnulib's side.
  126. dnl A 64-bit off_t is
  127. dnl - already the default on MacOS X, FreeBSD, NetBSD, OpenBSD, IRIX,
  128. dnl OSF/1, Cygwin,
  129. dnl - enabled by _FILE_OFFSET_BITS=64 (ensured by AC_SYS_LARGEFILE) on
  130. dnl glibc, HP-UX, Solaris,
  131. dnl - enabled by _LARGE_FILES=1 (ensured by AC_SYS_LARGEFILE) on AIX,
  132. dnl - impossible to achieve on Minix 3.1.8.
  133. WINDOWS_64_BIT_OFF_T=0
  134. WINDOWS_64_BIT_ST_SIZE=0
  135. ;;
  136. esac
  137. ])