[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Unexpected interaction between command line variables and override
From: |
J.T. Conklin |
Subject: |
Unexpected interaction between command line variables and override |
Date: |
Sun, 09 Oct 2011 14:41:31 -0700 |
User-agent: |
Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Jumbo Shrimp, berkeley-unix) |
I discovered an unexpected interaction between environment variables
and the override directive earlier this week (I tried gmake-3.81 and
gmake-3.82 on NetBSD and Linux).
Normally, when a variable is set on the command line, it is exported
to the environment:
'Except by explicit request, `make' exports a variable only if
it is either defined in the environment initially or set on the
command line,...'
So for the following Makefile:
CFLAGS = -O2
all: ; @echo $$CFLAGS
There is no output if gmake is invoked without arguments, and "-O2 -g"
if gmake is invoked as "gmake CFLAGS='-O2 -g'".
But if the Makefile is changed to use the override directive, like this:
override CFLAGS += -g
all: ; @echo $$CFLAGS
CFLAGS is not exported to the environment when gmake is invoked as
"gmake CFLAGS=-O2".
In my use case, it was easy enough to change it to the equivalent to
export override CFLAGS += -g
all: ; @echo $$CFLAGS
Perhaps it's implied, but I thought I'd mention it, as neither the
'override directive' nor the 'communicating variables to a sub-make'
sections explicitly say that the variables specified on the command
line will not be exported to the environment if used with the over-
ride directive.
--jtc
--
J.T. Conklin
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Unexpected interaction between command line variables and override,
J.T. Conklin <=