questionable feature in FreeBSD pmake

Dan Strick strick at covad.net
Thu Oct 28 12:50:52 PDT 2004


On Thu, 28 Oct 2004 03:23:02 -0700, I wrote:
>
> I just spent a *very* frustrating hour trying to figure out why the
> FreeBSD make program was invoking all commands to make things in a
> subdirectory named "obj".  I eventually discovered this gem in the
> make man page:
>
>     In addition, make sets or knows about the following internal
>     variables or environment variables:
>
>     ...
>
>     .OBJDIR	A path to the directory where the targets are built.  At
> 		startup, make searches for an alternate directory to place
> 		target files.  It will attempt to change into this special
> 		directory and will search this directory for
> 		found in the current directory.  The following directories
> 		are tried in order:
>
> 		1.   ${MAKEOBJDIRPREFIX}/`pwd`
> 		2.   ${MAKEOBJDIR}
> 		3.   obj.${MACHINE}
> 		4.   obj
> 		5.   /usr/obj/`pwd`
>	...
>

A little while later Peter Pentchev responded:
>
> Actually, this feature lies at the base of the FreeBSD base system build
> infrastructure, and it is pretty much The Feature that allows us to
> build from read-only and/or NFS-mounted sources shared among wide swarms
> of machines :)
>
and
>
> Oh, and let's not forget cross-platform builds, too.
>

It is clear that a great deal of current FreeBSD OS makefile practice
depends on the feature.  The tragedy is that it was never necessary to
make the feature unavoidable.  Its invocation should have been dependent
on using a special environment variable or make command option or makefile
command or makefile variable.  Unfortunately, it seems that its invocation
depends only on the presence of a subdirectory named "obj" in the directory
in which the make command is invoked and there is NO WAY to avoid it.
There seems to be absolutely nothing that I can put in my makefile to
turn the feature off or to undo its effect.

It seems that I have no alternative but to rename my "obj" directory.
Can someone suggest an alternative?  Note that it is not possible for me
to set an environment variable (i.e. MAKEOBJDIR) before running make or
to add an option to the make command line.  Any fix must be contained
entirely within the makefile.  Setting .OBJDIR or MAKEOBJDIR within the
makefile does not work.  Placing a "cd .." or "cd $(.CURDIR)" in front of
every set of makefile shell commands is unthinkable.

Dan Strick
strick at covad.net

(now *immensely* frustrated)


More information about the freebsd-hackers mailing list