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

Julio Merino julio at meroh.net
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
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Nov 07 20:20:00 UTC 2013
>Closed-Date:
>Last-Modified:
>Originator:     Julio Merino
>Release:        FreeBSD 11.0-CURRENT powerpc
>Organization:
>Environment:
System: FreeBSD mastodon.meroh.net 11.0-CURRENT FreeBSD 11.0-CURRENT #2 r257556M: Sat Nov 2 17:24:33 EDT 2013 jmmv at mastodon.meroh.net:/usr/obj/usr/src/sys/GENERIC64 powerpc


	
>Description:
	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 bsd.own.mk.
	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.

>How-To-Repeat:
	Sample Makefile:

-----
.if defined(DEFINE_VAR_IN_MAKEFILE)
VAR=foo
.endif

.undef VAR

all:
.if defined(VAR)
	@echo defined
.else
	@echo undefined
.endif
-----

	And sample invocations:

-----
$ make
undefined
$ make -DVAR
undefined
$ make -DDEFINE_VAR_IN_MAKEFILE
undefined
$ make VAR=
defined
$ VAR= make
defined
-----

	The last two cases shown above are unexpected behavior to me.
	I would expect the ".undef VAR" to take effect at all times.
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list