Blame m4/ax_build_date_epoch.m4

Packit e9ba0d
# ===========================================================================
Packit e9ba0d
#    http://www.gnu.org/software/autoconf-archive/ax_build_date_epoch.html
Packit e9ba0d
# ===========================================================================
Packit e9ba0d
#
Packit e9ba0d
# SYNOPSIS
Packit e9ba0d
#
Packit e9ba0d
#   AX_BUILD_DATE_EPOCH(VARIABLE[, FORMAT[, ACTION-IF-FAIL]])
Packit e9ba0d
#
Packit e9ba0d
# DESCRIPTION
Packit e9ba0d
#
Packit e9ba0d
#   Sets VARIABLE to a string representing the current time.  It is
Packit e9ba0d
#   formatted according to FORMAT if specified, otherwise it is formatted as
Packit e9ba0d
#   the number of seconds (excluding leap seconds) since the UNIX epoch (01
Packit e9ba0d
#   Jan 1970 00:00:00 UTC).
Packit e9ba0d
#
Packit e9ba0d
#   If the SOURCE_DATE_EPOCH environment variable is set, it uses the value
Packit e9ba0d
#   of that variable instead of the current time.  See
Packit e9ba0d
#   https://reproducible-builds.org/specs/source-date-epoch).  If
Packit e9ba0d
#   SOURCE_DATE_EPOCH is set but cannot be properly interpreted as a UNIX
Packit e9ba0d
#   timestamp, then execute ACTION-IF-FAIL if specified, otherwise error.
Packit e9ba0d
#
Packit e9ba0d
#   VARIABLE is AC_SUBST-ed.
Packit e9ba0d
#
Packit e9ba0d
# LICENSE
Packit e9ba0d
#
Packit e9ba0d
#   Copyright (c) 2016 Eric Bavier <bavier@member.fsf.org>
Packit e9ba0d
#
Packit e9ba0d
#   This program is free software: you can redistribute it and/or modify it
Packit e9ba0d
#   under the terms of the GNU General Public License as published by the
Packit e9ba0d
#   Free Software Foundation, either version 3 of the License, or (at your
Packit e9ba0d
#   option) any later version.
Packit e9ba0d
#
Packit e9ba0d
#   This program is distributed in the hope that it will be useful, but
Packit e9ba0d
#   WITHOUT ANY WARRANTY; without even the implied warranty of
Packit e9ba0d
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Packit e9ba0d
#   Public License for more details.
Packit e9ba0d
#
Packit e9ba0d
#   You should have received a copy of the GNU General Public License along
Packit e9ba0d
#   with this program. If not, see <http://www.gnu.org/licenses/>.
Packit e9ba0d
#
Packit e9ba0d
#   As a special exception, the respective Autoconf Macro's copyright owner
Packit e9ba0d
#   gives unlimited permission to copy, distribute and modify the configure
Packit e9ba0d
#   scripts that are the output of Autoconf when processing the Macro. You
Packit e9ba0d
#   need not follow the terms of the GNU General Public License when using
Packit e9ba0d
#   or distributing such scripts, even though portions of the text of the
Packit e9ba0d
#   Macro appear in them. The GNU General Public License (GPL) does govern
Packit e9ba0d
#   all other use of the material that constitutes the Autoconf Macro.
Packit e9ba0d
#
Packit e9ba0d
#   This special exception to the GPL applies to versions of the Autoconf
Packit e9ba0d
#   Macro released by the Autoconf Archive. When you make and distribute a
Packit e9ba0d
#   modified version of the Autoconf Macro, you may extend this special
Packit e9ba0d
#   exception to the GPL to apply to your modified version as well.
Packit e9ba0d
Packit e9ba0d
#serial 1
Packit e9ba0d
Packit e9ba0d
AC_DEFUN([AX_BUILD_DATE_EPOCH],
Packit e9ba0d
[dnl
Packit e9ba0d
AC_MSG_CHECKING([for build time])
Packit e9ba0d
ax_date_fmt="m4_default($2,%s)"
Packit e9ba0d
AS_IF([test x"$SOURCE_DATE_EPOCH" = x],
Packit e9ba0d
 [$1=`date -u "+$ax_date_fmt"`],
Packit e9ba0d
 [ax_build_date=`date -u -d "@$SOURCE_DATE_EPOCH" "+$ax_date_fmt" 2>/dev/null \
Packit e9ba0d
                 || date -u -r "$SOURCE_DATE_EPOCH" "+$ax_date_fmt" 2>/dev/null`
Packit e9ba0d
  AS_IF([test x"$ax_build_date" = x],
Packit e9ba0d
   [m4_ifval([$3],
Packit e9ba0d
      [$3],
Packit e9ba0d
      [AC_MSG_ERROR([malformed SOURCE_DATE_EPOCH])])],
Packit e9ba0d
   [$1=$ax_build_date])])
Packit e9ba0d
AC_MSG_RESULT([$$1])
Packit e9ba0d
])dnl AX_BUILD_DATE_EPOCH