From owner-freebsd-questions@FreeBSD.ORG Tue Sep 20 09:42:06 2005 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7AEC616A41F; Tue, 20 Sep 2005 09:42:06 +0000 (GMT) (envelope-from Hartmut.Brandt@dlr.de) Received: from smtp-3.dlr.de (smtp-3.dlr.de [195.37.61.187]) by mx1.FreeBSD.org (Postfix) with ESMTP id DDAB543D48; Tue, 20 Sep 2005 09:42:05 +0000 (GMT) (envelope-from Hartmut.Brandt@dlr.de) Received: from beagle.kn.op.dlr.de ([129.247.173.6]) by smtp-3.dlr.de over TLS secured channel with Microsoft SMTPSVC(6.0.3790.211); Tue, 20 Sep 2005 11:42:04 +0200 Date: Tue, 20 Sep 2005 11:42:05 +0200 (CEST) From: Harti Brandt X-X-Sender: brandt_h@beagle.kn.op.dlr.de To: Harlan Stenn In-Reply-To: <20050920090956.14D5F39AD2@ntp1.ntp.isc.org> Message-ID: <20050920111521.D754@beagle.kn.op.dlr.de> References: <20050920090956.14D5F39AD2@ntp1.ntp.isc.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-OriginalArrivalTime: 20 Sep 2005 09:42:04.0850 (UTC) FILETIME=[8F323120:01C5BDC7] Cc: Giorgos Keramidas , freebsd-questions@freebsd.org Subject: Re: gmake/make dependency problem X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Harti Brandt List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Sep 2005 09:42:06 -0000 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