1 # ===========================================================================
2 # https://www.gnu.org/software/autoconf-archive/ax_prog_date.html
3 # ===========================================================================
11 # This macro tries to determine the type of the date (1) command and some
12 # of its non-standard capabilities.
14 # The type is determined as follow:
16 # * If the version string contains "GNU", then:
17 # - The variable ax_cv_prog_date_gnu is set to "yes".
18 # - The variable ax_cv_prog_date_type is set to "gnu".
20 # * If date supports the "-v 1d" option, then:
21 # - The variable ax_cv_prog_date_bsd is set to "yes".
22 # - The variable ax_cv_prog_date_type is set to "bsd".
24 # * If both previous checks fail, then:
25 # - The variable ax_cv_prog_date_type is set to "unknown".
27 # The following capabilities of GNU date are checked:
29 # * If date supports the --date arg option, then:
30 # - The variable ax_cv_prog_date_gnu_date is set to "yes".
32 # * If date supports the --utc arg option, then:
33 # - The variable ax_cv_prog_date_gnu_utc is set to "yes".
35 # The following capabilities of BSD date are checked:
37 # * If date supports the -v 1d option, then:
38 # - The variable ax_cv_prog_date_bsd_adjust is set to "yes".
40 # * If date supports the -r arg option, then:
41 # - The variable ax_cv_prog_date_bsd_date is set to "yes".
43 # All the aforementioned variables are set to "no" before a check is
48 # Copyright (c) 2017 Enrico M. Crisostomo <enrico.m.crisostomo@gmail.com>
50 # This program is free software: you can redistribute it and/or modify it
51 # under the terms of the GNU General Public License as published by the
52 # Free Software Foundation, either version 3 of the License, or (at your
53 # option) any later version.
55 # This program is distributed in the hope that it will be useful, but
56 # WITHOUT ANY WARRANTY; without even the implied warranty of
57 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
58 # Public License for more details.
60 # You should have received a copy of the GNU General Public License along
61 # with this program. If not, see <http://www.gnu.org/licenses/>.
63 # As a special exception, the respective Autoconf Macro's copyright owner
64 # gives unlimited permission to copy, distribute and modify the configure
65 # scripts that are the output of Autoconf when processing the Macro. You
66 # need not follow the terms of the GNU General Public License when using
67 # or distributing such scripts, even though portions of the text of the
68 # Macro appear in them. The GNU General Public License (GPL) does govern
69 # all other use of the material that constitutes the Autoconf Macro.
71 # This special exception to the GPL applies to versions of the Autoconf
72 # Macro released by the Autoconf Archive. When you make and distribute a
73 # modified version of the Autoconf Macro, you may extend this special
74 # exception to the GPL to apply to your modified version as well.
78 AC_DEFUN([AX_PROG_DATE], [dnl
79 AC_CACHE_CHECK([for GNU date], [ax_cv_prog_date_gnu], [
80 ax_cv_prog_date_gnu=no
81 if date --version 2>/dev/null | head -1 | grep -q GNU
83 ax_cv_prog_date_gnu=yes
86 AC_CACHE_CHECK([for BSD date], [ax_cv_prog_date_bsd], [
87 ax_cv_prog_date_bsd=no
88 if date -v 1d > /dev/null 2>&1
90 ax_cv_prog_date_bsd=yes
93 AC_CACHE_CHECK([for date type], [ax_cv_prog_date_type], [
94 ax_cv_prog_date_type=unknown
95 if test "x${ax_cv_prog_date_gnu}" = "xyes"
97 ax_cv_prog_date_type=gnu
98 elif test "x${ax_cv_prog_date_bsd}" = "xyes"
100 ax_cv_prog_date_type=bsd
103 AS_VAR_IF([ax_cv_prog_date_gnu], [yes], [
104 AC_CACHE_CHECK([whether GNU date supports --date], [ax_cv_prog_date_gnu_date], [
105 ax_cv_prog_date_gnu_date=no
106 if date --date=@1512031231 > /dev/null 2>&1
108 ax_cv_prog_date_gnu_date=yes
111 AC_CACHE_CHECK([whether GNU date supports --utc], [ax_cv_prog_date_gnu_utc], [
112 ax_cv_prog_date_gnu_utc=no
113 if date --utc > /dev/null 2>&1
115 ax_cv_prog_date_gnu_utc=yes
119 AS_VAR_IF([ax_cv_prog_date_bsd], [yes], [
120 AC_CACHE_CHECK([whether BSD date supports -r], [ax_cv_prog_date_bsd_date], [
121 ax_cv_prog_date_bsd_date=no
122 if date -r 1512031231 > /dev/null 2>&1
124 ax_cv_prog_date_bsd_date=yes
128 AS_VAR_IF([ax_cv_prog_date_bsd], [yes], [
129 AC_CACHE_CHECK([whether BSD date supports -v], [ax_cv_prog_date_bsd_adjust], [
130 ax_cv_prog_date_bsd_adjust=no
131 if date -v 1d > /dev/null 2>&1
133 ax_cv_prog_date_bsd_adjust=yes