Makefile: DIFF_OBJS is not special at all these days
[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 SNPRINTF_RETURNS_BOGUS if your are on a system which snprintf()
7 # or vsnprintf() return -1 instead of number of characters which would
8 # have been written to the final string if enough space had been available.
9 #
10 # Define FREAD_READS_DIRECTORIES if your are on a system which succeeds
11 # when attempting to read from an fopen'ed directory.
12 #
13 # Define NO_OPENSSL environment variable if you do not have OpenSSL.
14 # This also implies MOZILLA_SHA1.
15 #
16 # Define NO_CURL if you do not have curl installed.  git-http-pull and
17 # git-http-push are not built, and you cannot use http:// and https://
18 # transports.
19 #
20 # Define CURLDIR=/foo/bar if your curl header and library files are in
21 # /foo/bar/include and /foo/bar/lib directories.
22 #
23 # Define NO_EXPAT if you do not have expat installed.  git-http-push is
24 # not built, and you cannot push using http:// and https:// transports.
25 #
26 # Define NO_D_INO_IN_DIRENT if you don't have d_ino in your struct dirent.
27 #
28 # Define NO_D_TYPE_IN_DIRENT if your platform defines DT_UNKNOWN but lacks
29 # d_type in struct dirent (latest Cygwin -- will be fixed soonish).
30 #
31 # Define NO_C99_FORMAT if your formatted IO functions (printf/scanf et.al.)
32 # do not support the 'size specifiers' introduced by C99, namely ll, hh,
33 # j, z, t. (representing long long int, char, intmax_t, size_t, ptrdiff_t).
34 # some C compilers supported these specifiers prior to C99 as an extension.
35 #
36 # Define NO_STRCASESTR if you don't have strcasestr.
37 #
38 # Define NO_MEMMEM if you don't have memmem.
39 #
40 # Define NO_STRLCPY if you don't have strlcpy.
41 #
42 # Define NO_STRTOUMAX if you don't have strtoumax in the C library.
43 # If your compiler also does not support long long or does not have
44 # strtoull, define NO_STRTOULL.
45 #
46 # Define NO_SETENV if you don't have setenv in the C library.
47 #
48 # Define NO_UNSETENV if you don't have unsetenv in the C library.
49 #
50 # Define NO_MKDTEMP if you don't have mkdtemp in the C library.
51 #
52 # Define NO_SYS_SELECT_H if you don't have sys/select.h.
53 #
54 # Define NO_SYMLINK_HEAD if you never want .git/HEAD to be a symbolic link.
55 # Enable it on Windows.  By default, symrefs are still used.
56 #
57 # Define NO_SVN_TESTS if you want to skip time-consuming SVN interoperability
58 # tests.  These tests take up a significant amount of the total test time
59 # but are not needed unless you plan to talk to SVN repos.
60 #
61 # Define NO_FINK if you are building on Darwin/Mac OS X, have Fink
62 # installed in /sw, but don't want GIT to link against any libraries
63 # installed there.  If defined you may specify your own (or Fink's)
64 # include directories and library directories by defining CFLAGS
65 # and LDFLAGS appropriately.
66 #
67 # Define NO_DARWIN_PORTS if you are building on Darwin/Mac OS X,
68 # have DarwinPorts installed in /opt/local, but don't want GIT to
69 # link against any libraries installed there.  If defined you may
70 # specify your own (or DarwinPort's) include directories and
71 # library directories by defining CFLAGS and LDFLAGS appropriately.
72 #
73 # Define PPC_SHA1 environment variable when running make to make use of
74 # a bundled SHA1 routine optimized for PowerPC.
75 #
76 # Define ARM_SHA1 environment variable when running make to make use of
77 # a bundled SHA1 routine optimized for ARM.
78 #
79 # Define MOZILLA_SHA1 environment variable when running make to make use of
80 # a bundled SHA1 routine coming from Mozilla. It is GPL'd and should be fast
81 # on non-x86 architectures (e.g. PowerPC), while the OpenSSL version (default
82 # choice) has very fast version optimized for i586.
83 #
84 # Define NEEDS_SSL_WITH_CRYPTO if you need -lcrypto with -lssl (Darwin).
85 #
86 # Define NEEDS_LIBICONV if linking with libc is not enough (Darwin).
87 #
88 # Define NEEDS_SOCKET if linking with libc is not enough (SunOS,
89 # Patrick Mauritz).
90 #
91 # Define NO_MMAP if you want to avoid mmap.
92 #
93 # Define NO_PREAD if you have a problem with pread() system call (e.g.
94 # cygwin.dll before v1.5.22).
95 #
96 # Define NO_FAST_WORKING_DIRECTORY if accessing objects in pack files is
97 # generally faster on your platform than accessing the working directory.
98 #
99 # Define NO_TRUSTABLE_FILEMODE if your filesystem may claim to support
100 # the executable mode bit, but doesn't really do so.
101 #
102 # Define NO_IPV6 if you lack IPv6 support and getaddrinfo().
103 #
104 # Define NO_SOCKADDR_STORAGE if your platform does not have struct
105 # sockaddr_storage.
106 #
107 # Define NO_ICONV if your libc does not properly support iconv.
108 #
109 # Define OLD_ICONV if your library has an old iconv(), where the second
110 # (input buffer pointer) parameter is declared with type (const char **).
111 #
112 # Define NO_DEFLATE_BOUND if your zlib does not have deflateBound.
113 #
114 # Define NO_R_TO_GCC_LINKER if your gcc does not like "-R/path/lib"
115 # that tells runtime paths to dynamic libraries;
116 # "-Wl,-rpath=/path/lib" is used instead.
117 #
118 # Define USE_NSEC below if you want git to care about sub-second file mtimes
119 # and ctimes. Note that you need recent glibc (at least 2.2.4) for this, and
120 # it will BREAK YOUR LOCAL DIFFS! show-diff and anything using it will likely
121 # randomly break unless your underlying filesystem supports those sub-second
122 # times (my ext3 doesn't).
123 #
124 # Define USE_STDEV below if you want git to care about the underlying device
125 # change being considered an inode change from the update-index perspective.
126 #
127 # Define ASCIIDOC8 if you want to format documentation with AsciiDoc 8
128 #
129 # Define DOCBOOK_XSL_172 if you want to format man pages with DocBook XSL v1.72.
130 #
131 # Define NO_PERL_MAKEMAKER if you cannot use Makefiles generated by perl's
132 # MakeMaker (e.g. using ActiveState under Cygwin).
133 #
134 # Define NO_TCLTK if you do not want Tcl/Tk GUI.
135 #
136 # The TCL_PATH variable governs the location of the Tcl interpreter
137 # used to optimize git-gui for your system.  Only used if NO_TCLTK
138 # is not set.  Defaults to the bare 'tclsh'.
139 #
140 # The TCLTK_PATH variable governs the location of the Tcl/Tk interpreter.
141 # If not set it defaults to the bare 'wish'. If it is set to the empty
142 # string then NO_TCLTK will be forced (this is used by configure script).
143 #
144 # Define THREADED_DELTA_SEARCH if you have pthreads and wish to exploit
145 # parallel delta searching when packing objects.
146 #
147 # Define INTERNAL_QSORT to use Git's implementation of qsort(), which
148 # is a simplified version of the merge sort used in glibc. This is
149 # recommended if Git triggers O(n^2) behavior in your platform's qsort().
150 #
151
152 GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
153         @$(SHELL_PATH) ./GIT-VERSION-GEN
154 -include GIT-VERSION-FILE
155
156 uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
157 uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not')
158 uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')
159 uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not')
160 uname_P := $(shell sh -c 'uname -p 2>/dev/null || echo not')
161
162 # CFLAGS and LDFLAGS are for the users to override from the command line.
163
164 CFLAGS = -g -O2 -Wall
165 LDFLAGS =
166 ALL_CFLAGS = $(CFLAGS)
167 ALL_LDFLAGS = $(LDFLAGS)
168 STRIP ?= strip
169
170 prefix = $(HOME)
171 bindir = $(prefix)/bin
172 mandir = $(prefix)/share/man
173 infodir = $(prefix)/share/info
174 gitexecdir = $(bindir)
175 sharedir = $(prefix)/share
176 template_dir = $(sharedir)/git-core/templates
177 htmldir=$(sharedir)/doc/git-doc
178 ifeq ($(prefix),/usr)
179 sysconfdir = /etc
180 else
181 sysconfdir = $(prefix)/etc
182 endif
183 lib = lib
184 ETC_GITCONFIG = $(sysconfdir)/gitconfig
185 # DESTDIR=
186
187 # default configuration for gitweb
188 GITWEB_CONFIG = gitweb_config.perl
189 GITWEB_HOME_LINK_STR = projects
190 GITWEB_SITENAME =
191 GITWEB_PROJECTROOT = /pub/git
192 GITWEB_PROJECT_MAXDEPTH = 2007
193 GITWEB_EXPORT_OK =
194 GITWEB_STRICT_EXPORT =
195 GITWEB_BASE_URL =
196 GITWEB_LIST =
197 GITWEB_HOMETEXT = indextext.html
198 GITWEB_CSS = gitweb.css
199 GITWEB_LOGO = git-logo.png
200 GITWEB_FAVICON = git-favicon.png
201 GITWEB_SITE_HEADER =
202 GITWEB_SITE_FOOTER =
203
204 export prefix bindir gitexecdir sharedir template_dir htmldir sysconfdir
205
206 CC = gcc
207 AR = ar
208 RM = rm -f
209 TAR = tar
210 FIND = find
211 INSTALL = install
212 RPMBUILD = rpmbuild
213 TCL_PATH = tclsh
214 TCLTK_PATH = wish
215
216 export TCL_PATH TCLTK_PATH
217
218 # sparse is architecture-neutral, which means that we need to tell it
219 # explicitly what architecture to check for. Fix this up for yours..
220 SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
221
222
223
224 ### --- END CONFIGURATION SECTION ---
225
226 # Those must not be GNU-specific; they are shared with perl/ which may
227 # be built by a different compiler. (Note that this is an artifact now
228 # but it still might be nice to keep that distinction.)
229 BASIC_CFLAGS =
230 BASIC_LDFLAGS =
231
232 SCRIPT_SH = \
233         git-bisect.sh \
234         git-clone.sh \
235         git-merge-one-file.sh git-mergetool.sh git-parse-remote.sh \
236         git-pull.sh git-rebase.sh git-rebase--interactive.sh \
237         git-repack.sh git-request-pull.sh \
238         git-sh-setup.sh \
239         git-am.sh \
240         git-merge.sh git-merge-stupid.sh git-merge-octopus.sh \
241         git-merge-resolve.sh \
242         git-lost-found.sh git-quiltimport.sh git-submodule.sh \
243         git-filter-branch.sh \
244         git-stash.sh \
245         git-web--browse.sh
246
247 SCRIPT_PERL = \
248         git-add--interactive.perl \
249         git-archimport.perl git-cvsimport.perl git-relink.perl \
250         git-cvsserver.perl git-cvsexportcommit.perl \
251         git-send-email.perl git-svn.perl
252
253 SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \
254           $(patsubst %.perl,%,$(SCRIPT_PERL)) \
255           git-instaweb
256
257 # ... and all the rest that could be moved out of bindir to gitexecdir
258 PROGRAMS = \
259         git-fetch-pack$X \
260         git-hash-object$X git-index-pack$X \
261         git-fast-import$X \
262         git-daemon$X \
263         git-merge-index$X git-mktag$X git-mktree$X git-patch-id$X \
264         git-receive-pack$X \
265         git-send-pack$X git-shell$X \
266         git-show-index$X \
267         git-unpack-file$X \
268         git-update-server-info$X \
269         git-upload-pack$X \
270         git-pack-redundant$X git-var$X \
271         git-merge-tree$X git-imap-send$X \
272         $(EXTRA_PROGRAMS)
273
274 # Empty...
275 EXTRA_PROGRAMS =
276
277 # List built-in command $C whose implementation cmd_$C() is not in
278 # builtin-$C.o but is linked in as part of some other command.
279 BUILT_INS = \
280         git-format-patch$X git-show$X git-whatchanged$X git-cherry$X \
281         git-get-tar-commit-id$X git-init$X git-repo-config$X \
282         git-fsck-objects$X git-cherry-pick$X git-peek-remote$X git-status$X \
283         git-merge-subtree$X \
284         $(patsubst builtin-%.o,git-%$X,$(BUILTIN_OBJS))
285
286 # what 'all' will build and 'install' will install, in gitexecdir
287 ALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS)
288
289 # what 'all' will build but not install in gitexecdir
290 OTHER_PROGRAMS = git$X gitweb/gitweb.cgi
291
292 # Set paths to tools early so that they can be used for version tests.
293 ifndef SHELL_PATH
294         SHELL_PATH = /bin/sh
295 endif
296 ifndef PERL_PATH
297         PERL_PATH = /usr/bin/perl
298 endif
299
300 export PERL_PATH
301
302 LIB_FILE=libgit.a
303 XDIFF_LIB=xdiff/lib.a
304
305 LIB_H = \
306         archive.h blob.h cache.h cache-tree.h commit.h csum-file.h delta.h grep.h \
307         diff.h object.h pack.h pkt-line.h quote.h refs.h list-objects.h sideband.h \
308         run-command.h strbuf.h tag.h tree.h git-compat-util.h revision.h \
309         tree-walk.h log-tree.h dir.h path-list.h unpack-trees.h builtin.h \
310         utf8.h reflog-walk.h patch-ids.h attr.h decorate.h progress.h \
311         mailmap.h remote.h parse-options.h transport.h diffcore.h hash.h ll-merge.h fsck.h \
312         pack-revindex.h
313
314 LIB_OBJS = \
315         blob.o commit.o connect.o csum-file.o cache-tree.o base85.o \
316         date.o diff-delta.o entry.o exec_cmd.o ident.o \
317         pretty.o interpolate.o hash.o \
318         lockfile.o \
319         patch-ids.o \
320         object.o pack-check.o pack-write.o patch-delta.o path.o pkt-line.o \
321         sideband.o reachable.o reflog-walk.o \
322         quote.o read-cache.o refs.o run-command.o dir.o \
323         server-info.o setup.o sha1_file.o sha1_name.o strbuf.o \
324         tag.o tree.o usage.o config.o environment.o ctype.o copy.o \
325         revision.o pager.o tree-walk.o xdiff-interface.o \
326         write_or_die.o trace.o list-objects.o grep.o match-trees.o \
327         alloc.o merge-file.o path-list.o help.o unpack-trees.o \
328         color.o wt-status.o archive-zip.o archive-tar.o shallow.o utf8.o \
329         convert.o attr.o decorate.o progress.o mailmap.o symlinks.o remote.o \
330         transport.o bundle.o walker.o parse-options.o ws.o archive.o branch.o \
331         ll-merge.o alias.o fsck.o pack-revindex.o \
332         diff.o diff-lib.o diffcore-break.o diffcore-order.o \
333         diffcore-pickaxe.o diffcore-rename.o tree-diff.o combine-diff.o \
334         diffcore-delta.o log-tree.o
335
336 BUILTIN_OBJS = \
337         builtin-add.o \
338         builtin-annotate.o \
339         builtin-apply.o \
340         builtin-archive.o \
341         builtin-blame.o \
342         builtin-branch.o \
343         builtin-bundle.o \
344         builtin-cat-file.o \
345         builtin-check-attr.o \
346         builtin-checkout.o \
347         builtin-checkout-index.o \
348         builtin-check-ref-format.o \
349         builtin-clean.o \
350         builtin-commit.o \
351         builtin-commit-tree.o \
352         builtin-count-objects.o \
353         builtin-describe.o \
354         builtin-diff.o \
355         builtin-diff-files.o \
356         builtin-diff-index.o \
357         builtin-diff-tree.o \
358         builtin-fast-export.o \
359         builtin-fetch.o \
360         builtin-fetch-pack.o \
361         builtin-fetch--tool.o \
362         builtin-fmt-merge-msg.o \
363         builtin-for-each-ref.o \
364         builtin-fsck.o \
365         builtin-gc.o \
366         builtin-grep.o \
367         builtin-init-db.o \
368         builtin-log.o \
369         builtin-ls-files.o \
370         builtin-ls-tree.o \
371         builtin-ls-remote.o \
372         builtin-mailinfo.o \
373         builtin-mailsplit.o \
374         builtin-merge-base.o \
375         builtin-merge-file.o \
376         builtin-merge-ours.o \
377         builtin-merge-recursive.o \
378         builtin-mv.o \
379         builtin-name-rev.o \
380         builtin-pack-objects.o \
381         builtin-prune.o \
382         builtin-prune-packed.o \
383         builtin-push.o \
384         builtin-read-tree.o \
385         builtin-reflog.o \
386         builtin-remote.o \
387         builtin-send-pack.o \
388         builtin-config.o \
389         builtin-rerere.o \
390         builtin-reset.o \
391         builtin-rev-list.o \
392         builtin-rev-parse.o \
393         builtin-revert.o \
394         builtin-rm.o \
395         builtin-shortlog.o \
396         builtin-show-branch.o \
397         builtin-stripspace.o \
398         builtin-symbolic-ref.o \
399         builtin-tag.o \
400         builtin-tar-tree.o \
401         builtin-unpack-objects.o \
402         builtin-update-index.o \
403         builtin-update-ref.o \
404         builtin-upload-archive.o \
405         builtin-verify-pack.o \
406         builtin-verify-tag.o \
407         builtin-write-tree.o \
408         builtin-show-ref.o \
409         builtin-pack-refs.o
410
411 GITLIBS = $(LIB_FILE) $(XDIFF_LIB)
412 EXTLIBS =
413
414 #
415 # Platform specific tweaks
416 #
417
418 # We choose to avoid "if .. else if .. else .. endif endif"
419 # because maintaining the nesting to match is a pain.  If
420 # we had "elif" things would have been much nicer...
421
422 ifeq ($(uname_S),Linux)
423         NO_STRLCPY = YesPlease
424 endif
425 ifeq ($(uname_S),GNU/kFreeBSD)
426         NO_STRLCPY = YesPlease
427 endif
428 ifeq ($(uname_S),Darwin)
429         NEEDS_SSL_WITH_CRYPTO = YesPlease
430         NEEDS_LIBICONV = YesPlease
431         ifneq ($(shell expr "$(uname_R)" : '9\.'),2)
432                 OLD_ICONV = UnfortunatelyYes
433         endif
434         NO_STRLCPY = YesPlease
435         NO_MEMMEM = YesPlease
436 endif
437 ifeq ($(uname_S),SunOS)
438         NEEDS_SOCKET = YesPlease
439         NEEDS_NSL = YesPlease
440         SHELL_PATH = /bin/bash
441         NO_STRCASESTR = YesPlease
442         NO_MEMMEM = YesPlease
443         NO_HSTRERROR = YesPlease
444         NO_MKDTEMP = YesPlease
445         ifeq ($(uname_R),5.8)
446                 NEEDS_LIBICONV = YesPlease
447                 NO_UNSETENV = YesPlease
448                 NO_SETENV = YesPlease
449                 NO_C99_FORMAT = YesPlease
450                 NO_STRTOUMAX = YesPlease
451         endif
452         ifeq ($(uname_R),5.9)
453                 NO_UNSETENV = YesPlease
454                 NO_SETENV = YesPlease
455                 NO_C99_FORMAT = YesPlease
456                 NO_STRTOUMAX = YesPlease
457         endif
458         INSTALL = ginstall
459         TAR = gtar
460         BASIC_CFLAGS += -D__EXTENSIONS__
461 endif
462 ifeq ($(uname_O),Cygwin)
463         NO_D_TYPE_IN_DIRENT = YesPlease
464         NO_D_INO_IN_DIRENT = YesPlease
465         NO_STRCASESTR = YesPlease
466         NO_MEMMEM = YesPlease
467         NO_SYMLINK_HEAD = YesPlease
468         NEEDS_LIBICONV = YesPlease
469         NO_FAST_WORKING_DIRECTORY = UnfortunatelyYes
470         NO_TRUSTABLE_FILEMODE = UnfortunatelyYes
471         OLD_ICONV = UnfortunatelyYes
472         # There are conflicting reports about this.
473         # On some boxes NO_MMAP is needed, and not so elsewhere.
474         # Try commenting this out if you suspect MMAP is more efficient
475         NO_MMAP = YesPlease
476         NO_IPV6 = YesPlease
477         X = .exe
478 endif
479 ifeq ($(uname_S),FreeBSD)
480         NEEDS_LIBICONV = YesPlease
481         NO_MEMMEM = YesPlease
482         BASIC_CFLAGS += -I/usr/local/include
483         BASIC_LDFLAGS += -L/usr/local/lib
484         DIR_HAS_BSD_GROUP_SEMANTICS = YesPlease
485 endif
486 ifeq ($(uname_S),OpenBSD)
487         NO_STRCASESTR = YesPlease
488         NO_MEMMEM = YesPlease
489         NEEDS_LIBICONV = YesPlease
490         BASIC_CFLAGS += -I/usr/local/include
491         BASIC_LDFLAGS += -L/usr/local/lib
492 endif
493 ifeq ($(uname_S),NetBSD)
494         ifeq ($(shell expr "$(uname_R)" : '[01]\.'),2)
495                 NEEDS_LIBICONV = YesPlease
496         endif
497         BASIC_CFLAGS += -I/usr/pkg/include
498         BASIC_LDFLAGS += -L/usr/pkg/lib
499         ALL_LDFLAGS += -Wl,-rpath,/usr/pkg/lib
500 endif
501 ifeq ($(uname_S),AIX)
502         NO_STRCASESTR=YesPlease
503         NO_MEMMEM = YesPlease
504         NO_STRLCPY = YesPlease
505         NEEDS_LIBICONV=YesPlease
506 endif
507 ifeq ($(uname_S),GNU)
508         # GNU/Hurd
509         NO_STRLCPY=YesPlease
510 endif
511 ifeq ($(uname_S),IRIX64)
512         NO_IPV6=YesPlease
513         NO_SETENV=YesPlease
514         NO_STRCASESTR=YesPlease
515         NO_MEMMEM = YesPlease
516         NO_STRLCPY = YesPlease
517         NO_SOCKADDR_STORAGE=YesPlease
518         SHELL_PATH=/usr/gnu/bin/bash
519         BASIC_CFLAGS += -DPATH_MAX=1024
520         # for now, build 32-bit version
521         BASIC_LDFLAGS += -L/usr/lib32
522 endif
523 ifeq ($(uname_S),HP-UX)
524         NO_IPV6=YesPlease
525         NO_SETENV=YesPlease
526         NO_STRCASESTR=YesPlease
527         NO_MEMMEM = YesPlease
528         NO_STRLCPY = YesPlease
529         NO_MKDTEMP = YesPlease
530         NO_UNSETENV = YesPlease
531         NO_HSTRERROR = YesPlease
532         NO_SYS_SELECT_H = YesPlease
533 endif
534 ifneq (,$(findstring arm,$(uname_M)))
535         ARM_SHA1 = YesPlease
536 endif
537
538 -include config.mak.autogen
539 -include config.mak
540
541 ifeq ($(uname_S),Darwin)
542         ifndef NO_FINK
543                 ifeq ($(shell test -d /sw/lib && echo y),y)
544                         BASIC_CFLAGS += -I/sw/include
545                         BASIC_LDFLAGS += -L/sw/lib
546                 endif
547         endif
548         ifndef NO_DARWIN_PORTS
549                 ifeq ($(shell test -d /opt/local/lib && echo y),y)
550                         BASIC_CFLAGS += -I/opt/local/include
551                         BASIC_LDFLAGS += -L/opt/local/lib
552                 endif
553         endif
554 endif
555
556 ifdef NO_R_TO_GCC_LINKER
557         # Some gcc does not accept and pass -R to the linker to specify
558         # the runtime dynamic library path.
559         CC_LD_DYNPATH = -Wl,-rpath=
560 else
561         CC_LD_DYNPATH = -R
562 endif
563
564 ifdef NO_CURL
565         BASIC_CFLAGS += -DNO_CURL
566 else
567         ifdef CURLDIR
568                 # Try "-Wl,-rpath=$(CURLDIR)/$(lib)" in such a case.
569                 BASIC_CFLAGS += -I$(CURLDIR)/include
570                 CURL_LIBCURL = -L$(CURLDIR)/$(lib) $(CC_LD_DYNPATH)$(CURLDIR)/$(lib) -lcurl
571         else
572                 CURL_LIBCURL = -lcurl
573         endif
574         BUILTIN_OBJS += builtin-http-fetch.o
575         EXTLIBS += $(CURL_LIBCURL)
576         LIB_OBJS += http.o http-walker.o
577         curl_check := $(shell (echo 070908; curl-config --vernum) | sort -r | sed -ne 2p)
578         ifeq "$(curl_check)" "070908"
579                 ifndef NO_EXPAT
580                         PROGRAMS += git-http-push$X
581                 endif
582         endif
583         ifndef NO_EXPAT
584                 EXPAT_LIBEXPAT = -lexpat
585         endif
586 endif
587
588 ifdef ZLIB_PATH
589         BASIC_CFLAGS += -I$(ZLIB_PATH)/include
590         EXTLIBS += -L$(ZLIB_PATH)/$(lib) $(CC_LD_DYNPATH)$(ZLIB_PATH)/$(lib)
591 endif
592 EXTLIBS += -lz
593
594 ifndef NO_OPENSSL
595         OPENSSL_LIBSSL = -lssl
596         ifdef OPENSSLDIR
597                 BASIC_CFLAGS += -I$(OPENSSLDIR)/include
598                 OPENSSL_LINK = -L$(OPENSSLDIR)/$(lib) $(CC_LD_DYNPATH)$(OPENSSLDIR)/$(lib)
599         else
600                 OPENSSL_LINK =
601         endif
602 else
603         BASIC_CFLAGS += -DNO_OPENSSL
604         MOZILLA_SHA1 = 1
605         OPENSSL_LIBSSL =
606 endif
607 ifdef NEEDS_SSL_WITH_CRYPTO
608         LIB_4_CRYPTO = $(OPENSSL_LINK) -lcrypto -lssl
609 else
610         LIB_4_CRYPTO = $(OPENSSL_LINK) -lcrypto
611 endif
612 ifdef NEEDS_LIBICONV
613         ifdef ICONVDIR
614                 BASIC_CFLAGS += -I$(ICONVDIR)/include
615                 ICONV_LINK = -L$(ICONVDIR)/$(lib) $(CC_LD_DYNPATH)$(ICONVDIR)/$(lib)
616         else
617                 ICONV_LINK =
618         endif
619         EXTLIBS += $(ICONV_LINK) -liconv
620 endif
621 ifdef NEEDS_SOCKET
622         EXTLIBS += -lsocket
623 endif
624 ifdef NEEDS_NSL
625         EXTLIBS += -lnsl
626 endif
627 ifdef NO_D_TYPE_IN_DIRENT
628         BASIC_CFLAGS += -DNO_D_TYPE_IN_DIRENT
629 endif
630 ifdef NO_D_INO_IN_DIRENT
631         BASIC_CFLAGS += -DNO_D_INO_IN_DIRENT
632 endif
633 ifdef NO_C99_FORMAT
634         BASIC_CFLAGS += -DNO_C99_FORMAT
635 endif
636 ifdef SNPRINTF_RETURNS_BOGUS
637         COMPAT_CFLAGS += -DSNPRINTF_RETURNS_BOGUS
638         COMPAT_OBJS += compat/snprintf.o
639 endif
640 ifdef FREAD_READS_DIRECTORIES
641         COMPAT_CFLAGS += -DFREAD_READS_DIRECTORIES
642         COMPAT_OBJS += compat/fopen.o
643 endif
644 ifdef NO_SYMLINK_HEAD
645         BASIC_CFLAGS += -DNO_SYMLINK_HEAD
646 endif
647 ifdef NO_STRCASESTR
648         COMPAT_CFLAGS += -DNO_STRCASESTR
649         COMPAT_OBJS += compat/strcasestr.o
650 endif
651 ifdef NO_STRLCPY
652         COMPAT_CFLAGS += -DNO_STRLCPY
653         COMPAT_OBJS += compat/strlcpy.o
654 endif
655 ifdef NO_STRTOUMAX
656         COMPAT_CFLAGS += -DNO_STRTOUMAX
657         COMPAT_OBJS += compat/strtoumax.o
658 endif
659 ifdef NO_STRTOULL
660         COMPAT_CFLAGS += -DNO_STRTOULL
661 endif
662 ifdef NO_SETENV
663         COMPAT_CFLAGS += -DNO_SETENV
664         COMPAT_OBJS += compat/setenv.o
665 endif
666 ifdef NO_MKDTEMP
667         COMPAT_CFLAGS += -DNO_MKDTEMP
668         COMPAT_OBJS += compat/mkdtemp.o
669 endif
670 ifdef NO_UNSETENV
671         COMPAT_CFLAGS += -DNO_UNSETENV
672         COMPAT_OBJS += compat/unsetenv.o
673 endif
674 ifdef NO_SYS_SELECT_H
675         BASIC_CFLAGS += -DNO_SYS_SELECT_H
676 endif
677 ifdef NO_MMAP
678         COMPAT_CFLAGS += -DNO_MMAP
679         COMPAT_OBJS += compat/mmap.o
680 endif
681 ifdef NO_PREAD
682         COMPAT_CFLAGS += -DNO_PREAD
683         COMPAT_OBJS += compat/pread.o
684 endif
685 ifdef NO_FAST_WORKING_DIRECTORY
686         BASIC_CFLAGS += -DNO_FAST_WORKING_DIRECTORY
687 endif
688 ifdef NO_TRUSTABLE_FILEMODE
689         BASIC_CFLAGS += -DNO_TRUSTABLE_FILEMODE
690 endif
691 ifdef NO_IPV6
692         BASIC_CFLAGS += -DNO_IPV6
693 endif
694 ifdef NO_SOCKADDR_STORAGE
695 ifdef NO_IPV6
696         BASIC_CFLAGS += -Dsockaddr_storage=sockaddr_in
697 else
698         BASIC_CFLAGS += -Dsockaddr_storage=sockaddr_in6
699 endif
700 endif
701 ifdef NO_INET_NTOP
702         LIB_OBJS += compat/inet_ntop.o
703 endif
704 ifdef NO_INET_PTON
705         LIB_OBJS += compat/inet_pton.o
706 endif
707
708 ifdef NO_ICONV
709         BASIC_CFLAGS += -DNO_ICONV
710 endif
711
712 ifdef OLD_ICONV
713         BASIC_CFLAGS += -DOLD_ICONV
714 endif
715
716 ifdef NO_DEFLATE_BOUND
717         BASIC_CFLAGS += -DNO_DEFLATE_BOUND
718 endif
719
720 ifdef PPC_SHA1
721         SHA1_HEADER = "ppc/sha1.h"
722         LIB_OBJS += ppc/sha1.o ppc/sha1ppc.o
723 else
724 ifdef ARM_SHA1
725         SHA1_HEADER = "arm/sha1.h"
726         LIB_OBJS += arm/sha1.o arm/sha1_arm.o
727 else
728 ifdef MOZILLA_SHA1
729         SHA1_HEADER = "mozilla-sha1/sha1.h"
730         LIB_OBJS += mozilla-sha1/sha1.o
731 else
732         SHA1_HEADER = <openssl/sha.h>
733         EXTLIBS += $(LIB_4_CRYPTO)
734 endif
735 endif
736 endif
737 ifdef NO_PERL_MAKEMAKER
738         export NO_PERL_MAKEMAKER
739 endif
740 ifdef NO_HSTRERROR
741         COMPAT_CFLAGS += -DNO_HSTRERROR
742         COMPAT_OBJS += compat/hstrerror.o
743 endif
744 ifdef NO_MEMMEM
745         COMPAT_CFLAGS += -DNO_MEMMEM
746         COMPAT_OBJS += compat/memmem.o
747 endif
748 ifdef INTERNAL_QSORT
749         COMPAT_CFLAGS += -DINTERNAL_QSORT
750         COMPAT_OBJS += compat/qsort.o
751 endif
752
753 ifdef THREADED_DELTA_SEARCH
754         BASIC_CFLAGS += -DTHREADED_DELTA_SEARCH
755         EXTLIBS += -lpthread
756         LIB_OBJS += thread-utils.o
757 endif
758 ifdef DIR_HAS_BSD_GROUP_SEMANTICS
759         COMPAT_CFLAGS += -DDIR_HAS_BSD_GROUP_SEMANTICS
760 endif
761
762 ifeq ($(TCLTK_PATH),)
763 NO_TCLTK=NoThanks
764 endif
765
766 QUIET_SUBDIR0  = +$(MAKE) -C # space to separate -C and subdir
767 QUIET_SUBDIR1  =
768
769 ifneq ($(findstring $(MAKEFLAGS),w),w)
770 PRINT_DIR = --no-print-directory
771 else # "make -w"
772 NO_SUBDIR = :
773 endif
774
775 ifneq ($(findstring $(MAKEFLAGS),s),s)
776 ifndef V
777         QUIET_CC       = @echo '   ' CC $@;
778         QUIET_AR       = @echo '   ' AR $@;
779         QUIET_LINK     = @echo '   ' LINK $@;
780         QUIET_BUILT_IN = @echo '   ' BUILTIN $@;
781         QUIET_GEN      = @echo '   ' GEN $@;
782         QUIET_SUBDIR0  = +@subdir=
783         QUIET_SUBDIR1  = ;$(NO_SUBDIR) echo '   ' SUBDIR $$subdir; \
784                          $(MAKE) $(PRINT_DIR) -C $$subdir
785         export V
786         export QUIET_GEN
787         export QUIET_BUILT_IN
788 endif
789 endif
790
791 ifdef ASCIIDOC8
792         export ASCIIDOC8
793 endif
794
795 # Shell quote (do not use $(call) to accommodate ancient setups);
796
797 SHA1_HEADER_SQ = $(subst ','\'',$(SHA1_HEADER))
798 ETC_GITCONFIG_SQ = $(subst ','\'',$(ETC_GITCONFIG))
799
800 DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
801 bindir_SQ = $(subst ','\'',$(bindir))
802 mandir_SQ = $(subst ','\'',$(mandir))
803 infodir_SQ = $(subst ','\'',$(infodir))
804 gitexecdir_SQ = $(subst ','\'',$(gitexecdir))
805 template_dir_SQ = $(subst ','\'',$(template_dir))
806 htmldir_SQ = $(subst ','\'',$(htmldir))
807 prefix_SQ = $(subst ','\'',$(prefix))
808
809 SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
810 PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
811 TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH))
812
813 LIBS = $(GITLIBS) $(EXTLIBS)
814
815 BASIC_CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER_SQ)' \
816         $(COMPAT_CFLAGS)
817 LIB_OBJS += $(COMPAT_OBJS)
818
819 ALL_CFLAGS += $(BASIC_CFLAGS)
820 ALL_LDFLAGS += $(BASIC_LDFLAGS)
821
822 export TAR INSTALL DESTDIR SHELL_PATH
823
824
825 ### Build rules
826
827 all:: $(ALL_PROGRAMS) $(BUILT_INS) $(OTHER_PROGRAMS) GIT-BUILD-OPTIONS
828 ifneq (,$X)
829         $(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) git$X)), $(RM) '$p';)
830 endif
831
832 all::
833 ifndef NO_TCLTK
834         $(QUIET_SUBDIR0)git-gui $(QUIET_SUBDIR1) all
835         $(QUIET_SUBDIR0)gitk-git $(QUIET_SUBDIR1) all
836 endif
837         $(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' all
838         $(QUIET_SUBDIR0)templates $(QUIET_SUBDIR1)
839
840 strip: $(PROGRAMS) git$X
841         $(STRIP) $(STRIP_OPTS) $(PROGRAMS) git$X
842
843 git.o: git.c common-cmds.h GIT-CFLAGS
844         $(QUIET_CC)$(CC) -DGIT_VERSION='"$(GIT_VERSION)"' \
845                 $(ALL_CFLAGS) -c $(filter %.c,$^)
846
847 git$X: git.o $(BUILTIN_OBJS) $(GITLIBS)
848         $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ git.o \
849                 $(BUILTIN_OBJS) $(ALL_LDFLAGS) $(LIBS)
850
851 help.o: help.c common-cmds.h GIT-CFLAGS
852         $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) \
853                 '-DGIT_HTML_PATH="$(htmldir_SQ)"' \
854                 '-DGIT_MAN_PATH="$(mandir_SQ)"' \
855                 '-DGIT_INFO_PATH="$(infodir_SQ)"' $<
856
857 $(BUILT_INS): git$X
858         $(QUIET_BUILT_IN)$(RM) $@ && ln git$X $@
859
860 common-cmds.h: ./generate-cmdlist.sh command-list.txt
861
862 common-cmds.h: $(wildcard Documentation/git-*.txt)
863         $(QUIET_GEN)./generate-cmdlist.sh > $@+ && mv $@+ $@
864
865 $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
866         $(QUIET_GEN)$(RM) $@ $@+ && \
867         sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
868             -e 's|@@PERL@@|$(PERL_PATH_SQ)|g' \
869             -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
870             -e 's/@@NO_CURL@@/$(NO_CURL)/g' \
871             $@.sh >$@+ && \
872         chmod +x $@+ && \
873         mv $@+ $@
874
875 $(patsubst %.perl,%,$(SCRIPT_PERL)): perl/perl.mak
876
877 perl/perl.mak: GIT-CFLAGS perl/Makefile perl/Makefile.PL
878         $(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' $(@F)
879
880 $(patsubst %.perl,%,$(SCRIPT_PERL)): % : %.perl
881         $(QUIET_GEN)$(RM) $@ $@+ && \
882         INSTLIBDIR=`MAKEFLAGS= $(MAKE) -C perl -s --no-print-directory instlibdir` && \
883         sed -e '1{' \
884             -e '        s|#!.*perl|#!$(PERL_PATH_SQ)|' \
885             -e '        h' \
886             -e '        s=.*=use lib (split(/:/, $$ENV{GITPERLLIB} || "@@INSTLIBDIR@@"));=' \
887             -e '        H' \
888             -e '        x' \
889             -e '}' \
890             -e 's|@@INSTLIBDIR@@|'"$$INSTLIBDIR"'|g' \
891             -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
892             $@.perl >$@+ && \
893         chmod +x $@+ && \
894         mv $@+ $@
895
896 gitweb/gitweb.cgi: gitweb/gitweb.perl
897         $(QUIET_GEN)$(RM) $@ $@+ && \
898         sed -e '1s|#!.*perl|#!$(PERL_PATH_SQ)|' \
899             -e 's|++GIT_VERSION++|$(GIT_VERSION)|g' \
900             -e 's|++GIT_BINDIR++|$(bindir)|g' \
901             -e 's|++GITWEB_CONFIG++|$(GITWEB_CONFIG)|g' \
902             -e 's|++GITWEB_HOME_LINK_STR++|$(GITWEB_HOME_LINK_STR)|g' \
903             -e 's|++GITWEB_SITENAME++|$(GITWEB_SITENAME)|g' \
904             -e 's|++GITWEB_PROJECTROOT++|$(GITWEB_PROJECTROOT)|g' \
905             -e 's|"++GITWEB_PROJECT_MAXDEPTH++"|$(GITWEB_PROJECT_MAXDEPTH)|g' \
906             -e 's|++GITWEB_EXPORT_OK++|$(GITWEB_EXPORT_OK)|g' \
907             -e 's|++GITWEB_STRICT_EXPORT++|$(GITWEB_STRICT_EXPORT)|g' \
908             -e 's|++GITWEB_BASE_URL++|$(GITWEB_BASE_URL)|g' \
909             -e 's|++GITWEB_LIST++|$(GITWEB_LIST)|g' \
910             -e 's|++GITWEB_HOMETEXT++|$(GITWEB_HOMETEXT)|g' \
911             -e 's|++GITWEB_CSS++|$(GITWEB_CSS)|g' \
912             -e 's|++GITWEB_LOGO++|$(GITWEB_LOGO)|g' \
913             -e 's|++GITWEB_FAVICON++|$(GITWEB_FAVICON)|g' \
914             -e 's|++GITWEB_SITE_HEADER++|$(GITWEB_SITE_HEADER)|g' \
915             -e 's|++GITWEB_SITE_FOOTER++|$(GITWEB_SITE_FOOTER)|g' \
916             $< >$@+ && \
917         chmod +x $@+ && \
918         mv $@+ $@
919
920 git-instaweb: git-instaweb.sh gitweb/gitweb.cgi gitweb/gitweb.css
921         $(QUIET_GEN)$(RM) $@ $@+ && \
922         sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
923             -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
924             -e 's/@@NO_CURL@@/$(NO_CURL)/g' \
925             -e '/@@GITWEB_CGI@@/r gitweb/gitweb.cgi' \
926             -e '/@@GITWEB_CGI@@/d' \
927             -e '/@@GITWEB_CSS@@/r gitweb/gitweb.css' \
928             -e '/@@GITWEB_CSS@@/d' \
929             -e 's|@@PERL@@|$(PERL_PATH_SQ)|g' \
930             $@.sh > $@+ && \
931         chmod +x $@+ && \
932         mv $@+ $@
933
934 configure: configure.ac
935         $(QUIET_GEN)$(RM) $@ $<+ && \
936         sed -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
937             $< > $<+ && \
938         autoconf -o $@ $<+ && \
939         $(RM) $<+
940
941 # These can record GIT_VERSION
942 git.o git.spec \
943         $(patsubst %.sh,%,$(SCRIPT_SH)) \
944         $(patsubst %.perl,%,$(SCRIPT_PERL)) \
945         : GIT-VERSION-FILE
946
947 %.o: %.c GIT-CFLAGS
948         $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $<
949 %.s: %.c GIT-CFLAGS
950         $(QUIET_CC)$(CC) -S $(ALL_CFLAGS) $<
951 %.o: %.S
952         $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $<
953
954 exec_cmd.o: exec_cmd.c GIT-CFLAGS
955         $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) '-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' $<
956 builtin-init-db.o: builtin-init-db.c GIT-CFLAGS
957         $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir_SQ)"' $<
958
959 config.o: config.c GIT-CFLAGS
960         $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DETC_GITCONFIG='"$(ETC_GITCONFIG_SQ)"' $<
961
962 http.o: http.c GIT-CFLAGS
963         $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DGIT_USER_AGENT='"git/$(GIT_VERSION)"' $<
964
965 ifdef NO_EXPAT
966 http-walker.o: http-walker.c http.h GIT-CFLAGS
967         $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DNO_EXPAT $<
968 endif
969
970 git-%$X: %.o $(GITLIBS)
971         $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
972
973 git-imap-send$X: imap-send.o $(LIB_FILE)
974
975 http.o http-walker.o http-push.o transport.o: http.h
976
977 git-http-push$X: revision.o http.o http-push.o $(GITLIBS)
978         $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
979                 $(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
980
981 $(LIB_OBJS) $(BUILTIN_OBJS): $(LIB_H)
982 $(patsubst git-%$X,%.o,$(PROGRAMS)): $(LIB_H) $(wildcard */*.h)
983 builtin-revert.o wt-status.o: wt-status.h
984
985 $(LIB_FILE): $(LIB_OBJS)
986         $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIB_OBJS)
987
988 XDIFF_OBJS=xdiff/xdiffi.o xdiff/xprepare.o xdiff/xutils.o xdiff/xemit.o \
989         xdiff/xmerge.o
990 $(XDIFF_OBJS): xdiff/xinclude.h xdiff/xmacros.h xdiff/xdiff.h xdiff/xtypes.h \
991         xdiff/xutils.h xdiff/xprepare.h xdiff/xdiffi.h xdiff/xemit.h
992
993 $(XDIFF_LIB): $(XDIFF_OBJS)
994         $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(XDIFF_OBJS)
995
996
997 doc:
998         $(MAKE) -C Documentation all
999
1000 info:
1001         $(MAKE) -C Documentation info
1002
1003 TAGS:
1004         $(RM) TAGS
1005         $(FIND) . -name '*.[hcS]' -print | xargs etags -a
1006
1007 tags:
1008         $(RM) tags
1009         $(FIND) . -name '*.[hcS]' -print | xargs ctags -a
1010
1011 cscope:
1012         $(RM) cscope*
1013         $(FIND) . -name '*.[hcS]' -print | xargs cscope -b
1014
1015 ### Detect prefix changes
1016 TRACK_CFLAGS = $(subst ','\'',$(ALL_CFLAGS)):\
1017              $(bindir_SQ):$(gitexecdir_SQ):$(template_dir_SQ):$(prefix_SQ)
1018
1019 GIT-CFLAGS: .FORCE-GIT-CFLAGS
1020         @FLAGS='$(TRACK_CFLAGS)'; \
1021             if test x"$$FLAGS" != x"`cat GIT-CFLAGS 2>/dev/null`" ; then \
1022                 echo 1>&2 "    * new build flags or prefix"; \
1023                 echo "$$FLAGS" >GIT-CFLAGS; \
1024             fi
1025
1026 GIT-BUILD-OPTIONS: .FORCE-GIT-BUILD-OPTIONS
1027         @echo SHELL_PATH=\''$(SHELL_PATH_SQ)'\' >$@
1028
1029 ### Detect Tck/Tk interpreter path changes
1030 ifndef NO_TCLTK
1031 TRACK_VARS = $(subst ','\'',-DTCLTK_PATH='$(TCLTK_PATH_SQ)')
1032
1033 GIT-GUI-VARS: .FORCE-GIT-GUI-VARS
1034         @VARS='$(TRACK_VARS)'; \
1035             if test x"$$VARS" != x"`cat $@ 2>/dev/null`" ; then \
1036                 echo 1>&2 "    * new Tcl/Tk interpreter location"; \
1037                 echo "$$VARS" >$@; \
1038             fi
1039
1040 .PHONY: .FORCE-GIT-GUI-VARS
1041 endif
1042
1043 ### Testing rules
1044
1045 TEST_PROGRAMS = test-chmtime$X test-genrandom$X test-date$X test-delta$X test-sha1$X test-match-trees$X test-absolute-path$X test-parse-options$X
1046
1047 all:: $(TEST_PROGRAMS)
1048
1049 # GNU make supports exporting all variables by "export" without parameters.
1050 # However, the environment gets quite big, and some programs have problems
1051 # with that.
1052
1053 export NO_SVN_TESTS
1054
1055 test: all
1056         $(MAKE) -C t/ all
1057
1058 test-date$X: date.o ctype.o
1059
1060 test-delta$X: diff-delta.o patch-delta.o
1061
1062 test-parse-options$X: parse-options.o
1063
1064 .PRECIOUS: $(patsubst test-%$X,test-%.o,$(TEST_PROGRAMS))
1065
1066 test-%$X: test-%.o $(GITLIBS)
1067         $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
1068
1069 check-sha1:: test-sha1$X
1070         ./test-sha1.sh
1071
1072 check: common-cmds.h
1073         for i in *.c; do sparse $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i || exit; done
1074
1075 remove-dashes:
1076         ./fixup-builtins $(BUILT_INS)
1077
1078 ### Installation rules
1079
1080 install: all
1081         $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'
1082         $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitexecdir_SQ)'
1083         $(INSTALL) $(ALL_PROGRAMS) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
1084         $(INSTALL) git$X '$(DESTDIR_SQ)$(bindir_SQ)'
1085         $(MAKE) -C templates DESTDIR='$(DESTDIR_SQ)' install
1086         $(MAKE) -C perl prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' install
1087 ifndef NO_TCLTK
1088         $(MAKE) -C gitk-git install
1089         $(MAKE) -C git-gui install
1090 endif
1091         if test 'z$(bindir_SQ)' != 'z$(gitexecdir_SQ)'; \
1092         then \
1093                 ln -f '$(DESTDIR_SQ)$(bindir_SQ)/git$X' \
1094                         '$(DESTDIR_SQ)$(gitexecdir_SQ)/git$X' || \
1095                 cp '$(DESTDIR_SQ)$(bindir_SQ)/git$X' \
1096                         '$(DESTDIR_SQ)$(gitexecdir_SQ)/git$X'; \
1097         fi
1098         $(foreach p,$(BUILT_INS), $(RM) '$(DESTDIR_SQ)$(gitexecdir_SQ)/$p' && ln '$(DESTDIR_SQ)$(gitexecdir_SQ)/git$X' '$(DESTDIR_SQ)$(gitexecdir_SQ)/$p' ;)
1099 ifneq (,$X)
1100         $(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) git$X)), $(RM) '$(DESTDIR_SQ)$(gitexecdir_SQ)/$p';)
1101 endif
1102
1103 install-doc:
1104         $(MAKE) -C Documentation install
1105
1106 install-info:
1107         $(MAKE) -C Documentation install-info
1108
1109 quick-install-doc:
1110         $(MAKE) -C Documentation quick-install
1111
1112
1113
1114 ### Maintainer's dist rules
1115
1116 git.spec: git.spec.in
1117         sed -e 's/@@VERSION@@/$(GIT_VERSION)/g' < $< > $@+
1118         mv $@+ $@
1119
1120 GIT_TARNAME=git-$(GIT_VERSION)
1121 dist: git.spec git-archive$(X) configure
1122         ./git-archive --format=tar \
1123                 --prefix=$(GIT_TARNAME)/ HEAD^{tree} > $(GIT_TARNAME).tar
1124         @mkdir -p $(GIT_TARNAME)
1125         @cp git.spec configure $(GIT_TARNAME)
1126         @echo $(GIT_VERSION) > $(GIT_TARNAME)/version
1127         @$(MAKE) -C git-gui TARDIR=../$(GIT_TARNAME)/git-gui dist-version
1128         $(TAR) rf $(GIT_TARNAME).tar \
1129                 $(GIT_TARNAME)/git.spec \
1130                 $(GIT_TARNAME)/configure \
1131                 $(GIT_TARNAME)/version \
1132                 $(GIT_TARNAME)/git-gui/version
1133         @$(RM) -r $(GIT_TARNAME)
1134         gzip -f -9 $(GIT_TARNAME).tar
1135
1136 rpm: dist
1137         $(RPMBUILD) -ta $(GIT_TARNAME).tar.gz
1138
1139 htmldocs = git-htmldocs-$(GIT_VERSION)
1140 manpages = git-manpages-$(GIT_VERSION)
1141 dist-doc:
1142         $(RM) -r .doc-tmp-dir
1143         mkdir .doc-tmp-dir
1144         $(MAKE) -C Documentation WEBDOC_DEST=../.doc-tmp-dir install-webdoc
1145         cd .doc-tmp-dir && $(TAR) cf ../$(htmldocs).tar .
1146         gzip -n -9 -f $(htmldocs).tar
1147         :
1148         $(RM) -r .doc-tmp-dir
1149         mkdir -p .doc-tmp-dir/man1 .doc-tmp-dir/man5 .doc-tmp-dir/man7
1150         $(MAKE) -C Documentation DESTDIR=./ \
1151                 man1dir=../.doc-tmp-dir/man1 \
1152                 man5dir=../.doc-tmp-dir/man5 \
1153                 man7dir=../.doc-tmp-dir/man7 \
1154                 install
1155         cd .doc-tmp-dir && $(TAR) cf ../$(manpages).tar .
1156         gzip -n -9 -f $(manpages).tar
1157         $(RM) -r .doc-tmp-dir
1158
1159 ### Cleaning rules
1160
1161 distclean: clean
1162         $(RM) configure
1163
1164 clean:
1165         $(RM) *.o mozilla-sha1/*.o arm/*.o ppc/*.o compat/*.o xdiff/*.o \
1166                 $(LIB_FILE) $(XDIFF_LIB)
1167         $(RM) $(ALL_PROGRAMS) $(BUILT_INS) git$X
1168         $(RM) $(TEST_PROGRAMS)
1169         $(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo common-cmds.h TAGS tags cscope*
1170         $(RM) -r autom4te.cache
1171         $(RM) config.log config.mak.autogen config.mak.append config.status config.cache
1172         $(RM) -r $(GIT_TARNAME) .doc-tmp-dir
1173         $(RM) $(GIT_TARNAME).tar.gz git-core_$(GIT_VERSION)-*.tar.gz
1174         $(RM) $(htmldocs).tar.gz $(manpages).tar.gz
1175         $(RM) gitweb/gitweb.cgi
1176         $(MAKE) -C Documentation/ clean
1177         $(MAKE) -C perl clean
1178         $(MAKE) -C templates/ clean
1179         $(MAKE) -C t/ clean
1180 ifndef NO_TCLTK
1181         $(MAKE) -C gitk-git clean
1182         $(MAKE) -C git-gui clean
1183 endif
1184         $(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-GUI-VARS GIT-BUILD-OPTIONS
1185
1186 .PHONY: all install clean strip
1187 .PHONY: .FORCE-GIT-VERSION-FILE TAGS tags cscope .FORCE-GIT-CFLAGS
1188 .PHONY: .FORCE-GIT-BUILD-OPTIONS
1189
1190 ### Check documentation
1191 #
1192 check-docs::
1193         @(for v in $(ALL_PROGRAMS) $(BUILT_INS) git gitk; \
1194         do \
1195                 case "$$v" in \
1196                 git-merge-octopus | git-merge-ours | git-merge-recursive | \
1197                 git-merge-resolve | git-merge-stupid | git-merge-subtree | \
1198                 git-fsck-objects | git-init-db | \
1199                 git-?*--?* ) continue ;; \
1200                 esac ; \
1201                 test -f "Documentation/$$v.txt" || \
1202                 echo "no doc: $$v"; \
1203                 sed -e '/^#/d' command-list.txt | \
1204                 grep -q "^$$v[  ]" || \
1205                 case "$$v" in \
1206                 git) ;; \
1207                 *) echo "no link: $$v";; \
1208                 esac ; \
1209         done; \
1210         ( \
1211                 sed -e '/^#/d' \
1212                     -e 's/[     ].*//' \
1213                     -e 's/^/listed /' command-list.txt; \
1214                 ls -1 Documentation/git*txt | \
1215                 sed -e 's|Documentation/|documented |' \
1216                     -e 's/\.txt//'; \
1217         ) | while read how cmd; \
1218         do \
1219                 case "$$how,$$cmd" in \
1220                 *,git-citool | \
1221                 *,git-gui | \
1222                 *,git-help | \
1223                 documented,gitattributes | \
1224                 documented,gitignore | \
1225                 documented,gitmodules | \
1226                 documented,gitcli | \
1227                 documented,git-tools | \
1228                 sentinel,not,matching,is,ok ) continue ;; \
1229                 esac; \
1230                 case " $(ALL_PROGRAMS) $(BUILT_INS) git gitk " in \
1231                 *" $$cmd "*)    ;; \
1232                 *) echo "removed but $$how: $$cmd" ;; \
1233                 esac; \
1234         done ) | sort
1235
1236 ### Make sure built-ins do not have dups and listed in git.c
1237 #
1238 check-builtins::
1239         ./check-builtins.sh
1240