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