Subject: Re: make(1)'s inbuilt objdir handling
To: None <tech-toolchain@netbsd.org>
From: Christos Zoulas <christos@tac.gw.com>
List: tech-toolchain
Date: 06/21/2005 22:16:43
In article <20050621033916.GF5900@mewburn.net>,
Luke Mewburn <lukem@NetBSD.org> wrote:
>-=-=-=-=-=-
>
>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?
Yes, just do it. Less magic == more sane.
christos