[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Additional environment information with make 4
From: |
Markus Fischer |
Subject: |
Re: Additional environment information with make 4 |
Date: |
Thu, 26 Feb 2015 13:06:11 +0100 |
User-agent: |
Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 |
On 25.02.2015 17:03, Paul Smith wrote:
> Or do you mean that when make invokes a program it places this into the
> environment of the program?
Yes, that was what I meant.
>
> You'll have to be much more specific before we can help... as always a
> short example makefile, along with command line you invoked, the result
> you got (cut/paste) and an explanation of what is wrong with it or what
> you expected to get, is best.
>
> In any event, I ran this simple makefile:
>
> all: ; env | sort
>
> and looked at the output and I didn't see anything in the environment
> that shouldn't be there.
>
I made a minimal example, here is the program I invoke with make along
with the makefile:
#### main.cpp ####
#include <stdio.h>
extern char** environ;
int main (int argc, char** argv)
{
char* entry = 0;
int i = 0;
while ((entry = environ[i++]))
printf("%s\n", entry);
fflush(stdout);
return 0;
}
#### makefile ####
all:
@g++ -o example main.cpp
run:
./example
#### output ####
$ make && make run
./example
DESKTOP_SESSION=KDE-4
KONSOLE_DBUS_WINDOW=/Windows/1
GTK_RC_FILES=/etc/gtk/gtkrc:/home/mjf/.gtkrc:/home/mjf/.kde4/share/config/gtkrc
SHELL=/bin/bash
_=/usr/bin/make
....
If I run ./example directly from the shell I don't get this "./example"
entry. I expect the same output when run with make. In this minimal
example I also get the string "./example" with make 3.82, though. I
haven't looked into it further, why in my actual program this happens
only with make 4, but either way it would be interesting to know why it
is there at all.