do not unconditionally use PATH_MAX with getcwd

Instead, grow a buffer until getcwd either succeeds or fails with an errno different than ERANGE
(meaning the passed buffer was too short to represent the actual path).
Reset errno before calling getcwd to check it eventually did not fail.
Fix typo in HACKING.md
Add error check for -j flag.
Browse tool uses real hostname not localhost, to allow -t browse when using ssh

Change-Id: Ic4be6527151a7ff68afab62e61951071ad5694b7
Added bootstrap/configure option to force pselect

All modern Linux kernels have ppoll() but sometimes
you might want to compile on something ancient.

This patch adds the possibility to force the use
of pselect() instead by passing --force-pselect
to bootstrap/configure.

The use of ppoll() is still default for Linux
and OpenBSD
Merge pull request #579 from rui314/master

Minor fixes
Merge pull request #583 from tru/add_force_pselect

Added bootstrap/configure option to force pselect
Merge pull request #578 from pinotree/remove-path-max

do not unconditionally use PATH_MAX with getcwd
Merge pull request #470 from rgeary1/remotebrowser

Ninja -t browse opens localhost in browser, which doesn't work when using ssh
Don't use va_start() with reference parameters, it's undefined behavior.

Should fix issue #584.
Merge pull request #585 from nico/fixcrash

Don't use va_start() with reference parameters, it's undefined behavior.
factor out flag parsing from enormous NinjaMain()
simplify some ifdefs
refactor ninja main() into a struct with methods

This removes the ugly Globals struct, and the ResetState() hack.
This also eliminates the only goto!
Fixed the build on Debian/kfreebsd
Fix mingw based builds. Fixes #587
Merge pull request #588 from jonforums/mingw-fix

Fix mingw based builds. Fixes #587
Merge pull request #586 from grimmy/master

Build fails on Debian/kfreebsd
Stop `-t msvc -o` from lowercasing paths from /showIncludes output.

/showIncludes prints absolute paths. If a source file says
`#include <WiNdOwS.h>`, /showIncludes will use that spelling in
its output for the basename and use the on-disk cache for the
directory names in the rest for its output.

This makes the .d files created by `-t msvc -o` consistent with the
.d files written by gcc and clang.
Before this change, `-t msvc -o` would convert this output to
lower case. This is a problem if a build step produces a header file
with mixed case, such as "RuntimeFeatures.h". Due to the lowercasing,
the .d file would contain "runtimefeatures.h", while the build step
will create "RuntimeFeatures.h". Due to the case difference, ninja
would not realize that regeneration of the .h file would require
a rebuild of all source files having the header in the .d file.
(On the next build, ninja would rebuild them since stat()ing is not
case-sensitive on Windows.) One possible fix for this is to make sure
that generators always write generated header files in lower case too,
but on Mac gcc doesn't do lower-casing and .d files end up with the
case-as-written, so generators would have to be different on Mac and
Windows, which is undesirable.

If case-insensitve path comparisons are useful, they should be done
somewhere else (e.g. in CanonicalizePath()) where they affect both
paths read from .d files and paths read from .ninja files. This should
then be controlled by a top-level variable.

This patch changes behavior, but it only has an effect on generated
header files, which aren't common, and it only affects -t msvc, which
is still marked as experimental. (cmake doesn't use it yet.)

(If a file has both `#include <windows.h>` and `<Windows.h>`, this
will now take 2 stat() calls instead of just one, but that should
have a negligible cost.)
Merge pull request #589 from nico/wincase

Stop `-t msvc -o` from lowercasing paths from /showIncludes output.