Subject: make(1)'s inbuilt objdir handling
To: None <tech-toolchain@NetBSD.org>
From: Luke Mewburn <lukem@NetBSD.org>
List: tech-toolchain
Date: 06/21/2005 13:39:16
--TeJTyD9hb8KJN2Jy
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

As recently observed in another discussion on this list,
make(1) has "special" inbuilt .OBJDIR handling.

To recap, the inbuilt-to-make .OBJDIR rules are:

    	if MAKEOBJDIRPREFIX is set in the environment		# rule 1
		.OBJDIR = ${MAKEOBJDIRPREFIX}/${PWD}
	else MAKEOBJDIR is set in the environment		# rule 2
			# MAKEOBJDIR may be an expression
		.OBJDIR = ${MAKEOBJDIR}
	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
		.OBJDIR = .CURDIR

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

    *	They're not documented in make(1)'s manual page.

    *	They cause enormous confusion when building programs without
	MAKEOBJDIR or MAKEOBJDIRPREFIX, especially programs outside
	of the "standard" NetBSD source tree, that have:
	    -	a subdirectory called "obj",
	    -	a subdirectory called "obj.`uname -n`"
		(although that's less likely), or
	    -	a directory in /usr/obj/`pwd`

It has been suggested to me privately that we could add another
special target to control this behaviour, but I'm not convinced
we need it; "standard" NetBSD builds already have support in
<bsd.own.mk> for this magic objdir handling.

(I'd argue we cull this magic from bsd.obj.mk as well but
that's a separate discussion.)


This change would simplify the .OBJDIR handling in make(1) to:

    	if MAKEOBJDIRPREFIX is set in the environment		# rule 1
		.OBJDIR = ${MAKEOBJDIRPREFIX}/${PWD}
	else MAKEOBJDIR is set in the environment		# rule 2
			# MAKEOBJDIR may be an expression
		.OBJDIR = ${MAKEOBJDIR}
	else							# rule 3
		.OBJDIR = .CURDIR

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



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.


Comments?

Luke.

--TeJTyD9hb8KJN2Jy
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (NetBSD)

iD8DBQFCt4vkpBhtmn8zJHIRAqlZAKCLaeO4pIzw1Cng2DG+Q4aim6V9OACgxoqJ
pnwU+WKerXAxoa4k28G0RfY=
=6uwG
-----END PGP SIGNATURE-----

--TeJTyD9hb8KJN2Jy--