Is WITH_*=yes in make's command line expected to work?

Julio Merino julio at meroh.net
Thu Nov 7 15:35:59 UTC 2013


Hello all,

I'm currently working on fixing the build when the TESTS knob is enabled
and I have encountered some odd behavior that I'm not sure is expected.

Basically, it seems that passing a WITH_*=yes option (note, no -D)
through make's command line conflicts with a similar NO_* option.

Consider this sample Makefile which is derived from the contents of
bsd.own.mk:

-----
.if defined(SIMULATE_WITH_FOO_IN_SRC_CONF)
WITH_FOO=yes
.endif

# Same code as in bsd.own.mk.
.for var in FOO
.if defined(NO_${var})
.if defined(WITH_${var})
.undef WITH_${var}
.endif
WITHOUT_${var}=
.endif
.endfor
# End code from bsd.own.mk.

all:
.if defined(WITH_FOO)
	@echo WITH_FOO
.endif
.if defined(WITHOUT_FOO)
	@echo WITHOUT_FOO
.endif
-----

Now look at the following invocations:

$ make -DSIMULATE_WITH_FOO_IN_SRC_CONF
WITH_FOO  # OK.

$ make -DSIMULATE_WITH_FOO_IN_SRC_CONF -DNO_FOO
WITHOUT_FOO  # OK.

$ make -DWITH_FOO -DNO_FOO
WITHOUT_FOO  # OK.

$ make WITH_FOO=yes -DNO_FOO
WITH_FOO  # OOPS!
WITHOUT_FOO

Is this expected behavior?  It seems to me that the .undef is not working
properly in the way it's used by bsd.own.mk.

The src.conf(5) manpage says that the WITH_* and WITHOUT_* variables can
be provided to make via the command line with -D.  There is no mention of
providing explicit overrides with WITH_*=yes as I did above.  Is it OK
to rely on this assumption and consider invocations with WITH_FOO=yes in
the command line to be broken?

Thank you!


More information about the freebsd-hackers mailing list