Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 7 Nov 2013 08:44:23 -0700
From:      Alan Somers <asomers@freebsd.org>
To:        Julio Merino <julio@meroh.net>
Cc:        "freebsd-hackers@freebsd.org" <freebsd-hackers@freebsd.org>
Subject:   Re: Is WITH_="yes"in make's command line expected to work?
Message-ID:  <CAOtMX2gjKN=VWWR=i_jPf4uVtFQB2rFXHJ_kN2VtNj3LqgX6yw@mail.gmail.com>
In-Reply-To: <20131106084849.GA45949@fbair.virtual.network>
References:  <20131106084849.GA45949@fbair.virtual.network>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Nov 6, 2013 at 1:48 AM, Julio Merino <julio@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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAOtMX2gjKN=VWWR=i_jPf4uVtFQB2rFXHJ_kN2VtNj3LqgX6yw>