]> rtime.felk.cvut.cz Git - git.git/blob - Makefile
Teach Makefile to check header dependencies
[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 SNPRINTF_RETURNS_BOGUS if your are on a system which snprintf()
12 # or vsnprintf() return -1 instead of number of characters which would
13 # have been written to the final string if enough space had been available.
14 #
15 # Define FREAD_READS_DIRECTORIES if your are on a system which succeeds
16 # when attempting to read from an fopen'ed directory.
17 #
18 # Define NO_OPENSSL environment variable if you do not have OpenSSL.
19 # This also implies BLK_SHA1.
20 #
21 # Define NO_CURL if you do not have libcurl installed.  git-http-pull and
22 # git-http-push are not built, and you cannot use http:// and https://
23 # transports.
24 #
25 # Define CURLDIR=/foo/bar if your curl header and library files are in
26 # /foo/bar/include and /foo/bar/lib directories.
27 #
28 # Define NO_EXPAT if you do not have expat installed.  git-http-push is
29 # not built, and you cannot push using http:// and https:// transports.
30 #
31 # Define EXPATDIR=/foo/bar if your expat header and library files are in
32 # /foo/bar/include and /foo/bar/lib directories.
33 #
34 # Define NO_D_INO_IN_DIRENT if you don't have d_ino in your struct dirent.
35 #
36 # Define NO_D_TYPE_IN_DIRENT if your platform defines DT_UNKNOWN but lacks
37 # d_type in struct dirent (latest Cygwin -- will be fixed soonish).
38 #
39 # Define NO_C99_FORMAT if your formatted IO functions (printf/scanf et.al.)
40 # do not support the 'size specifiers' introduced by C99, namely ll, hh,
41 # j, z, t. (representing long long int, char, intmax_t, size_t, ptrdiff_t).
42 # some C compilers supported these specifiers prior to C99 as an extension.
43 #
44 # Define NO_STRCASESTR if you don't have strcasestr.
45 #
46 # Define NO_MEMMEM if you don't have memmem.
47 #
48 # Define NO_STRLCPY if you don't have strlcpy.
49 #
50 # Define NO_STRTOUMAX if you don't have strtoumax in the C library.
51 # If your compiler also does not support long long or does not have
52 # strtoull, define NO_STRTOULL.
53 #
54 # Define NO_SETENV if you don't have setenv in the C library.
55 #
56 # Define NO_UNSETENV if you don't have unsetenv in the C library.
57 #
58 # Define NO_MKDTEMP if you don't have mkdtemp in the C library.
59 #
60 # Define NO_MKSTEMPS if you don't have mkstemps in the C library.
61 #
62 # Define NO_LIBGEN_H if you don't have libgen.h.
63 #
64 # Define NEEDS_LIBGEN if your libgen needs -lgen when linking
65 #
66 # Define NO_SYS_SELECT_H if you don't have sys/select.h.
67 #
68 # Define NO_SYMLINK_HEAD if you never want .git/HEAD to be a symbolic link.
69 # Enable it on Windows.  By default, symrefs are still used.
70 #
71 # Define NO_SVN_TESTS if you want to skip time-consuming SVN interoperability
72 # tests.  These tests take up a significant amount of the total test time
73 # but are not needed unless you plan to talk to SVN repos.
74 #
75 # Define NO_FINK if you are building on Darwin/Mac OS X, have Fink
76 # installed in /sw, but don't want GIT to link against any libraries
77 # installed there.  If defined you may specify your own (or Fink's)
78 # include directories and library directories by defining CFLAGS
79 # and LDFLAGS appropriately.
80 #
81 # Define NO_DARWIN_PORTS if you are building on Darwin/Mac OS X,
82 # have DarwinPorts installed in /opt/local, but don't want GIT to
83 # link against any libraries installed there.  If defined you may
84 # specify your own (or DarwinPort's) include directories and
85 # library directories by defining CFLAGS and LDFLAGS appropriately.
86 #
87 # Define BLK_SHA1 environment variable if you want the C version
88 # of the SHA1 that assumes you can do unaligned 32-bit loads and
89 # have a fast htonl() function.
90 #
91 # Define PPC_SHA1 environment variable when running make to make use of
92 # a bundled SHA1 routine optimized for PowerPC.
93 #
94 # Define NEEDS_CRYPTO_WITH_SSL if you need -lcrypto when using -lssl (Darwin).
95 #
96 # Define NEEDS_SSL_WITH_CRYPTO if you need -lssl when using -lcrypto (Darwin).
97 #
98 # Define NEEDS_LIBICONV if linking with libc is not enough (Darwin).
99 #
100 # Define NEEDS_SOCKET if linking with libc is not enough (SunOS,
101 # Patrick Mauritz).
102 #
103 # Define NEEDS_RESOLV if linking with -lnsl and/or -lsocket is not enough.
104 # Notably on Solaris hstrerror resides in libresolv and on Solaris 7
105 # inet_ntop and inet_pton additionally reside there.
106 #
107 # Define NO_MMAP if you want to avoid mmap.
108 #
109 # Define NO_PTHREADS if you do not have or do not want to use Pthreads.
110 #
111 # Define NO_PREAD if you have a problem with pread() system call (e.g.
112 # cygwin.dll before v1.5.22).
113 #
114 # Define NO_FAST_WORKING_DIRECTORY if accessing objects in pack files is
115 # generally faster on your platform than accessing the working directory.
116 #
117 # Define NO_TRUSTABLE_FILEMODE if your filesystem may claim to support
118 # the executable mode bit, but doesn't really do so.
119 #
120 # Define NO_IPV6 if you lack IPv6 support and getaddrinfo().
121 #
122 # Define NO_SOCKADDR_STORAGE if your platform does not have struct
123 # sockaddr_storage.
124 #
125 # Define NO_ICONV if your libc does not properly support iconv.
126 #
127 # Define OLD_ICONV if your library has an old iconv(), where the second
128 # (input buffer pointer) parameter is declared with type (const char **).
129 #
130 # Define NO_DEFLATE_BOUND if your zlib does not have deflateBound.
131 #
132 # Define NO_R_TO_GCC_LINKER if your gcc does not like "-R/path/lib"
133 # that tells runtime paths to dynamic libraries;
134 # "-Wl,-rpath=/path/lib" is used instead.
135 #
136 # Define USE_NSEC below if you want git to care about sub-second file mtimes
137 # and ctimes. Note that you need recent glibc (at least 2.2.4) for this, and
138 # it will BREAK YOUR LOCAL DIFFS! show-diff and anything using it will likely
139 # randomly break unless your underlying filesystem supports those sub-second
140 # times (my ext3 doesn't).
141 #
142 # Define USE_ST_TIMESPEC if your "struct stat" uses "st_ctimespec" instead of
143 # "st_ctim"
144 #
145 # Define NO_NSEC if your "struct stat" does not have "st_ctim.tv_nsec"
146 # available.  This automatically turns USE_NSEC off.
147 #
148 # Define USE_STDEV below if you want git to care about the underlying device
149 # change being considered an inode change from the update-index perspective.
150 #
151 # Define NO_ST_BLOCKS_IN_STRUCT_STAT if your platform does not have st_blocks
152 # field that counts the on-disk footprint in 512-byte blocks.
153 #
154 # Define ASCIIDOC8 if you want to format documentation with AsciiDoc 8
155 #
156 # Define DOCBOOK_XSL_172 if you want to format man pages with DocBook XSL v1.72
157 # (not v1.73 or v1.71).
158 #
159 # Define ASCIIDOC_NO_ROFF if your DocBook XSL escapes raw roff directives
160 # (versions 1.72 and later and 1.68.1 and earlier).
161 #
162 # Define GNU_ROFF if your target system uses GNU groff.  This forces
163 # apostrophes to be ASCII so that cut&pasting examples to the shell
164 # will work.
165 #
166 # Define NO_PERL_MAKEMAKER if you cannot use Makefiles generated by perl's
167 # MakeMaker (e.g. using ActiveState under Cygwin).
168 #
169 # Define NO_PERL if you do not want Perl scripts or libraries at all.
170 #
171 # Define NO_PYTHON if you do not want Python scripts or libraries at all.
172 #
173 # Define NO_TCLTK if you do not want Tcl/Tk GUI.
174 #
175 # The TCL_PATH variable governs the location of the Tcl interpreter
176 # used to optimize git-gui for your system.  Only used if NO_TCLTK
177 # is not set.  Defaults to the bare 'tclsh'.
178 #
179 # The TCLTK_PATH variable governs the location of the Tcl/Tk interpreter.
180 # If not set it defaults to the bare 'wish'. If it is set to the empty
181 # string then NO_TCLTK will be forced (this is used by configure script).
182 #
183 # Define THREADED_DELTA_SEARCH if you have pthreads and wish to exploit
184 # parallel delta searching when packing objects.
185 #
186 # Define INTERNAL_QSORT to use Git's implementation of qsort(), which
187 # is a simplified version of the merge sort used in glibc. This is
188 # recommended if Git triggers O(n^2) behavior in your platform's qsort().
189 #
190 # Define UNRELIABLE_FSTAT if your system's fstat does not return the same
191 # information on a not yet closed file that lstat would return for the same
192 # file after it was closed.
193 #
194 # Define OBJECT_CREATION_USES_RENAMES if your operating systems has problems
195 # when hardlinking a file to another name and unlinking the original file right
196 # away (some NTFS drivers seem to zero the contents in that scenario).
197 #
198 # Define NO_CROSS_DIRECTORY_HARDLINKS if you plan to distribute the installed
199 # programs as a tar, where bin/ and libexec/ might be on different file systems.
200 #
201 # Define USE_NED_ALLOCATOR if you want to replace the platforms default
202 # memory allocators with the nedmalloc allocator written by Niall Douglas.
203 #
204 # Define NO_REGEX if you have no or inferior regex support in your C library.
205 #
206 # Define JSMIN to point to JavaScript minifier that functions as
207 # a filter to have gitweb.js minified.
208 #
209 # Define DEFAULT_PAGER to a sensible pager command (defaults to "less") if
210 # you want to use something different.  The value will be interpreted by the
211 # shell at runtime when it is used.
212 #
213 # Define DEFAULT_EDITOR to a sensible editor command (defaults to "vi") if you
214 # want to use something different.  The value will be interpreted by the shell
215 # if necessary when it is used.  Examples:
216 #
217 #   DEFAULT_EDITOR='~/bin/vi',
218 #   DEFAULT_EDITOR='$GIT_FALLBACK_EDITOR',
219 #   DEFAULT_EDITOR='"C:\Program Files\Vim\gvim.exe" --nofork'
220 #
221 # Define COMPUTE_HEADER_DEPENDENCIES if your compiler supports the -MMD option
222 # and you want to avoid rebuilding objects when an unrelated header file
223 # changes.
224 #
225 # Define CHECK_HEADER_DEPENDENCIES to check for problems in the hard-coded
226 # dependency rules.
227
228 GIT-VERSION-FILE: FORCE
229         @$(SHELL_PATH) ./GIT-VERSION-GEN
230 -include GIT-VERSION-FILE
231
232 uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
233 uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not')
234 uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')
235 uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not')
236 uname_P := $(shell sh -c 'uname -p 2>/dev/null || echo not')
237 uname_V := $(shell sh -c 'uname -v 2>/dev/null || echo not')
238
239 ifdef MSVC
240         # avoid the MingW and Cygwin configuration sections
241         uname_S := Windows
242         uname_O := Windows
243 endif
244
245 # CFLAGS and LDFLAGS are for the users to override from the command line.
246
247 CFLAGS = -g -O2 -Wall
248 LDFLAGS =
249 ALL_CFLAGS = $(CFLAGS)
250 ALL_LDFLAGS = $(LDFLAGS)
251 STRIP ?= strip
252
253 # Among the variables below, these:
254 #   gitexecdir
255 #   template_dir
256 #   mandir
257 #   infodir
258 #   htmldir
259 #   ETC_GITCONFIG (but not sysconfdir)
260 # can be specified as a relative path some/where/else;
261 # this is interpreted as relative to $(prefix) and "git" at
262 # runtime figures out where they are based on the path to the executable.
263 # This can help installing the suite in a relocatable way.
264
265 prefix = $(HOME)
266 bindir_relative = bin
267 bindir = $(prefix)/$(bindir_relative)
268 mandir = share/man
269 infodir = share/info
270 gitexecdir = libexec/git-core
271 sharedir = $(prefix)/share
272 template_dir = share/git-core/templates
273 htmldir = share/doc/git-doc
274 ifeq ($(prefix),/usr)
275 sysconfdir = /etc
276 ETC_GITCONFIG = $(sysconfdir)/gitconfig
277 else
278 sysconfdir = $(prefix)/etc
279 ETC_GITCONFIG = etc/gitconfig
280 endif
281 lib = lib
282 # DESTDIR=
283 pathsep = :
284
285 # JavaScript minifier invocation that can function as filter
286 JSMIN =
287
288 # default configuration for gitweb
289 GITWEB_CONFIG = gitweb_config.perl
290 GITWEB_CONFIG_SYSTEM = /etc/gitweb.conf
291 GITWEB_HOME_LINK_STR = projects
292 GITWEB_SITENAME =
293 GITWEB_PROJECTROOT = /pub/git
294 GITWEB_PROJECT_MAXDEPTH = 2007
295 GITWEB_EXPORT_OK =
296 GITWEB_STRICT_EXPORT =
297 GITWEB_BASE_URL =
298 GITWEB_LIST =
299 GITWEB_HOMETEXT = indextext.html
300 GITWEB_CSS = gitweb.css
301 GITWEB_LOGO = git-logo.png
302 GITWEB_FAVICON = git-favicon.png
303 ifdef JSMIN
304 GITWEB_JS = gitweb.min.js
305 else
306 GITWEB_JS = gitweb.js
307 endif
308 GITWEB_SITE_HEADER =
309 GITWEB_SITE_FOOTER =
310
311 export prefix bindir sharedir sysconfdir
312
313 CC = gcc
314 AR = ar
315 RM = rm -f
316 TAR = tar
317 FIND = find
318 INSTALL = install
319 RPMBUILD = rpmbuild
320 TCL_PATH = tclsh
321 TCLTK_PATH = wish
322 PTHREAD_LIBS = -lpthread
323
324 export TCL_PATH TCLTK_PATH
325
326 # sparse is architecture-neutral, which means that we need to tell it
327 # explicitly what architecture to check for. Fix this up for yours..
328 SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
329
330
331
332 ### --- END CONFIGURATION SECTION ---
333
334 # Those must not be GNU-specific; they are shared with perl/ which may
335 # be built by a different compiler. (Note that this is an artifact now
336 # but it still might be nice to keep that distinction.)
337 BASIC_CFLAGS =
338 BASIC_LDFLAGS =
339
340 # Guard against environment variables
341 BUILTIN_OBJS =
342 BUILT_INS =
343 COMPAT_CFLAGS =
344 COMPAT_OBJS =
345 LIB_H =
346 LIB_OBJS =
347 PROGRAM_OBJS =
348 PROGRAMS =
349 SCRIPT_PERL =
350 SCRIPT_PYTHON =
351 SCRIPT_SH =
352 TEST_PROGRAMS_NEED_X =
353
354 SCRIPT_SH += git-am.sh
355 SCRIPT_SH += git-bisect.sh
356 SCRIPT_SH += git-difftool--helper.sh
357 SCRIPT_SH += git-filter-branch.sh
358 SCRIPT_SH += git-lost-found.sh
359 SCRIPT_SH += git-merge-octopus.sh
360 SCRIPT_SH += git-merge-one-file.sh
361 SCRIPT_SH += git-merge-resolve.sh
362 SCRIPT_SH += git-mergetool.sh
363 SCRIPT_SH += git-mergetool--lib.sh
364 SCRIPT_SH += git-notes.sh
365 SCRIPT_SH += git-parse-remote.sh
366 SCRIPT_SH += git-pull.sh
367 SCRIPT_SH += git-quiltimport.sh
368 SCRIPT_SH += git-rebase--interactive.sh
369 SCRIPT_SH += git-rebase.sh
370 SCRIPT_SH += git-repack.sh
371 SCRIPT_SH += git-request-pull.sh
372 SCRIPT_SH += git-sh-setup.sh
373 SCRIPT_SH += git-stash.sh
374 SCRIPT_SH += git-submodule.sh
375 SCRIPT_SH += git-web--browse.sh
376
377 SCRIPT_PERL += git-add--interactive.perl
378 SCRIPT_PERL += git-difftool.perl
379 SCRIPT_PERL += git-archimport.perl
380 SCRIPT_PERL += git-cvsexportcommit.perl
381 SCRIPT_PERL += git-cvsimport.perl
382 SCRIPT_PERL += git-cvsserver.perl
383 SCRIPT_PERL += git-relink.perl
384 SCRIPT_PERL += git-send-email.perl
385 SCRIPT_PERL += git-svn.perl
386
387 SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \
388           $(patsubst %.perl,%,$(SCRIPT_PERL)) \
389           $(patsubst %.py,%,$(SCRIPT_PYTHON)) \
390           git-instaweb
391
392 # Empty...
393 EXTRA_PROGRAMS =
394
395 # ... and all the rest that could be moved out of bindir to gitexecdir
396 PROGRAMS += $(EXTRA_PROGRAMS)
397
398 PROGRAM_OBJS += fast-import.o
399 PROGRAM_OBJS += imap-send.o
400 PROGRAM_OBJS += shell.o
401 PROGRAM_OBJS += show-index.o
402 PROGRAM_OBJS += upload-pack.o
403 PROGRAM_OBJS += http-backend.o
404
405 PROGRAMS += $(patsubst %.o,git-%$X,$(PROGRAM_OBJS))
406
407 TEST_PROGRAMS_NEED_X += test-chmtime
408 TEST_PROGRAMS_NEED_X += test-ctype
409 TEST_PROGRAMS_NEED_X += test-date
410 TEST_PROGRAMS_NEED_X += test-delta
411 TEST_PROGRAMS_NEED_X += test-dump-cache-tree
412 TEST_PROGRAMS_NEED_X += test-genrandom
413 TEST_PROGRAMS_NEED_X += test-match-trees
414 TEST_PROGRAMS_NEED_X += test-parse-options
415 TEST_PROGRAMS_NEED_X += test-path-utils
416 TEST_PROGRAMS_NEED_X += test-run-command
417 TEST_PROGRAMS_NEED_X += test-sha1
418 TEST_PROGRAMS_NEED_X += test-sigchain
419 TEST_PROGRAMS_NEED_X += test-index-version
420
421 TEST_PROGRAMS := $(patsubst %,%$X,$(TEST_PROGRAMS_NEED_X))
422
423 # List built-in command $C whose implementation cmd_$C() is not in
424 # builtin-$C.o but is linked in as part of some other command.
425 BUILT_INS += $(patsubst builtin-%.o,git-%$X,$(BUILTIN_OBJS))
426
427 BUILT_INS += git-cherry$X
428 BUILT_INS += git-cherry-pick$X
429 BUILT_INS += git-format-patch$X
430 BUILT_INS += git-fsck-objects$X
431 BUILT_INS += git-get-tar-commit-id$X
432 BUILT_INS += git-init$X
433 BUILT_INS += git-merge-subtree$X
434 BUILT_INS += git-peek-remote$X
435 BUILT_INS += git-repo-config$X
436 BUILT_INS += git-show$X
437 BUILT_INS += git-stage$X
438 BUILT_INS += git-status$X
439 BUILT_INS += git-whatchanged$X
440
441 # what 'all' will build and 'install' will install in gitexecdir,
442 # excluding programs for built-in commands
443 ALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS)
444
445 # what 'all' will build but not install in gitexecdir
446 OTHER_PROGRAMS = git$X
447
448 # what test wrappers are needed and 'install' will install, in bindir
449 BINDIR_PROGRAMS_NEED_X += git
450 BINDIR_PROGRAMS_NEED_X += git-upload-pack
451 BINDIR_PROGRAMS_NEED_X += git-receive-pack
452 BINDIR_PROGRAMS_NEED_X += git-upload-archive
453 BINDIR_PROGRAMS_NEED_X += git-shell
454
455 BINDIR_PROGRAMS_NO_X += git-cvsserver
456
457 # Set paths to tools early so that they can be used for version tests.
458 ifndef SHELL_PATH
459         SHELL_PATH = /bin/sh
460 endif
461 ifndef PERL_PATH
462         PERL_PATH = /usr/bin/perl
463 endif
464 ifndef PYTHON_PATH
465         PYTHON_PATH = /usr/bin/python
466 endif
467
468 export PERL_PATH
469 export PYTHON_PATH
470
471 LIB_FILE=libgit.a
472 XDIFF_LIB=xdiff/lib.a
473
474 LIB_H += advice.h
475 LIB_H += archive.h
476 LIB_H += attr.h
477 LIB_H += blob.h
478 LIB_H += builtin.h
479 LIB_H += cache.h
480 LIB_H += cache-tree.h
481 LIB_H += color.h
482 LIB_H += commit.h
483 LIB_H += compat/bswap.h
484 LIB_H += compat/cygwin.h
485 LIB_H += compat/mingw.h
486 LIB_H += compat/win32/pthread.h
487 LIB_H += csum-file.h
488 LIB_H += decorate.h
489 LIB_H += delta.h
490 LIB_H += diffcore.h
491 LIB_H += diff.h
492 LIB_H += dir.h
493 LIB_H += exec_cmd.h
494 LIB_H += fsck.h
495 LIB_H += git-compat-util.h
496 LIB_H += graph.h
497 LIB_H += grep.h
498 LIB_H += hash.h
499 LIB_H += help.h
500 LIB_H += levenshtein.h
501 LIB_H += list-objects.h
502 LIB_H += ll-merge.h
503 LIB_H += log-tree.h
504 LIB_H += mailmap.h
505 LIB_H += merge-recursive.h
506 LIB_H += notes.h
507 LIB_H += object.h
508 LIB_H += pack.h
509 LIB_H += pack-refs.h
510 LIB_H += pack-revindex.h
511 LIB_H += parse-options.h
512 LIB_H += patch-ids.h
513 LIB_H += pkt-line.h
514 LIB_H += progress.h
515 LIB_H += quote.h
516 LIB_H += reflog-walk.h
517 LIB_H += refs.h
518 LIB_H += remote.h
519 LIB_H += rerere.h
520 LIB_H += resolve-undo.h
521 LIB_H += revision.h
522 LIB_H += run-command.h
523 LIB_H += sha1-lookup.h
524 LIB_H += sideband.h
525 LIB_H += sigchain.h
526 LIB_H += strbuf.h
527 LIB_H += string-list.h
528 LIB_H += submodule.h
529 LIB_H += tag.h
530 LIB_H += transport.h
531 LIB_H += tree.h
532 LIB_H += tree-walk.h
533 LIB_H += unpack-trees.h
534 LIB_H += userdiff.h
535 LIB_H += utf8.h
536 LIB_H += xdiff-interface.h
537 LIB_H += xdiff/xdiff.h
538
539 LIB_OBJS += abspath.o
540 LIB_OBJS += advice.o
541 LIB_OBJS += alias.o
542 LIB_OBJS += alloc.o
543 LIB_OBJS += archive.o
544 LIB_OBJS += archive-tar.o
545 LIB_OBJS += archive-zip.o
546 LIB_OBJS += attr.o
547 LIB_OBJS += base85.o
548 LIB_OBJS += bisect.o
549 LIB_OBJS += blob.o
550 LIB_OBJS += branch.o
551 LIB_OBJS += bundle.o
552 LIB_OBJS += cache-tree.o
553 LIB_OBJS += color.o
554 LIB_OBJS += combine-diff.o
555 LIB_OBJS += commit.o
556 LIB_OBJS += config.o
557 LIB_OBJS += connect.o
558 LIB_OBJS += convert.o
559 LIB_OBJS += copy.o
560 LIB_OBJS += csum-file.o
561 LIB_OBJS += ctype.o
562 LIB_OBJS += date.o
563 LIB_OBJS += decorate.o
564 LIB_OBJS += diffcore-break.o
565 LIB_OBJS += diffcore-delta.o
566 LIB_OBJS += diffcore-order.o
567 LIB_OBJS += diffcore-pickaxe.o
568 LIB_OBJS += diffcore-rename.o
569 LIB_OBJS += diff-delta.o
570 LIB_OBJS += diff-lib.o
571 LIB_OBJS += diff-no-index.o
572 LIB_OBJS += diff.o
573 LIB_OBJS += dir.o
574 LIB_OBJS += editor.o
575 LIB_OBJS += entry.o
576 LIB_OBJS += environment.o
577 LIB_OBJS += exec_cmd.o
578 LIB_OBJS += fsck.o
579 LIB_OBJS += graph.o
580 LIB_OBJS += grep.o
581 LIB_OBJS += hash.o
582 LIB_OBJS += help.o
583 LIB_OBJS += hex.o
584 LIB_OBJS += ident.o
585 LIB_OBJS += levenshtein.o
586 LIB_OBJS += list-objects.o
587 LIB_OBJS += ll-merge.o
588 LIB_OBJS += lockfile.o
589 LIB_OBJS += log-tree.o
590 LIB_OBJS += mailmap.o
591 LIB_OBJS += match-trees.o
592 LIB_OBJS += merge-file.o
593 LIB_OBJS += merge-recursive.o
594 LIB_OBJS += name-hash.o
595 LIB_OBJS += notes.o
596 LIB_OBJS += object.o
597 LIB_OBJS += pack-check.o
598 LIB_OBJS += pack-refs.o
599 LIB_OBJS += pack-revindex.o
600 LIB_OBJS += pack-write.o
601 LIB_OBJS += pager.o
602 LIB_OBJS += parse-options.o
603 LIB_OBJS += patch-delta.o
604 LIB_OBJS += patch-ids.o
605 LIB_OBJS += path.o
606 LIB_OBJS += pkt-line.o
607 LIB_OBJS += preload-index.o
608 LIB_OBJS += pretty.o
609 LIB_OBJS += progress.o
610 LIB_OBJS += quote.o
611 LIB_OBJS += reachable.o
612 LIB_OBJS += read-cache.o
613 LIB_OBJS += reflog-walk.o
614 LIB_OBJS += refs.o
615 LIB_OBJS += remote.o
616 LIB_OBJS += replace_object.o
617 LIB_OBJS += rerere.o
618 LIB_OBJS += resolve-undo.o
619 LIB_OBJS += revision.o
620 LIB_OBJS += run-command.o
621 LIB_OBJS += server-info.o
622 LIB_OBJS += setup.o
623 LIB_OBJS += sha1-lookup.o
624 LIB_OBJS += sha1_file.o
625 LIB_OBJS += sha1_name.o
626 LIB_OBJS += shallow.o
627 LIB_OBJS += sideband.o
628 LIB_OBJS += sigchain.o
629 LIB_OBJS += strbuf.o
630 LIB_OBJS += string-list.o
631 LIB_OBJS += submodule.o
632 LIB_OBJS += symlinks.o
633 LIB_OBJS += tag.o
634 LIB_OBJS += trace.o
635 LIB_OBJS += transport.o
636 LIB_OBJS += transport-helper.o
637 LIB_OBJS += tree-diff.o
638 LIB_OBJS += tree.o
639 LIB_OBJS += tree-walk.o
640 LIB_OBJS += unpack-trees.o
641 LIB_OBJS += usage.o
642 LIB_OBJS += userdiff.o
643 LIB_OBJS += utf8.o
644 LIB_OBJS += walker.o
645 LIB_OBJS += wrapper.o
646 LIB_OBJS += write_or_die.o
647 LIB_OBJS += ws.o
648 LIB_OBJS += wt-status.o
649 LIB_OBJS += xdiff-interface.o
650
651 BUILTIN_OBJS += builtin-add.o
652 BUILTIN_OBJS += builtin-annotate.o
653 BUILTIN_OBJS += builtin-apply.o
654 BUILTIN_OBJS += builtin-archive.o
655 BUILTIN_OBJS += builtin-bisect--helper.o
656 BUILTIN_OBJS += builtin-blame.o
657 BUILTIN_OBJS += builtin-branch.o
658 BUILTIN_OBJS += builtin-bundle.o
659 BUILTIN_OBJS += builtin-cat-file.o
660 BUILTIN_OBJS += builtin-check-attr.o
661 BUILTIN_OBJS += builtin-check-ref-format.o
662 BUILTIN_OBJS += builtin-checkout-index.o
663 BUILTIN_OBJS += builtin-checkout.o
664 BUILTIN_OBJS += builtin-clean.o
665 BUILTIN_OBJS += builtin-clone.o
666 BUILTIN_OBJS += builtin-commit-tree.o
667 BUILTIN_OBJS += builtin-commit.o
668 BUILTIN_OBJS += builtin-config.o
669 BUILTIN_OBJS += builtin-count-objects.o
670 BUILTIN_OBJS += builtin-describe.o
671 BUILTIN_OBJS += builtin-diff-files.o
672 BUILTIN_OBJS += builtin-diff-index.o
673 BUILTIN_OBJS += builtin-diff-tree.o
674 BUILTIN_OBJS += builtin-diff.o
675 BUILTIN_OBJS += builtin-fast-export.o
676 BUILTIN_OBJS += builtin-fetch-pack.o
677 BUILTIN_OBJS += builtin-fetch.o
678 BUILTIN_OBJS += builtin-fmt-merge-msg.o
679 BUILTIN_OBJS += builtin-for-each-ref.o
680 BUILTIN_OBJS += builtin-fsck.o
681 BUILTIN_OBJS += builtin-gc.o
682 BUILTIN_OBJS += builtin-grep.o
683 BUILTIN_OBJS += builtin-hash-object.o
684 BUILTIN_OBJS += builtin-help.o
685 BUILTIN_OBJS += builtin-index-pack.o
686 BUILTIN_OBJS += builtin-init-db.o
687 BUILTIN_OBJS += builtin-log.o
688 BUILTIN_OBJS += builtin-ls-files.o
689 BUILTIN_OBJS += builtin-ls-remote.o
690 BUILTIN_OBJS += builtin-ls-tree.o
691 BUILTIN_OBJS += builtin-mailinfo.o
692 BUILTIN_OBJS += builtin-mailsplit.o
693 BUILTIN_OBJS += builtin-merge.o
694 BUILTIN_OBJS += builtin-merge-base.o
695 BUILTIN_OBJS += builtin-merge-file.o
696 BUILTIN_OBJS += builtin-merge-index.o
697 BUILTIN_OBJS += builtin-merge-ours.o
698 BUILTIN_OBJS += builtin-merge-recursive.o
699 BUILTIN_OBJS += builtin-merge-tree.o
700 BUILTIN_OBJS += builtin-mktag.o
701 BUILTIN_OBJS += builtin-mktree.o
702 BUILTIN_OBJS += builtin-mv.o
703 BUILTIN_OBJS += builtin-name-rev.o
704 BUILTIN_OBJS += builtin-pack-objects.o
705 BUILTIN_OBJS += builtin-pack-redundant.o
706 BUILTIN_OBJS += builtin-pack-refs.o
707 BUILTIN_OBJS += builtin-patch-id.o
708 BUILTIN_OBJS += builtin-prune-packed.o
709 BUILTIN_OBJS += builtin-prune.o
710 BUILTIN_OBJS += builtin-push.o
711 BUILTIN_OBJS += builtin-read-tree.o
712 BUILTIN_OBJS += builtin-receive-pack.o
713 BUILTIN_OBJS += builtin-reflog.o
714 BUILTIN_OBJS += builtin-remote.o
715 BUILTIN_OBJS += builtin-replace.o
716 BUILTIN_OBJS += builtin-rerere.o
717 BUILTIN_OBJS += builtin-reset.o
718 BUILTIN_OBJS += builtin-rev-list.o
719 BUILTIN_OBJS += builtin-rev-parse.o
720 BUILTIN_OBJS += builtin-revert.o
721 BUILTIN_OBJS += builtin-rm.o
722 BUILTIN_OBJS += builtin-send-pack.o
723 BUILTIN_OBJS += builtin-shortlog.o
724 BUILTIN_OBJS += builtin-show-branch.o
725 BUILTIN_OBJS += builtin-show-ref.o
726 BUILTIN_OBJS += builtin-stripspace.o
727 BUILTIN_OBJS += builtin-symbolic-ref.o
728 BUILTIN_OBJS += builtin-tag.o
729 BUILTIN_OBJS += builtin-tar-tree.o
730 BUILTIN_OBJS += builtin-unpack-file.o
731 BUILTIN_OBJS += builtin-unpack-objects.o
732 BUILTIN_OBJS += builtin-update-index.o
733 BUILTIN_OBJS += builtin-update-ref.o
734 BUILTIN_OBJS += builtin-update-server-info.o
735 BUILTIN_OBJS += builtin-upload-archive.o
736 BUILTIN_OBJS += builtin-var.o
737 BUILTIN_OBJS += builtin-verify-pack.o
738 BUILTIN_OBJS += builtin-verify-tag.o
739 BUILTIN_OBJS += builtin-write-tree.o
740
741 TEST_OBJS := $(patsubst test-%$X,test-%.o,$(TEST_PROGRAMS))
742
743 GITLIBS = $(LIB_FILE) $(XDIFF_LIB)
744 EXTLIBS =
745
746 #
747 # Platform specific tweaks
748 #
749
750 # We choose to avoid "if .. else if .. else .. endif endif"
751 # because maintaining the nesting to match is a pain.  If
752 # we had "elif" things would have been much nicer...
753
754 ifeq ($(uname_S),Linux)
755         NO_STRLCPY = YesPlease
756         NO_MKSTEMPS = YesPlease
757         THREADED_DELTA_SEARCH = YesPlease
758 endif
759 ifeq ($(uname_S),GNU/kFreeBSD)
760         NO_STRLCPY = YesPlease
761         NO_MKSTEMPS = YesPlease
762         THREADED_DELTA_SEARCH = YesPlease
763 endif
764 ifeq ($(uname_S),UnixWare)
765         CC = cc
766         NEEDS_SOCKET = YesPlease
767         NEEDS_NSL = YesPlease
768         NEEDS_SSL_WITH_CRYPTO = YesPlease
769         NEEDS_LIBICONV = YesPlease
770         SHELL_PATH = /usr/local/bin/bash
771         NO_IPV6 = YesPlease
772         NO_HSTRERROR = YesPlease
773         NO_MKSTEMPS = YesPlease
774         BASIC_CFLAGS += -Kthread
775         BASIC_CFLAGS += -I/usr/local/include
776         BASIC_LDFLAGS += -L/usr/local/lib
777         INSTALL = ginstall
778         TAR = gtar
779         NO_STRCASESTR = YesPlease
780         NO_MEMMEM = YesPlease
781 endif
782 ifeq ($(uname_S),SCO_SV)
783         ifeq ($(uname_R),3.2)
784                 CFLAGS = -O2
785         endif
786         ifeq ($(uname_R),5)
787                 CC = cc
788                 BASIC_CFLAGS += -Kthread
789         endif
790         NEEDS_SOCKET = YesPlease
791         NEEDS_NSL = YesPlease
792         NEEDS_SSL_WITH_CRYPTO = YesPlease
793         NEEDS_LIBICONV = YesPlease
794         SHELL_PATH = /usr/bin/bash
795         NO_IPV6 = YesPlease
796         NO_HSTRERROR = YesPlease
797         NO_MKSTEMPS = YesPlease
798         BASIC_CFLAGS += -I/usr/local/include
799         BASIC_LDFLAGS += -L/usr/local/lib
800         NO_STRCASESTR = YesPlease
801         NO_MEMMEM = YesPlease
802         INSTALL = ginstall
803         TAR = gtar
804 endif
805 ifeq ($(uname_S),Darwin)
806         NEEDS_CRYPTO_WITH_SSL = YesPlease
807         NEEDS_SSL_WITH_CRYPTO = YesPlease
808         NEEDS_LIBICONV = YesPlease
809         ifeq ($(shell expr "$(uname_R)" : '[15678]\.'),2)
810                 OLD_ICONV = UnfortunatelyYes
811         endif
812         ifeq ($(shell expr "$(uname_R)" : '[15]\.'),2)
813                 NO_STRLCPY = YesPlease
814         endif
815         NO_MEMMEM = YesPlease
816         THREADED_DELTA_SEARCH = YesPlease
817         USE_ST_TIMESPEC = YesPlease
818 endif
819 ifeq ($(uname_S),SunOS)
820         NEEDS_SOCKET = YesPlease
821         NEEDS_NSL = YesPlease
822         SHELL_PATH = /bin/bash
823         SANE_TOOL_PATH = /usr/xpg6/bin:/usr/xpg4/bin
824         NO_STRCASESTR = YesPlease
825         NO_MEMMEM = YesPlease
826         NO_MKDTEMP = YesPlease
827         NO_MKSTEMPS = YesPlease
828         NO_REGEX = YesPlease
829         THREADED_DELTA_SEARCH = YesPlease
830         ifeq ($(uname_R),5.7)
831                 NEEDS_RESOLV = YesPlease
832                 NO_IPV6 = YesPlease
833                 NO_SOCKADDR_STORAGE = YesPlease
834                 NO_UNSETENV = YesPlease
835                 NO_SETENV = YesPlease
836                 NO_STRLCPY = YesPlease
837                 NO_C99_FORMAT = YesPlease
838                 NO_STRTOUMAX = YesPlease
839         endif
840         ifeq ($(uname_R),5.8)
841                 NO_UNSETENV = YesPlease
842                 NO_SETENV = YesPlease
843                 NO_C99_FORMAT = YesPlease
844                 NO_STRTOUMAX = YesPlease
845         endif
846         ifeq ($(uname_R),5.9)
847                 NO_UNSETENV = YesPlease
848                 NO_SETENV = YesPlease
849                 NO_C99_FORMAT = YesPlease
850                 NO_STRTOUMAX = YesPlease
851         endif
852         INSTALL = /usr/ucb/install
853         TAR = gtar
854         BASIC_CFLAGS += -D__EXTENSIONS__ -D__sun__ -DHAVE_ALLOCA_H
855 endif
856 ifeq ($(uname_O),Cygwin)
857         NO_D_TYPE_IN_DIRENT = YesPlease
858         NO_D_INO_IN_DIRENT = YesPlease
859         NO_STRCASESTR = YesPlease
860         NO_MEMMEM = YesPlease
861         NO_MKSTEMPS = YesPlease
862         NO_SYMLINK_HEAD = YesPlease
863         NEEDS_LIBICONV = YesPlease
864         NO_FAST_WORKING_DIRECTORY = UnfortunatelyYes
865         NO_TRUSTABLE_FILEMODE = UnfortunatelyYes
866         OLD_ICONV = UnfortunatelyYes
867         NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease
868         # There are conflicting reports about this.
869         # On some boxes NO_MMAP is needed, and not so elsewhere.
870         # Try commenting this out if you suspect MMAP is more efficient
871         NO_MMAP = YesPlease
872         NO_IPV6 = YesPlease
873         X = .exe
874         COMPAT_OBJS += compat/cygwin.o
875         UNRELIABLE_FSTAT = UnfortunatelyYes
876 endif
877 ifeq ($(uname_S),FreeBSD)
878         NEEDS_LIBICONV = YesPlease
879         OLD_ICONV = YesPlease
880         NO_MEMMEM = YesPlease
881         BASIC_CFLAGS += -I/usr/local/include
882         BASIC_LDFLAGS += -L/usr/local/lib
883         DIR_HAS_BSD_GROUP_SEMANTICS = YesPlease
884         USE_ST_TIMESPEC = YesPlease
885         THREADED_DELTA_SEARCH = YesPlease
886         ifeq ($(shell expr "$(uname_R)" : '4\.'),2)
887                 PTHREAD_LIBS = -pthread
888                 NO_UINTMAX_T = YesPlease
889                 NO_STRTOUMAX = YesPlease
890         endif
891 endif
892 ifeq ($(uname_S),OpenBSD)
893         NO_STRCASESTR = YesPlease
894         NO_MEMMEM = YesPlease
895         USE_ST_TIMESPEC = YesPlease
896         NEEDS_LIBICONV = YesPlease
897         BASIC_CFLAGS += -I/usr/local/include
898         BASIC_LDFLAGS += -L/usr/local/lib
899         THREADED_DELTA_SEARCH = YesPlease
900 endif
901 ifeq ($(uname_S),NetBSD)
902         ifeq ($(shell expr "$(uname_R)" : '[01]\.'),2)
903                 NEEDS_LIBICONV = YesPlease
904         endif
905         BASIC_CFLAGS += -I/usr/pkg/include
906         BASIC_LDFLAGS += -L/usr/pkg/lib $(CC_LD_DYNPATH)/usr/pkg/lib
907         THREADED_DELTA_SEARCH = YesPlease
908         USE_ST_TIMESPEC = YesPlease
909         NO_MKSTEMPS = YesPlease
910 endif
911 ifeq ($(uname_S),AIX)
912         NO_STRCASESTR=YesPlease
913         NO_MEMMEM = YesPlease
914         NO_MKDTEMP = YesPlease
915         NO_MKSTEMPS = YesPlease
916         NO_STRLCPY = YesPlease
917         NO_NSEC = YesPlease
918         FREAD_READS_DIRECTORIES = UnfortunatelyYes
919         INTERNAL_QSORT = UnfortunatelyYes
920         NEEDS_LIBICONV=YesPlease
921         BASIC_CFLAGS += -D_LARGE_FILES
922         ifneq ($(shell expr "$(uname_V)" : '[1234]'),1)
923                 THREADED_DELTA_SEARCH = YesPlease
924         else
925                 NO_PTHREADS = YesPlease
926         endif
927 endif
928 ifeq ($(uname_S),GNU)
929         # GNU/Hurd
930         NO_STRLCPY=YesPlease
931         NO_MKSTEMPS = YesPlease
932 endif
933 ifeq ($(uname_S),IRIX)
934         NO_SETENV = YesPlease
935         NO_UNSETENV = YesPlease
936         NO_STRCASESTR = YesPlease
937         NO_MEMMEM = YesPlease
938         NO_MKSTEMPS = YesPlease
939         NO_MKDTEMP = YesPlease
940         # When compiled with the MIPSpro 7.4.4m compiler, and without pthreads
941         # (i.e. NO_PTHREADS is set), and _with_ MMAP (i.e. NO_MMAP is not set),
942         # git dies with a segmentation fault when trying to access the first
943         # entry of a reflog.  The conservative choice is made to always set
944         # NO_MMAP.  If you suspect that your compiler is not affected by this
945         # issue, comment out the NO_MMAP statement.
946         NO_MMAP = YesPlease
947         SNPRINTF_RETURNS_BOGUS = YesPlease
948         SHELL_PATH = /usr/gnu/bin/bash
949         NEEDS_LIBGEN = YesPlease
950         THREADED_DELTA_SEARCH = YesPlease
951 endif
952 ifeq ($(uname_S),IRIX64)
953         NO_SETENV=YesPlease
954         NO_UNSETENV = YesPlease
955         NO_STRCASESTR=YesPlease
956         NO_MEMMEM = YesPlease
957         NO_MKSTEMPS = YesPlease
958         NO_MKDTEMP = YesPlease
959         # When compiled with the MIPSpro 7.4.4m compiler, and without pthreads
960         # (i.e. NO_PTHREADS is set), and _with_ MMAP (i.e. NO_MMAP is not set),
961         # git dies with a segmentation fault when trying to access the first
962         # entry of a reflog.  The conservative choice is made to always set
963         # NO_MMAP.  If you suspect that your compiler is not affected by this
964         # issue, comment out the NO_MMAP statement.
965         NO_MMAP = YesPlease
966         SNPRINTF_RETURNS_BOGUS = YesPlease
967         SHELL_PATH=/usr/gnu/bin/bash
968         NEEDS_LIBGEN = YesPlease
969         THREADED_DELTA_SEARCH = YesPlease
970 endif
971 ifeq ($(uname_S),HP-UX)
972         NO_IPV6=YesPlease
973         NO_SETENV=YesPlease
974         NO_STRCASESTR=YesPlease
975         NO_MEMMEM = YesPlease
976         NO_MKSTEMPS = YesPlease
977         NO_STRLCPY = YesPlease
978         NO_MKDTEMP = YesPlease
979         NO_UNSETENV = YesPlease
980         NO_HSTRERROR = YesPlease
981         NO_SYS_SELECT_H = YesPlease
982         SNPRINTF_RETURNS_BOGUS = YesPlease
983 endif
984 ifeq ($(uname_S),Windows)
985         GIT_VERSION := $(GIT_VERSION).MSVC
986         pathsep = ;
987         NO_PREAD = YesPlease
988         NEEDS_CRYPTO_WITH_SSL = YesPlease
989         NO_LIBGEN_H = YesPlease
990         NO_SYMLINK_HEAD = YesPlease
991         NO_IPV6 = YesPlease
992         NO_SETENV = YesPlease
993         NO_UNSETENV = YesPlease
994         NO_STRCASESTR = YesPlease
995         NO_STRLCPY = YesPlease
996         NO_MEMMEM = YesPlease
997         # NEEDS_LIBICONV = YesPlease
998         NO_ICONV = YesPlease
999         NO_C99_FORMAT = YesPlease
1000         NO_STRTOUMAX = YesPlease
1001         NO_STRTOULL = YesPlease
1002         NO_MKDTEMP = YesPlease
1003         NO_MKSTEMPS = YesPlease
1004         SNPRINTF_RETURNS_BOGUS = YesPlease
1005         NO_SVN_TESTS = YesPlease
1006         NO_PERL_MAKEMAKER = YesPlease
1007         RUNTIME_PREFIX = YesPlease
1008         NO_POSIX_ONLY_PROGRAMS = YesPlease
1009         NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease
1010         NO_NSEC = YesPlease
1011         USE_WIN32_MMAP = YesPlease
1012         # USE_NED_ALLOCATOR = YesPlease
1013         UNRELIABLE_FSTAT = UnfortunatelyYes
1014         OBJECT_CREATION_USES_RENAMES = UnfortunatelyNeedsTo
1015         NO_REGEX = YesPlease
1016         NO_CURL = YesPlease
1017         NO_PYTHON = YesPlease
1018         BLK_SHA1 = YesPlease
1019         THREADED_DELTA_SEARCH = YesPlease
1020
1021         CC = compat/vcbuild/scripts/clink.pl
1022         AR = compat/vcbuild/scripts/lib.pl
1023         CFLAGS =
1024         BASIC_CFLAGS = -nologo -I. -I../zlib -Icompat/vcbuild -Icompat/vcbuild/include -DWIN32 -D_CONSOLE -DHAVE_STRING_H -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE
1025         COMPAT_OBJS = compat/msvc.o compat/fnmatch/fnmatch.o compat/winansi.o compat/win32/pthread.o
1026         COMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DNOGDI -DHAVE_STRING_H -DHAVE_ALLOCA_H -Icompat -Icompat/fnmatch -Icompat/regex -Icompat/fnmatch -Icompat/win32 -DSTRIP_EXTENSION=\".exe\"
1027         BASIC_LDFLAGS = -IGNORE:4217 -IGNORE:4049 -NOLOGO -SUBSYSTEM:CONSOLE -NODEFAULTLIB:MSVCRT.lib
1028         EXTLIBS = advapi32.lib shell32.lib wininet.lib ws2_32.lib
1029         PTHREAD_LIBS =
1030         lib =
1031 ifndef DEBUG
1032         BASIC_CFLAGS += -GL -Os -MT
1033         BASIC_LDFLAGS += -LTCG
1034         AR += -LTCG
1035 else
1036         BASIC_CFLAGS += -Zi -MTd
1037 endif
1038         X = .exe
1039 endif
1040 ifneq (,$(findstring MINGW,$(uname_S)))
1041         pathsep = ;
1042         NO_PREAD = YesPlease
1043         NEEDS_CRYPTO_WITH_SSL = YesPlease
1044         NO_LIBGEN_H = YesPlease
1045         NO_SYMLINK_HEAD = YesPlease
1046         NO_SETENV = YesPlease
1047         NO_UNSETENV = YesPlease
1048         NO_STRCASESTR = YesPlease
1049         NO_STRLCPY = YesPlease
1050         NO_MEMMEM = YesPlease
1051         NEEDS_LIBICONV = YesPlease
1052         OLD_ICONV = YesPlease
1053         NO_C99_FORMAT = YesPlease
1054         NO_STRTOUMAX = YesPlease
1055         NO_MKDTEMP = YesPlease
1056         NO_MKSTEMPS = YesPlease
1057         SNPRINTF_RETURNS_BOGUS = YesPlease
1058         NO_SVN_TESTS = YesPlease
1059         NO_PERL_MAKEMAKER = YesPlease
1060         RUNTIME_PREFIX = YesPlease
1061         NO_POSIX_ONLY_PROGRAMS = YesPlease
1062         NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease
1063         NO_NSEC = YesPlease
1064         USE_WIN32_MMAP = YesPlease
1065         USE_NED_ALLOCATOR = YesPlease
1066         UNRELIABLE_FSTAT = UnfortunatelyYes
1067         OBJECT_CREATION_USES_RENAMES = UnfortunatelyNeedsTo
1068         NO_REGEX = YesPlease
1069         NO_PYTHON = YesPlease
1070         BLK_SHA1 = YesPlease
1071         THREADED_DELTA_SEARCH = YesPlease
1072         COMPAT_CFLAGS += -D__USE_MINGW_ACCESS -DNOGDI -Icompat -Icompat/fnmatch -Icompat/win32
1073         COMPAT_CFLAGS += -DSTRIP_EXTENSION=\".exe\"
1074         COMPAT_OBJS += compat/mingw.o compat/fnmatch/fnmatch.o compat/winansi.o \
1075                 compat/win32/pthread.o
1076         EXTLIBS += -lws2_32
1077         PTHREAD_LIBS =
1078         X = .exe
1079 ifneq (,$(wildcard ../THIS_IS_MSYSGIT))
1080         htmldir=doc/git/html/
1081         prefix =
1082         INSTALL = /bin/install
1083         EXTLIBS += /mingw/lib/libz.a
1084         NO_R_TO_GCC_LINKER = YesPlease
1085         INTERNAL_QSORT = YesPlease
1086 else
1087         NO_CURL = YesPlease
1088 endif
1089 endif
1090
1091 -include config.mak.autogen
1092 -include config.mak
1093
1094 ifdef CHECK_HEADER_DEPENDENCIES
1095 USE_COMPUTED_HEADER_DEPENDENCIES =
1096 endif
1097
1098 ifdef COMPUTE_HEADER_DEPENDENCIES
1099 USE_COMPUTED_HEADER_DEPENDENCIES = YesPlease
1100 endif
1101
1102 ifdef SANE_TOOL_PATH
1103 SANE_TOOL_PATH_SQ = $(subst ','\'',$(SANE_TOOL_PATH))
1104 BROKEN_PATH_FIX = 's|^\# @@BROKEN_PATH_FIX@@$$|git_broken_path_fix $(SANE_TOOL_PATH_SQ)|'
1105 PATH := $(SANE_TOOL_PATH):${PATH}
1106 else
1107 BROKEN_PATH_FIX = '/^\# @@BROKEN_PATH_FIX@@$$/d'
1108 endif
1109
1110 ifeq ($(uname_S),Darwin)
1111         ifndef NO_FINK
1112                 ifeq ($(shell test -d /sw/lib && echo y),y)
1113                         BASIC_CFLAGS += -I/sw/include
1114                         BASIC_LDFLAGS += -L/sw/lib
1115                 endif
1116         endif
1117         ifndef NO_DARWIN_PORTS
1118                 ifeq ($(shell test -d /opt/local/lib && echo y),y)
1119                         BASIC_CFLAGS += -I/opt/local/include
1120                         BASIC_LDFLAGS += -L/opt/local/lib
1121                 endif
1122         endif
1123         PTHREAD_LIBS =
1124 endif
1125
1126 ifndef CC_LD_DYNPATH
1127         ifdef NO_R_TO_GCC_LINKER
1128                 # Some gcc does not accept and pass -R to the linker to specify
1129                 # the runtime dynamic library path.
1130                 CC_LD_DYNPATH = -Wl,-rpath,
1131         else
1132                 CC_LD_DYNPATH = -R
1133         endif
1134 endif
1135
1136 ifdef NO_LIBGEN_H
1137         COMPAT_CFLAGS += -DNO_LIBGEN_H
1138         COMPAT_OBJS += compat/basename.o
1139 endif
1140
1141 ifdef NO_CURL
1142         BASIC_CFLAGS += -DNO_CURL
1143         REMOTE_CURL_PRIMARY =
1144         REMOTE_CURL_ALIASES =
1145         REMOTE_CURL_NAMES =
1146 else
1147         ifdef CURLDIR
1148                 # Try "-Wl,-rpath=$(CURLDIR)/$(lib)" in such a case.
1149                 BASIC_CFLAGS += -I$(CURLDIR)/include
1150                 CURL_LIBCURL = -L$(CURLDIR)/$(lib) $(CC_LD_DYNPATH)$(CURLDIR)/$(lib) -lcurl
1151         else
1152                 CURL_LIBCURL = -lcurl
1153         endif
1154         REMOTE_CURL_PRIMARY = git-remote-http$X
1155         REMOTE_CURL_ALIASES = git-remote-https$X git-remote-ftp$X git-remote-ftps$X
1156         REMOTE_CURL_NAMES = $(REMOTE_CURL_PRIMARY) $(REMOTE_CURL_ALIASES)
1157         PROGRAM_OBJS += http-fetch.o
1158         PROGRAMS += $(REMOTE_CURL_NAMES)
1159         curl_check := $(shell (echo 070908; curl-config --vernum) | sort -r | sed -ne 2p)
1160         ifeq "$(curl_check)" "070908"
1161                 ifndef NO_EXPAT
1162                         PROGRAM_OBJS += http-push.o
1163                 endif
1164         endif
1165         ifndef NO_EXPAT
1166                 ifdef EXPATDIR
1167                         BASIC_CFLAGS += -I$(EXPATDIR)/include
1168                         EXPAT_LIBEXPAT = -L$(EXPATDIR)/$(lib) $(CC_LD_DYNPATH)$(EXPATDIR)/$(lib) -lexpat
1169                 else
1170                         EXPAT_LIBEXPAT = -lexpat
1171                 endif
1172         endif
1173 endif
1174
1175 ifdef ZLIB_PATH
1176         BASIC_CFLAGS += -I$(ZLIB_PATH)/include
1177         EXTLIBS += -L$(ZLIB_PATH)/$(lib) $(CC_LD_DYNPATH)$(ZLIB_PATH)/$(lib)
1178 endif
1179 EXTLIBS += -lz
1180
1181 ifndef NO_POSIX_ONLY_PROGRAMS
1182         PROGRAM_OBJS += daemon.o
1183 endif
1184 ifndef NO_OPENSSL
1185         OPENSSL_LIBSSL = -lssl
1186         ifdef OPENSSLDIR
1187                 BASIC_CFLAGS += -I$(OPENSSLDIR)/include
1188                 OPENSSL_LINK = -L$(OPENSSLDIR)/$(lib) $(CC_LD_DYNPATH)$(OPENSSLDIR)/$(lib)
1189         else
1190                 OPENSSL_LINK =
1191         endif
1192         ifdef NEEDS_CRYPTO_WITH_SSL
1193                 OPENSSL_LINK += -lcrypto
1194         endif
1195 else
1196         BASIC_CFLAGS += -DNO_OPENSSL
1197         BLK_SHA1 = 1
1198         OPENSSL_LIBSSL =
1199 endif
1200 ifdef NEEDS_SSL_WITH_CRYPTO
1201         LIB_4_CRYPTO = $(OPENSSL_LINK) -lcrypto -lssl
1202 else
1203         LIB_4_CRYPTO = $(OPENSSL_LINK) -lcrypto
1204 endif
1205 ifdef NEEDS_LIBICONV
1206         ifdef ICONVDIR
1207                 BASIC_CFLAGS += -I$(ICONVDIR)/include
1208                 ICONV_LINK = -L$(ICONVDIR)/$(lib) $(CC_LD_DYNPATH)$(ICONVDIR)/$(lib)
1209         else
1210                 ICONV_LINK =
1211         endif
1212         EXTLIBS += $(ICONV_LINK) -liconv
1213 endif
1214 ifdef NEEDS_LIBGEN
1215         EXTLIBS += -lgen
1216 endif
1217 ifdef NEEDS_SOCKET
1218         EXTLIBS += -lsocket
1219 endif
1220 ifdef NEEDS_NSL
1221         EXTLIBS += -lnsl
1222 endif
1223 ifdef NEEDS_RESOLV
1224         EXTLIBS += -lresolv
1225 endif
1226 ifdef NO_D_TYPE_IN_DIRENT
1227         BASIC_CFLAGS += -DNO_D_TYPE_IN_DIRENT
1228 endif
1229 ifdef NO_D_INO_IN_DIRENT
1230         BASIC_CFLAGS += -DNO_D_INO_IN_DIRENT
1231 endif
1232 ifdef NO_ST_BLOCKS_IN_STRUCT_STAT
1233         BASIC_CFLAGS += -DNO_ST_BLOCKS_IN_STRUCT_STAT
1234 endif
1235 ifdef USE_NSEC
1236         BASIC_CFLAGS += -DUSE_NSEC
1237 endif
1238 ifdef USE_ST_TIMESPEC
1239         BASIC_CFLAGS += -DUSE_ST_TIMESPEC
1240 endif
1241 ifdef NO_NSEC
1242         BASIC_CFLAGS += -DNO_NSEC
1243 endif
1244 ifdef NO_C99_FORMAT
1245         BASIC_CFLAGS += -DNO_C99_FORMAT
1246 endif
1247 ifdef SNPRINTF_RETURNS_BOGUS
1248         COMPAT_CFLAGS += -DSNPRINTF_RETURNS_BOGUS
1249         COMPAT_OBJS += compat/snprintf.o
1250 endif
1251 ifdef FREAD_READS_DIRECTORIES
1252         COMPAT_CFLAGS += -DFREAD_READS_DIRECTORIES
1253         COMPAT_OBJS += compat/fopen.o
1254 endif
1255 ifdef NO_SYMLINK_HEAD
1256         BASIC_CFLAGS += -DNO_SYMLINK_HEAD
1257 endif
1258 ifdef NO_STRCASESTR
1259         COMPAT_CFLAGS += -DNO_STRCASESTR
1260         COMPAT_OBJS += compat/strcasestr.o
1261 endif
1262 ifdef NO_STRLCPY
1263         COMPAT_CFLAGS += -DNO_STRLCPY
1264         COMPAT_OBJS += compat/strlcpy.o
1265 endif
1266 ifdef NO_STRTOUMAX
1267         COMPAT_CFLAGS += -DNO_STRTOUMAX
1268         COMPAT_OBJS += compat/strtoumax.o
1269 endif
1270 ifdef NO_STRTOULL
1271         COMPAT_CFLAGS += -DNO_STRTOULL
1272 endif
1273 ifdef NO_SETENV
1274         COMPAT_CFLAGS += -DNO_SETENV
1275         COMPAT_OBJS += compat/setenv.o
1276 endif
1277 ifdef NO_MKDTEMP
1278         COMPAT_CFLAGS += -DNO_MKDTEMP
1279         COMPAT_OBJS += compat/mkdtemp.o
1280 endif
1281 ifdef NO_MKSTEMPS
1282         COMPAT_CFLAGS += -DNO_MKSTEMPS
1283         COMPAT_OBJS += compat/mkstemps.o
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_MMAP
1293         COMPAT_CFLAGS += -DNO_MMAP
1294         COMPAT_OBJS += compat/mmap.o
1295 else
1296         ifdef USE_WIN32_MMAP
1297                 COMPAT_CFLAGS += -DUSE_WIN32_MMAP
1298                 COMPAT_OBJS += compat/win32mmap.o
1299         endif
1300 endif
1301 ifdef OBJECT_CREATION_USES_RENAMES
1302         COMPAT_CFLAGS += -DOBJECT_CREATION_MODE=1
1303 endif
1304 ifdef NO_PREAD
1305         COMPAT_CFLAGS += -DNO_PREAD
1306         COMPAT_OBJS += compat/pread.o
1307 endif
1308 ifdef NO_FAST_WORKING_DIRECTORY
1309         BASIC_CFLAGS += -DNO_FAST_WORKING_DIRECTORY
1310 endif
1311 ifdef NO_TRUSTABLE_FILEMODE
1312         BASIC_CFLAGS += -DNO_TRUSTABLE_FILEMODE
1313 endif
1314 ifdef NO_IPV6
1315         BASIC_CFLAGS += -DNO_IPV6
1316 endif
1317 ifdef NO_UINTMAX_T
1318         BASIC_CFLAGS += -Duintmax_t=uint32_t
1319 endif
1320 ifdef NO_SOCKADDR_STORAGE
1321 ifdef NO_IPV6
1322         BASIC_CFLAGS += -Dsockaddr_storage=sockaddr_in
1323 else
1324         BASIC_CFLAGS += -Dsockaddr_storage=sockaddr_in6
1325 endif
1326 endif
1327 ifdef NO_INET_NTOP
1328         LIB_OBJS += compat/inet_ntop.o
1329 endif
1330 ifdef NO_INET_PTON
1331         LIB_OBJS += compat/inet_pton.o
1332 endif
1333
1334 ifdef NO_ICONV
1335         BASIC_CFLAGS += -DNO_ICONV
1336 endif
1337
1338 ifdef OLD_ICONV
1339         BASIC_CFLAGS += -DOLD_ICONV
1340 endif
1341
1342 ifdef NO_DEFLATE_BOUND
1343         BASIC_CFLAGS += -DNO_DEFLATE_BOUND
1344 endif
1345
1346 ifdef BLK_SHA1
1347         SHA1_HEADER = "block-sha1/sha1.h"
1348         LIB_OBJS += block-sha1/sha1.o
1349         LIB_H += block-sha1/sha1.h
1350 else
1351 ifdef PPC_SHA1
1352         SHA1_HEADER = "ppc/sha1.h"
1353         LIB_OBJS += ppc/sha1.o ppc/sha1ppc.o
1354         LIB_H += ppc/sha1.h
1355 else
1356         SHA1_HEADER = <openssl/sha.h>
1357         EXTLIBS += $(LIB_4_CRYPTO)
1358 endif
1359 endif
1360 ifdef NO_PERL_MAKEMAKER
1361         export NO_PERL_MAKEMAKER
1362 endif
1363 ifdef NO_HSTRERROR
1364         COMPAT_CFLAGS += -DNO_HSTRERROR
1365         COMPAT_OBJS += compat/hstrerror.o
1366 endif
1367 ifdef NO_MEMMEM
1368         COMPAT_CFLAGS += -DNO_MEMMEM
1369         COMPAT_OBJS += compat/memmem.o
1370 endif
1371 ifdef INTERNAL_QSORT
1372         COMPAT_CFLAGS += -DINTERNAL_QSORT
1373         COMPAT_OBJS += compat/qsort.o
1374 endif
1375 ifdef RUNTIME_PREFIX
1376         COMPAT_CFLAGS += -DRUNTIME_PREFIX
1377 endif
1378
1379 ifdef NO_PTHREADS
1380         THREADED_DELTA_SEARCH =
1381         BASIC_CFLAGS += -DNO_PTHREADS
1382 else
1383         EXTLIBS += $(PTHREAD_LIBS)
1384 endif
1385
1386 ifdef THREADED_DELTA_SEARCH
1387         BASIC_CFLAGS += -DTHREADED_DELTA_SEARCH
1388         LIB_OBJS += thread-utils.o
1389 endif
1390 ifdef DIR_HAS_BSD_GROUP_SEMANTICS
1391         COMPAT_CFLAGS += -DDIR_HAS_BSD_GROUP_SEMANTICS
1392 endif
1393 ifdef UNRELIABLE_FSTAT
1394         BASIC_CFLAGS += -DUNRELIABLE_FSTAT
1395 endif
1396 ifdef NO_REGEX
1397         COMPAT_CFLAGS += -Icompat/regex
1398         COMPAT_OBJS += compat/regex/regex.o
1399 endif
1400
1401 ifdef USE_NED_ALLOCATOR
1402        COMPAT_CFLAGS += -DUSE_NED_ALLOCATOR -DOVERRIDE_STRDUP -DNDEBUG -DREPLACE_SYSTEM_ALLOCATOR -Icompat/nedmalloc
1403        COMPAT_OBJS += compat/nedmalloc/nedmalloc.o
1404 endif
1405
1406 ifeq ($(TCLTK_PATH),)
1407 NO_TCLTK=NoThanks
1408 endif
1409
1410 ifeq ($(PERL_PATH),)
1411 NO_PERL=NoThanks
1412 endif
1413
1414 ifeq ($(PYTHON_PATH),)
1415 NO_PYTHON=NoThanks
1416 endif
1417
1418 QUIET_SUBDIR0  = +$(MAKE) -C # space to separate -C and subdir
1419 QUIET_SUBDIR1  =
1420
1421 ifneq ($(findstring $(MAKEFLAGS),w),w)
1422 PRINT_DIR = --no-print-directory
1423 else # "make -w"
1424 NO_SUBDIR = :
1425 endif
1426
1427 ifneq ($(findstring $(MAKEFLAGS),s),s)
1428 ifndef V
1429         QUIET_CC       = @echo '   ' CC $@;
1430         QUIET_AR       = @echo '   ' AR $@;
1431         QUIET_LINK     = @echo '   ' LINK $@;
1432         QUIET_BUILT_IN = @echo '   ' BUILTIN $@;
1433         QUIET_GEN      = @echo '   ' GEN $@;
1434         QUIET_LNCP     = @echo '   ' LN/CP $@;
1435         QUIET_SUBDIR0  = +@subdir=
1436         QUIET_SUBDIR1  = ;$(NO_SUBDIR) echo '   ' SUBDIR $$subdir; \
1437                          $(MAKE) $(PRINT_DIR) -C $$subdir
1438         export V
1439         export QUIET_GEN
1440         export QUIET_BUILT_IN
1441 endif
1442 endif
1443
1444 ifdef ASCIIDOC8
1445         export ASCIIDOC8
1446 endif
1447
1448 # Shell quote (do not use $(call) to accommodate ancient setups);
1449
1450 SHA1_HEADER_SQ = $(subst ','\'',$(SHA1_HEADER))
1451 ETC_GITCONFIG_SQ = $(subst ','\'',$(ETC_GITCONFIG))
1452
1453 DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
1454 bindir_SQ = $(subst ','\'',$(bindir))
1455 bindir_relative_SQ = $(subst ','\'',$(bindir_relative))
1456 mandir_SQ = $(subst ','\'',$(mandir))
1457 infodir_SQ = $(subst ','\'',$(infodir))
1458 gitexecdir_SQ = $(subst ','\'',$(gitexecdir))
1459 template_dir_SQ = $(subst ','\'',$(template_dir))
1460 htmldir_SQ = $(subst ','\'',$(htmldir))
1461 prefix_SQ = $(subst ','\'',$(prefix))
1462
1463 SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
1464 PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
1465 PYTHON_PATH_SQ = $(subst ','\'',$(PYTHON_PATH))
1466 TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH))
1467
1468 LIBS = $(GITLIBS) $(EXTLIBS)
1469
1470 BASIC_CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER_SQ)' \
1471         $(COMPAT_CFLAGS)
1472 LIB_OBJS += $(COMPAT_OBJS)
1473
1474 # Quote for C
1475
1476 ifdef DEFAULT_EDITOR
1477 DEFAULT_EDITOR_CQ = "$(subst ",\",$(subst \,\\,$(DEFAULT_EDITOR)))"
1478 DEFAULT_EDITOR_CQ_SQ = $(subst ','\'',$(DEFAULT_EDITOR_CQ))
1479
1480 BASIC_CFLAGS += -DDEFAULT_EDITOR='$(DEFAULT_EDITOR_CQ_SQ)'
1481 endif
1482
1483 ifdef DEFAULT_PAGER
1484 DEFAULT_PAGER_CQ = "$(subst ",\",$(subst \,\\,$(DEFAULT_PAGER)))"
1485 DEFAULT_PAGER_CQ_SQ = $(subst ','\'',$(DEFAULT_PAGER_CQ))
1486
1487 BASIC_CFLAGS += -DDEFAULT_PAGER='$(DEFAULT_PAGER_CQ_SQ)'
1488 endif
1489
1490 ALL_CFLAGS += $(BASIC_CFLAGS)
1491 ALL_LDFLAGS += $(BASIC_LDFLAGS)
1492
1493 export TAR INSTALL DESTDIR SHELL_PATH
1494
1495
1496 ### Build rules
1497
1498 SHELL = $(SHELL_PATH)
1499
1500 all:: shell_compatibility_test $(ALL_PROGRAMS) $(BUILT_INS) $(OTHER_PROGRAMS) GIT-BUILD-OPTIONS
1501 ifneq (,$X)
1502         $(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';)
1503 endif
1504
1505 all::
1506 ifndef NO_TCLTK
1507         $(QUIET_SUBDIR0)git-gui $(QUIET_SUBDIR1) gitexecdir='$(gitexec_instdir_SQ)' all
1508         $(QUIET_SUBDIR0)gitk-git $(QUIET_SUBDIR1) all
1509 endif
1510 ifndef NO_PERL
1511         $(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' all
1512 endif
1513 ifndef NO_PYTHON
1514         $(QUIET_SUBDIR0)git_remote_helpers $(QUIET_SUBDIR1) PYTHON_PATH='$(PYTHON_PATH_SQ)' prefix='$(prefix_SQ)' all
1515 endif
1516         $(QUIET_SUBDIR0)templates $(QUIET_SUBDIR1)
1517
1518 please_set_SHELL_PATH_to_a_more_modern_shell:
1519         @$$(:)
1520
1521 shell_compatibility_test: please_set_SHELL_PATH_to_a_more_modern_shell
1522
1523 strip: $(PROGRAMS) git$X
1524         $(STRIP) $(STRIP_OPTS) $(PROGRAMS) git$X
1525
1526 git.o: common-cmds.h
1527 git.s git.o: ALL_CFLAGS += -DGIT_VERSION='"$(GIT_VERSION)"' \
1528         '-DGIT_HTML_PATH="$(htmldir_SQ)"'
1529
1530 git$X: git.o $(BUILTIN_OBJS) $(GITLIBS)
1531         $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ git.o \
1532                 $(BUILTIN_OBJS) $(ALL_LDFLAGS) $(LIBS)
1533
1534 builtin-help.o: common-cmds.h
1535 builtin-help.s builtin-help.o: ALL_CFLAGS += \
1536         '-DGIT_HTML_PATH="$(htmldir_SQ)"' \
1537         '-DGIT_MAN_PATH="$(mandir_SQ)"' \
1538         '-DGIT_INFO_PATH="$(infodir_SQ)"'
1539
1540 $(BUILT_INS): git$X
1541         $(QUIET_BUILT_IN)$(RM) $@ && \
1542         ln git$X $@ 2>/dev/null || \
1543         ln -s git$X $@ 2>/dev/null || \
1544         cp git$X $@
1545
1546 common-cmds.h: ./generate-cmdlist.sh command-list.txt
1547
1548 common-cmds.h: $(wildcard Documentation/git-*.txt)
1549         $(QUIET_GEN)./generate-cmdlist.sh > $@+ && mv $@+ $@
1550
1551 $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
1552         $(QUIET_GEN)$(RM) $@ $@+ && \
1553         sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
1554             -e 's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \
1555             -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
1556             -e 's/@@NO_CURL@@/$(NO_CURL)/g' \
1557             -e $(BROKEN_PATH_FIX) \
1558             $@.sh >$@+ && \
1559         chmod +x $@+ && \
1560         mv $@+ $@
1561
1562 ifndef NO_PERL
1563 $(patsubst %.perl,%,$(SCRIPT_PERL)): perl/perl.mak
1564
1565 perl/perl.mak: GIT-CFLAGS perl/Makefile perl/Makefile.PL
1566         $(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' $(@F)
1567
1568 $(patsubst %.perl,%,$(SCRIPT_PERL)): % : %.perl
1569         $(QUIET_GEN)$(RM) $@ $@+ && \
1570         INSTLIBDIR=`MAKEFLAGS= $(MAKE) -C perl -s --no-print-directory instlibdir` && \
1571         sed -e '1{' \
1572             -e '        s|#!.*perl|#!$(PERL_PATH_SQ)|' \
1573             -e '        h' \
1574             -e '        s=.*=use lib (split(/$(pathsep)/, $$ENV{GITPERLLIB} || "@@INSTLIBDIR@@"));=' \
1575             -e '        H' \
1576             -e '        x' \
1577             -e '}' \
1578             -e 's|@@INSTLIBDIR@@|'"$$INSTLIBDIR"'|g' \
1579             -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
1580             $@.perl >$@+ && \
1581         chmod +x $@+ && \
1582         mv $@+ $@
1583
1584 ifdef JSMIN
1585 OTHER_PROGRAMS += gitweb/gitweb.cgi   gitweb/gitweb.min.js
1586 gitweb/gitweb.cgi: gitweb/gitweb.perl gitweb/gitweb.min.js
1587 else
1588 OTHER_PROGRAMS += gitweb/gitweb.cgi
1589 gitweb/gitweb.cgi: gitweb/gitweb.perl
1590 endif
1591         $(QUIET_GEN)$(RM) $@ $@+ && \
1592         sed -e '1s|#!.*perl|#!$(PERL_PATH_SQ)|' \
1593             -e 's|++GIT_VERSION++|$(GIT_VERSION)|g' \
1594             -e 's|++GIT_BINDIR++|$(bindir)|g' \
1595             -e 's|++GITWEB_CONFIG++|$(GITWEB_CONFIG)|g' \
1596             -e 's|++GITWEB_CONFIG_SYSTEM++|$(GITWEB_CONFIG_SYSTEM)|g' \
1597             -e 's|++GITWEB_HOME_LINK_STR++|$(GITWEB_HOME_LINK_STR)|g' \
1598             -e 's|++GITWEB_SITENAME++|$(GITWEB_SITENAME)|g' \
1599             -e 's|++GITWEB_PROJECTROOT++|$(GITWEB_PROJECTROOT)|g' \
1600             -e 's|"++GITWEB_PROJECT_MAXDEPTH++"|$(GITWEB_PROJECT_MAXDEPTH)|g' \
1601             -e 's|++GITWEB_EXPORT_OK++|$(GITWEB_EXPORT_OK)|g' \
1602             -e 's|++GITWEB_STRICT_EXPORT++|$(GITWEB_STRICT_EXPORT)|g' \
1603             -e 's|++GITWEB_BASE_URL++|$(GITWEB_BASE_URL)|g' \
1604             -e 's|++GITWEB_LIST++|$(GITWEB_LIST)|g' \
1605             -e 's|++GITWEB_HOMETEXT++|$(GITWEB_HOMETEXT)|g' \
1606             -e 's|++GITWEB_CSS++|$(GITWEB_CSS)|g' \
1607             -e 's|++GITWEB_LOGO++|$(GITWEB_LOGO)|g' \
1608             -e 's|++GITWEB_FAVICON++|$(GITWEB_FAVICON)|g' \
1609             -e 's|++GITWEB_JS++|$(GITWEB_JS)|g' \
1610             -e 's|++GITWEB_SITE_HEADER++|$(GITWEB_SITE_HEADER)|g' \
1611             -e 's|++GITWEB_SITE_FOOTER++|$(GITWEB_SITE_FOOTER)|g' \
1612             $< >$@+ && \
1613         chmod +x $@+ && \
1614         mv $@+ $@
1615
1616 git-instaweb: git-instaweb.sh gitweb/gitweb.cgi gitweb/gitweb.css gitweb/gitweb.js
1617         $(QUIET_GEN)$(RM) $@ $@+ && \
1618         sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
1619             -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
1620             -e 's/@@NO_CURL@@/$(NO_CURL)/g' \
1621             -e '/@@GITWEB_CGI@@/r gitweb/gitweb.cgi' \
1622             -e '/@@GITWEB_CGI@@/d' \
1623             -e '/@@GITWEB_CSS@@/r gitweb/gitweb.css' \
1624             -e '/@@GITWEB_CSS@@/d' \
1625             -e '/@@GITWEB_JS@@/r gitweb/gitweb.js' \
1626             -e '/@@GITWEB_JS@@/d' \
1627             -e 's|@@PERL@@|$(PERL_PATH_SQ)|g' \
1628             $@.sh > $@+ && \
1629         chmod +x $@+ && \
1630         mv $@+ $@
1631 else # NO_PERL
1632 $(patsubst %.perl,%,$(SCRIPT_PERL)) git-instaweb: % : unimplemented.sh
1633         $(QUIET_GEN)$(RM) $@ $@+ && \
1634         sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
1635             -e 's|@@REASON@@|NO_PERL=$(NO_PERL)|g' \
1636             unimplemented.sh >$@+ && \
1637         chmod +x $@+ && \
1638         mv $@+ $@
1639 endif # NO_PERL
1640
1641
1642 ifdef JSMIN
1643 gitweb/gitweb.min.js: gitweb/gitweb.js
1644         $(QUIET_GEN)$(JSMIN) <$< >$@
1645 endif # JSMIN
1646
1647 ifndef NO_PYTHON
1648 $(patsubst %.py,%,$(SCRIPT_PYTHON)): GIT-CFLAGS
1649 $(patsubst %.py,%,$(SCRIPT_PYTHON)): % : %.py
1650         $(QUIET_GEN)$(RM) $@ $@+ && \
1651         INSTLIBDIR=`MAKEFLAGS= $(MAKE) -C git_remote_helpers -s \
1652                 --no-print-directory prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' \
1653                 instlibdir` && \
1654         sed -e '1{' \
1655             -e '        s|#!.*python|#!$(PYTHON_PATH_SQ)|' \
1656             -e '}' \
1657             -e 's|^import sys.*|&; \\\
1658                    import os; \\\
1659                    sys.path[0] = os.environ.has_key("GITPYTHONLIB") and \\\
1660                                  os.environ["GITPYTHONLIB"] or \\\
1661                                  "@@INSTLIBDIR@@"|' \
1662             -e 's|@@INSTLIBDIR@@|'"$$INSTLIBDIR"'|g' \
1663             $@.py >$@+ && \
1664         chmod +x $@+ && \
1665         mv $@+ $@
1666 else # NO_PYTHON
1667 $(patsubst %.py,%,$(SCRIPT_PYTHON)): % : unimplemented.sh
1668         $(QUIET_GEN)$(RM) $@ $@+ && \
1669         sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
1670             -e 's|@@REASON@@|NO_PYTHON=$(NO_PYTHON)|g' \
1671             unimplemented.sh >$@+ && \
1672         chmod +x $@+ && \
1673         mv $@+ $@
1674 endif # NO_PYTHON
1675
1676 configure: configure.ac
1677         $(QUIET_GEN)$(RM) $@ $<+ && \
1678         sed -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
1679             $< > $<+ && \
1680         autoconf -o $@ $<+ && \
1681         $(RM) $<+
1682
1683 # These can record GIT_VERSION
1684 git.o git.spec \
1685         $(patsubst %.sh,%,$(SCRIPT_SH)) \
1686         $(patsubst %.perl,%,$(SCRIPT_PERL)) \
1687         : GIT-VERSION-FILE
1688
1689 GIT_OBJS := $(LIB_OBJS) $(BUILTIN_OBJS) $(PROGRAM_OBJS) $(TEST_OBJS) \
1690         git.o http.o http-walker.o remote-curl.o
1691 XDIFF_OBJS = xdiff/xdiffi.o xdiff/xprepare.o xdiff/xutils.o xdiff/xemit.o \
1692         xdiff/xmerge.o xdiff/xpatience.o
1693 OBJECTS := $(GIT_OBJS) $(XDIFF_OBJS)
1694
1695 dep_files := $(foreach f,$(OBJECTS),$(dir $f)deps/$(notdir $f).d)
1696
1697 ifdef COMPUTE_HEADER_DEPENDENCIES
1698 dep_dirs := $(addsuffix deps,$(sort $(dir $(OBJECTS))))
1699 $(dep_dirs):
1700         mkdir -p $@
1701
1702 missing_dep_dirs := $(filter-out $(wildcard $(dep_dirs)),$(dep_dirs))
1703 dep_file = $(dir $@)deps/$(notdir $@).d
1704 dep_args = -MF $(dep_file) -MMD -MP
1705 ifdef CHECK_HEADER_DEPENDENCIES
1706 $(error cannot compute header dependencies outside a normal build. \
1707 Please unset CHECK_HEADER_DEPENDENCIES and try again)
1708 endif
1709 endif
1710
1711 ifndef COMPUTE_HEADER_DEPENDENCIES
1712 ifndef CHECK_HEADER_DEPENDENCIES
1713 dep_dirs =
1714 missing_dep_dirs =
1715 dep_args =
1716 endif
1717 endif
1718
1719 ifdef CHECK_HEADER_DEPENDENCIES
1720 ifndef PRINT_HEADER_DEPENDENCIES
1721 missing_deps = $(filter-out $(notdir $^), \
1722         $(notdir $(shell $(MAKE) -s $@ \
1723                 CHECK_HEADER_DEPENDENCIES=YesPlease \
1724                 USE_COMPUTED_HEADER_DEPENDENCIES=YesPlease \
1725                 PRINT_HEADER_DEPENDENCIES=YesPlease)))
1726 endif
1727 endif
1728
1729 ASM_SRC := $(wildcard $(OBJECTS:o=S))
1730 ASM_OBJ := $(ASM_SRC:S=o)
1731 C_OBJ := $(filter-out $(ASM_OBJ),$(OBJECTS))
1732
1733 .SUFFIXES:
1734
1735 ifdef PRINT_HEADER_DEPENDENCIES
1736 $(C_OBJ): %.o: %.c FORCE
1737         echo $^
1738 $(ASM_OBJ): %.o: %.S FORCE
1739         echo $^
1740
1741 ifndef CHECK_HEADER_DEPENDENCIES
1742 $(error cannot print header dependencies during a normal build. \
1743 Please set CHECK_HEADER_DEPENDENCIES and try again)
1744 endif
1745 endif
1746
1747 ifndef PRINT_HEADER_DEPENDENCIES
1748 ifdef CHECK_HEADER_DEPENDENCIES
1749 $(C_OBJ): %.o: %.c $(dep_files) FORCE
1750         @set -e; echo CHECK $@; \
1751         missing_deps="$(missing_deps)"; \
1752         if test "$$missing_deps"; \
1753         then \
1754                 echo missing dependencies: $$missing_deps; \
1755                 false; \
1756         fi
1757 $(ASM_OBJ): %.o: %.S $(dep_files) FORCE
1758         @set -e; echo CHECK $@; \
1759         missing_deps="$(missing_deps)"; \
1760         if test "$$missing_deps"; \
1761         then \
1762                 echo missing dependencies: $$missing_deps; \
1763                 false; \
1764         fi
1765 endif
1766 endif
1767
1768 ifndef CHECK_HEADER_DEPENDENCIES
1769 $(C_OBJ): %.o: %.c GIT-CFLAGS $(missing_dep_dirs)
1770         $(QUIET_CC)$(CC) -o $*.o -c $(dep_args) $(ALL_CFLAGS) $<
1771 $(ASM_OBJ): %.o: %.S GIT-CFLAGS $(missing_dep_dirs)
1772         $(QUIET_CC)$(CC) -o $*.o -c $(dep_args) $(ALL_CFLAGS) $<
1773 endif
1774
1775 %.s: %.c GIT-CFLAGS FORCE
1776         $(QUIET_CC)$(CC) -S $(ALL_CFLAGS) $<
1777
1778 ifdef USE_COMPUTED_HEADER_DEPENDENCIES
1779 # Take advantage of gcc's on-the-fly dependency generation
1780 # See <http://gcc.gnu.org/gcc-3.0/features.html>.
1781 dep_files_present := $(wildcard $(dep_files))
1782 ifneq ($(dep_files_present),)
1783 include $(dep_files_present)
1784 endif
1785 else
1786 # Dependencies on header files, for platforms that do not support
1787 # the gcc -MMD option.
1788 #
1789 # Dependencies on automatically generated headers such as common-cmds.h
1790 # should _not_ be included here, since they are necessary even when
1791 # building an object for the first time.
1792 #
1793 # XXX. Please check occasionally that these include all dependencies
1794 # gcc detects!
1795
1796 $(GIT_OBJS): $(LIB_H)
1797 builtin-branch.o builtin-checkout.o builtin-clone.o builtin-reset.o branch.o transport.o: branch.h
1798 builtin-bundle.o bundle.o transport.o: bundle.h
1799 builtin-bisect--helper.o builtin-rev-list.o bisect.o: bisect.h
1800 builtin-clone.o builtin-fetch-pack.o transport.o: fetch-pack.h
1801 builtin-send-pack.o transport.o: send-pack.h
1802 builtin-log.o builtin-shortlog.o: shortlog.h
1803 builtin-prune.o builtin-reflog.o reachable.o: reachable.h
1804 builtin-commit.o builtin-revert.o wt-status.o: wt-status.h
1805 builtin-tar-tree.o archive-tar.o: tar.h
1806 builtin-pack-objects.o: thread-utils.h
1807 http-fetch.o http-walker.o remote-curl.o transport.o walker.o: walker.h
1808 http.o http-walker.o http-push.o remote-curl.o: http.h
1809
1810 xdiff-interface.o $(XDIFF_OBJS): \
1811         xdiff/xinclude.h xdiff/xmacros.h xdiff/xdiff.h xdiff/xtypes.h \
1812         xdiff/xutils.h xdiff/xprepare.h xdiff/xdiffi.h xdiff/xemit.h
1813 endif
1814
1815 exec_cmd.s exec_cmd.o: ALL_CFLAGS += \
1816         '-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' \
1817         '-DBINDIR="$(bindir_relative_SQ)"' \
1818         '-DPREFIX="$(prefix_SQ)"'
1819
1820 builtin-init-db.s builtin-init-db.o: ALL_CFLAGS += \
1821         -DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir_SQ)"'
1822
1823 config.s config.o: ALL_CFLAGS += -DETC_GITCONFIG='"$(ETC_GITCONFIG_SQ)"'
1824
1825 http.s http.o: ALL_CFLAGS += -DGIT_USER_AGENT='"git/$(GIT_VERSION)"'
1826
1827 ifdef NO_EXPAT
1828 http-walker.s http-walker.o: ALL_CFLAGS += -DNO_EXPAT
1829 endif
1830
1831 git-%$X: %.o $(GITLIBS)
1832         $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
1833
1834 git-imap-send$X: imap-send.o $(GITLIBS)
1835         $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
1836                 $(LIBS) $(OPENSSL_LINK) $(OPENSSL_LIBSSL)
1837
1838 git-http-fetch$X: revision.o http.o http-walker.o http-fetch.o $(GITLIBS)
1839         $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
1840                 $(LIBS) $(CURL_LIBCURL)
1841 git-http-push$X: revision.o http.o http-push.o $(GITLIBS)
1842         $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
1843                 $(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
1844
1845 $(REMOTE_CURL_ALIASES): $(REMOTE_CURL_PRIMARY)
1846         $(QUIET_LNCP)$(RM) $@ && \
1847         ln $< $@ 2>/dev/null || \
1848         ln -s $< $@ 2>/dev/null || \
1849         cp $< $@
1850
1851 $(REMOTE_CURL_PRIMARY): remote-curl.o http.o http-walker.o $(GITLIBS)
1852         $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
1853                 $(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
1854
1855 $(LIB_FILE): $(LIB_OBJS)
1856         $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIB_OBJS)
1857
1858 $(XDIFF_LIB): $(XDIFF_OBJS)
1859         $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(XDIFF_OBJS)
1860
1861
1862 doc:
1863         $(MAKE) -C Documentation all
1864
1865 man:
1866         $(MAKE) -C Documentation man
1867
1868 html:
1869         $(MAKE) -C Documentation html
1870
1871 info:
1872         $(MAKE) -C Documentation info
1873
1874 pdf:
1875         $(MAKE) -C Documentation pdf
1876
1877 TAGS:
1878         $(RM) TAGS
1879         $(FIND) . -name '*.[hcS]' -print | xargs etags -a
1880
1881 tags:
1882         $(RM) tags
1883         $(FIND) . -name '*.[hcS]' -print | xargs ctags -a
1884
1885 cscope:
1886         $(RM) cscope*
1887         $(FIND) . -name '*.[hcS]' -print | xargs cscope -b
1888
1889 ### Detect prefix changes
1890 TRACK_CFLAGS = $(subst ','\'',$(ALL_CFLAGS)):\
1891              $(bindir_SQ):$(gitexecdir_SQ):$(template_dir_SQ):$(prefix_SQ)
1892
1893 GIT-CFLAGS: FORCE
1894         @FLAGS='$(TRACK_CFLAGS)'; \
1895             if test x"$$FLAGS" != x"`cat GIT-CFLAGS 2>/dev/null`" ; then \
1896                 echo 1>&2 "    * new build flags or prefix"; \
1897                 echo "$$FLAGS" >GIT-CFLAGS; \
1898             fi
1899
1900 # We need to apply sq twice, once to protect from the shell
1901 # that runs GIT-BUILD-OPTIONS, and then again to protect it
1902 # and the first level quoting from the shell that runs "echo".
1903 GIT-BUILD-OPTIONS: FORCE
1904         @echo SHELL_PATH=\''$(subst ','\'',$(SHELL_PATH_SQ))'\' >$@
1905         @echo PERL_PATH=\''$(subst ','\'',$(PERL_PATH_SQ))'\' >>$@
1906         @echo TAR=\''$(subst ','\'',$(subst ','\'',$(TAR)))'\' >>$@
1907         @echo NO_CURL=\''$(subst ','\'',$(subst ','\'',$(NO_CURL)))'\' >>$@
1908         @echo NO_PERL=\''$(subst ','\'',$(subst ','\'',$(NO_PERL)))'\' >>$@
1909         @echo NO_PYTHON=\''$(subst ','\'',$(subst ','\'',$(NO_PYTHON)))'\' >>$@
1910
1911 ### Detect Tck/Tk interpreter path changes
1912 ifndef NO_TCLTK
1913 TRACK_VARS = $(subst ','\'',-DTCLTK_PATH='$(TCLTK_PATH_SQ)')
1914
1915 GIT-GUI-VARS: FORCE
1916         @VARS='$(TRACK_VARS)'; \
1917             if test x"$$VARS" != x"`cat $@ 2>/dev/null`" ; then \
1918                 echo 1>&2 "    * new Tcl/Tk interpreter location"; \
1919                 echo "$$VARS" >$@; \
1920             fi
1921 endif
1922
1923 test_bindir_programs := $(patsubst %,bin-wrappers/%,$(BINDIR_PROGRAMS_NEED_X) $(BINDIR_PROGRAMS_NO_X) $(TEST_PROGRAMS_NEED_X))
1924
1925 all:: $(TEST_PROGRAMS) $(test_bindir_programs)
1926
1927 bin-wrappers/%: wrap-for-bin.sh
1928         @mkdir -p bin-wrappers
1929         $(QUIET_GEN)sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
1930              -e 's|@@BUILD_DIR@@|$(shell pwd)|' \
1931              -e 's|@@PROG@@|$(@F)|' < $< > $@ && \
1932         chmod +x $@
1933
1934 # GNU make supports exporting all variables by "export" without parameters.
1935 # However, the environment gets quite big, and some programs have problems
1936 # with that.
1937
1938 export NO_SVN_TESTS
1939
1940 ### Testing rules
1941
1942 test: all
1943         $(MAKE) -C t/ all
1944
1945 test-ctype$X: ctype.o
1946
1947 test-date$X: date.o ctype.o
1948
1949 test-delta$X: diff-delta.o patch-delta.o
1950
1951 test-parse-options$X: parse-options.o
1952
1953 .PRECIOUS: $(TEST_OBJS)
1954
1955 test-%$X: test-%.o $(GITLIBS)
1956         $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
1957
1958 check-sha1:: test-sha1$X
1959         ./test-sha1.sh
1960
1961 check: common-cmds.h
1962         if sparse; \
1963         then \
1964                 for i in *.c; \
1965                 do \
1966                         sparse $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i || exit; \
1967                 done; \
1968         else \
1969                 echo 2>&1 "Did you mean 'make test'?"; \
1970                 exit 1; \
1971         fi
1972
1973 remove-dashes:
1974         ./fixup-builtins $(BUILT_INS) $(PROGRAMS) $(SCRIPTS)
1975
1976 ### Installation rules
1977
1978 ifneq ($(filter /%,$(firstword $(template_dir))),)
1979 template_instdir = $(template_dir)
1980 else
1981 template_instdir = $(prefix)/$(template_dir)
1982 endif
1983 export template_instdir
1984
1985 ifneq ($(filter /%,$(firstword $(gitexecdir))),)
1986 gitexec_instdir = $(gitexecdir)
1987 else
1988 gitexec_instdir = $(prefix)/$(gitexecdir)
1989 endif
1990 gitexec_instdir_SQ = $(subst ','\'',$(gitexec_instdir))
1991 export gitexec_instdir
1992
1993 install_bindir_programs := $(patsubst %,%$X,$(BINDIR_PROGRAMS_NEED_X)) $(BINDIR_PROGRAMS_NO_X)
1994
1995 install: all
1996         $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'
1997         $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
1998         $(INSTALL) $(ALL_PROGRAMS) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
1999         $(INSTALL) $(install_bindir_programs) '$(DESTDIR_SQ)$(bindir_SQ)'
2000         $(MAKE) -C templates DESTDIR='$(DESTDIR_SQ)' install
2001 ifndef NO_PERL
2002         $(MAKE) -C perl prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' install
2003 endif
2004 ifndef NO_PYTHON
2005         $(MAKE) -C git_remote_helpers prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' install
2006 endif
2007 ifndef NO_TCLTK
2008         $(MAKE) -C gitk-git install
2009         $(MAKE) -C git-gui gitexecdir='$(gitexec_instdir_SQ)' install
2010 endif
2011 ifneq (,$X)
2012         $(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';)
2013 endif
2014
2015         bindir=$$(cd '$(DESTDIR_SQ)$(bindir_SQ)' && pwd) && \
2016         execdir=$$(cd '$(DESTDIR_SQ)$(gitexec_instdir_SQ)' && pwd) && \
2017         { test "$$bindir/" = "$$execdir/" || \
2018                 { $(RM) "$$execdir/git$X" && \
2019                 test -z "$(NO_CROSS_DIRECTORY_HARDLINKS)" && \
2020                 ln "$$bindir/git$X" "$$execdir/git$X" 2>/dev/null || \
2021                 cp "$$bindir/git$X" "$$execdir/git$X"; } ; } && \
2022         { for p in $(BUILT_INS); do \
2023                 $(RM) "$$execdir/$$p" && \
2024                 ln "$$execdir/git$X" "$$execdir/$$p" 2>/dev/null || \
2025                 ln -s "git$X" "$$execdir/$$p" 2>/dev/null || \
2026                 cp "$$execdir/git$X" "$$execdir/$$p" || exit; \
2027           done; } && \
2028         { for p in $(REMOTE_CURL_ALIASES); do \
2029                 $(RM) "$$execdir/$$p" && \
2030                 ln "$$execdir/git-remote-http$X" "$$execdir/$$p" 2>/dev/null || \
2031                 ln -s "git-remote-http$X" "$$execdir/$$p" 2>/dev/null || \
2032                 cp "$$execdir/git-remote-http$X" "$$execdir/$$p" || exit; \
2033           done; } && \
2034         ./check_bindir "z$$bindir" "z$$execdir" "$$bindir/git-add$X"
2035
2036 install-doc:
2037         $(MAKE) -C Documentation install
2038
2039 install-man:
2040         $(MAKE) -C Documentation install-man
2041
2042 install-html:
2043         $(MAKE) -C Documentation install-html
2044
2045 install-info:
2046         $(MAKE) -C Documentation install-info
2047
2048 install-pdf:
2049         $(MAKE) -C Documentation install-pdf
2050
2051 quick-install-doc:
2052         $(MAKE) -C Documentation quick-install
2053
2054 quick-install-man:
2055         $(MAKE) -C Documentation quick-install-man
2056
2057 quick-install-html:
2058         $(MAKE) -C Documentation quick-install-html
2059
2060
2061
2062 ### Maintainer's dist rules
2063
2064 git.spec: git.spec.in
2065         sed -e 's/@@VERSION@@/$(GIT_VERSION)/g' < $< > $@+
2066         mv $@+ $@
2067
2068 GIT_TARNAME=git-$(GIT_VERSION)
2069 dist: git.spec git-archive$(X) configure
2070         ./git-archive --format=tar \
2071                 --prefix=$(GIT_TARNAME)/ HEAD^{tree} > $(GIT_TARNAME).tar
2072         @mkdir -p $(GIT_TARNAME)
2073         @cp git.spec configure $(GIT_TARNAME)
2074         @echo $(GIT_VERSION) > $(GIT_TARNAME)/version
2075         @$(MAKE) -C git-gui TARDIR=../$(GIT_TARNAME)/git-gui dist-version
2076         $(TAR) rf $(GIT_TARNAME).tar \
2077                 $(GIT_TARNAME)/git.spec \
2078                 $(GIT_TARNAME)/configure \
2079                 $(GIT_TARNAME)/version \
2080                 $(GIT_TARNAME)/git-gui/version
2081         @$(RM) -r $(GIT_TARNAME)
2082         gzip -f -9 $(GIT_TARNAME).tar
2083
2084 rpm: dist
2085         $(RPMBUILD) \
2086                 --define "_source_filedigest_algorithm md5" \
2087                 --define "_binary_filedigest_algorithm md5" \
2088                 -ta $(GIT_TARNAME).tar.gz
2089
2090 htmldocs = git-htmldocs-$(GIT_VERSION)
2091 manpages = git-manpages-$(GIT_VERSION)
2092 dist-doc:
2093         $(RM) -r .doc-tmp-dir
2094         mkdir .doc-tmp-dir
2095         $(MAKE) -C Documentation WEBDOC_DEST=../.doc-tmp-dir install-webdoc
2096         cd .doc-tmp-dir && $(TAR) cf ../$(htmldocs).tar .
2097         gzip -n -9 -f $(htmldocs).tar
2098         :
2099         $(RM) -r .doc-tmp-dir
2100         mkdir -p .doc-tmp-dir/man1 .doc-tmp-dir/man5 .doc-tmp-dir/man7
2101         $(MAKE) -C Documentation DESTDIR=./ \
2102                 man1dir=../.doc-tmp-dir/man1 \
2103                 man5dir=../.doc-tmp-dir/man5 \
2104                 man7dir=../.doc-tmp-dir/man7 \
2105                 install
2106         cd .doc-tmp-dir && $(TAR) cf ../$(manpages).tar .
2107         gzip -n -9 -f $(manpages).tar
2108         $(RM) -r .doc-tmp-dir
2109
2110 ### Cleaning rules
2111
2112 distclean: clean
2113         $(RM) configure
2114
2115 clean:
2116         $(RM) *.o block-sha1/*.o ppc/*.o compat/*.o compat/*/*.o xdiff/*.o \
2117                 $(LIB_FILE) $(XDIFF_LIB)
2118         $(RM) $(ALL_PROGRAMS) $(BUILT_INS) git$X
2119         $(RM) $(TEST_PROGRAMS)
2120         $(RM) -r bin-wrappers
2121         $(RM) -r $(dep_dirs)
2122         $(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo common-cmds.h TAGS tags cscope*
2123         $(RM) -r autom4te.cache
2124         $(RM) config.log config.mak.autogen config.mak.append config.status config.cache
2125         $(RM) -r $(GIT_TARNAME) .doc-tmp-dir
2126         $(RM) $(GIT_TARNAME).tar.gz git-core_$(GIT_VERSION)-*.tar.gz
2127         $(RM) $(htmldocs).tar.gz $(manpages).tar.gz
2128         $(MAKE) -C Documentation/ clean
2129 ifndef NO_PERL
2130         $(RM) gitweb/gitweb.cgi
2131         $(MAKE) -C perl clean
2132 endif
2133 ifndef NO_PYTHON
2134         $(MAKE) -C git_remote_helpers clean
2135 endif
2136         $(MAKE) -C templates/ clean
2137         $(MAKE) -C t/ clean
2138 ifndef NO_TCLTK
2139         $(MAKE) -C gitk-git clean
2140         $(MAKE) -C git-gui clean
2141 endif
2142         $(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-GUI-VARS GIT-BUILD-OPTIONS
2143
2144 .PHONY: all install clean strip
2145 .PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell
2146 .PHONY: FORCE TAGS tags cscope
2147
2148 ### Check documentation
2149 #
2150 check-docs::
2151         @(for v in $(ALL_PROGRAMS) $(BUILT_INS) git gitk; \
2152         do \
2153                 case "$$v" in \
2154                 git-merge-octopus | git-merge-ours | git-merge-recursive | \
2155                 git-merge-resolve | git-merge-subtree | \
2156                 git-fsck-objects | git-init-db | \
2157                 git-?*--?* ) continue ;; \
2158                 esac ; \
2159                 test -f "Documentation/$$v.txt" || \
2160                 echo "no doc: $$v"; \
2161                 sed -e '/^#/d' command-list.txt | \
2162                 grep -q "^$$v[  ]" || \
2163                 case "$$v" in \
2164                 git) ;; \
2165                 *) echo "no link: $$v";; \
2166                 esac ; \
2167         done; \
2168         ( \
2169                 sed -e '/^#/d' \
2170                     -e 's/[     ].*//' \
2171                     -e 's/^/listed /' command-list.txt; \
2172                 ls -1 Documentation/git*txt | \
2173                 sed -e 's|Documentation/|documented |' \
2174                     -e 's/\.txt//'; \
2175         ) | while read how cmd; \
2176         do \
2177                 case "$$how,$$cmd" in \
2178                 *,git-citool | \
2179                 *,git-gui | \
2180                 *,git-help | \
2181                 documented,gitattributes | \
2182                 documented,gitignore | \
2183                 documented,gitmodules | \
2184                 documented,gitcli | \
2185                 documented,git-tools | \
2186                 documented,gitcore-tutorial | \
2187                 documented,gitcvs-migration | \
2188                 documented,gitdiffcore | \
2189                 documented,gitglossary | \
2190                 documented,githooks | \
2191                 documented,gitrepository-layout | \
2192                 documented,gittutorial | \
2193                 documented,gittutorial-2 | \
2194                 sentinel,not,matching,is,ok ) continue ;; \
2195                 esac; \
2196                 case " $(ALL_PROGRAMS) $(BUILT_INS) git gitk " in \
2197                 *" $$cmd "*)    ;; \
2198                 *) echo "removed but $$how: $$cmd" ;; \
2199                 esac; \
2200         done ) | sort
2201
2202 ### Make sure built-ins do not have dups and listed in git.c
2203 #
2204 check-builtins::
2205         ./check-builtins.sh
2206
2207 ### Test suite coverage testing
2208 #
2209 .PHONY: coverage coverage-clean coverage-build coverage-report
2210
2211 coverage:
2212         $(MAKE) coverage-build
2213         $(MAKE) coverage-report
2214
2215 coverage-clean:
2216         rm -f *.gcda *.gcno
2217
2218 COVERAGE_CFLAGS = $(CFLAGS) -O0 -ftest-coverage -fprofile-arcs
2219 COVERAGE_LDFLAGS = $(CFLAGS)  -O0 -lgcov
2220
2221 coverage-build: coverage-clean
2222         $(MAKE) CFLAGS="$(COVERAGE_CFLAGS)" LDFLAGS="$(COVERAGE_LDFLAGS)" all
2223         $(MAKE) CFLAGS="$(COVERAGE_CFLAGS)" LDFLAGS="$(COVERAGE_LDFLAGS)" \
2224                 -j1 test
2225
2226 coverage-report:
2227         gcov -b *.c
2228         grep '^function.*called 0 ' *.c.gcov \
2229                 | sed -e 's/\([^:]*\)\.gcov: *function \([^ ]*\) called.*/\1: \2/' \
2230                 | tee coverage-untested-functions