bug-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GNU Make 3.79.1 Bug-Report?


From: Paul D. Smith
Subject: Re: GNU Make 3.79.1 Bug-Report?
Date: Tue, 20 Jan 2004 21:47:21 -0500

%% "Gerd Igelmann" <address@hidden> writes:

  gi> for more then 5 years we used the GNU Make version 3.76.1 at PCs
  gi> with OS Win98.  Now we changed to GNU Make version 3.79.1 which
  gi> comes with the mingw32 Compiler.  Since this time we are not able
  gi> to run the old makefiles of already existimg projects.

  gi> The result for the following lines on the same PC with OS Win98 is
  gi> completely different.

  gi> all:
  gi>   cd test
  gi>   dir > content.txt
  gi>   cd ..

  gi> Make 3.76.1 does the change of directory as expected, make 3.79.1
  gi> does not

The short answer is you need to discuss this with the people
distributing the MINGW port of GNU make.

The longer answer is that the behavior in 3.79.1 is correct according
to the make standard, and every implementation of make on any UNIX or
UNIX-like system behaves that way.  In make each line of a command
script is run as a separate step.  In UNIX-y systems, the current
working directory is local to that processes environment (child
processes inherit their environment from their parents), and also no
child process can ever modify the environment of its parent.  That
combination means that each individual line of a make rule (run as a
child process of make) can modify its own working directory value, but
when that line is done and the process exits, any changes made to the
working directory are gone; they are not reflected in the environment of
the parent (make).

In Windows and DOS, the COMMAND.COM works differently in that the
current working directory value is global, to some extent, so any change
to it, in any process, effects future processes.  This is the behavior
you were seeing with the older version of GNU make.

Although the MINGW port is not actually supported on this list as it's
created by a 3rd party (although GNU make 3.81 will merge that port in
officially), I suspect that the MINGW port is using something other than
COMMAND.COM to invoke its commands.

If you like you can go get the source to GNU make from
ftp://ftp.gnu.org/gnu/make/ (the FSF doesn't distribute pre-built
versions of its software on the FTP site).  Unpack it and read the
README.W32 and README.DOS files and they will explain how to build GNU
make to use basic COMMAND.COM, whereupon you might get back the older
behavior.


Finally, note that what you are doing above would be written in a
standard makefile as:

  all:
        cd test; dir > content.txt

By putting these two commands on one line they are both executed by the
same process, which means the "cd" command is still in effect when the
"dir" is run.  We don't have to "cd ..", because that happens
automatically when the process ends.

I don't know if whatever shell you're using with your port supports
syntax like this or not.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.paulandlesley.org
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist




reply via email to

[Prev in Thread] Current Thread [Next in Thread]