compat/fsmonitor/fsm-listen-darwin: add MacOS header files for FSEvent
[git.git] / config.mak.uname
blob501970902da186fdbc2812a3b39f5fcb8a889b5b
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_P := $(shell sh -c 'uname -p 2>/dev/null || echo not')
12 uname_V := $(shell sh -c 'uname -v 2>/dev/null || echo not')
14 ifneq ($(findstring MINGW,$(uname_S)),)
15         uname_S := MINGW
16 endif
18 ifdef MSVC
19         # avoid the MingW and Cygwin configuration sections
20         uname_S := Windows
21         uname_O := Windows
23         # Generate and include makefile variables that point to the
24         # currently installed set of MSVC command line tools.
25 compat/vcbuild/MSVC-DEFS-GEN: compat/vcbuild/find_vs_env.bat
26         @"$<" | tr '\\' / >"$@"
27 include compat/vcbuild/MSVC-DEFS-GEN
29         # See if vcpkg and the vcpkg-build versions of the third-party
30         # libraries that we use are installed.  We include the result
31         # to get $(vcpkg_*) variables defined for the Makefile.
32 ifeq (,$(SKIP_VCPKG))
33 compat/vcbuild/VCPKG-DEFS: compat/vcbuild/vcpkg_install.bat
34         @"$<"
35 include compat/vcbuild/VCPKG-DEFS
36 endif
37 endif
39 # We choose to avoid "if .. else if .. else .. endif endif"
40 # because maintaining the nesting to match is a pain.  If
41 # we had "elif" things would have been much nicer...
43 ifeq ($(uname_S),OSF1)
44         # Need this for u_short definitions et al
45         BASIC_CFLAGS += -D_OSF_SOURCE
46         SOCKLEN_T = int
47         NO_STRTOULL = YesPlease
48         NO_NSEC = YesPlease
49 endif
50 ifeq ($(uname_S),Linux)
51         HAVE_ALLOCA_H = YesPlease
52         NO_STRLCPY = YesPlease
53         HAVE_PATHS_H = YesPlease
54         LIBC_CONTAINS_LIBINTL = YesPlease
55         HAVE_DEV_TTY = YesPlease
56         HAVE_CLOCK_GETTIME = YesPlease
57         HAVE_CLOCK_MONOTONIC = YesPlease
58         # -lrt is needed for clock_gettime on glibc <= 2.16
59         NEEDS_LIBRT = 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
69         endif
70 endif
71 ifeq ($(uname_S),GNU/kFreeBSD)
72         HAVE_ALLOCA_H = YesPlease
73         NO_STRLCPY = YesPlease
74         HAVE_PATHS_H = YesPlease
75         DIR_HAS_BSD_GROUP_SEMANTICS = YesPlease
76         LIBC_CONTAINS_LIBINTL = YesPlease
77         FREAD_READS_DIRECTORIES = UnfortunatelyYes
78 endif
79 ifeq ($(uname_S),UnixWare)
80         CC = cc
81         NEEDS_SOCKET = YesPlease
82         NEEDS_NSL = YesPlease
83         NEEDS_SSL_WITH_CRYPTO = YesPlease
84         NEEDS_LIBICONV = YesPlease
85         SHELL_PATH = /usr/local/bin/bash
86         NO_IPV6 = YesPlease
87         NO_HSTRERROR = YesPlease
88         BASIC_CFLAGS += -Kthread
89         BASIC_CFLAGS += -I/usr/local/include
90         BASIC_LDFLAGS += -L/usr/local/lib
91         INSTALL = ginstall
92         TAR = gtar
93         NO_STRCASESTR = YesPlease
94         NO_MEMMEM = YesPlease
95 endif
96 ifeq ($(uname_S),SCO_SV)
97         ifeq ($(uname_R),3.2)
98                 CFLAGS = -O2
99         endif
100         ifeq ($(uname_R),5)
101                 CC = cc
102                 BASIC_CFLAGS += -Kthread
103         endif
104         NEEDS_SOCKET = YesPlease
105         NEEDS_NSL = YesPlease
106         NEEDS_SSL_WITH_CRYPTO = YesPlease
107         NEEDS_LIBICONV = YesPlease
108         SHELL_PATH = /usr/bin/bash
109         NO_IPV6 = YesPlease
110         NO_HSTRERROR = YesPlease
111         BASIC_CFLAGS += -I/usr/local/include
112         BASIC_LDFLAGS += -L/usr/local/lib
113         NO_STRCASESTR = YesPlease
114         NO_MEMMEM = YesPlease
115         INSTALL = ginstall
116         TAR = gtar
117 endif
118 ifeq ($(uname_S),Darwin)
119         NEEDS_CRYPTO_WITH_SSL = YesPlease
120         NEEDS_SSL_WITH_CRYPTO = YesPlease
121         NEEDS_LIBICONV = YesPlease
122         # Note: $(uname_R) gives us the underlying Darwin version.
123         # - MacOS 10.0.* and MacOS 10.1.0 = Darwin 1.*
124         # - MacOS 10.x.* = Darwin (x+4).* for (1 <= x)
125         # i.e. "begins with [15678] and a dot" means "10.4.* or older".
126         ifeq ($(shell expr "$(uname_R)" : '[15678]\.'),2)
127                 OLD_ICONV = UnfortunatelyYes
128                 NO_APPLE_COMMON_CRYPTO = YesPlease
129         endif
130         ifeq ($(shell expr "$(uname_R)" : '[15]\.'),2)
131                 NO_STRLCPY = YesPlease
132         endif
133         ifeq ($(shell test "`expr "$(uname_R)" : '\([0-9][0-9]*\)\.'`" -ge 11 && echo 1),1)
134                 HAVE_GETDELIM = YesPlease
135         endif
136         ifeq ($(shell test "`expr "$(uname_R)" : '\([0-9][0-9]*\)\.'`" -ge 20 && echo 1),1)
137                 OPEN_RETURNS_EINTR = UnfortunatelyYes
138         endif
139         NO_MEMMEM = YesPlease
140         USE_ST_TIMESPEC = YesPlease
141         HAVE_DEV_TTY = YesPlease
142         COMPAT_OBJS += compat/precompose_utf8.o
143         BASIC_CFLAGS += -DPRECOMPOSE_UNICODE
144         BASIC_CFLAGS += -DPROTECT_HFS_DEFAULT=1
145         HAVE_BSD_SYSCTL = YesPlease
146         FREAD_READS_DIRECTORIES = UnfortunatelyYes
147         HAVE_NS_GET_EXECUTABLE_PATH = YesPlease
148         CSPRNG_METHOD = arc4random
150         # Workaround for `gettext` being keg-only and not even being linked via
151         # `brew link --force gettext`, should be obsolete as of
152         # https://github.com/Homebrew/homebrew-core/pull/53489
153         ifeq ($(shell test -d /usr/local/opt/gettext/ && echo y),y)
154                 BASIC_CFLAGS += -I/usr/local/include -I/usr/local/opt/gettext/include
155                 BASIC_LDFLAGS += -L/usr/local/lib -L/usr/local/opt/gettext/lib
156                 ifeq ($(shell test -x /usr/local/opt/gettext/bin/msgfmt && echo y),y)
157                         MSGFMT = /usr/local/opt/gettext/bin/msgfmt
158                 endif
159         endif
161         # The builtin FSMonitor on MacOS builds upon Simple-IPC.  Both require
162         # Unix domain sockets and PThreads.
163         ifndef NO_PTHREADS
164         ifndef NO_UNIX_SOCKETS
165         FSMONITOR_DAEMON_BACKEND = darwin
166         endif
167         endif
169         BASIC_LDFLAGS += -framework CoreServices
170 endif
171 ifeq ($(uname_S),SunOS)
172         NEEDS_SOCKET = YesPlease
173         NEEDS_NSL = YesPlease
174         SHELL_PATH = /bin/bash
175         SANE_TOOL_PATH = /usr/xpg6/bin:/usr/xpg4/bin
176         HAVE_ALLOCA_H = YesPlease
177         NO_STRCASESTR = YesPlease
178         NO_MEMMEM = YesPlease
179         NO_MKDTEMP = YesPlease
180         NO_REGEX = YesPlease
181         NO_MSGFMT_EXTENDED_OPTIONS = YesPlease
182         HAVE_DEV_TTY = YesPlease
183         ifeq ($(uname_R),5.6)
184                 SOCKLEN_T = int
185                 NO_HSTRERROR = YesPlease
186                 NO_IPV6 = YesPlease
187                 NO_SOCKADDR_STORAGE = YesPlease
188                 NO_UNSETENV = YesPlease
189                 NO_SETENV = YesPlease
190                 NO_STRLCPY = YesPlease
191                 NO_STRTOUMAX = YesPlease
192                 GIT_TEST_CMP = cmp
193         endif
194         ifeq ($(uname_R),5.7)
195                 NEEDS_RESOLV = YesPlease
196                 NO_IPV6 = YesPlease
197                 NO_SOCKADDR_STORAGE = YesPlease
198                 NO_UNSETENV = YesPlease
199                 NO_SETENV = YesPlease
200                 NO_STRLCPY = YesPlease
201                 NO_STRTOUMAX = YesPlease
202                 GIT_TEST_CMP = cmp
203         endif
204         ifeq ($(uname_R),5.8)
205                 NO_UNSETENV = YesPlease
206                 NO_SETENV = YesPlease
207                 NO_STRTOUMAX = YesPlease
208                 GIT_TEST_CMP = cmp
209         endif
210         ifeq ($(uname_R),5.9)
211                 NO_UNSETENV = YesPlease
212                 NO_SETENV = YesPlease
213                 NO_STRTOUMAX = YesPlease
214                 GIT_TEST_CMP = cmp
215         endif
216         INSTALL = /usr/ucb/install
217         TAR = gtar
218         BASIC_CFLAGS += -D__EXTENSIONS__ -D__sun__
219 endif
220 ifeq ($(uname_O),Cygwin)
221         ifeq ($(shell expr "$(uname_R)" : '1\.[1-6]\.'),4)
222                 NO_D_TYPE_IN_DIRENT = YesPlease
223                 NO_STRCASESTR = YesPlease
224                 NO_MEMMEM = YesPlease
225                 NO_SYMLINK_HEAD = YesPlease
226                 NO_IPV6 = YesPlease
227                 OLD_ICONV = UnfortunatelyYes
228                 # There are conflicting reports about this.
229                 # On some boxes NO_MMAP is needed, and not so elsewhere.
230                 # Try commenting this out if you suspect MMAP is more efficient
231                 NO_MMAP = YesPlease
232         else
233                 NO_REGEX = UnfortunatelyYes
234         endif
235         HAVE_ALLOCA_H = YesPlease
236         NEEDS_LIBICONV = YesPlease
237         NO_FAST_WORKING_DIRECTORY = UnfortunatelyYes
238         NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease
239         X = .exe
240         UNRELIABLE_FSTAT = UnfortunatelyYes
241         OBJECT_CREATION_USES_RENAMES = UnfortunatelyNeedsTo
242         MMAP_PREVENTS_DELETE = UnfortunatelyYes
243         COMPAT_OBJS += compat/win32/path-utils.o
244         FREAD_READS_DIRECTORIES = UnfortunatelyYes
245 endif
246 ifeq ($(uname_S),FreeBSD)
247         NEEDS_LIBICONV = YesPlease
248         # Versions up to 10.1 require OLD_ICONV; 10.2 and beyond don't.
249         # A typical version string looks like "10.2-RELEASE".
250         ifeq ($(shell expr "$(uname_R)" : '[1-9]\.'),2)
251                 OLD_ICONV = YesPlease
252         endif
253         ifeq ($(firstword $(subst -, ,$(uname_R))),10.0)
254                 OLD_ICONV = YesPlease
255         endif
256         ifeq ($(firstword $(subst -, ,$(uname_R))),10.1)
257                 OLD_ICONV = YesPlease
258         endif
259         NO_MEMMEM = YesPlease
260         BASIC_CFLAGS += -I/usr/local/include
261         BASIC_LDFLAGS += -L/usr/local/lib
262         DIR_HAS_BSD_GROUP_SEMANTICS = YesPlease
263         USE_ST_TIMESPEC = YesPlease
264         ifeq ($(shell expr "$(uname_R)" : '4\.'),2)
265                 PTHREAD_LIBS = -pthread
266                 NO_UINTMAX_T = YesPlease
267                 NO_STRTOUMAX = YesPlease
268         endif
269         PYTHON_PATH = /usr/local/bin/python
270         PERL_PATH = /usr/local/bin/perl
271         HAVE_PATHS_H = YesPlease
272         HAVE_BSD_SYSCTL = YesPlease
273         HAVE_BSD_KERN_PROC_SYSCTL = YesPlease
274         CSPRNG_METHOD = arc4random
275         PAGER_ENV = LESS=FRX LV=-c MORE=FRX
276         FREAD_READS_DIRECTORIES = UnfortunatelyYes
277         FILENO_IS_A_MACRO = UnfortunatelyYes
278 endif
279 ifeq ($(uname_S),OpenBSD)
280         NO_STRCASESTR = YesPlease
281         NO_MEMMEM = YesPlease
282         USE_ST_TIMESPEC = YesPlease
283         NEEDS_LIBICONV = YesPlease
284         BASIC_CFLAGS += -I/usr/local/include
285         BASIC_LDFLAGS += -L/usr/local/lib
286         HAVE_PATHS_H = YesPlease
287         HAVE_BSD_SYSCTL = YesPlease
288         HAVE_BSD_KERN_PROC_SYSCTL = YesPlease
289         CSPRNG_METHOD = arc4random
290         PROCFS_EXECUTABLE_PATH = /proc/curproc/file
291         FREAD_READS_DIRECTORIES = UnfortunatelyYes
292         FILENO_IS_A_MACRO = UnfortunatelyYes
293 endif
294 ifeq ($(uname_S),MirBSD)
295         NO_STRCASESTR = YesPlease
296         NO_MEMMEM = YesPlease
297         USE_ST_TIMESPEC = YesPlease
298         NEEDS_LIBICONV = YesPlease
299         HAVE_PATHS_H = YesPlease
300         HAVE_BSD_SYSCTL = YesPlease
301         CSPRNG_METHOD = arc4random
302 endif
303 ifeq ($(uname_S),NetBSD)
304         ifeq ($(shell expr "$(uname_R)" : '[01]\.'),2)
305                 NEEDS_LIBICONV = YesPlease
306         endif
307         BASIC_CFLAGS += -I/usr/pkg/include
308         BASIC_LDFLAGS += -L/usr/pkg/lib $(CC_LD_DYNPATH)/usr/pkg/lib
309         USE_ST_TIMESPEC = YesPlease
310         HAVE_PATHS_H = YesPlease
311         HAVE_BSD_SYSCTL = YesPlease
312         HAVE_BSD_KERN_PROC_SYSCTL = YesPlease
313         CSPRNG_METHOD = arc4random
314         PROCFS_EXECUTABLE_PATH = /proc/curproc/exe
315 endif
316 ifeq ($(uname_S),AIX)
317         DEFAULT_PAGER = more
318         NO_STRCASESTR = YesPlease
319         NO_MEMMEM = YesPlease
320         NO_MKDTEMP = YesPlease
321         NO_STRLCPY = YesPlease
322         NO_NSEC = YesPlease
323         NO_REGEX = NeedsStartEnd
324         FREAD_READS_DIRECTORIES = UnfortunatelyYes
325         INTERNAL_QSORT = UnfortunatelyYes
326         NEEDS_LIBICONV = YesPlease
327         BASIC_CFLAGS += -D_LARGE_FILES
328         FILENO_IS_A_MACRO = UnfortunatelyYes
329         NEED_ACCESS_ROOT_HANDLER = UnfortunatelyYes
330         ifeq ($(shell expr "$(uname_V)" : '[1234]'),1)
331                 NO_PTHREADS = YesPlease
332         else
333                 PTHREAD_LIBS = -lpthread
334         endif
335         ifeq ($(shell expr "$(uname_V).$(uname_R)" : '5\.1'),3)
336                 INLINE = ''
337         endif
338         GIT_TEST_CMP = cmp
339 endif
340 ifeq ($(uname_S),GNU)
341         # GNU/Hurd
342         HAVE_ALLOCA_H = YesPlease
343         NO_STRLCPY = YesPlease
344         HAVE_PATHS_H = YesPlease
345         LIBC_CONTAINS_LIBINTL = YesPlease
346         FREAD_READS_DIRECTORIES = UnfortunatelyYes
347 endif
348 ifeq ($(uname_S),IRIX)
349         NO_SETENV = YesPlease
350         NO_UNSETENV = YesPlease
351         NO_STRCASESTR = YesPlease
352         NO_MEMMEM = YesPlease
353         NO_MKDTEMP = YesPlease
354         # When compiled with the MIPSpro 7.4.4m compiler, and without pthreads
355         # (i.e. NO_PTHREADS is set), and _with_ MMAP (i.e. NO_MMAP is not set),
356         # git dies with a segmentation fault when trying to access the first
357         # entry of a reflog.  The conservative choice is made to always set
358         # NO_MMAP.  If you suspect that your compiler is not affected by this
359         # issue, comment out the NO_MMAP statement.
360         NO_MMAP = YesPlease
361         NO_REGEX = YesPlease
362         SNPRINTF_RETURNS_BOGUS = YesPlease
363         SHELL_PATH = /usr/gnu/bin/bash
364         NEEDS_LIBGEN = YesPlease
365 endif
366 ifeq ($(uname_S),IRIX64)
367         NO_SETENV = YesPlease
368         NO_UNSETENV = YesPlease
369         NO_STRCASESTR = YesPlease
370         NO_MEMMEM = YesPlease
371         NO_MKDTEMP = YesPlease
372         # When compiled with the MIPSpro 7.4.4m compiler, and without pthreads
373         # (i.e. NO_PTHREADS is set), and _with_ MMAP (i.e. NO_MMAP is not set),
374         # git dies with a segmentation fault when trying to access the first
375         # entry of a reflog.  The conservative choice is made to always set
376         # NO_MMAP.  If you suspect that your compiler is not affected by this
377         # issue, comment out the NO_MMAP statement.
378         NO_MMAP = YesPlease
379         NO_REGEX = YesPlease
380         SNPRINTF_RETURNS_BOGUS = YesPlease
381         SHELL_PATH = /usr/gnu/bin/bash
382         NEEDS_LIBGEN = YesPlease
383 endif
384 ifeq ($(uname_S),HP-UX)
385         INLINE = __inline
386         NO_IPV6 = YesPlease
387         NO_SETENV = YesPlease
388         NO_STRCASESTR = YesPlease
389         NO_MEMMEM = YesPlease
390         NO_STRLCPY = YesPlease
391         NO_MKDTEMP = YesPlease
392         NO_UNSETENV = YesPlease
393         NO_HSTRERROR = YesPlease
394         NO_SYS_SELECT_H = YesPlease
395         SNPRINTF_RETURNS_BOGUS = YesPlease
396         NO_NSEC = YesPlease
397         ifeq ($(uname_R),B.11.00)
398                 NO_INET_NTOP = YesPlease
399                 NO_INET_PTON = YesPlease
400         endif
401         ifeq ($(uname_R),B.10.20)
402                 # Override HP-UX 11.x setting:
403                 INLINE =
404                 SOCKLEN_T = size_t
405                 NO_PREAD = YesPlease
406                 NO_INET_NTOP = YesPlease
407                 NO_INET_PTON = YesPlease
408         endif
409         GIT_TEST_CMP = cmp
410 endif
411 ifeq ($(uname_S),Windows)
412         GIT_VERSION := $(GIT_VERSION).MSVC
413         pathsep = ;
414         # Assume that this is built in Git for Windows' SDK
415         ifeq (MINGW32,$(MSYSTEM))
416                 prefix = /mingw32
417         else
418                 prefix = /mingw64
419         endif
420         # Prepend MSVC 64-bit tool-chain to PATH.
421         #
422         # A regular Git Bash *does not* have cl.exe in its $PATH. As there is a
423         # link.exe next to, and required by, cl.exe, we have to prepend this
424         # onto the existing $PATH.
425         #
426         SANE_TOOL_PATH ?= $(msvc_bin_dir_msys)
427         HAVE_ALLOCA_H = YesPlease
428         NO_PREAD = YesPlease
429         NEEDS_CRYPTO_WITH_SSL = YesPlease
430         NO_LIBGEN_H = YesPlease
431         NO_POLL = YesPlease
432         NO_SYMLINK_HEAD = YesPlease
433         NO_IPV6 = YesPlease
434         NO_UNIX_SOCKETS = YesPlease
435         NO_SETENV = YesPlease
436         NO_STRCASESTR = YesPlease
437         NO_STRLCPY = YesPlease
438         NO_MEMMEM = YesPlease
439         NEEDS_LIBICONV = YesPlease
440         NO_STRTOUMAX = YesPlease
441         NO_MKDTEMP = YesPlease
442         NO_INTTYPES_H = YesPlease
443         CSPRNG_METHOD = rtlgenrandom
444         # VS2015 with UCRT claims that snprintf and friends are C99 compliant,
445         # so we don't need this:
446         #
447         #   SNPRINTF_RETURNS_BOGUS = YesPlease
449         # The builtin FSMonitor requires Named Pipes and Threads on Windows.
450         # These are always available, so we do not have to conditionally
451         # support it.
452         FSMONITOR_DAEMON_BACKEND = win32
453         NO_SVN_TESTS = YesPlease
454         RUNTIME_PREFIX = YesPlease
455         HAVE_WPGMPTR = YesWeDo
456         NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease
457         USE_WIN32_IPC = YesPlease
458         USE_WIN32_MMAP = YesPlease
459         MMAP_PREVENTS_DELETE = UnfortunatelyYes
460         # USE_NED_ALLOCATOR = YesPlease
461         UNRELIABLE_FSTAT = UnfortunatelyYes
462         OBJECT_CREATION_USES_RENAMES = UnfortunatelyNeedsTo
463         NO_REGEX = YesPlease
464         NO_GETTEXT = YesPlease
465         NO_PYTHON = YesPlease
466         ETAGS_TARGET = ETAGS
467         NO_POSIX_GOODIES = UnfortunatelyYes
468         NATIVE_CRLF = YesPlease
469         DEFAULT_HELP_FORMAT = html
470 ifeq (/mingw64,$(subst 32,64,$(prefix)))
471         # Move system config into top-level /etc/
472         ETC_GITCONFIG = ../etc/gitconfig
473         ETC_GITATTRIBUTES = ../etc/gitattributes
474 endif
476         CC = compat/vcbuild/scripts/clink.pl
477         AR = compat/vcbuild/scripts/lib.pl
478         CFLAGS =
479         BASIC_CFLAGS = -nologo -I. -Icompat/vcbuild/include -DWIN32 -D_CONSOLE -DHAVE_STRING_H -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE
480         COMPAT_OBJS = compat/msvc.o compat/winansi.o \
481                 compat/win32/path-utils.o \
482                 compat/win32/pthread.o compat/win32/syslog.o \
483                 compat/win32/trace2_win32_process_info.o \
484                 compat/win32/dirent.o
485         COMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DDETECT_MSYS_TTY -DNOGDI -DHAVE_STRING_H -Icompat -Icompat/regex -Icompat/win32 -DSTRIP_EXTENSION=\".exe\"
486         BASIC_LDFLAGS = -IGNORE:4217 -IGNORE:4049 -NOLOGO -ENTRY:wmainCRTStartup -SUBSYSTEM:CONSOLE
487         # invalidcontinue.obj allows Git's source code to close the same file
488         # handle twice, or to access the osfhandle of an already-closed stdout
489         # See https://msdn.microsoft.com/en-us/library/ms235330.aspx
490         EXTLIBS = user32.lib advapi32.lib shell32.lib wininet.lib ws2_32.lib invalidcontinue.obj kernel32.lib ntdll.lib
491         PTHREAD_LIBS =
492         lib =
493         BASIC_CFLAGS += $(vcpkg_inc) $(sdk_includes) $(msvc_includes)
494 ifndef DEBUG
495         BASIC_CFLAGS += $(vcpkg_rel_lib)
496 else
497         BASIC_CFLAGS += $(vcpkg_dbg_lib)
498 endif
499         BASIC_CFLAGS += $(sdk_libs) $(msvc_libs)
501 ifneq ($(USE_MSVC_CRTDBG),)
502         # Optionally enable memory leak reporting.
503         BASIC_CFLAGS += -DUSE_MSVC_CRTDBG
504 endif
505         # Always give "-Zi" to the compiler and "-debug" to linker (even in
506         # release mode) to force a PDB to be generated (like RelWithDebInfo).
507         BASIC_CFLAGS += -Zi
508         BASIC_LDFLAGS += -debug -Zf
510 ifdef NO_SAFESEH
511         LDFLAGS += -SAFESEH:NO
512 endif
514 ifndef DEBUG
515         BASIC_CFLAGS += -GL -Gy -O2 -Oy- -MD -DNDEBUG
516         BASIC_LDFLAGS += -release -LTCG /OPT:REF /OPT:ICF /INCREMENTAL:NO /DEBUGTYPE:CV,FIXUP
517         AR += -LTCG
518 else
519         BASIC_CFLAGS += -MDd -DDEBUG -D_DEBUG
520 endif
521         X = .exe
523 compat/msvc.o: compat/msvc.c compat/mingw.c GIT-CFLAGS
524 endif
525 ifeq ($(uname_S),Interix)
526         NO_INITGROUPS = YesPlease
527         NO_IPV6 = YesPlease
528         NO_MEMMEM = YesPlease
529         NO_MKDTEMP = YesPlease
530         NO_STRTOUMAX = YesPlease
531         NO_NSEC = YesPlease
532         ifeq ($(uname_R),3.5)
533                 NO_INET_NTOP = YesPlease
534                 NO_INET_PTON = YesPlease
535                 NO_SOCKADDR_STORAGE = YesPlease
536         endif
537         ifeq ($(uname_R),5.2)
538                 NO_INET_NTOP = YesPlease
539                 NO_INET_PTON = YesPlease
540                 NO_SOCKADDR_STORAGE = YesPlease
541         endif
542 endif
543 ifeq ($(uname_S),Minix)
544         NO_IPV6 = YesPlease
545         NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease
546         NO_NSEC = YesPlease
547         NEEDS_LIBGEN =
548         NEEDS_CRYPTO_WITH_SSL = YesPlease
549         NEEDS_RESOLV =
550         NO_HSTRERROR = YesPlease
551         NO_MMAP = YesPlease
552         NO_CURL =
553         NO_EXPAT =
554 endif
555 ifeq ($(uname_S),NONSTOP_KERNEL)
556         # Needs some C99 features, "inline" is just one of them.
557         # INLINE='' would just replace one set of warnings with another and
558         # still not compile in c89 mode, due to non-const array initializations.
559         CC = cc -c99
560         # Build down-rev compatible objects that don't use our new getopt_long.
561         ifeq ($(uname_R).$(uname_V),J06.21)
562                 CC += -WRVU=J06.20
563         endif
564         ifeq ($(uname_R).$(uname_V),L17.02)
565                 CC += -WRVU=L16.05
566         endif
567         # Disable all optimization, seems to result in bad code, with -O or -O2
568         # or even -O1 (default), /usr/local/libexec/git-core/git-pack-objects
569         # abends on "git push". Needs more investigation.
570         CFLAGS = -g -O0 -Winline
571         # We'd want it to be here.
572         prefix = /usr/local
573         # perl and python must be in /usr/bin on NonStop - supplied by HPE
574         # with operating system in that managed directory.
575         PERL_PATH = /usr/bin/perl
576         PYTHON_PATH = /usr/bin/python
577         # The current /usr/coreutils/rm at lowest support level does not work
578         # with the git test structure. Long paths as in
579         # 'trash directory...' cause rm to terminate prematurely without fully
580         # removing the directory at OS releases J06.21 and L17.02.
581         # Default to the older rm until those two releases are deprecated.
582         RM = /bin/rm -f
583         NEEDS_CRYPTO_WITH_SSL = YesPlease
584         HAVE_DEV_TTY = YesPlease
585         HAVE_LIBCHARSET_H = YesPlease
586         HAVE_STRINGS_H = YesPlease
587         NEEDS_LIBICONV = YesPlease
588         NEEDS_LIBINTL_BEFORE_LIBICONV = YesPlease
589         NO_SYS_SELECT_H = UnfortunatelyYes
590         NO_D_TYPE_IN_DIRENT = YesPlease
591         NO_GETTEXT = YesPlease
592         NO_HSTRERROR = YesPlease
593         NO_STRCASESTR = YesPlease
594         NO_MEMMEM = YesPlease
595         NO_STRLCPY = YesPlease
596         NO_SETENV = YesPlease
597         NO_UNSETENV = YesPlease
598         NO_MKDTEMP = YesPlease
599         # Currently libiconv-1.9.1.
600         OLD_ICONV = UnfortunatelyYes
601         NO_REGEX = NeedsStartEnd
602         NO_PTHREADS = UnfortunatelyYes
603         FREAD_READS_DIRECTORIES = UnfortunatelyYes
605         # Not detected (nor checked for) by './configure'.
606         # We don't have SA_RESTART on NonStop, unfortunalety.
607         COMPAT_CFLAGS += -DSA_RESTART=0
608         # Apparently needed in compat/fnmatch/fnmatch.c.
609         COMPAT_CFLAGS += -DHAVE_STRING_H=1
610         NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease
611         NO_NSEC = YesPlease
612         NO_PREAD = YesPlease
613         NO_MMAP = YesPlease
614         NO_POLL = YesPlease
615         NO_INTPTR_T = UnfortunatelyYes
616         CSPRNG_METHOD = openssl
617         SANE_TOOL_PATH = /usr/coreutils/bin:/usr/local/bin
618         SHELL_PATH = /usr/coreutils/bin/bash
619 endif
620 ifeq ($(uname_S),MINGW)
621         pathsep = ;
622         HAVE_ALLOCA_H = YesPlease
623         NO_PREAD = YesPlease
624         NEEDS_CRYPTO_WITH_SSL = YesPlease
625         NO_LIBGEN_H = YesPlease
626         NO_POLL = YesPlease
627         NO_SYMLINK_HEAD = YesPlease
628         NO_UNIX_SOCKETS = YesPlease
629         NO_SETENV = YesPlease
630         NO_STRCASESTR = YesPlease
631         NO_STRLCPY = YesPlease
632         NO_MEMMEM = YesPlease
633         NEEDS_LIBICONV = YesPlease
634         NO_STRTOUMAX = YesPlease
635         NO_MKDTEMP = YesPlease
636         NO_SVN_TESTS = YesPlease
638         # The builtin FSMonitor requires Named Pipes and Threads on Windows.
639         # These are always available, so we do not have to conditionally
640         # support it.
641         FSMONITOR_DAEMON_BACKEND = win32
642         RUNTIME_PREFIX = YesPlease
643         HAVE_WPGMPTR = YesWeDo
644         NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease
645         USE_WIN32_IPC = YesPlease
646         USE_WIN32_MMAP = YesPlease
647         MMAP_PREVENTS_DELETE = UnfortunatelyYes
648         USE_NED_ALLOCATOR = YesPlease
649         UNRELIABLE_FSTAT = UnfortunatelyYes
650         OBJECT_CREATION_USES_RENAMES = UnfortunatelyNeedsTo
651         NO_REGEX = YesPlease
652         NO_PYTHON = YesPlease
653         ETAGS_TARGET = ETAGS
654         NO_POSIX_GOODIES = UnfortunatelyYes
655         DEFAULT_HELP_FORMAT = html
656         HAVE_PLATFORM_PROCINFO = YesPlease
657         CSPRNG_METHOD = rtlgenrandom
658         BASIC_LDFLAGS += -municode
659         COMPAT_CFLAGS += -DNOGDI -Icompat -Icompat/win32
660         COMPAT_CFLAGS += -DSTRIP_EXTENSION=\".exe\"
661         COMPAT_OBJS += compat/mingw.o compat/winansi.o \
662                 compat/win32/trace2_win32_process_info.o \
663                 compat/win32/path-utils.o \
664                 compat/win32/pthread.o compat/win32/syslog.o \
665                 compat/win32/dirent.o
666         BASIC_CFLAGS += -DWIN32
667         EXTLIBS += -lws2_32
668         GITLIBS += git.res
669         PTHREAD_LIBS =
670         RC = windres -O coff
671         NATIVE_CRLF = YesPlease
672         X = .exe
673 ifneq (,$(wildcard ../THIS_IS_MSYSGIT))
674         htmldir = doc/git/html/
675         prefix =
676         INSTALL = /bin/install
677         EXTLIBS += /mingw/lib/libz.a
678         INTERNAL_QSORT = YesPlease
679         HAVE_LIBCHARSET_H = YesPlease
680         NO_GETTEXT = YesPlease
681         COMPAT_CFLAGS += -D__USE_MINGW_ACCESS
682 else
683         ifneq ($(shell expr "$(uname_R)" : '1\.'),2)
684                 # MSys2
685                 prefix = /usr/
686                 # Enable DEP
687                 BASIC_LDFLAGS += -Wl,--nxcompat
688                 # Enable ASLR (unless debugging)
689                 ifneq (,$(findstring -O,$(filter-out -O0 -Og,$(CFLAGS))))
690                         BASIC_LDFLAGS += -Wl,--dynamicbase
691                 endif
692                 ifeq (MINGW32,$(MSYSTEM))
693                         prefix = /mingw32
694                         HOST_CPU = i686
695                         BASIC_LDFLAGS += -Wl,--pic-executable,-e,_mainCRTStartup
696                 endif
697                 ifeq (MINGW64,$(MSYSTEM))
698                         prefix = /mingw64
699                         HOST_CPU = x86_64
700                         BASIC_LDFLAGS += -Wl,--pic-executable,-e,mainCRTStartup
701                 else
702                         COMPAT_CFLAGS += -D_USE_32BIT_TIME_T
703                         BASIC_LDFLAGS += -Wl,--large-address-aware
704                 endif
705                 CC = gcc
706                 COMPAT_CFLAGS += -D__USE_MINGW_ANSI_STDIO=0 -DDETECT_MSYS_TTY \
707                         -fstack-protector-strong
708                 EXTLIBS += -lntdll
709                 INSTALL = /bin/install
710                 INTERNAL_QSORT = YesPlease
711                 HAVE_LIBCHARSET_H = YesPlease
712                 NO_GETTEXT =
713                 USE_GETTEXT_SCHEME = fallthrough
714                 USE_LIBPCRE = YesPlease
715                 NO_CURL =
716                 USE_NED_ALLOCATOR = YesPlease
717                 ifeq (/mingw64,$(subst 32,64,$(prefix)))
718                         # Move system config into top-level /etc/
719                         ETC_GITCONFIG = ../etc/gitconfig
720                         ETC_GITATTRIBUTES = ../etc/gitattributes
721                 endif
722         else
723                 COMPAT_CFLAGS += -D__USE_MINGW_ANSI_STDIO
724                 NO_CURL = YesPlease
725         endif
726 endif
727 endif
728 ifeq ($(uname_S),QNX)
729         COMPAT_CFLAGS += -DSA_RESTART=0
730         EXPAT_NEEDS_XMLPARSE_H = YesPlease
731         HAVE_STRINGS_H = YesPlease
732         NEEDS_SOCKET = YesPlease
733         NO_GETPAGESIZE = YesPlease
734         NO_ICONV = YesPlease
735         NO_MEMMEM = YesPlease
736         NO_MKDTEMP = YesPlease
737         NO_NSEC = YesPlease
738         NO_PTHREADS = YesPlease
739         NO_STRCASESTR = YesPlease
740         NO_STRLCPY = YesPlease
741 endif
743 vcxproj:
744         # Require clean work tree
745         git update-index -q --refresh && \
746         git diff-files --quiet && \
747         git diff-index --cached --quiet HEAD --
749         # Make .vcxproj files and add them
750         unset QUIET_GEN QUIET_BUILT_IN; \
751         perl contrib/buildsystems/generate -g Vcxproj
752         git add -f git.sln {*,*/lib,t/helper/*}/*.vcxproj
754         # Generate the LinkOrCopyBuiltins.targets and LinkOrCopyRemoteHttp.targets file
755         (echo '<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">' && \
756          echo '  <Target Name="CopyBuiltins_AfterBuild" AfterTargets="AfterBuild">' && \
757          for name in $(BUILT_INS);\
758          do \
759            echo '    <Copy SourceFiles="$$(OutDir)\git.exe" DestinationFiles="$$(OutDir)\'"$$name"'" SkipUnchangedFiles="true" UseHardlinksIfPossible="true" />'; \
760          done && \
761          echo '  </Target>' && \
762          echo '</Project>') >git/LinkOrCopyBuiltins.targets
763         (echo '<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">' && \
764          echo '  <Target Name="CopyBuiltins_AfterBuild" AfterTargets="AfterBuild">' && \
765          for name in $(REMOTE_CURL_ALIASES); \
766          do \
767            echo '    <Copy SourceFiles="$$(OutDir)\'"$(REMOTE_CURL_PRIMARY)"'" DestinationFiles="$$(OutDir)\'"$$name"'" SkipUnchangedFiles="true" UseHardlinksIfPossible="true" />'; \
768          done && \
769          echo '  </Target>' && \
770          echo '</Project>') >git-remote-http/LinkOrCopyRemoteHttp.targets
771         git add -f git/LinkOrCopyBuiltins.targets git-remote-http/LinkOrCopyRemoteHttp.targets
773         # Add generated headers
774         $(MAKE) MSVC=1 SKIP_VCPKG=1 prefix=/mingw64 $(GENERATED_H)
775         git add -f $(GENERATED_H)
777         # Add scripts
778         rm -f perl/perl.mak
779         $(MAKE) MSVC=1 SKIP_VCPKG=1 prefix=/mingw64 $(SCRIPT_LIB) $(SCRIPTS)
780         # Strip out the sane tool path, needed only for building
781         sed -i '/^git_broken_path_fix ".*/d' git-sh-setup
782         git add -f $(SCRIPT_LIB) $(SCRIPTS)
784         # Add Perl module
785         $(MAKE) $(LIB_PERL_GEN)
786         git add -f perl/build
788         # Add bin-wrappers, for testing
789         rm -rf bin-wrappers/
790         $(MAKE) MSVC=1 SKIP_VCPKG=1 prefix=/mingw64 $(test_bindir_programs)
791         # Ensure that the GIT_EXEC_PATH is a Unix-y one, and that the absolute
792         # path of the repository is not hard-coded (GIT_EXEC_PATH will be set
793         # by test-lib.sh according to the current setup)
794         sed -i -e 's/^\(GIT_EXEC_PATH\)=.*/test -n "$${\1##*:*}" ||\
795                         \1="$$(cygpath -u "$$\1")"/' \
796                 -e "s|'$$(pwd)|\"\$$GIT_EXEC_PATH\"'|g" bin-wrappers/*
797         # Ensure that test-* helpers find the .dll files copied to top-level
798         sed -i 's|^PATH=.*|&:"$$GIT_EXEC_PATH"|' bin-wrappers/test-*
799         # We do not want to force hard-linking builtins
800         sed -i 's|\(git\)-\([-a-z]*\)\.exe"|\1.exe" \2|g' \
801                 bin-wrappers/git-{receive-pack,upload-archive}
802         git add -f $(test_bindir_programs)
803         # remote-ext is a builtin, but invoked as if it were external
804         sed 's|receive-pack|remote-ext|g' \
805                 <bin-wrappers/git-receive-pack >bin-wrappers/git-remote-ext
806         git add -f bin-wrappers/git-remote-ext
808         # Add templates
809         $(MAKE) -C templates
810         git add -f templates/boilerplates.made templates/blt/
812         # Add the translated messages
813         make MSVC=1 SKIP_VCPKG=1 prefix=/mingw64 $(MOFILES)
814         git add -f $(MOFILES)
816         # Add build options
817         $(MAKE) MSVC=1 SKIP_VCPKG=1 prefix=/mingw64 GIT-BUILD-OPTIONS
818         git add -f GIT-BUILD-OPTIONS
820         # Commit the whole shebang
821         git commit -m "Generate Visual Studio solution" \
822                 -m "Auto-generated by \`$(MAKE)$(MAKEFLAGS) $@\`"