git
/
config.mak.uname
839 строк · 26.5 Кб
1# Platform specific Makefile tweaks based on uname detection
2
3# Define NO_SAFESEH if you need MSVC/Visual Studio to ignore the lack of
4# Microsoft's Safe Exception Handling in libraries (such as zlib).
5# Typically required for VS2013+/32-bit compilation on Vista+ versions.
6
7uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
8uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not')
9uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')
10uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not')
11uname_V := $(shell sh -c 'uname -v 2>/dev/null || echo not')
12
13ifneq ($(findstring MINGW,$(uname_S)),)
14uname_S := MINGW
15endif
16
17ifdef MSVC
18# avoid the MingW and Cygwin configuration sections
19uname_S := Windows
20uname_O := Windows
21
22# Generate and include makefile variables that point to the
23# currently installed set of MSVC command line tools.
24compat/vcbuild/MSVC-DEFS-GEN: compat/vcbuild/find_vs_env.bat
25@"$<" | tr '\\' / >"$@"
26include compat/vcbuild/MSVC-DEFS-GEN
27
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.
31ifeq (,$(SKIP_VCPKG))
32compat/vcbuild/VCPKG-DEFS: compat/vcbuild/vcpkg_install.bat
33@"$<"
34include compat/vcbuild/VCPKG-DEFS
35endif
36endif
37
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...
41
42ifeq ($(uname_S),OSF1)
43# Need this for u_short definitions et al
44BASIC_CFLAGS += -D_OSF_SOURCE
45SOCKLEN_T = int
46NO_STRTOULL = YesPlease
47NO_NSEC = YesPlease
48endif
49ifeq ($(uname_S),Linux)
50HAVE_ALLOCA_H = YesPlease
51NO_STRLCPY = YesPlease
52HAVE_PATHS_H = YesPlease
53LIBC_CONTAINS_LIBINTL = YesPlease
54HAVE_DEV_TTY = YesPlease
55HAVE_CLOCK_GETTIME = YesPlease
56HAVE_CLOCK_MONOTONIC = YesPlease
57# -lrt is needed for clock_gettime on glibc <= 2.16
58NEEDS_LIBRT = YesPlease
59HAVE_SYNC_FILE_RANGE = YesPlease
60HAVE_GETDELIM = YesPlease
61FREAD_READS_DIRECTORIES = UnfortunatelyYes
62BASIC_CFLAGS += -DHAVE_SYSINFO
63PROCFS_EXECUTABLE_PATH = /proc/self/exe
64HAVE_PLATFORM_PROCINFO = YesPlease
65COMPAT_OBJS += compat/linux/procinfo.o
66# centos7/rhel7 provides gcc 4.8.5 and zlib 1.2.7.
67ifneq ($(findstring .el7.,$(uname_R)),)
68BASIC_CFLAGS += -std=c99
69endif
70LINK_FUZZ_PROGRAMS = YesPlease
71endif
72ifeq ($(uname_S),GNU/kFreeBSD)
73HAVE_ALLOCA_H = YesPlease
74NO_STRLCPY = YesPlease
75HAVE_PATHS_H = YesPlease
76DIR_HAS_BSD_GROUP_SEMANTICS = YesPlease
77LIBC_CONTAINS_LIBINTL = YesPlease
78FREAD_READS_DIRECTORIES = UnfortunatelyYes
79endif
80ifeq ($(uname_S),UnixWare)
81CC = cc
82NEEDS_SOCKET = YesPlease
83NEEDS_NSL = YesPlease
84NEEDS_SSL_WITH_CRYPTO = YesPlease
85NEEDS_LIBICONV = YesPlease
86SHELL_PATH = /usr/local/bin/bash
87NO_IPV6 = YesPlease
88NO_HSTRERROR = YesPlease
89BASIC_CFLAGS += -Kthread
90BASIC_CFLAGS += -I/usr/local/include
91BASIC_LDFLAGS += -L/usr/local/lib
92INSTALL = ginstall
93TAR = gtar
94NO_STRCASESTR = YesPlease
95NO_MEMMEM = YesPlease
96endif
97ifeq ($(uname_S),SCO_SV)
98ifeq ($(uname_R),3.2)
99CFLAGS = -O2
100endif
101ifeq ($(uname_R),5)
102CC = cc
103BASIC_CFLAGS += -Kthread
104endif
105NEEDS_SOCKET = YesPlease
106NEEDS_NSL = YesPlease
107NEEDS_SSL_WITH_CRYPTO = YesPlease
108NEEDS_LIBICONV = YesPlease
109SHELL_PATH = /usr/bin/bash
110NO_IPV6 = YesPlease
111NO_HSTRERROR = YesPlease
112BASIC_CFLAGS += -I/usr/local/include
113BASIC_LDFLAGS += -L/usr/local/lib
114NO_STRCASESTR = YesPlease
115NO_MEMMEM = YesPlease
116INSTALL = ginstall
117TAR = gtar
118endif
119ifeq ($(uname_S),Darwin)
120NEEDS_CRYPTO_WITH_SSL = YesPlease
121NEEDS_SSL_WITH_CRYPTO = YesPlease
122NEEDS_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".
127ifeq ($(shell expr "$(uname_R)" : '[15678]\.'),2)
128OLD_ICONV = UnfortunatelyYes
129NO_APPLE_COMMON_CRYPTO = YesPlease
130endif
131ifeq ($(shell expr "$(uname_R)" : '[15]\.'),2)
132NO_STRLCPY = YesPlease
133endif
134ifeq ($(shell test "`expr "$(uname_R)" : '\([0-9][0-9]*\)\.'`" -ge 11 && echo 1),1)
135HAVE_GETDELIM = YesPlease
136endif
137ifeq ($(shell test "`expr "$(uname_R)" : '\([0-9][0-9]*\)\.'`" -ge 20 && echo 1),1)
138OPEN_RETURNS_EINTR = UnfortunatelyYes
139endif
140NO_MEMMEM = YesPlease
141USE_ST_TIMESPEC = YesPlease
142HAVE_DEV_TTY = YesPlease
143COMPAT_OBJS += compat/precompose_utf8.o
144BASIC_CFLAGS += -DPRECOMPOSE_UNICODE
145BASIC_CFLAGS += -DPROTECT_HFS_DEFAULT=1
146HAVE_BSD_SYSCTL = YesPlease
147FREAD_READS_DIRECTORIES = UnfortunatelyYes
148HAVE_NS_GET_EXECUTABLE_PATH = YesPlease
149CSPRNG_METHOD = arc4random
150USE_ENHANCED_BASIC_REGULAR_EXPRESSIONS = YesPlease
151
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
155ifeq ($(shell test -d /usr/local/opt/gettext/ && echo y),y)
156BASIC_CFLAGS += -I/usr/local/include -I/usr/local/opt/gettext/include
157BASIC_LDFLAGS += -L/usr/local/lib -L/usr/local/opt/gettext/lib
158ifeq ($(shell test -x /usr/local/opt/gettext/bin/msgfmt && echo y),y)
159MSGFMT = /usr/local/opt/gettext/bin/msgfmt
160endif
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.
168else ifeq ($(shell test -d /opt/homebrew/ && echo y),y)
169BASIC_CFLAGS += -I/opt/homebrew/include
170BASIC_LDFLAGS += -L/opt/homebrew/lib
171ifeq ($(shell test -x /opt/homebrew/bin/msgfmt && echo y),y)
172MSGFMT = /opt/homebrew/bin/msgfmt
173endif
174endif
175
176# The builtin FSMonitor on MacOS builds upon Simple-IPC. Both require
177# Unix domain sockets and PThreads.
178ifndef NO_PTHREADS
179ifndef NO_UNIX_SOCKETS
180FSMONITOR_DAEMON_BACKEND = darwin
181FSMONITOR_OS_SETTINGS = darwin
182endif
183endif
184
185BASIC_LDFLAGS += -framework CoreServices
186endif
187ifeq ($(uname_S),SunOS)
188NEEDS_SOCKET = YesPlease
189NEEDS_NSL = YesPlease
190SHELL_PATH = /bin/bash
191SANE_TOOL_PATH = /usr/xpg6/bin:/usr/xpg4/bin
192HAVE_ALLOCA_H = YesPlease
193NO_STRCASESTR = YesPlease
194NO_MEMMEM = YesPlease
195NO_MKDTEMP = YesPlease
196NO_REGEX = YesPlease
197NO_MSGFMT_EXTENDED_OPTIONS = YesPlease
198HAVE_DEV_TTY = YesPlease
199ifeq ($(uname_R),5.6)
200SOCKLEN_T = int
201NO_HSTRERROR = YesPlease
202NO_IPV6 = YesPlease
203NO_SOCKADDR_STORAGE = YesPlease
204NO_UNSETENV = YesPlease
205NO_SETENV = YesPlease
206NO_STRLCPY = YesPlease
207NO_STRTOUMAX = YesPlease
208GIT_TEST_CMP = cmp
209endif
210ifeq ($(uname_R),5.7)
211NEEDS_RESOLV = YesPlease
212NO_IPV6 = YesPlease
213NO_SOCKADDR_STORAGE = YesPlease
214NO_UNSETENV = YesPlease
215NO_SETENV = YesPlease
216NO_STRLCPY = YesPlease
217NO_STRTOUMAX = YesPlease
218GIT_TEST_CMP = cmp
219endif
220ifeq ($(uname_R),5.8)
221NO_UNSETENV = YesPlease
222NO_SETENV = YesPlease
223NO_STRTOUMAX = YesPlease
224GIT_TEST_CMP = cmp
225endif
226ifeq ($(uname_R),5.9)
227NO_UNSETENV = YesPlease
228NO_SETENV = YesPlease
229NO_STRTOUMAX = YesPlease
230GIT_TEST_CMP = cmp
231endif
232INSTALL = /usr/ucb/install
233TAR = gtar
234BASIC_CFLAGS += -D__EXTENSIONS__ -D__sun__
235endif
236ifeq ($(uname_O),Cygwin)
237ifeq ($(shell expr "$(uname_R)" : '1\.[1-6]\.'),4)
238NO_D_TYPE_IN_DIRENT = YesPlease
239NO_STRCASESTR = YesPlease
240NO_MEMMEM = YesPlease
241NO_SYMLINK_HEAD = YesPlease
242NO_IPV6 = YesPlease
243OLD_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
247NO_MMAP = YesPlease
248else
249NO_REGEX = UnfortunatelyYes
250endif
251HAVE_ALLOCA_H = YesPlease
252NEEDS_LIBICONV = YesPlease
253NO_FAST_WORKING_DIRECTORY = UnfortunatelyYes
254NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease
255X = .exe
256UNRELIABLE_FSTAT = UnfortunatelyYes
257OBJECT_CREATION_USES_RENAMES = UnfortunatelyNeedsTo
258MMAP_PREVENTS_DELETE = UnfortunatelyYes
259COMPAT_OBJS += compat/win32/path-utils.o
260FREAD_READS_DIRECTORIES = UnfortunatelyYes
261endif
262ifeq ($(uname_S),FreeBSD)
263NEEDS_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".
266ifeq ($(shell expr "$(uname_R)" : '[1-9]\.'),2)
267OLD_ICONV = YesPlease
268endif
269ifeq ($(firstword $(subst -, ,$(uname_R))),10.0)
270OLD_ICONV = YesPlease
271endif
272ifeq ($(firstword $(subst -, ,$(uname_R))),10.1)
273OLD_ICONV = YesPlease
274endif
275NO_MEMMEM = YesPlease
276BASIC_CFLAGS += -I/usr/local/include
277BASIC_LDFLAGS += -L/usr/local/lib
278DIR_HAS_BSD_GROUP_SEMANTICS = YesPlease
279USE_ST_TIMESPEC = YesPlease
280ifeq ($(shell expr "$(uname_R)" : '4\.'),2)
281PTHREAD_LIBS = -pthread
282NO_UINTMAX_T = YesPlease
283NO_STRTOUMAX = YesPlease
284endif
285PYTHON_PATH = /usr/local/bin/python
286PERL_PATH = /usr/local/bin/perl
287HAVE_PATHS_H = YesPlease
288HAVE_BSD_SYSCTL = YesPlease
289HAVE_BSD_KERN_PROC_SYSCTL = YesPlease
290CSPRNG_METHOD = arc4random
291PAGER_ENV = LESS=FRX LV=-c MORE=FRX
292FREAD_READS_DIRECTORIES = UnfortunatelyYes
293FILENO_IS_A_MACRO = UnfortunatelyYes
294endif
295ifeq ($(uname_S),OpenBSD)
296NO_STRCASESTR = YesPlease
297NO_MEMMEM = YesPlease
298USE_ST_TIMESPEC = YesPlease
299NEEDS_LIBICONV = YesPlease
300BASIC_CFLAGS += -I/usr/local/include
301BASIC_LDFLAGS += -L/usr/local/lib
302HAVE_PATHS_H = YesPlease
303HAVE_BSD_SYSCTL = YesPlease
304HAVE_BSD_KERN_PROC_SYSCTL = YesPlease
305CSPRNG_METHOD = arc4random
306PROCFS_EXECUTABLE_PATH = /proc/curproc/file
307FREAD_READS_DIRECTORIES = UnfortunatelyYes
308FILENO_IS_A_MACRO = UnfortunatelyYes
309endif
310ifeq ($(uname_S),MirBSD)
311NO_STRCASESTR = YesPlease
312NO_MEMMEM = YesPlease
313USE_ST_TIMESPEC = YesPlease
314NEEDS_LIBICONV = YesPlease
315HAVE_PATHS_H = YesPlease
316HAVE_BSD_SYSCTL = YesPlease
317CSPRNG_METHOD = arc4random
318endif
319ifeq ($(uname_S),NetBSD)
320ifeq ($(shell expr "$(uname_R)" : '[01]\.'),2)
321NEEDS_LIBICONV = YesPlease
322endif
323BASIC_CFLAGS += -I/usr/pkg/include
324BASIC_LDFLAGS += -L/usr/pkg/lib $(CC_LD_DYNPATH)/usr/pkg/lib
325USE_ST_TIMESPEC = YesPlease
326HAVE_PATHS_H = YesPlease
327HAVE_BSD_SYSCTL = YesPlease
328HAVE_BSD_KERN_PROC_SYSCTL = YesPlease
329CSPRNG_METHOD = arc4random
330PROCFS_EXECUTABLE_PATH = /proc/curproc/exe
331endif
332ifeq ($(uname_S),AIX)
333DEFAULT_PAGER = more
334NO_STRCASESTR = YesPlease
335NO_MEMMEM = YesPlease
336NO_MKDTEMP = YesPlease
337NO_STRLCPY = YesPlease
338NO_NSEC = YesPlease
339NO_REGEX = NeedsStartEnd
340FREAD_READS_DIRECTORIES = UnfortunatelyYes
341INTERNAL_QSORT = UnfortunatelyYes
342NEEDS_LIBICONV = YesPlease
343BASIC_CFLAGS += -D_LARGE_FILES
344FILENO_IS_A_MACRO = UnfortunatelyYes
345NEED_ACCESS_ROOT_HANDLER = UnfortunatelyYes
346ifeq ($(shell expr "$(uname_V)" : '[1234]'),1)
347NO_PTHREADS = YesPlease
348else
349PTHREAD_LIBS = -lpthread
350endif
351ifeq ($(shell expr "$(uname_V).$(uname_R)" : '5\.1'),3)
352INLINE = ''
353endif
354GIT_TEST_CMP = cmp
355endif
356ifeq ($(uname_S),GNU)
357# GNU/Hurd
358HAVE_ALLOCA_H = YesPlease
359NO_STRLCPY = YesPlease
360HAVE_PATHS_H = YesPlease
361LIBC_CONTAINS_LIBINTL = YesPlease
362FREAD_READS_DIRECTORIES = UnfortunatelyYes
363endif
364ifeq ($(uname_S),IRIX)
365NO_SETENV = YesPlease
366NO_UNSETENV = YesPlease
367NO_STRCASESTR = YesPlease
368NO_MEMMEM = YesPlease
369NO_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.
376NO_MMAP = YesPlease
377NO_REGEX = YesPlease
378SNPRINTF_RETURNS_BOGUS = YesPlease
379SHELL_PATH = /usr/gnu/bin/bash
380NEEDS_LIBGEN = YesPlease
381endif
382ifeq ($(uname_S),IRIX64)
383NO_SETENV = YesPlease
384NO_UNSETENV = YesPlease
385NO_STRCASESTR = YesPlease
386NO_MEMMEM = YesPlease
387NO_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.
394NO_MMAP = YesPlease
395NO_REGEX = YesPlease
396SNPRINTF_RETURNS_BOGUS = YesPlease
397SHELL_PATH = /usr/gnu/bin/bash
398NEEDS_LIBGEN = YesPlease
399endif
400ifeq ($(uname_S),HP-UX)
401INLINE = __inline
402NO_IPV6 = YesPlease
403NO_SETENV = YesPlease
404NO_STRCASESTR = YesPlease
405NO_MEMMEM = YesPlease
406NO_STRLCPY = YesPlease
407NO_MKDTEMP = YesPlease
408NO_UNSETENV = YesPlease
409NO_HSTRERROR = YesPlease
410NO_SYS_SELECT_H = YesPlease
411SNPRINTF_RETURNS_BOGUS = YesPlease
412NO_NSEC = YesPlease
413ifeq ($(uname_R),B.11.00)
414NO_INET_NTOP = YesPlease
415NO_INET_PTON = YesPlease
416endif
417ifeq ($(uname_R),B.10.20)
418# Override HP-UX 11.x setting:
419INLINE =
420SOCKLEN_T = size_t
421NO_PREAD = YesPlease
422NO_INET_NTOP = YesPlease
423NO_INET_PTON = YesPlease
424endif
425GIT_TEST_CMP = cmp
426endif
427ifeq ($(uname_S),Windows)
428GIT_VERSION := $(GIT_VERSION).MSVC
429pathsep = ;
430# Assume that this is built in Git for Windows' SDK
431ifeq (MINGW32,$(MSYSTEM))
432prefix = /mingw32
433else
434prefix = /mingw64
435endif
436# Prepend MSVC 64-bit tool-chain to PATH.
437#
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.
441#
442SANE_TOOL_PATH ?= $(msvc_bin_dir_msys)
443HAVE_ALLOCA_H = YesPlease
444NO_PREAD = YesPlease
445NEEDS_CRYPTO_WITH_SSL = YesPlease
446NO_LIBGEN_H = YesPlease
447NO_POLL = YesPlease
448NO_SYMLINK_HEAD = YesPlease
449NO_IPV6 = YesPlease
450NO_SETENV = YesPlease
451NO_STRCASESTR = YesPlease
452NO_STRLCPY = YesPlease
453NO_MEMMEM = YesPlease
454NEEDS_LIBICONV = YesPlease
455NO_STRTOUMAX = YesPlease
456NO_MKDTEMP = YesPlease
457NO_INTTYPES_H = YesPlease
458CSPRNG_METHOD = rtlgenrandom
459# VS2015 with UCRT claims that snprintf and friends are C99 compliant,
460# so we don't need this:
461#
462# SNPRINTF_RETURNS_BOGUS = YesPlease
463
464# The builtin FSMonitor requires Named Pipes and Threads on Windows.
465# These are always available, so we do not have to conditionally
466# support it.
467FSMONITOR_DAEMON_BACKEND = win32
468FSMONITOR_OS_SETTINGS = win32
469
470NO_SVN_TESTS = YesPlease
471RUNTIME_PREFIX = YesPlease
472HAVE_WPGMPTR = YesWeDo
473NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease
474USE_WIN32_IPC = YesPlease
475USE_WIN32_MMAP = YesPlease
476MMAP_PREVENTS_DELETE = UnfortunatelyYes
477# USE_NED_ALLOCATOR = YesPlease
478UNRELIABLE_FSTAT = UnfortunatelyYes
479OBJECT_CREATION_USES_RENAMES = UnfortunatelyNeedsTo
480NO_REGEX = YesPlease
481NO_GETTEXT = YesPlease
482NO_PYTHON = YesPlease
483ETAGS_TARGET = ETAGS
484NO_POSIX_GOODIES = UnfortunatelyYes
485NATIVE_CRLF = YesPlease
486DEFAULT_HELP_FORMAT = html
487ifeq (/mingw64,$(subst 32,64,$(prefix)))
488# Move system config into top-level /etc/
489ETC_GITCONFIG = ../etc/gitconfig
490ETC_GITATTRIBUTES = ../etc/gitattributes
491endif
492
493CC = compat/vcbuild/scripts/clink.pl
494AR = compat/vcbuild/scripts/lib.pl
495CFLAGS =
496BASIC_CFLAGS = -nologo -I. -Icompat/vcbuild/include -DWIN32 -D_CONSOLE -DHAVE_STRING_H -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE
497COMPAT_OBJS = compat/msvc.o compat/winansi.o \
498compat/win32/flush.o \
499compat/win32/path-utils.o \
500compat/win32/pthread.o compat/win32/syslog.o \
501compat/win32/trace2_win32_process_info.o \
502compat/win32/dirent.o
503COMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DDETECT_MSYS_TTY -DNOGDI -DHAVE_STRING_H -Icompat -Icompat/regex -Icompat/win32 -DSTRIP_EXTENSION=\".exe\"
504BASIC_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
508EXTLIBS = user32.lib advapi32.lib shell32.lib wininet.lib ws2_32.lib invalidcontinue.obj kernel32.lib ntdll.lib
509PTHREAD_LIBS =
510lib =
511BASIC_CFLAGS += $(vcpkg_inc) $(sdk_includes) $(msvc_includes)
512ifndef DEBUG
513BASIC_CFLAGS += $(vcpkg_rel_lib)
514else
515BASIC_CFLAGS += $(vcpkg_dbg_lib)
516endif
517BASIC_CFLAGS += $(sdk_libs) $(msvc_libs)
518
519ifneq ($(USE_MSVC_CRTDBG),)
520# Optionally enable memory leak reporting.
521BASIC_CFLAGS += -DUSE_MSVC_CRTDBG
522endif
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).
525BASIC_CFLAGS += -Zi
526BASIC_LDFLAGS += -debug -Zf
527
528ifdef NO_SAFESEH
529LDFLAGS += -SAFESEH:NO
530endif
531
532ifndef DEBUG
533BASIC_CFLAGS += -GL -Gy -O2 -Oy- -MD -DNDEBUG
534BASIC_LDFLAGS += -release -LTCG /OPT:REF /OPT:ICF /INCREMENTAL:NO /DEBUGTYPE:CV,FIXUP
535AR += -LTCG
536else
537BASIC_CFLAGS += -MDd -DDEBUG -D_DEBUG
538endif
539X = .exe
540
541EXTRA_PROGRAMS += headless-git$X
542
543compat/msvc.o: compat/msvc.c compat/mingw.c GIT-CFLAGS
544endif
545ifeq ($(uname_S),Interix)
546NO_INITGROUPS = YesPlease
547NO_IPV6 = YesPlease
548NO_MEMMEM = YesPlease
549NO_MKDTEMP = YesPlease
550NO_STRTOUMAX = YesPlease
551NO_NSEC = YesPlease
552ifeq ($(uname_R),3.5)
553NO_INET_NTOP = YesPlease
554NO_INET_PTON = YesPlease
555NO_SOCKADDR_STORAGE = YesPlease
556endif
557ifeq ($(uname_R),5.2)
558NO_INET_NTOP = YesPlease
559NO_INET_PTON = YesPlease
560NO_SOCKADDR_STORAGE = YesPlease
561endif
562endif
563ifeq ($(uname_S),Minix)
564NO_IPV6 = YesPlease
565NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease
566NO_NSEC = YesPlease
567NEEDS_LIBGEN =
568NEEDS_CRYPTO_WITH_SSL = YesPlease
569NEEDS_RESOLV =
570NO_HSTRERROR = YesPlease
571NO_MMAP = YesPlease
572NO_CURL =
573NO_EXPAT =
574endif
575ifeq ($(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.
579CC = cc -c99
580# Build down-rev compatible objects that don't use our new getopt_long.
581ifeq ($(uname_R).$(uname_V),J06.21)
582CC += -WRVU=J06.20
583endif
584ifeq ($(uname_R).$(uname_V),L17.02)
585CC += -WRVU=L16.05
586endif
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.
590CFLAGS = -g -O0 -Winline
591# We'd want it to be here.
592prefix = /usr/local
593# perl and python must be in /usr/bin on NonStop - supplied by HPE
594# with operating system in that managed directory.
595PERL_PATH = /usr/bin/perl
596PYTHON_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.
602RM = /bin/rm -f
603NEEDS_CRYPTO_WITH_SSL = YesPlease
604HAVE_DEV_TTY = YesPlease
605HAVE_LIBCHARSET_H = YesPlease
606HAVE_STRINGS_H = YesPlease
607NEEDS_LIBICONV = YesPlease
608NEEDS_LIBINTL_BEFORE_LIBICONV = YesPlease
609NO_SYS_SELECT_H = UnfortunatelyYes
610NO_D_TYPE_IN_DIRENT = YesPlease
611NO_GETTEXT = YesPlease
612NO_HSTRERROR = YesPlease
613NO_STRCASESTR = YesPlease
614NO_MEMMEM = YesPlease
615NO_STRLCPY = YesPlease
616NO_SETENV = YesPlease
617NO_UNSETENV = YesPlease
618NO_MKDTEMP = YesPlease
619# Currently libiconv-1.9.1.
620OLD_ICONV = UnfortunatelyYes
621NO_REGEX = NeedsStartEnd
622NO_PTHREADS = UnfortunatelyYes
623FREAD_READS_DIRECTORIES = UnfortunatelyYes
624
625# Not detected (nor checked for) by './configure'.
626# We don't have SA_RESTART on NonStop, unfortunalety.
627COMPAT_CFLAGS += -DSA_RESTART=0
628# Apparently needed in compat/fnmatch/fnmatch.c.
629COMPAT_CFLAGS += -DHAVE_STRING_H=1
630NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease
631NO_NSEC = YesPlease
632NO_PREAD = YesPlease
633NO_MMAP = YesPlease
634NO_POLL = YesPlease
635NO_INTPTR_T = UnfortunatelyYes
636CSPRNG_METHOD = openssl
637SANE_TOOL_PATH = /usr/coreutils/bin:/usr/local/bin
638SHELL_PATH = /usr/coreutils/bin/bash
639endif
640ifeq ($(uname_S),OS/390)
641NO_SYS_POLL_H = YesPlease
642NO_STRCASESTR = YesPlease
643NO_REGEX = YesPlease
644NO_MMAP = YesPlease
645NO_NSEC = YesPlease
646NO_STRLCPY = YesPlease
647NO_MEMMEM = YesPlease
648NO_GECOS_IN_PWENT = YesPlease
649HAVE_STRINGS_H = YesPlease
650NEEDS_MODE_TRANSLATION = YesPlease
651endif
652ifeq ($(uname_S),MINGW)
653ifeq ($(shell expr "$(uname_R)" : '1\.'),2)
654$(error "Building with MSys is no longer supported")
655endif
656pathsep = ;
657HAVE_ALLOCA_H = YesPlease
658NO_PREAD = YesPlease
659NEEDS_CRYPTO_WITH_SSL = YesPlease
660NO_LIBGEN_H = YesPlease
661NO_POLL = YesPlease
662NO_SYMLINK_HEAD = YesPlease
663NO_SETENV = YesPlease
664NO_STRCASESTR = YesPlease
665NO_STRLCPY = YesPlease
666NO_MEMMEM = YesPlease
667NEEDS_LIBICONV = YesPlease
668NO_STRTOUMAX = YesPlease
669NO_MKDTEMP = YesPlease
670NO_SVN_TESTS = YesPlease
671
672# The builtin FSMonitor requires Named Pipes and Threads on Windows.
673# These are always available, so we do not have to conditionally
674# support it.
675FSMONITOR_DAEMON_BACKEND = win32
676FSMONITOR_OS_SETTINGS = win32
677
678RUNTIME_PREFIX = YesPlease
679HAVE_WPGMPTR = YesWeDo
680NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease
681USE_WIN32_IPC = YesPlease
682USE_WIN32_MMAP = YesPlease
683MMAP_PREVENTS_DELETE = UnfortunatelyYes
684UNRELIABLE_FSTAT = UnfortunatelyYes
685OBJECT_CREATION_USES_RENAMES = UnfortunatelyNeedsTo
686NO_REGEX = YesPlease
687ETAGS_TARGET = ETAGS
688NO_POSIX_GOODIES = UnfortunatelyYes
689DEFAULT_HELP_FORMAT = html
690HAVE_PLATFORM_PROCINFO = YesPlease
691CSPRNG_METHOD = rtlgenrandom
692BASIC_LDFLAGS += -municode
693COMPAT_CFLAGS += -DNOGDI -Icompat -Icompat/win32
694COMPAT_CFLAGS += -DSTRIP_EXTENSION=\".exe\"
695COMPAT_OBJS += compat/mingw.o compat/winansi.o \
696compat/win32/trace2_win32_process_info.o \
697compat/win32/flush.o \
698compat/win32/path-utils.o \
699compat/win32/pthread.o compat/win32/syslog.o \
700compat/win32/dirent.o
701BASIC_CFLAGS += -DWIN32
702EXTLIBS += -lws2_32
703GITLIBS += git.res
704PTHREAD_LIBS =
705RC = windres -O coff
706NATIVE_CRLF = YesPlease
707X = .exe
708# MSys2
709prefix = /usr/
710# Enable DEP
711BASIC_LDFLAGS += -Wl,--nxcompat
712# Enable ASLR (unless debugging)
713ifneq (,$(findstring -O,$(filter-out -O0 -Og,$(CFLAGS))))
714BASIC_LDFLAGS += -Wl,--dynamicbase
715endif
716ifeq (MINGW32,$(MSYSTEM))
717prefix = /mingw32
718HOST_CPU = i686
719BASIC_LDFLAGS += -Wl,--pic-executable,-e,_mainCRTStartup
720endif
721ifeq (MINGW64,$(MSYSTEM))
722prefix = /mingw64
723HOST_CPU = x86_64
724BASIC_LDFLAGS += -Wl,--pic-executable,-e,mainCRTStartup
725else
726COMPAT_CFLAGS += -D_USE_32BIT_TIME_T
727BASIC_LDFLAGS += -Wl,--large-address-aware
728endif
729CC = gcc
730COMPAT_CFLAGS += -D__USE_MINGW_ANSI_STDIO=0 -DDETECT_MSYS_TTY \
731-fstack-protector-strong
732EXTLIBS += -lntdll
733EXTRA_PROGRAMS += headless-git$X
734INSTALL = /bin/install
735INTERNAL_QSORT = YesPlease
736HAVE_LIBCHARSET_H = YesPlease
737USE_GETTEXT_SCHEME = fallthrough
738USE_LIBPCRE = YesPlease
739USE_NED_ALLOCATOR = YesPlease
740ifeq (/mingw64,$(subst 32,64,$(prefix)))
741# Move system config into top-level /etc/
742ETC_GITCONFIG = ../etc/gitconfig
743ETC_GITATTRIBUTES = ../etc/gitattributes
744endif
745endif
746ifeq ($(uname_S),QNX)
747COMPAT_CFLAGS += -DSA_RESTART=0
748EXPAT_NEEDS_XMLPARSE_H = YesPlease
749HAVE_STRINGS_H = YesPlease
750NEEDS_SOCKET = YesPlease
751NO_GETPAGESIZE = YesPlease
752NO_ICONV = YesPlease
753NO_MEMMEM = YesPlease
754NO_MKDTEMP = YesPlease
755NO_NSEC = YesPlease
756NO_PTHREADS = YesPlease
757NO_STRCASESTR = YesPlease
758NO_STRLCPY = YesPlease
759endif
760
761vcxproj:
762# Require clean work tree
763git update-index -q --refresh && \
764git diff-files --quiet && \
765git diff-index --cached --quiet HEAD --
766
767# Make .vcxproj files and add them
768perl contrib/buildsystems/generate -g Vcxproj
769git add -f git.sln {*,*/lib,t/helper/*}/*.vcxproj
770
771# Generate the LinkOrCopyBuiltins.targets and LinkOrCopyRemoteHttp.targets file
772(echo '<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">' && \
773echo ' <Target Name="CopyBuiltins_AfterBuild" AfterTargets="AfterBuild">' && \
774for name in $(BUILT_INS);\
775do \
776echo ' <Copy SourceFiles="$$(OutDir)\git.exe" DestinationFiles="$$(OutDir)\'"$$name"'" SkipUnchangedFiles="true" UseHardlinksIfPossible="true" />'; \
777done && \
778echo ' </Target>' && \
779echo '</Project>') >git/LinkOrCopyBuiltins.targets
780(echo '<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">' && \
781echo ' <Target Name="CopyBuiltins_AfterBuild" AfterTargets="AfterBuild">' && \
782for name in $(REMOTE_CURL_ALIASES); \
783do \
784echo ' <Copy SourceFiles="$$(OutDir)\'"$(REMOTE_CURL_PRIMARY)"'" DestinationFiles="$$(OutDir)\'"$$name"'" SkipUnchangedFiles="true" UseHardlinksIfPossible="true" />'; \
785done && \
786echo ' </Target>' && \
787echo '</Project>') >git-remote-http/LinkOrCopyRemoteHttp.targets
788git add -f git/LinkOrCopyBuiltins.targets git-remote-http/LinkOrCopyRemoteHttp.targets
789
790# Add generated headers
791$(MAKE) MSVC=1 SKIP_VCPKG=1 prefix=/mingw64 $(GENERATED_H)
792git add -f $(GENERATED_H)
793
794# Add scripts
795rm -f perl/perl.mak
796$(MAKE) MSVC=1 SKIP_VCPKG=1 prefix=/mingw64 $(SCRIPT_LIB) $(SCRIPTS)
797# Strip out the sane tool path, needed only for building
798sed -i '/^git_broken_path_fix ".*/d' git-sh-setup
799git add -f $(SCRIPT_LIB) $(SCRIPTS)
800
801# Add Perl module
802$(MAKE) $(LIB_PERL_GEN)
803git add -f perl/build
804
805# Add bin-wrappers, for testing
806rm -rf bin-wrappers/
807$(MAKE) MSVC=1 SKIP_VCPKG=1 prefix=/mingw64 $(test_bindir_programs)
808# Ensure that the GIT_EXEC_PATH is a Unix-y one, and that the absolute
809# path of the repository is not hard-coded (GIT_EXEC_PATH will be set
810# by test-lib.sh according to the current setup)
811sed -i -e 's/^\(GIT_EXEC_PATH\)=.*/test -n "$${\1##*:*}" ||\
812\1="$$(cygpath -u "$$\1")"/' \
813-e "s|'$$(pwd)|\"\$$GIT_EXEC_PATH\"'|g" bin-wrappers/*
814# Ensure that test-* helpers find the .dll files copied to top-level
815sed -i 's|^PATH=.*|&:"$$GIT_EXEC_PATH"|' bin-wrappers/test-*
816# We do not want to force hard-linking builtins
817sed -i 's|\(git\)-\([-a-z]*\)\.exe"|\1.exe" \2|g' \
818bin-wrappers/git-{receive-pack,upload-archive}
819git add -f $(test_bindir_programs)
820# remote-ext is a builtin, but invoked as if it were external
821sed 's|receive-pack|remote-ext|g' \
822<bin-wrappers/git-receive-pack >bin-wrappers/git-remote-ext
823git add -f bin-wrappers/git-remote-ext
824
825# Add templates
826$(MAKE) -C templates
827git add -f templates/boilerplates.made templates/blt/
828
829# Add the translated messages
830make MSVC=1 SKIP_VCPKG=1 prefix=/mingw64 $(MOFILES)
831git add -f $(MOFILES)
832
833# Add build options
834$(MAKE) MSVC=1 SKIP_VCPKG=1 prefix=/mingw64 GIT-BUILD-OPTIONS
835git add -f GIT-BUILD-OPTIONS
836
837# Commit the whole shebang
838git commit -m "Generate Visual Studio solution" \
839-m "Auto-generated by \`$(MAKE)$(MAKEFLAGS) $@\`"
840