]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Autoconf: Use AC_SYS_YEAR2038_RECOMMENDED when possible
authorFrancois-Xavier Le Bail <[email protected]>
Fri, 14 Mar 2025 22:36:01 +0000 (23:36 +0100)
committerFrancois-Xavier Le Bail <[email protected]>
Tue, 18 Mar 2025 14:20:34 +0000 (15:20 +0100)
On Linux, if the environment variable BUILD_YEAR2038=yes, Autoconf
version >= 2.72 and GNU C Library version >= 2.34, uncomment
AC_SYS_YEAR2038_RECOMMENDED to ensure time_t is Y2038-safe.

Tested with: BUILD_YEAR2038=yes MATRIX_CMAKE=no ./build_matrix.sh
on linux-armv7l because currently CMake build don't have year 2038 support.

(backported from commit 7cd08fe7c4a07df9028084612f81f90bd1b8a412)

autogen.sh
configure.ac

index c84a6b5c5dd256080187e14cd2a1d48dc49296b9..34b3b17990c814c85e9f63c28a1aa7c10e90bd2d 100755 (executable)
@@ -1,6 +1,7 @@
 #!/bin/sh -e
 
 : "${AUTORECONF:=autoreconf}"
+: "${BUILD_YEAR2038:=no}"
 
 AUTORECONFVERSION=`$AUTORECONF --version 2>&1 | grep "^autoreconf" | sed 's/.*) *//'`
 
@@ -21,5 +22,26 @@ if [ "$maj" = "" ] || [ "$min" = "" ] || \
        exit 1
 fi
 
+# On Linux, if Autoconf version >= 2.72 and GNU C Library version >= 2.34,
+# s/AC_SYS_LARGEFILE/AC_SYS_YEAR2038_RECOMMENDED/ to ensure time_t
+# is Y2038-safe.
+if [ "$BUILD_YEAR2038" = yes ] && [ "`uname -s`" = Linux ]; then
+       if [ "$maj" -gt 2 ] || { [ "$maj" -eq 2 ] && [ "$min" -ge 72 ]; }; then
+               GLIBC_VERSION=`ldd --version|head -1|grep GLIBC|sed 's/.* //'`
+               maj_glibc=`echo "$GLIBC_VERSION" | cut -d. -f1`
+               min_glibc=`echo "$GLIBC_VERSION" | cut -d. -f2`
+               if [ "$maj_glibc" -gt 2 ] || { [ "$maj_glibc" -eq 2 ] && \
+                  [ "$min_glibc" -ge 34 ]; }; then
+                       CONFIGURE_AC_NEW="configure.ac.new$$"
+                       sed 's/^# \(AC_SYS_YEAR2038_RECOMMENDED\)/\1/' \
+                               <configure.ac >"$CONFIGURE_AC_NEW"
+                       cmp -s configure.ac "$CONFIGURE_AC_NEW" || \
+                       cat "$CONFIGURE_AC_NEW" >configure.ac
+                       rm -f "$CONFIGURE_AC_NEW"
+                       echo 'Setup to ensure time_t is Y2038-safe.'
+               fi
+       fi
+fi
+
 echo "$AUTORECONF identification: $AUTORECONFVERSION"
 "$AUTORECONF" -f
index ae4500e9b2e9e6533c0d67ffb3b5fc114e75eb98..c353691ec6bf5d02aeb6c891ea44a2bac6cd9616 100644 (file)
@@ -32,6 +32,11 @@ AC_LBL_C_INIT(V_CCOPT, V_INCLS)
 AC_LBL_C_INLINE
 
 AC_CHECK_HEADERS(rpc/rpc.h rpc/rpcent.h net/if.h)
+
+# On Linux, if Autoconf version >= 2.72 and GNU C Library version >= 2.34,
+# uncomment AC_SYS_YEAR2038_RECOMMENDED to ensure time_t is Y2038-safe.
+# (Can be done by autogen.sh)
+# AC_SYS_YEAR2038_RECOMMENDED
 #
 # Get the size of a void *, to know whether this is a 32-bit or 64-bit build.
 #