1 # Platform specific Makefile tweaks based on uname detection
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.
7 uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
8 uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not')
9 uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')
10 uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not')
11 uname_V := $(shell sh -c 'uname -v 2>/dev/null || echo not')
13 ifneq ($(findstring MINGW,$(uname_S)),)
18 # avoid the MingW and Cygwin configuration sections
22 # Generate and include makefile variables that point to the
23 # currently installed set of MSVC command line tools.
24 compat/vcbuild/MSVC-DEFS-GEN: compat/vcbuild/find_vs_env.bat
25 @"$<" | tr '\\' / >"$@"
26 include compat/vcbuild/MSVC-DEFS-GEN
28 # See if vcpkg and the vcpkg-build versions of the third-party
29 # libraries that we use are installed. We include the result
30 # to get $(vcpkg_*) variables defined for the Makefile.
32 compat/vcbuild/VCPKG-DEFS: compat/vcbuild/vcpkg_install.bat
34 include compat/vcbuild/VCPKG-DEFS
38 # We choose to avoid "if .. else if .. else .. endif endif"
39 # because maintaining the nesting to match is a pain. If
40 # we had "elif" things would have been much nicer...
42 ifeq ($(uname_S),OSF1)
43 # Need this for u_short definitions et al
44 BASIC_CFLAGS += -D_OSF_SOURCE
46 NO_STRTOULL = YesPlease
49 ifeq ($(uname_S),Linux)
50 HAVE_ALLOCA_H = YesPlease
51 NO_STRLCPY = YesPlease
52 HAVE_PATHS_H = YesPlease
53 LIBC_CONTAINS_LIBINTL = YesPlease
54 HAVE_DEV_TTY = YesPlease
55 HAVE_CLOCK_GETTIME = YesPlease
56 HAVE_CLOCK_MONOTONIC = YesPlease
57 # -lrt is needed for clock_gettime on glibc <= 2.16
58 NEEDS_LIBRT = YesPlease
59 HAVE_SYNC_FILE_RANGE = YesPlease
60 HAVE_GETDELIM = YesPlease
61 FREAD_READS_DIRECTORIES = UnfortunatelyYes
62 BASIC_CFLAGS += -DHAVE_SYSINFO
63 PROCFS_EXECUTABLE_PATH = /proc/self/exe
64 HAVE_PLATFORM_PROCINFO = YesPlease
65 COMPAT_OBJS += compat/linux/procinfo.o
66 # centos7/rhel7 provides gcc 4.8.5 and zlib 1.2.7.
67 ifneq ($(findstring .el7.,$(uname_R)),)
68 BASIC_CFLAGS += -std=c99
70 LINK_FUZZ_PROGRAMS = YesPlease
72 ifeq ($(uname_S),GNU/kFreeBSD)
73 HAVE_ALLOCA_H = YesPlease
74 NO_STRLCPY = YesPlease
75 HAVE_PATHS_H = YesPlease
76 DIR_HAS_BSD_GROUP_SEMANTICS = YesPlease
77 LIBC_CONTAINS_LIBINTL = YesPlease
78 FREAD_READS_DIRECTORIES = UnfortunatelyYes
80 ifeq ($(uname_S),UnixWare)
82 NEEDS_SOCKET = YesPlease
84 NEEDS_SSL_WITH_CRYPTO = YesPlease
85 NEEDS_LIBICONV = YesPlease
86 SHELL_PATH = /usr/local/bin/bash
88 NO_HSTRERROR = YesPlease
89 BASIC_CFLAGS += -Kthread
90 BASIC_CFLAGS += -I/usr/local/include
91 BASIC_LDFLAGS += -L/usr/local/lib
94 NO_STRCASESTR = YesPlease
97 ifeq ($(uname_S),SCO_SV)
103 BASIC_CFLAGS += -Kthread
105 NEEDS_SOCKET = YesPlease
106 NEEDS_NSL = YesPlease
107 NEEDS_SSL_WITH_CRYPTO = YesPlease
108 NEEDS_LIBICONV = YesPlease
109 SHELL_PATH = /usr/bin/bash
111 NO_HSTRERROR = YesPlease
112 BASIC_CFLAGS += -I/usr/local/include
113 BASIC_LDFLAGS += -L/usr/local/lib
114 NO_STRCASESTR = YesPlease
115 NO_MEMMEM = YesPlease
119 ifeq ($(uname_S),Darwin)
120 NEEDS_CRYPTO_WITH_SSL = YesPlease
121 NEEDS_SSL_WITH_CRYPTO = YesPlease
122 NEEDS_LIBICONV = YesPlease
123 # Note: $(uname_R) gives us the underlying Darwin version.
124 # - MacOS 10.0.* and MacOS 10.1.0 = Darwin 1.*
125 # - MacOS 10.x.* = Darwin (x+4).* for (1 <= x)
126 # i.e. "begins with [15678] and a dot" means "10.4.* or older".
127 ifeq ($(shell expr "$(uname_R)" : '[15678]\.'),2)
128 OLD_ICONV = UnfortunatelyYes
129 NO_APPLE_COMMON_CRYPTO = YesPlease
131 ifeq ($(shell expr "$(uname_R)" : '[15]\.'),2)
132 NO_STRLCPY = YesPlease
134 ifeq ($(shell test "`expr "$(uname_R)" : '\([0-9][0-9]*\)\.'`" -ge 11 && echo 1),1)
135 HAVE_GETDELIM = YesPlease
137 ifeq ($(shell test "`expr "$(uname_R)" : '\([0-9][0-9]*\)\.'`" -ge 20 && echo 1),1)
138 OPEN_RETURNS_EINTR = UnfortunatelyYes
140 NO_MEMMEM = YesPlease
141 USE_ST_TIMESPEC = YesPlease
142 HAVE_DEV_TTY = YesPlease
143 COMPAT_OBJS += compat/precompose_utf8.o
144 BASIC_CFLAGS += -DPRECOMPOSE_UNICODE
145 BASIC_CFLAGS += -DPROTECT_HFS_DEFAULT=1
146 HAVE_BSD_SYSCTL = YesPlease
147 FREAD_READS_DIRECTORIES = UnfortunatelyYes
148 HAVE_NS_GET_EXECUTABLE_PATH = YesPlease
149 CSPRNG_METHOD = arc4random
150 USE_ENHANCED_BASIC_REGULAR_EXPRESSIONS = YesPlease
152 # Workaround for `gettext` being keg-only and not even being linked via
153 # `brew link --force gettext`, should be obsolete as of
154 # https://github.com/Homebrew/homebrew-core/pull/53489
155 ifeq ($(shell test -d /usr/local/opt/gettext/ && echo y),y)
156 BASIC_CFLAGS += -I/usr/local/include -I/usr/local/opt/gettext/include
157 BASIC_LDFLAGS += -L/usr/local/lib -L/usr/local/opt/gettext/lib
158 ifeq ($(shell test -x /usr/local/opt/gettext/bin/msgfmt && echo y),y)
159 MSGFMT = /usr/local/opt/gettext/bin/msgfmt
161 # On newer ARM-based machines the default installation path has changed to
162 # /opt/homebrew. Include it in our search paths so that the user does not
163 # have to configure this manually.
165 # Note that we do not employ the same workaround as above where we manually
166 # add gettext. The issue was fixed more than three years ago by now, and at
167 # that point there haven't been any ARM-based Macs yet.
168 else ifeq ($(shell test -d /opt/homebrew/ && echo y),y)
169 BASIC_CFLAGS += -I/opt/homebrew/include
170 BASIC_LDFLAGS += -L/opt/homebrew/lib
171 ifeq ($(shell test -x /opt/homebrew/bin/msgfmt && echo y),y)
172 MSGFMT = /opt/homebrew/bin/msgfmt
176 # The builtin FSMonitor on MacOS builds upon Simple-IPC. Both require
177 # Unix domain sockets and PThreads.
179 ifndef NO_UNIX_SOCKETS
180 FSMONITOR_DAEMON_BACKEND = darwin
181 FSMONITOR_OS_SETTINGS = darwin
185 BASIC_LDFLAGS += -framework CoreServices
187 ifeq ($(uname_S),SunOS)
188 NEEDS_SOCKET = YesPlease
189 NEEDS_NSL = YesPlease
190 SHELL_PATH = /bin/bash
191 SANE_TOOL_PATH = /usr/xpg6/bin:/usr/xpg4/bin
192 HAVE_ALLOCA_H = YesPlease
193 NO_STRCASESTR = YesPlease
194 NO_MEMMEM = YesPlease
195 NO_MKDTEMP = YesPlease
197 NO_MSGFMT_EXTENDED_OPTIONS = YesPlease
198 HAVE_DEV_TTY = YesPlease
199 ifeq ($(uname_R),5.6)
201 NO_HSTRERROR = YesPlease
203 NO_SOCKADDR_STORAGE = YesPlease
204 NO_UNSETENV = YesPlease
205 NO_SETENV = YesPlease
206 NO_STRLCPY = YesPlease
207 NO_STRTOUMAX = YesPlease
210 ifeq ($(uname_R),5.7)
211 NEEDS_RESOLV = YesPlease
213 NO_SOCKADDR_STORAGE = YesPlease
214 NO_UNSETENV = YesPlease
215 NO_SETENV = YesPlease
216 NO_STRLCPY = YesPlease
217 NO_STRTOUMAX = YesPlease
220 ifeq ($(uname_R),5.8)
221 NO_UNSETENV = YesPlease
222 NO_SETENV = YesPlease
223 NO_STRTOUMAX = YesPlease
226 ifeq ($(uname_R),5.9)
227 NO_UNSETENV = YesPlease
228 NO_SETENV = YesPlease
229 NO_STRTOUMAX = YesPlease
232 INSTALL = /usr/ucb/install
234 BASIC_CFLAGS += -D__EXTENSIONS__ -D__sun__
236 ifeq ($(uname_O),Cygwin)
237 ifeq ($(shell expr "$(uname_R)" : '1\.[1-6]\.'),4)
238 NO_D_TYPE_IN_DIRENT = YesPlease
239 NO_STRCASESTR = YesPlease
240 NO_MEMMEM = YesPlease
241 NO_SYMLINK_HEAD = YesPlease
243 OLD_ICONV = UnfortunatelyYes
244 # There are conflicting reports about this.
245 # On some boxes NO_MMAP is needed, and not so elsewhere.
246 # Try commenting this out if you suspect MMAP is more efficient
249 NO_REGEX = UnfortunatelyYes
251 HAVE_ALLOCA_H = YesPlease
252 NEEDS_LIBICONV = YesPlease
253 NO_FAST_WORKING_DIRECTORY = UnfortunatelyYes
254 NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease
256 UNRELIABLE_FSTAT = UnfortunatelyYes
257 OBJECT_CREATION_USES_RENAMES = UnfortunatelyNeedsTo
258 MMAP_PREVENTS_DELETE = UnfortunatelyYes
259 COMPAT_OBJS += compat/win32/path-utils.o
260 FREAD_READS_DIRECTORIES = UnfortunatelyYes
262 ifeq ($(uname_S),FreeBSD)
263 NEEDS_LIBICONV = YesPlease
264 # Versions up to 10.1 require OLD_ICONV; 10.2 and beyond don't.
265 # A typical version string looks like "10.2-RELEASE".
266 ifeq ($(shell expr "$(uname_R)" : '[1-9]\.'),2)
267 OLD_ICONV = YesPlease
269 ifeq ($(firstword $(subst -, ,$(uname_R))),10.0)
270 OLD_ICONV = YesPlease
272 ifeq ($(firstword $(subst -, ,$(uname_R))),10.1)
273 OLD_ICONV = YesPlease
275 NO_MEMMEM = YesPlease
276 BASIC_CFLAGS += -I/usr/local/include
277 BASIC_LDFLAGS += -L/usr/local/lib
278 DIR_HAS_BSD_GROUP_SEMANTICS = YesPlease
279 USE_ST_TIMESPEC = YesPlease
280 ifeq ($(shell expr "$(uname_R)" : '4\.'),2)
281 PTHREAD_LIBS = -pthread
282 NO_UINTMAX_T = YesPlease
283 NO_STRTOUMAX = YesPlease
285 PYTHON_PATH = /usr/local/bin/python
286 PERL_PATH = /usr/local/bin/perl
287 HAVE_PATHS_H = YesPlease
288 HAVE_BSD_SYSCTL = YesPlease
289 HAVE_BSD_KERN_PROC_SYSCTL = YesPlease
290 CSPRNG_METHOD = arc4random
291 PAGER_ENV = LESS=FRX LV=-c MORE=FRX
292 FREAD_READS_DIRECTORIES = UnfortunatelyYes
293 FILENO_IS_A_MACRO = UnfortunatelyYes
295 ifeq ($(uname_S),OpenBSD)
296 NO_STRCASESTR = YesPlease
297 NO_MEMMEM = YesPlease
298 USE_ST_TIMESPEC = YesPlease
299 NEEDS_LIBICONV = YesPlease
300 BASIC_CFLAGS += -I/usr/local/include
301 BASIC_LDFLAGS += -L/usr/local/lib
302 HAVE_PATHS_H = YesPlease
303 HAVE_BSD_SYSCTL = YesPlease
304 HAVE_BSD_KERN_PROC_SYSCTL = YesPlease
305 CSPRNG_METHOD = arc4random
306 PROCFS_EXECUTABLE_PATH = /proc/curproc/file
307 FREAD_READS_DIRECTORIES = UnfortunatelyYes
308 FILENO_IS_A_MACRO = UnfortunatelyYes
310 ifeq ($(uname_S),MirBSD)
311 NO_STRCASESTR = YesPlease
312 NO_MEMMEM = YesPlease
313 USE_ST_TIMESPEC = YesPlease
314 NEEDS_LIBICONV = YesPlease
315 HAVE_PATHS_H = YesPlease
316 HAVE_BSD_SYSCTL = YesPlease
317 CSPRNG_METHOD = arc4random
319 ifeq ($(uname_S),NetBSD)
320 ifeq ($(shell expr "$(uname_R)" : '[01]\.'),2)
321 NEEDS_LIBICONV = YesPlease
323 BASIC_CFLAGS += -I/usr/pkg/include
324 BASIC_LDFLAGS += -L/usr/pkg/lib $(CC_LD_DYNPATH)/usr/pkg/lib
325 USE_ST_TIMESPEC = YesPlease
326 HAVE_PATHS_H = YesPlease
327 HAVE_BSD_SYSCTL = YesPlease
328 HAVE_BSD_KERN_PROC_SYSCTL = YesPlease
329 CSPRNG_METHOD = arc4random
330 PROCFS_EXECUTABLE_PATH = /proc/curproc/exe
332 ifeq ($(uname_S),AIX)
334 NO_STRCASESTR = YesPlease
335 NO_MEMMEM = YesPlease
336 NO_MKDTEMP = YesPlease
337 NO_STRLCPY = YesPlease
339 NO_REGEX = NeedsStartEnd
340 FREAD_READS_DIRECTORIES = UnfortunatelyYes
341 INTERNAL_QSORT = UnfortunatelyYes
342 NEEDS_LIBICONV = YesPlease
343 BASIC_CFLAGS += -D_LARGE_FILES
344 FILENO_IS_A_MACRO = UnfortunatelyYes
345 NEED_ACCESS_ROOT_HANDLER = UnfortunatelyYes
346 ifeq ($(shell expr "$(uname_V)" : '[1234]'),1)
347 NO_PTHREADS = YesPlease
349 PTHREAD_LIBS = -lpthread
351 ifeq ($(shell expr "$(uname_V).$(uname_R)" : '5\.1'),3)
356 ifeq ($(uname_S),GNU)
358 HAVE_ALLOCA_H = YesPlease
359 NO_STRLCPY = YesPlease
360 HAVE_PATHS_H = YesPlease
361 LIBC_CONTAINS_LIBINTL = YesPlease
362 FREAD_READS_DIRECTORIES = UnfortunatelyYes
364 ifeq ($(uname_S),IRIX)
365 NO_SETENV = YesPlease
366 NO_UNSETENV = YesPlease
367 NO_STRCASESTR = YesPlease
368 NO_MEMMEM = YesPlease
369 NO_MKDTEMP = YesPlease
370 # When compiled with the MIPSpro 7.4.4m compiler, and without pthreads
371 # (i.e. NO_PTHREADS is set), and _with_ MMAP (i.e. NO_MMAP is not set),
372 # git dies with a segmentation fault when trying to access the first
373 # entry of a reflog. The conservative choice is made to always set
374 # NO_MMAP. If you suspect that your compiler is not affected by this
375 # issue, comment out the NO_MMAP statement.
378 SNPRINTF_RETURNS_BOGUS = YesPlease
379 SHELL_PATH = /usr/gnu/bin/bash
380 NEEDS_LIBGEN = YesPlease
382 ifeq ($(uname_S),IRIX64)
383 NO_SETENV = YesPlease
384 NO_UNSETENV = YesPlease
385 NO_STRCASESTR = YesPlease
386 NO_MEMMEM = YesPlease
387 NO_MKDTEMP = YesPlease
388 # When compiled with the MIPSpro 7.4.4m compiler, and without pthreads
389 # (i.e. NO_PTHREADS is set), and _with_ MMAP (i.e. NO_MMAP is not set),
390 # git dies with a segmentation fault when trying to access the first
391 # entry of a reflog. The conservative choice is made to always set
392 # NO_MMAP. If you suspect that your compiler is not affected by this
393 # issue, comment out the NO_MMAP statement.
396 SNPRINTF_RETURNS_BOGUS = YesPlease
397 SHELL_PATH = /usr/gnu/bin/bash
398 NEEDS_LIBGEN = YesPlease
400 ifeq ($(uname_S),HP-UX)
403 NO_SETENV = YesPlease
404 NO_STRCASESTR = YesPlease
405 NO_MEMMEM = YesPlease
406 NO_STRLCPY = YesPlease
407 NO_MKDTEMP = YesPlease
408 NO_UNSETENV = YesPlease
409 NO_HSTRERROR = YesPlease
410 NO_SYS_SELECT_H = YesPlease
411 SNPRINTF_RETURNS_BOGUS = YesPlease
413 ifeq ($(uname_R),B.11.00)
414 NO_INET_NTOP = YesPlease
415 NO_INET_PTON = YesPlease
417 ifeq ($(uname_R),B.10.20)
418 # Override HP-UX 11.x setting:
422 NO_INET_NTOP = YesPlease
423 NO_INET_PTON = YesPlease
427 ifeq ($(uname_S),Windows)
428 GIT_VERSION := $(GIT_VERSION).MSVC
430 # Assume that this is built in Git for Windows' SDK
431 ifeq (MINGW32,$(MSYSTEM))
436 # Prepend MSVC 64-bit tool-chain to PATH.
438 # A regular Git Bash *does not* have cl.exe in its $PATH. As there is a
439 # link.exe next to, and required by, cl.exe, we have to prepend this
440 # onto the existing $PATH.
442 SANE_TOOL_PATH ?= $(msvc_bin_dir_msys)
443 HAVE_ALLOCA_H = YesPlease
445 NEEDS_CRYPTO_WITH_SSL = YesPlease
446 NO_LIBGEN_H = YesPlease
448 NO_SYMLINK_HEAD = YesPlease
450 NO_SETENV = YesPlease
451 NO_STRCASESTR = YesPlease
452 NO_STRLCPY = YesPlease
453 NO_MEMMEM = YesPlease
454 NEEDS_LIBICONV = YesPlease
455 NO_STRTOUMAX = YesPlease
456 NO_MKDTEMP = YesPlease
457 NO_INTTYPES_H = YesPlease
458 CSPRNG_METHOD = rtlgenrandom
459 # VS2015 with UCRT claims that snprintf and friends are C99 compliant,
460 # so we don't need this:
462 # SNPRINTF_RETURNS_BOGUS = YesPlease
464 # The builtin FSMonitor requires Named Pipes and Threads on Windows.
465 # These are always available, so we do not have to conditionally
467 FSMONITOR_DAEMON_BACKEND = win32
468 FSMONITOR_OS_SETTINGS = win32
470 NO_SVN_TESTS = YesPlease
471 RUNTIME_PREFIX = YesPlease
472 HAVE_WPGMPTR = YesWeDo
473 NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease
474 USE_WIN32_IPC = YesPlease
475 USE_WIN32_MMAP = YesPlease
476 MMAP_PREVENTS_DELETE = UnfortunatelyYes
477 # USE_NED_ALLOCATOR = YesPlease
478 UNRELIABLE_FSTAT = UnfortunatelyYes
479 OBJECT_CREATION_USES_RENAMES = UnfortunatelyNeedsTo
481 NO_GETTEXT = YesPlease
482 NO_PYTHON = YesPlease
484 NO_POSIX_GOODIES = UnfortunatelyYes
485 NATIVE_CRLF = YesPlease
486 DEFAULT_HELP_FORMAT = html
487 ifeq (/mingw64,$(subst 32,64,$(prefix)))
488 # Move system config into top-level /etc/
489 ETC_GITCONFIG = ../etc/gitconfig
490 ETC_GITATTRIBUTES = ../etc/gitattributes
493 CC = compat/vcbuild/scripts/clink.pl
494 AR = compat/vcbuild/scripts/lib.pl
496 BASIC_CFLAGS = -nologo -I. -Icompat/vcbuild/include -DWIN32 -D_CONSOLE -DHAVE_STRING_H -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE
497 COMPAT_OBJS = compat/msvc.o compat/winansi.o \
498 compat/win32/flush.o \
499 compat/win32/path-utils.o \
500 compat/win32/pthread.o compat/win32/syslog.o \
501 compat/win32/trace2_win32_process_info.o \
502 compat/win32/dirent.o
503 COMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DDETECT_MSYS_TTY -DNOGDI -DHAVE_STRING_H -Icompat -Icompat/regex -Icompat/win32 -DSTRIP_EXTENSION=\".exe\"
504 BASIC_LDFLAGS = -IGNORE:4217 -IGNORE:4049 -NOLOGO -ENTRY:wmainCRTStartup -SUBSYSTEM:CONSOLE
505 # invalidcontinue.obj allows Git's source code to close the same file
506 # handle twice, or to access the osfhandle of an already-closed stdout
507 # See https://msdn.microsoft.com/en-us/library/ms235330.aspx
508 EXTLIBS = user32.lib advapi32.lib shell32.lib wininet.lib ws2_32.lib invalidcontinue.obj kernel32.lib ntdll.lib
511 BASIC_CFLAGS += $(vcpkg_inc) $(sdk_includes) $(msvc_includes)
513 BASIC_CFLAGS += $(vcpkg_rel_lib)
515 BASIC_CFLAGS += $(vcpkg_dbg_lib)
517 BASIC_CFLAGS += $(sdk_libs) $(msvc_libs)
519 ifneq ($(USE_MSVC_CRTDBG),)
520 # Optionally enable memory leak reporting.
521 BASIC_CFLAGS += -DUSE_MSVC_CRTDBG
523 # Always give "-Zi" to the compiler and "-debug" to linker (even in
524 # release mode) to force a PDB to be generated (like RelWithDebInfo).
526 BASIC_LDFLAGS += -debug -Zf
529 LDFLAGS += -SAFESEH:NO
533 BASIC_CFLAGS += -GL -Gy -O2 -Oy- -MD -DNDEBUG
534 BASIC_LDFLAGS += -release -LTCG /OPT:REF /OPT:ICF /INCREMENTAL:NO /DEBUGTYPE:CV,FIXUP
537 BASIC_CFLAGS += -MDd -DDEBUG -D_DEBUG
541 EXTRA_PROGRAMS += headless-git$X
543 compat/msvc.o: compat/msvc.c compat/mingw.c GIT-CFLAGS
545 ifeq ($(uname_S),Interix)
546 NO_INITGROUPS = YesPlease
548 NO_MEMMEM = YesPlease
549 NO_MKDTEMP = YesPlease
550 NO_STRTOUMAX = YesPlease
552 ifeq ($(uname_R),3.5)
553 NO_INET_NTOP = YesPlease
554 NO_INET_PTON = YesPlease
555 NO_SOCKADDR_STORAGE = YesPlease
557 ifeq ($(uname_R),5.2)
558 NO_INET_NTOP = YesPlease
559 NO_INET_PTON = YesPlease
560 NO_SOCKADDR_STORAGE = YesPlease
563 ifeq ($(uname_S),Minix)
565 NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease
568 NEEDS_CRYPTO_WITH_SSL = YesPlease
570 NO_HSTRERROR = YesPlease
575 ifeq ($(uname_S),NONSTOP_KERNEL)
576 # Needs some C99 features, "inline" is just one of them.
577 # INLINE='' would just replace one set of warnings with another and
578 # still not compile in c89 mode, due to non-const array initializations.
580 # Build down-rev compatible objects that don't use our new getopt_long.
581 ifeq ($(uname_R).$(uname_V),J06.21)
584 ifeq ($(uname_R).$(uname_V),L17.02)
587 # Disable all optimization, seems to result in bad code, with -O or -O2
588 # or even -O1 (default), /usr/local/libexec/git-core/git-pack-objects
589 # abends on "git push". Needs more investigation.
590 CFLAGS = -g -O0 -Winline
591 # We'd want it to be here.
593 # perl and python must be in /usr/bin on NonStop - supplied by HPE
594 # with operating system in that managed directory.
595 PERL_PATH = /usr/bin/perl
596 PYTHON_PATH = /usr/bin/python
597 # The current /usr/coreutils/rm at lowest support level does not work
598 # with the git test structure. Long paths as in
599 # 'trash directory...' cause rm to terminate prematurely without fully
600 # removing the directory at OS releases J06.21 and L17.02.
601 # Default to the older rm until those two releases are deprecated.
603 NEEDS_CRYPTO_WITH_SSL = YesPlease
604 HAVE_DEV_TTY = YesPlease
605 HAVE_LIBCHARSET_H = YesPlease
606 HAVE_STRINGS_H = YesPlease
607 NEEDS_LIBICONV = YesPlease
608 NEEDS_LIBINTL_BEFORE_LIBICONV = YesPlease
609 NO_SYS_SELECT_H = UnfortunatelyYes
610 NO_D_TYPE_IN_DIRENT = YesPlease
611 NO_GETTEXT = YesPlease
612 NO_HSTRERROR = YesPlease
613 NO_STRCASESTR = YesPlease
614 NO_MEMMEM = YesPlease
615 NO_STRLCPY = YesPlease
616 NO_SETENV = YesPlease
617 NO_UNSETENV = YesPlease
618 NO_MKDTEMP = YesPlease
619 # Currently libiconv-1.9.1.
620 OLD_ICONV = UnfortunatelyYes
621 NO_REGEX = NeedsStartEnd
622 NO_PTHREADS = UnfortunatelyYes
623 FREAD_READS_DIRECTORIES = UnfortunatelyYes
625 # Not detected (nor checked for) by './configure'.
626 # We don't have SA_RESTART on NonStop, unfortunalety.
627 COMPAT_CFLAGS += -DSA_RESTART=0
628 # Apparently needed in compat/fnmatch/fnmatch.c.
629 COMPAT_CFLAGS += -DHAVE_STRING_H=1
630 NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease
635 NO_INTPTR_T = UnfortunatelyYes
636 CSPRNG_METHOD = openssl
637 SANE_TOOL_PATH = /usr/coreutils/bin:/usr/local/bin
638 SHELL_PATH = /usr/coreutils/bin/bash
640 ifeq ($(uname_S),OS/390)
641 NO_SYS_POLL_H = YesPlease
642 NO_STRCASESTR = YesPlease
646 NO_STRLCPY = YesPlease
647 NO_MEMMEM = YesPlease
648 NO_GECOS_IN_PWENT = YesPlease
649 HAVE_STRINGS_H = YesPlease
650 NEEDS_MODE_TRANSLATION = YesPlease
651 HAVE_ZOS_GET_EXECUTABLE_PATH = YesPlease
653 ifeq ($(uname_S),MINGW)
654 ifeq ($(shell expr "$(uname_R)" : '1\.'),2)
655 $(error "Building with MSys is no longer supported")
658 HAVE_ALLOCA_H = YesPlease
660 NEEDS_CRYPTO_WITH_SSL = YesPlease
661 NO_LIBGEN_H = YesPlease
663 NO_SYMLINK_HEAD = YesPlease
664 NO_SETENV = YesPlease
665 NO_STRCASESTR = YesPlease
666 NO_STRLCPY = YesPlease
667 NO_MEMMEM = YesPlease
668 NEEDS_LIBICONV = YesPlease
669 NO_STRTOUMAX = YesPlease
670 NO_MKDTEMP = YesPlease
671 NO_SVN_TESTS = YesPlease
673 # The builtin FSMonitor requires Named Pipes and Threads on Windows.
674 # These are always available, so we do not have to conditionally
676 FSMONITOR_DAEMON_BACKEND = win32
677 FSMONITOR_OS_SETTINGS = win32
679 RUNTIME_PREFIX = YesPlease
680 HAVE_WPGMPTR = YesWeDo
681 NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease
682 USE_WIN32_IPC = YesPlease
683 USE_WIN32_MMAP = YesPlease
684 MMAP_PREVENTS_DELETE = UnfortunatelyYes
685 UNRELIABLE_FSTAT = UnfortunatelyYes
686 OBJECT_CREATION_USES_RENAMES = UnfortunatelyNeedsTo
689 NO_POSIX_GOODIES = UnfortunatelyYes
690 DEFAULT_HELP_FORMAT = html
691 HAVE_PLATFORM_PROCINFO = YesPlease
692 CSPRNG_METHOD = rtlgenrandom
693 BASIC_LDFLAGS += -municode
694 COMPAT_CFLAGS += -DNOGDI -Icompat -Icompat/win32
695 COMPAT_CFLAGS += -DSTRIP_EXTENSION=\".exe\"
696 COMPAT_OBJS += compat/mingw.o compat/winansi.o \
697 compat/win32/trace2_win32_process_info.o \
698 compat/win32/flush.o \
699 compat/win32/path-utils.o \
700 compat/win32/pthread.o compat/win32/syslog.o \
701 compat/win32/dirent.o
702 BASIC_CFLAGS += -DWIN32
707 NATIVE_CRLF = YesPlease
712 BASIC_LDFLAGS += -Wl,--nxcompat
713 # Enable ASLR (unless debugging)
714 ifneq (,$(findstring -O,$(filter-out -O0 -Og,$(CFLAGS))))
715 BASIC_LDFLAGS += -Wl,--dynamicbase
717 ifeq (MINGW32,$(MSYSTEM))
720 BASIC_LDFLAGS += -Wl,--pic-executable,-e,_mainCRTStartup
722 ifeq (MINGW64,$(MSYSTEM))
725 BASIC_LDFLAGS += -Wl,--pic-executable,-e,mainCRTStartup
727 COMPAT_CFLAGS += -D_USE_32BIT_TIME_T
728 BASIC_LDFLAGS += -Wl,--large-address-aware
731 COMPAT_CFLAGS += -D__USE_MINGW_ANSI_STDIO=0 -DDETECT_MSYS_TTY \
732 -fstack-protector-strong
734 EXTRA_PROGRAMS += headless-git$X
735 INSTALL = /bin/install
736 INTERNAL_QSORT = YesPlease
737 HAVE_LIBCHARSET_H = YesPlease
738 USE_GETTEXT_SCHEME = fallthrough
739 USE_LIBPCRE = YesPlease
740 USE_NED_ALLOCATOR = YesPlease
741 ifeq (/mingw64,$(subst 32,64,$(prefix)))
742 # Move system config into top-level /etc/
743 ETC_GITCONFIG = ../etc/gitconfig
744 ETC_GITATTRIBUTES = ../etc/gitattributes
747 ifeq ($(uname_S),QNX)
748 COMPAT_CFLAGS += -DSA_RESTART=0
749 EXPAT_NEEDS_XMLPARSE_H = YesPlease
750 HAVE_STRINGS_H = YesPlease
751 NEEDS_SOCKET = YesPlease
752 NO_GETPAGESIZE = YesPlease
754 NO_MEMMEM = YesPlease
755 NO_MKDTEMP = YesPlease
757 NO_PTHREADS = YesPlease
758 NO_STRCASESTR = YesPlease
759 NO_STRLCPY = YesPlease
763 # Require clean work tree
764 git update-index -q --refresh && \
765 git diff-files --quiet && \
766 git diff-index --cached --quiet HEAD --
768 # Make .vcxproj files and add them
769 perl contrib/buildsystems/generate -g Vcxproj
770 git add -f git.sln {*,*/lib,t/helper/*}/*.vcxproj
772 # Generate the LinkOrCopyBuiltins.targets and LinkOrCopyRemoteHttp.targets file
773 (echo '<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">' && \
774 echo ' <Target Name="CopyBuiltins_AfterBuild" AfterTargets="AfterBuild">' && \
775 for name in $(BUILT_INS);\
777 echo ' <Copy SourceFiles="$$(OutDir)\git.exe" DestinationFiles="$$(OutDir)\'"$$name"'" SkipUnchangedFiles="true" UseHardlinksIfPossible="true" />'; \
779 echo ' </Target>' && \
780 echo '</Project>') >git/LinkOrCopyBuiltins.targets
781 (echo '<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">' && \
782 echo ' <Target Name="CopyBuiltins_AfterBuild" AfterTargets="AfterBuild">' && \
783 for name in $(REMOTE_CURL_ALIASES); \
785 echo ' <Copy SourceFiles="$$(OutDir)\'"$(REMOTE_CURL_PRIMARY)"'" DestinationFiles="$$(OutDir)\'"$$name"'" SkipUnchangedFiles="true" UseHardlinksIfPossible="true" />'; \
787 echo ' </Target>' && \
788 echo '</Project>') >git-remote-http/LinkOrCopyRemoteHttp.targets
789 git add -f git/LinkOrCopyBuiltins.targets git-remote-http/LinkOrCopyRemoteHttp.targets
791 # Add generated headers
792 $(MAKE) MSVC=1 SKIP_VCPKG=1 prefix=/mingw64 $(GENERATED_H)
793 git add -f $(GENERATED_H)
797 $(MAKE) MSVC=1 SKIP_VCPKG=1 prefix=/mingw64 $(SCRIPT_LIB) $(SCRIPTS)
798 # Strip out the sane tool path, needed only for building
799 sed -i '/^git_broken_path_fix ".*/d' git-sh-setup
800 git add -f $(SCRIPT_LIB) $(SCRIPTS)
803 $(MAKE) $(LIB_PERL_GEN)
804 git add -f perl/build
806 # Add bin-wrappers, for testing
808 $(MAKE) MSVC=1 SKIP_VCPKG=1 prefix=/mingw64 $(test_bindir_programs)
809 # Ensure that the GIT_EXEC_PATH is a Unix-y one, and that the absolute
810 # path of the repository is not hard-coded (GIT_EXEC_PATH will be set
811 # by test-lib.sh according to the current setup)
812 sed -i -e 's/^\(GIT_EXEC_PATH\)=.*/test -n "$${\1##*:*}" ||\
813 \1="$$(cygpath -u "$$\1")"/' \
814 -e "s|'$$(pwd)|\"\$$GIT_EXEC_PATH\"'|g" bin-wrappers/*
815 # Ensure that test-* helpers find the .dll files copied to top-level
816 sed -i 's|^PATH=.*|&:"$$GIT_EXEC_PATH"|' bin-wrappers/test-*
817 # We do not want to force hard-linking builtins
818 sed -i 's|\(git\)-\([-a-z]*\)\.exe"|\1.exe" \2|g' \
819 bin-wrappers/git-{receive-pack,upload-archive}
820 git add -f $(test_bindir_programs)
821 # remote-ext is a builtin, but invoked as if it were external
822 sed 's|receive-pack|remote-ext|g' \
823 <bin-wrappers/git-receive-pack >bin-wrappers/git-remote-ext
824 git add -f bin-wrappers/git-remote-ext
828 git add -f templates/boilerplates.made templates/blt/
830 # Add the translated messages
831 make MSVC=1 SKIP_VCPKG=1 prefix=/mingw64 $(MOFILES)
832 git add -f $(MOFILES)
835 $(MAKE) MSVC=1 SKIP_VCPKG=1 prefix=/mingw64 GIT-BUILD-OPTIONS
836 git add -f GIT-BUILD-OPTIONS
838 # Commit the whole shebang
839 git commit -m "Generate Visual Studio solution" \
840 -m "Auto-generated by \`$(MAKE)$(MAKEFLAGS) $@\`"