bin/183762: make(1) .undef does not work with variables set to a value

Julio Merino julio at
Thu Nov 7 20:20:04 UTC 2013

>Number:         183762
>Category:       bin
>Synopsis:       make(1) .undef does not work with variables set to a value
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Nov 07 20:20:00 UTC 2013
>Originator:     Julio Merino
>Release:        FreeBSD 11.0-CURRENT powerpc
System: FreeBSD 11.0-CURRENT FreeBSD 11.0-CURRENT #2 r257556M: Sat Nov 2 17:24:33 EDT 2013 jmmv at powerpc

	The .undef directive of make(1) does not seem to work on a
	variable that has been defined to a value (even if empty) either
	via the environment or a command-line argument to make.  However
	.undef works on variables that have been defined using make's
	-D flag and variables defined in the same Makefile.

	I have found this while debugging build issues in
	Makefile.inc1 has to pass -DNO_* to make in order to explicitly
	disable some features during the build bootstrap.  However, if
	the user explicitly sets WITH_* from the command line (without
	using -D), the build fails because it finds both WITH_* and
	WITHOUT_* defined.

	I believe .undef is buggy and hence the reason for this PR.  And
	if it is not a bug, make(1) probably deserves some note about
	this as well as the build documentation (maybe in src.conf(5))
	to warn about this.

	Sample Makefile:


.undef VAR

.if defined(VAR)
	@echo defined
	@echo undefined

	And sample invocations:

$ make
$ make -DVAR
$ make VAR=
$ VAR= make

	The last two cases shown above are unexpected behavior to me.
	I would expect the ".undef VAR" to take effect at all times.

More information about the freebsd-bugs mailing list