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