make(1) and SUBDIR assignments

Ruslan Ermilov ru at
Sun Jan 25 13:14:56 PST 2004

On Sun, Jan 25, 2004 at 04:18:24PM +0100, Jens Schweikhardt wrote:
> hello, world\n
> I'm trying to selectively install binaries in the source tree, i.e. to
> only install bin/dd and bin/df this is what I hoped would work:
> root at hal9000:/usr/src # make buildworld      # succeeds
> root at hal9000:/usr/src # cd bin
> root at hal9000:/usr/src/bin # make install SUBDIR='dd df'
> But it fails:
> ===> dd
> "/usr/share/mk/", line 60: Inconsistent operator for dd
> "/usr/share/mk/", line 66: warning: duplicate script for target "dd" ignored
> make: fatal errors encountered -- cannot continue
> *** Error code 1
> Stop in /share/HEAD/src/bin.
> (-CURRENT sources and /usr/share/mk/* as of today). Is this
> 1) a bug somewhere (though nothings seems to be wrong with
> 2) me being confused about how SUBDIR is intended to be used
> 3) something else
> Yes, I know I can workaround by
> cd /usr/src/bin/dd; make install
> cd /usr/src/bin/df; make install
> But why do all the src/*/Makefiles assign the list of subdirs to SUBDIR
> and DTRT, but I can't from the outside?
Yes, this looks confusing, but here's what happens here: in make(1),
there are four types of variables, and command-line variables take
precedence over local variables, and you use this feature to override
the SUBDIR assignment inside the src/bin/Makefile.  This works, but
what you don't take into an account is that make(1) also saves all
command-line assignments in environment and makes them available to
its subprocesses, so src/bin/Makefile also gets SUBDIR='dd df', which
conflicts with its <> "dd" target.

Ruslan Ermilov
FreeBSD committer
ru at
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url :

More information about the freebsd-current mailing list