1
1
# Platform specific Makefile tweaks based on uname detection
2
2
3
+ # Define NO_SAFESEH if you need MSVC/Visual Studio to ignore the lack of
4
+ # Microsoft's Safe Exception Handling in libraries (such as zlib).
5
+ # Typically required for VS2013+/32-bit compilation on Vista+ versions.
6
+
3
7
uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
4
8
uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not')
5
9
uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')
@@ -361,6 +365,7 @@ ifeq ($(uname_S),Windows)
361
365
NEEDS_LIBICONV = YesPlease
362
366
NO_STRTOUMAX = YesPlease
363
367
NO_MKDTEMP = YesPlease
368
+ NO_INTTYPES_H = YesPlease
364
369
# VS2015 with UCRT claims that snprintf and friends are C99 compliant,
365
370
# so we don't need this.
366
371
#
@@ -396,6 +401,9 @@ ifeq ($(uname_S),Windows)
396
401
compat/win32/dirent.o compat/win32/fscache.o
397
402
COMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DDETECT_MSYS_TTY -DNOGDI -DHAVE_STRING_H -Icompat -Icompat/regex -Icompat/win32 -DSTRIP_EXTENSION=\".exe\"
398
403
BASIC_LDFLAGS = -IGNORE:4217 -IGNORE:4049 -NOLOGO -SUBSYSTEM:CONSOLE
404
+ # invalidcontinue.obj allows Git's source code to close the same file
405
+ # handle twice, or to access the osfhandle of an already-closed stdout
406
+ # See https://msdn.microsoft.com/en-us/library/ms235330.aspx
399
407
EXTLIBS = user32.lib advapi32.lib shell32.lib wininet.lib ws2_32.lib invalidcontinue.obj kernel32.lib ntdll.lib
400
408
PTHREAD_LIBS =
401
409
lib =
@@ -428,6 +436,11 @@ ifeq ($(uname_S),Windows)
428
436
# release mode) to force a PDB to be generated (like RelWithDebInfo).
429
437
BASIC_CFLAGS += -Zi
430
438
BASIC_LDFLAGS += -debug
439
+
440
+ ifdef NO_SAFESEH
441
+ LDFLAGS += -SAFESEH:NO
442
+ endif
443
+
431
444
ifndef DEBUG
432
445
BASIC_CFLAGS += -GL -Gy -O2 -Oy- -MD -DNDEBUG
433
446
BASIC_LDFLAGS += -release -LTCG /OPT:REF /OPT:ICF /INCREMENTAL:NO /DEBUGTYPE:CV,FIXUP
@@ -438,6 +451,80 @@ endif
438
451
X = .exe
439
452
440
453
compat/msvc.o: compat/msvc.c compat/mingw.c GIT-CFLAGS
454
+
455
+ vcxproj:
456
+ # Require clean work tree
457
+ git update-index -q --refresh && \
458
+ git diff-files --quiet && \
459
+ git diff-index --cached --quiet HEAD --
460
+
461
+ # Make .vcxproj files and add them
462
+ unset QUIET_GEN QUIET_BUILT_IN; \
463
+ perl contrib/buildsystems/generate -g Vcxproj
464
+ git add -f git.sln {*,*/lib,t/helper/*}/*.vcxproj
465
+
466
+ # Generate the LinkOrCopyBuiltins.targets file
467
+ (echo '<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">' && \
468
+ echo ' <Target Name="CopyBuiltins_AfterBuild" AfterTargets="AfterBuild">' && \
469
+ for name in $(BUILT_INS);\
470
+ do \
471
+ echo ' <Copy SourceFiles="$$(OutDir)\git.exe" DestinationFiles="$$(OutDir)\'"$$name"'" SkipUnchangedFiles="true" UseHardlinksIfPossible="true" />'; \
472
+ done && \
473
+ for name in $(REMOTE_CURL_ALIASES); \
474
+ do \
475
+ echo ' <Copy SourceFiles="$$(OutDir)\'"$(REMOTE_CURL_PRIMARY)"'" DestinationFiles="$$(OutDir)\'"$$name"'" SkipUnchangedFiles="true" UseHardlinksIfPossible="true" />'; \
476
+ done && \
477
+ echo ' </Target>' && \
478
+ echo '</Project>') >git/LinkOrCopyBuiltins.targets
479
+ git add -f git/LinkOrCopyBuiltins.targets
480
+
481
+ # Add command-list.h
482
+ $(MAKE) MSVC=1 SKIP_VCPKG=1 prefix=/mingw64 command-list.h
483
+ git add -f command-list.h
484
+
485
+ # Add scripts
486
+ rm -f perl/perl.mak
487
+ $(MAKE) MSVC=1 SKIP_VCPKG=1 prefix=/mingw64 \
488
+ $(SCRIPT_LIB) $(SCRIPT_SH_GEN) $(SCRIPT_PERL_GEN)
489
+ # Strip out the sane tool path, needed only for building
490
+ sed -i '/^git_broken_path_fix ".*/d' git-sh-setup
491
+ git add -f $(SCRIPT_LIB) $(SCRIPT_SH_GEN) $(SCRIPT_PERL_GEN)
492
+
493
+ # Add Perl module
494
+ $(MAKE) $(LIB_PERL_GEN)
495
+ git add -f perl/build
496
+
497
+ # Add bin-wrappers, for testing
498
+ rm -rf bin-wrappers/
499
+ $(MAKE) MSVC=1 SKIP_VCPKG=1 prefix=/mingw64 $(test_bindir_programs)
500
+ # Ensure that the GIT_EXEC_PATH is a Unix-y one, and that the absolute
501
+ # path of the repository is not hard-coded (GIT_EXEC_PATH will be set
502
+ # by test-lib.sh according to the current setup)
503
+ sed -i -e 's/^\(GIT_EXEC_PATH\)=.*/test -n "$${\1##*:*}" ||\
504
+ \1="$$(cygpath -u "$$\1")"/' \
505
+ -e "s|'$$(pwd)|\"\$$GIT_EXEC_PATH\"'|g" bin-wrappers/*
506
+ # Ensure that test-* helpers find the .dll files copied to top-level
507
+ sed -i 's|^PATH=.*|&:"$$GIT_EXEC_PATH"|' bin-wrappers/test-*
508
+ # We do not want to force hard-linking builtins
509
+ sed -i 's|\(git\)-\([-a-z]*\)\.exe"|\1.exe" \2|g' \
510
+ bin-wrappers/git-{receive-pack,upload-archive}
511
+ git add -f $(test_bindir_programs)
512
+ # remote-ext is a builtin, but invoked as if it were external
513
+ sed 's|receive-pack|remote-ext|g' \
514
+ <bin-wrappers/git-receive-pack >bin-wrappers/git-remote-ext
515
+ git add -f bin-wrappers/git-remote-ext
516
+
517
+ # Add templates
518
+ $(MAKE) -C templates
519
+ git add -f templates/boilerplates.made templates/blt/
520
+
521
+ # Add build options
522
+ $(MAKE) MSVC=1 SKIP_VCPKG=1 prefix=/mingw64 GIT-BUILD-OPTIONS
523
+ git add -f GIT-BUILD-OPTIONS
524
+
525
+ # Commit the whole shebang
526
+ git commit -m "Generate Visual Studio solution" \
527
+ -m "Auto-generated by \`$(MAKE)$(MAKEFLAGS) $@\`"
441
528
endif
442
529
ifeq ($(uname_S),Interix)
443
530
NO_INITGROUPS = YesPlease
0 commit comments