1# =========================================================================== 2# https://www.gnu.org/software/autoconf-archive/ax_build_date_epoch.html 3# =========================================================================== 4# 5# SYNOPSIS 6# 7# AX_BUILD_DATE_EPOCH(VARIABLE[, FORMAT[, ACTION-IF-FAIL]]) 8# 9# DESCRIPTION 10# 11# Sets VARIABLE to a string representing the current time. It is 12# formatted according to FORMAT if specified, otherwise it is formatted as 13# the number of seconds (excluding leap seconds) since the UNIX epoch (01 14# Jan 1970 00:00:00 UTC). 15# 16# If the SOURCE_DATE_EPOCH environment variable is set, it uses the value 17# of that variable instead of the current time. See 18# https://reproducible-builds.org/specs/source-date-epoch). If 19# SOURCE_DATE_EPOCH is set but cannot be properly interpreted as a UNIX 20# timestamp, then execute ACTION-IF-FAIL if specified, otherwise error. 21# 22# VARIABLE is AC_SUBST-ed. 23# 24# LICENSE 25# 26# Copyright (c) 2016 Eric Bavier <bavier@member.fsf.org> 27# 28# This program is free software: you can redistribute it and/or modify it 29# under the terms of the GNU General Public License as published by the 30# Free Software Foundation, either version 3 of the License, or (at your 31# option) any later version. 32# 33# This program is distributed in the hope that it will be useful, but 34# WITHOUT ANY WARRANTY; without even the implied warranty of 35# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 36# Public License for more details. 37# 38# You should have received a copy of the GNU General Public License along 39# with this program. If not, see <https://www.gnu.org/licenses/>. 40# 41# As a special exception, the respective Autoconf Macro's copyright owner 42# gives unlimited permission to copy, distribute and modify the configure 43# scripts that are the output of Autoconf when processing the Macro. You 44# need not follow the terms of the GNU General Public License when using 45# or distributing such scripts, even though portions of the text of the 46# Macro appear in them. The GNU General Public License (GPL) does govern 47# all other use of the material that constitutes the Autoconf Macro. 48# 49# This special exception to the GPL applies to versions of the Autoconf 50# Macro released by the Autoconf Archive. When you make and distribute a 51# modified version of the Autoconf Macro, you may extend this special 52# exception to the GPL to apply to your modified version as well. 53 54#serial 2 55 56AC_DEFUN([AX_BUILD_DATE_EPOCH], 57[dnl 58AC_MSG_CHECKING([for build time]) 59ax_date_fmt="m4_default($2,%s)" 60AS_IF([test x"$SOURCE_DATE_EPOCH" = x], 61 [$1=`date "+$ax_date_fmt"`], 62 [ax_build_date=`date -u -d "@$SOURCE_DATE_EPOCH" "+$ax_date_fmt" 2>/dev/null \ 63 || date -u -r "$SOURCE_DATE_EPOCH" "+$ax_date_fmt" 2>/dev/null` 64 AS_IF([test x"$ax_build_date" = x], 65 [m4_ifval([$3], 66 [$3], 67 [AC_MSG_ERROR([malformed SOURCE_DATE_EPOCH])])], 68 [$1=$ax_build_date])]) 69AC_MSG_RESULT([$$1]) 70])dnl AX_BUILD_DATE_EPOCH 71