Merge branch 'jk/rebase-i-comment-char'
[git.git] / Makefile
1 # The default target of this Makefile is...
2 all::
3
4 # Define V=1 to have a more verbose compile.
5 #
6 # Define SHELL_PATH to a POSIX shell if your /bin/sh is broken.
7 #
8 # Define SANE_TOOL_PATH to a colon-separated list of paths to prepend
9 # to PATH if your tools in /usr/bin are broken.
10 #
11 # Define SOCKLEN_T to a suitable type (such as 'size_t') if your
12 # system headers do not define a socklen_t type.
13 #
14 # Define INLINE to a suitable substitute (such as '__inline' or '') if git
15 # fails to compile with errors about undefined inline functions or similar.
16 #
17 # Define SNPRINTF_RETURNS_BOGUS if your are on a system which snprintf()
18 # or vsnprintf() return -1 instead of number of characters which would
19 # have been written to the final string if enough space had been available.
20 #
21 # Define FREAD_READS_DIRECTORIES if your are on a system which succeeds
22 # when attempting to read from an fopen'ed directory.
23 #
24 # Define NO_OPENSSL environment variable if you do not have OpenSSL.
25 # This also implies BLK_SHA1.
26 #
27 # Define USE_LIBPCRE if you have and want to use libpcre. git-grep will be
28 # able to use Perl-compatible regular expressions.
29 #
30 # Define LIBPCREDIR=/foo/bar if your libpcre header and library files are in
31 # /foo/bar/include and /foo/bar/lib directories.
32 #
33 # Define NO_CURL if you do not have libcurl installed.  git-http-fetch and
34 # git-http-push are not built, and you cannot use http:// and https://
35 # transports (neither smart nor dumb).
36 #
37 # Define CURLDIR=/foo/bar if your curl header and library files are in
38 # /foo/bar/include and /foo/bar/lib directories.
39 #
40 # Define NO_EXPAT if you do not have expat installed.  git-http-push is
41 # not built, and you cannot push using http:// and https:// transports (dumb).
42 #
43 # Define EXPATDIR=/foo/bar if your expat header and library files are in
44 # /foo/bar/include and /foo/bar/lib directories.
45 #
46 # Define EXPAT_NEEDS_XMLPARSE_H if you have an old version of expat (e.g.,
47 # 1.1 or 1.2) that provides xmlparse.h instead of expat.h.
48 #
49 # Define NO_GETTEXT if you don't want Git output to be translated.
50 # A translated Git requires GNU libintl or another gettext implementation,
51 # plus libintl-perl at runtime.
52 #
53 # Define USE_GETTEXT_SCHEME and set it to 'fallthrough', if you don't trust
54 # the installed gettext translation of the shell scripts output.
55 #
56 # Define HAVE_LIBCHARSET_H if you haven't set NO_GETTEXT and you can't
57 # trust the langinfo.h's nl_langinfo(CODESET) function to return the
58 # current character set. GNU and Solaris have a nl_langinfo(CODESET),
59 # FreeBSD can use either, but MinGW and some others need to use
60 # libcharset.h's locale_charset() instead.
61 #
62 # Define CHARSET_LIB to you need to link with library other than -liconv to
63 # use locale_charset() function.  On some platforms this needs to set to
64 # -lcharset
65 #
66 # Define LIBC_CONTAINS_LIBINTL if your gettext implementation doesn't
67 # need -lintl when linking.
68 #
69 # Define NO_MSGFMT_EXTENDED_OPTIONS if your implementation of msgfmt
70 # doesn't support GNU extensions like --check and --statistics
71 #
72 # Define HAVE_PATHS_H if you have paths.h and want to use the default PATH
73 # it specifies.
74 #
75 # Define NO_D_INO_IN_DIRENT if you don't have d_ino in your struct dirent.
76 #
77 # Define NO_D_TYPE_IN_DIRENT if your platform defines DT_UNKNOWN but lacks
78 # d_type in struct dirent (Cygwin 1.5, fixed in Cygwin 1.7).
79 #
80 # Define HAVE_STRINGS_H if you have strings.h and need it for strcasecmp.
81 #
82 # Define NO_STRCASESTR if you don't have strcasestr.
83 #
84 # Define NO_MEMMEM if you don't have memmem.
85 #
86 # Define NO_GETPAGESIZE if you don't have getpagesize.
87 #
88 # Define NO_STRLCPY if you don't have strlcpy.
89 #
90 # Define NO_STRTOUMAX if you don't have both strtoimax and strtoumax in the
91 # C library. If your compiler also does not support long long or does not have
92 # strtoull, define NO_STRTOULL.
93 #
94 # Define NO_SETENV if you don't have setenv in the C library.
95 #
96 # Define NO_UNSETENV if you don't have unsetenv in the C library.
97 #
98 # Define NO_MKDTEMP if you don't have mkdtemp in the C library.
99 #
100 # Define MKDIR_WO_TRAILING_SLASH if your mkdir() can't deal with trailing slash.
101 #
102 # Define NO_MKSTEMPS if you don't have mkstemps in the C library.
103 #
104 # Define NO_STRTOK_R if you don't have strtok_r in the C library.
105 #
106 # Define NO_FNMATCH if you don't have fnmatch in the C library.
107 #
108 # Define NO_FNMATCH_CASEFOLD if your fnmatch function doesn't have the
109 # FNM_CASEFOLD GNU extension.
110 #
111 # Define USE_WILDMATCH if you want to use Git's wildmatch
112 # implementation as fnmatch
113 #
114 # Define NO_GECOS_IN_PWENT if you don't have pw_gecos in struct passwd
115 # in the C library.
116 #
117 # Define NO_LIBGEN_H if you don't have libgen.h.
118 #
119 # Define NEEDS_LIBGEN if your libgen needs -lgen when linking
120 #
121 # Define NO_SYS_SELECT_H if you don't have sys/select.h.
122 #
123 # Define NO_SYMLINK_HEAD if you never want .git/HEAD to be a symbolic link.
124 # Enable it on Windows.  By default, symrefs are still used.
125 #
126 # Define NO_SVN_TESTS if you want to skip time-consuming SVN interoperability
127 # tests.  These tests take up a significant amount of the total test time
128 # but are not needed unless you plan to talk to SVN repos.
129 #
130 # Define NO_FINK if you are building on Darwin/Mac OS X, have Fink
131 # installed in /sw, but don't want GIT to link against any libraries
132 # installed there.  If defined you may specify your own (or Fink's)
133 # include directories and library directories by defining CFLAGS
134 # and LDFLAGS appropriately.
135 #
136 # Define NO_DARWIN_PORTS if you are building on Darwin/Mac OS X,
137 # have DarwinPorts installed in /opt/local, but don't want GIT to
138 # link against any libraries installed there.  If defined you may
139 # specify your own (or DarwinPort's) include directories and
140 # library directories by defining CFLAGS and LDFLAGS appropriately.
141 #
142 # Define BLK_SHA1 environment variable to make use of the bundled
143 # optimized C SHA1 routine.
144 #
145 # Define PPC_SHA1 environment variable when running make to make use of
146 # a bundled SHA1 routine optimized for PowerPC.
147 #
148 # Define NEEDS_CRYPTO_WITH_SSL if you need -lcrypto when using -lssl (Darwin).
149 #
150 # Define NEEDS_SSL_WITH_CRYPTO if you need -lssl when using -lcrypto (Darwin).
151 #
152 # Define NEEDS_SSL_WITH_CURL if you need -lssl with -lcurl (Minix).
153 #
154 # Define NEEDS_IDN_WITH_CURL if you need -lidn when using -lcurl (Minix).
155 #
156 # Define NEEDS_LIBICONV if linking with libc is not enough (Darwin).
157 #
158 # Define NEEDS_LIBINTL_BEFORE_LIBICONV if you need libintl before libiconv.
159 #
160 # Define NO_INTPTR_T if you don't have intptr_t nor uintptr_t.
161 #
162 # Define NO_UINTMAX_T if you don't have uintmax_t.
163 #
164 # Define NEEDS_SOCKET if linking with libc is not enough (SunOS,
165 # Patrick Mauritz).
166 #
167 # Define NEEDS_RESOLV if linking with -lnsl and/or -lsocket is not enough.
168 # Notably on Solaris hstrerror resides in libresolv and on Solaris 7
169 # inet_ntop and inet_pton additionally reside there.
170 #
171 # Define NO_MMAP if you want to avoid mmap.
172 #
173 # Define NO_SYS_POLL_H if you don't have sys/poll.h.
174 #
175 # Define NO_POLL if you do not have or don't want to use poll().
176 # This also implies NO_SYS_POLL_H.
177 #
178 # Define NEEDS_SYS_PARAM_H if you need to include sys/param.h to compile,
179 # *PLEASE* REPORT to git@vger.kernel.org if your platform needs this;
180 # we want to know more about the issue.
181 #
182 # Define NO_PTHREADS if you do not have or do not want to use Pthreads.
183 #
184 # Define NO_PREAD if you have a problem with pread() system call (e.g.
185 # cygwin1.dll before v1.5.22).
186 #
187 # Define NO_SETITIMER if you don't have setitimer()
188 #
189 # Define NO_STRUCT_ITIMERVAL if you don't have struct itimerval
190 # This also implies NO_SETITIMER
191 #
192 # Define NO_THREAD_SAFE_PREAD if your pread() implementation is not
193 # thread-safe. (e.g. compat/pread.c or cygwin)
194 #
195 # Define NO_FAST_WORKING_DIRECTORY if accessing objects in pack files is
196 # generally faster on your platform than accessing the working directory.
197 #
198 # Define NO_TRUSTABLE_FILEMODE if your filesystem may claim to support
199 # the executable mode bit, but doesn't really do so.
200 #
201 # Define NO_IPV6 if you lack IPv6 support and getaddrinfo().
202 #
203 # Define NO_UNIX_SOCKETS if your system does not offer unix sockets.
204 #
205 # Define NO_SOCKADDR_STORAGE if your platform does not have struct
206 # sockaddr_storage.
207 #
208 # Define NO_ICONV if your libc does not properly support iconv.
209 #
210 # Define OLD_ICONV if your library has an old iconv(), where the second
211 # (input buffer pointer) parameter is declared with type (const char **).
212 #
213 # Define NO_DEFLATE_BOUND if your zlib does not have deflateBound.
214 #
215 # Define NO_R_TO_GCC_LINKER if your gcc does not like "-R/path/lib"
216 # that tells runtime paths to dynamic libraries;
217 # "-Wl,-rpath=/path/lib" is used instead.
218 #
219 # Define NO_NORETURN if using buggy versions of gcc 4.6+ and profile feedback,
220 # as the compiler can crash (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49299)
221 #
222 # Define USE_NSEC below if you want git to care about sub-second file mtimes
223 # and ctimes. Note that you need recent glibc (at least 2.2.4) for this, and
224 # it will BREAK YOUR LOCAL DIFFS! show-diff and anything using it will likely
225 # randomly break unless your underlying filesystem supports those sub-second
226 # times (my ext3 doesn't).
227 #
228 # Define USE_ST_TIMESPEC if your "struct stat" uses "st_ctimespec" instead of
229 # "st_ctim"
230 #
231 # Define NO_NSEC if your "struct stat" does not have "st_ctim.tv_nsec"
232 # available.  This automatically turns USE_NSEC off.
233 #
234 # Define USE_STDEV below if you want git to care about the underlying device
235 # change being considered an inode change from the update-index perspective.
236 #
237 # Define NO_ST_BLOCKS_IN_STRUCT_STAT if your platform does not have st_blocks
238 # field that counts the on-disk footprint in 512-byte blocks.
239 #
240 # Define DOCBOOK_XSL_172 if you want to format man pages with DocBook XSL v1.72
241 # (not v1.73 or v1.71).
242 #
243 # Define ASCIIDOC_ROFF if your DocBook XSL does not escape raw roff directives
244 # (versions 1.68.1 through v1.72).
245 #
246 # Define GNU_ROFF if your target system uses GNU groff.  This forces
247 # apostrophes to be ASCII so that cut&pasting examples to the shell
248 # will work.
249 #
250 # Define PERL_PATH to the path of your Perl binary (usually /usr/bin/perl).
251 #
252 # Define NO_PERL_MAKEMAKER if you cannot use Makefiles generated by perl's
253 # MakeMaker (e.g. using ActiveState under Cygwin).
254 #
255 # Define NO_PERL if you do not want Perl scripts or libraries at all.
256 #
257 # Define PYTHON_PATH to the path of your Python binary (often /usr/bin/python
258 # but /usr/bin/python2.7 on some platforms).
259 #
260 # Define NO_PYTHON if you do not want Python scripts or libraries at all.
261 #
262 # Define NO_TCLTK if you do not want Tcl/Tk GUI.
263 #
264 # The TCL_PATH variable governs the location of the Tcl interpreter
265 # used to optimize git-gui for your system.  Only used if NO_TCLTK
266 # is not set.  Defaults to the bare 'tclsh'.
267 #
268 # The TCLTK_PATH variable governs the location of the Tcl/Tk interpreter.
269 # If not set it defaults to the bare 'wish'. If it is set to the empty
270 # string then NO_TCLTK will be forced (this is used by configure script).
271 #
272 # Define INTERNAL_QSORT to use Git's implementation of qsort(), which
273 # is a simplified version of the merge sort used in glibc. This is
274 # recommended if Git triggers O(n^2) behavior in your platform's qsort().
275 #
276 # Define UNRELIABLE_FSTAT if your system's fstat does not return the same
277 # information on a not yet closed file that lstat would return for the same
278 # file after it was closed.
279 #
280 # Define OBJECT_CREATION_USES_RENAMES if your operating systems has problems
281 # when hardlinking a file to another name and unlinking the original file right
282 # away (some NTFS drivers seem to zero the contents in that scenario).
283 #
284 # Define NO_CROSS_DIRECTORY_HARDLINKS if you plan to distribute the installed
285 # programs as a tar, where bin/ and libexec/ might be on different file systems.
286 #
287 # Define NO_INSTALL_HARDLINKS if you prefer to use either symbolic links or
288 # copies to install built-in git commands e.g. git-cat-file.
289 #
290 # Define USE_NED_ALLOCATOR if you want to replace the platforms default
291 # memory allocators with the nedmalloc allocator written by Niall Douglas.
292 #
293 # Define NO_REGEX if you have no or inferior regex support in your C library.
294 #
295 # Define CYGWIN_V15_WIN32API if you are using Cygwin v1.7.x but are not
296 # using the current w32api packages. The recommended approach, however,
297 # is to update your installation if compilation errors occur.
298 #
299 # Define HAVE_DEV_TTY if your system can open /dev/tty to interact with the
300 # user.
301 #
302 # Define GETTEXT_POISON if you are debugging the choice of strings marked
303 # for translation.  In a GETTEXT_POISON build, you can turn all strings marked
304 # for translation into gibberish by setting the GIT_GETTEXT_POISON variable
305 # (to any value) in your environment.
306 #
307 # Define JSMIN to point to JavaScript minifier that functions as
308 # a filter to have gitweb.js minified.
309 #
310 # Define CSSMIN to point to a CSS minifier in order to generate a minified
311 # version of gitweb.css
312 #
313 # Define DEFAULT_PAGER to a sensible pager command (defaults to "less") if
314 # you want to use something different.  The value will be interpreted by the
315 # shell at runtime when it is used.
316 #
317 # Define DEFAULT_EDITOR to a sensible editor command (defaults to "vi") if you
318 # want to use something different.  The value will be interpreted by the shell
319 # if necessary when it is used.  Examples:
320 #
321 #   DEFAULT_EDITOR='~/bin/vi',
322 #   DEFAULT_EDITOR='$GIT_FALLBACK_EDITOR',
323 #   DEFAULT_EDITOR='"C:\Program Files\Vim\gvim.exe" --nofork'
324 #
325 # Define COMPUTE_HEADER_DEPENDENCIES to "yes" if you want dependencies on
326 # header files to be automatically computed, to avoid rebuilding objects when
327 # an unrelated header file changes.  Define it to "no" to use the hard-coded
328 # dependency rules.  The default is "auto", which means to use computed header
329 # dependencies if your compiler is detected to support it.
330 #
331 # Define CHECK_HEADER_DEPENDENCIES to check for problems in the hard-coded
332 # dependency rules.
333 #
334 # Define NATIVE_CRLF if your platform uses CRLF for line endings.
335 #
336 # Define XDL_FAST_HASH to use an alternative line-hashing method in
337 # the diff algorithm.  It gives a nice speedup if your processor has
338 # fast unaligned word loads.  Does NOT work on big-endian systems!
339 # Enabled by default on x86_64.
340 #
341 # Define GIT_USER_AGENT if you want to change how git identifies itself during
342 # network interactions.  The default is "git/$(GIT_VERSION)".
343 #
344 # Define DEFAULT_HELP_FORMAT to "man", "info" or "html"
345 # (defaults to "man") if you want to have a different default when
346 # "git help" is called without a parameter specifying the format.
347
348 GIT-VERSION-FILE: FORCE
349         @$(SHELL_PATH) ./GIT-VERSION-GEN
350 -include GIT-VERSION-FILE
351
352 # CFLAGS and LDFLAGS are for the users to override from the command line.
353
354 CFLAGS = -g -O2 -Wall
355 LDFLAGS =
356 ALL_CFLAGS = $(CPPFLAGS) $(CFLAGS)
357 ALL_LDFLAGS = $(LDFLAGS)
358 STRIP ?= strip
359
360 # Among the variables below, these:
361 #   gitexecdir
362 #   template_dir
363 #   mandir
364 #   infodir
365 #   htmldir
366 #   sysconfdir
367 # can be specified as a relative path some/where/else;
368 # this is interpreted as relative to $(prefix) and "git" at
369 # runtime figures out where they are based on the path to the executable.
370 # This can help installing the suite in a relocatable way.
371
372 prefix = $(HOME)
373 bindir_relative = bin
374 bindir = $(prefix)/$(bindir_relative)
375 mandir = share/man
376 infodir = share/info
377 gitexecdir = libexec/git-core
378 mergetoolsdir = $(gitexecdir)/mergetools
379 sharedir = $(prefix)/share
380 gitwebdir = $(sharedir)/gitweb
381 localedir = $(sharedir)/locale
382 template_dir = share/git-core/templates
383 htmldir = share/doc/git-doc
384 ETC_GITCONFIG = $(sysconfdir)/gitconfig
385 ETC_GITATTRIBUTES = $(sysconfdir)/gitattributes
386 lib = lib
387 # DESTDIR =
388 pathsep = :
389
390 export prefix bindir sharedir sysconfdir gitwebdir localedir
391
392 CC = cc
393 AR = ar
394 RM = rm -f
395 DIFF = diff
396 TAR = tar
397 FIND = find
398 INSTALL = install
399 RPMBUILD = rpmbuild
400 TCL_PATH = tclsh
401 TCLTK_PATH = wish
402 XGETTEXT = xgettext
403 MSGFMT = msgfmt
404 PTHREAD_LIBS = -lpthread
405 PTHREAD_CFLAGS =
406 GCOV = gcov
407
408 export TCL_PATH TCLTK_PATH
409
410 SPARSE_FLAGS =
411
412
413
414 ### --- END CONFIGURATION SECTION ---
415
416 # Those must not be GNU-specific; they are shared with perl/ which may
417 # be built by a different compiler. (Note that this is an artifact now
418 # but it still might be nice to keep that distinction.)
419 BASIC_CFLAGS = -I.
420 BASIC_LDFLAGS =
421
422 # Guard against environment variables
423 BUILTIN_OBJS =
424 BUILT_INS =
425 COMPAT_CFLAGS =
426 COMPAT_OBJS =
427 XDIFF_OBJS =
428 VCSSVN_OBJS =
429 GENERATED_H =
430 EXTRA_CPPFLAGS =
431 LIB_H =
432 LIB_OBJS =
433 PROGRAM_OBJS =
434 PROGRAMS =
435 SCRIPT_PERL =
436 SCRIPT_PYTHON =
437 SCRIPT_SH =
438 SCRIPT_LIB =
439 TEST_PROGRAMS_NEED_X =
440
441 # Having this variable in your environment would break pipelines because
442 # you cause "cd" to echo its destination to stdout.  It can also take
443 # scripts to unexpected places.  If you like CDPATH, define it for your
444 # interactive shell sessions without exporting it.
445 unexport CDPATH
446
447 SCRIPT_SH += git-am.sh
448 SCRIPT_SH += git-bisect.sh
449 SCRIPT_SH += git-difftool--helper.sh
450 SCRIPT_SH += git-filter-branch.sh
451 SCRIPT_SH += git-lost-found.sh
452 SCRIPT_SH += git-merge-octopus.sh
453 SCRIPT_SH += git-merge-one-file.sh
454 SCRIPT_SH += git-merge-resolve.sh
455 SCRIPT_SH += git-mergetool.sh
456 SCRIPT_SH += git-pull.sh
457 SCRIPT_SH += git-quiltimport.sh
458 SCRIPT_SH += git-rebase.sh
459 SCRIPT_SH += git-repack.sh
460 SCRIPT_SH += git-request-pull.sh
461 SCRIPT_SH += git-stash.sh
462 SCRIPT_SH += git-submodule.sh
463 SCRIPT_SH += git-web--browse.sh
464
465 SCRIPT_LIB += git-mergetool--lib
466 SCRIPT_LIB += git-parse-remote
467 SCRIPT_LIB += git-rebase--am
468 SCRIPT_LIB += git-rebase--interactive
469 SCRIPT_LIB += git-rebase--merge
470 SCRIPT_LIB += git-sh-setup
471 SCRIPT_LIB += git-sh-i18n
472
473 SCRIPT_PERL += git-add--interactive.perl
474 SCRIPT_PERL += git-difftool.perl
475 SCRIPT_PERL += git-archimport.perl
476 SCRIPT_PERL += git-cvsexportcommit.perl
477 SCRIPT_PERL += git-cvsimport.perl
478 SCRIPT_PERL += git-cvsserver.perl
479 SCRIPT_PERL += git-relink.perl
480 SCRIPT_PERL += git-send-email.perl
481 SCRIPT_PERL += git-svn.perl
482
483 SCRIPT_PYTHON += git-remote-testpy.py
484 SCRIPT_PYTHON += git-p4.py
485
486 # Generated files for scripts
487 SCRIPT_SH_GEN = $(patsubst %.sh,%,$(SCRIPT_SH))
488 SCRIPT_PERL_GEN = $(patsubst %.perl,%,$(SCRIPT_PERL))
489 SCRIPT_PYTHON_GEN = $(patsubst %.py,%,$(SCRIPT_PYTHON))
490
491 # Individual rules to allow e.g.
492 # "make -C ../.. SCRIPT_PERL=contrib/foo/bar.perl build-perl-script"
493 # from subdirectories like contrib/*/
494 .PHONY: build-perl-script build-sh-script build-python-script
495 build-perl-script: $(SCRIPT_PERL_GEN)
496 build-sh-script: $(SCRIPT_SH_GEN)
497 build-python-script: $(SCRIPT_PYTHON_GEN)
498
499 .PHONY: install-perl-script install-sh-script install-python-script
500 install-sh-script: $(SCRIPT_SH_GEN)
501         $(INSTALL) $(SCRIPT_SH_GEN) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
502 install-perl-script: $(SCRIPT_PERL_GEN)
503         $(INSTALL) $(SCRIPT_PERL_GEN) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
504 install-python-script: $(SCRIPT_PYTHON_GEN)
505         $(INSTALL) $(SCRIPT_PYTHON_GEN) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
506
507 .PHONY: clean-perl-script clean-sh-script clean-python-script
508 clean-sh-script:
509         $(RM) $(SCRIPT_SH_GEN)
510 clean-perl-script:
511         $(RM) $(SCRIPT_PERL_GEN)
512 clean-python-script:
513         $(RM) $(SCRIPT_PYTHON_GEN)
514
515 SCRIPTS = $(SCRIPT_SH_GEN) \
516           $(SCRIPT_PERL_GEN) \
517           $(SCRIPT_PYTHON_GEN) \
518           git-instaweb
519
520 ETAGS_TARGET = TAGS
521
522 # Empty...
523 EXTRA_PROGRAMS =
524
525 # ... and all the rest that could be moved out of bindir to gitexecdir
526 PROGRAMS += $(EXTRA_PROGRAMS)
527
528 PROGRAM_OBJS += credential-store.o
529 PROGRAM_OBJS += daemon.o
530 PROGRAM_OBJS += fast-import.o
531 PROGRAM_OBJS += http-backend.o
532 PROGRAM_OBJS += imap-send.o
533 PROGRAM_OBJS += sh-i18n--envsubst.o
534 PROGRAM_OBJS += shell.o
535 PROGRAM_OBJS += show-index.o
536 PROGRAM_OBJS += upload-pack.o
537 PROGRAM_OBJS += remote-testsvn.o
538
539 # Binary suffix, set to .exe for Windows builds
540 X =
541
542 PROGRAMS += $(patsubst %.o,git-%$X,$(PROGRAM_OBJS))
543
544 TEST_PROGRAMS_NEED_X += test-chmtime
545 TEST_PROGRAMS_NEED_X += test-ctype
546 TEST_PROGRAMS_NEED_X += test-date
547 TEST_PROGRAMS_NEED_X += test-delta
548 TEST_PROGRAMS_NEED_X += test-dump-cache-tree
549 TEST_PROGRAMS_NEED_X += test-genrandom
550 TEST_PROGRAMS_NEED_X += test-index-version
551 TEST_PROGRAMS_NEED_X += test-line-buffer
552 TEST_PROGRAMS_NEED_X += test-match-trees
553 TEST_PROGRAMS_NEED_X += test-mergesort
554 TEST_PROGRAMS_NEED_X += test-mktemp
555 TEST_PROGRAMS_NEED_X += test-parse-options
556 TEST_PROGRAMS_NEED_X += test-path-utils
557 TEST_PROGRAMS_NEED_X += test-regex
558 TEST_PROGRAMS_NEED_X += test-revision-walking
559 TEST_PROGRAMS_NEED_X += test-run-command
560 TEST_PROGRAMS_NEED_X += test-scrap-cache-tree
561 TEST_PROGRAMS_NEED_X += test-sha1
562 TEST_PROGRAMS_NEED_X += test-sigchain
563 TEST_PROGRAMS_NEED_X += test-string-list
564 TEST_PROGRAMS_NEED_X += test-subprocess
565 TEST_PROGRAMS_NEED_X += test-svn-fe
566 TEST_PROGRAMS_NEED_X += test-wildmatch
567
568 TEST_PROGRAMS = $(patsubst %,%$X,$(TEST_PROGRAMS_NEED_X))
569
570 # List built-in command $C whose implementation cmd_$C() is not in
571 # builtin/$C.o but is linked in as part of some other command.
572 BUILT_INS += $(patsubst builtin/%.o,git-%$X,$(BUILTIN_OBJS))
573
574 BUILT_INS += git-cherry$X
575 BUILT_INS += git-cherry-pick$X
576 BUILT_INS += git-format-patch$X
577 BUILT_INS += git-fsck-objects$X
578 BUILT_INS += git-get-tar-commit-id$X
579 BUILT_INS += git-init$X
580 BUILT_INS += git-merge-subtree$X
581 BUILT_INS += git-peek-remote$X
582 BUILT_INS += git-repo-config$X
583 BUILT_INS += git-show$X
584 BUILT_INS += git-stage$X
585 BUILT_INS += git-status$X
586 BUILT_INS += git-whatchanged$X
587
588 # what 'all' will build and 'install' will install in gitexecdir,
589 # excluding programs for built-in commands
590 ALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS)
591
592 # what 'all' will build but not install in gitexecdir
593 OTHER_PROGRAMS = git$X
594
595 # what test wrappers are needed and 'install' will install, in bindir
596 BINDIR_PROGRAMS_NEED_X += git
597 BINDIR_PROGRAMS_NEED_X += git-upload-pack
598 BINDIR_PROGRAMS_NEED_X += git-receive-pack
599 BINDIR_PROGRAMS_NEED_X += git-upload-archive
600 BINDIR_PROGRAMS_NEED_X += git-shell
601
602 BINDIR_PROGRAMS_NO_X += git-cvsserver
603
604 # Set paths to tools early so that they can be used for version tests.
605 ifndef SHELL_PATH
606         SHELL_PATH = /bin/sh
607 endif
608 ifndef PERL_PATH
609         PERL_PATH = /usr/bin/perl
610 endif
611 ifndef PYTHON_PATH
612         PYTHON_PATH = /usr/bin/python
613 endif
614
615 export PERL_PATH
616 export PYTHON_PATH
617
618 LIB_FILE = libgit.a
619 XDIFF_LIB = xdiff/lib.a
620 VCSSVN_LIB = vcs-svn/lib.a
621
622 LIB_H += xdiff/xinclude.h
623 LIB_H += xdiff/xmacros.h
624 LIB_H += xdiff/xdiff.h
625 LIB_H += xdiff/xtypes.h
626 LIB_H += xdiff/xutils.h
627 LIB_H += xdiff/xprepare.h
628 LIB_H += xdiff/xdiffi.h
629 LIB_H += xdiff/xemit.h
630
631 LIB_H += vcs-svn/line_buffer.h
632 LIB_H += vcs-svn/sliding_window.h
633 LIB_H += vcs-svn/repo_tree.h
634 LIB_H += vcs-svn/fast_export.h
635 LIB_H += vcs-svn/svndiff.h
636 LIB_H += vcs-svn/svndump.h
637
638 GENERATED_H += common-cmds.h
639
640 LIB_H += advice.h
641 LIB_H += archive.h
642 LIB_H += argv-array.h
643 LIB_H += attr.h
644 LIB_H += bisect.h
645 LIB_H += blob.h
646 LIB_H += branch.h
647 LIB_H += builtin.h
648 LIB_H += bulk-checkin.h
649 LIB_H += bundle.h
650 LIB_H += cache-tree.h
651 LIB_H += cache.h
652 LIB_H += color.h
653 LIB_H += column.h
654 LIB_H += commit.h
655 LIB_H += compat/bswap.h
656 LIB_H += compat/cygwin.h
657 LIB_H += compat/mingw.h
658 LIB_H += compat/obstack.h
659 LIB_H += compat/poll/poll.h
660 LIB_H += compat/precompose_utf8.h
661 LIB_H += compat/terminal.h
662 LIB_H += compat/win32/dirent.h
663 LIB_H += compat/win32/pthread.h
664 LIB_H += compat/win32/syslog.h
665 LIB_H += connected.h
666 LIB_H += convert.h
667 LIB_H += credential.h
668 LIB_H += csum-file.h
669 LIB_H += decorate.h
670 LIB_H += delta.h
671 LIB_H += diff.h
672 LIB_H += diffcore.h
673 LIB_H += dir.h
674 LIB_H += exec_cmd.h
675 LIB_H += fetch-pack.h
676 LIB_H += fmt-merge-msg.h
677 LIB_H += fsck.h
678 LIB_H += gettext.h
679 LIB_H += git-compat-util.h
680 LIB_H += gpg-interface.h
681 LIB_H += graph.h
682 LIB_H += grep.h
683 LIB_H += hash.h
684 LIB_H += help.h
685 LIB_H += http.h
686 LIB_H += kwset.h
687 LIB_H += levenshtein.h
688 LIB_H += list-objects.h
689 LIB_H += ll-merge.h
690 LIB_H += log-tree.h
691 LIB_H += mailmap.h
692 LIB_H += merge-blobs.h
693 LIB_H += merge-recursive.h
694 LIB_H += mergesort.h
695 LIB_H += notes-cache.h
696 LIB_H += notes-merge.h
697 LIB_H += notes.h
698 LIB_H += object.h
699 LIB_H += pack-refs.h
700 LIB_H += pack-revindex.h
701 LIB_H += pack.h
702 LIB_H += parse-options.h
703 LIB_H += patch-ids.h
704 LIB_H += pathspec.h
705 LIB_H += pkt-line.h
706 LIB_H += progress.h
707 LIB_H += prompt.h
708 LIB_H += quote.h
709 LIB_H += reachable.h
710 LIB_H += reflog-walk.h
711 LIB_H += refs.h
712 LIB_H += remote.h
713 LIB_H += rerere.h
714 LIB_H += resolve-undo.h
715 LIB_H += revision.h
716 LIB_H += run-command.h
717 LIB_H += send-pack.h
718 LIB_H += sequencer.h
719 LIB_H += sha1-array.h
720 LIB_H += sha1-lookup.h
721 LIB_H += shortlog.h
722 LIB_H += sideband.h
723 LIB_H += sigchain.h
724 LIB_H += strbuf.h
725 LIB_H += streaming.h
726 LIB_H += string-list.h
727 LIB_H += submodule.h
728 LIB_H += tag.h
729 LIB_H += tar.h
730 LIB_H += thread-utils.h
731 LIB_H += transport.h
732 LIB_H += tree-walk.h
733 LIB_H += tree.h
734 LIB_H += unpack-trees.h
735 LIB_H += url.h
736 LIB_H += userdiff.h
737 LIB_H += utf8.h
738 LIB_H += varint.h
739 LIB_H += walker.h
740 LIB_H += wildmatch.h
741 LIB_H += wt-status.h
742 LIB_H += xdiff-interface.h
743 LIB_H += xdiff/xdiff.h
744
745 LIB_OBJS += abspath.o
746 LIB_OBJS += advice.o
747 LIB_OBJS += alias.o
748 LIB_OBJS += alloc.o
749 LIB_OBJS += archive.o
750 LIB_OBJS += archive-tar.o
751 LIB_OBJS += archive-zip.o
752 LIB_OBJS += argv-array.o
753 LIB_OBJS += attr.o
754 LIB_OBJS += base85.o
755 LIB_OBJS += bisect.o
756 LIB_OBJS += blob.o
757 LIB_OBJS += branch.o
758 LIB_OBJS += bulk-checkin.o
759 LIB_OBJS += bundle.o
760 LIB_OBJS += cache-tree.o
761 LIB_OBJS += color.o
762 LIB_OBJS += column.o
763 LIB_OBJS += combine-diff.o
764 LIB_OBJS += commit.o
765 LIB_OBJS += compat/obstack.o
766 LIB_OBJS += compat/terminal.o
767 LIB_OBJS += config.o
768 LIB_OBJS += connect.o
769 LIB_OBJS += connected.o
770 LIB_OBJS += convert.o
771 LIB_OBJS += copy.o
772 LIB_OBJS += credential.o
773 LIB_OBJS += csum-file.o
774 LIB_OBJS += ctype.o
775 LIB_OBJS += date.o
776 LIB_OBJS += decorate.o
777 LIB_OBJS += diffcore-break.o
778 LIB_OBJS += diffcore-delta.o
779 LIB_OBJS += diffcore-order.o
780 LIB_OBJS += diffcore-pickaxe.o
781 LIB_OBJS += diffcore-rename.o
782 LIB_OBJS += diff-delta.o
783 LIB_OBJS += diff-lib.o
784 LIB_OBJS += diff-no-index.o
785 LIB_OBJS += diff.o
786 LIB_OBJS += dir.o
787 LIB_OBJS += editor.o
788 LIB_OBJS += entry.o
789 LIB_OBJS += environment.o
790 LIB_OBJS += exec_cmd.o
791 LIB_OBJS += fetch-pack.o
792 LIB_OBJS += fsck.o
793 LIB_OBJS += gettext.o
794 LIB_OBJS += gpg-interface.o
795 LIB_OBJS += graph.o
796 LIB_OBJS += grep.o
797 LIB_OBJS += hash.o
798 LIB_OBJS += help.o
799 LIB_OBJS += hex.o
800 LIB_OBJS += ident.o
801 LIB_OBJS += kwset.o
802 LIB_OBJS += levenshtein.o
803 LIB_OBJS += list-objects.o
804 LIB_OBJS += ll-merge.o
805 LIB_OBJS += lockfile.o
806 LIB_OBJS += log-tree.o
807 LIB_OBJS += mailmap.o
808 LIB_OBJS += match-trees.o
809 LIB_OBJS += merge.o
810 LIB_OBJS += merge-blobs.o
811 LIB_OBJS += merge-recursive.o
812 LIB_OBJS += mergesort.o
813 LIB_OBJS += name-hash.o
814 LIB_OBJS += notes.o
815 LIB_OBJS += notes-cache.o
816 LIB_OBJS += notes-merge.o
817 LIB_OBJS += object.o
818 LIB_OBJS += pack-check.o
819 LIB_OBJS += pack-refs.o
820 LIB_OBJS += pack-revindex.o
821 LIB_OBJS += pack-write.o
822 LIB_OBJS += pager.o
823 LIB_OBJS += parse-options.o
824 LIB_OBJS += parse-options-cb.o
825 LIB_OBJS += patch-delta.o
826 LIB_OBJS += patch-ids.o
827 LIB_OBJS += path.o
828 LIB_OBJS += pathspec.o
829 LIB_OBJS += pkt-line.o
830 LIB_OBJS += preload-index.o
831 LIB_OBJS += pretty.o
832 LIB_OBJS += progress.o
833 LIB_OBJS += prompt.o
834 LIB_OBJS += quote.o
835 LIB_OBJS += reachable.o
836 LIB_OBJS += read-cache.o
837 LIB_OBJS += reflog-walk.o
838 LIB_OBJS += refs.o
839 LIB_OBJS += remote.o
840 LIB_OBJS += replace_object.o
841 LIB_OBJS += rerere.o
842 LIB_OBJS += resolve-undo.o
843 LIB_OBJS += revision.o
844 LIB_OBJS += run-command.o
845 LIB_OBJS += send-pack.o
846 LIB_OBJS += sequencer.o
847 LIB_OBJS += server-info.o
848 LIB_OBJS += setup.o
849 LIB_OBJS += sha1-array.o
850 LIB_OBJS += sha1-lookup.o
851 LIB_OBJS += sha1_file.o
852 LIB_OBJS += sha1_name.o
853 LIB_OBJS += shallow.o
854 LIB_OBJS += sideband.o
855 LIB_OBJS += sigchain.o
856 LIB_OBJS += strbuf.o
857 LIB_OBJS += streaming.o
858 LIB_OBJS += string-list.o
859 LIB_OBJS += submodule.o
860 LIB_OBJS += symlinks.o
861 LIB_OBJS += tag.o
862 LIB_OBJS += trace.o
863 LIB_OBJS += transport.o
864 LIB_OBJS += transport-helper.o
865 LIB_OBJS += tree-diff.o
866 LIB_OBJS += tree.o
867 LIB_OBJS += tree-walk.o
868 LIB_OBJS += unpack-trees.o
869 LIB_OBJS += url.o
870 LIB_OBJS += usage.o
871 LIB_OBJS += userdiff.o
872 LIB_OBJS += utf8.o
873 LIB_OBJS += varint.o
874 LIB_OBJS += version.o
875 LIB_OBJS += walker.o
876 LIB_OBJS += wildmatch.o
877 LIB_OBJS += wrapper.o
878 LIB_OBJS += write_or_die.o
879 LIB_OBJS += ws.o
880 LIB_OBJS += wt-status.o
881 LIB_OBJS += xdiff-interface.o
882 LIB_OBJS += zlib.o
883
884 BUILTIN_OBJS += builtin/add.o
885 BUILTIN_OBJS += builtin/annotate.o
886 BUILTIN_OBJS += builtin/apply.o
887 BUILTIN_OBJS += builtin/archive.o
888 BUILTIN_OBJS += builtin/bisect--helper.o
889 BUILTIN_OBJS += builtin/blame.o
890 BUILTIN_OBJS += builtin/branch.o
891 BUILTIN_OBJS += builtin/bundle.o
892 BUILTIN_OBJS += builtin/cat-file.o
893 BUILTIN_OBJS += builtin/check-attr.o
894 BUILTIN_OBJS += builtin/check-ignore.o
895 BUILTIN_OBJS += builtin/check-ref-format.o
896 BUILTIN_OBJS += builtin/checkout-index.o
897 BUILTIN_OBJS += builtin/checkout.o
898 BUILTIN_OBJS += builtin/clean.o
899 BUILTIN_OBJS += builtin/clone.o
900 BUILTIN_OBJS += builtin/column.o
901 BUILTIN_OBJS += builtin/commit-tree.o
902 BUILTIN_OBJS += builtin/commit.o
903 BUILTIN_OBJS += builtin/config.o
904 BUILTIN_OBJS += builtin/count-objects.o
905 BUILTIN_OBJS += builtin/credential.o
906 BUILTIN_OBJS += builtin/describe.o
907 BUILTIN_OBJS += builtin/diff-files.o
908 BUILTIN_OBJS += builtin/diff-index.o
909 BUILTIN_OBJS += builtin/diff-tree.o
910 BUILTIN_OBJS += builtin/diff.o
911 BUILTIN_OBJS += builtin/fast-export.o
912 BUILTIN_OBJS += builtin/fetch-pack.o
913 BUILTIN_OBJS += builtin/fetch.o
914 BUILTIN_OBJS += builtin/fmt-merge-msg.o
915 BUILTIN_OBJS += builtin/for-each-ref.o
916 BUILTIN_OBJS += builtin/fsck.o
917 BUILTIN_OBJS += builtin/gc.o
918 BUILTIN_OBJS += builtin/grep.o
919 BUILTIN_OBJS += builtin/hash-object.o
920 BUILTIN_OBJS += builtin/help.o
921 BUILTIN_OBJS += builtin/index-pack.o
922 BUILTIN_OBJS += builtin/init-db.o
923 BUILTIN_OBJS += builtin/log.o
924 BUILTIN_OBJS += builtin/ls-files.o
925 BUILTIN_OBJS += builtin/ls-remote.o
926 BUILTIN_OBJS += builtin/ls-tree.o
927 BUILTIN_OBJS += builtin/mailinfo.o
928 BUILTIN_OBJS += builtin/mailsplit.o
929 BUILTIN_OBJS += builtin/merge.o
930 BUILTIN_OBJS += builtin/merge-base.o
931 BUILTIN_OBJS += builtin/merge-file.o
932 BUILTIN_OBJS += builtin/merge-index.o
933 BUILTIN_OBJS += builtin/merge-ours.o
934 BUILTIN_OBJS += builtin/merge-recursive.o
935 BUILTIN_OBJS += builtin/merge-tree.o
936 BUILTIN_OBJS += builtin/mktag.o
937 BUILTIN_OBJS += builtin/mktree.o
938 BUILTIN_OBJS += builtin/mv.o
939 BUILTIN_OBJS += builtin/name-rev.o
940 BUILTIN_OBJS += builtin/notes.o
941 BUILTIN_OBJS += builtin/pack-objects.o
942 BUILTIN_OBJS += builtin/pack-redundant.o
943 BUILTIN_OBJS += builtin/pack-refs.o
944 BUILTIN_OBJS += builtin/patch-id.o
945 BUILTIN_OBJS += builtin/prune-packed.o
946 BUILTIN_OBJS += builtin/prune.o
947 BUILTIN_OBJS += builtin/push.o
948 BUILTIN_OBJS += builtin/read-tree.o
949 BUILTIN_OBJS += builtin/receive-pack.o
950 BUILTIN_OBJS += builtin/reflog.o
951 BUILTIN_OBJS += builtin/remote.o
952 BUILTIN_OBJS += builtin/remote-ext.o
953 BUILTIN_OBJS += builtin/remote-fd.o
954 BUILTIN_OBJS += builtin/replace.o
955 BUILTIN_OBJS += builtin/rerere.o
956 BUILTIN_OBJS += builtin/reset.o
957 BUILTIN_OBJS += builtin/rev-list.o
958 BUILTIN_OBJS += builtin/rev-parse.o
959 BUILTIN_OBJS += builtin/revert.o
960 BUILTIN_OBJS += builtin/rm.o
961 BUILTIN_OBJS += builtin/send-pack.o
962 BUILTIN_OBJS += builtin/shortlog.o
963 BUILTIN_OBJS += builtin/show-branch.o
964 BUILTIN_OBJS += builtin/show-ref.o
965 BUILTIN_OBJS += builtin/stripspace.o
966 BUILTIN_OBJS += builtin/symbolic-ref.o
967 BUILTIN_OBJS += builtin/tag.o
968 BUILTIN_OBJS += builtin/tar-tree.o
969 BUILTIN_OBJS += builtin/unpack-file.o
970 BUILTIN_OBJS += builtin/unpack-objects.o
971 BUILTIN_OBJS += builtin/update-index.o
972 BUILTIN_OBJS += builtin/update-ref.o
973 BUILTIN_OBJS += builtin/update-server-info.o
974 BUILTIN_OBJS += builtin/upload-archive.o
975 BUILTIN_OBJS += builtin/var.o
976 BUILTIN_OBJS += builtin/verify-pack.o
977 BUILTIN_OBJS += builtin/verify-tag.o
978 BUILTIN_OBJS += builtin/write-tree.o
979
980 GITLIBS = $(LIB_FILE) $(XDIFF_LIB)
981 EXTLIBS =
982
983 GIT_USER_AGENT = git/$(GIT_VERSION)
984
985 include config.mak.uname
986 -include config.mak.autogen
987 -include config.mak
988
989 ifndef sysconfdir
990 ifeq ($(prefix),/usr)
991 sysconfdir = /etc
992 else
993 sysconfdir = etc
994 endif
995 endif
996
997 ifdef CHECK_HEADER_DEPENDENCIES
998 COMPUTE_HEADER_DEPENDENCIES = no
999 USE_COMPUTED_HEADER_DEPENDENCIES =
1000 endif
1001
1002 ifndef COMPUTE_HEADER_DEPENDENCIES
1003 COMPUTE_HEADER_DEPENDENCIES = auto
1004 endif
1005
1006 ifeq ($(COMPUTE_HEADER_DEPENDENCIES),auto)
1007 dep_check = $(shell $(CC) $(ALL_CFLAGS) \
1008         -c -MF /dev/null -MQ /dev/null -MMD -MP \
1009         -x c /dev/null -o /dev/null 2>&1; \
1010         echo $$?)
1011 ifeq ($(dep_check),0)
1012 override COMPUTE_HEADER_DEPENDENCIES = yes
1013 else
1014 override COMPUTE_HEADER_DEPENDENCIES = no
1015 endif
1016 endif
1017
1018 ifeq ($(COMPUTE_HEADER_DEPENDENCIES),yes)
1019 USE_COMPUTED_HEADER_DEPENDENCIES = YesPlease
1020 else
1021 ifneq ($(COMPUTE_HEADER_DEPENDENCIES),no)
1022 $(error please set COMPUTE_HEADER_DEPENDENCIES to yes, no, or auto \
1023 (not "$(COMPUTE_HEADER_DEPENDENCIES)"))
1024 endif
1025 endif
1026
1027 ifdef SANE_TOOL_PATH
1028 SANE_TOOL_PATH_SQ = $(subst ','\'',$(SANE_TOOL_PATH))
1029 BROKEN_PATH_FIX = 's|^\# @@BROKEN_PATH_FIX@@$$|git_broken_path_fix $(SANE_TOOL_PATH_SQ)|'
1030 PATH := $(SANE_TOOL_PATH):${PATH}
1031 else
1032 BROKEN_PATH_FIX = '/^\# @@BROKEN_PATH_FIX@@$$/d'
1033 endif
1034
1035 ifneq (,$(INLINE))
1036         BASIC_CFLAGS += -Dinline=$(INLINE)
1037 endif
1038
1039 ifneq (,$(SOCKLEN_T))
1040         BASIC_CFLAGS += -Dsocklen_t=$(SOCKLEN_T)
1041 endif
1042
1043 ifeq ($(uname_S),Darwin)
1044         ifndef NO_FINK
1045                 ifeq ($(shell test -d /sw/lib && echo y),y)
1046                         BASIC_CFLAGS += -I/sw/include
1047                         BASIC_LDFLAGS += -L/sw/lib
1048                 endif
1049         endif
1050         ifndef NO_DARWIN_PORTS
1051                 ifeq ($(shell test -d /opt/local/lib && echo y),y)
1052                         BASIC_CFLAGS += -I/opt/local/include
1053                         BASIC_LDFLAGS += -L/opt/local/lib
1054                 endif
1055         endif
1056         PTHREAD_LIBS =
1057 endif
1058
1059 ifndef CC_LD_DYNPATH
1060         ifdef NO_R_TO_GCC_LINKER
1061                 # Some gcc does not accept and pass -R to the linker to specify
1062                 # the runtime dynamic library path.
1063                 CC_LD_DYNPATH = -Wl,-rpath,
1064         else
1065                 CC_LD_DYNPATH = -R
1066         endif
1067 endif
1068
1069 ifdef NO_LIBGEN_H
1070         COMPAT_CFLAGS += -DNO_LIBGEN_H
1071         COMPAT_OBJS += compat/basename.o
1072 endif
1073
1074 ifdef USE_LIBPCRE
1075         BASIC_CFLAGS += -DUSE_LIBPCRE
1076         ifdef LIBPCREDIR
1077                 BASIC_CFLAGS += -I$(LIBPCREDIR)/include
1078                 EXTLIBS += -L$(LIBPCREDIR)/$(lib) $(CC_LD_DYNPATH)$(LIBPCREDIR)/$(lib)
1079         endif
1080         EXTLIBS += -lpcre
1081 endif
1082
1083 ifdef NO_CURL
1084         BASIC_CFLAGS += -DNO_CURL
1085         REMOTE_CURL_PRIMARY =
1086         REMOTE_CURL_ALIASES =
1087         REMOTE_CURL_NAMES =
1088 else
1089         ifdef CURLDIR
1090                 # Try "-Wl,-rpath=$(CURLDIR)/$(lib)" in such a case.
1091                 BASIC_CFLAGS += -I$(CURLDIR)/include
1092                 CURL_LIBCURL = -L$(CURLDIR)/$(lib) $(CC_LD_DYNPATH)$(CURLDIR)/$(lib) -lcurl
1093         else
1094                 CURL_LIBCURL = -lcurl
1095         endif
1096         ifdef NEEDS_SSL_WITH_CURL
1097                 CURL_LIBCURL += -lssl
1098                 ifdef NEEDS_CRYPTO_WITH_SSL
1099                         CURL_LIBCURL += -lcrypto
1100                 endif
1101         endif
1102         ifdef NEEDS_IDN_WITH_CURL
1103                 CURL_LIBCURL += -lidn
1104         endif
1105
1106         REMOTE_CURL_PRIMARY = git-remote-http$X
1107         REMOTE_CURL_ALIASES = git-remote-https$X git-remote-ftp$X git-remote-ftps$X
1108         REMOTE_CURL_NAMES = $(REMOTE_CURL_PRIMARY) $(REMOTE_CURL_ALIASES)
1109         PROGRAM_OBJS += http-fetch.o
1110         PROGRAMS += $(REMOTE_CURL_NAMES)
1111         curl_check := $(shell (echo 070908; curl-config --vernum) 2>/dev/null | sort -r | sed -ne 2p)
1112         ifeq "$(curl_check)" "070908"
1113                 ifndef NO_EXPAT
1114                         PROGRAM_OBJS += http-push.o
1115                 endif
1116         endif
1117         ifndef NO_EXPAT
1118                 ifdef EXPATDIR
1119                         BASIC_CFLAGS += -I$(EXPATDIR)/include
1120                         EXPAT_LIBEXPAT = -L$(EXPATDIR)/$(lib) $(CC_LD_DYNPATH)$(EXPATDIR)/$(lib) -lexpat
1121                 else
1122                         EXPAT_LIBEXPAT = -lexpat
1123                 endif
1124                 ifdef EXPAT_NEEDS_XMLPARSE_H
1125                         BASIC_CFLAGS += -DEXPAT_NEEDS_XMLPARSE_H
1126                 endif
1127         endif
1128 endif
1129
1130 ifdef ZLIB_PATH
1131         BASIC_CFLAGS += -I$(ZLIB_PATH)/include
1132         EXTLIBS += -L$(ZLIB_PATH)/$(lib) $(CC_LD_DYNPATH)$(ZLIB_PATH)/$(lib)
1133 endif
1134 EXTLIBS += -lz
1135
1136 ifndef NO_OPENSSL
1137         OPENSSL_LIBSSL = -lssl
1138         ifdef OPENSSLDIR
1139                 BASIC_CFLAGS += -I$(OPENSSLDIR)/include
1140                 OPENSSL_LINK = -L$(OPENSSLDIR)/$(lib) $(CC_LD_DYNPATH)$(OPENSSLDIR)/$(lib)
1141         else
1142                 OPENSSL_LINK =
1143         endif
1144         ifdef NEEDS_CRYPTO_WITH_SSL
1145                 OPENSSL_LIBSSL += -lcrypto
1146         endif
1147 else
1148         BASIC_CFLAGS += -DNO_OPENSSL
1149         BLK_SHA1 = 1
1150         OPENSSL_LIBSSL =
1151 endif
1152 ifdef NO_OPENSSL
1153         LIB_4_CRYPTO =
1154 else
1155 ifdef NEEDS_SSL_WITH_CRYPTO
1156         LIB_4_CRYPTO = $(OPENSSL_LINK) -lcrypto -lssl
1157 else
1158         LIB_4_CRYPTO = $(OPENSSL_LINK) -lcrypto
1159 endif
1160 endif
1161 ifdef NEEDS_LIBICONV
1162         ifdef ICONVDIR
1163                 BASIC_CFLAGS += -I$(ICONVDIR)/include
1164                 ICONV_LINK = -L$(ICONVDIR)/$(lib) $(CC_LD_DYNPATH)$(ICONVDIR)/$(lib)
1165         else
1166                 ICONV_LINK =
1167         endif
1168         ifdef NEEDS_LIBINTL_BEFORE_LIBICONV
1169                 ICONV_LINK += -lintl
1170         endif
1171         EXTLIBS += $(ICONV_LINK) -liconv
1172 endif
1173 ifdef NEEDS_LIBGEN
1174         EXTLIBS += -lgen
1175 endif
1176 ifndef NO_GETTEXT
1177 ifndef LIBC_CONTAINS_LIBINTL
1178         EXTLIBS += -lintl
1179 endif
1180 endif
1181 ifdef NEEDS_SOCKET
1182         EXTLIBS += -lsocket
1183 endif
1184 ifdef NEEDS_NSL
1185         EXTLIBS += -lnsl
1186 endif
1187 ifdef NEEDS_RESOLV
1188         EXTLIBS += -lresolv
1189 endif
1190 ifdef NO_D_TYPE_IN_DIRENT
1191         BASIC_CFLAGS += -DNO_D_TYPE_IN_DIRENT
1192 endif
1193 ifdef NO_D_INO_IN_DIRENT
1194         BASIC_CFLAGS += -DNO_D_INO_IN_DIRENT
1195 endif
1196 ifdef NO_GECOS_IN_PWENT
1197         BASIC_CFLAGS += -DNO_GECOS_IN_PWENT
1198 endif
1199 ifdef NO_ST_BLOCKS_IN_STRUCT_STAT
1200         BASIC_CFLAGS += -DNO_ST_BLOCKS_IN_STRUCT_STAT
1201 endif
1202 ifdef USE_NSEC
1203         BASIC_CFLAGS += -DUSE_NSEC
1204 endif
1205 ifdef USE_ST_TIMESPEC
1206         BASIC_CFLAGS += -DUSE_ST_TIMESPEC
1207 endif
1208 ifdef NO_NORETURN
1209         BASIC_CFLAGS += -DNO_NORETURN
1210 endif
1211 ifdef NO_NSEC
1212         BASIC_CFLAGS += -DNO_NSEC
1213 endif
1214 ifdef SNPRINTF_RETURNS_BOGUS
1215         COMPAT_CFLAGS += -DSNPRINTF_RETURNS_BOGUS
1216         COMPAT_OBJS += compat/snprintf.o
1217 endif
1218 ifdef FREAD_READS_DIRECTORIES
1219         COMPAT_CFLAGS += -DFREAD_READS_DIRECTORIES
1220         COMPAT_OBJS += compat/fopen.o
1221 endif
1222 ifdef NO_SYMLINK_HEAD
1223         BASIC_CFLAGS += -DNO_SYMLINK_HEAD
1224 endif
1225 ifdef GETTEXT_POISON
1226         BASIC_CFLAGS += -DGETTEXT_POISON
1227 endif
1228 ifdef NO_GETTEXT
1229         BASIC_CFLAGS += -DNO_GETTEXT
1230         USE_GETTEXT_SCHEME ?= fallthrough
1231 endif
1232 ifdef NO_POLL
1233         NO_SYS_POLL_H = YesPlease
1234         COMPAT_CFLAGS += -DNO_POLL -Icompat/poll
1235         COMPAT_OBJS += compat/poll/poll.o
1236 endif
1237 ifdef NO_STRCASESTR
1238         COMPAT_CFLAGS += -DNO_STRCASESTR
1239         COMPAT_OBJS += compat/strcasestr.o
1240 endif
1241 ifdef NO_STRLCPY
1242         COMPAT_CFLAGS += -DNO_STRLCPY
1243         COMPAT_OBJS += compat/strlcpy.o
1244 endif
1245 ifdef NO_STRTOUMAX
1246         COMPAT_CFLAGS += -DNO_STRTOUMAX
1247         COMPAT_OBJS += compat/strtoumax.o compat/strtoimax.o
1248 endif
1249 ifdef NO_STRTOULL
1250         COMPAT_CFLAGS += -DNO_STRTOULL
1251 endif
1252 ifdef NO_STRTOK_R
1253         COMPAT_CFLAGS += -DNO_STRTOK_R
1254         COMPAT_OBJS += compat/strtok_r.o
1255 endif
1256 ifdef NO_FNMATCH
1257         COMPAT_CFLAGS += -Icompat/fnmatch
1258         COMPAT_CFLAGS += -DNO_FNMATCH
1259         COMPAT_OBJS += compat/fnmatch/fnmatch.o
1260 else
1261 ifdef NO_FNMATCH_CASEFOLD
1262         COMPAT_CFLAGS += -Icompat/fnmatch
1263         COMPAT_CFLAGS += -DNO_FNMATCH_CASEFOLD
1264         COMPAT_OBJS += compat/fnmatch/fnmatch.o
1265 endif
1266 endif
1267 ifdef USE_WILDMATCH
1268         COMPAT_CFLAGS += -DUSE_WILDMATCH
1269 endif
1270 ifdef NO_SETENV
1271         COMPAT_CFLAGS += -DNO_SETENV
1272         COMPAT_OBJS += compat/setenv.o
1273 endif
1274 ifdef NO_MKDTEMP
1275         COMPAT_CFLAGS += -DNO_MKDTEMP
1276         COMPAT_OBJS += compat/mkdtemp.o
1277 endif
1278 ifdef MKDIR_WO_TRAILING_SLASH
1279         COMPAT_CFLAGS += -DMKDIR_WO_TRAILING_SLASH
1280         COMPAT_OBJS += compat/mkdir.o
1281 endif
1282 ifdef NO_MKSTEMPS
1283         COMPAT_CFLAGS += -DNO_MKSTEMPS
1284 endif
1285 ifdef NO_UNSETENV
1286         COMPAT_CFLAGS += -DNO_UNSETENV
1287         COMPAT_OBJS += compat/unsetenv.o
1288 endif
1289 ifdef NO_SYS_SELECT_H
1290         BASIC_CFLAGS += -DNO_SYS_SELECT_H
1291 endif
1292 ifdef NO_SYS_POLL_H
1293         BASIC_CFLAGS += -DNO_SYS_POLL_H
1294 endif
1295 ifdef NEEDS_SYS_PARAM_H
1296         BASIC_CFLAGS += -DNEEDS_SYS_PARAM_H
1297 endif
1298 ifdef NO_INTTYPES_H
1299         BASIC_CFLAGS += -DNO_INTTYPES_H
1300 endif
1301 ifdef NO_INITGROUPS
1302         BASIC_CFLAGS += -DNO_INITGROUPS
1303 endif
1304 ifdef NO_MMAP
1305         COMPAT_CFLAGS += -DNO_MMAP
1306         COMPAT_OBJS += compat/mmap.o
1307 else
1308         ifdef USE_WIN32_MMAP
1309                 COMPAT_CFLAGS += -DUSE_WIN32_MMAP
1310                 COMPAT_OBJS += compat/win32mmap.o
1311         endif
1312 endif
1313 ifdef OBJECT_CREATION_USES_RENAMES
1314         COMPAT_CFLAGS += -DOBJECT_CREATION_MODE=1
1315 endif
1316 ifdef NO_STRUCT_ITIMERVAL
1317         COMPAT_CFLAGS += -DNO_STRUCT_ITIMERVAL
1318         NO_SETITIMER = YesPlease
1319 endif
1320 ifdef NO_SETITIMER
1321         COMPAT_CFLAGS += -DNO_SETITIMER
1322 endif
1323 ifdef NO_PREAD
1324         COMPAT_CFLAGS += -DNO_PREAD
1325         COMPAT_OBJS += compat/pread.o
1326         NO_THREAD_SAFE_PREAD = YesPlease
1327 endif
1328 ifdef NO_THREAD_SAFE_PREAD
1329         BASIC_CFLAGS += -DNO_THREAD_SAFE_PREAD
1330 endif
1331 ifdef NO_FAST_WORKING_DIRECTORY
1332         BASIC_CFLAGS += -DNO_FAST_WORKING_DIRECTORY
1333 endif
1334 ifdef NO_TRUSTABLE_FILEMODE
1335         BASIC_CFLAGS += -DNO_TRUSTABLE_FILEMODE
1336 endif
1337 ifdef NO_IPV6
1338         BASIC_CFLAGS += -DNO_IPV6
1339 endif
1340 ifdef NO_INTPTR_T
1341         COMPAT_CFLAGS += -DNO_INTPTR_T
1342 endif
1343 ifdef NO_UINTMAX_T
1344         BASIC_CFLAGS += -Duintmax_t=uint32_t
1345 endif
1346 ifdef NO_SOCKADDR_STORAGE
1347 ifdef NO_IPV6
1348         BASIC_CFLAGS += -Dsockaddr_storage=sockaddr_in
1349 else
1350         BASIC_CFLAGS += -Dsockaddr_storage=sockaddr_in6
1351 endif
1352 endif
1353 ifdef NO_INET_NTOP
1354         LIB_OBJS += compat/inet_ntop.o
1355         BASIC_CFLAGS += -DNO_INET_NTOP
1356 endif
1357 ifdef NO_INET_PTON
1358         LIB_OBJS += compat/inet_pton.o
1359         BASIC_CFLAGS += -DNO_INET_PTON
1360 endif
1361 ifndef NO_UNIX_SOCKETS
1362         LIB_OBJS += unix-socket.o
1363         LIB_H += unix-socket.h
1364         PROGRAM_OBJS += credential-cache.o
1365         PROGRAM_OBJS += credential-cache--daemon.o
1366 endif
1367
1368 ifdef NO_ICONV
1369         BASIC_CFLAGS += -DNO_ICONV
1370 endif
1371
1372 ifdef OLD_ICONV
1373         BASIC_CFLAGS += -DOLD_ICONV
1374 endif
1375
1376 ifdef NO_DEFLATE_BOUND
1377         BASIC_CFLAGS += -DNO_DEFLATE_BOUND
1378 endif
1379
1380 ifdef NO_POSIX_GOODIES
1381         BASIC_CFLAGS += -DNO_POSIX_GOODIES
1382 endif
1383
1384 ifdef BLK_SHA1
1385         SHA1_HEADER = "block-sha1/sha1.h"
1386         LIB_OBJS += block-sha1/sha1.o
1387         LIB_H += block-sha1/sha1.h
1388 else
1389 ifdef PPC_SHA1
1390         SHA1_HEADER = "ppc/sha1.h"
1391         LIB_OBJS += ppc/sha1.o ppc/sha1ppc.o
1392         LIB_H += ppc/sha1.h
1393 else
1394         SHA1_HEADER = <openssl/sha.h>
1395         EXTLIBS += $(LIB_4_CRYPTO)
1396 endif
1397 endif
1398 ifdef NO_PERL_MAKEMAKER
1399         export NO_PERL_MAKEMAKER
1400 endif
1401 ifdef NO_HSTRERROR
1402         COMPAT_CFLAGS += -DNO_HSTRERROR
1403         COMPAT_OBJS += compat/hstrerror.o
1404 endif
1405 ifdef NO_MEMMEM
1406         COMPAT_CFLAGS += -DNO_MEMMEM
1407         COMPAT_OBJS += compat/memmem.o
1408 endif
1409 ifdef NO_GETPAGESIZE
1410         COMPAT_CFLAGS += -DNO_GETPAGESIZE
1411 endif
1412 ifdef INTERNAL_QSORT
1413         COMPAT_CFLAGS += -DINTERNAL_QSORT
1414         COMPAT_OBJS += compat/qsort.o
1415 endif
1416 ifdef RUNTIME_PREFIX
1417         COMPAT_CFLAGS += -DRUNTIME_PREFIX
1418 endif
1419
1420 ifdef NO_PTHREADS
1421         BASIC_CFLAGS += -DNO_PTHREADS
1422 else
1423         BASIC_CFLAGS += $(PTHREAD_CFLAGS)
1424         EXTLIBS += $(PTHREAD_LIBS)
1425         LIB_OBJS += thread-utils.o
1426 endif
1427
1428 ifdef HAVE_PATHS_H
1429         BASIC_CFLAGS += -DHAVE_PATHS_H
1430 endif
1431
1432 ifdef HAVE_LIBCHARSET_H
1433         BASIC_CFLAGS += -DHAVE_LIBCHARSET_H
1434         EXTLIBS += $(CHARSET_LIB)
1435 endif
1436
1437 ifdef HAVE_STRINGS_H
1438         BASIC_CFLAGS += -DHAVE_STRINGS_H
1439 endif
1440
1441 ifdef HAVE_DEV_TTY
1442         BASIC_CFLAGS += -DHAVE_DEV_TTY
1443 endif
1444
1445 ifdef DIR_HAS_BSD_GROUP_SEMANTICS
1446         COMPAT_CFLAGS += -DDIR_HAS_BSD_GROUP_SEMANTICS
1447 endif
1448 ifdef UNRELIABLE_FSTAT
1449         BASIC_CFLAGS += -DUNRELIABLE_FSTAT
1450 endif
1451 ifdef NO_REGEX
1452         COMPAT_CFLAGS += -Icompat/regex
1453         COMPAT_OBJS += compat/regex/regex.o
1454 endif
1455 ifdef CYGWIN_V15_WIN32API
1456         COMPAT_CFLAGS += -DCYGWIN_V15_WIN32API
1457 endif
1458
1459 ifdef USE_NED_ALLOCATOR
1460        COMPAT_CFLAGS += -Icompat/nedmalloc
1461        COMPAT_OBJS += compat/nedmalloc/nedmalloc.o
1462 endif
1463
1464 ifdef GIT_TEST_CMP_USE_COPIED_CONTEXT
1465         export GIT_TEST_CMP_USE_COPIED_CONTEXT
1466 endif
1467
1468 ifndef NO_MSGFMT_EXTENDED_OPTIONS
1469         MSGFMT += --check --statistics
1470 endif
1471
1472 ifneq (,$(XDL_FAST_HASH))
1473         BASIC_CFLAGS += -DXDL_FAST_HASH
1474 endif
1475
1476 ifeq ($(TCLTK_PATH),)
1477 NO_TCLTK = NoThanks
1478 endif
1479
1480 ifeq ($(PERL_PATH),)
1481 NO_PERL = NoThanks
1482 endif
1483
1484 ifeq ($(PYTHON_PATH),)
1485 NO_PYTHON = NoThanks
1486 endif
1487
1488 QUIET_SUBDIR0  = +$(MAKE) -C # space to separate -C and subdir
1489 QUIET_SUBDIR1  =
1490
1491 ifneq ($(findstring $(MAKEFLAGS),w),w)
1492 PRINT_DIR = --no-print-directory
1493 else # "make -w"
1494 NO_SUBDIR = :
1495 endif
1496
1497 ifneq ($(findstring $(MAKEFLAGS),s),s)
1498 ifndef V
1499         QUIET_CC       = @echo '   ' CC $@;
1500         QUIET_AR       = @echo '   ' AR $@;
1501         QUIET_LINK     = @echo '   ' LINK $@;
1502         QUIET_BUILT_IN = @echo '   ' BUILTIN $@;
1503         QUIET_GEN      = @echo '   ' GEN $@;
1504         QUIET_LNCP     = @echo '   ' LN/CP $@;
1505         QUIET_XGETTEXT = @echo '   ' XGETTEXT $@;
1506         QUIET_MSGFMT   = @echo '   ' MSGFMT $@;
1507         QUIET_GCOV     = @echo '   ' GCOV $@;
1508         QUIET_SP       = @echo '   ' SP $<;
1509         QUIET_SUBDIR0  = +@subdir=
1510         QUIET_SUBDIR1  = ;$(NO_SUBDIR) echo '   ' SUBDIR $$subdir; \
1511                          $(MAKE) $(PRINT_DIR) -C $$subdir
1512         export V
1513         export QUIET_GEN
1514         export QUIET_BUILT_IN
1515 endif
1516 endif
1517
1518 ifdef NO_INSTALL_HARDLINKS
1519         export NO_INSTALL_HARDLINKS
1520 endif
1521
1522 ### profile feedback build
1523 #
1524
1525 # Can adjust this to be a global directory if you want to do extended
1526 # data gathering
1527 PROFILE_DIR := $(CURDIR)
1528
1529 ifeq ("$(PROFILE)","GEN")
1530         CFLAGS += -fprofile-generate=$(PROFILE_DIR) -DNO_NORETURN=1
1531         EXTLIBS += -lgcov
1532         export CCACHE_DISABLE = t
1533         V = 1
1534 else
1535 ifneq ("$(PROFILE)","")
1536         CFLAGS += -fprofile-use=$(PROFILE_DIR) -fprofile-correction -DNO_NORETURN=1
1537         export CCACHE_DISABLE = t
1538         V = 1
1539 endif
1540 endif
1541
1542 # Shell quote (do not use $(call) to accommodate ancient setups);
1543
1544 SHA1_HEADER_SQ = $(subst ','\'',$(SHA1_HEADER))
1545 ETC_GITCONFIG_SQ = $(subst ','\'',$(ETC_GITCONFIG))
1546 ETC_GITATTRIBUTES_SQ = $(subst ','\'',$(ETC_GITATTRIBUTES))
1547
1548 DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
1549 bindir_SQ = $(subst ','\'',$(bindir))
1550 bindir_relative_SQ = $(subst ','\'',$(bindir_relative))
1551 mandir_SQ = $(subst ','\'',$(mandir))
1552 infodir_SQ = $(subst ','\'',$(infodir))
1553 localedir_SQ = $(subst ','\'',$(localedir))
1554 gitexecdir_SQ = $(subst ','\'',$(gitexecdir))
1555 template_dir_SQ = $(subst ','\'',$(template_dir))
1556 htmldir_SQ = $(subst ','\'',$(htmldir))
1557 prefix_SQ = $(subst ','\'',$(prefix))
1558 gitwebdir_SQ = $(subst ','\'',$(gitwebdir))
1559
1560 SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
1561 PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
1562 PYTHON_PATH_SQ = $(subst ','\'',$(PYTHON_PATH))
1563 TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH))
1564 DIFF_SQ = $(subst ','\'',$(DIFF))
1565
1566 LIBS = $(GITLIBS) $(EXTLIBS)
1567
1568 BASIC_CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER_SQ)' \
1569         $(COMPAT_CFLAGS)
1570 LIB_OBJS += $(COMPAT_OBJS)
1571
1572 # Quote for C
1573
1574 ifdef DEFAULT_EDITOR
1575 DEFAULT_EDITOR_CQ = "$(subst ",\",$(subst \,\\,$(DEFAULT_EDITOR)))"
1576 DEFAULT_EDITOR_CQ_SQ = $(subst ','\'',$(DEFAULT_EDITOR_CQ))
1577
1578 BASIC_CFLAGS += -DDEFAULT_EDITOR='$(DEFAULT_EDITOR_CQ_SQ)'
1579 endif
1580
1581 ifdef DEFAULT_PAGER
1582 DEFAULT_PAGER_CQ = "$(subst ",\",$(subst \,\\,$(DEFAULT_PAGER)))"
1583 DEFAULT_PAGER_CQ_SQ = $(subst ','\'',$(DEFAULT_PAGER_CQ))
1584
1585 BASIC_CFLAGS += -DDEFAULT_PAGER='$(DEFAULT_PAGER_CQ_SQ)'
1586 endif
1587
1588 ifdef SHELL_PATH
1589 SHELL_PATH_CQ = "$(subst ",\",$(subst \,\\,$(SHELL_PATH)))"
1590 SHELL_PATH_CQ_SQ = $(subst ','\'',$(SHELL_PATH_CQ))
1591
1592 BASIC_CFLAGS += -DSHELL_PATH='$(SHELL_PATH_CQ_SQ)'
1593 endif
1594
1595 GIT_USER_AGENT_SQ = $(subst ','\'',$(GIT_USER_AGENT))
1596 GIT_USER_AGENT_CQ = "$(subst ",\",$(subst \,\\,$(GIT_USER_AGENT)))"
1597 GIT_USER_AGENT_CQ_SQ = $(subst ','\'',$(GIT_USER_AGENT_CQ))
1598 GIT-USER-AGENT: FORCE
1599         @if test x'$(GIT_USER_AGENT_SQ)' != x"`cat GIT-USER-AGENT 2>/dev/null`"; then \
1600                 echo '$(GIT_USER_AGENT_SQ)' >GIT-USER-AGENT; \
1601         fi
1602
1603 ifdef DEFAULT_HELP_FORMAT
1604 BASIC_CFLAGS += -DDEFAULT_HELP_FORMAT='"$(DEFAULT_HELP_FORMAT)"'
1605 endif
1606
1607 ALL_CFLAGS += $(BASIC_CFLAGS)
1608 ALL_LDFLAGS += $(BASIC_LDFLAGS)
1609
1610 export DIFF TAR INSTALL DESTDIR SHELL_PATH
1611
1612
1613 ### Build rules
1614
1615 SHELL = $(SHELL_PATH)
1616
1617 all:: shell_compatibility_test
1618
1619 ifeq "$(PROFILE)" "BUILD"
1620 ifeq ($(filter all,$(MAKECMDGOALS)),all)
1621 all:: profile-clean
1622         $(MAKE) PROFILE=GEN all
1623         $(MAKE) PROFILE=GEN -j1 test
1624 endif
1625 endif
1626
1627 all:: $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) $(OTHER_PROGRAMS) GIT-BUILD-OPTIONS
1628 ifneq (,$X)
1629         $(QUIET_BUILT_IN)$(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) git$X)), test -d '$p' -o '$p' -ef '$p$X' || $(RM) '$p';)
1630 endif
1631
1632 all::
1633 ifndef NO_TCLTK
1634         $(QUIET_SUBDIR0)git-gui $(QUIET_SUBDIR1) gitexecdir='$(gitexec_instdir_SQ)' all
1635         $(QUIET_SUBDIR0)gitk-git $(QUIET_SUBDIR1) all
1636 endif
1637 ifndef NO_PERL
1638         $(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' localedir='$(localedir_SQ)' all
1639 endif
1640 ifndef NO_PYTHON
1641         $(QUIET_SUBDIR0)git_remote_helpers $(QUIET_SUBDIR1) PYTHON_PATH='$(PYTHON_PATH_SQ)' prefix='$(prefix_SQ)' all
1642 endif
1643         $(QUIET_SUBDIR0)templates $(QUIET_SUBDIR1) SHELL_PATH='$(SHELL_PATH_SQ)' PERL_PATH='$(PERL_PATH_SQ)'
1644
1645 please_set_SHELL_PATH_to_a_more_modern_shell:
1646         @$$(:)
1647
1648 shell_compatibility_test: please_set_SHELL_PATH_to_a_more_modern_shell
1649
1650 strip: $(PROGRAMS) git$X
1651         $(STRIP) $(STRIP_OPTS) $(PROGRAMS) git$X
1652
1653 ### Target-specific flags and dependencies
1654
1655 # The generic compilation pattern rule and automatically
1656 # computed header dependencies (falling back to a dependency on
1657 # LIB_H) are enough to describe how most targets should be built,
1658 # but some targets are special enough to need something a little
1659 # different.
1660 #
1661 # - When a source file "foo.c" #includes a generated header file,
1662 #   we need to list that dependency for the "foo.o" target.
1663 #
1664 #   We also list it from other targets that are built from foo.c
1665 #   like "foo.sp" and "foo.s", even though that is easy to forget
1666 #   to do because the generated header is already present around
1667 #   after a regular build attempt.
1668 #
1669 # - Some code depends on configuration kept in makefile
1670 #   variables. The target-specific variable EXTRA_CPPFLAGS can
1671 #   be used to convey that information to the C preprocessor
1672 #   using -D options.
1673 #
1674 #   The "foo.o" target should have a corresponding dependency on
1675 #   a file that changes when the value of the makefile variable
1676 #   changes.  For example, targets making use of the
1677 #   $(GIT_VERSION) variable depend on GIT-VERSION-FILE.
1678 #
1679 #   Technically the ".sp" and ".s" targets do not need this
1680 #   dependency because they are force-built, but they get the
1681 #   same dependency for consistency. This way, you do not have to
1682 #   know how each target is implemented. And it means the
1683 #   dependencies here will not need to change if the force-build
1684 #   details change some day.
1685
1686 git.sp git.s git.o: GIT-PREFIX
1687 git.sp git.s git.o: EXTRA_CPPFLAGS = \
1688         '-DGIT_HTML_PATH="$(htmldir_SQ)"' \
1689         '-DGIT_MAN_PATH="$(mandir_SQ)"' \
1690         '-DGIT_INFO_PATH="$(infodir_SQ)"'
1691
1692 git$X: git.o GIT-LDFLAGS $(BUILTIN_OBJS) $(GITLIBS)
1693         $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ git.o \
1694                 $(BUILTIN_OBJS) $(ALL_LDFLAGS) $(LIBS)
1695
1696 help.sp help.s help.o: common-cmds.h
1697
1698 builtin/help.sp builtin/help.s builtin/help.o: common-cmds.h GIT-PREFIX
1699 builtin/help.sp builtin/help.s builtin/help.o: EXTRA_CPPFLAGS = \
1700         '-DGIT_HTML_PATH="$(htmldir_SQ)"' \
1701         '-DGIT_MAN_PATH="$(mandir_SQ)"' \
1702         '-DGIT_INFO_PATH="$(infodir_SQ)"'
1703
1704 version.sp version.s version.o: GIT-VERSION-FILE GIT-USER-AGENT
1705 version.sp version.s version.o: EXTRA_CPPFLAGS = \
1706         '-DGIT_VERSION="$(GIT_VERSION)"' \
1707         '-DGIT_USER_AGENT=$(GIT_USER_AGENT_CQ_SQ)'
1708
1709 $(BUILT_INS): git$X
1710         $(QUIET_BUILT_IN)$(RM) $@ && \
1711         ln git$X $@ 2>/dev/null || \
1712         ln -s git$X $@ 2>/dev/null || \
1713         cp git$X $@
1714
1715 common-cmds.h: ./generate-cmdlist.sh command-list.txt
1716
1717 common-cmds.h: $(wildcard Documentation/git-*.txt)
1718         $(QUIET_GEN)./generate-cmdlist.sh > $@+ && mv $@+ $@
1719
1720 SCRIPT_DEFINES = $(SHELL_PATH_SQ):$(DIFF_SQ):$(GIT_VERSION):\
1721         $(localedir_SQ):$(NO_CURL):$(USE_GETTEXT_SCHEME):$(SANE_TOOL_PATH_SQ):\
1722         $(gitwebdir_SQ):$(PERL_PATH_SQ)
1723 define cmd_munge_script
1724 $(RM) $@ $@+ && \
1725 sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
1726     -e 's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \
1727     -e 's|@@DIFF@@|$(DIFF_SQ)|' \
1728     -e 's|@@LOCALEDIR@@|$(localedir_SQ)|g' \
1729     -e 's/@@NO_CURL@@/$(NO_CURL)/g' \
1730     -e 's/@@USE_GETTEXT_SCHEME@@/$(USE_GETTEXT_SCHEME)/g' \
1731     -e $(BROKEN_PATH_FIX) \
1732     -e 's|@@GITWEBDIR@@|$(gitwebdir_SQ)|g' \
1733     -e 's|@@PERL@@|$(PERL_PATH_SQ)|g' \
1734     $@.sh >$@+
1735 endef
1736
1737 GIT-SCRIPT-DEFINES: FORCE
1738         @FLAGS='$(SCRIPT_DEFINES)'; \
1739             if test x"$$FLAGS" != x"`cat $@ 2>/dev/null`" ; then \
1740                 echo >&2 "    * new script parameters"; \
1741                 echo "$$FLAGS" >$@; \
1742             fi
1743
1744
1745 $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh GIT-SCRIPT-DEFINES
1746         $(QUIET_GEN)$(cmd_munge_script) && \
1747         chmod +x $@+ && \
1748         mv $@+ $@
1749
1750 $(SCRIPT_LIB) : % : %.sh GIT-SCRIPT-DEFINES
1751         $(QUIET_GEN)$(cmd_munge_script) && \
1752         mv $@+ $@
1753
1754 ifndef NO_PERL
1755 $(patsubst %.perl,%,$(SCRIPT_PERL)): perl/perl.mak
1756
1757 perl/perl.mak: perl/PM.stamp
1758
1759 perl/PM.stamp: FORCE
1760         $(QUIET_GEN)$(FIND) perl -type f -name '*.pm' | sort >$@+ && \
1761         { cmp $@+ $@ >/dev/null 2>/dev/null || mv $@+ $@; } && \
1762         $(RM) $@+
1763
1764 perl/perl.mak: GIT-CFLAGS GIT-PREFIX perl/Makefile perl/Makefile.PL
1765         $(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' $(@F)
1766
1767 $(patsubst %.perl,%,$(SCRIPT_PERL)): % : %.perl GIT-VERSION-FILE
1768         $(QUIET_GEN)$(RM) $@ $@+ && \
1769         INSTLIBDIR=`MAKEFLAGS= $(MAKE) -C perl -s --no-print-directory instlibdir` && \
1770         sed -e '1{' \
1771             -e '        s|#!.*perl|#!$(PERL_PATH_SQ)|' \
1772             -e '        h' \
1773             -e '        s=.*=use lib (split(/$(pathsep)/, $$ENV{GITPERLLIB} || "'"$$INSTLIBDIR"'"));=' \
1774             -e '        H' \
1775             -e '        x' \
1776             -e '}' \
1777             -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
1778             $@.perl >$@+ && \
1779         chmod +x $@+ && \
1780         mv $@+ $@
1781
1782
1783 .PHONY: gitweb
1784 gitweb:
1785         $(QUIET_SUBDIR0)gitweb $(QUIET_SUBDIR1) all
1786
1787 git-instaweb: git-instaweb.sh gitweb GIT-SCRIPT-DEFINES
1788         $(QUIET_GEN)$(cmd_munge_script) && \
1789         chmod +x $@+ && \
1790         mv $@+ $@
1791 else # NO_PERL
1792 $(patsubst %.perl,%,$(SCRIPT_PERL)) git-instaweb: % : unimplemented.sh
1793         $(QUIET_GEN)$(RM) $@ $@+ && \
1794         sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
1795             -e 's|@@REASON@@|NO_PERL=$(NO_PERL)|g' \
1796             unimplemented.sh >$@+ && \
1797         chmod +x $@+ && \
1798         mv $@+ $@
1799 endif # NO_PERL
1800
1801 ifndef NO_PYTHON
1802 $(patsubst %.py,%,$(SCRIPT_PYTHON)): GIT-CFLAGS GIT-PREFIX GIT-PYTHON-VARS
1803 $(patsubst %.py,%,$(SCRIPT_PYTHON)): % : %.py
1804         $(QUIET_GEN)$(RM) $@ $@+ && \
1805         INSTLIBDIR=`MAKEFLAGS= $(MAKE) -C git_remote_helpers -s \
1806                 --no-print-directory prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' \
1807                 instlibdir` && \
1808         sed -e '1s|#!.*python|#!$(PYTHON_PATH_SQ)|' \
1809             -e 's|\(os\.getenv("GITPYTHONLIB"\)[^)]*)|\1,"@@INSTLIBDIR@@")|' \
1810             -e 's|@@INSTLIBDIR@@|'"$$INSTLIBDIR"'|g' \
1811             $@.py >$@+ && \
1812         chmod +x $@+ && \
1813         mv $@+ $@
1814 else # NO_PYTHON
1815 $(patsubst %.py,%,$(SCRIPT_PYTHON)): % : unimplemented.sh
1816         $(QUIET_GEN)$(RM) $@ $@+ && \
1817         sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
1818             -e 's|@@REASON@@|NO_PYTHON=$(NO_PYTHON)|g' \
1819             unimplemented.sh >$@+ && \
1820         chmod +x $@+ && \
1821         mv $@+ $@
1822 endif # NO_PYTHON
1823
1824 configure: configure.ac GIT-VERSION-FILE
1825         $(QUIET_GEN)$(RM) $@ $<+ && \
1826         sed -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
1827             $< > $<+ && \
1828         autoconf -o $@ $<+ && \
1829         $(RM) $<+
1830
1831 ifdef AUTOCONFIGURED
1832 # We avoid depending on 'configure' here, because it gets rebuilt
1833 # every time GIT-VERSION-FILE is modified, only to update the embedded
1834 # version number string, which config.status does not care about.  We
1835 # do want to recheck when the platform/environment detection logic
1836 # changes, hence this depends on configure.ac.
1837 config.status: configure.ac
1838         $(QUIET_GEN)$(MAKE) configure && \
1839         if test -f config.status; then \
1840           ./config.status --recheck; \
1841         else \
1842           ./configure; \
1843         fi
1844 reconfigure config.mak.autogen: config.status
1845         $(QUIET_GEN)./config.status
1846 .PHONY: reconfigure # This is a convenience target.
1847 endif
1848
1849 XDIFF_OBJS += xdiff/xdiffi.o
1850 XDIFF_OBJS += xdiff/xprepare.o
1851 XDIFF_OBJS += xdiff/xutils.o
1852 XDIFF_OBJS += xdiff/xemit.o
1853 XDIFF_OBJS += xdiff/xmerge.o
1854 XDIFF_OBJS += xdiff/xpatience.o
1855 XDIFF_OBJS += xdiff/xhistogram.o
1856
1857 VCSSVN_OBJS += vcs-svn/line_buffer.o
1858 VCSSVN_OBJS += vcs-svn/sliding_window.o
1859 VCSSVN_OBJS += vcs-svn/repo_tree.o
1860 VCSSVN_OBJS += vcs-svn/fast_export.o
1861 VCSSVN_OBJS += vcs-svn/svndiff.o
1862 VCSSVN_OBJS += vcs-svn/svndump.o
1863
1864 TEST_OBJS := $(patsubst test-%$X,test-%.o,$(TEST_PROGRAMS))
1865 OBJECTS := $(LIB_OBJS) $(BUILTIN_OBJS) $(PROGRAM_OBJS) $(TEST_OBJS) \
1866         $(XDIFF_OBJS) \
1867         $(VCSSVN_OBJS) \
1868         git.o
1869 ifndef NO_CURL
1870         OBJECTS += http.o http-walker.o remote-curl.o
1871 endif
1872
1873 dep_files := $(foreach f,$(OBJECTS),$(dir $f).depend/$(notdir $f).d)
1874 dep_dirs := $(addsuffix .depend,$(sort $(dir $(OBJECTS))))
1875
1876 ifeq ($(COMPUTE_HEADER_DEPENDENCIES),yes)
1877 $(dep_dirs):
1878         @mkdir -p $@
1879
1880 missing_dep_dirs := $(filter-out $(wildcard $(dep_dirs)),$(dep_dirs))
1881 dep_file = $(dir $@).depend/$(notdir $@).d
1882 dep_args = -MF $(dep_file) -MQ $@ -MMD -MP
1883 ifdef CHECK_HEADER_DEPENDENCIES
1884 $(error cannot compute header dependencies outside a normal build. \
1885 Please unset CHECK_HEADER_DEPENDENCIES and try again)
1886 endif
1887 endif
1888
1889 ifneq ($(COMPUTE_HEADER_DEPENDENCIES),yes)
1890 ifndef CHECK_HEADER_DEPENDENCIES
1891 dep_dirs =
1892 missing_dep_dirs =
1893 dep_args =
1894 endif
1895 endif
1896
1897 ifdef CHECK_HEADER_DEPENDENCIES
1898 ifndef PRINT_HEADER_DEPENDENCIES
1899 missing_deps = $(filter-out $(notdir $^), \
1900         $(notdir $(shell $(MAKE) -s $@ \
1901                 CHECK_HEADER_DEPENDENCIES=YesPlease \
1902                 USE_COMPUTED_HEADER_DEPENDENCIES=YesPlease \
1903                 PRINT_HEADER_DEPENDENCIES=YesPlease)))
1904 endif
1905 endif
1906
1907 ASM_SRC := $(wildcard $(OBJECTS:o=S))
1908 ASM_OBJ := $(ASM_SRC:S=o)
1909 C_OBJ := $(filter-out $(ASM_OBJ),$(OBJECTS))
1910
1911 .SUFFIXES:
1912
1913 ifdef PRINT_HEADER_DEPENDENCIES
1914 $(C_OBJ): %.o: %.c FORCE
1915         echo $^
1916 $(ASM_OBJ): %.o: %.S FORCE
1917         echo $^
1918
1919 ifndef CHECK_HEADER_DEPENDENCIES
1920 $(error cannot print header dependencies during a normal build. \
1921 Please set CHECK_HEADER_DEPENDENCIES and try again)
1922 endif
1923 endif
1924
1925 ifndef PRINT_HEADER_DEPENDENCIES
1926 ifdef CHECK_HEADER_DEPENDENCIES
1927 $(C_OBJ): %.o: %.c $(dep_files) FORCE
1928         @set -e; echo CHECK $@; \
1929         missing_deps="$(missing_deps)"; \
1930         if test "$$missing_deps"; \
1931         then \
1932                 echo missing dependencies: $$missing_deps; \
1933                 false; \
1934         fi
1935 $(ASM_OBJ): %.o: %.S $(dep_files) FORCE
1936         @set -e; echo CHECK $@; \
1937         missing_deps="$(missing_deps)"; \
1938         if test "$$missing_deps"; \
1939         then \
1940                 echo missing dependencies: $$missing_deps; \
1941                 false; \
1942         fi
1943 endif
1944 endif
1945
1946 ifndef CHECK_HEADER_DEPENDENCIES
1947 $(C_OBJ): %.o: %.c GIT-CFLAGS $(missing_dep_dirs)
1948         $(QUIET_CC)$(CC) -o $*.o -c $(dep_args) $(ALL_CFLAGS) $(EXTRA_CPPFLAGS) $<
1949 $(ASM_OBJ): %.o: %.S GIT-CFLAGS $(missing_dep_dirs)
1950         $(QUIET_CC)$(CC) -o $*.o -c $(dep_args) $(ALL_CFLAGS) $(EXTRA_CPPFLAGS) $<
1951 endif
1952
1953 %.s: %.c GIT-CFLAGS FORCE
1954         $(QUIET_CC)$(CC) -o $@ -S $(ALL_CFLAGS) $(EXTRA_CPPFLAGS) $<
1955
1956 ifdef USE_COMPUTED_HEADER_DEPENDENCIES
1957 # Take advantage of gcc's on-the-fly dependency generation
1958 # See <http://gcc.gnu.org/gcc-3.0/features.html>.
1959 dep_files_present := $(wildcard $(dep_files))
1960 ifneq ($(dep_files_present),)
1961 include $(dep_files_present)
1962 endif
1963 else
1964 # Dependencies on header files, for platforms that do not support
1965 # the gcc -MMD option.
1966 #
1967 # Dependencies on automatically generated headers such as common-cmds.h
1968 # should _not_ be included here, since they are necessary even when
1969 # building an object for the first time.
1970
1971 $(OBJECTS): $(LIB_H)
1972 endif
1973
1974 exec_cmd.sp exec_cmd.s exec_cmd.o: GIT-PREFIX
1975 exec_cmd.sp exec_cmd.s exec_cmd.o: EXTRA_CPPFLAGS = \
1976         '-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' \
1977         '-DBINDIR="$(bindir_relative_SQ)"' \
1978         '-DPREFIX="$(prefix_SQ)"'
1979
1980 builtin/init-db.sp builtin/init-db.s builtin/init-db.o: GIT-PREFIX
1981 builtin/init-db.sp builtin/init-db.s builtin/init-db.o: EXTRA_CPPFLAGS = \
1982         -DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir_SQ)"'
1983
1984 config.sp config.s config.o: GIT-PREFIX
1985 config.sp config.s config.o: EXTRA_CPPFLAGS = \
1986         -DETC_GITCONFIG='"$(ETC_GITCONFIG_SQ)"'
1987
1988 attr.sp attr.s attr.o: GIT-PREFIX
1989 attr.sp attr.s attr.o: EXTRA_CPPFLAGS = \
1990         -DETC_GITATTRIBUTES='"$(ETC_GITATTRIBUTES_SQ)"'
1991
1992 gettext.sp gettext.s gettext.o: GIT-PREFIX
1993 gettext.sp gettext.s gettext.o: EXTRA_CPPFLAGS = \
1994         -DGIT_LOCALE_PATH='"$(localedir_SQ)"'
1995
1996 ifdef NO_EXPAT
1997 http-walker.sp http-walker.s http-walker.o: EXTRA_CPPFLAGS = -DNO_EXPAT
1998 endif
1999
2000 ifdef NO_REGEX
2001 compat/regex/regex.sp compat/regex/regex.o: EXTRA_CPPFLAGS = \
2002         -DGAWK -DNO_MBSUPPORT
2003 endif
2004
2005 ifdef USE_NED_ALLOCATOR
2006 compat/nedmalloc/nedmalloc.sp compat/nedmalloc/nedmalloc.o: EXTRA_CPPFLAGS = \
2007         -DNDEBUG -DOVERRIDE_STRDUP -DREPLACE_SYSTEM_ALLOCATOR
2008 endif
2009
2010 git-%$X: %.o GIT-LDFLAGS $(GITLIBS)
2011         $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
2012
2013 git-imap-send$X: imap-send.o GIT-LDFLAGS $(GITLIBS)
2014         $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
2015                 $(LIBS) $(OPENSSL_LINK) $(OPENSSL_LIBSSL) $(LIB_4_CRYPTO)
2016
2017 git-http-fetch$X: revision.o http.o http-walker.o http-fetch.o GIT-LDFLAGS $(GITLIBS)
2018         $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
2019                 $(LIBS) $(CURL_LIBCURL)
2020 git-http-push$X: revision.o http.o http-push.o GIT-LDFLAGS $(GITLIBS)
2021         $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
2022                 $(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
2023
2024 git-remote-testsvn$X: remote-testsvn.o GIT-LDFLAGS $(GITLIBS) $(VCSSVN_LIB)
2025         $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS) \
2026         $(VCSSVN_LIB)
2027
2028 $(REMOTE_CURL_ALIASES): $(REMOTE_CURL_PRIMARY)
2029         $(QUIET_LNCP)$(RM) $@ && \
2030         ln $< $@ 2>/dev/null || \
2031         ln -s $< $@ 2>/dev/null || \
2032         cp $< $@
2033
2034 $(REMOTE_CURL_PRIMARY): remote-curl.o http.o http-walker.o GIT-LDFLAGS $(GITLIBS)
2035         $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
2036                 $(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
2037
2038 $(LIB_FILE): $(LIB_OBJS)
2039         $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIB_OBJS)
2040
2041 $(XDIFF_LIB): $(XDIFF_OBJS)
2042         $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(XDIFF_OBJS)
2043
2044 $(VCSSVN_LIB): $(VCSSVN_OBJS)
2045         $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(VCSSVN_OBJS)
2046
2047 export DEFAULT_EDITOR DEFAULT_PAGER
2048
2049 doc:
2050         $(MAKE) -C Documentation all
2051
2052 man:
2053         $(MAKE) -C Documentation man
2054
2055 html:
2056         $(MAKE) -C Documentation html
2057
2058 info:
2059         $(MAKE) -C Documentation info
2060
2061 pdf:
2062         $(MAKE) -C Documentation pdf
2063
2064 XGETTEXT_FLAGS = \
2065         --force-po \
2066         --add-comments \
2067         --msgid-bugs-address="Git Mailing List <git@vger.kernel.org>" \
2068         --from-code=UTF-8
2069 XGETTEXT_FLAGS_C = $(XGETTEXT_FLAGS) --language=C \
2070         --keyword=_ --keyword=N_ --keyword="Q_:1,2"
2071 XGETTEXT_FLAGS_SH = $(XGETTEXT_FLAGS) --language=Shell \
2072         --keyword=gettextln --keyword=eval_gettextln
2073 XGETTEXT_FLAGS_PERL = $(XGETTEXT_FLAGS) --keyword=__ --language=Perl
2074 LOCALIZED_C := $(C_OBJ:o=c) $(LIB_H) $(GENERATED_H)
2075 LOCALIZED_SH := $(SCRIPT_SH)
2076 LOCALIZED_PERL := $(SCRIPT_PERL)
2077
2078 ifdef XGETTEXT_INCLUDE_TESTS
2079 LOCALIZED_C += t/t0200/test.c
2080 LOCALIZED_SH += t/t0200/test.sh
2081 LOCALIZED_PERL += t/t0200/test.perl
2082 endif
2083
2084 po/git.pot: $(LOCALIZED_C)
2085         $(QUIET_XGETTEXT)$(XGETTEXT) -o$@+ $(XGETTEXT_FLAGS_C) $(LOCALIZED_C)
2086         $(QUIET_XGETTEXT)$(XGETTEXT) -o$@+ --join-existing $(XGETTEXT_FLAGS_SH) \
2087                 $(LOCALIZED_SH)
2088         $(QUIET_XGETTEXT)$(XGETTEXT) -o$@+ --join-existing $(XGETTEXT_FLAGS_PERL) \
2089                 $(LOCALIZED_PERL)
2090         mv $@+ $@
2091
2092 pot: po/git.pot
2093
2094 POFILES := $(wildcard po/*.po)
2095 MOFILES := $(patsubst po/%.po,po/build/locale/%/LC_MESSAGES/git.mo,$(POFILES))
2096
2097 ifndef NO_GETTEXT
2098 all:: $(MOFILES)
2099 endif
2100
2101 po/build/locale/%/LC_MESSAGES/git.mo: po/%.po
2102         $(QUIET_MSGFMT)mkdir -p $(dir $@) && $(MSGFMT) -o $@ $<
2103
2104 FIND_SOURCE_FILES = ( git ls-files '*.[hcS]' 2>/dev/null || \
2105                         $(FIND) . \( -name .git -type d -prune \) \
2106                                 -o \( -name '*.[hcS]' -type f -print \) )
2107
2108 $(ETAGS_TARGET): FORCE
2109         $(RM) $(ETAGS_TARGET)
2110         $(FIND_SOURCE_FILES) | xargs etags -a -o $(ETAGS_TARGET)
2111
2112 tags: FORCE
2113         $(RM) tags
2114         $(FIND_SOURCE_FILES) | xargs ctags -a
2115
2116 cscope:
2117         $(RM) cscope*
2118         $(FIND_SOURCE_FILES) | xargs cscope -b
2119
2120 ### Detect prefix changes
2121 TRACK_PREFIX = $(bindir_SQ):$(gitexecdir_SQ):$(template_dir_SQ):$(prefix_SQ):\
2122                 $(localedir_SQ)
2123
2124 GIT-PREFIX: FORCE
2125         @FLAGS='$(TRACK_PREFIX)'; \
2126         if test x"$$FLAGS" != x"`cat GIT-PREFIX 2>/dev/null`" ; then \
2127                 echo >&2 "    * new prefix flags"; \
2128                 echo "$$FLAGS" >GIT-PREFIX; \
2129         fi
2130
2131 TRACK_CFLAGS = $(CC):$(subst ','\'',$(ALL_CFLAGS)):$(USE_GETTEXT_SCHEME)
2132
2133 GIT-CFLAGS: FORCE
2134         @FLAGS='$(TRACK_CFLAGS)'; \
2135             if test x"$$FLAGS" != x"`cat GIT-CFLAGS 2>/dev/null`" ; then \
2136                 echo >&2 "    * new build flags"; \
2137                 echo "$$FLAGS" >GIT-CFLAGS; \
2138             fi
2139
2140 TRACK_LDFLAGS = $(subst ','\'',$(ALL_LDFLAGS))
2141
2142 GIT-LDFLAGS: FORCE
2143         @FLAGS='$(TRACK_LDFLAGS)'; \
2144             if test x"$$FLAGS" != x"`cat GIT-LDFLAGS 2>/dev/null`" ; then \
2145                 echo >&2 "    * new link flags"; \
2146                 echo "$$FLAGS" >GIT-LDFLAGS; \
2147             fi
2148
2149 # We need to apply sq twice, once to protect from the shell
2150 # that runs GIT-BUILD-OPTIONS, and then again to protect it
2151 # and the first level quoting from the shell that runs "echo".
2152 GIT-BUILD-OPTIONS: FORCE
2153         @echo SHELL_PATH=\''$(subst ','\'',$(SHELL_PATH_SQ))'\' >$@
2154         @echo PERL_PATH=\''$(subst ','\'',$(PERL_PATH_SQ))'\' >>$@
2155         @echo DIFF=\''$(subst ','\'',$(subst ','\'',$(DIFF)))'\' >>$@
2156         @echo PYTHON_PATH=\''$(subst ','\'',$(PYTHON_PATH_SQ))'\' >>$@
2157         @echo TAR=\''$(subst ','\'',$(subst ','\'',$(TAR)))'\' >>$@
2158         @echo NO_CURL=\''$(subst ','\'',$(subst ','\'',$(NO_CURL)))'\' >>$@
2159         @echo USE_LIBPCRE=\''$(subst ','\'',$(subst ','\'',$(USE_LIBPCRE)))'\' >>$@
2160         @echo NO_PERL=\''$(subst ','\'',$(subst ','\'',$(NO_PERL)))'\' >>$@
2161         @echo NO_PYTHON=\''$(subst ','\'',$(subst ','\'',$(NO_PYTHON)))'\' >>$@
2162         @echo NO_UNIX_SOCKETS=\''$(subst ','\'',$(subst ','\'',$(NO_UNIX_SOCKETS)))'\' >>$@
2163 ifdef GIT_TEST_OPTS
2164         @echo GIT_TEST_OPTS=\''$(subst ','\'',$(subst ','\'',$(GIT_TEST_OPTS)))'\' >>$@
2165 endif
2166 ifdef GIT_TEST_CMP
2167         @echo GIT_TEST_CMP=\''$(subst ','\'',$(subst ','\'',$(GIT_TEST_CMP)))'\' >>$@
2168 endif
2169 ifdef GIT_TEST_CMP_USE_COPIED_CONTEXT
2170         @echo GIT_TEST_CMP_USE_COPIED_CONTEXT=YesPlease >>$@
2171 endif
2172         @echo NO_GETTEXT=\''$(subst ','\'',$(subst ','\'',$(NO_GETTEXT)))'\' >>$@
2173         @echo GETTEXT_POISON=\''$(subst ','\'',$(subst ','\'',$(GETTEXT_POISON)))'\' >>$@
2174 ifdef GIT_PERF_REPEAT_COUNT
2175         @echo GIT_PERF_REPEAT_COUNT=\''$(subst ','\'',$(subst ','\'',$(GIT_PERF_REPEAT_COUNT)))'\' >>$@
2176 endif
2177 ifdef GIT_PERF_REPO
2178         @echo GIT_PERF_REPO=\''$(subst ','\'',$(subst ','\'',$(GIT_PERF_REPO)))'\' >>$@
2179 endif
2180 ifdef GIT_PERF_LARGE_REPO
2181         @echo GIT_PERF_LARGE_REPO=\''$(subst ','\'',$(subst ','\'',$(GIT_PERF_LARGE_REPO)))'\' >>$@
2182 endif
2183 ifdef GIT_PERF_MAKE_OPTS
2184         @echo GIT_PERF_MAKE_OPTS=\''$(subst ','\'',$(subst ','\'',$(GIT_PERF_MAKE_OPTS)))'\' >>$@
2185 endif
2186
2187 ### Detect Python interpreter path changes
2188 ifndef NO_PYTHON
2189 TRACK_PYTHON = $(subst ','\'',-DPYTHON_PATH='$(PYTHON_PATH_SQ)')
2190
2191 GIT-PYTHON-VARS: FORCE
2192         @VARS='$(TRACK_PYTHON)'; \
2193             if test x"$$VARS" != x"`cat $@ 2>/dev/null`" ; then \
2194                 echo >&2 "    * new Python interpreter location"; \
2195                 echo "$$VARS" >$@; \
2196             fi
2197 endif
2198
2199 test_bindir_programs := $(patsubst %,bin-wrappers/%,$(BINDIR_PROGRAMS_NEED_X) $(BINDIR_PROGRAMS_NO_X) $(TEST_PROGRAMS_NEED_X))
2200
2201 all:: $(TEST_PROGRAMS) $(test_bindir_programs)
2202
2203 bin-wrappers/%: wrap-for-bin.sh
2204         @mkdir -p bin-wrappers
2205         $(QUIET_GEN)sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
2206              -e 's|@@BUILD_DIR@@|$(shell pwd)|' \
2207              -e 's|@@PROG@@|$(@F)|' < $< > $@ && \
2208         chmod +x $@
2209
2210 # GNU make supports exporting all variables by "export" without parameters.
2211 # However, the environment gets quite big, and some programs have problems
2212 # with that.
2213
2214 export NO_SVN_TESTS
2215 export TEST_NO_MALLOC_CHECK
2216
2217 ### Testing rules
2218
2219 test: all
2220         $(MAKE) -C t/ all
2221
2222 perf: all
2223         $(MAKE) -C t/perf/ all
2224
2225 .PHONY: test perf
2226
2227 test-ctype$X: ctype.o
2228
2229 test-date$X: date.o ctype.o
2230
2231 test-delta$X: diff-delta.o patch-delta.o
2232
2233 test-line-buffer$X: vcs-svn/lib.a
2234
2235 test-parse-options$X: parse-options.o parse-options-cb.o
2236
2237 test-svn-fe$X: vcs-svn/lib.a
2238
2239 .PRECIOUS: $(TEST_OBJS)
2240
2241 test-%$X: test-%.o GIT-LDFLAGS $(GITLIBS)
2242         $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(filter %.a,$^) $(LIBS)
2243
2244 check-sha1:: test-sha1$X
2245         ./test-sha1.sh
2246
2247 SP_OBJ = $(patsubst %.o,%.sp,$(C_OBJ))
2248
2249 $(SP_OBJ): %.sp: %.c GIT-CFLAGS FORCE
2250         $(QUIET_SP)cgcc -no-compile $(ALL_CFLAGS) $(EXTRA_CPPFLAGS) \
2251                 $(SPARSE_FLAGS) $<
2252
2253 .PHONY: sparse $(SP_OBJ)
2254 sparse: $(SP_OBJ)
2255
2256 check: common-cmds.h
2257         @if sparse; \
2258         then \
2259                 echo 2>&1 "Use 'make sparse' instead"; \
2260                 $(MAKE) --no-print-directory sparse; \
2261         else \
2262                 echo 2>&1 "Did you mean 'make test'?"; \
2263                 exit 1; \
2264         fi
2265
2266 remove-dashes:
2267         ./fixup-builtins $(BUILT_INS) $(PROGRAMS) $(SCRIPTS)
2268
2269 ### Installation rules
2270
2271 ifneq ($(filter /%,$(firstword $(template_dir))),)
2272 template_instdir = $(template_dir)
2273 else
2274 template_instdir = $(prefix)/$(template_dir)
2275 endif
2276 export template_instdir
2277
2278 ifneq ($(filter /%,$(firstword $(gitexecdir))),)
2279 gitexec_instdir = $(gitexecdir)
2280 else
2281 gitexec_instdir = $(prefix)/$(gitexecdir)
2282 endif
2283 gitexec_instdir_SQ = $(subst ','\'',$(gitexec_instdir))
2284 export gitexec_instdir
2285
2286 ifneq ($(filter /%,$(firstword $(mergetoolsdir))),)
2287 mergetools_instdir = $(mergetoolsdir)
2288 else
2289 mergetools_instdir = $(prefix)/$(mergetoolsdir)
2290 endif
2291 mergetools_instdir_SQ = $(subst ','\'',$(mergetools_instdir))
2292
2293 install_bindir_programs := $(patsubst %,%$X,$(BINDIR_PROGRAMS_NEED_X)) $(BINDIR_PROGRAMS_NO_X)
2294
2295 install: all
2296         $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'
2297         $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
2298         $(INSTALL) $(ALL_PROGRAMS) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
2299         $(INSTALL) -m 644 $(SCRIPT_LIB) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
2300         $(INSTALL) $(install_bindir_programs) '$(DESTDIR_SQ)$(bindir_SQ)'
2301         $(MAKE) -C templates DESTDIR='$(DESTDIR_SQ)' install
2302         $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(mergetools_instdir_SQ)'
2303         $(INSTALL) -m 644 mergetools/* '$(DESTDIR_SQ)$(mergetools_instdir_SQ)'
2304 ifndef NO_GETTEXT
2305         $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(localedir_SQ)'
2306         (cd po/build/locale && $(TAR) cf - .) | \
2307         (cd '$(DESTDIR_SQ)$(localedir_SQ)' && umask 022 && $(TAR) xof -)
2308 endif
2309 ifndef NO_PERL
2310         $(MAKE) -C perl prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' install
2311         $(MAKE) -C gitweb install
2312 endif
2313 ifndef NO_PYTHON
2314         $(MAKE) -C git_remote_helpers prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' install
2315 endif
2316 ifndef NO_TCLTK
2317         $(MAKE) -C gitk-git install
2318         $(MAKE) -C git-gui gitexecdir='$(gitexec_instdir_SQ)' install
2319 endif
2320 ifneq (,$X)
2321         $(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) git$X)), test '$(DESTDIR_SQ)$(gitexec_instdir_SQ)/$p' -ef '$(DESTDIR_SQ)$(gitexec_instdir_SQ)/$p$X' || $(RM) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)/$p';)
2322 endif
2323
2324         bindir=$$(cd '$(DESTDIR_SQ)$(bindir_SQ)' && pwd) && \
2325         execdir=$$(cd '$(DESTDIR_SQ)$(gitexec_instdir_SQ)' && pwd) && \
2326         { test "$$bindir/" = "$$execdir/" || \
2327           for p in git$X $(filter $(install_bindir_programs),$(ALL_PROGRAMS)); do \
2328                 $(RM) "$$execdir/$$p" && \
2329                 test -z "$(NO_INSTALL_HARDLINKS)$(NO_CROSS_DIRECTORY_HARDLINKS)" && \
2330                 ln "$$bindir/$$p" "$$execdir/$$p" 2>/dev/null || \
2331                 cp "$$bindir/$$p" "$$execdir/$$p" || exit; \
2332           done; \
2333         } && \
2334         for p in $(filter $(install_bindir_programs),$(BUILT_INS)); do \
2335                 $(RM) "$$bindir/$$p" && \
2336                 test -z "$(NO_INSTALL_HARDLINKS)" && \
2337                 ln "$$bindir/git$X" "$$bindir/$$p" 2>/dev/null || \
2338                 ln -s "git$X" "$$bindir/$$p" 2>/dev/null || \
2339                 cp "$$bindir/git$X" "$$bindir/$$p" || exit; \
2340         done && \
2341         for p in $(BUILT_INS); do \
2342                 $(RM) "$$execdir/$$p" && \
2343                 test -z "$(NO_INSTALL_HARDLINKS)" && \
2344                 ln "$$execdir/git$X" "$$execdir/$$p" 2>/dev/null || \
2345                 ln -s "git$X" "$$execdir/$$p" 2>/dev/null || \
2346                 cp "$$execdir/git$X" "$$execdir/$$p" || exit; \
2347         done && \
2348         remote_curl_aliases="$(REMOTE_CURL_ALIASES)" && \
2349         for p in $$remote_curl_aliases; do \
2350                 $(RM) "$$execdir/$$p" && \
2351                 test -z "$(NO_INSTALL_HARDLINKS)" && \
2352                 ln "$$execdir/git-remote-http$X" "$$execdir/$$p" 2>/dev/null || \
2353                 ln -s "git-remote-http$X" "$$execdir/$$p" 2>/dev/null || \
2354                 cp "$$execdir/git-remote-http$X" "$$execdir/$$p" || exit; \
2355         done && \
2356         ./check_bindir "z$$bindir" "z$$execdir" "$$bindir/git-add$X"
2357
2358 install-gitweb:
2359         $(MAKE) -C gitweb install
2360
2361 install-doc:
2362         $(MAKE) -C Documentation install
2363
2364 install-man:
2365         $(MAKE) -C Documentation install-man
2366
2367 install-html:
2368         $(MAKE) -C Documentation install-html
2369
2370 install-info:
2371         $(MAKE) -C Documentation install-info
2372
2373 install-pdf:
2374         $(MAKE) -C Documentation install-pdf
2375
2376 quick-install-doc:
2377         $(MAKE) -C Documentation quick-install
2378
2379 quick-install-man:
2380         $(MAKE) -C Documentation quick-install-man
2381
2382 quick-install-html:
2383         $(MAKE) -C Documentation quick-install-html
2384
2385
2386
2387 ### Maintainer's dist rules
2388
2389 git.spec: git.spec.in GIT-VERSION-FILE
2390         sed -e 's/@@VERSION@@/$(GIT_VERSION)/g' < $< > $@+
2391         mv $@+ $@
2392
2393 GIT_TARNAME = git-$(GIT_VERSION)
2394 dist: git.spec git-archive$(X) configure
2395         ./git-archive --format=tar \
2396                 --prefix=$(GIT_TARNAME)/ HEAD^{tree} > $(GIT_TARNAME).tar
2397         @mkdir -p $(GIT_TARNAME)
2398         @cp git.spec configure $(GIT_TARNAME)
2399         @echo $(GIT_VERSION) > $(GIT_TARNAME)/version
2400         @$(MAKE) -C git-gui TARDIR=../$(GIT_TARNAME)/git-gui dist-version
2401         $(TAR) rf $(GIT_TARNAME).tar \
2402                 $(GIT_TARNAME)/git.spec \
2403                 $(GIT_TARNAME)/configure \
2404                 $(GIT_TARNAME)/version \
2405                 $(GIT_TARNAME)/git-gui/version
2406         @$(RM) -r $(GIT_TARNAME)
2407         gzip -f -9 $(GIT_TARNAME).tar
2408
2409 rpm: dist
2410         $(RPMBUILD) \
2411                 --define "_source_filedigest_algorithm md5" \
2412                 --define "_binary_filedigest_algorithm md5" \
2413                 -ta $(GIT_TARNAME).tar.gz
2414
2415 htmldocs = git-htmldocs-$(GIT_VERSION)
2416 manpages = git-manpages-$(GIT_VERSION)
2417 dist-doc:
2418         $(RM) -r .doc-tmp-dir
2419         mkdir .doc-tmp-dir
2420         $(MAKE) -C Documentation WEBDOC_DEST=../.doc-tmp-dir install-webdoc
2421         cd .doc-tmp-dir && $(TAR) cf ../$(htmldocs).tar .
2422         gzip -n -9 -f $(htmldocs).tar
2423         :
2424         $(RM) -r .doc-tmp-dir
2425         mkdir -p .doc-tmp-dir/man1 .doc-tmp-dir/man5 .doc-tmp-dir/man7
2426         $(MAKE) -C Documentation DESTDIR=./ \
2427                 man1dir=../.doc-tmp-dir/man1 \
2428                 man5dir=../.doc-tmp-dir/man5 \
2429                 man7dir=../.doc-tmp-dir/man7 \
2430                 install
2431         cd .doc-tmp-dir && $(TAR) cf ../$(manpages).tar .
2432         gzip -n -9 -f $(manpages).tar
2433         $(RM) -r .doc-tmp-dir
2434
2435 ### Cleaning rules
2436
2437 distclean: clean
2438         $(RM) configure
2439         $(RM) config.log config.status config.cache
2440         $(RM) config.mak.autogen config.mak.append
2441         $(RM) -r autom4te.cache
2442
2443 profile-clean:
2444         $(RM) $(addsuffix *.gcda,$(addprefix $(PROFILE_DIR)/, $(object_dirs)))
2445         $(RM) $(addsuffix *.gcno,$(addprefix $(PROFILE_DIR)/, $(object_dirs)))
2446
2447 clean: profile-clean
2448         $(RM) *.o block-sha1/*.o ppc/*.o compat/*.o compat/*/*.o xdiff/*.o vcs-svn/*.o \
2449                 builtin/*.o $(LIB_FILE) $(XDIFF_LIB) $(VCSSVN_LIB)
2450         $(RM) $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) git$X
2451         $(RM) $(TEST_PROGRAMS)
2452         $(RM) -r bin-wrappers $(dep_dirs)
2453         $(RM) -r po/build/
2454         $(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo common-cmds.h $(ETAGS_TARGET) tags cscope*
2455         $(RM) -r $(GIT_TARNAME) .doc-tmp-dir
2456         $(RM) $(GIT_TARNAME).tar.gz git-core_$(GIT_VERSION)-*.tar.gz
2457         $(RM) $(htmldocs).tar.gz $(manpages).tar.gz
2458         $(MAKE) -C Documentation/ clean
2459 ifndef NO_PERL
2460         $(MAKE) -C gitweb clean
2461         $(MAKE) -C perl clean
2462 endif
2463 ifndef NO_PYTHON
2464         $(MAKE) -C git_remote_helpers clean
2465 endif
2466         $(MAKE) -C templates/ clean
2467         $(MAKE) -C t/ clean
2468 ifndef NO_TCLTK
2469         $(MAKE) -C gitk-git clean
2470         $(MAKE) -C git-gui clean
2471 endif
2472         $(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-LDFLAGS GIT-BUILD-OPTIONS
2473         $(RM) GIT-USER-AGENT GIT-PREFIX GIT-SCRIPT-DEFINES GIT-PYTHON-VARS
2474
2475 .PHONY: all install profile-clean clean strip
2476 .PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell
2477 .PHONY: FORCE cscope
2478
2479 ### Check documentation
2480 #
2481 ALL_COMMANDS = $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS)
2482 ALL_COMMANDS += git
2483 ALL_COMMANDS += gitk
2484 ALL_COMMANDS += gitweb
2485 ALL_COMMANDS += git-gui git-citool
2486 check-docs::
2487         @(for v in $(ALL_COMMANDS); \
2488         do \
2489                 case "$$v" in \
2490                 git-merge-octopus | git-merge-ours | git-merge-recursive | \
2491                 git-merge-resolve | git-merge-subtree | \
2492                 git-fsck-objects | git-init-db | \
2493                 git-remote-* | git-stage | \
2494                 git-?*--?* ) continue ;; \
2495                 esac ; \
2496                 test -f "Documentation/$$v.txt" || \
2497                 echo "no doc: $$v"; \
2498                 sed -e '/^#/d' command-list.txt | \
2499                 grep -q "^$$v[  ]" || \
2500                 case "$$v" in \
2501                 git) ;; \
2502                 *) echo "no link: $$v";; \
2503                 esac ; \
2504         done; \
2505         ( \
2506                 sed -e '/^#/d' \
2507                     -e 's/[     ].*//' \
2508                     -e 's/^/listed /' command-list.txt; \
2509                 $(MAKE) -C Documentation print-man1 | \
2510                 grep '\.txt$$' | \
2511                 sed -e 's|Documentation/|documented |' \
2512                     -e 's/\.txt//'; \
2513         ) | while read how cmd; \
2514         do \
2515                 case " $(ALL_COMMANDS) " in \
2516                 *" $$cmd "*)    ;; \
2517                 *) echo "removed but $$how: $$cmd" ;; \
2518                 esac; \
2519         done ) | sort
2520
2521 ### Make sure built-ins do not have dups and listed in git.c
2522 #
2523 check-builtins::
2524         ./check-builtins.sh
2525
2526 ### Test suite coverage testing
2527 #
2528 .PHONY: coverage coverage-clean coverage-build coverage-report
2529
2530 coverage:
2531         $(MAKE) coverage-build
2532         $(MAKE) coverage-report
2533
2534 object_dirs := $(sort $(dir $(OBJECTS)))
2535 coverage-clean:
2536         $(RM) $(addsuffix *.gcov,$(object_dirs))
2537         $(RM) $(addsuffix *.gcda,$(object_dirs))
2538         $(RM) $(addsuffix *.gcno,$(object_dirs))
2539         $(RM) coverage-untested-functions
2540         $(RM) -r cover_db/
2541         $(RM) -r cover_db_html/
2542
2543 COVERAGE_CFLAGS = $(CFLAGS) -O0 -ftest-coverage -fprofile-arcs
2544 COVERAGE_LDFLAGS = $(CFLAGS)  -O0 -lgcov
2545 GCOVFLAGS = --preserve-paths --branch-probabilities --all-blocks
2546
2547 coverage-build: coverage-clean
2548         $(MAKE) CFLAGS="$(COVERAGE_CFLAGS)" LDFLAGS="$(COVERAGE_LDFLAGS)" all
2549         $(MAKE) CFLAGS="$(COVERAGE_CFLAGS)" LDFLAGS="$(COVERAGE_LDFLAGS)" \
2550                 -j1 test
2551
2552 coverage-report:
2553         $(QUIET_GCOV)for dir in $(object_dirs); do \
2554                 $(GCOV) $(GCOVFLAGS) --object-directory=$$dir $$dir*.c || exit; \
2555         done
2556
2557 coverage-untested-functions: coverage-report
2558         grep '^function.*called 0 ' *.c.gcov \
2559                 | sed -e 's/\([^:]*\)\.gcov: *function \([^ ]*\) called.*/\1: \2/' \
2560                 > coverage-untested-functions
2561
2562 cover_db: coverage-report
2563         gcov2perl -db cover_db *.gcov
2564
2565 cover_db_html: cover_db
2566         cover -report html -outputdir cover_db_html cover_db
2567