Is WITH_="yes"in make's command line expected to work?
Alan Somers
asomers at freebsd.org
Thu Nov 7 15:44:25 UTC 2013
On Wed, Nov 6, 2013 at 1:48 AM, Julio Merino <julio at meroh.net> wrote:
> 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!
Whether or not it's the correct thing to do, I usually set WITH_* as
an environment variable. eg "WITH_TESTS=1 make install". It seems to
work. I also frequently use a src.conf that is not in the usual
location by setting SRCCONF. eg " SRCCONF=/path/to/src.conf make
install"
-Alan
More information about the freebsd-hackers
mailing list