Git development
 help / color / mirror / Atom feed
* Conditionally define vars to improve portability
@ 2015-09-07 17:51 Renato Botelho
  2015-09-08  6:30 ` Jeff King
  0 siblings, 1 reply; 5+ messages in thread
From: Renato Botelho @ 2015-09-07 17:51 UTC (permalink / raw)
  To: git

Default variables used to build are set using = on Makefile, (e.g. CC, INSTALL, CFLAGS, …). GNU make overwrite these values if it’s passed as an argument (make CC=clang) and it works as expected.

Default method of passing arguments for make operations on FreeBSD ports tree is using environment variables instead of make arguments, then we have CC set on env before call gmake. Today these values are ignored by git Makefile, and we ended up patching Makefile replacing = by ?= on variable assignments [1].

Before I write a patch and submit I would like to check if it would be an acceptable change of if it’s something you won’t accept for any reason.

Regards

[1] https://svnweb.freebsd.org/ports/head/devel/git/files/patch-Makefile?revision=396048&view=markup#l7
--
Renato Botelho

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Conditionally define vars to improve portability
  2015-09-07 17:51 Conditionally define vars to improve portability Renato Botelho
@ 2015-09-08  6:30 ` Jeff King
  2015-09-08  8:19   ` Renato Botelho
  2015-09-08 18:57   ` Junio C Hamano
  0 siblings, 2 replies; 5+ messages in thread
From: Jeff King @ 2015-09-08  6:30 UTC (permalink / raw)
  To: Renato Botelho; +Cc: git

On Mon, Sep 07, 2015 at 02:51:42PM -0300, Renato Botelho wrote:

> Default variables used to build are set using = on Makefile, (e.g. CC,
> INSTALL, CFLAGS, …). GNU make overwrite these values if it’s passed as
> an argument (make CC=clang) and it works as expected.
> 
> Default method of passing arguments for make operations on FreeBSD
> ports tree is using environment variables instead of make arguments,
> then we have CC set on env before call gmake. Today these values are
> ignored by git Makefile, and we ended up patching Makefile replacing =
> by ?= on variable assignments [1].

Hmm. I can't really think of a downside to doing so, unless we expect
users to have things like CC set in the environment and _not_ want them
to bleed through to our build.

But doesn't "gmake -e" solve your problem without a patch?

-Peff

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Conditionally define vars to improve portability
  2015-09-08  6:30 ` Jeff King
@ 2015-09-08  8:19   ` Renato Botelho
  2015-09-08 18:57   ` Junio C Hamano
  1 sibling, 0 replies; 5+ messages in thread
From: Renato Botelho @ 2015-09-08  8:19 UTC (permalink / raw)
  To: Jeff King; +Cc: git

> On Sep 8, 2015, at 03:30, Jeff King <peff@peff.net> wrote:
> 
> On Mon, Sep 07, 2015 at 02:51:42PM -0300, Renato Botelho wrote:
> 
>> Default variables used to build are set using = on Makefile, (e.g. CC,
>> INSTALL, CFLAGS, …). GNU make overwrite these values if it’s passed as
>> an argument (make CC=clang) and it works as expected.
>> 
>> Default method of passing arguments for make operations on FreeBSD
>> ports tree is using environment variables instead of make arguments,
>> then we have CC set on env before call gmake. Today these values are
>> ignored by git Makefile, and we ended up patching Makefile replacing =
>> by ?= on variable assignments [1].
> 
> Hmm. I can't really think of a downside to doing so, unless we expect
> users to have things like CC set in the environment and _not_ want them
> to bleed through to our build.
> 
> But doesn't "gmake -e" solve your problem without a patch?

Good idea, let me try it… :)

--
Renato Botelho

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Conditionally define vars to improve portability
  2015-09-08  6:30 ` Jeff King
  2015-09-08  8:19   ` Renato Botelho
@ 2015-09-08 18:57   ` Junio C Hamano
  2015-09-08 20:09     ` Jacob Keller
  1 sibling, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2015-09-08 18:57 UTC (permalink / raw)
  To: Jeff King; +Cc: Renato Botelho, git

Jeff King <peff@peff.net> writes:

> On Mon, Sep 07, 2015 at 02:51:42PM -0300, Renato Botelho wrote:
>
>> Default variables used to build are set using = on Makefile, (e.g. CC,
>> INSTALL, CFLAGS, …). GNU make overwrite these values if it’s passed as
>> an argument (make CC=clang) and it works as expected.
>> 
>> Default method of passing arguments for make operations on FreeBSD
>> ports tree is using environment variables instead of make arguments,
>> then we have CC set on env before call gmake. Today these values are
>> ignored by git Makefile, and we ended up patching Makefile replacing =
>> by ?= on variable assignments [1].
>
> Hmm. I can't really think of a downside to doing so, unless we expect
> users to have things like CC set in the environment and _not_ want them
> to bleed through to our build.

I do think that is the reason behind the choice.  I am not saying I
necessarily personally agree with it, though.

Common things like CC are not so problematic, but more problematic
are various Git build customization in our Makefile that can be left
behind from a previous build.  It is easier for users to forget, as
a "GIT_FOO=NoThanks; export GIT_FOO" that was run previously in the
same shell does not leave trace once the shell exits, compared to
other avenues of customization including config.mak and explicit
command line settings given to the 'make' utility (i.e. can be seen
in 'history' as a single entry, without having to trace the sequence
of 'GIT_FOO=NoThanks', 'export GIT_FOO' and possible 'unset GIT_FOO'
to find what was in effect when 'make' was run).  So from that point
of view, if you encourage users to be less explicit by keeping them
in the environment, you are making it easier for the users to hurt
themselves.

In an environment to build with a "make world" style propagation of
settings from top-level to down below, "environment bleeding" is a
non-issue.  It is merely a convention in that build environment how
the settings are passed to submakes in a whole system and everybody
in that environment understands the ramifications.  I agree that
your suggestion of using "gmake -e" may be a good workaround for
handling cases like that.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Conditionally define vars to improve portability
  2015-09-08 18:57   ` Junio C Hamano
@ 2015-09-08 20:09     ` Jacob Keller
  0 siblings, 0 replies; 5+ messages in thread
From: Jacob Keller @ 2015-09-08 20:09 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Jeff King, Renato Botelho, Git List

On Tue, Sep 8, 2015 at 11:57 AM, Junio C Hamano <gitster@pobox.com> wrote:
> Common things like CC are not so problematic, but more problematic
> are various Git build customization in our Makefile that can be left
> behind from a previous build.  It is easier for users to forget, as
> a "GIT_FOO=NoThanks; export GIT_FOO" that was run previously in the
> same shell does not leave trace once the shell exits, compared to
> other avenues of customization including config.mak and explicit
> command line settings given to the 'make' utility (i.e. can be seen
> in 'history' as a single entry, without having to trace the sequence
> of 'GIT_FOO=NoThanks', 'export GIT_FOO' and possible 'unset GIT_FOO'
> to find what was in effect when 'make' was run).  So from that point
> of view, if you encourage users to be less explicit by keeping them
> in the environment, you are making it easier for the users to hurt
> themselves.

It should be noted that a common idiom is also "VARIABLE=VALUE Make"
where we set the variable in the environment before running the
command. This would begin working if you allow the =? setting of
variables.

That being said, since "make VARIABLE=VALUE" already works, and is
really just as easy to type as above, I think I prefer your argument
overall. We shouldn't encourage people to use the environment, and
instead use config.mak or other methods which are far more explicit.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-09-08 20:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-07 17:51 Conditionally define vars to improve portability Renato Botelho
2015-09-08  6:30 ` Jeff King
2015-09-08  8:19   ` Renato Botelho
2015-09-08 18:57   ` Junio C Hamano
2015-09-08 20:09     ` Jacob Keller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox