Subject: bug#8564: 24.0.50; bootstrap on windows 7: `gl-stamp' target failed

From: Eli Zaretskii <[email-masked]>
Date: Thu, 28 Apr 2011 00:53:09 -0400

> From: William Xu <[email-masked]>
> Date: Thu, 28 Apr 2011 10:24:26 +0800
> 
>    After you bootstrap, does the same command work for a normal (i.e.,
>    non-bootstrap) build, or does it fail in the same way?
> 
> Yes, if i revert my change.  I modified some c files, and run following
> command: 
> 
> ,----[ make gl-stamp ]
> | cmd /c "fc /b gl-tmp globals.h >nul 2>&1 || cp -f gl-tmp globals.h"
> | Microsoft Windows [Version 6.1.7600]
> | Copyright (c) 2009 Microsoft Corporation.  All rights reserved.
> | 
> | L:\bin\emacs\src>mingw32-make: *** [gl-stamp] Error 66048
> `----

So it fails in non-bootstrap case as well.  Good, this makes things
simpler.

> I was compiling in on cmd.exe(i have some unix tools on %path%, though)
> The beginning: 
> 
> ,----
> | L:\bin\emacs\src>mingw32-make gl-stamp
> | [Please ignore a syntax error on the next line - it is intentional]
> | /bin/sh: -c: line 0: unexpected EOF while looking for matching `"'
> | /bin/sh: -c: line 1: syntax error: unexpected end of file
> | rm gl-tmp
> `----

Uh-oh!  Is this the MSYS port of Bash, by any chance?  Or maybe the
Cygwin Bash?  If so, can you remove sh.exe from PATH and try again?
At least the MSYS Bash has a nasty habit of munging the command-line
arguments if it "thinks" that those arguments are Unix-style /foo/bar
file names.  So my crystal ball says that it "thinks" "/c" in "cmd /c"
is such a file name and changes it to something like "cmd L:/c", which
of course totally confuses cmd.exe.

You will see that nt/INSTALL advises against the MSYS shell:

                           MSYS sh.exe also appears to cause various
  problems.  If you have MSYS installed, try "make SHELL=cmd.exe" to
  force the use of cmd.exe instead of sh.exe.

>    >   cp -f gl-tmp globals.h  # Wouldn't this be simpler & good enough? 
> 
>    No, it's not good enough.  `cp' updates the time stamp of globals.h
>    each time you build, and therefore all the C files will be recompiled,
>    because they all include globals.h, even though the contents of
>    globals.h rarely changes.  That kinda makes Make redundant, since its
>    main goal is to avoid unnecessary compilations...  The command that
>    invokes `fc' only updates globals.h if the new version has different
>    contents.  IOW, this is the Windows way of saying move-if-change.
> 
> How about using `diff' here? (considering commands like `cp' is already
> dependent? )
>   diff gl-tmp globals.h >nul 2>&1 || $(CP) gl-tmp globals.h

Using Diff means we ask the Windows users to have yet another
non-standard package installed as a prerequisite to building Emacs.  I
would like to avoid that if possible; `fc' is a standard program on
every Windows machine, and it does this particular job just fine.

It is also unsafe to use this command without going through "cmd /c",
because ported Unixy shells generally don't know about "NUL" being the
Windows null device, while cmd.exe doesn't know about "/dev/null".

Anyway, I think your problem is not with `fc', it's with "cmd /c".  So
using Diff won't solve it.