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