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 NO_MKSTEMPS = YesPlease
31 HAVE_PATHS_H = YesPlease
32 LIBC_CONTAINS_LIBINTL = YesPlease
33 HAVE_DEV_TTY = YesPlease
34 HAVE_CLOCK_GETTIME = YesPlease
35 HAVE_CLOCK_MONOTONIC = YesPlease
36 # -lrt is needed for clock_gettime on glibc <= 2.16
37 NEEDS_LIBRT = YesPlease
38 HAVE_GETDELIM = YesPlease
41 ifeq ($(uname_S),GNU/kFreeBSD)
42 HAVE_ALLOCA_H = YesPlease
43 NO_STRLCPY = YesPlease
44 NO_MKSTEMPS = YesPlease
45 HAVE_PATHS_H = YesPlease
46 DIR_HAS_BSD_GROUP_SEMANTICS = YesPlease
47 LIBC_CONTAINS_LIBINTL = YesPlease
49 ifeq ($(uname_S),UnixWare)
51 NEEDS_SOCKET = YesPlease
53 NEEDS_SSL_WITH_CRYPTO = YesPlease
54 NEEDS_LIBICONV = YesPlease
55 SHELL_PATH = /usr/local/bin/bash
57 NO_HSTRERROR = YesPlease
58 NO_MKSTEMPS = YesPlease
59 BASIC_CFLAGS += -Kthread
60 BASIC_CFLAGS += -I/usr/local/include
61 BASIC_LDFLAGS += -L/usr/local/lib
64 NO_STRCASESTR = YesPlease
67 ifeq ($(uname_S),SCO_SV)
73 BASIC_CFLAGS += -Kthread
75 NEEDS_SOCKET = YesPlease
77 NEEDS_SSL_WITH_CRYPTO = YesPlease
78 NEEDS_LIBICONV = YesPlease
79 SHELL_PATH = /usr/bin/bash
81 NO_HSTRERROR = YesPlease
82 NO_MKSTEMPS = YesPlease
83 BASIC_CFLAGS += -I/usr/local/include
84 BASIC_LDFLAGS += -L/usr/local/lib
85 NO_STRCASESTR = YesPlease
90 ifeq ($(uname_S),Darwin)
91 NEEDS_CRYPTO_WITH_SSL = YesPlease
92 NEEDS_SSL_WITH_CRYPTO = YesPlease
93 NEEDS_LIBICONV = YesPlease
94 # Note: $(uname_R) gives us the underlying Darwin version.
95 # - MacOS 10.0.* and MacOS 10.1.0 = Darwin 1.*
96 # - MacOS 10.x.* = Darwin (x+4).* for (1 <= x)
97 # i.e. "begins with [15678] and a dot" means "10.4.* or older".
98 ifeq ($(shell expr "$(uname_R)" : '[15678]\.'),2)
99 OLD_ICONV = UnfortunatelyYes
100 NO_APPLE_COMMON_CRYPTO = YesPlease
102 ifeq ($(shell expr "$(uname_R)" : '[15]\.'),2)
103 NO_STRLCPY = YesPlease
105 ifeq ($(shell test "`expr "$(uname_R)" : '\([0-9][0-9]*\)\.'`" -ge 11 && echo 1),1)
106 HAVE_GETDELIM = YesPlease
108 NO_MEMMEM = YesPlease
109 USE_ST_TIMESPEC = YesPlease
110 HAVE_DEV_TTY = YesPlease
111 COMPAT_OBJS += compat/precompose_utf8.o
112 BASIC_CFLAGS += -DPRECOMPOSE_UNICODE
113 BASIC_CFLAGS += -DPROTECT_HFS_DEFAULT=1
114 HAVE_BSD_SYSCTL = YesPlease
116 ifeq ($(uname_S),SunOS)
117 NEEDS_SOCKET = YesPlease
118 NEEDS_NSL = YesPlease
119 SHELL_PATH = /bin/bash
120 SANE_TOOL_PATH = /usr/xpg6/bin:/usr/xpg4/bin
121 HAVE_ALLOCA_H = YesPlease
122 NO_STRCASESTR = YesPlease
123 NO_MEMMEM = YesPlease
124 NO_MKDTEMP = YesPlease
125 NO_MKSTEMPS = YesPlease
127 NO_MSGFMT_EXTENDED_OPTIONS = YesPlease
128 HAVE_DEV_TTY = YesPlease
129 ifeq ($(uname_R),5.6)
131 NO_HSTRERROR = YesPlease
133 NO_SOCKADDR_STORAGE = YesPlease
134 NO_UNSETENV = YesPlease
135 NO_SETENV = YesPlease
136 NO_STRLCPY = YesPlease
137 NO_STRTOUMAX = YesPlease
140 ifeq ($(uname_R),5.7)
141 NEEDS_RESOLV = YesPlease
143 NO_SOCKADDR_STORAGE = YesPlease
144 NO_UNSETENV = YesPlease
145 NO_SETENV = YesPlease
146 NO_STRLCPY = YesPlease
147 NO_STRTOUMAX = YesPlease
150 ifeq ($(uname_R),5.8)
151 NO_UNSETENV = YesPlease
152 NO_SETENV = YesPlease
153 NO_STRTOUMAX = YesPlease
156 ifeq ($(uname_R),5.9)
157 NO_UNSETENV = YesPlease
158 NO_SETENV = YesPlease
159 NO_STRTOUMAX = YesPlease
162 INSTALL = /usr/ucb/install
164 BASIC_CFLAGS += -D__EXTENSIONS__ -D__sun__
166 ifeq ($(uname_O),Cygwin)
167 ifeq ($(shell expr "$(uname_R)" : '1\.[1-6]\.'),4)
168 NO_D_TYPE_IN_DIRENT = YesPlease
169 NO_STRCASESTR = YesPlease
170 NO_MEMMEM = YesPlease
171 NO_MKSTEMPS = YesPlease
172 NO_SYMLINK_HEAD = YesPlease
174 OLD_ICONV = UnfortunatelyYes
175 # There are conflicting reports about this.
176 # On some boxes NO_MMAP is needed, and not so elsewhere.
177 # Try commenting this out if you suspect MMAP is more efficient
180 NO_REGEX = UnfortunatelyYes
182 HAVE_ALLOCA_H = YesPlease
183 NEEDS_LIBICONV = YesPlease
184 NO_FAST_WORKING_DIRECTORY = UnfortunatelyYes
185 NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease
187 UNRELIABLE_FSTAT = UnfortunatelyYes
188 SPARSE_FLAGS = -isystem /usr/include/w32api -Wno-one-bit-signed-bitfield
189 OBJECT_CREATION_USES_RENAMES = UnfortunatelyNeedsTo
191 ifeq ($(uname_S),FreeBSD)
192 NEEDS_LIBICONV = YesPlease
193 OLD_ICONV = YesPlease
194 NO_MEMMEM = YesPlease
195 BASIC_CFLAGS += -I/usr/local/include
196 BASIC_LDFLAGS += -L/usr/local/lib
197 DIR_HAS_BSD_GROUP_SEMANTICS = YesPlease
198 USE_ST_TIMESPEC = YesPlease
199 ifeq ($(shell expr "$(uname_R)" : '4\.'),2)
200 PTHREAD_LIBS = -pthread
201 NO_UINTMAX_T = YesPlease
202 NO_STRTOUMAX = YesPlease
204 PYTHON_PATH = /usr/local/bin/python
205 PERL_PATH = /usr/local/bin/perl
206 HAVE_PATHS_H = YesPlease
207 GMTIME_UNRELIABLE_ERRORS = UnfortunatelyYes
208 HAVE_BSD_SYSCTL = YesPlease
209 PAGER_ENV = LESS=FRX LV=-c MORE=FRX
211 ifeq ($(uname_S),OpenBSD)
212 NO_STRCASESTR = YesPlease
213 NO_MEMMEM = YesPlease
214 USE_ST_TIMESPEC = YesPlease
215 NEEDS_LIBICONV = YesPlease
216 BASIC_CFLAGS += -I/usr/local/include
217 BASIC_LDFLAGS += -L/usr/local/lib
218 HAVE_PATHS_H = YesPlease
219 HAVE_BSD_SYSCTL = YesPlease
221 ifeq ($(uname_S),MirBSD)
222 NO_STRCASESTR = YesPlease
223 NO_MEMMEM = YesPlease
224 USE_ST_TIMESPEC = YesPlease
225 NEEDS_LIBICONV = YesPlease
226 HAVE_PATHS_H = YesPlease
227 HAVE_BSD_SYSCTL = YesPlease
229 ifeq ($(uname_S),NetBSD)
230 ifeq ($(shell expr "$(uname_R)" : '[01]\.'),2)
231 NEEDS_LIBICONV = YesPlease
233 BASIC_CFLAGS += -I/usr/pkg/include
234 BASIC_LDFLAGS += -L/usr/pkg/lib $(CC_LD_DYNPATH)/usr/pkg/lib
235 USE_ST_TIMESPEC = YesPlease
236 NO_MKSTEMPS = YesPlease
237 HAVE_PATHS_H = YesPlease
238 HAVE_BSD_SYSCTL = YesPlease
240 ifeq ($(uname_S),AIX)
242 NO_STRCASESTR = YesPlease
243 NO_MEMMEM = YesPlease
244 NO_MKDTEMP = YesPlease
245 NO_MKSTEMPS = YesPlease
246 NO_STRLCPY = YesPlease
248 FREAD_READS_DIRECTORIES = UnfortunatelyYes
249 INTERNAL_QSORT = UnfortunatelyYes
250 NEEDS_LIBICONV = YesPlease
251 BASIC_CFLAGS += -D_LARGE_FILES
252 ifeq ($(shell expr "$(uname_V)" : '[1234]'),1)
253 NO_PTHREADS = YesPlease
255 PTHREAD_LIBS = -lpthread
257 ifeq ($(shell expr "$(uname_V).$(uname_R)" : '5\.1'),3)
262 ifeq ($(uname_S),GNU)
264 HAVE_ALLOCA_H = YesPlease
265 NO_STRLCPY = YesPlease
266 NO_MKSTEMPS = YesPlease
267 HAVE_PATHS_H = YesPlease
268 LIBC_CONTAINS_LIBINTL = YesPlease
270 ifeq ($(uname_S),IRIX)
271 NO_SETENV = YesPlease
272 NO_UNSETENV = YesPlease
273 NO_STRCASESTR = YesPlease
274 NO_MEMMEM = YesPlease
275 NO_MKSTEMPS = YesPlease
276 NO_MKDTEMP = YesPlease
277 # When compiled with the MIPSpro 7.4.4m compiler, and without pthreads
278 # (i.e. NO_PTHREADS is set), and _with_ MMAP (i.e. NO_MMAP is not set),
279 # git dies with a segmentation fault when trying to access the first
280 # entry of a reflog. The conservative choice is made to always set
281 # NO_MMAP. If you suspect that your compiler is not affected by this
282 # issue, comment out the NO_MMAP statement.
285 SNPRINTF_RETURNS_BOGUS = YesPlease
286 SHELL_PATH = /usr/gnu/bin/bash
287 NEEDS_LIBGEN = YesPlease
289 ifeq ($(uname_S),IRIX64)
290 NO_SETENV = YesPlease
291 NO_UNSETENV = YesPlease
292 NO_STRCASESTR = YesPlease
293 NO_MEMMEM = YesPlease
294 NO_MKSTEMPS = YesPlease
295 NO_MKDTEMP = YesPlease
296 # When compiled with the MIPSpro 7.4.4m compiler, and without pthreads
297 # (i.e. NO_PTHREADS is set), and _with_ MMAP (i.e. NO_MMAP is not set),
298 # git dies with a segmentation fault when trying to access the first
299 # entry of a reflog. The conservative choice is made to always set
300 # NO_MMAP. If you suspect that your compiler is not affected by this
301 # issue, comment out the NO_MMAP statement.
304 SNPRINTF_RETURNS_BOGUS = YesPlease
305 SHELL_PATH = /usr/gnu/bin/bash
306 NEEDS_LIBGEN = YesPlease
308 ifeq ($(uname_S),HP-UX)
311 NO_SETENV = YesPlease
312 NO_STRCASESTR = YesPlease
313 NO_MEMMEM = YesPlease
314 NO_MKSTEMPS = YesPlease
315 NO_STRLCPY = YesPlease
316 NO_MKDTEMP = YesPlease
317 NO_UNSETENV = YesPlease
318 NO_HSTRERROR = YesPlease
319 NO_SYS_SELECT_H = YesPlease
320 SNPRINTF_RETURNS_BOGUS = YesPlease
322 ifeq ($(uname_R),B.11.00)
323 NO_INET_NTOP = YesPlease
324 NO_INET_PTON = YesPlease
326 ifeq ($(uname_R),B.10.20)
327 # Override HP-UX 11.x setting:
331 NO_INET_NTOP = YesPlease
332 NO_INET_PTON = YesPlease
336 ifeq ($(uname_S),Windows)
337 GIT_VERSION := $(GIT_VERSION).MSVC
339 HAVE_ALLOCA_H = YesPlease
341 NEEDS_CRYPTO_WITH_SSL = YesPlease
342 NO_LIBGEN_H = YesPlease
344 NO_SYMLINK_HEAD = YesPlease
346 NO_UNIX_SOCKETS = YesPlease
347 NO_SETENV = YesPlease
348 NO_STRCASESTR = YesPlease
349 NO_STRLCPY = YesPlease
350 NO_MEMMEM = YesPlease
351 # NEEDS_LIBICONV = YesPlease
353 NO_STRTOUMAX = YesPlease
354 NO_MKDTEMP = YesPlease
355 NO_MKSTEMPS = YesPlease
356 SNPRINTF_RETURNS_BOGUS = YesPlease
357 NO_SVN_TESTS = YesPlease
358 RUNTIME_PREFIX = YesPlease
359 NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease
361 USE_WIN32_MMAP = YesPlease
362 # USE_NED_ALLOCATOR = YesPlease
363 UNRELIABLE_FSTAT = UnfortunatelyYes
364 OBJECT_CREATION_USES_RENAMES = UnfortunatelyNeedsTo
366 NO_GETTEXT = YesPlease
367 NO_PYTHON = YesPlease
370 NO_INET_PTON = YesPlease
371 NO_INET_NTOP = YesPlease
372 NO_POSIX_GOODIES = UnfortunatelyYes
373 NATIVE_CRLF = YesPlease
374 DEFAULT_HELP_FORMAT = html
376 CC = compat/vcbuild/scripts/clink.pl
377 AR = compat/vcbuild/scripts/lib.pl
379 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
380 COMPAT_OBJS = compat/msvc.o compat/winansi.o \
381 compat/win32/pthread.o compat/win32/syslog.o \
382 compat/win32/dirent.o
383 COMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DNOGDI -DHAVE_STRING_H -Icompat -Icompat/regex -Icompat/win32 -DSTRIP_EXTENSION=\".exe\"
384 BASIC_LDFLAGS = -IGNORE:4217 -IGNORE:4049 -NOLOGO -SUBSYSTEM:CONSOLE
385 EXTLIBS = user32.lib advapi32.lib shell32.lib wininet.lib ws2_32.lib invalidcontinue.obj
388 BASIC_CFLAGS += -DPROTECT_NTFS_DEFAULT=1
390 BASIC_CFLAGS += -GL -Os -MD
391 BASIC_LDFLAGS += -LTCG
394 BASIC_CFLAGS += -Zi -MDd
398 ifeq ($(uname_S),Interix)
399 NO_INITGROUPS = YesPlease
401 NO_MEMMEM = YesPlease
402 NO_MKDTEMP = YesPlease
403 NO_STRTOUMAX = YesPlease
405 NO_MKSTEMPS = YesPlease
406 ifeq ($(uname_R),3.5)
407 NO_INET_NTOP = YesPlease
408 NO_INET_PTON = YesPlease
409 NO_SOCKADDR_STORAGE = YesPlease
411 ifeq ($(uname_R),5.2)
412 NO_INET_NTOP = YesPlease
413 NO_INET_PTON = YesPlease
414 NO_SOCKADDR_STORAGE = YesPlease
417 ifeq ($(uname_S),Minix)
419 NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease
422 NEEDS_CRYPTO_WITH_SSL = YesPlease
423 NEEDS_IDN_WITH_CURL = YesPlease
424 NEEDS_SSL_WITH_CURL = YesPlease
426 NO_HSTRERROR = YesPlease
431 ifeq ($(uname_S),NONSTOP_KERNEL)
432 # Needs some C99 features, "inline" is just one of them.
433 # INLINE='' would just replace one set of warnings with another and
434 # still not compile in c89 mode, due to non-const array initializations.
436 # Disable all optimization, seems to result in bad code, with -O or -O2
437 # or even -O1 (default), /usr/local/libexec/git-core/git-pack-objects
438 # abends on "git push". Needs more investigation.
440 # We'd want it to be here.
442 # Our's are in ${prefix}/bin (perl might also be in /usr/bin/perl).
443 PERL_PATH = ${prefix}/bin/perl
444 PYTHON_PATH = ${prefix}/bin/python
446 # As detected by './configure'.
447 # Missdetected, hence commented out, see below.
449 # Added manually, see above.
450 NEEDS_SSL_WITH_CURL = YesPlease
451 HAVE_LIBCHARSET_H = YesPlease
452 HAVE_STRINGS_H = YesPlease
453 NEEDS_LIBICONV = YesPlease
454 NEEDS_LIBINTL_BEFORE_LIBICONV = YesPlease
455 NO_SYS_SELECT_H = UnfortunatelyYes
456 NO_D_TYPE_IN_DIRENT = YesPlease
457 NO_HSTRERROR = YesPlease
458 NO_STRCASESTR = YesPlease
459 NO_MEMMEM = YesPlease
460 NO_STRLCPY = YesPlease
461 NO_SETENV = YesPlease
462 NO_UNSETENV = YesPlease
463 NO_MKDTEMP = YesPlease
464 NO_MKSTEMPS = YesPlease
465 # Currently libiconv-1.9.1.
466 OLD_ICONV = UnfortunatelyYes
468 NO_PTHREADS = UnfortunatelyYes
470 # Not detected (nor checked for) by './configure'.
471 # We don't have SA_RESTART on NonStop, unfortunalety.
472 COMPAT_CFLAGS += -DSA_RESTART=0
473 # Apparently needed in compat/fnmatch/fnmatch.c.
474 COMPAT_CFLAGS += -DHAVE_STRING_H=1
475 NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease
480 NO_INTPTR_T = UnfortunatelyYes
481 # Bug report 10-120822-4477 submitted to HP NonStop development.
482 MKDIR_WO_TRAILING_SLASH = YesPlease
483 # RFE 10-120912-4693 submitted to HP NonStop development.
484 NO_SETITIMER = UnfortunatelyYes
485 SANE_TOOL_PATH = /usr/coreutils/bin:/usr/local/bin
486 SHELL_PATH = /usr/local/bin/bash
487 # as of H06.25/J06.14, we might better use this
488 #SHELL_PATH = /usr/coreutils/bin/bash
490 ifneq (,$(findstring MINGW,$(uname_S)))
492 HAVE_ALLOCA_H = YesPlease
494 NEEDS_CRYPTO_WITH_SSL = YesPlease
495 NO_LIBGEN_H = YesPlease
497 NO_SYMLINK_HEAD = YesPlease
498 NO_UNIX_SOCKETS = YesPlease
499 NO_SETENV = YesPlease
500 NO_STRCASESTR = YesPlease
501 NO_STRLCPY = YesPlease
502 NO_MEMMEM = YesPlease
503 NEEDS_LIBICONV = YesPlease
504 NO_STRTOUMAX = YesPlease
505 NO_MKDTEMP = YesPlease
506 NO_MKSTEMPS = YesPlease
507 NO_SVN_TESTS = YesPlease
508 NO_PERL_MAKEMAKER = YesPlease
509 RUNTIME_PREFIX = YesPlease
510 NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease
512 USE_WIN32_MMAP = YesPlease
513 USE_NED_ALLOCATOR = YesPlease
514 UNRELIABLE_FSTAT = UnfortunatelyYes
515 OBJECT_CREATION_USES_RENAMES = UnfortunatelyNeedsTo
517 NO_PYTHON = YesPlease
520 NO_INET_PTON = YesPlease
521 NO_INET_NTOP = YesPlease
522 NO_POSIX_GOODIES = UnfortunatelyYes
523 DEFAULT_HELP_FORMAT = html
524 COMPAT_CFLAGS += -DNOGDI -Icompat -Icompat/win32
525 COMPAT_CFLAGS += -DSTRIP_EXTENSION=\".exe\"
526 COMPAT_OBJS += compat/mingw.o compat/winansi.o \
527 compat/win32/pthread.o compat/win32/syslog.o \
528 compat/win32/dirent.o
529 BASIC_CFLAGS += -DPROTECT_NTFS_DEFAULT=1
534 NATIVE_CRLF = YesPlease
536 SPARSE_FLAGS = -Wno-one-bit-signed-bitfield
537 ifneq (,$(wildcard ../THIS_IS_MSYSGIT))
538 htmldir = doc/git/html/
540 INSTALL = /bin/install
541 EXTLIBS += /mingw/lib/libz.a
542 NO_R_TO_GCC_LINKER = YesPlease
543 INTERNAL_QSORT = YesPlease
544 HAVE_LIBCHARSET_H = YesPlease
545 NO_GETTEXT = YesPlease
546 COMPAT_CLFAGS += -D__USE_MINGW_ACCESS
548 ifeq ($(shell expr "$(uname_R)" : '2\.'),2)
551 ifeq (MINGW32,$(MSYSTEM))
554 ifeq (MINGW64,$(MSYSTEM))
557 COMPAT_CFLAGS += -D_USE_32BIT_TIME_T
558 BASIC_LDFLAGS += -Wl,--large-address-aware
561 COMPAT_CFLAGS += -D__USE_MINGW_ANSI_STDIO=0 -DDETECT_MSYS_TTY
563 INSTALL = /bin/install
564 NO_R_TO_GCC_LINKER = YesPlease
565 INTERNAL_QSORT = YesPlease
566 HAVE_LIBCHARSET_H = YesPlease
568 USE_GETTEXT_SCHEME = fallthrough
569 USE_LIBPCRE= YesPlease
571 USE_NED_ALLOCATOR = YesPlease
573 COMPAT_CFLAGS += -D__USE_MINGW_ANSI_STDIO
578 ifeq ($(uname_S),QNX)
579 COMPAT_CFLAGS += -DSA_RESTART=0
580 EXPAT_NEEDS_XMLPARSE_H = YesPlease
581 HAVE_STRINGS_H = YesPlease
582 NEEDS_SOCKET = YesPlease
583 NO_GETPAGESIZE = YesPlease
585 NO_MEMMEM = YesPlease
586 NO_MKDTEMP = YesPlease
587 NO_MKSTEMPS = YesPlease
589 NO_PTHREADS = YesPlease
590 NO_R_TO_GCC_LINKER = YesPlease
591 NO_STRCASESTR = YesPlease
592 NO_STRLCPY = YesPlease