Code

Merge branch 'js/rerere'
[git.git] / Makefile
1 # The default target of this Makefile is...
2 all:
4 # Define NO_OPENSSL environment variable if you do not have OpenSSL.
5 # This also implies MOZILLA_SHA1.
6 #
7 # Define NO_CURL if you do not have curl installed.  git-http-pull and
8 # git-http-push are not built, and you cannot use http:// and https://
9 # transports.
10 #
11 # Define CURLDIR=/foo/bar if your curl header and library files are in
12 # /foo/bar/include and /foo/bar/lib directories.
13 #
14 # Define NO_EXPAT if you do not have expat installed.  git-http-push is
15 # not built, and you cannot push using http:// and https:// transports.
16 #
17 # Define NO_D_INO_IN_DIRENT if you don't have d_ino in your struct dirent.
18 #
19 # Define NO_D_TYPE_IN_DIRENT if your platform defines DT_UNKNOWN but lacks
20 # d_type in struct dirent (latest Cygwin -- will be fixed soonish).
21 #
22 # Define NO_C99_FORMAT if your formatted IO functions (printf/scanf et.al.)
23 # do not support the 'size specifiers' introduced by C99, namely ll, hh,
24 # j, z, t. (representing long long int, char, intmax_t, size_t, ptrdiff_t).
25 # some C compilers supported these specifiers prior to C99 as an extension.
26 #
27 # Define NO_STRCASESTR if you don't have strcasestr.
28 #
29 # Define NO_STRLCPY if you don't have strlcpy.
30 #
31 # Define NO_SETENV if you don't have setenv in the C library.
32 #
33 # Define NO_SYMLINK_HEAD if you never want .git/HEAD to be a symbolic link.
34 # Enable it on Windows.  By default, symrefs are still used.
35 #
36 # Define NO_SVN_TESTS if you want to skip time-consuming SVN interoperability
37 # tests.  These tests take up a significant amount of the total test time
38 # but are not needed unless you plan to talk to SVN repos.
39 #
40 # Define NO_FINK if you are building on Darwin/Mac OS X, have Fink
41 # installed in /sw, but don't want GIT to link against any libraries
42 # installed there.  If defined you may specify your own (or Fink's)
43 # include directories and library directories by defining CFLAGS
44 # and LDFLAGS appropriately.
45 #
46 # Define NO_DARWIN_PORTS if you are building on Darwin/Mac OS X,
47 # have DarwinPorts installed in /opt/local, but don't want GIT to
48 # link against any libraries installed there.  If defined you may
49 # specify your own (or DarwinPort's) include directories and
50 # library directories by defining CFLAGS and LDFLAGS appropriately.
51 #
52 # Define PPC_SHA1 environment variable when running make to make use of
53 # a bundled SHA1 routine optimized for PowerPC.
54 #
55 # Define ARM_SHA1 environment variable when running make to make use of
56 # a bundled SHA1 routine optimized for ARM.
57 #
58 # Define MOZILLA_SHA1 environment variable when running make to make use of
59 # a bundled SHA1 routine coming from Mozilla. It is GPL'd and should be fast
60 # on non-x86 architectures (e.g. PowerPC), while the OpenSSL version (default
61 # choice) has very fast version optimized for i586.
62 #
63 # Define NEEDS_SSL_WITH_CRYPTO if you need -lcrypto with -lssl (Darwin).
64 #
65 # Define NEEDS_LIBICONV if linking with libc is not enough (Darwin).
66 #
67 # Define NEEDS_SOCKET if linking with libc is not enough (SunOS,
68 # Patrick Mauritz).
69 #
70 # Define NO_MMAP if you want to avoid mmap.
71 #
72 # Define NO_FAST_WORKING_DIRECTORY if accessing objects in pack files is
73 # generally faster on your platform than accessing the working directory.
74 #
75 # Define NO_IPV6 if you lack IPv6 support and getaddrinfo().
76 #
77 # Define NO_SOCKADDR_STORAGE if your platform does not have struct
78 # sockaddr_storage.
79 #
80 # Define NO_ICONV if your libc does not properly support iconv.
81 #
82 # Define USE_NSEC below if you want git to care about sub-second file mtimes
83 # and ctimes. Note that you need recent glibc (at least 2.2.4) for this, and
84 # it will BREAK YOUR LOCAL DIFFS! show-diff and anything using it will likely
85 # randomly break unless your underlying filesystem supports those sub-second
86 # times (my ext3 doesn't).
87 #
88 # Define USE_STDEV below if you want git to care about the underlying device
89 # change being considered an inode change from the update-cache perspective.
90 #
91 # Define NO_PERL_MAKEMAKER if you cannot use Makefiles generated by perl's
92 # MakeMaker (e.g. using ActiveState under Cygwin).
93 #
95 GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
96         @$(SHELL_PATH) ./GIT-VERSION-GEN
97 -include GIT-VERSION-FILE
99 uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
100 uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not')
101 uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')
102 uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not')
103 uname_P := $(shell sh -c 'uname -p 2>/dev/null || echo not')
105 # CFLAGS and LDFLAGS are for the users to override from the command line.
107 CFLAGS = -g -O2 -Wall
108 LDFLAGS =
109 ALL_CFLAGS = $(CFLAGS)
110 ALL_LDFLAGS = $(LDFLAGS)
111 STRIP ?= strip
113 prefix = $(HOME)
114 bindir = $(prefix)/bin
115 gitexecdir = $(bindir)
116 template_dir = $(prefix)/share/git-core/templates/
117 # DESTDIR=
119 # default configuration for gitweb
120 GITWEB_CONFIG = gitweb_config.perl
121 GITWEB_HOME_LINK_STR = projects
122 GITWEB_SITENAME =
123 GITWEB_PROJECTROOT = /pub/git
124 GITWEB_EXPORT_OK =
125 GITWEB_STRICT_EXPORT =
126 GITWEB_BASE_URL =
127 GITWEB_LIST =
128 GITWEB_HOMETEXT = indextext.html
129 GITWEB_CSS = gitweb.css
130 GITWEB_LOGO = git-logo.png
131 GITWEB_FAVICON = git-favicon.png
132 GITWEB_SITE_HEADER =
133 GITWEB_SITE_FOOTER =
135 export prefix bindir gitexecdir template_dir
137 CC = gcc
138 AR = ar
139 TAR = tar
140 INSTALL = install
141 RPMBUILD = rpmbuild
143 # sparse is architecture-neutral, which means that we need to tell it
144 # explicitly what architecture to check for. Fix this up for yours..
145 SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
149 ### --- END CONFIGURATION SECTION ---
151 # Those must not be GNU-specific; they are shared with perl/ which may
152 # be built by a different compiler. (Note that this is an artifact now
153 # but it still might be nice to keep that distinction.)
154 BASIC_CFLAGS =
155 BASIC_LDFLAGS =
157 SCRIPT_SH = \
158         git-bisect.sh git-checkout.sh \
159         git-clean.sh git-clone.sh git-commit.sh \
160         git-fetch.sh \
161         git-ls-remote.sh \
162         git-merge-one-file.sh git-parse-remote.sh \
163         git-pull.sh git-rebase.sh \
164         git-repack.sh git-request-pull.sh git-reset.sh \
165         git-resolve.sh git-revert.sh git-sh-setup.sh \
166         git-tag.sh git-verify-tag.sh \
167         git-applymbox.sh git-applypatch.sh git-am.sh \
168         git-merge.sh git-merge-stupid.sh git-merge-octopus.sh \
169         git-merge-resolve.sh git-merge-ours.sh \
170         git-lost-found.sh git-quiltimport.sh
172 SCRIPT_PERL = \
173         git-archimport.perl git-cvsimport.perl git-relink.perl \
174         git-cvsserver.perl \
175         git-svnimport.perl git-cvsexportcommit.perl \
176         git-send-email.perl git-svn.perl
178 SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \
179           $(patsubst %.perl,%,$(SCRIPT_PERL)) \
180           git-cherry-pick git-status git-instaweb
182 # ... and all the rest that could be moved out of bindir to gitexecdir
183 PROGRAMS = \
184         git-convert-objects$X git-fetch-pack$X git-fsck-objects$X \
185         git-hash-object$X git-index-pack$X git-local-fetch$X \
186         git-merge-base$X \
187         git-daemon$X \
188         git-merge-index$X git-mktag$X git-mktree$X git-patch-id$X \
189         git-peek-remote$X git-receive-pack$X \
190         git-send-pack$X git-shell$X \
191         git-show-index$X git-ssh-fetch$X \
192         git-ssh-upload$X git-unpack-file$X \
193         git-update-server-info$X \
194         git-upload-pack$X git-verify-pack$X \
195         git-pack-redundant$X git-var$X \
196         git-describe$X git-merge-tree$X git-imap-send$X \
197         git-merge-recursive$X \
198         $(EXTRA_PROGRAMS)
200 # Empty...
201 EXTRA_PROGRAMS =
203 BUILT_INS = \
204         git-format-patch$X git-show$X git-whatchanged$X git-cherry$X \
205         git-get-tar-commit-id$X \
206         $(patsubst builtin-%.o,git-%$X,$(BUILTIN_OBJS))
208 # what 'all' will build and 'install' will install, in gitexecdir
209 ALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS) \
210         git-merge-recur$X
212 # Backward compatibility -- to be removed after 1.0
213 PROGRAMS += git-ssh-pull$X git-ssh-push$X
215 # Set paths to tools early so that they can be used for version tests.
216 ifndef SHELL_PATH
217         SHELL_PATH = /bin/sh
218 endif
219 ifndef PERL_PATH
220         PERL_PATH = /usr/bin/perl
221 endif
223 export PERL_PATH
225 LIB_FILE=libgit.a
226 XDIFF_LIB=xdiff/lib.a
228 LIB_H = \
229         archive.h blob.h cache.h commit.h csum-file.h delta.h grep.h \
230         diff.h object.h pack.h pkt-line.h quote.h refs.h list-objects.h sideband.h \
231         run-command.h strbuf.h tag.h tree.h git-compat-util.h revision.h \
232         tree-walk.h log-tree.h dir.h path-list.h unpack-trees.h builtin.h \
233         utf8.h
235 DIFF_OBJS = \
236         diff.o diff-lib.o diffcore-break.o diffcore-order.o \
237         diffcore-pickaxe.o diffcore-rename.o tree-diff.o combine-diff.o \
238         diffcore-delta.o log-tree.o
240 LIB_OBJS = \
241         blob.o commit.o connect.o csum-file.o cache-tree.o base85.o \
242         date.o diff-delta.o entry.o exec_cmd.o ident.o \
243         interpolate.o \
244         lockfile.o \
245         object.o pack-check.o patch-delta.o path.o pkt-line.o sideband.o \
246         quote.o read-cache.o refs.o run-command.o dir.o object-refs.o \
247         server-info.o setup.o sha1_file.o sha1_name.o strbuf.o \
248         tag.o tree.o usage.o config.o environment.o ctype.o copy.o \
249         revision.o pager.o tree-walk.o xdiff-interface.o \
250         write_or_die.o trace.o list-objects.o grep.o \
251         alloc.o merge-file.o path-list.o help.o unpack-trees.o $(DIFF_OBJS) \
252         color.o wt-status.o archive-zip.o archive-tar.o \
253         utf8.o
255 BUILTIN_OBJS = \
256         builtin-add.o \
257         builtin-annotate.o \
258         builtin-apply.o \
259         builtin-archive.o \
260         builtin-blame.o \
261         builtin-branch.o \
262         builtin-cat-file.o \
263         builtin-checkout-index.o \
264         builtin-check-ref-format.o \
265         builtin-commit-tree.o \
266         builtin-count-objects.o \
267         builtin-diff.o \
268         builtin-diff-files.o \
269         builtin-diff-index.o \
270         builtin-diff-stages.o \
271         builtin-diff-tree.o \
272         builtin-fmt-merge-msg.o \
273         builtin-for-each-ref.o \
274         builtin-grep.o \
275         builtin-init-db.o \
276         builtin-log.o \
277         builtin-ls-files.o \
278         builtin-ls-tree.o \
279         builtin-mailinfo.o \
280         builtin-mailsplit.o \
281         builtin-merge-file.o \
282         builtin-mv.o \
283         builtin-name-rev.o \
284         builtin-pack-objects.o \
285         builtin-prune.o \
286         builtin-prune-packed.o \
287         builtin-push.o \
288         builtin-read-tree.o \
289         builtin-repo-config.o \
290         builtin-rerere.o \
291         builtin-rev-list.o \
292         builtin-rev-parse.o \
293         builtin-rm.o \
294         builtin-runstatus.o \
295         builtin-shortlog.o \
296         builtin-show-branch.o \
297         builtin-stripspace.o \
298         builtin-symbolic-ref.o \
299         builtin-tar-tree.o \
300         builtin-unpack-objects.o \
301         builtin-update-index.o \
302         builtin-update-ref.o \
303         builtin-upload-archive.o \
304         builtin-verify-pack.o \
305         builtin-write-tree.o \
306         builtin-show-ref.o \
307         builtin-pack-refs.o
309 GITLIBS = $(LIB_FILE) $(XDIFF_LIB)
310 EXTLIBS = -lz
313 # Platform specific tweaks
316 # We choose to avoid "if .. else if .. else .. endif endif"
317 # because maintaining the nesting to match is a pain.  If
318 # we had "elif" things would have been much nicer...
320 ifeq ($(uname_S),Linux)
321         NO_STRLCPY = YesPlease
322 endif
323 ifeq ($(uname_S),GNU/kFreeBSD)
324         NO_STRLCPY = YesPlease
325 endif
326 ifeq ($(uname_S),Darwin)
327         NEEDS_SSL_WITH_CRYPTO = YesPlease
328         NEEDS_LIBICONV = YesPlease
329         NO_STRLCPY = YesPlease
330 endif
331 ifeq ($(uname_S),SunOS)
332         NEEDS_SOCKET = YesPlease
333         NEEDS_NSL = YesPlease
334         SHELL_PATH = /bin/bash
335         NO_STRCASESTR = YesPlease
336         ifeq ($(uname_R),5.8)
337                 NEEDS_LIBICONV = YesPlease
338                 NO_UNSETENV = YesPlease
339                 NO_SETENV = YesPlease
340                 NO_C99_FORMAT = YesPlease
341         endif
342         ifeq ($(uname_R),5.9)
343                 NO_UNSETENV = YesPlease
344                 NO_SETENV = YesPlease
345                 NO_C99_FORMAT = YesPlease
346         endif
347         INSTALL = ginstall
348         TAR = gtar
349         BASIC_CFLAGS += -D__EXTENSIONS__
350 endif
351 ifeq ($(uname_O),Cygwin)
352         NO_D_TYPE_IN_DIRENT = YesPlease
353         NO_D_INO_IN_DIRENT = YesPlease
354         NO_STRCASESTR = YesPlease
355         NO_SYMLINK_HEAD = YesPlease
356         NEEDS_LIBICONV = YesPlease
357         NO_C99_FORMAT = YesPlease
358         NO_FAST_WORKING_DIRECTORY = UnfortunatelyYes
359         # There are conflicting reports about this.
360         # On some boxes NO_MMAP is needed, and not so elsewhere.
361         # Try uncommenting this if you see things break -- YMMV.
362         # NO_MMAP = YesPlease
363         NO_IPV6 = YesPlease
364         X = .exe
365 endif
366 ifeq ($(uname_S),FreeBSD)
367         NEEDS_LIBICONV = YesPlease
368         BASIC_CFLAGS += -I/usr/local/include
369         BASIC_LDFLAGS += -L/usr/local/lib
370 endif
371 ifeq ($(uname_S),OpenBSD)
372         NO_STRCASESTR = YesPlease
373         NEEDS_LIBICONV = YesPlease
374         BASIC_CFLAGS += -I/usr/local/include
375         BASIC_LDFLAGS += -L/usr/local/lib
376 endif
377 ifeq ($(uname_S),NetBSD)
378         ifeq ($(shell expr "$(uname_R)" : '[01]\.'),2)
379                 NEEDS_LIBICONV = YesPlease
380         endif
381         BASIC_CFLAGS += -I/usr/pkg/include
382         BASIC_LDFLAGS += -L/usr/pkg/lib
383         ALL_LDFLAGS += -Wl,-rpath,/usr/pkg/lib
384 endif
385 ifeq ($(uname_S),AIX)
386         NO_STRCASESTR=YesPlease
387         NO_STRLCPY = YesPlease
388         NEEDS_LIBICONV=YesPlease
389 endif
390 ifeq ($(uname_S),IRIX64)
391         NO_IPV6=YesPlease
392         NO_SETENV=YesPlease
393         NO_STRCASESTR=YesPlease
394         NO_STRLCPY = YesPlease
395         NO_SOCKADDR_STORAGE=YesPlease
396         SHELL_PATH=/usr/gnu/bin/bash
397         BASIC_CFLAGS += -DPATH_MAX=1024
398         # for now, build 32-bit version
399         BASIC_LDFLAGS += -L/usr/lib32
400 endif
401 ifneq (,$(findstring arm,$(uname_M)))
402         ARM_SHA1 = YesPlease
403 endif
405 -include config.mak.autogen
406 -include config.mak
408 ifeq ($(uname_S),Darwin)
409         ifndef NO_FINK
410                 ifeq ($(shell test -d /sw/lib && echo y),y)
411                         BASIC_CFLAGS += -I/sw/include
412                         BASIC_LDFLAGS += -L/sw/lib
413                 endif
414         endif
415         ifndef NO_DARWIN_PORTS
416                 ifeq ($(shell test -d /opt/local/lib && echo y),y)
417                         BASIC_CFLAGS += -I/opt/local/include
418                         BASIC_LDFLAGS += -L/opt/local/lib
419                 endif
420         endif
421 endif
423 ifndef NO_CURL
424         ifdef CURLDIR
425                 # This is still problematic -- gcc does not always want -R.
426                 BASIC_CFLAGS += -I$(CURLDIR)/include
427                 CURL_LIBCURL = -L$(CURLDIR)/lib -R$(CURLDIR)/lib -lcurl
428         else
429                 CURL_LIBCURL = -lcurl
430         endif
431         PROGRAMS += git-http-fetch$X
432         curl_check := $(shell (echo 070908; curl-config --vernum) | sort -r | sed -ne 2p)
433         ifeq "$(curl_check)" "070908"
434                 ifndef NO_EXPAT
435                         PROGRAMS += git-http-push$X
436                 endif
437         endif
438         ifndef NO_EXPAT
439                 EXPAT_LIBEXPAT = -lexpat
440         endif
441 endif
443 ifndef NO_OPENSSL
444         OPENSSL_LIBSSL = -lssl
445         ifdef OPENSSLDIR
446                 # Again this may be problematic -- gcc does not always want -R.
447                 BASIC_CFLAGS += -I$(OPENSSLDIR)/include
448                 OPENSSL_LINK = -L$(OPENSSLDIR)/lib -R$(OPENSSLDIR)/lib
449         else
450                 OPENSSL_LINK =
451         endif
452 else
453         BASIC_CFLAGS += -DNO_OPENSSL
454         MOZILLA_SHA1 = 1
455         OPENSSL_LIBSSL =
456 endif
457 ifdef NEEDS_SSL_WITH_CRYPTO
458         LIB_4_CRYPTO = $(OPENSSL_LINK) -lcrypto -lssl
459 else
460         LIB_4_CRYPTO = $(OPENSSL_LINK) -lcrypto
461 endif
462 ifdef NEEDS_LIBICONV
463         ifdef ICONVDIR
464                 # Again this may be problematic -- gcc does not always want -R.
465                 BASIC_CFLAGS += -I$(ICONVDIR)/include
466                 ICONV_LINK = -L$(ICONVDIR)/lib -R$(ICONVDIR)/lib
467         else
468                 ICONV_LINK =
469         endif
470         EXTLIBS += $(ICONV_LINK) -liconv
471 endif
472 ifdef NEEDS_SOCKET
473         EXTLIBS += -lsocket
474 endif
475 ifdef NEEDS_NSL
476         EXTLIBS += -lnsl
477 endif
478 ifdef NO_D_TYPE_IN_DIRENT
479         BASIC_CFLAGS += -DNO_D_TYPE_IN_DIRENT
480 endif
481 ifdef NO_D_INO_IN_DIRENT
482         BASIC_CFLAGS += -DNO_D_INO_IN_DIRENT
483 endif
484 ifdef NO_C99_FORMAT
485         ALL_CFLAGS += -DNO_C99_FORMAT
486 endif
487 ifdef NO_SYMLINK_HEAD
488         BASIC_CFLAGS += -DNO_SYMLINK_HEAD
489 endif
490 ifdef NO_STRCASESTR
491         COMPAT_CFLAGS += -DNO_STRCASESTR
492         COMPAT_OBJS += compat/strcasestr.o
493 endif
494 ifdef NO_STRLCPY
495         COMPAT_CFLAGS += -DNO_STRLCPY
496         COMPAT_OBJS += compat/strlcpy.o
497 endif
498 ifdef NO_SETENV
499         COMPAT_CFLAGS += -DNO_SETENV
500         COMPAT_OBJS += compat/setenv.o
501 endif
502 ifdef NO_UNSETENV
503         COMPAT_CFLAGS += -DNO_UNSETENV
504         COMPAT_OBJS += compat/unsetenv.o
505 endif
506 ifdef NO_MMAP
507         COMPAT_CFLAGS += -DNO_MMAP
508         COMPAT_OBJS += compat/mmap.o
509 endif
510 ifdef NO_FAST_WORKING_DIRECTORY
511         BASIC_CFLAGS += -DNO_FAST_WORKING_DIRECTORY
512 endif
513 ifdef NO_IPV6
514         BASIC_CFLAGS += -DNO_IPV6
515 endif
516 ifdef NO_SOCKADDR_STORAGE
517 ifdef NO_IPV6
518         BASIC_CFLAGS += -Dsockaddr_storage=sockaddr_in
519 else
520         BASIC_CFLAGS += -Dsockaddr_storage=sockaddr_in6
521 endif
522 endif
523 ifdef NO_INET_NTOP
524         LIB_OBJS += compat/inet_ntop.o
525 endif
526 ifdef NO_INET_PTON
527         LIB_OBJS += compat/inet_pton.o
528 endif
530 ifdef NO_ICONV
531         BASIC_CFLAGS += -DNO_ICONV
532 endif
534 ifdef PPC_SHA1
535         SHA1_HEADER = "ppc/sha1.h"
536         LIB_OBJS += ppc/sha1.o ppc/sha1ppc.o
537 else
538 ifdef ARM_SHA1
539         SHA1_HEADER = "arm/sha1.h"
540         LIB_OBJS += arm/sha1.o arm/sha1_arm.o
541 else
542 ifdef MOZILLA_SHA1
543         SHA1_HEADER = "mozilla-sha1/sha1.h"
544         LIB_OBJS += mozilla-sha1/sha1.o
545 else
546         SHA1_HEADER = <openssl/sha.h>
547         EXTLIBS += $(LIB_4_CRYPTO)
548 endif
549 endif
550 endif
551 ifdef NO_PERL_MAKEMAKER
552         export NO_PERL_MAKEMAKER
553 endif
555 # Shell quote (do not use $(call) to accommodate ancient setups);
557 SHA1_HEADER_SQ = $(subst ','\'',$(SHA1_HEADER))
559 DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
560 bindir_SQ = $(subst ','\'',$(bindir))
561 gitexecdir_SQ = $(subst ','\'',$(gitexecdir))
562 template_dir_SQ = $(subst ','\'',$(template_dir))
563 prefix_SQ = $(subst ','\'',$(prefix))
565 SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
566 PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
568 LIBS = $(GITLIBS) $(EXTLIBS)
570 BASIC_CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER_SQ)' $(COMPAT_CFLAGS)
571 LIB_OBJS += $(COMPAT_OBJS)
573 ALL_CFLAGS += $(BASIC_CFLAGS)
574 ALL_LDFLAGS += $(BASIC_LDFLAGS)
576 export prefix TAR INSTALL DESTDIR SHELL_PATH template_dir
579 ### Build rules
581 all: $(ALL_PROGRAMS) $(BUILT_INS) git$X gitk gitweb/gitweb.cgi
583 all:
584         $(MAKE) -C perl PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' all
585         $(MAKE) -C templates
587 strip: $(PROGRAMS) git$X
588         $(STRIP) $(STRIP_OPTS) $(PROGRAMS) git$X
590 git$X: git.c common-cmds.h $(BUILTIN_OBJS) $(GITLIBS) GIT-CFLAGS
591         $(CC) -DGIT_VERSION='"$(GIT_VERSION)"' \
592                 $(ALL_CFLAGS) -o $@ $(filter %.c,$^) \
593                 $(BUILTIN_OBJS) $(ALL_LDFLAGS) $(LIBS)
595 help.o: common-cmds.h
597 git-merge-recur$X: git-merge-recursive$X
598         rm -f $@ && ln git-merge-recursive$X $@
600 $(BUILT_INS): git$X
601         rm -f $@ && ln git$X $@
603 common-cmds.h: Documentation/git-*.txt
604         ./generate-cmdlist.sh > $@+
605         mv $@+ $@
607 $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
608         rm -f $@ $@+
609         sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
610             -e 's|@@PERL@@|$(PERL_PATH_SQ)|g' \
611             -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
612             -e 's/@@NO_CURL@@/$(NO_CURL)/g' \
613             $@.sh >$@+
614         chmod +x $@+
615         mv $@+ $@
617 $(patsubst %.perl,%,$(SCRIPT_PERL)): perl/perl.mak
619 perl/perl.mak: GIT-CFLAGS
620         $(MAKE) -C perl PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' $(@F)
622 $(patsubst %.perl,%,$(SCRIPT_PERL)): % : %.perl
623         rm -f $@ $@+
624         INSTLIBDIR=`$(MAKE) -C perl -s --no-print-directory instlibdir` && \
625         sed -e '1{' \
626             -e '        s|#!.*perl|#!$(PERL_PATH_SQ)|' \
627             -e '        h' \
628             -e '        s=.*=use lib (split(/:/, $$ENV{GITPERLLIB} || "@@INSTLIBDIR@@"));=' \
629             -e '        H' \
630             -e '        x' \
631             -e '}' \
632             -e 's|@@INSTLIBDIR@@|'"$$INSTLIBDIR"'|g' \
633             -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
634             $@.perl >$@+
635         chmod +x $@+
636         mv $@+ $@
638 git-cherry-pick: git-revert
639         cp $< $@+
640         mv $@+ $@
642 git-status: git-commit
643         cp $< $@+
644         mv $@+ $@
646 gitweb/gitweb.cgi: gitweb/gitweb.perl
647         rm -f $@ $@+
648         sed -e '1s|#!.*perl|#!$(PERL_PATH_SQ)|' \
649             -e 's|++GIT_VERSION++|$(GIT_VERSION)|g' \
650             -e 's|++GIT_BINDIR++|$(bindir)|g' \
651             -e 's|++GITWEB_CONFIG++|$(GITWEB_CONFIG)|g' \
652             -e 's|++GITWEB_HOME_LINK_STR++|$(GITWEB_HOME_LINK_STR)|g' \
653             -e 's|++GITWEB_SITENAME++|$(GITWEB_SITENAME)|g' \
654             -e 's|++GITWEB_PROJECTROOT++|$(GITWEB_PROJECTROOT)|g' \
655             -e 's|++GITWEB_EXPORT_OK++|$(GITWEB_EXPORT_OK)|g' \
656             -e 's|++GITWEB_STRICT_EXPORT++|$(GITWEB_STRICT_EXPORT)|g' \
657             -e 's|++GITWEB_BASE_URL++|$(GITWEB_BASE_URL)|g' \
658             -e 's|++GITWEB_LIST++|$(GITWEB_LIST)|g' \
659             -e 's|++GITWEB_HOMETEXT++|$(GITWEB_HOMETEXT)|g' \
660             -e 's|++GITWEB_CSS++|$(GITWEB_CSS)|g' \
661             -e 's|++GITWEB_LOGO++|$(GITWEB_LOGO)|g' \
662             -e 's|++GITWEB_FAVICON++|$(GITWEB_FAVICON)|g' \
663             -e 's|++GITWEB_SITE_HEADER++|$(GITWEB_SITE_HEADER)|g' \
664             -e 's|++GITWEB_SITE_FOOTER++|$(GITWEB_SITE_FOOTER)|g' \
665             $< >$@+
666         chmod +x $@+
667         mv $@+ $@
669 git-instaweb: git-instaweb.sh gitweb/gitweb.cgi gitweb/gitweb.css
670         rm -f $@ $@+
671         sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
672             -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
673             -e 's/@@NO_CURL@@/$(NO_CURL)/g' \
674             -e '/@@GITWEB_CGI@@/r gitweb/gitweb.cgi' \
675             -e '/@@GITWEB_CGI@@/d' \
676             -e '/@@GITWEB_CSS@@/r gitweb/gitweb.css' \
677             -e '/@@GITWEB_CSS@@/d' \
678             $@.sh > $@+
679         chmod +x $@+
680         mv $@+ $@
682 configure: configure.ac
683         rm -f $@ $<+
684         sed -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
685             $< > $<+
686         autoconf -o $@ $<+
687         rm -f $<+
689 # These can record GIT_VERSION
690 git$X git.spec \
691         $(patsubst %.sh,%,$(SCRIPT_SH)) \
692         $(patsubst %.perl,%,$(SCRIPT_PERL)) \
693         : GIT-VERSION-FILE
695 %.o: %.c GIT-CFLAGS
696         $(CC) -o $*.o -c $(ALL_CFLAGS) $<
697 %.o: %.S
698         $(CC) -o $*.o -c $(ALL_CFLAGS) $<
700 exec_cmd.o: exec_cmd.c GIT-CFLAGS
701         $(CC) -o $*.o -c $(ALL_CFLAGS) '-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' $<
702 builtin-init-db.o: builtin-init-db.c GIT-CFLAGS
703         $(CC) -o $*.o -c $(ALL_CFLAGS) -DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir_SQ)"' $<
705 http.o: http.c GIT-CFLAGS
706         $(CC) -o $*.o -c $(ALL_CFLAGS) -DGIT_USER_AGENT='"git/$(GIT_VERSION)"' $<
708 ifdef NO_EXPAT
709 http-fetch.o: http-fetch.c http.h GIT-CFLAGS
710         $(CC) -o $*.o -c $(ALL_CFLAGS) -DNO_EXPAT $<
711 endif
713 git-%$X: %.o $(GITLIBS)
714         $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
716 ssh-pull.o: ssh-fetch.c
717 ssh-push.o: ssh-upload.c
718 git-local-fetch$X: fetch.o
719 git-ssh-fetch$X: rsh.o fetch.o
720 git-ssh-upload$X: rsh.o
721 git-ssh-pull$X: rsh.o fetch.o
722 git-ssh-push$X: rsh.o
724 git-imap-send$X: imap-send.o $(LIB_FILE)
726 http.o http-fetch.o http-push.o: http.h
727 git-http-fetch$X: fetch.o http.o http-fetch.o $(GITLIBS)
728         $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
729                 $(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
731 git-http-push$X: revision.o http.o http-push.o $(GITLIBS)
732         $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
733                 $(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
735 $(LIB_OBJS) $(BUILTIN_OBJS): $(LIB_H)
736 $(patsubst git-%$X,%.o,$(PROGRAMS)): $(LIB_H) $(wildcard */*.h)
737 $(DIFF_OBJS): diffcore.h
739 $(LIB_FILE): $(LIB_OBJS)
740         rm -f $@ && $(AR) rcs $@ $(LIB_OBJS)
742 XDIFF_OBJS=xdiff/xdiffi.o xdiff/xprepare.o xdiff/xutils.o xdiff/xemit.o \
743         xdiff/xmerge.o
744 $(XDIFF_OBJS): xdiff/xinclude.h xdiff/xmacros.h xdiff/xdiff.h xdiff/xtypes.h \
745         xdiff/xutils.h xdiff/xprepare.h xdiff/xdiffi.h xdiff/xemit.h
747 $(XDIFF_LIB): $(XDIFF_OBJS)
748         rm -f $@ && $(AR) rcs $@ $(XDIFF_OBJS)
751 perl/Makefile: perl/Git.pm perl/Makefile.PL GIT-CFLAGS
752         (cd perl && $(PERL_PATH) Makefile.PL \
753                 PREFIX='$(prefix_SQ)')
755 doc:
756         $(MAKE) -C Documentation all
758 TAGS:
759         rm -f TAGS
760         find . -name '*.[hcS]' -print | xargs etags -a
762 tags:
763         rm -f tags
764         find . -name '*.[hcS]' -print | xargs ctags -a
766 ### Detect prefix changes
767 TRACK_CFLAGS = $(subst ','\'',$(ALL_CFLAGS)):\
768              $(bindir_SQ):$(gitexecdir_SQ):$(template_dir_SQ):$(prefix_SQ)
770 GIT-CFLAGS: .FORCE-GIT-CFLAGS
771         @FLAGS='$(TRACK_CFLAGS)'; \
772             if test x"$$FLAGS" != x"`cat GIT-CFLAGS 2>/dev/null`" ; then \
773                 echo 1>&2 "    * new build flags or prefix"; \
774                 echo "$$FLAGS" >GIT-CFLAGS; \
775             fi
777 ### Testing rules
779 # GNU make supports exporting all variables by "export" without parameters.
780 # However, the environment gets quite big, and some programs have problems
781 # with that.
783 export NO_SVN_TESTS
785 test: all
786         $(MAKE) -C t/ all
788 test-date$X: test-date.c date.o ctype.o
789         $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) test-date.c date.o ctype.o
791 test-delta$X: test-delta.o diff-delta.o patch-delta.o $(GITLIBS)
792         $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
794 test-dump-cache-tree$X: dump-cache-tree.o $(GITLIBS)
795         $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
797 test-sha1$X: test-sha1.o $(GITLIBS)
798         $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
800 check-sha1:: test-sha1$X
801         ./test-sha1.sh
803 check:
804         for i in *.c; do sparse $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i || exit; done
808 ### Installation rules
810 install: all
811         $(INSTALL) -d -m755 '$(DESTDIR_SQ)$(bindir_SQ)'
812         $(INSTALL) -d -m755 '$(DESTDIR_SQ)$(gitexecdir_SQ)'
813         $(INSTALL) $(ALL_PROGRAMS) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
814         $(INSTALL) git$X gitk '$(DESTDIR_SQ)$(bindir_SQ)'
815         $(MAKE) -C templates DESTDIR='$(DESTDIR_SQ)' install
816         $(MAKE) -C perl prefix='$(prefix_SQ)' install
817         if test 'z$(bindir_SQ)' != 'z$(gitexecdir_SQ)'; \
818         then \
819                 ln -f '$(DESTDIR_SQ)$(bindir_SQ)/git$X' \
820                         '$(DESTDIR_SQ)$(gitexecdir_SQ)/git$X' || \
821                 cp '$(DESTDIR_SQ)$(bindir_SQ)/git$X' \
822                         '$(DESTDIR_SQ)$(gitexecdir_SQ)/git$X'; \
823         fi
824         $(foreach p,$(BUILT_INS), rm -f '$(DESTDIR_SQ)$(gitexecdir_SQ)/$p' && ln '$(DESTDIR_SQ)$(gitexecdir_SQ)/git$X' '$(DESTDIR_SQ)$(gitexecdir_SQ)/$p' ;)
826 install-doc:
827         $(MAKE) -C Documentation install
829 quick-install-doc:
830         $(MAKE) -C Documentation quick-install
834 ### Maintainer's dist rules
836 git.spec: git.spec.in
837         sed -e 's/@@VERSION@@/$(GIT_VERSION)/g' < $< > $@+
838         mv $@+ $@
840 GIT_TARNAME=git-$(GIT_VERSION)
841 dist: git.spec git-archive
842         ./git-archive --format=tar \
843                 --prefix=$(GIT_TARNAME)/ HEAD^{tree} > $(GIT_TARNAME).tar
844         @mkdir -p $(GIT_TARNAME)
845         @cp git.spec $(GIT_TARNAME)
846         @echo $(GIT_VERSION) > $(GIT_TARNAME)/version
847         $(TAR) rf $(GIT_TARNAME).tar \
848                 $(GIT_TARNAME)/git.spec $(GIT_TARNAME)/version
849         @rm -rf $(GIT_TARNAME)
850         gzip -f -9 $(GIT_TARNAME).tar
852 rpm: dist
853         $(RPMBUILD) -ta $(GIT_TARNAME).tar.gz
855 htmldocs = git-htmldocs-$(GIT_VERSION)
856 manpages = git-manpages-$(GIT_VERSION)
857 dist-doc:
858         rm -fr .doc-tmp-dir
859         mkdir .doc-tmp-dir
860         $(MAKE) -C Documentation WEBDOC_DEST=../.doc-tmp-dir install-webdoc
861         cd .doc-tmp-dir && $(TAR) cf ../$(htmldocs).tar .
862         gzip -n -9 -f $(htmldocs).tar
863         :
864         rm -fr .doc-tmp-dir
865         mkdir .doc-tmp-dir .doc-tmp-dir/man1 .doc-tmp-dir/man7
866         $(MAKE) -C Documentation DESTDIR=./ \
867                 man1dir=../.doc-tmp-dir/man1 \
868                 man7dir=../.doc-tmp-dir/man7 \
869                 install
870         cd .doc-tmp-dir && $(TAR) cf ../$(manpages).tar .
871         gzip -n -9 -f $(manpages).tar
872         rm -fr .doc-tmp-dir
874 ### Cleaning rules
876 clean:
877         rm -f *.o mozilla-sha1/*.o arm/*.o ppc/*.o compat/*.o xdiff/*.o \
878                 $(LIB_FILE) $(XDIFF_LIB)
879         rm -f $(ALL_PROGRAMS) $(BUILT_INS) git$X
880         rm -f *.spec *.pyc *.pyo */*.pyc */*.pyo common-cmds.h TAGS tags
881         rm -rf autom4te.cache
882         rm -f configure config.log config.mak.autogen config.mak.append config.status config.cache
883         rm -rf $(GIT_TARNAME) .doc-tmp-dir
884         rm -f $(GIT_TARNAME).tar.gz git-core_$(GIT_VERSION)-*.tar.gz
885         rm -f $(htmldocs).tar.gz $(manpages).tar.gz
886         rm -f gitweb/gitweb.cgi
887         $(MAKE) -C Documentation/ clean
888         $(MAKE) -C perl clean
889         $(MAKE) -C templates/ clean
890         $(MAKE) -C t/ clean
891         rm -f GIT-VERSION-FILE GIT-CFLAGS
893 .PHONY: all install clean strip
894 .PHONY: .FORCE-GIT-VERSION-FILE TAGS tags .FORCE-GIT-CFLAGS
896 ### Check documentation
898 check-docs::
899         @for v in $(ALL_PROGRAMS) $(BUILT_INS) git$X gitk; \
900         do \
901                 case "$$v" in \
902                 git-merge-octopus | git-merge-ours | git-merge-recursive | \
903                 git-merge-resolve | git-merge-stupid | git-merge-recur | \
904                 git-ssh-pull | git-ssh-push ) continue ;; \
905                 esac ; \
906                 test -f "Documentation/$$v.txt" || \
907                 echo "no doc: $$v"; \
908                 grep -q "^gitlink:$$v\[[0-9]\]::" Documentation/git.txt || \
909                 case "$$v" in \
910                 git) ;; \
911                 *) echo "no link: $$v";; \
912                 esac ; \
913         done | sort
915 ### Make sure built-ins do not have dups and listed in git.c
917 check-builtins::
918         ./check-builtins.sh