Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 20 Sep 2005 11:42:05 +0200 (CEST)
From:      Harti Brandt <hartmut.brandt@dlr.de>
To:        Harlan Stenn <stenn@ntp.isc.org>
Cc:        Giorgos Keramidas <keramida@freebsd.org>, freebsd-questions@freebsd.org
Subject:   Re: gmake/make dependency problem 
Message-ID:  <20050920111521.D754@beagle.kn.op.dlr.de>
In-Reply-To: <20050920090956.14D5F39AD2@ntp1.ntp.isc.org>
References:  <20050920090956.14D5F39AD2@ntp1.ntp.isc.org>

next in thread | previous in thread | raw e-mail | index | archive | help

Hi Harlan,

On Tue, 20 Sep 2005, Harlan Stenn wrote:

HS>I guess it depends on your definition of a "source" file.

That's fairly easy: what's left of the ':' is the target, what's right of
it is the source. This is just the terminology make is using.

HS>I think of a Makefile in terms of "target" and "dependency" files.
HS>
HS>Automake makes it easy to build a package in the source tree (in which
HS>case the "source" file is in the same directory as the object files) or
HS>in a separate build/object tree.

'Source' in make-speak is not the same as source code for the program 
you're going to compile. Posix make as such has no support for compiling 
in separate build/object trees.

HS>
HS>Under gmake the behavior is consistent.
HS>
HS>Under (at least FreeBSD's) (p)make, the behavior is not consistent.

That just depends on what one thinks is consistent. It works either way 
around. Just look at how easy you can build FreeBSD under /usr/obj - you 
don't need any cd commands in Makefiles usually.

HS>The example I face is no different that a system that uses lex and yacc
HS>(in the case where the distribution provides generated .c and .h files).

This is not the problem. The problem is, that you don't have a clear cut 
between the source and the build directory. With BSD make files you never 
write into the source directory. Your Makefile tries to do this, when it 
updates ntpd-opts.c. This seems not too lucky too me. The ntpd-opts.c file 
is a build-file, not a source file and so it should reside in the build 
directory. If you want to distribute it, then copy or link it from the 
source directory to the build directory if the one in the source directory 
is up-to-date, if not just build a new one in the build directory. (this 
probably requires some thinking to get it right). The build process should 
never try to write to the source directory except when the user 
explicitely asks it to do so.

HS>Does a POSIX spec cover this case?

As I said POSIX make does not directly support .PATH or VPATH. If you work 
in another directory you need to specify the path on both target and 
source sides of the rules.

A simple fix in your case is specifying files on the target side of rules 
with the prefix to the source directory and relying on VPATH to find 
source files. This is in fact easy - I build my own Makefiles this way. A 
better fix is not to make the build process write to the source directory 
altogether.

While it would surely be possible to make BSD make work like GNU/Sun make,
this would be a huge undertaking with regard to testing.

harti



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050920111521.D754>