[U-Boot] [RFC PATCH] Makefile: search for GNU date

Andreas Bießmann andreas.devel at googlemail.com
Thu Aug 27 10:56:49 CEST 2015


On 08/27/2015 10:32 AM, Paul Kocialkowski wrote:
> Le jeudi 27 août 2015 à 10:13 +0200, Andreas Bießmann a écrit :
>> The SOURCE_DATE_EPOCH mechanism for reproducible builds requires the GNU
>> variant of date. Respect this and search it, error on missing GNU date.
> 
> Well, IMHO we shouldn't check for GNU date but for the extensions it
> implements. Those could be included in other date implementations. For
> instance, it looks like busybox's date implements the -u and -d options
> too.

But BSD date used the -d switch to set the timezone [1] ...

---8<---
  -d	dst  Set the kernel's value for	daylight saving	time.  If dst
             is non-zero, future calls	to gettimeofday(2) will	return
             a non-zero for tz_dsttime.
--->8---

And it is the same for OS X [2].

>> Signed-off-by: Andreas Bießmann <andreas.devel at googlemail.com>
>> ---
>> This commit tries to figure out if we have a GNU date variant
>> available. It errors on missing GNU date when it is required (for
>> SOURCE_DATE_EPOCH set). The result is:
> 
> Also, I don't think it should be up to the Makefile to figure out which
> date binary to use. It should be up to the user to put the right one as
> "date", e.g. with an alias. That is, unless the name for GNU date is
> something really standardized on non-GNU systems.

Most *BSD systems use gdate or date.gnu for the GNU variant of date, if
available. The date tool available is the one of the *BSD distributiuon.
HAving a shell alias for date covering gdate is for some users not an
option. So it has to be some make variable. For me it would be neat to
have the make find some possible solution (e.g. search for the GNU
variant on systems which have it).

>> diff --git a/Makefile b/Makefile
>> index b9b2375..95eae64 100644
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -346,6 +346,9 @@ PERL		= perl
>>  PYTHON		= python
>>  DTC		= dtc
>>  CHECK		= sparse
>> +GNUDATE	       := $(foreach date,gdate date.gnu date, \
>> +		    $(shell _date=`which $(date)`; \
>> +		      $${_date} --version 2> /dev/null | $(AWK) "/GNU coreutils/ { print \"$${_date}\"; }"))
> 
> I advise running date with the needed options (-u -d) and checked the
> error code instead of this. And of course, the variable names shouldn't
> mention GNU date.

Good point, let's see how my OS X date behaves with a set '-d' switch.

Andreas

[1] http://www.freebsd.org/cgi/man.cgi?query=date
[2]
https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/date.1.html


More information about the U-Boot mailing list