summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS34
-rw-r--r--doc/autoconf.texi165
-rw-r--r--lib/autoconf/functions.m466
-rw-r--r--lib/autoconf/specific.m4437
-rw-r--r--tests/local.at5
5 files changed, 463 insertions, 244 deletions
diff --git a/NEWS b/NEWS
index 338addb5..d9c6ed94 100644
--- a/NEWS
+++ b/NEWS
@@ -21,15 +21,43 @@ GNU Autoconf NEWS - User visible changes.
that you will get a confusing error message if you run autoconf on
a configure.ac that neglects to use AC_INIT or AC_OUTPUT.
-*** AC_SYS_LARGEFILE now arranges for 64-bit time_t if possible.
-
*** m4sh diversions like BINSH have been renumbered.
This matters only for uses that, contrary to the documentation
and despite warnings, use m4_divert with numbered diversions.
** New features
-*** New macro AC_SYS_YEAR2038 for 64-bit time_t.
+*** New macros AC_SYS_YEAR2038 and AC_SYS_YEAR2038_REQUIRED.
+ These macros attempt to enlarge time_t to 64 bits, on systems where
+ it has historically been only 32 bits wide, and therefore (assuming
+ the usual Unix epoch) cannot represent dates after mid-January of
+ 2038 (hence the names). The difference between the two is that
+ AC_SYS_YEAR2038_REQUIRED unconditionally causes 'configure' to error
+ out if 64-bit time_t is not available.
+
+ AC_SYS_YEAR2038 will also error out if the host system shows signs of
+ supporting dates after Jan 2038 (e.g. in file timestamps) but it can’t
+ figure out how to get a wider time_t; this failure can be overridden
+ with the --disable-year2038 option.
+
+ Library authors should be cautious about adding these macros to
+ their configure scripts; they can break binary backward compatibility.
+
+*** New macro AC_SYS_LARGEFILE_REQUIRED.
+ This macro is the same as the existing AC_SYS_LARGEFILE except that
+ it will cause 'configure' to error out if 64-bit off_t is not available,
+ and it does not provide a --disable-largefile option.
+
+*** AC_SYS_LARGEFILE now optionally arranges to enlarge time_t.
+ As an experimental measure to make it easier to rebuild old programs
+ with support for dates after Jan 2038, if you regenerate any configure
+ script that uses AC_SYS_LARGEFILE (but not AC_SYS_YEAR2038) using
+ Autoconf 2.72, it will gain an --enable-year2038 option. When the
+ program is configured with this option, time_t will be enlarged if
+ possible, as if AC_SYS_YEAR2038 had been used.
+
+ Using this option in a library build also potentially breaks binary
+ backward compatibility.
*** AC_USE_SYSTEM_EXTENSIONS now enables C23 Annex F extensions
by defining __STDC_WANT_IEC_60559_EXT__.
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index d2d8c23d..df96280b 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -31,7 +31,7 @@
@c Same as @dvar{ARG, DEFAULT-VAR}, but with @var instead of @samp
@c around DEFAULT-VAR.
@macro dvarv{varname, default}
-@r{[}@var{\varname\} = @var{\default\}@r{]}@c
+@r{[}@var{\varname\} = @var{\default\}@r{]}
@end macro
@c Handling the indexes with Texinfo yields several different problems.
@@ -5229,6 +5229,7 @@ test, you also need to set the @code{ac_cv_func_fork} and
@code{ac_cv_func_vfork} variables.
@end defmac
+@anchor{AC_FUNC_FSEEKO}
@defmac AC_FUNC_FSEEKO
@acindex{FUNC_FSEEKO}
@cvindex _LARGEFILE_SOURCE
@@ -5238,12 +5239,13 @@ test, you also need to set the @code{ac_cv_func_fork} and
@c @fuindex ftello
@prindex @code{ftello}
@c @caindex sys_largefile_source
-If the @code{fseeko} function is available, define @code{HAVE_FSEEKO}.
-Define @code{_LARGEFILE_SOURCE} if necessary to make the prototype
-visible on some systems (e.g., glibc 2.2). Otherwise linkage problems
-may occur when compiling with @code{AC_SYS_LARGEFILE} on
-largefile-sensitive systems where @code{off_t} does not default to a
-64bit entity. All systems with @code{fseeko} also supply @code{ftello}.
+If the @code{fseeko} and @code{ftello} functions are available, define
+@code{HAVE_FSEEKO}. Define @code{_LARGEFILE_SOURCE} if necessary to
+make the prototype visible.
+
+Configure scripts that use @code{AC_FUNC_FSEEKO} should normally also
+use @code{AC_SYS_LARGEFILE} to ensure that @code{off_t} can represent
+all supported file sizes. @xref{AC_SYS_LARGEFILE}.
The Gnulib module @code{fseeko} invokes @code{AC_FUNC_FSEEKO}
and also contains workarounds for other portability problems of
@@ -8792,45 +8794,76 @@ the shell variable @code{interpval}; it is set to @samp{yes}
if the system supports @samp{#!}, @samp{no} if not.
@end defmac
+@anchor{AC_SYS_LARGEFILE}
@defmac AC_SYS_LARGEFILE
@acindex{SYS_LARGEFILE}
@cvindex _FILE_OFFSET_BITS
-@cvindex _LARGE_FILES
-@cvindex _TIME_BITS
@ovindex CC
@cindex Large file support
@cindex LFS
-Arrange for 64-bit file offsets, known as
-@uref{http://@/www.unix.org/@/version2/@/whatsnew/@/lfs20mar.html,
-large-file support}, along with other large attributes.
-On some hosts, one must use special compiler options
-to build programs that can access files with large sizes inode
-numbers, timestamps, or other attributes. Append any such
-options to the output variable @code{CC}. Define
-@code{_FILE_OFFSET_BITS}, @code{_LARGE_FILES}, and @code{_TIME_BITS}
-if necessary.
+If the default @code{off_t} type is a 32-bit integer, and therefore
+cannot be used to work with files larger than 4 gigabytes, arrange to
+make a larger @code{off_t} available, if the system supports this.
+Several other types related to the sizes of files and file systems will
+also be enlarged: @code{ino_t}, @code{blkcnt_t}, @code{fsblkcnt_t},
+@code{fsfilcnt_t}, and possibly @code{dev_t}.
+
+If a large @code{off_t} is available (whether or not any arrangements
+were necessary), the shell variable @code{ac_have_largefile} will be set
+to @samp{yes}; if not, it will be set to @samp{no}.
+
+Preprocessor macros will be defined if necessary to make a larger
+@code{off_t} available. (For example, on many systems the macro
+@code{_FILE_OFFSET_BITS} will be defined.) Some of these macros only
+work if they are defined before the first system header is included;
+therefore, when using this macro in concert with
+@code{AC_CONFIG_HEADERS}, make sure that @file{config.h} is included
+before any system headers.
+
+On a few older systems, the output variable @code{CC} will also be
+changed to add special compiler options that are needed to enable large
+@code{off_t}.
Large-file support can be disabled by configuring with the
-@option{--disable-largefile} option. If you disable large-file
-support, your program may have trouble accessing arbitrary files, such
-as files that might be found in an adversary's directory.
-
-If you use this macro, check that your program works even when the types
-@code{blkcnt_t}, @code{dev_t}, @code{ino_t}, @code{off_t}, and @code{time_t}
-are wider than @code{long int}, since this is common when
-large-file support is enabled. For example, it is not correct to print
-an arbitrary @code{off_t} value @code{X} with @code{printf ("%ld",
-(long int) X)}. Also, when using this macro in concert with
-@code{AC_CONFIG_HEADERS}, be sure that @file{config.h} is included
-before any system header.
+@option{--disable-largefile} option. Note that this has no effect on
+systems where @code{off_t} is 64 bits or larger by default. Disabling
+large-file support can have surprising effects, such as causing
+functions like @code{readdir} and @code{stat} to fail on small files
+(because their @emph{inode numbers} are unrepresentable).
-The LFS introduced the @code{fseeko} and @code{ftello} functions to
-replace their C counterparts @code{fseek} and @code{ftell} that do not
-use @code{off_t}. Take care to use @code{AC_FUNC_FSEEKO} to make their
-prototypes available when using them and large-file support is
-enabled.
+Regardless of whether you use this macro, portable programs should not
+assume that any of the types listed above fit into a @code{long int}.
+For example, it is not correct to print an arbitrary @code{off_t} value
+@code{X} with @code{printf ("%ld", (long int) X)}.
+
+Note that the standard C library functions @code{fseek} and @code{ftell}
+do not use @code{off_t}. If you need to use either of these functions,
+you should use @code{AC_FUNC_FSEEKO} as well as @code{AC_SYS_LARGEFILE},
+and then use their Posix replacements @code{fseeko} and @code{ftello},
+which @emph{do} use @code{off_t}, when available. @xref{AC_FUNC_FSEEKO}.
+
+As of Autoconf 2.72, @code{AC_SYS_LARGEFILE} also @emph{optionally}
+arranges to enlarge @code{time_t}. This is to make it easier to build
+programs that support timestamps after 2038; many configure scripts will
+not need to be modified, only regenerated with newer Autoconf. When
+@code{AC_SYS_LARGEFILE} is used, and @code{AC_SYS_YEAR2038} is
+@emph{not} used, @code{time_t} will normally be left at the system's
+default size, but you can request it be enlarged by configuring with the
+@option{--enable-year2038} option. (When @code{AC_SYS_YEAR2038} is also
+used, @code{time_t} is enlarged if possible. @xref{AC_SYS_YEAR2038}.)
+@end defmac
+
+@defmac AC_SYS_LARGEFILE_REQUIRED
+@acindex{SYS_LARGEFILE_REQUIRED}
+This macro has the same effect as @code{AC_SYS_LARGEFILE},
+but also declares that the program being configured
+@emph{requires} support for large files.
+If a large @code{off_t} is unavailable,
+@command{configure} will error out.
+The @option{--disable-largefile} option will not be available.
@end defmac
+
@anchor{AC_SYS_LONG_FILE_NAMES}
@defmac AC_SYS_LONG_FILE_NAMES
@acindex{SYS_LONG_FILE_NAMES}
@@ -8849,32 +8882,58 @@ system. If so, set the shell variable @code{ac_cv_sys_posix_termios} to
@samp{yes}. If not, set the variable to @samp{no}.
@end defmac
+@anchor{AC_SYS_YEAR2038}
@defmac AC_SYS_YEAR2038
@acindex{SYS_YEAR2038}
@cvindex _TIME_BITS
-@ovindex CC
@cindex Year 2038
-If the default @code{time_t} type is a signed 32-bit integer that stops
-working in the year 2038, then arrange to use a wider @code{time_t} if
-possible and report a fatal error otherwise. Define @code{_TIME_BITS}
-if necessary.
-
-Wider-time support can be disabled by configuring with the
-@option{--disable-year2038} option.
+If the default @code{time_t} type is a signed 32-bit integer,
+and therefore (assuming the usual Unix epoch) cannot represent
+timestamps after mid-January of 2038, arrange to make a larger
+@code{time_t} available, if the system supports this.
+
+If a large @code{time_t} is available (whether or not any arrangements
+were necessary), the shell variable @code{ac_have_year2038} will be set
+to @samp{yes}; if not, it will be set to @samp{no}.
+
+Preprocessor macros will be defined if necessary to make a larger
+@code{time_t} available. (For example, on some systems the macro
+@code{_TIME_BITS} will be defined.) Some of these macros only work if
+they are defined before the first system header is included; therefore,
+when using this macro in concert with @code{AC_CONFIG_HEADERS}, make
+sure that @file{config.h} is included before any system headers.
+
+Support for timestamps after 2038 can be disabled by configuring with
+the @option{--disable-year2038} option. Note that this has no effect on
+systems where @code{time_t} is 64 bits or larger by default.
+If this option is @emph{not} given, and @command{configure} fails to
+find a way to enable a large @code{time_t}, but inspection of the
+system suggests that this feature is available @emph{somehow}, it will
+error out.
Regardless of whether you use this macro, portable programs should not
assume that @code{time_t} fits into @code{long int}. For example, it is
not correct to print an arbitrary @code{time_t} value @code{X} with
-@code{printf ("%ld", (long int) X)}. Also, when using this macro in
-concert with @code{AC_CONFIG_HEADERS}, be sure that @file{config.h} is
-included before any system header.
-
-@code{AC_SYS_LARGFILE} also widens @code{time_t} if possible,
-as this is needed for programs that access files with large timestamps,
-However, @code{AC_SYS_LARGEFILE} merely warns if @code{time_t} is too
-narrow and cannot be widened, rather than reporting a fatal error as
-@code{AC_SYS_YEAR2038} does. This is for portability to older
-platforms that will become obsolete in the year 2038.
+@code{printf ("%ld", (long int) X)}.
+
+@strong{Caution:} If you are developing a shared library, and
+@code{time_t} appears anywhere in your library's public interface, use
+of this macro may break binary compatibility with older executables.
+@end defmac
+
+@defmac AC_SYS_YEAR2038_REQUIRED
+@acindex{SYS_YEAR2038_REQUIRED}
+This macro has the same effect as @code{AC_SYS_YEAR2038},
+but also declares that the program being configured
+@emph{requires} support for timestamps after mid-January of 2038.
+If a large @code{time_t} is unavailable,
+@command{configure} will @emph{unconditionally} error out
+(unlike the behavior of @code{AC_SYS_YEAR2038}).
+The @option{--disable-year2038} option will not be available.
+
+@strong{Caution:} If you are developing a shared library, and
+@code{time_t} appears anywhere in your library's public interface, use
+of this macro may break binary compatibility with older executables.
@end defmac
@node C and Posix Variants
diff --git a/lib/autoconf/functions.m4 b/lib/autoconf/functions.m4
index 110e2f05..3dbeae79 100644
--- a/lib/autoconf/functions.m4
+++ b/lib/autoconf/functions.m4
@@ -641,35 +641,57 @@ AU_ALIAS([AM_FUNC_FNMATCH], [AC_FUNC_FNMATCH])
AU_ALIAS([fp_FUNC_FNMATCH], [AC_FUNC_FNMATCH])
+# _AC_FUNC_FSEEKO_TEST_PROGRAM
+# ----------------------------
+# Test code used by AC_FUNC_FSEEKO.
+m4_define([_AC_FUNC_FSEEKO_TEST_PROGRAM],
+[AC_LANG_PROGRAM([[
+#if defined __hpux && !defined _LARGEFILE_SOURCE
+# include <limits.h>
+# if LONG_MAX >> 31 == 0
+# error "32-bit HP-UX 11/ia64 needs _LARGEFILE_SOURCE for fseeko in C++"
+# endif
+#endif
+#include <sys/types.h> /* for off_t */
+#include <stdio.h>
+]], [[
+ int (*fp1) (FILE *, off_t, int) = fseeko;
+ off_t (*fp2) (FILE *) = ftello;
+ return fseeko (stdin, 0, 0)
+ && fp1 (stdin, 0, 0)
+ && ftello (stdin) >= 0
+ && fp2 (stdin) >= 0;
+]])])
+
# AC_FUNC_FSEEKO
# --------------
+# Check for correctly prototyped declarations of fseeko and ftello;
+# define HAVE_FSEEKO if they are available. If it is necessary to
+# define _LARGEFILE_SOURCE=1 to make these declarations available,
+# do that (this is needed on 32-bit HP/UX). We used to try defining
+# _XOPEN_SOURCE=500 too, to work around a bug in glibc 2.1.3, but that
+# breaks too many other things. If you want fseeko and ftello with
+# glibc, upgrade to a fixed glibc.
AN_FUNCTION([ftello], [AC_FUNC_FSEEKO])
AN_FUNCTION([fseeko], [AC_FUNC_FSEEKO])
AC_DEFUN([AC_FUNC_FSEEKO],
-[_AC_SYS_LARGEFILE_MACRO_VALUE(_LARGEFILE_SOURCE, 1,
- [ac_cv_sys_largefile_source],
- [Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2).],
- [[#if defined __hpux && !defined _LARGEFILE_SOURCE
- #include <limits.h>
- #if LONG_MAX >> 31 == 0
- #error "32-bit HP-UX 11/ia64 needs _LARGEFILE_SOURCE for fseeko in C++"
- #endif
- #endif
- #include <sys/types.h> /* for off_t */
- #include <stdio.h>]],
- [[int (*fp) (FILE *, off_t, int) = fseeko;
- return fseeko (stdin, 0, 0) && fp (stdin, 0, 0);]])
-
-# We used to try defining _XOPEN_SOURCE=500 too, to work around a bug
-# in glibc 2.1.3, but that breaks too many other things.
-# If you want fseeko and ftello with glibc, upgrade to a fixed glibc.
-if test $ac_cv_sys_largefile_source != unknown; then
- AC_DEFINE(HAVE_FSEEKO, 1,
- [Define to 1 if fseeko (and presumably ftello) exists and is declared.])
-fi
+[AC_CACHE_CHECK([for declarations of fseeko and ftello],
+ [ac_cv_func_fseeko_ftello],
+ [AC_COMPILE_IFELSE([_AC_FUNC_FSEEKO_TEST_PROGRAM],
+ [ac_cv_func_fseeko_ftello=yes],
+ [ac_save_CPPFLAGS="$CPPFLAGS"
+ CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE=1"
+ AC_COMPILE_IFELSE([_AC_FUNC_FSEEKO_TEST_PROGRAM],
+ [ac_cv_func_fseeko_ftello="need _LARGEFILE_SOURCE"],
+ [ac_cv_func_fseeko_ftello=no])])])
+AS_IF([test "$ac_cv_func_fseeko_ftello" != no],
+ [AC_DEFINE([HAVE_FSEEKO], [1],
+ [Define to 1 if fseeko (and ftello) are declared in stdio.h.])])
+AS_IF([test "$ac_cv_func_fseeko_ftello" = "need _LARGEFILE_SOURCE"],
+ [AC_DEFINE([_LARGEFILE_SOURCE], [1],
+ [Define to 1 if necessary to make fseeko visible.])])
])# AC_FUNC_FSEEKO
-
# AC_FUNC_GETGROUPS
# -----------------
# Try to find 'getgroups', and check that it works.
diff --git a/lib/autoconf/specific.m4 b/lib/autoconf/specific.m4
index 231da8da..0493d01d 100644
--- a/lib/autoconf/specific.m4
+++ b/lib/autoconf/specific.m4
@@ -85,9 +85,13 @@ AU_DEFUN([AC_ARG_ARRAY], [],
with arguments. Remove this warning when you adjust your code.])
-# _AC_SYS_YEAR2038_TEST_INCLUDES
-# ------------------------------
-AC_DEFUN([_AC_SYS_YEAR2038_TEST_INCLUDES],
+# _AC_SYS_YEAR2038_TEST_CODE
+# --------------------------
+# C code used to probe for time_t that can represent time points more
+# than 2**31 - 1 seconds after the epoch. With the usual Unix epoch,
+# these correspond to dates after 2038-01-18 22:14:07 +0000 (Gregorian),
+# hence the name.
+AC_DEFUN([_AC_SYS_YEAR2038_TEST_CODE],
[[
#include <time.h>
/* Check that time_t can represent 2**32 - 1 correctly. */
@@ -98,102 +102,171 @@ AC_DEFUN([_AC_SYS_YEAR2038_TEST_INCLUDES],
? 1 : -1];
]])
-# _AC_SYS_YEAR2038(REQUIRE-YEAR2038-SAFE)
-# ---------------------------------------
-AC_DEFUN([_AC_SYS_YEAR2038],
-[
- AC_ARG_ENABLE([year2038],
- [ --disable-year2038 omit support for timestamps past the year 2038])
- AS_IF([test "$enable_year2038" != no],
- [
- dnl On many systems, time_t is already a 64-bit type.
- dnl On those systems where time_t is still 32-bit, it requires kernel
- dnl and libc support to make it 64-bit. For glibc 2.34 and later on Linux,
- dnl defining _TIME_BITS=64 and _FILE_OFFSET_BITS=64 is needed on x86 and ARM.
- dnl
- dnl On native Windows, the system include files define types __time32_t
- dnl and __time64_t. By default, time_t is an alias of
- dnl - __time32_t on 32-bit mingw,
- dnl - __time64_t on 64-bit mingw and on MSVC (since MSVC 8).
- dnl But when compiling with -D__MINGW_USE_VC2005_COMPAT, time_t is an
- dnl alias of __time64_t.
- dnl And when compiling with -D_USE_32BIT_TIME_T, time_t is an alias of
- dnl __time32_t.
- AC_CACHE_CHECK([for time_t past the year 2038], [ac_cv_type_time_t_y2038],
- [AC_COMPILE_IFELSE(
- [AC_LANG_SOURCE([_AC_SYS_YEAR2038_TEST_INCLUDES])],
- [ac_cv_type_time_t_y2038=yes], [ac_cv_type_time_t_y2038=no])
- ])
- if test "$ac_cv_type_time_t_y2038" = no; then
- AC_CACHE_CHECK([for 64-bit time_t with _TIME_BITS=64],
- [ac_cv_type_time_t_bits_macro],
- [AC_COMPILE_IFELSE(
- [AC_LANG_SOURCE([[#define _TIME_BITS 64
- #define _FILE_OFFSET_BITS 64
- ]_AC_SYS_YEAR2038_TEST_INCLUDES])],
- [ac_cv_type_time_t_bits_macro=yes],
- [ac_cv_type_time_t_bits_macro=no])
- ])
- if test "$ac_cv_type_time_t_bits_macro" = yes; then
- AC_DEFINE([_TIME_BITS], [64],
- [Number of bits in a timestamp, on hosts where this is settable.])
- dnl AC_SYS_LARGFILE also defines this; it's OK if we do too.
- AC_DEFINE([_FILE_OFFSET_BITS], [64],
- [Number of bits in a file offset, on hosts where this is settable.])
- ac_cv_type_time_t_y2038=yes
- fi
- fi
- if test $ac_cv_type_time_t_y2038 = no; then
- AC_COMPILE_IFELSE(
- [AC_LANG_SOURCE(
- [[#ifdef _USE_32BIT_TIME_T
- int ok;
- #else
- error fail
- #endif
- ]])],
- [AC_MSG_FAILURE(
- [The 'time_t' type stops working after January 2038.
- Remove _USE_32BIT_TIME_T from the compiler flags.])],
- [# If not cross-compiling and $1 says we should check,
- # and 'touch' works with a large timestamp, then evidently wider time_t
- # is desired and supported, so fail and ask the builder to fix the
- # problem. Otherwise, just warn the builder.
- m4_ifval([$1],
- [if test $cross_compiling = no \
- && TZ=UTC0 touch -t 210602070628.15 conftest.time 2>/dev/null; then
- case `TZ=UTC0 LC_ALL=C ls -l conftest.time 2>/dev/null` in
- *'Feb 7 2106'* | *'Feb 7 17:10'*)
- AC_MSG_FAILURE(
- [The 'time_t' type stops working after January 2038,
- and your system appears to support a wider 'time_t'.
- Try configuring with 'CC="${CC} -m64"'.
- To build with a 32-bit time_t anyway (not recommended),
- configure with '--disable-year2038'.]);;
- esac
- rm -f conftest.time
- fi])
- if test "$ac_warned_about_y2038" != yes; then
- AC_MSG_WARN(
- [The 'time_t' type stops working after January 2038,
- and this package needs a wider 'time_t' type
- if there is any way to access timestamps after that.
- Configure with 'CC="${CC} -m64"' perhaps?])
- ac_warned_about_y2038=yes
- fi
- ])
- fi])
+# _AC_SYS_YEAR2038_OPTIONS
+# ------------------------
+# List of known ways to enable support for large time_t. If you change
+# this list you probably also need to change the AS_CASE at the end of
+# _AC_SYS_YEAR2038_PROBE.
+m4_define([_AC_SYS_YEAR2038_OPTIONS], m4_normalize(
+ ["none needed"] dnl 64-bit and newer 32-bit Unix
+ ["-D_TIME_BITS=64"] dnl glibc 2.34 with some 32-bit ABIs
+ ["-D__MINGW_USE_VC2005_COMPAT"] dnl 32-bit MinGW
+ ["-U_USE_32_BIT_TIME_T -D__MINGW_USE_VC2005_COMPAT"]
+ dnl 32-bit MinGW (misconfiguration)
+))
+
+# _AC_SYS_YEAR2038_PROBE([IF-NOT-DETECTED])
+# -----------------------------------------
+# Subroutine of AC_SYS_YEAR2038. Probe for time_t that can represent
+# time points more than 2**31 - 1 seconds after the epoch (dates after
+# 2038-01-18, see above) and set the cache variable ac_cv_sys_year2038_opts
+# to one of the values in the _AC_SYS_YEAR2038_OPTIONS list, or to
+# "support not detected" if none of them worked. Then, set compilation
+# options and #defines as necessary to enable large time_t support.
+#
+# Note that we do not test whether mktime, localtime, etc. handle
+# large values of time_t correctly, as that would require use of
+# AC_TRY_RUN. Note also that some systems only support large time_t
+# together with large off_t.
+#
+# If support is not detected, the behavior depends on which of the
+# top-level AC_SYS_YEAR2038 macros was used (see below).
+#
+# If you change this macro you may also need to change
+# _AC_SYS_YEAR2038_OPTIONS.
+AC_DEFUN([_AC_SYS_YEAR2038_PROBE],
+[AC_CACHE_CHECK([for $CC option to enable timestamps after Jan 2038],
+ [ac_cv_sys_year2038_opts],
+ [ac_save_CPPFLAGS="$CPPFLAGS"
+ ac_opt_found=no
+ for ac_opt in _AC_SYS_YEAR2038_OPTIONS; do
+ AS_IF([test x"$ac_opt" != x"none needed"],
+ [CPPFLAGS="$ac_save_CPPFLAGS $ac_opt"])
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([_AC_SYS_YEAR2038_TEST_CODE])],
+ [ac_cv_sys_year2038_opts="$ac_opt"
+ ac_opt_found=yes])
+ test $ac_opt_found = no || break
+ done
+ CPPFLAGS="$ac_save_CPPFLAGS"
+ test $ac_opt_found = yes || ac_cv_sys_year2038_opts="support not detected"])
+
+ac_have_year2038=yes
+AS_CASE([$ac_cv_sys_year2038_opts],
+ ["none needed"], [],
+ ["support not detected"],
+ [ac_have_year2038=no
+ AS_CASE([$enable_year2038],
+ [required],
+ [AC_MSG_FAILURE([support for timestamps after Jan 2038 is required])],
+ [yes],
+ [# If we're not cross compiling and 'touch' works with a large
+ # timestamp, then we can presume the system supports wider time_t
+ # *somehow* and we just weren't able to detect it. One common
+ # case that we deliberately *don't* probe for is a system that
+ # supports both 32- and 64-bit ABIs but only the 64-bit ABI offers
+ # wide time_t. (It would be inappropriate for us to override an
+ # intentional use of -m32.) Error out, demanding use of
+ # --disable-year2038 if this is intentional.
+ AS_IF([test $cross_compiling = no],
+ [AS_IF([TZ=UTC0 touch -t 210602070628.15 conftest.time 2>/dev/null],
+ [AS_CASE([`TZ=UTC0 LC_ALL=C ls -l conftest.time 2>/dev/null`],
+ [*'Feb 7 2106'* | *'Feb 7 17:10'*],
+ [AC_MSG_FAILURE(m4_text_wrap(
+ [this system appears to support timestamps after January 2038,
+ but no mechanism for enabling wide 'time_t' was detected.
+ Did you mean to build a 64-bit binary? (e.g. 'CC="${CC} -m64"'.)
+ To proceed with 32-bit time_t, configure with '--disable-year2038'.],
+ [], [], [55]))])])])])],
+
+ ["-D_TIME_BITS=64"],
+ [AC_DEFINE([_TIME_BITS], [64],
+ [Number of bits in time_t, on hosts where this is settable.])],
+
+ ["-D__MINGW_USE_VC2005_COMPAT=1"],
+ [AC_DEFINE([__MINGW_USE_VC2005_COMPAT], [1],
+ [Define to 1 on platforms where this makes time_t a 64-bit type.])],
+
+ ["-U_USE_32_BIT_TIME_T"*],
+ [AC_MSG_FAILURE(m4_text_wrap(
+ [the 'time_t' type is currently forced to be 32-bit.
+ It will stop working after January 2038.
+ Remove _USE_32BIT_TIME_T from the compiler flags.],
+ [], [], [55]))],
+
+ [AC_MSG_ERROR(
+ [internal error: bad value for \$ac_cv_sys_year2038_opts])])
])
+# _AC_SYS_YEAR2038_ENABLE
+# -----------------------
+# Subroutine of AC_SYS_YEAR2038 and _AC_SYS_YEAR2038_OPT_IN.
+# Depending on which of the YEAR2038 macros was used, add either an
+# --enable-year2038, or a --disable-year2038, or no option at all to
+# the configure script. Note that this is expanded very late and
+# therefore there cannot be any code in the AC_ARG_ENABLE. The
+# default value for `enable_year2038` is emitted unconditionally
+# because the generated code always looks at this variable.
+m4_define([_AC_SYS_YEAR2038_ENABLE],
+[m4_divert_text([DEFAULTS],
+ m4_provide_if([AC_SYS_YEAR2038_REQUIRED],
+ [enable_year2038=required],
+ m4_provide_if([AC_SYS_YEAR2038],
+ [enable_year2038=yes],
+ [enable_year2038=no])))]dnl
+[m4_provide_if([AC_SYS_YEAR2038_REQUIRED], [],
+[AC_ARG_ENABLE([year2038],
+ m4_provide_if([AC_SYS_YEAR2038],
+ [AS_HELP_STRING([--disable-year2038],
+ [omit support for dates after Jan 2038])],
+ [AS_HELP_STRING([--enable-year2038],
+ [include support for dates after Jan 2038])]))])])
+
+# _AC_SYS_YEAR2038_OPT_IN
+# -----------------------
+# If the --enable-year2038 option is given to configure, attempt to
+# detect and activate support for large time_t on 32-bit systems.
+# This macro is automatically invoked by AC_SYS_LARGEFILE when large
+# *file* support is detected. It does not AC_REQUIRE AC_SYS_LARGEFILE
+# to avoid a dependency loop, and is therefore unsafe to expose as a
+# documented macro.
+AC_DEFUN([_AC_SYS_YEAR2038_OPT_IN],
+[m4_provide_if([_AC_SYS_YEAR2038_PROBE], [], [dnl
+ AS_IF([test "$enable_year2038" != no], [_AC_SYS_YEAR2038_PROBE])
+ AC_CONFIG_COMMANDS_PRE([_AC_SYS_YEAR2038_ENABLE])
+])])
+
+# AC_SYS_YEAR2038
+# ---------------
+# Attempt to detect and activate support for large time_t.
+# On systems where time_t is not always 64 bits, this probe can be
+# skipped by passing the --disable-year2038 option to configure.
AC_DEFUN([AC_SYS_YEAR2038],
-[
- _$0([require-year2038-safe])
-])
-
-
-# _AC_SYS_LARGEFILE_TEST_INCLUDES
-# -------------------------------
-m4_define([_AC_SYS_LARGEFILE_TEST_INCLUDES],
+[m4_provide_if([AC_SYS_LARGEFILE_REQUIRED], [],
+ [AC_REQUIRE([AC_SYS_LARGEFILE])])]dnl
+[m4_provide_if([_AC_SYS_YEAR2038_PROBE], [], [dnl
+ AS_IF([test "$enable_year2038" != no], [_AC_SYS_YEAR2038_PROBE])
+ AC_CONFIG_COMMANDS_PRE([_AC_SYS_YEAR2038_ENABLE])
+])])
+
+# AC_SYS_YEAR2038_REQUIRED
+# ------------------------
+# Same as AC_SYS_YEAR2038, but declares that this program *requires*
+# support for large time_t. If we cannot find any way to make time_t
+# capable of representing values larger than 2**31 - 1, configure will
+# error out. Furthermore, no --enable-year2038 nor --disable-year2038
+# option will be available.
+AC_DEFUN([AC_SYS_YEAR2038_REQUIRED],
+[m4_provide_if([AC_SYS_LARGEFILE_REQUIRED], [],
+ [AC_REQUIRE([AC_SYS_LARGEFILE])])]dnl
+[m4_provide_if([_AC_SYS_YEAR2038_PROBE], [], [dnl
+ _AC_SYS_YEAR2038_PROBE
+ AC_CONFIG_COMMANDS_PRE([_AC_SYS_YEAR2038_ENABLE])
+])])
+
+# _AC_SYS_LARGEFILE_TEST_CODE
+# ---------------------------
+# C code used to probe for large file support.
+m4_define([_AC_SYS_LARGEFILE_TEST_CODE],
[@%:@include <sys/types.h>
/* Check that off_t can represent 2**63 - 1 correctly.
We can't simply define LARGE_OFF_T to be 9223372036854775807,
@@ -205,33 +278,89 @@ m4_define([_AC_SYS_LARGEFILE_TEST_INCLUDES],
? 1 : -1]];[]dnl
])
+# _AC_SYS_LARGEFILE_OPTIONS
+# -------------------------
+# List of known ways to enable support for large files. If you change
+# this list you probably also need to change the AS_CASE at the end of
+# _AC_SYS_LARGEFILE_PROBE.
+m4_define([_AC_SYS_LARGEFILE_OPTIONS], m4_normalize(
+ ["none needed"] dnl Most current systems
+ ["-D_FILE_OFFSET_BITS=64"] dnl X/Open LFS spec
+ ["-D_LARGE_FILES=1"] dnl AIX (which versions?)
+ ["-n32"] dnl Irix 6.2 w/ SGI compiler
+))
+
+# _AC_SYS_LARGEFILE_PROBE
+# -----------------------
+# Subroutine of AC_SYS_LARGEFILE. Probe for large file support and set
+# the cache variable ac_cv_sys_largefile_opts to one of the values in
+# the _AC_SYS_LARGEFILE_OPTIONS list, or to "support not detected" if
+# none of the options in that list worked. Then, set compilation
+# options and #defines as necessary to enable large file support.
+#
+# If large file support is not detected, the behavior depends on which of
+# the top-level AC_SYS_LARGEFILE macros was used (see below).
+#
+# If you change this macro you may also need to change
+# _AC_SYS_LARGEFILE_OPTIONS.
+AC_DEFUN([_AC_SYS_LARGEFILE_PROBE],
+[AC_CACHE_CHECK([for $CC option to enable large file support],
+ [ac_cv_sys_largefile_opts],
+ [ac_save_CC="$CC"
+ ac_opt_found=no
+ for ac_opt in _AC_SYS_LARGEFILE_OPTIONS; do
+ AS_IF([test x"$ac_opt" != x"none needed"],
+ [CC="$ac_save_CC $ac_opt"])
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([_AC_SYS_LARGEFILE_TEST_CODE])],
+ [ac_cv_sys_largefile_opts="$ac_opt"
+ ac_opt_found=yes])
+ test $ac_opt_found = no || break
+ done
+ CC="$ac_save_CC"
+ test $ac_opt_found = yes || ac_cv_sys_largefile_opts="support not detected"])
+
+ac_have_largefile=yes
+AS_CASE([$ac_cv_sys_largefile_opts],
+ ["none needed"], [],
+ ["support not detected"],
+ [ac_have_largefile=no
+ AS_IF([test $enable_largefile = required],
+ [AC_MSG_FAILURE([support for large files is required])])],
+
+ ["-D_FILE_OFFSET_BITS=64"],
+ [AC_DEFINE([_FILE_OFFSET_BITS], [64],
+ [Number of bits in a file offset, on hosts where this is settable.])],
+
+ ["-D_LARGE_FILES=1"],
+ [AC_DEFINE([_LARGE_FILES], [1],
+ [Define to 1 on platforms where this makes off_t a 64-bit type.])],
+
+ ["-n32"],
+ [CC="$CC -n32"],
+
+ [AC_MSG_ERROR(
+ [internal error: bad value for \$ac_cv_sys_largefile_opts])])
+
+_AC_SYS_YEAR2038_OPT_IN
+])
-# _AC_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE,
-# CACHE-VAR,
-# DESCRIPTION,
-# PROLOGUE, [FUNCTION-BODY])
-# --------------------------------------------------------
-m4_define([_AC_SYS_LARGEFILE_MACRO_VALUE],
-[AC_CACHE_CHECK([for $1 value needed for large files], [$3],
-[while :; do
- m4_ifval([$6], [AC_LINK_IFELSE], [AC_COMPILE_IFELSE])(
- [AC_LANG_PROGRAM([$5], [$6])],
- [$3=no; break])
- m4_ifval([$6], [AC_LINK_IFELSE], [AC_COMPILE_IFELSE])(
- [AC_LANG_PROGRAM([#undef $1
-#define $1 $2
-$5], [$6])],
- [$3=$2; break])
- $3=unknown
- break
-done])
-case $$3 in #(
- no | unknown) ;;
- *) AC_DEFINE_UNQUOTED([$1], [$$3], [$4]);;
-esac
-rm -rf conftest*[]dnl
-])# _AC_SYS_LARGEFILE_MACRO_VALUE
-
+# _AC_SYS_LARGEFILE_ENABLE
+# ------------------------
+# Subroutine of AC_SYS_LARGEFILE. If AC_SYS_LARGEFILE_REQUIRED was
+# not used at any point in this configure script, add a
+# --disable-largefile option to the configure script. Note that this
+# is expanded very late and therefore there cannot be any code in the
+# AC_ARG_ENABLE. The default value for `enable_largefile` is emitted
+# unconditionally because the generated shell code always looks at
+# this variable.
+m4_define([_AC_SYS_LARGEFILE_ENABLE],
+[m4_divert_text([DEFAULTS],
+ m4_provide_if([AC_SYS_LARGEFILE_REQUIRED],
+ [enable_largefile=required],
+ [enable_largefile=yes]))]dnl
+[m4_provide_if([AC_SYS_LARGEFILE_REQUIRED], [],
+[AC_ARG_ENABLE([largefile],
+ [AS_HELP_STRING([--disable-largefile], [omit support for large files])])])])
# AC_SYS_LARGEFILE
# ----------------
@@ -242,50 +371,28 @@ rm -rf conftest*[]dnl
# Additionally, on Linux file systems with 64-bit inodes a file that happens
# to have a 64-bit inode number cannot be accessed by 32-bit applications on
# Linux x86/x86_64. This can occur with file systems such as XFS and NFS.
+# This macro allows configuration to continue if the system doesn't support
+# large files; see also AC_SYS_LARGEFILE_REQUIRED.
AC_DEFUN([AC_SYS_LARGEFILE],
-[AC_ARG_ENABLE(largefile,
- [ --disable-largefile omit support for large files])
-AS_IF([test "$enable_largefile" != no],
- [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
-
- _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])
- AS_CASE([$ac_cv_sys_file_offset_bits],
- [unknown],
- [_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])],
- [64],
- [_AC_SYS_YEAR2038()])])
-
- AH_VERBATIM([__MINGW_USE_VC2005_COMPAT],
-[#if !defined __MINGW_USE_VC2005_COMPAT && defined __MINGW32__
-# define __MINGW_USE_VC2005_COMPAT 1 /* For 64-bit time_t. */
-#endif])
-])# AC_SYS_LARGEFILE
-
+[m4_provide_if([_AC_SYS_LARGEFILE_PROBE], [], [dnl
+ AS_IF([test "$enable_largefile" != no], [_AC_SYS_LARGEFILE_PROBE])
+ AC_CONFIG_COMMANDS_PRE([_AC_SYS_LARGEFILE_ENABLE])
+])])
+
+# AC_SYS_LARGEFILE_REQUIRED
+# -------------------------
+# Same as AC_SYS_LARGEFILE, but declares that this program *requires*
+# support for large files. If we cannot find a combination of compiler
+# options and #defines that makes `off_t` capable of representing 2**63 - 1,
+# `configure` will error out. Furthermore, `configure` will not offer a
+# --disable-largefile command line option.
+# If both AC_SYS_LARGEFILE and AC_SYS_LARGEFILE_REQUIRED are used in the
+# same configure script -- in either order -- AC_SYS_LARGEFILE_REQUIRED wins.
+AC_DEFUN([AC_SYS_LARGEFILE_REQUIRED],
+[m4_provide_if([_AC_SYS_LARGEFILE_PROBE], [], [dnl
+ _AC_SYS_LARGEFILE_PROBE
+ AC_CONFIG_COMMANDS_PRE([_AC_SYS_LARGEFILE_ENABLE])
+])])
# AC_SYS_LONG_FILE_NAMES
# ----------------------
diff --git a/tests/local.at b/tests/local.at
index a9cf4050..158ba841 100644
--- a/tests/local.at
+++ b/tests/local.at
@@ -347,6 +347,8 @@ m4_define([AT_CHECK_CONFIGURE],
# Set by AC_INIT.
# - interpval
# Set by AC_SYS_INTERPRETER.
+# - enableval, withval, enable_*, with_*
+# Set by AC_ARG_ENABLE and AC_ARG_WITH.
# - CONFIG_STATUS and DEFS
# Set by AC_OUTPUT.
# - AC_SUBST'ed variables
@@ -381,7 +383,7 @@ if test -f state-env.before && test -f state-env.after; then
($EGREP -v '^(m4_join([|],
[a[cs]_.*],
[(exec_)?prefix|DEFS|CONFIG_STATUS],
- [CC|CFLAGS|CPP|GCC|CXX|CXXFLAGS|CXXCPP|GXX|F77|FFLAGS|FLIBS|G77],
+ [CC|CFLAGS|CPPFLAGS|CPP|GCC|CXX|CXXFLAGS|CXXCPP|GXX|F77|FFLAGS|FLIBS|G77],
[ERL|ERLC|ERLCFLAGS|ERLANG_PATH_ERL|ERLANG_ROOT_DIR|ERLANG_LIB_DIR],
[ERLANG_LIB_DIR_.*|ERLANG_LIB_VER_.*|ERLANG_INSTALL_LIB_DIR],
[ERLANG_INSTALL_LIB_DIR_.*|ERLANG_ERTS_VER|OBJC|OBJCPP|OBJCFLAGS],
@@ -395,6 +397,7 @@ if test -f state-env.before && test -f state-env.after; then
[X_(CFLAGS|(EXTRA_|PRE_)?LIBS)|x_(includes|libraries)|(have|no)_x],
[(host|build|target)(_(alias|cpu|vendor|os))?],
[cross_compiling|U],
+ [enableval|enable_.*|withval|with_.*],
[interpval|PATH_SEPARATOR],
[GFC|F77_DUMMY_MAIN|f77_(case|underscore)],
[FC(_DUMMY_MAIN|FLAGS|LIBS|FLAGS_[fF]|_MODEXT|_MODINC|_MODOUT|_DEFINE)?],