1 # Platform specific Makefile tweaks based on uname detection
3 uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
4 uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not')
5 uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')
6 uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not')
7 uname_P := $(shell sh -c 'uname -p 2>/dev/null || echo not')
8 uname_V := $(shell sh -c 'uname -v 2>/dev/null || echo not')
11 # avoid the MingW and Cygwin configuration sections
16 # We choose to avoid "if .. else if .. else .. endif endif"
17 # because maintaining the nesting to match is a pain. If
18 # we had "elif" things would have been much nicer...
20 ifeq ($(uname_S),OSF1)
21 # Need this for u_short definitions et al
22 BASIC_CFLAGS += -D_OSF_SOURCE
24 NO_STRTOULL = YesPlease
27 ifeq ($(uname_S),Linux)
28 HAVE_ALLOCA_H = YesPlease
29 NO_STRLCPY = YesPlease
30 HAVE_PATHS_H = YesPlease
31 LIBC_CONTAINS_LIBINTL = YesPlease
32 HAVE_DEV_TTY = YesPlease
33 HAVE_CLOCK_GETTIME = YesPlease
34 HAVE_CLOCK_MONOTONIC = YesPlease
35 # -lrt is needed for clock_gettime on glibc <= 2.16
36 NEEDS_LIBRT = YesPlease
37 HAVE_GETDELIM = YesPlease
40 ifeq ($(uname_S),GNU/kFreeBSD)
41 HAVE_ALLOCA_H = YesPlease
42 NO_STRLCPY = YesPlease
43 HAVE_PATHS_H = YesPlease
44 DIR_HAS_BSD_GROUP_SEMANTICS = YesPlease
45 LIBC_CONTAINS_LIBINTL = YesPlease
47 ifeq ($(uname_S),UnixWare)
49 NEEDS_SOCKET = YesPlease
51 NEEDS_SSL_WITH_CRYPTO = YesPlease
52 NEEDS_LIBICONV = YesPlease
53 SHELL_PATH = /usr/local/bin/bash
55 NO_HSTRERROR = YesPlease
56 BASIC_CFLAGS += -Kthread
57 BASIC_CFLAGS += -I/usr/local/include
58 BASIC_LDFLAGS += -L/usr/local/lib
61 NO_STRCASESTR = YesPlease
64 ifeq ($(uname_S),SCO_SV)
70 BASIC_CFLAGS += -Kthread
72 NEEDS_SOCKET = YesPlease
74 NEEDS_SSL_WITH_CRYPTO = YesPlease
75 NEEDS_LIBICONV = YesPlease
76 SHELL_PATH = /usr/bin/bash
78 NO_HSTRERROR = YesPlease
79 BASIC_CFLAGS += -I/usr/local/include
80 BASIC_LDFLAGS += -L/usr/local/lib
81 NO_STRCASESTR = YesPlease
86 ifeq ($(uname_S),Darwin)
87 NEEDS_CRYPTO_WITH_SSL = YesPlease
88 NEEDS_SSL_WITH_CRYPTO = YesPlease
89 NEEDS_LIBICONV = YesPlease
90 # Note: $(uname_R) gives us the underlying Darwin version.
91 # - MacOS 10.0.* and MacOS 10.1.0 = Darwin 1.*
92 # - MacOS 10.x.* = Darwin (x+4).* for (1 <= x)
93 # i.e. "begins with [15678] and a dot" means "10.4.* or older".
94 ifeq ($(shell expr "$(uname_R)" : '[15678]\.'),2)
95 OLD_ICONV = UnfortunatelyYes
96 NO_APPLE_COMMON_CRYPTO = YesPlease
98 ifeq ($(shell expr "$(uname_R)" : '[15]\.'),2)
99 NO_STRLCPY = YesPlease
101 ifeq ($(shell test "`expr "$(uname_R)" : '\([0-9][0-9]*\)\.'`" -ge 11 && echo 1),1)
102 HAVE_GETDELIM = YesPlease
104 NO_MEMMEM = YesPlease
105 USE_ST_TIMESPEC = YesPlease
106 HAVE_DEV_TTY = YesPlease
107 COMPAT_OBJS += compat/precompose_utf8.o
108 BASIC_CFLAGS += -DPRECOMPOSE_UNICODE
109 BASIC_CFLAGS += -DPROTECT_HFS_DEFAULT=1
110 HAVE_BSD_SYSCTL = YesPlease
112 ifeq ($(uname_S),SunOS)
113 NEEDS_SOCKET = YesPlease
114 NEEDS_NSL = YesPlease
115 SHELL_PATH = /bin/bash
116 SANE_TOOL_PATH = /usr/xpg6/bin:/usr/xpg4/bin
117 HAVE_ALLOCA_H = YesPlease
118 NO_STRCASESTR = YesPlease
119 NO_MEMMEM = YesPlease
120 NO_MKDTEMP = YesPlease
122 NO_MSGFMT_EXTENDED_OPTIONS = YesPlease
123 HAVE_DEV_TTY = YesPlease
124 ifeq ($(uname_R),5.6)
126 NO_HSTRERROR = YesPlease
128 NO_SOCKADDR_STORAGE = YesPlease
129 NO_UNSETENV = YesPlease
130 NO_SETENV = YesPlease
131 NO_STRLCPY = YesPlease
132 NO_STRTOUMAX = YesPlease
135 ifeq ($(uname_R),5.7)
136 NEEDS_RESOLV = YesPlease
138 NO_SOCKADDR_STORAGE = YesPlease
139 NO_UNSETENV = YesPlease
140 NO_SETENV = YesPlease
141 NO_STRLCPY = YesPlease
142 NO_STRTOUMAX = YesPlease
145 ifeq ($(uname_R),5.8)
146 NO_UNSETENV = YesPlease
147 NO_SETENV = YesPlease
148 NO_STRTOUMAX = YesPlease
151 ifeq ($(uname_R),5.9)
152 NO_UNSETENV = YesPlease
153 NO_SETENV = YesPlease
154 NO_STRTOUMAX = YesPlease
157 INSTALL = /usr/ucb/install
159 BASIC_CFLAGS += -D__EXTENSIONS__ -D__sun__
161 ifeq ($(uname_O),Cygwin)
162 ifeq ($(shell expr "$(uname_R)" : '1\.[1-6]\.'),4)
163 NO_D_TYPE_IN_DIRENT = YesPlease
164 NO_STRCASESTR = YesPlease
165 NO_MEMMEM = YesPlease
166 NO_SYMLINK_HEAD = YesPlease
168 OLD_ICONV = UnfortunatelyYes
169 # There are conflicting reports about this.
170 # On some boxes NO_MMAP is needed, and not so elsewhere.
171 # Try commenting this out if you suspect MMAP is more efficient
174 NO_REGEX = UnfortunatelyYes
176 HAVE_ALLOCA_H = YesPlease
177 NEEDS_LIBICONV = YesPlease
178 NO_FAST_WORKING_DIRECTORY = UnfortunatelyYes
179 NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease
181 UNRELIABLE_FSTAT = UnfortunatelyYes
182 SPARSE_FLAGS = -isystem /usr/include/w32api -Wno-one-bit-signed-bitfield
183 OBJECT_CREATION_USES_RENAMES = UnfortunatelyNeedsTo
184 COMPAT_OBJS += compat/cygwin.o
186 ifeq ($(uname_S),FreeBSD)
187 NEEDS_LIBICONV = YesPlease
188 OLD_ICONV = YesPlease
189 NO_MEMMEM = YesPlease
190 BASIC_CFLAGS += -I/usr/local/include
191 BASIC_LDFLAGS += -L/usr/local/lib
192 DIR_HAS_BSD_GROUP_SEMANTICS = YesPlease
193 USE_ST_TIMESPEC = YesPlease
194 ifeq ($(shell expr "$(uname_R)" : '4\.'),2)
195 PTHREAD_LIBS = -pthread
196 NO_UINTMAX_T = YesPlease
197 NO_STRTOUMAX = YesPlease
199 PYTHON_PATH = /usr/local/bin/python
200 PERL_PATH = /usr/local/bin/perl
201 HAVE_PATHS_H = YesPlease
202 GMTIME_UNRELIABLE_ERRORS = UnfortunatelyYes
203 HAVE_BSD_SYSCTL = YesPlease
204 PAGER_ENV = LESS=FRX LV=-c MORE=FRX
206 ifeq ($(uname_S),OpenBSD)
207 NO_STRCASESTR = YesPlease
208 NO_MEMMEM = YesPlease
209 USE_ST_TIMESPEC = YesPlease
210 NEEDS_LIBICONV = YesPlease
211 BASIC_CFLAGS += -I/usr/local/include
212 BASIC_LDFLAGS += -L/usr/local/lib
213 HAVE_PATHS_H = YesPlease
214 HAVE_BSD_SYSCTL = YesPlease
216 ifeq ($(uname_S),MirBSD)
217 NO_STRCASESTR = YesPlease
218 NO_MEMMEM = YesPlease
219 USE_ST_TIMESPEC = YesPlease
220 NEEDS_LIBICONV = YesPlease
221 HAVE_PATHS_H = YesPlease
222 HAVE_BSD_SYSCTL = YesPlease
224 ifeq ($(uname_S),NetBSD)
225 ifeq ($(shell expr "$(uname_R)" : '[01]\.'),2)
226 NEEDS_LIBICONV = YesPlease
228 BASIC_CFLAGS += -I/usr/pkg/include
229 BASIC_LDFLAGS += -L/usr/pkg/lib $(CC_LD_DYNPATH)/usr/pkg/lib
230 USE_ST_TIMESPEC = YesPlease
231 HAVE_PATHS_H = YesPlease
232 HAVE_BSD_SYSCTL = YesPlease
234 ifeq ($(uname_S),AIX)
236 NO_STRCASESTR = YesPlease
237 NO_MEMMEM = YesPlease
238 NO_MKDTEMP = YesPlease
239 NO_STRLCPY = YesPlease
241 NO_REGEX = NeedsStartEnd
242 FREAD_READS_DIRECTORIES = UnfortunatelyYes
243 INTERNAL_QSORT = UnfortunatelyYes
244 NEEDS_LIBICONV = YesPlease
245 BASIC_CFLAGS += -D_LARGE_FILES
246 ifeq ($(shell expr "$(uname_V)" : '[1234]'),1)
247 NO_PTHREADS = YesPlease
249 PTHREAD_LIBS = -lpthread
251 ifeq ($(shell expr "$(uname_V).$(uname_R)" : '5\.1'),3)
256 ifeq ($(uname_S),GNU)
258 HAVE_ALLOCA_H = YesPlease
259 NO_STRLCPY = YesPlease
260 HAVE_PATHS_H = YesPlease
261 LIBC_CONTAINS_LIBINTL = YesPlease
263 ifeq ($(uname_S),IRIX)
264 NO_SETENV = YesPlease
265 NO_UNSETENV = YesPlease
266 NO_STRCASESTR = YesPlease
267 NO_MEMMEM = YesPlease
268 NO_MKDTEMP = YesPlease
269 # When compiled with the MIPSpro 7.4.4m compiler, and without pthreads
270 # (i.e. NO_PTHREADS is set), and _with_ MMAP (i.e. NO_MMAP is not set),
271 # git dies with a segmentation fault when trying to access the first
272 # entry of a reflog. The conservative choice is made to always set
273 # NO_MMAP. If you suspect that your compiler is not affected by this
274 # issue, comment out the NO_MMAP statement.
277 SNPRINTF_RETURNS_BOGUS = YesPlease
278 SHELL_PATH = /usr/gnu/bin/bash
279 NEEDS_LIBGEN = YesPlease
281 ifeq ($(uname_S),IRIX64)
282 NO_SETENV = YesPlease
283 NO_UNSETENV = YesPlease
284 NO_STRCASESTR = YesPlease
285 NO_MEMMEM = YesPlease
286 NO_MKDTEMP = YesPlease
287 # When compiled with the MIPSpro 7.4.4m compiler, and without pthreads
288 # (i.e. NO_PTHREADS is set), and _with_ MMAP (i.e. NO_MMAP is not set),
289 # git dies with a segmentation fault when trying to access the first
290 # entry of a reflog. The conservative choice is made to always set
291 # NO_MMAP. If you suspect that your compiler is not affected by this
292 # issue, comment out the NO_MMAP statement.
295 SNPRINTF_RETURNS_BOGUS = YesPlease
296 SHELL_PATH = /usr/gnu/bin/bash
297 NEEDS_LIBGEN = YesPlease
299 ifeq ($(uname_S),HP-UX)
302 NO_SETENV = YesPlease
303 NO_STRCASESTR = YesPlease
304 NO_MEMMEM = YesPlease
305 NO_STRLCPY = YesPlease
306 NO_MKDTEMP = YesPlease
307 NO_UNSETENV = YesPlease
308 NO_HSTRERROR = YesPlease
309 NO_SYS_SELECT_H = YesPlease
310 SNPRINTF_RETURNS_BOGUS = YesPlease
312 ifeq ($(uname_R),B.11.00)
313 NO_INET_NTOP = YesPlease
314 NO_INET_PTON = YesPlease
316 ifeq ($(uname_R),B.10.20)
317 # Override HP-UX 11.x setting:
321 NO_INET_NTOP = YesPlease
322 NO_INET_PTON = YesPlease
326 ifeq ($(uname_S),Windows)
327 GIT_VERSION := $(GIT_VERSION).MSVC
329 HAVE_ALLOCA_H = YesPlease
331 NEEDS_CRYPTO_WITH_SSL = YesPlease
332 NO_LIBGEN_H = YesPlease
334 NO_SYMLINK_HEAD = YesPlease
336 NO_UNIX_SOCKETS = YesPlease
337 NO_SETENV = YesPlease
338 NO_STRCASESTR = YesPlease
339 NO_STRLCPY = YesPlease
340 NO_MEMMEM = YesPlease
341 # NEEDS_LIBICONV = YesPlease
343 NO_STRTOUMAX = YesPlease
344 NO_MKDTEMP = YesPlease
345 SNPRINTF_RETURNS_BOGUS = YesPlease
346 NO_SVN_TESTS = YesPlease
347 RUNTIME_PREFIX = YesPlease
348 NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease
350 USE_WIN32_MMAP = YesPlease
351 # USE_NED_ALLOCATOR = YesPlease
352 UNRELIABLE_FSTAT = UnfortunatelyYes
353 OBJECT_CREATION_USES_RENAMES = UnfortunatelyNeedsTo
355 NO_GETTEXT = YesPlease
356 NO_PYTHON = YesPlease
359 NO_INET_PTON = YesPlease
360 NO_INET_NTOP = YesPlease
361 NO_POSIX_GOODIES = UnfortunatelyYes
362 NATIVE_CRLF = YesPlease
363 DEFAULT_HELP_FORMAT = html
365 CC = compat/vcbuild/scripts/clink.pl
366 AR = compat/vcbuild/scripts/lib.pl
368 BASIC_CFLAGS = -nologo -I. -I../zlib -Icompat/vcbuild -Icompat/vcbuild/include -DWIN32 -D_CONSOLE -DHAVE_STRING_H -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE
369 COMPAT_OBJS = compat/msvc.o compat/winansi.o \
370 compat/win32/pthread.o compat/win32/syslog.o \
371 compat/win32/dirent.o
372 COMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DNOGDI -DHAVE_STRING_H -Icompat -Icompat/regex -Icompat/win32 -DSTRIP_EXTENSION=\".exe\"
373 BASIC_LDFLAGS = -IGNORE:4217 -IGNORE:4049 -NOLOGO -SUBSYSTEM:CONSOLE
374 EXTLIBS = user32.lib advapi32.lib shell32.lib wininet.lib ws2_32.lib invalidcontinue.obj
377 BASIC_CFLAGS += -DPROTECT_NTFS_DEFAULT=1
379 BASIC_CFLAGS += -GL -Os -MD
380 BASIC_LDFLAGS += -LTCG
383 BASIC_CFLAGS += -Zi -MDd
387 ifeq ($(uname_S),Interix)
388 NO_INITGROUPS = YesPlease
390 NO_MEMMEM = YesPlease
391 NO_MKDTEMP = YesPlease
392 NO_STRTOUMAX = YesPlease
394 ifeq ($(uname_R),3.5)
395 NO_INET_NTOP = YesPlease
396 NO_INET_PTON = YesPlease
397 NO_SOCKADDR_STORAGE = YesPlease
399 ifeq ($(uname_R),5.2)
400 NO_INET_NTOP = YesPlease
401 NO_INET_PTON = YesPlease
402 NO_SOCKADDR_STORAGE = YesPlease
405 ifeq ($(uname_S),Minix)
407 NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease
410 NEEDS_CRYPTO_WITH_SSL = YesPlease
411 NEEDS_IDN_WITH_CURL = YesPlease
412 NEEDS_SSL_WITH_CURL = YesPlease
414 NO_HSTRERROR = YesPlease
419 ifeq ($(uname_S),NONSTOP_KERNEL)
420 # Needs some C99 features, "inline" is just one of them.
421 # INLINE='' would just replace one set of warnings with another and
422 # still not compile in c89 mode, due to non-const array initializations.
424 # Disable all optimization, seems to result in bad code, with -O or -O2
425 # or even -O1 (default), /usr/local/libexec/git-core/git-pack-objects
426 # abends on "git push". Needs more investigation.
428 # We'd want it to be here.
430 # Our's are in ${prefix}/bin (perl might also be in /usr/bin/perl).
431 PERL_PATH = ${prefix}/bin/perl
432 PYTHON_PATH = ${prefix}/bin/python
434 # As detected by './configure'.
435 # Missdetected, hence commented out, see below.
437 # Added manually, see above.
438 NEEDS_SSL_WITH_CURL = YesPlease
439 HAVE_LIBCHARSET_H = YesPlease
440 HAVE_STRINGS_H = YesPlease
441 NEEDS_LIBICONV = YesPlease
442 NEEDS_LIBINTL_BEFORE_LIBICONV = YesPlease
443 NO_SYS_SELECT_H = UnfortunatelyYes
444 NO_D_TYPE_IN_DIRENT = YesPlease
445 NO_HSTRERROR = YesPlease
446 NO_STRCASESTR = YesPlease
447 NO_MEMMEM = YesPlease
448 NO_STRLCPY = YesPlease
449 NO_SETENV = YesPlease
450 NO_UNSETENV = YesPlease
451 NO_MKDTEMP = YesPlease
452 # Currently libiconv-1.9.1.
453 OLD_ICONV = UnfortunatelyYes
455 NO_PTHREADS = UnfortunatelyYes
457 # Not detected (nor checked for) by './configure'.
458 # We don't have SA_RESTART on NonStop, unfortunalety.
459 COMPAT_CFLAGS += -DSA_RESTART=0
460 # Apparently needed in compat/fnmatch/fnmatch.c.
461 COMPAT_CFLAGS += -DHAVE_STRING_H=1
462 NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease
467 NO_INTPTR_T = UnfortunatelyYes
468 # Bug report 10-120822-4477 submitted to HP NonStop development.
469 MKDIR_WO_TRAILING_SLASH = YesPlease
470 # RFE 10-120912-4693 submitted to HP NonStop development.
471 NO_SETITIMER = UnfortunatelyYes
472 SANE_TOOL_PATH = /usr/coreutils/bin:/usr/local/bin
473 SHELL_PATH = /usr/local/bin/bash
474 # as of H06.25/J06.14, we might better use this
475 #SHELL_PATH = /usr/coreutils/bin/bash
477 ifneq (,$(findstring MINGW,$(uname_S)))
479 HAVE_ALLOCA_H = YesPlease
481 NEEDS_CRYPTO_WITH_SSL = YesPlease
482 NO_LIBGEN_H = YesPlease
484 NO_SYMLINK_HEAD = YesPlease
485 NO_UNIX_SOCKETS = YesPlease
486 NO_SETENV = YesPlease
487 NO_STRCASESTR = YesPlease
488 NO_STRLCPY = YesPlease
489 NO_MEMMEM = YesPlease
490 NEEDS_LIBICONV = YesPlease
491 NO_STRTOUMAX = YesPlease
492 NO_MKDTEMP = YesPlease
493 NO_SVN_TESTS = YesPlease
494 NO_PERL_MAKEMAKER = YesPlease
495 RUNTIME_PREFIX = YesPlease
496 NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease
498 USE_WIN32_MMAP = YesPlease
499 USE_NED_ALLOCATOR = YesPlease
500 UNRELIABLE_FSTAT = UnfortunatelyYes
501 OBJECT_CREATION_USES_RENAMES = UnfortunatelyNeedsTo
503 NO_PYTHON = YesPlease
505 NO_INET_PTON = YesPlease
506 NO_INET_NTOP = YesPlease
507 NO_POSIX_GOODIES = UnfortunatelyYes
508 DEFAULT_HELP_FORMAT = html
509 COMPAT_CFLAGS += -DNOGDI -Icompat -Icompat/win32
510 COMPAT_CFLAGS += -DSTRIP_EXTENSION=\".exe\"
511 COMPAT_OBJS += compat/mingw.o compat/winansi.o \
512 compat/win32/pthread.o compat/win32/syslog.o \
513 compat/win32/dirent.o
514 BASIC_CFLAGS += -DPROTECT_NTFS_DEFAULT=1
519 NATIVE_CRLF = YesPlease
521 SPARSE_FLAGS = -Wno-one-bit-signed-bitfield
522 ifneq (,$(wildcard ../THIS_IS_MSYSGIT))
523 htmldir = doc/git/html/
525 INSTALL = /bin/install
526 EXTLIBS += /mingw/lib/libz.a
527 NO_R_TO_GCC_LINKER = YesPlease
528 INTERNAL_QSORT = YesPlease
529 HAVE_LIBCHARSET_H = YesPlease
530 NO_GETTEXT = YesPlease
531 COMPAT_CLFAGS += -D__USE_MINGW_ACCESS
533 ifeq ($(shell expr "$(uname_R)" : '2\.'),2)
536 ifeq (MINGW32,$(MSYSTEM))
539 ifeq (MINGW64,$(MSYSTEM))
542 COMPAT_CFLAGS += -D_USE_32BIT_TIME_T
543 BASIC_LDFLAGS += -Wl,--large-address-aware
546 COMPAT_CFLAGS += -D__USE_MINGW_ANSI_STDIO=0 -DDETECT_MSYS_TTY
548 INSTALL = /bin/install
549 NO_R_TO_GCC_LINKER = YesPlease
550 INTERNAL_QSORT = YesPlease
551 HAVE_LIBCHARSET_H = YesPlease
553 USE_GETTEXT_SCHEME = fallthrough
554 USE_LIBPCRE= YesPlease
556 USE_NED_ALLOCATOR = YesPlease
558 COMPAT_CFLAGS += -D__USE_MINGW_ANSI_STDIO
563 ifeq ($(uname_S),QNX)
564 COMPAT_CFLAGS += -DSA_RESTART=0
565 EXPAT_NEEDS_XMLPARSE_H = YesPlease
566 HAVE_STRINGS_H = YesPlease
567 NEEDS_SOCKET = YesPlease
568 NO_GETPAGESIZE = YesPlease
570 NO_MEMMEM = YesPlease
571 NO_MKDTEMP = YesPlease
573 NO_PTHREADS = YesPlease
574 NO_R_TO_GCC_LINKER = YesPlease
575 NO_STRCASESTR = YesPlease
576 NO_STRLCPY = YesPlease