MINGW: compat/mingw.h: do not attempt to redefine lseek on mingw-w64

Unlike MinGW, MinGW-W64 has lseek already properly defined in io.h.

Signed-off-by: Marat Radchenko <marat@slonopotamus.org>
Acked-by: Erik Faye-Lund <kusmabite@gmail.com>
MSVC: config.mak.uname: drop -D__USE_MINGW_ACCESS from CFLAGS

-D__USE_MINGW_ACCESS only affects MinGW and does nothing when
MSVC is used.

Signed-off-by: Marat Radchenko <marat@slonopotamus.org>
Acked-by: Erik Faye-Lund <kusmabite@gmail.com>
MINGW: compat/mingw.h: drop fork() definition

fork() is not used in MinGW builds but causes a compiler warning
on x86_64 MinGW-W64: conflicting types for built-in function 'fork'

Signed-off-by: Marat Radchenko <marat@slonopotamus.org>
Acked-by: Erik Faye-Lund <kusmabite@gmail.com>
MINGW: do not fail at redefining pid_t on MinGW-W64

pid_t is available in sys/types.h on both MinGW and MinGW-W64

Signed-off-by: Marat Radchenko <marat@slonopotamus.org>
Acked-by: Erik Faye-Lund <kusmabite@gmail.com>
MINGW: config.mak.uname: allow using cURL for non-msysGit builds

Is it absolutely valid and possible to have cURL in generic
MinGW environment. Building Git without cURL is still possible
by passing NO_CURL=1

Signed-off-by: Marat Radchenko <marat@slonopotamus.org>
Acked-by: Erik Faye-Lund <kusmabite@gmail.com>
MINGW: compat/winansi.c: do not redefine CONSOLE_FONT_INFOEX

Unlike MinGW, MinGW-W64 has CONSOLE_FONT_INFOEX already properly defined
in wincon.h.

Signed-off-by: Marat Radchenko <marat@slonopotamus.org>
MINGW: do not pass 32bit-only cc/ld flags for 64bit MinGW-w64

 1. 64bit ld doesn't have '--large-address-aware' and errors if sees it
 2. -D_USE_32BIT_TIME_T on 64bit triggers
  #error You cannot use 32-bit time_t (_USE_32BIT_TIME_T) with _WIN64

Signed-off-by: Ray Donnelly <mingw.android@gmail.com>
Signed-off-by: Marat Radchenko <marat@slonopotamus.org>
MINGW: git-compat-util.h: use inttypes.h for printf macros

1. Don't try to be smarter than libc and simply use printf macros
from inttypes.h.

All MinGW flavors have inttypes.h, so just include it.

Pass -D__USE_MINGW_ANSI_STDIO=1 to select
GNU-compatible macro definitions on MinGW-W64 [1]
and avoid 'BUG: your vsnprintf is broken' from strbuf.c.

As a side-effect, Git no longer builds with MSVC < 2010 due to
its lack of stdint.h.

2. compat/bswap.h uses uint32_t, so we must #include <stdint.h>
or <inttypes.h> to avoid error on MinGW-W64:

  compat/bswap.h:12:1: error: unknown type name 'uint32_t'

[1] http://sourceforge.net/p/mingw-w64/wiki2/gnu%20printf/

Signed-off-by: Marat Radchenko <marat@slonopotamus.org>
MINGW: config.mak.uname: reorganize MinGW settings

HAVE_LIBCHARSET_H and NO_R_TO_GCC_LINKER are not specific to
msysGit, they're general MinGW settings.

Logic behind HAVE_LIBCHARSET_H: if user is on MinGW and has iconv,
we expect him to have libcharset.h. If user doesn't have iconv,
he has to explicitly say so via NO_ICONV=1 regardless of this
commit.

Signed-off-by: Marat Radchenko <marat@slonopotamus.org>
Makefile: introduce CROSS_COMPILE variable

To ease cross-compilation process, introduce a single variable
with the prefix to all compiler-related executables.

Define CROSS_COMPILE=foo- if your compiler and binary utilities
are foo-cc, foo-ar, foo-strip, etc.  More specific variables
override this, so if you set CC=gcc CROSS_COMPILE=ia64-linux-gnu-
then the compiler will be 'gcc', not 'ia64-linux-gnu-gcc'.

Signed-off-by: Marat Radchenko <marat@slonopotamus.org>
compat/nedmalloc/malloc.c.h: fix compilation under MinGW-W64

1. Unlike MinGW, MinGW-W64 already provides _ReadWriteBarrier macro,
   so don't try to redefine it.

2. MinGW-W64 has a strange definition FORCEINLINE as
   extern __inline__ __attribute__((__always_inline__,__gnu_inline__))

   'extern' doesn't work together with 'static', so #undef MinGW-W64
   version of FORCEINLINE.

Signed-off-by: Marat Radchenko <marat@slonopotamus.org>
Fix pointer -> integer casts on IL32P64 systems

This commit touches regcomp.c from Gnulib,
was fixed upstream in 3a4836d1.

This commit also touches poll.c from Gnulib,
was fixed upstream in d295f6c5.

This commit also touches regex_internal.h from Gnulib,
was fixed upstream in 8335a4d6.

Wrt ShellExecute in winansi.c, quoting [1]:

  MSDN says you can cast the result to an integer and compare the result
  against 32... You could cast in the other direction, comparing the return
  value against (HINSTANCE)32... Or you could cast the result to an INT_PTR
  and compare the result against 32.

We use the third option: cast HINSTANCE to intptr_t.

[1]: http://blogs.msdn.com/b/oldnewthing/archive/2006/11/08/1035971.aspx

Signed-off-by: Marat Radchenko <marat@slonopotamus.org>
git-compat-util.h: fix integer overflow on IL32P64 systems

Signed-off-by: Marat Radchenko <marat@slonopotamus.org>
MINGW: config.mak.uname: auto-detect MinGW build from compiler

When crosscompiling, one cannot rely on `uname` from host system.

Signed-off-by: Marat Radchenko <marat@slonopotamus.org>