compiling FreeBSD date on Linux

Chuck Robey chuckr at
Wed May 20 00:38:46 UTC 2009

Polytropon wrote:
> On Tue, 19 May 2009 18:19:21 -0300, francis keyes <fkeymo at> wrote:
>> I would like to compile the FreeBSD date command for use on Linux because
>> the FreeBSD version has some features that are not present in Linux.
>> I downloaded all the files from
>> and tried to compile it
>> but I get an error from the Makefile:
>> Makefile:9: *** missing separator.  Stop.
> First of all, it seems that it's not that easy. FreeBSD's make
> is, if I am correct, a different one than the Linux make. It
> uses - if you look into date's Makefile, an include file,
> named which is located outside of the date/ directory,
> this is /usr/share/mk/ or /usr/src/share/mk/
> or /usr/src/tools/build/mk/ You could try to write
> an own Makefile on Linux, or try to work without one...
>> I suspect this is the first of many errors I will run into during this
>> process.  Can anyone help me out with this or tell me if there is an easier
>> way to get this version of the date command running in Linux?
> I'm not sure, but it's possible that FreeBSD can be used to
> compile date so it will run on Linux (cross-compier). Because
> I never tried this, I can't tell you how to achieve this.
> Furthermore, I'm not sure in how far date hooks into the FreeBSD
> kernel in order to work. It's completely possible that it would
> be easier to implement FreeBSD's date functionality in Linux's
> date command itself ("from scratch").

The code isn't all that hard to port, unless you're at a very basic level with
C.  The compatibility level between the BSD Make (bmake) and the GNU Make
(gmake) isn't all that great.  One killer problem is that gmake hasn't got any
concept of a single central include directory, for automatically building up a
per machine make environment.  Gmake can do the including (using a protocol
which is unfortunately different than that of bmake) BUT you can't just rely on
gmake looking into the bmake central directory (/usr/share/mk) for make include
files.  All of those are named like "", in that they all begin with
"bsd." and end in ".mk", and there isn't any portability between bmake and gmake
on those include files.  I have personally (in the past) written up a set of
gmake compatible include files, so it CAN be done, but you getter have your hard
hat on, it's not all that simple to do.

The various timing commands in either the bsd libc or the Linux glibc look much
alike, so the porting isn't all that hard, once you conquer the makefiles.


More information about the freebsd-questions mailing list