largefile.m4 5.2 KB

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