From b0fed8df8e38c35791f2314b5ac859d64c9a80c9 Mon Sep 17 00:00:00 2001 From: Julian Graham Date: Mon, 31 Mar 2014 18:12:46 -0400 Subject: [PATCH 6/6] [build] Support both GNU date and BSD date for irc-server timestamping. The arguments to GNU date and BSD date used for parsing and formatting date strings are different (and conflicting). Additionally, extracting file modification time and formatting it predictably are notoriously tricky to do portably. mdate-sh, as part of the GNU Autotools suite, takes responsibility for "pretty-printing" a modification timestamp for a file, so it seems reasonable to delegate to it when reproducing the behavior of GNU date's `-r' flag, which BSD date does not support. * src/irc-server/Makefile.am (timestamp.c): Detect BSD date and conditionally use mdate-sh to capture modification date of config.status. --- src/irc-server/Makefile.am | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/irc-server/Makefile.am b/src/irc-server/Makefile.am index e8a6743..8ab8fae 100644 --- a/src/irc-server/Makefile.am +++ b/src/irc-server/Makefile.am @@ -42,5 +42,14 @@ libircserver_a_SOURCES = \ BUILT_SOURCES = timestamp.c +# Detect the presence of GNU date, whose arguments are incompatible with those +# of BSD date. + timestamp.c: $(top_builddir)/config.status - date -r $< -u +'static char created[] = "%Y-%m-%d %R UTC";' > $@ + if date --version >/dev/null 2>&1; then \ + DATESTR=`date -r $< -u +'%Y-%m-%d %R UTC'`; \ + else \ + MDATE=`$(top_builddir)/build-aux/mdate-sh $<`; \ + DATESTR=`date -jf "%d %B %Y" "$$MDATE" +'%Y-%m-%d %R UTC'`; \ + fi; \ + printf 'static char created[] = "%s";\n' "$$DATESTR" > $@ -- 1.8.5.2 (Apple Git-48)