Subject: Re: make(1)'s inbuilt objdir handling
To: None <>
From: Alan Barrett <>
List: tech-toolchain
Date: 06/21/2005 11:24:27
On Tue, 21 Jun 2005, Luke Mewburn wrote:
> To recap, the inbuilt-to-make .OBJDIR rules are:
>     	if MAKEOBJDIRPREFIX is set in the environment		# rule 1
> 	else MAKEOBJDIR is set in the environment		# rule 2
> 			# MAKEOBJDIR may be an expression
> 	else if -d "obj.${MACHINE}"				# rule 3
> 		.OBJDIR = obj.${MACHINE}
> 	else if -d "obj"					# rule 4
> 		.OBJDIR = obj
> 	else if -d "/usr/obj/${PWD}"				# rule 5
> 		.OBJDIR = /usr/obj/${PWD}
> 	else							# rule 6

Even if nothing else changes, please could the above set of rules
be added to the make(1) man page.

> I personally believe that rules 3 through 5 should be removed from make.

That sounds fine to me.  Those rules can be approximated by
setting MAKEOBJDIR in the environment:

	MAKEOBJDIR=${.CURDIR}/obj.${MACHINE}	# substitute for rule 3
	MAKEOBJDIR=${.CURDIR}/obj		# substitute for rule 4
	MAKEOBJDIR=/usr/obj/${.CURDIR}		# substitute for rule 5

> Of course, a Makefile is still free to override .OBJDIR if it wants to.

Oh, really?  Does the right thing happen if you set .OBJDIR
in the Makefile like this:

	.OBJDIR:=${.CURDIR}/obj.${MACHINE}	# substitute for rule 3
	.OBJDIR:=${.CURDIR}/obj			# substitute for rule 4
	.OBJDIR:=/usr/obj/${.CURDIR}		# substitute for rule 5
	.OBJDIR:=${.CURDIR}			# substitute for rule 6

If so, then presumably could set .OBJDIR to keep the old
semantics even if rules 3, 4 and 5 were removed from make(1) itself.

> This would solve a bunch of complaints users have raised,
> allow us to use our (NetBSD) make for some packages which
> currently use GNU make to avoid the "obj" subdir .OBJDIR frobbery,
> and result in less effort required to modify make(1)'s manual
> page to match reality.

Why can't these packages just set .OBJDIR:=${.CURDIR} in their
makefiles, or set MAKEOBJDIR=${.CURDIR} in the environment?

--apb (Alan Barrett)