3 dnl By default, many hosts won't let programs access large files;
4 dnl one must use special compiler options to get large-file access to work.
5 dnl For more details about this brain damage please see:
6 dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
8 dnl Written by Paul Eggert <eggert@twinsun.com>.
10 dnl Internal subroutine of AC_SYS_LARGEFILE.
11 dnl AC_SYS_LARGEFILE_TEST_INCLUDES
12 AC_DEFUN(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 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)
24 dnl Internal subroutine of AC_SYS_LARGEFILE.
25 dnl AC_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE, CACHE-VAR, COMMENT, INCLUDES, FUNCTION-BODY)
26 AC_DEFUN(AC_SYS_LARGEFILE_MACRO_VALUE,
27 [AC_CACHE_CHECK([for $1 value needed for large files], $3,
32 [AC_TRY_COMPILE([#define $1 $2]
37 if test "[$]$3" != no; then
38 AC_DEFINE_UNQUOTED([$1], [$]$3, [$4])
41 AC_DEFUN(AC_SYS_LARGEFILE,
42 [AC_REQUIRE([AC_PROG_CC])
43 AC_ARG_ENABLE(largefile,
44 [ --disable-largefile omit support for large files])
45 if test "$enable_largefile" != no; then
47 AC_CACHE_CHECK([for special C compiler options needed for large files],
48 ac_cv_sys_largefile_CC,
49 [ac_cv_sys_largefile_CC=no
50 if test "$GCC" != yes; then
51 # IRIX 6.2 and later do not support large files by default,
52 # so use the C compiler's -n32 option if that helps.
53 AC_TRY_COMPILE(AC_SYS_LARGEFILE_TEST_INCLUDES, , ,
56 AC_TRY_COMPILE(AC_SYS_LARGEFILE_TEST_INCLUDES, ,
57 ac_cv_sys_largefile_CC=' -n32')
60 if test "$ac_cv_sys_largefile_CC" != no; then
61 CC="$CC$ac_cv_sys_largefile_CC"
64 AC_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64,
65 ac_cv_sys_file_offset_bits,
66 [Number of bits in a file offset, on hosts where this is settable.],
67 AC_SYS_LARGEFILE_TEST_INCLUDES)
68 AC_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1,
69 ac_cv_sys_large_files,
70 [Define for large files, on AIX-style hosts.],
71 AC_SYS_LARGEFILE_TEST_INCLUDES)
75 AC_DEFUN(AC_FUNC_FSEEKO,
76 [AC_SYS_LARGEFILE_MACRO_VALUE(_LARGEFILE_SOURCE, 1,
77 ac_cv_sys_largefile_source,
78 [Define to make fseeko visible on some hosts (e.g. glibc 2.2).],
79 [#include <stdio.h>], [return !fseeko;])
80 # We used to try defining _XOPEN_SOURCE=500 too, to work around a bug
81 # in glibc 2.1.3, but that breaks too many other things.
82 # If you want fseeko and ftello with glibc, upgrade to a fixed glibc.
84 AC_CACHE_CHECK([for fseeko], ac_cv_func_fseeko,
86 AC_TRY_LINK([#include <stdio.h>],
87 [return fseeko && fseeko (stdin, 0, 0);],
88 [ac_cv_func_fseeko=yes])])
89 if test $ac_cv_func_fseeko != no; then
90 AC_DEFINE(HAVE_FSEEKO, 1,
91 [Define if fseeko (and presumably ftello) exists and is declared.])