[802] in NetBSD-Development

home help back first fref pref prev next nref lref last post

Modified make semantics

daemon@ATHENA.MIT.EDU (Greg Hudson)
Tue Jun 20 02:19:43 1995

Date: Tue, 20 Jun 1995 02:22:03 -0400
From: Greg Hudson <ghudson@MIT.EDU>
To: netbsd-dev@MIT.EDU


Okay, I've cleaned up make a bit in our source tree.  I'm not sure
whether people will agree with the semantics I chose; if people can
come up with a cleaner set of decisions, I can implement those
instead.  The goals are to allow the .mk files to decide where the
object directory will be, and to allow people to easily do makes in
any object directory without write access to the source tree.

	* As I mentioned before, make no longer looks for "obj", but
	  instead looks at the OBJDIR environment variable after the
	  Makefile has been read to determine where the object
	  directory should be.  ${.OBJDIR} still gets set, but only
	  after the Makefile is read (this will affect := assignments
	  within the Makefile).

	  make will automatically try to ensure the existence of
	  ${OBJDIR} by making all the directories in the path up to
	  ${OBJDIR}.  This has to be done by make (not by the .mk
	  files), since make has to chdir() into the object directory
	  before running any commands from the Makefile.

	* I added a variable modifier :C, which treats the contents of
	  the variable as a filename and canonicalizes it.  This way,
	  ${.CURDIR} can be taken from the PWD environment variable
	  with problems, and ${BSDSRCDIR} can be a symlink without
	  problems.

	  The current implementation of canonicalize() is pretty lame;
	  it does a popen() to do a cd and getcwd().  I didn't want to
	  change directories and call getcwd() because I might not be
	  able to change back in some psychotic cases, and I didn't
	  want to pull in the implementation of getcwd() and change it
	  to canonicalize an arbitrary directory (instead of the
	  current directory).

	* bsd.obj.mk adds a bit of logic to decide OBJDIR:

.if !defined(OBJDIR) && !empty(BSDOBJDIR) && exists(${BSDOBJDIR}) && \
        (${.CURDIR:C:S/^${BSDSRCDIR:C}/${BSDOBJDIR}/} != ${.CURDIR:C})
OBJDIR=${.CURDIR:C:S/^${BSDSRCDIR:C}/${BSDOBJDIR}/}
.elif exists(${.CURDIR}/obj) && !defined(OBJDIR)
OBJDIR=${.CURDIR}/obj
.endif

	  The first test checks whether substituting ${BSDSRCDIR} with
	  ${BSDOBJDIR} in ${.CURDIR} produces a different directory.
	  The second test is to emulate the old "obj in the current
	  directory" semantics.  However, note that make will be able
	  to substitute /usr/src with /usr/obj most of the time when
	  you're in the NetBSD source tree, so most users will
	  immediately notice that make is trying to build things in
	  /usr/obj even if they have obj directories.

	* The man page had no particular documentation of the "obj"
	  semantics, so I've just documented the ":C" variable
	  modifier and removed the reference to the MAKE_OBJDIR
	  environment variable.  I will document the OBJDIR behavior
	  and that ${.OBJDIR} doesn't get set until after the Makefile
	  is read, but first I want to see if anyone can suggest a
	  better set of semantics changes.

This is a lot more complicated that I was hoping it would be, but I do
want users to be able to build stuff out of our source tree without a
lot of hassle (on our part or theirs).  Comments?


home help back first fref pref prev next nref lref last post