blob: 3e085dfa6fbabf1bcf758b795f32ea50a40880c2 [file] [log] [blame]
Junio C Hamano2731d042005-12-01 12:26:41 -08001# The default target of this Makefile is...
2all:
3
Petr Baudis5bdac8b2005-07-29 17:48:26 +02004# Define MOZILLA_SHA1 environment variable when running make to make use of
5# a bundled SHA1 routine coming from Mozilla. It is GPL'd and should be fast
6# on non-x86 architectures (e.g. PowerPC), while the OpenSSL version (default
7# choice) has very fast version optimized for i586.
8#
Linus Torvalds765ac8e2006-02-28 15:07:20 -08009# Define NO_OPENSSL environment variable if you do not have OpenSSL.
10# This also implies MOZILLA_SHA1.
Petr Baudis5bdac8b2005-07-29 17:48:26 +020011#
Nick Hengeveld58e60dd2005-11-02 11:19:24 -080012# Define NO_CURL if you do not have curl installed. git-http-pull and
13# git-http-push are not built, and you cannot use http:// and https://
14# transports.
Johannes Schindelinb2c0bd62005-07-31 02:14:23 +020015#
Patrick Mauritz6d9bbc52005-09-19 16:11:19 +020016# Define CURLDIR=/foo/bar if your curl header and library files are in
17# /foo/bar/include and /foo/bar/lib directories.
18#
Nick Hengeveld58e60dd2005-11-02 11:19:24 -080019# Define NO_EXPAT if you do not have expat installed. git-http-push is
20# not built, and you cannot push using http:// and https:// transports.
21#
Junio C Hamano35a730f2006-01-19 17:13:51 -080022# Define NO_D_INO_IN_DIRENT if you don't have d_ino in your struct dirent.
23#
Junio C Hamano63be37b2006-01-19 17:13:57 -080024# Define NO_D_TYPE_IN_DIRENT if your platform defines DT_UNKNOWN but lacks
25# d_type in struct dirent (latest Cygwin -- will be fixed soonish).
26#
Linus Torvaldsef34af22005-09-18 18:30:50 -070027# Define NO_STRCASESTR if you don't have strcasestr.
28#
Peter Eriksen817151e2006-06-24 16:01:25 +020029# Define NO_STRLCPY if you don't have strlcpy.
30#
Jason Riedye40b61f2005-12-02 15:08:28 -080031# Define NO_SETENV if you don't have setenv in the C library.
32#
Junio C Hamano9f0bb902006-05-02 00:40:24 -070033# 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.
Pavel Roskin2fabd212005-11-15 00:59:50 -050035#
Pavel Roskin02853582006-07-09 02:44:58 -070036# Define NO_SVN_TESTS if you want to skip time-consuming SVN interoperability
Eric Wong60d02cc2006-07-06 00:14:16 -070037# 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#
Shawn Pearce8eb38ca2006-07-24 00:28:28 -040040# 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#
Petr Baudis5bdac8b2005-07-29 17:48:26 +020052# Define PPC_SHA1 environment variable when running make to make use of
53# a bundled SHA1 routine optimized for PowerPC.
Junio C Hamano597c9cc2005-09-07 12:22:56 -070054#
Nicolas Pitre7c6ef2f2005-09-20 12:27:13 -040055# Define ARM_SHA1 environment variable when running make to make use of
56# a bundled SHA1 routine optimized for ARM.
57#
Junio C Hamano597c9cc2005-09-07 12:22:56 -070058# Define NEEDS_SSL_WITH_CRYPTO if you need -lcrypto with -lssl (Darwin).
Patrick Mauritzf0ebff02005-09-06 01:24:03 +020059#
Junio C Hamano597c9cc2005-09-07 12:22:56 -070060# Define NEEDS_LIBICONV if linking with libc is not enough (Darwin).
Patrick Mauritzf0ebff02005-09-06 01:24:03 +020061#
62# Define NEEDS_SOCKET if linking with libc is not enough (SunOS,
63# Patrick Mauritz).
64#
Johannes Schindelin730d48a2005-10-08 15:54:36 -070065# Define NO_MMAP if you want to avoid mmap.
66#
Junio C Hamano343d35c2005-09-19 19:47:54 -070067# Define WITH_OWN_SUBPROCESS_PY if you want to use with python 2.3.
68#
hpa49744d62005-09-28 16:52:21 -070069# Define NO_IPV6 if you lack IPv6 support and getaddrinfo().
70#
Junio C Hamanobdc37f52006-01-19 17:13:32 -080071# Define NO_SOCKADDR_STORAGE if your platform does not have struct
72# sockaddr_storage.
73#
Fernando J. Peredab6e56ec2006-02-16 09:38:01 +010074# Define NO_ICONV if your libc does not properly support iconv.
75#
Johannes Schindelin5b5d4d92006-02-17 15:23:16 +010076# Define NO_ACCURATE_DIFF if your diff program at least sometimes misses
77# a missing newline at the end of the file.
78#
Pavel Roskinaddf88e2006-07-09 03:44:30 -040079# Define NO_PYTHON if you want to lose all benefits of the recursive merge.
Johannes Schindelinabb7c7b2006-02-18 13:01:18 +010080#
Petr Baudis5bdac8b2005-07-29 17:48:26 +020081# Define COLLISION_CHECK below if you believe that SHA1's
Petr Baudis5c2a7fb2005-04-13 02:14:06 -070082# 1461501637330902918203684832716283019655932542976 hashes do not give you
Petr Baudis5bdac8b2005-07-29 17:48:26 +020083# sufficient guarantee that no collisions between objects will ever happen.
84
Petr Baudis5bdac8b2005-07-29 17:48:26 +020085# Define USE_NSEC below if you want git to care about sub-second file mtimes
86# and ctimes. Note that you need recent glibc (at least 2.2.4) for this, and
87# it will BREAK YOUR LOCAL DIFFS! show-diff and anything using it will likely
88# randomly break unless your underlying filesystem supports those sub-second
89# times (my ext3 doesn't).
90
Petr Baudis5bdac8b2005-07-29 17:48:26 +020091# Define USE_STDEV below if you want git to care about the underlying device
92# change being considered an inode change from the update-cache perspective.
93
Junio C Hamano9b88fce2005-12-27 14:40:17 -080094GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
Fredrik Kuivinen36546382006-02-14 00:15:14 +010095 @$(SHELL_PATH) ./GIT-VERSION-GEN
Junio C Hamano9b88fce2005-12-27 14:40:17 -080096-include GIT-VERSION-FILE
Petr Baudis5bdac8b2005-07-29 17:48:26 +020097
Paul Jakmae15f5452006-02-20 23:36:28 +000098uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
99uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not')
100uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')
101uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not')
102uname_P := $(shell sh -c 'uname -p 2>/dev/null || echo not')
103
Junio C Hamano94d23312005-11-13 01:46:13 -0800104# CFLAGS and LDFLAGS are for the users to override from the command line.
Junio C Hamano12aa7452005-11-04 23:50:09 -0800105
Pavel Roskinb05701c2005-08-06 01:36:15 -0400106CFLAGS = -g -O2 -Wall
Junio C Hamano94d23312005-11-13 01:46:13 -0800107LDFLAGS =
Junio C Hamano12aa7452005-11-04 23:50:09 -0800108ALL_CFLAGS = $(CFLAGS)
Junio C Hamano94d23312005-11-13 01:46:13 -0800109ALL_LDFLAGS = $(LDFLAGS)
Junio C Hamano4dc00022006-01-12 21:42:25 -0800110STRIP ?= strip
Thomas Glanzmann29c2cce2005-05-07 10:41:54 +0200111
Pavel Roskinb05701c2005-08-06 01:36:15 -0400112prefix = $(HOME)
113bindir = $(prefix)/bin
Paul Jakmae15f5452006-02-20 23:36:28 +0000114gitexecdir = $(bindir)
Pavel Roskinb05701c2005-08-06 01:36:15 -0400115template_dir = $(prefix)/share/git-core/templates/
Junio C Hamano720d1502005-09-10 17:46:27 -0700116GIT_PYTHON_DIR = $(prefix)/share/git-core/python
Petr Baudisa682ef92005-08-05 01:56:38 +0200117# DESTDIR=
Petr Baudis5c2a7fb2005-04-13 02:14:06 -0700118
Pavel Roskinb05701c2005-08-06 01:36:15 -0400119CC = gcc
120AR = ar
Junio C Hamano229a7ed2005-09-23 10:41:40 -0700121TAR = tar
Pavel Roskinb05701c2005-08-06 01:36:15 -0400122INSTALL = install
123RPMBUILD = rpmbuild
Linus Torvaldse83c5162005-04-07 15:13:13 -0700124
Linus Torvalds44c9e852005-07-03 10:02:35 -0700125# sparse is architecture-neutral, which means that we need to tell it
126# explicitly what architecture to check for. Fix this up for yours..
Pavel Roskinb05701c2005-08-06 01:36:15 -0400127SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
Linus Torvalds44c9e852005-07-03 10:02:35 -0700128
Petr Baudis28818ff2005-07-29 17:50:24 +0200129
130
131### --- END CONFIGURATION SECTION ---
132
Junio C Hamano215a7ad2005-09-07 17:26:23 -0700133SCRIPT_SH = \
Linus Torvaldsc699f9b2006-05-17 21:21:04 -0700134 git-bisect.sh git-branch.sh git-checkout.sh \
Pavel Roskinc3b831b2006-04-05 02:00:48 -0400135 git-cherry.sh git-clean.sh git-clone.sh git-commit.sh \
Junio C Hamano230f5442006-05-03 23:54:34 -0700136 git-fetch.sh \
Junio C Hamano68563732006-05-21 02:48:21 -0700137 git-ls-remote.sh \
Junio C Hamanoe32faa82005-12-19 18:03:31 -0800138 git-merge-one-file.sh git-parse-remote.sh \
Linus Torvaldsba84a792006-07-06 10:16:22 -0700139 git-pull.sh git-rebase.sh \
Junio C Hamano215a7ad2005-09-07 17:26:23 -0700140 git-repack.sh git-request-pull.sh git-reset.sh \
Linus Torvaldsd9b814c2006-05-19 16:19:34 -0700141 git-resolve.sh git-revert.sh git-sh-setup.sh \
Junio C Hamano7b763f72006-05-01 23:14:58 -0700142 git-tag.sh git-verify-tag.sh \
Junio C Hamanod1c5f2a2005-10-07 03:44:18 -0700143 git-applymbox.sh git-applypatch.sh git-am.sh \
Junio C Hamano2276aa62005-09-10 17:56:19 -0700144 git-merge.sh git-merge-stupid.sh git-merge-octopus.sh \
Linus Torvalds63dffdf2006-05-16 16:46:31 -0700145 git-merge-resolve.sh git-merge-ours.sh \
Eric W. Biedermand3d8f362006-05-17 12:44:40 -0600146 git-lost-found.sh git-quiltimport.sh
Petr Baudis28818ff2005-07-29 17:50:24 +0200147
Junio C Hamano215a7ad2005-09-07 17:26:23 -0700148SCRIPT_PERL = \
149 git-archimport.perl git-cvsimport.perl git-relink.perl \
Johannes Schindelin00449f92006-07-03 17:18:43 +0200150 git-shortlog.perl git-rerere.perl \
Junio C Hamano98214e92006-02-22 19:20:55 -0800151 git-annotate.perl git-cvsserver.perl \
Eric Wong15739c82006-05-14 19:26:56 -0700152 git-svnimport.perl git-mv.perl git-cvsexportcommit.perl \
Eric Wong60d02cc2006-07-06 00:14:16 -0700153 git-send-email.perl git-svn.perl
Junio C Hamano60036a42005-07-30 17:31:47 -0700154
Junio C Hamano720d1502005-09-10 17:46:27 -0700155SCRIPT_PYTHON = \
Fredrik Kuivinene4cf17c2005-09-13 08:22:26 +0200156 git-merge-recursive.py
Junio C Hamano720d1502005-09-10 17:46:27 -0700157
Andreas Ericssond6ebd252005-11-22 00:44:15 +0100158SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \
159 $(patsubst %.perl,%,$(SCRIPT_PERL)) \
160 $(patsubst %.py,%,$(SCRIPT_PYTHON)) \
Eric Wonga51d37c2006-07-01 15:14:14 -0700161 git-cherry-pick git-status git-instaweb
Andreas Ericssond6ebd252005-11-22 00:44:15 +0100162
Junio C Hamano8eef8e02006-03-31 16:23:46 -0800163# The ones that do not have to link with lcrypto, lz nor xdiff.
Junio C Hamano597c9cc2005-09-07 12:22:56 -0700164SIMPLE_PROGRAMS = \
Lukas Sandström7499c992006-06-13 22:21:53 +0200165 git-daemon$X
Junio C Hamano597c9cc2005-09-07 12:22:56 -0700166
Junio C Hamanob42934d2006-01-12 21:37:17 -0800167# ... and all the rest that could be moved out of bindir to gitexecdir
Junio C Hamano215a7ad2005-09-07 17:26:23 -0700168PROGRAMS = \
Junio C Hamanoefc7fa52006-06-20 23:54:26 -0700169 git-checkout-index$X \
Peter Eriksene8cc9cd2006-05-23 14:15:36 +0200170 git-convert-objects$X git-fetch-pack$X git-fsck-objects$X \
Timo Hirvonenc3c88352006-05-19 13:03:57 +0300171 git-hash-object$X git-index-pack$X git-local-fetch$X \
Lukas Sandström34488e32006-06-13 22:21:50 +0200172 git-merge-base$X \
Junio C Hamano83f50532006-02-20 21:50:01 -0800173 git-merge-index$X git-mktag$X git-mktree$X git-pack-objects$X git-patch-id$X \
Christian Couder895f10c2006-06-03 18:45:43 +0200174 git-peek-remote$X git-prune-packed$X git-receive-pack$X \
Peter Eriksen51ce34b2006-05-23 14:15:35 +0200175 git-send-pack$X git-shell$X \
Peter Anvin79a9d8e2005-10-03 12:04:44 -0700176 git-show-index$X git-ssh-fetch$X \
Peter Eriksen56d13982006-05-23 14:15:31 +0200177 git-ssh-upload$X git-unpack-file$X \
Lukas Sandströmfefe81c2006-06-13 22:21:57 +0200178 git-unpack-objects$X git-update-server-info$X \
Lukas Sandström8ed05fb2006-06-13 22:21:42 +0200179 git-upload-pack$X git-verify-pack$X \
Lukas Sandström854b4622006-06-13 22:22:00 +0200180 git-symbolic-ref$X \
Linus Torvalds908e5312005-12-24 13:50:45 -0800181 git-name-rev$X git-pack-redundant$X git-repo-config$X git-var$X \
Mike McCormackf2561fd2006-03-10 14:32:50 +0900182 git-describe$X git-merge-tree$X git-blame$X git-imap-send$X
Andreas Ericssond6ebd252005-11-22 00:44:15 +0100183
Lukas Sandström854b4622006-06-13 22:22:00 +0200184BUILT_INS = git-log$X git-whatchanged$X git-show$X git-update-ref$X \
Lukas Sandströme690e842006-06-13 22:21:46 +0200185 git-count-objects$X git-diff$X git-push$X git-mailsplit$X \
Lukas Sandström7499c992006-06-13 22:21:53 +0200186 git-grep$X git-add$X git-rm$X git-rev-list$X git-stripspace$X \
Lukas Sandström34488e32006-06-13 22:21:50 +0200187 git-check-ref-format$X git-rev-parse$X git-mailinfo$X \
Junio C Hamano73f0a152006-05-24 12:19:47 -0700188 git-init-db$X git-tar-tree$X git-upload-tar$X git-format-patch$X \
Rene Scharfe52ba03c2006-06-10 16:13:41 +0200189 git-ls-files$X git-ls-tree$X git-get-tar-commit-id$X \
Lukas Sandström8ed05fb2006-06-13 22:21:42 +0200190 git-read-tree$X git-commit-tree$X git-write-tree$X \
Lukas Sandströmfefe81c2006-06-13 22:21:57 +0200191 git-apply$X git-show-branch$X git-diff-files$X git-update-index$X \
Johannes Schindelin00449f92006-07-03 17:18:43 +0200192 git-diff-index$X git-diff-stages$X git-diff-tree$X git-cat-file$X \
Linus Torvaldsba84a792006-07-06 10:16:22 -0700193 git-fmt-merge-msg$X git-prune$X
Junio C Hamano91730802006-04-10 17:37:58 -0700194
Junio C Hamanob42934d2006-01-12 21:37:17 -0800195# what 'all' will build and 'install' will install, in gitexecdir
Junio C Hamanof94fbbe2006-04-11 11:29:36 -0700196ALL_PROGRAMS = $(PROGRAMS) $(SIMPLE_PROGRAMS) $(SCRIPTS)
Linus Torvaldse83c5162005-04-07 15:13:13 -0700197
Junio C Hamano894a8a82005-09-30 00:27:11 -0700198# Backward compatibility -- to be removed after 1.0
H. Peter Anvin2f29dd52005-09-30 10:46:25 -0700199PROGRAMS += git-ssh-pull$X git-ssh-push$X
Junio C Hamanof71a69a2005-09-15 14:56:37 -0700200
Ryan Anderson3d320512005-11-21 00:11:22 -0500201# Set paths to tools early so that they can be used for version tests.
202ifndef SHELL_PATH
203 SHELL_PATH = /bin/sh
204endif
205ifndef PERL_PATH
206 PERL_PATH = /usr/bin/perl
207endif
208ifndef PYTHON_PATH
209 PYTHON_PATH = /usr/bin/python
210endif
211
Junio C Hamano720d1502005-09-10 17:46:27 -0700212PYMODULES = \
213 gitMergeCommon.py
214
Linus Torvalds0a02ce72005-04-18 12:49:39 -0700215LIB_FILE=libgit.a
Linus Torvalds34435462006-03-24 20:13:22 -0800216XDIFF_LIB=xdiff/lib.a
Linus Torvalds0a02ce72005-04-18 12:49:39 -0700217
Junio C Hamano215a7ad2005-09-07 17:26:23 -0700218LIB_H = \
Junio C Hamanof5948cf2006-03-04 02:51:19 -0800219 blob.h cache.h commit.h csum-file.h delta.h \
Linus Torvalds765ac8e2006-02-28 15:07:20 -0800220 diff.h object.h pack.h pkt-line.h quote.h refs.h \
Junio C Hamano1b0c7172006-03-29 22:55:43 -0800221 run-command.h strbuf.h tag.h tree.h git-compat-util.h revision.h \
Linus Torvalds453ec4b2006-05-16 19:02:14 -0700222 tree-walk.h log-tree.h dir.h
Junio C Hamano8f3f9b02005-07-23 17:54:41 -0700223
Junio C Hamano215a7ad2005-09-07 17:26:23 -0700224DIFF_OBJS = \
Junio C Hamano6973dca2006-04-21 23:57:45 -0700225 diff.o diff-lib.o diffcore-break.o diffcore-order.o \
Junio C Hamano65416752006-02-28 16:01:36 -0800226 diffcore-pickaxe.o diffcore-rename.o tree-diff.o combine-diff.o \
Junio C Hamano5f1c3f02006-04-09 01:11:11 -0700227 diffcore-delta.o log-tree.o
Josef Weidendorferb1bf95b2005-07-31 21:17:43 +0200228
Junio C Hamano215a7ad2005-09-07 17:26:23 -0700229LIB_OBJS = \
Junio C Hamano283c8ee2006-05-20 00:56:11 -0700230 blob.o commit.o connect.o csum-file.o cache-tree.o base85.o \
Junio C Hamano021b6e42006-06-06 12:51:49 -0700231 date.o diff-delta.o entry.o exec_cmd.o ident.o lockfile.o \
Junio C Hamano215a7ad2005-09-07 17:26:23 -0700232 object.o pack-check.o patch-delta.o path.o pkt-line.o \
Linus Torvalds3e4339e2006-06-18 11:45:02 -0700233 quote.o read-cache.o refs.o run-command.o dir.o object-refs.o \
Junio C Hamano215a7ad2005-09-07 17:26:23 -0700234 server-info.o setup.o sha1_file.o sha1_name.o strbuf.o \
Junio C Hamanof3123c42005-10-22 01:28:13 -0700235 tag.o tree.o usage.o config.o environment.o ctype.o copy.o \
Junio C Hamanod9ea73e2006-04-05 02:03:58 -0700236 fetch-clone.o revision.o pager.o tree-walk.o xdiff-interface.o \
Linus Torvalds0c799382006-06-28 22:06:36 -0700237 alloc.o merge-file.o $(DIFF_OBJS)
Junio C Hamanod19938a2005-05-09 17:57:56 -0700238
Linus Torvalds70827b12006-04-21 10:27:34 -0700239BUILTIN_OBJS = \
Junio C Hamanoefca5782006-05-15 18:12:06 -0700240 builtin-log.o builtin-help.o builtin-count.o builtin-diff.o builtin-push.o \
Linus Torvaldsd9b814c2006-05-19 16:19:34 -0700241 builtin-grep.o builtin-add.o builtin-rev-list.o builtin-check-ref-format.o \
Christian Couder895f10c2006-06-03 18:45:43 +0200242 builtin-rm.o builtin-init-db.o builtin-rev-parse.o \
Lukas Sandströmfefe81c2006-06-13 22:21:57 +0200243 builtin-tar-tree.o builtin-upload-tar.o builtin-update-index.o \
Lukas Sandström8ed05fb2006-06-13 22:21:42 +0200244 builtin-ls-files.o builtin-ls-tree.o builtin-write-tree.o \
Lukas Sandström34488e32006-06-13 22:21:50 +0200245 builtin-read-tree.o builtin-commit-tree.o builtin-mailinfo.o \
Peter Eriksene8cc9cd2006-05-23 14:15:36 +0200246 builtin-apply.o builtin-show-branch.o builtin-diff-files.o \
Timo Hirvonenf81daef2006-05-24 14:08:46 +0300247 builtin-diff-index.o builtin-diff-stages.o builtin-diff-tree.o \
Lukas Sandström854b4622006-06-13 22:22:00 +0200248 builtin-cat-file.o builtin-mailsplit.o builtin-stripspace.o \
Linus Torvaldsba84a792006-07-06 10:16:22 -0700249 builtin-update-ref.o builtin-fmt-merge-msg.o builtin-prune.o
Linus Torvalds70827b12006-04-21 10:27:34 -0700250
Johannes Schindelin54c261f2006-03-27 01:14:52 +0200251GITLIBS = $(LIB_FILE) $(XDIFF_LIB)
252LIBS = $(GITLIBS) -lz
Linus Torvaldscef661f2005-04-21 12:33:22 -0700253
Junio C Hamano229a7ed2005-09-23 10:41:40 -0700254#
255# Platform specific tweaks
256#
Junio C Hamanof7c15342005-10-09 12:52:35 -0700257
258# We choose to avoid "if .. else if .. else .. endif endif"
259# because maintaining the nesting to match is a pain. If
260# we had "elif" things would have been much nicer...
Junio C Hamanof7c15342005-10-09 12:52:35 -0700261
Peter Eriksen817151e2006-06-24 16:01:25 +0200262ifeq ($(uname_S),Linux)
263 NO_STRLCPY = YesPlease
264endif
Junio C Hamanof7c15342005-10-09 12:52:35 -0700265ifeq ($(uname_S),Darwin)
Junio C Hamano597c9cc2005-09-07 12:22:56 -0700266 NEEDS_SSL_WITH_CRYPTO = YesPlease
267 NEEDS_LIBICONV = YesPlease
Peter Eriksen817151e2006-06-24 16:01:25 +0200268 NO_STRLCPY = YesPlease
Shawn Pearce8eb38ca2006-07-24 00:28:28 -0400269 ifndef NO_FINK
270 ifeq ($(shell test -d /sw/lib && echo y),y)
271 ALL_CFLAGS += -I/sw/include
272 ALL_LDFLAGS += -L/sw/lib
273 endif
Shawn Pearcee3601e82006-02-28 09:03:48 -0500274 endif
Shawn Pearce8eb38ca2006-07-24 00:28:28 -0400275 ifndef NO_DARWIN_PORTS
276 ifeq ($(shell test -d /opt/local/lib && echo y),y)
277 ALL_CFLAGS += -I/opt/local/include
278 ALL_LDFLAGS += -L/opt/local/lib
279 endif
Shawn Pearcee3601e82006-02-28 09:03:48 -0500280 endif
Junio C Hamano597c9cc2005-09-07 12:22:56 -0700281endif
Junio C Hamanof7c15342005-10-09 12:52:35 -0700282ifeq ($(uname_S),SunOS)
Patrick Mauritzf0ebff02005-09-06 01:24:03 +0200283 NEEDS_SOCKET = YesPlease
Junio C Hamano5a90d4a2005-09-11 22:25:49 -0700284 NEEDS_NSL = YesPlease
Junio C Hamano229a7ed2005-09-23 10:41:40 -0700285 SHELL_PATH = /bin/bash
286 NO_STRCASESTR = YesPlease
Peter Eriksen817151e2006-06-24 16:01:25 +0200287 NO_STRLCPY = YesPlease
Jason Riedye40b61f2005-12-02 15:08:28 -0800288 ifeq ($(uname_R),5.8)
Paul Jakmae15f5452006-02-20 23:36:28 +0000289 NEEDS_LIBICONV = YesPlease
Jason Riedy731043f2006-01-25 12:38:36 -0800290 NO_UNSETENV = YesPlease
Jason Riedye40b61f2005-12-02 15:08:28 -0800291 NO_SETENV = YesPlease
292 endif
Dennis Stosberg40d88d42006-04-11 11:42:26 -0700293 ifeq ($(uname_R),5.9)
294 NO_UNSETENV = YesPlease
295 NO_SETENV = YesPlease
296 endif
Junio C Hamano229a7ed2005-09-23 10:41:40 -0700297 INSTALL = ginstall
298 TAR = gtar
Junio C Hamano12aa7452005-11-04 23:50:09 -0800299 ALL_CFLAGS += -D__EXTENSIONS__
Patrick Mauritzf0ebff02005-09-06 01:24:03 +0200300endif
Junio C Hamanof7c15342005-10-09 12:52:35 -0700301ifeq ($(uname_O),Cygwin)
Junio C Hamano63be37b2006-01-19 17:13:57 -0800302 NO_D_TYPE_IN_DIRENT = YesPlease
Junio C Hamano35a730f2006-01-19 17:13:51 -0800303 NO_D_INO_IN_DIRENT = YesPlease
hpa17754512005-09-28 16:37:37 -0700304 NO_STRCASESTR = YesPlease
Peter Eriksen817151e2006-06-24 16:01:25 +0200305 NO_STRLCPY = YesPlease
Junio C Hamano9f0bb902006-05-02 00:40:24 -0700306 NO_SYMLINK_HEAD = YesPlease
hpa17754512005-09-28 16:37:37 -0700307 NEEDS_LIBICONV = YesPlease
Junio C Hamano2e67a5f2005-11-17 11:29:47 -0800308 # There are conflicting reports about this.
309 # On some boxes NO_MMAP is needed, and not so elsewhere.
310 # Try uncommenting this if you see things break -- YMMV.
311 # NO_MMAP = YesPlease
hpa49744d62005-09-28 16:52:21 -0700312 NO_IPV6 = YesPlease
Peter Anvina23cd8e2005-09-28 19:08:37 -0700313 X = .exe
Nicolas Pitre7c6ef2f2005-09-20 12:27:13 -0400314endif
Alecs Kingb3bf9742006-01-27 02:04:30 +0800315ifeq ($(uname_S),FreeBSD)
316 NEEDS_LIBICONV = YesPlease
317 ALL_CFLAGS += -I/usr/local/include
318 ALL_LDFLAGS += -L/usr/local/lib
319endif
Junio C Hamanof7c15342005-10-09 12:52:35 -0700320ifeq ($(uname_S),OpenBSD)
Junio C Hamano5fb41e82005-10-10 11:51:11 -0700321 NO_STRCASESTR = YesPlease
Han Boetes18c5a522005-10-01 08:23:26 +0200322 NEEDS_LIBICONV = YesPlease
Junio C Hamano94d23312005-11-13 01:46:13 -0800323 ALL_CFLAGS += -I/usr/local/include
324 ALL_LDFLAGS += -L/usr/local/lib
325endif
326ifeq ($(uname_S),NetBSD)
Dennis Stosberge88856b2006-05-11 19:35:31 +0200327 ifeq ($(shell expr "$(uname_R)" : '[01]\.'),2)
328 NEEDS_LIBICONV = YesPlease
329 endif
Junio C Hamano94d23312005-11-13 01:46:13 -0800330 ALL_CFLAGS += -I/usr/pkg/include
331 ALL_LDFLAGS += -L/usr/pkg/lib -Wl,-rpath,/usr/pkg/lib
Han Boetes18c5a522005-10-01 08:23:26 +0200332endif
Jason Riedya6da9392005-12-06 14:20:16 -0800333ifeq ($(uname_S),AIX)
334 NO_STRCASESTR=YesPlease
Peter Eriksen817151e2006-06-24 16:01:25 +0200335 NO_STRLCPY = YesPlease
Jason Riedya6da9392005-12-06 14:20:16 -0800336 NEEDS_LIBICONV=YesPlease
337endif
Johannes Schindelin289c4b32006-02-17 15:23:41 +0100338ifeq ($(uname_S),IRIX64)
339 NO_IPV6=YesPlease
340 NO_SETENV=YesPlease
341 NO_STRCASESTR=YesPlease
Peter Eriksen817151e2006-06-24 16:01:25 +0200342 NO_STRLCPY = YesPlease
Johannes Schindelin289c4b32006-02-17 15:23:41 +0100343 NO_SOCKADDR_STORAGE=YesPlease
344 SHELL_PATH=/usr/gnu/bin/bash
345 ALL_CFLAGS += -DPATH_MAX=1024
346 # for now, build 32-bit version
347 ALL_LDFLAGS += -L/usr/lib32
348endif
Junio C Hamanof7c15342005-10-09 12:52:35 -0700349ifneq (,$(findstring arm,$(uname_M)))
350 ARM_SHA1 = YesPlease
351endif
Junio C Hamano597c9cc2005-09-07 12:22:56 -0700352
Johannes Schindelinf2d6a252005-10-11 15:22:47 -0700353-include config.mak
Linus Torvaldscef661f2005-04-21 12:33:22 -0700354
Timo Hirvonenb34403a2005-12-01 03:32:01 +0200355ifdef WITH_OWN_SUBPROCESS_PY
356 PYMODULES += compat/subprocess.py
357else
Johannes Schindelina348ab72006-02-19 21:13:48 +0100358 ifeq ($(NO_PYTHON),)
359 ifneq ($(shell $(PYTHON_PATH) -c 'import subprocess;print"OK"' 2>/dev/null),OK)
360 PYMODULES += compat/subprocess.py
361 endif
Timo Hirvonenb34403a2005-12-01 03:32:01 +0200362 endif
363endif
364
Junio C Hamano229a7ed2005-09-23 10:41:40 -0700365ifndef NO_CURL
366 ifdef CURLDIR
Junio C Hamano94d23312005-11-13 01:46:13 -0800367 # This is still problematic -- gcc does not always want -R.
Junio C Hamano12aa7452005-11-04 23:50:09 -0800368 ALL_CFLAGS += -I$(CURLDIR)/include
Junio C Hamano229a7ed2005-09-23 10:41:40 -0700369 CURL_LIBCURL = -L$(CURLDIR)/lib -R$(CURLDIR)/lib -lcurl
370 else
371 CURL_LIBCURL = -lcurl
372 endif
H. Peter Anvin2f29dd52005-09-30 10:46:25 -0700373 PROGRAMS += git-http-fetch$X
Nick Hengeveld08900982005-11-18 17:08:36 -0800374 curl_check := $(shell (echo 070908; curl-config --vernum) | sort -r | sed -ne 2p)
375 ifeq "$(curl_check)" "070908"
376 ifndef NO_EXPAT
Nick Hengeveld08900982005-11-18 17:08:36 -0800377 PROGRAMS += git-http-push$X
378 endif
Nick Hengeveld58e60dd2005-11-02 11:19:24 -0800379 endif
Johannes Schindelin459a21b2006-04-05 16:22:40 +0200380 ifndef NO_EXPAT
381 EXPAT_LIBEXPAT = -lexpat
382 endif
Junio C Hamano229a7ed2005-09-23 10:41:40 -0700383endif
384
Petr Baudisdd53c7a2005-07-29 17:50:51 +0200385ifndef NO_OPENSSL
Junio C Hamano215a7ad2005-09-07 17:26:23 -0700386 OPENSSL_LIBSSL = -lssl
Junio C Hamano455a7f32005-09-30 13:31:16 -0700387 ifdef OPENSSLDIR
388 # Again this may be problematic -- gcc does not always want -R.
Junio C Hamano12aa7452005-11-04 23:50:09 -0800389 ALL_CFLAGS += -I$(OPENSSLDIR)/include
Junio C Hamano455a7f32005-09-30 13:31:16 -0700390 OPENSSL_LINK = -L$(OPENSSLDIR)/lib -R$(OPENSSLDIR)/lib
391 else
392 OPENSSL_LINK =
393 endif
Petr Baudisdd53c7a2005-07-29 17:50:51 +0200394else
Junio C Hamano12aa7452005-11-04 23:50:09 -0800395 ALL_CFLAGS += -DNO_OPENSSL
Junio C Hamano215a7ad2005-09-07 17:26:23 -0700396 MOZILLA_SHA1 = 1
397 OPENSSL_LIBSSL =
Petr Baudisdd53c7a2005-07-29 17:50:51 +0200398endif
Junio C Hamano597c9cc2005-09-07 12:22:56 -0700399ifdef NEEDS_SSL_WITH_CRYPTO
Junio C Hamano455a7f32005-09-30 13:31:16 -0700400 LIB_4_CRYPTO = $(OPENSSL_LINK) -lcrypto -lssl
Junio C Hamano597c9cc2005-09-07 12:22:56 -0700401else
Junio C Hamano455a7f32005-09-30 13:31:16 -0700402 LIB_4_CRYPTO = $(OPENSSL_LINK) -lcrypto
Junio C Hamano597c9cc2005-09-07 12:22:56 -0700403endif
404ifdef NEEDS_LIBICONV
Junio C Hamano455a7f32005-09-30 13:31:16 -0700405 ifdef ICONVDIR
406 # Again this may be problematic -- gcc does not always want -R.
Junio C Hamano12aa7452005-11-04 23:50:09 -0800407 ALL_CFLAGS += -I$(ICONVDIR)/include
Junio C Hamano455a7f32005-09-30 13:31:16 -0700408 ICONV_LINK = -L$(ICONVDIR)/lib -R$(ICONVDIR)/lib
409 else
410 ICONV_LINK =
411 endif
Lukas Sandström34488e32006-06-13 22:21:50 +0200412 LIBS += $(ICONV_LINK) -liconv
Junio C Hamano597c9cc2005-09-07 12:22:56 -0700413endif
Patrick Mauritzf0ebff02005-09-06 01:24:03 +0200414ifdef NEEDS_SOCKET
415 LIBS += -lsocket
416 SIMPLE_LIB += -lsocket
417endif
Junio C Hamano5a90d4a2005-09-11 22:25:49 -0700418ifdef NEEDS_NSL
419 LIBS += -lnsl
420 SIMPLE_LIB += -lnsl
421endif
Junio C Hamano63be37b2006-01-19 17:13:57 -0800422ifdef NO_D_TYPE_IN_DIRENT
423 ALL_CFLAGS += -DNO_D_TYPE_IN_DIRENT
424endif
Junio C Hamano35a730f2006-01-19 17:13:51 -0800425ifdef NO_D_INO_IN_DIRENT
426 ALL_CFLAGS += -DNO_D_INO_IN_DIRENT
427endif
Junio C Hamano9f0bb902006-05-02 00:40:24 -0700428ifdef NO_SYMLINK_HEAD
429 ALL_CFLAGS += -DNO_SYMLINK_HEAD
430endif
Linus Torvaldsef34af22005-09-18 18:30:50 -0700431ifdef NO_STRCASESTR
Junio C Hamano4050c0d2005-12-05 11:54:29 -0800432 COMPAT_CFLAGS += -DNO_STRCASESTR
Jason Riedye40b61f2005-12-02 15:08:28 -0800433 COMPAT_OBJS += compat/strcasestr.o
434endif
Peter Eriksen817151e2006-06-24 16:01:25 +0200435ifdef NO_STRLCPY
436 COMPAT_CFLAGS += -DNO_STRLCPY
437 COMPAT_OBJS += compat/strlcpy.o
438endif
Jason Riedye40b61f2005-12-02 15:08:28 -0800439ifdef NO_SETENV
Junio C Hamano4050c0d2005-12-05 11:54:29 -0800440 COMPAT_CFLAGS += -DNO_SETENV
Jason Riedye40b61f2005-12-02 15:08:28 -0800441 COMPAT_OBJS += compat/setenv.o
Linus Torvaldsef34af22005-09-18 18:30:50 -0700442endif
Jason Riedy731043f2006-01-25 12:38:36 -0800443ifdef NO_SETENV
444 COMPAT_CFLAGS += -DNO_UNSETENV
445 COMPAT_OBJS += compat/unsetenv.o
446endif
Johannes Schindelin730d48a2005-10-08 15:54:36 -0700447ifdef NO_MMAP
Junio C Hamano4050c0d2005-12-05 11:54:29 -0800448 COMPAT_CFLAGS += -DNO_MMAP
Jason Riedye40b61f2005-12-02 15:08:28 -0800449 COMPAT_OBJS += compat/mmap.o
Johannes Schindelin730d48a2005-10-08 15:54:36 -0700450endif
hpa49744d62005-09-28 16:52:21 -0700451ifdef NO_IPV6
Junio C Hamanobdc37f52006-01-19 17:13:32 -0800452 ALL_CFLAGS += -DNO_IPV6
453endif
454ifdef NO_SOCKADDR_STORAGE
455ifdef NO_IPV6
456 ALL_CFLAGS += -Dsockaddr_storage=sockaddr_in
457else
458 ALL_CFLAGS += -Dsockaddr_storage=sockaddr_in6
459endif
hpa49744d62005-09-28 16:52:21 -0700460endif
Yakov Lerner6ba68ab2006-05-22 00:37:00 +0300461ifdef NO_INET_NTOP
462 LIB_OBJS += compat/inet_ntop.o
463endif
Linus Torvaldscef661f2005-04-21 12:33:22 -0700464
Fernando J. Peredab6e56ec2006-02-16 09:38:01 +0100465ifdef NO_ICONV
466 ALL_CFLAGS += -DNO_ICONV
467endif
468
Nicolas Pitre7c6ef2f2005-09-20 12:27:13 -0400469ifdef PPC_SHA1
470 SHA1_HEADER = "ppc/sha1.h"
471 LIB_OBJS += ppc/sha1.o ppc/sha1ppc.o
472else
473ifdef ARM_SHA1
474 SHA1_HEADER = "arm/sha1.h"
475 LIB_OBJS += arm/sha1.o arm/sha1_arm.o
476else
477ifdef MOZILLA_SHA1
478 SHA1_HEADER = "mozilla-sha1/sha1.h"
479 LIB_OBJS += mozilla-sha1/sha1.o
480else
481 SHA1_HEADER = <openssl/sha.h>
482 LIBS += $(LIB_4_CRYPTO)
483endif
484endif
485endif
Johannes Schindelin5b5d4d92006-02-17 15:23:16 +0100486ifdef NO_ACCURATE_DIFF
487 ALL_CFLAGS += -DNO_ACCURATE_DIFF
488endif
Nicolas Pitre7c6ef2f2005-09-20 12:27:13 -0400489
Pavel Roskinaddf88e2006-07-09 03:44:30 -0400490# Shell quote (do not use $(call) to accommodate ancient setups);
Johannes Schindelin39c015c2006-02-18 12:40:22 +0100491
492SHA1_HEADER_SQ = $(subst ','\'',$(SHA1_HEADER))
493
494DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
495bindir_SQ = $(subst ','\'',$(bindir))
496gitexecdir_SQ = $(subst ','\'',$(gitexecdir))
497template_dir_SQ = $(subst ','\'',$(template_dir))
Yakov Lernerca3bcab2006-06-15 01:36:00 +0300498prefix_SQ = $(subst ','\'',$(prefix))
Johannes Schindelin39c015c2006-02-18 12:40:22 +0100499
500SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
501PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
502PYTHON_PATH_SQ = $(subst ','\'',$(PYTHON_PATH))
503GIT_PYTHON_DIR_SQ = $(subst ','\'',$(GIT_PYTHON_DIR))
504
505ALL_CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER_SQ)' $(COMPAT_CFLAGS)
Jason Riedye40b61f2005-12-02 15:08:28 -0800506LIB_OBJS += $(COMPAT_OBJS)
Tom Princeec2d1512005-10-11 18:47:33 -0700507export prefix TAR INSTALL DESTDIR SHELL_PATH template_dir
Petr Baudis28818ff2005-07-29 17:50:24 +0200508### Build rules
Linus Torvalds89967022005-04-30 13:19:56 -0700509
Junio C Hamanof94fbbe2006-04-11 11:29:36 -0700510all: $(ALL_PROGRAMS) $(BUILT_INS) git$X gitk
Petr Baudis28818ff2005-07-29 17:50:24 +0200511
Junio C Hamanod3af6212005-08-06 12:50:14 -0700512all:
513 $(MAKE) -C templates
Nicolas Pitrea310d432005-05-19 10:27:14 -0400514
Junio C Hamano4dc00022006-01-12 21:42:25 -0800515strip: $(PROGRAMS) git$X
516 $(STRIP) $(STRIP_OPTS) $(PROGRAMS) git$X
517
Yakov Lernerca3bcab2006-06-15 01:36:00 +0300518git$X: git.c common-cmds.h $(BUILTIN_OBJS) $(GITLIBS) GIT-CFLAGS
Michal Ostrowski77cb17e2006-01-10 21:12:17 -0500519 $(CC) -DGIT_VERSION='"$(GIT_VERSION)"' \
Junio C Hamano8eef8e02006-03-31 16:23:46 -0800520 $(ALL_CFLAGS) -o $@ $(filter %.c,$^) \
Linus Torvalds70827b12006-04-21 10:27:34 -0700521 $(BUILTIN_OBJS) $(ALL_LDFLAGS) $(LIBS)
Junio C Hamano6a2e50f2005-09-07 21:26:52 -0700522
Junio C Hamano08df6172006-04-21 21:56:13 -0700523builtin-help.o: common-cmds.h
524
Junio C Hamano91730802006-04-10 17:37:58 -0700525$(BUILT_INS): git$X
526 rm -f $@ && ln git$X $@
527
Fredrik Kuivinena87cd022006-03-09 17:24:19 +0100528common-cmds.h: Documentation/git-*.txt
Jim Meyeringfc36f6a2006-05-25 18:52:01 +0200529 ./generate-cmdlist.sh > $@+
530 mv $@+ $@
Fredrik Kuivinena87cd022006-03-09 17:24:19 +0100531
Andreas Ericssond6ebd252005-11-22 00:44:15 +0100532$(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
Jim Meyeringfc36f6a2006-05-25 18:52:01 +0200533 rm -f $@ $@+
Johannes Schindelin39c015c2006-02-18 12:40:22 +0100534 sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
Michal Rokosd9bffc02006-07-08 17:32:04 +0200535 -e 's|@@PERL@@|$(PERL_PATH_SQ)|g' \
Junio C Hamano3ff8cbe2005-10-04 12:41:35 -0700536 -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
Fernando J. Pereda6c5c62f2006-02-15 12:37:30 +0100537 -e 's/@@NO_CURL@@/$(NO_CURL)/g' \
Johannes Schindelinabb7c7b2006-02-18 13:01:18 +0100538 -e 's/@@NO_PYTHON@@/$(NO_PYTHON)/g' \
Jim Meyeringfc36f6a2006-05-25 18:52:01 +0200539 $@.sh >$@+
540 chmod +x $@+
541 mv $@+ $@
Junio C Hamanobc6146d2005-09-08 18:50:33 -0700542
543$(patsubst %.perl,%,$(SCRIPT_PERL)) : % : %.perl
Jim Meyeringfc36f6a2006-05-25 18:52:01 +0200544 rm -f $@ $@+
Johannes Schindelin39c015c2006-02-18 12:40:22 +0100545 sed -e '1s|#!.*perl|#!$(PERL_PATH_SQ)|' \
Junio C Hamano3ff8cbe2005-10-04 12:41:35 -0700546 -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
Jim Meyeringfc36f6a2006-05-25 18:52:01 +0200547 $@.perl >$@+
548 chmod +x $@+
549 mv $@+ $@
Junio C Hamanobc6146d2005-09-08 18:50:33 -0700550
Yakov Lernerca3bcab2006-06-15 01:36:00 +0300551$(patsubst %.py,%,$(SCRIPT_PYTHON)) : % : %.py GIT-CFLAGS
Jim Meyeringfc36f6a2006-05-25 18:52:01 +0200552 rm -f $@ $@+
Johannes Schindelin39c015c2006-02-18 12:40:22 +0100553 sed -e '1s|#!.*python|#!$(PYTHON_PATH_SQ)|' \
554 -e 's|@@GIT_PYTHON_PATH@@|$(GIT_PYTHON_DIR_SQ)|g' \
Junio C Hamano3ff8cbe2005-10-04 12:41:35 -0700555 -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
Jim Meyeringfc36f6a2006-05-25 18:52:01 +0200556 $@.py >$@+
557 chmod +x $@+
558 mv $@+ $@
Junio C Hamano720d1502005-09-10 17:46:27 -0700559
Johannes Schindelin4eba0f32005-10-20 17:13:24 +0200560git-cherry-pick: git-revert
Jim Meyeringfc36f6a2006-05-25 18:52:01 +0200561 cp $< $@+
562 mv $@+ $@
Johannes Schindelin4eba0f32005-10-20 17:13:24 +0200563
Junio C Hamanocf7bb582006-02-10 00:45:59 -0800564git-status: git-commit
Jim Meyeringfc36f6a2006-05-25 18:52:01 +0200565 cp $< $@+
566 mv $@+ $@
Junio C Hamanocf7bb582006-02-10 00:45:59 -0800567
Eric Wonga51d37c2006-07-01 15:14:14 -0700568git-instaweb: git-instaweb.sh gitweb/gitweb.cgi gitweb/gitweb.css
569 rm -f $@ $@+
570 sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
571 -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
572 -e 's/@@NO_CURL@@/$(NO_CURL)/g' \
573 -e 's/@@NO_PYTHON@@/$(NO_PYTHON)/g' \
Michal Rokos6e959ab2006-07-08 17:27:10 +0200574 -e '/@@GITWEB_CGI@@/r gitweb/gitweb.cgi' \
Johannes Schindelin07002282006-07-02 11:31:30 +0200575 -e '/@@GITWEB_CGI@@/d' \
Michal Rokos6e959ab2006-07-08 17:27:10 +0200576 -e '/@@GITWEB_CSS@@/r gitweb/gitweb.css' \
Johannes Schindelin07002282006-07-02 11:31:30 +0200577 -e '/@@GITWEB_CSS@@/d' \
578 $@.sh > $@+
Eric Wonga51d37c2006-07-01 15:14:14 -0700579 chmod +x $@+
580 mv $@+ $@
581
Junio C Hamano9b88fce2005-12-27 14:40:17 -0800582# These can record GIT_VERSION
583git$X git.spec \
584 $(patsubst %.sh,%,$(SCRIPT_SH)) \
585 $(patsubst %.perl,%,$(SCRIPT_PERL)) \
586 $(patsubst %.py,%,$(SCRIPT_PYTHON)) \
587 : GIT-VERSION-FILE
Johannes Schindeline99fcf92005-12-22 20:38:23 +0100588
Yakov Lernerca3bcab2006-06-15 01:36:00 +0300589%.o: %.c GIT-CFLAGS
Pavel Roskinb05701c2005-08-06 01:36:15 -0400590 $(CC) -o $*.o -c $(ALL_CFLAGS) $<
591%.o: %.S
592 $(CC) -o $*.o -c $(ALL_CFLAGS) $<
593
Yakov Lernerca3bcab2006-06-15 01:36:00 +0300594exec_cmd.o: exec_cmd.c GIT-CFLAGS
Johannes Schindelin39c015c2006-02-18 12:40:22 +0100595 $(CC) -o $*.o -c $(ALL_CFLAGS) '-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' $<
Yakov Lernerc1f80642006-06-22 04:47:00 +0300596builtin-init-db.o: builtin-init-db.c GIT-CFLAGS
597 $(CC) -o $*.o -c $(ALL_CFLAGS) -DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir_SQ)"' $<
Michal Ostrowski77cb17e2006-01-10 21:12:17 -0500598
Yakov Lernerca3bcab2006-06-15 01:36:00 +0300599http.o: http.c GIT-CFLAGS
Nick Hengeveld20fc9bc2006-04-04 10:11:29 -0700600 $(CC) -o $*.o -c $(ALL_CFLAGS) -DGIT_USER_AGENT='"git/$(GIT_VERSION)"' $<
601
Nick Hengeveld8d9fbe52006-04-04 05:33:18 -0700602ifdef NO_EXPAT
Yakov Lernerca3bcab2006-06-15 01:36:00 +0300603http-fetch.o: http-fetch.c http.h GIT-CFLAGS
Nick Hengeveld8d9fbe52006-04-04 05:33:18 -0700604 $(CC) -o $*.o -c $(ALL_CFLAGS) -DNO_EXPAT $<
605endif
606
Junio C Hamano8eef8e02006-03-31 16:23:46 -0800607git-%$X: %.o $(GITLIBS)
Junio C Hamano94d23312005-11-13 01:46:13 -0800608 $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
Daniel Barkalow6eb7ed52005-04-23 18:47:23 -0700609
Junio C Hamano597c9cc2005-09-07 12:22:56 -0700610$(SIMPLE_PROGRAMS) : $(LIB_FILE)
H. Peter Anvin2f29dd52005-09-30 10:46:25 -0700611$(SIMPLE_PROGRAMS) : git-%$X : %.o
Junio C Hamano94d23312005-11-13 01:46:13 -0800612 $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
613 $(LIB_FILE) $(SIMPLE_LIB)
Junio C Hamano597c9cc2005-09-07 12:22:56 -0700614
H. Peter Anvin2f29dd52005-09-30 10:46:25 -0700615git-local-fetch$X: fetch.o
616git-ssh-fetch$X: rsh.o fetch.o
617git-ssh-upload$X: rsh.o
618git-ssh-pull$X: rsh.o fetch.o
619git-ssh-push$X: rsh.o
Daniel Barkalow6eb7ed52005-04-23 18:47:23 -0700620
Mike McCormackf2561fd2006-03-10 14:32:50 +0900621git-imap-send$X: imap-send.o $(LIB_FILE)
622
Junio C Hamanodd8239f2006-06-06 14:26:57 -0700623http.o http-fetch.o http-push.o: http.h
Junio C Hamano8fced612006-07-03 00:53:13 -0700624git-http-fetch$X: fetch.o http.o http-fetch.o $(GITLIBS)
Johannes Schindelin39c015c2006-02-18 12:40:22 +0100625 $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
Nick Hengeveld8d9fbe52006-04-04 05:33:18 -0700626 $(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
Johannes Schindelin39c015c2006-02-18 12:40:22 +0100627
Junio C Hamano8fced612006-07-03 00:53:13 -0700628git-http-push$X: revision.o http.o http-push.o $(GITLIBS)
Johannes Schindelin39c015c2006-02-18 12:40:22 +0100629 $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
630 $(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
631
Linus Torvalds70827b12006-04-21 10:27:34 -0700632$(LIB_OBJS) $(BUILTIN_OBJS): $(LIB_H)
Junio C Hamano1f330262006-06-22 15:43:47 -0700633$(patsubst git-%$X,%.o,$(PROGRAMS)): $(LIB_H) $(wildcard */*.h)
Petr Baudise4683052005-07-29 17:48:50 +0200634$(DIFF_OBJS): diffcore.h
Linus Torvaldse83c5162005-04-07 15:13:13 -0700635
Petr Baudis28818ff2005-07-29 17:50:24 +0200636$(LIB_FILE): $(LIB_OBJS)
Junio C Hamano71459c12006-04-25 23:11:17 -0700637 rm -f $@ && $(AR) rcs $@ $(LIB_OBJS)
Petr Baudis28818ff2005-07-29 17:50:24 +0200638
Linus Torvalds34435462006-03-24 20:13:22 -0800639XDIFF_OBJS=xdiff/xdiffi.o xdiff/xprepare.o xdiff/xutils.o xdiff/xemit.o
640
641$(XDIFF_LIB): $(XDIFF_OBJS)
Junio C Hamano2d86d2c2006-04-26 03:12:58 -0700642 rm -f $@ && $(AR) rcs $@ $(XDIFF_OBJS)
Linus Torvalds34435462006-03-24 20:13:22 -0800643
644
Petr Baudis28818ff2005-07-29 17:50:24 +0200645doc:
646 $(MAKE) -C Documentation all
647
Fredrik Kuivinenf81e7c62006-03-18 11:07:12 +0100648TAGS:
649 rm -f TAGS
650 find . -name '*.[hcS]' -print | xargs etags -a
651
652tags:
653 rm -f tags
654 find . -name '*.[hcS]' -print | xargs ctags -a
Petr Baudis28818ff2005-07-29 17:50:24 +0200655
Yakov Lernerca3bcab2006-06-15 01:36:00 +0300656### Detect prefix changes
Junio C Hamanobbc932c2006-06-22 02:04:27 -0700657TRACK_CFLAGS = $(subst ','\'',$(ALL_CFLAGS)):$(GIT_PYTHON_DIR_SQ):\
Yakov Lernerca3bcab2006-06-15 01:36:00 +0300658 $(bindir_SQ):$(gitexecdir_SQ):$(template_dir_SQ):$(prefix_SQ)
659
660GIT-CFLAGS: .FORCE-GIT-CFLAGS
661 @FLAGS='$(TRACK_CFLAGS)'; \
662 if test x"$$FLAGS" != x"`cat GIT-CFLAGS 2>/dev/null`" ; then \
663 echo 1>&2 " * new build flags or prefix"; \
664 echo "$$FLAGS" >GIT-CFLAGS; \
665 fi
666
Petr Baudis28818ff2005-07-29 17:50:24 +0200667### Testing rules
668
Johannes Schindelinabb7c7b2006-02-18 13:01:18 +0100669# GNU make supports exporting all variables by "export" without parameters.
670# However, the environment gets quite big, and some programs have problems
671# with that.
672
673export NO_PYTHON
Johannes Schindelin140245b2006-07-07 13:26:31 +0200674export NO_SVN_TESTS
Johannes Schindelinabb7c7b2006-02-18 13:01:18 +0100675
Petr Baudis28818ff2005-07-29 17:50:24 +0200676test: all
677 $(MAKE) -C t/ all
678
Junio C Hamano4ccafd72005-11-02 12:01:06 -0800679test-date$X: test-date.c date.o ctype.o
Junio C Hamano94d23312005-11-13 01:46:13 -0800680 $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) test-date.c date.o ctype.o
Petr Baudis28818ff2005-07-29 17:50:24 +0200681
H. Peter Anvin2f29dd52005-09-30 10:46:25 -0700682test-delta$X: test-delta.c diff-delta.o patch-delta.o
Nicolas Pitre3dc5a9e2006-04-29 00:58:05 -0400683 $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $^
Petr Baudis28818ff2005-07-29 17:50:24 +0200684
Junio C Hamano17448202006-04-23 20:20:25 -0700685test-dump-cache-tree$X: dump-cache-tree.o $(GITLIBS)
686 $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
687
Junio C Hamanob65bc212006-06-24 00:59:49 -0700688test-sha1$X: test-sha1.o $(GITLIBS)
689 $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
690
691check-sha1:: test-sha1$X
692 ./test-sha1.sh
693
Petr Baudis28818ff2005-07-29 17:50:24 +0200694check:
Junio C Hamano773b6332005-12-14 13:32:52 -0800695 for i in *.c; do sparse $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i || exit; done
Petr Baudis28818ff2005-07-29 17:50:24 +0200696
697
698
699### Installation rules
700
Andreas Ericssond6ebd252005-11-22 00:44:15 +0100701install: all
Johannes Schindelin39c015c2006-02-18 12:40:22 +0100702 $(INSTALL) -d -m755 '$(DESTDIR_SQ)$(bindir_SQ)'
703 $(INSTALL) -d -m755 '$(DESTDIR_SQ)$(gitexecdir_SQ)'
704 $(INSTALL) $(ALL_PROGRAMS) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
705 $(INSTALL) git$X gitk '$(DESTDIR_SQ)$(bindir_SQ)'
Junio C Hamano8d5afef2005-08-02 16:45:21 -0700706 $(MAKE) -C templates install
Johannes Schindelin39c015c2006-02-18 12:40:22 +0100707 $(INSTALL) -d -m755 '$(DESTDIR_SQ)$(GIT_PYTHON_DIR_SQ)'
708 $(INSTALL) $(PYMODULES) '$(DESTDIR_SQ)$(GIT_PYTHON_DIR_SQ)'
Sean7f7e6ea2006-05-22 00:42:59 -0400709 if test 'z$(bindir_SQ)' != 'z$(gitexecdir_SQ)'; \
710 then \
711 ln -f '$(DESTDIR_SQ)$(bindir_SQ)/git$X' \
712 '$(DESTDIR_SQ)$(gitexecdir_SQ)/git$X' || \
713 cp '$(DESTDIR_SQ)$(bindir_SQ)/git$X' \
714 '$(DESTDIR_SQ)$(gitexecdir_SQ)/git$X'; \
715 fi
716 $(foreach p,$(BUILT_INS), rm -f '$(DESTDIR_SQ)$(gitexecdir_SQ)/$p' && ln '$(DESTDIR_SQ)$(gitexecdir_SQ)/git$X' '$(DESTDIR_SQ)$(gitexecdir_SQ)/$p' ;)
Petr Baudis28818ff2005-07-29 17:50:24 +0200717
718install-doc:
719 $(MAKE) -C Documentation install
720
721
722
723
724### Maintainer's dist rules
725
Junio C Hamano9b88fce2005-12-27 14:40:17 -0800726git.spec: git.spec.in
Jim Meyeringfc36f6a2006-05-25 18:52:01 +0200727 sed -e 's/@@VERSION@@/$(GIT_VERSION)/g' < $< > $@+
728 mv $@+ $@
Chris Wrighta9db2972005-07-07 13:09:50 -0700729
Junio C Hamano27dedf02005-11-16 21:32:44 -0800730GIT_TARNAME=git-$(GIT_VERSION)
731dist: git.spec git-tar-tree
Rene Scharfe9cd625b2006-06-18 15:25:33 +0200732 ./git-tar-tree HEAD^{tree} $(GIT_TARNAME) > $(GIT_TARNAME).tar
Chris Wrighta9db2972005-07-07 13:09:50 -0700733 @mkdir -p $(GIT_TARNAME)
Junio C Hamano27dedf02005-11-16 21:32:44 -0800734 @cp git.spec $(GIT_TARNAME)
H. Peter Anvin181129d2006-01-09 18:07:01 -0800735 @echo $(GIT_VERSION) > $(GIT_TARNAME)/version
736 $(TAR) rf $(GIT_TARNAME).tar \
737 $(GIT_TARNAME)/git.spec $(GIT_TARNAME)/version
Chris Wrighta9db2972005-07-07 13:09:50 -0700738 @rm -rf $(GIT_TARNAME)
Eric W. Biederman9dce3c02005-07-14 19:20:50 -0600739 gzip -f -9 $(GIT_TARNAME).tar
Chris Wrighta9db2972005-07-07 13:09:50 -0700740
741rpm: dist
Junio C Hamano27dedf02005-11-16 21:32:44 -0800742 $(RPMBUILD) -ta $(GIT_TARNAME).tar.gz
Chris Wrighta9db2972005-07-07 13:09:50 -0700743
Tilman Sauerbeck52db0492006-05-18 12:57:04 +0200744htmldocs = git-htmldocs-$(GIT_VERSION)
745manpages = git-manpages-$(GIT_VERSION)
746dist-doc:
747 rm -fr .doc-tmp-dir
748 mkdir .doc-tmp-dir
749 $(MAKE) -C Documentation WEBDOC_DEST=../.doc-tmp-dir install-webdoc
750 cd .doc-tmp-dir && $(TAR) cf ../$(htmldocs).tar .
751 gzip -n -9 -f $(htmldocs).tar
752 :
753 rm -fr .doc-tmp-dir
754 mkdir .doc-tmp-dir .doc-tmp-dir/man1 .doc-tmp-dir/man7
Martin Waitzc5360322006-05-25 14:37:46 +0200755 $(MAKE) -C Documentation DESTDIR=./ \
Tilman Sauerbeck52db0492006-05-18 12:57:04 +0200756 man1=../.doc-tmp-dir/man1 \
757 man7=../.doc-tmp-dir/man7 \
758 install
759 cd .doc-tmp-dir && $(TAR) cf ../$(manpages).tar .
760 gzip -n -9 -f $(manpages).tar
761 rm -fr .doc-tmp-dir
762
Petr Baudis28818ff2005-07-29 17:50:24 +0200763### Cleaning rules
Eric W. Biederman87a81c82005-07-14 19:21:57 -0600764
Linus Torvaldse83c5162005-04-07 15:13:13 -0700765clean:
Junio C Hamano3467fec2006-03-26 23:41:22 -0800766 rm -f *.o mozilla-sha1/*.o arm/*.o ppc/*.o compat/*.o xdiff/*.o \
767 $(LIB_FILE) $(XDIFF_LIB)
A Large Angry SCMe6bfaf32006-04-16 20:17:38 -0700768 rm -f $(ALL_PROGRAMS) $(BUILT_INS) git$X
Fredrik Kuivinenf81e7c62006-03-18 11:07:12 +0100769 rm -f *.spec *.pyc *.pyo */*.pyc */*.pyo common-cmds.h TAGS tags
Tilman Sauerbeck52db0492006-05-18 12:57:04 +0200770 rm -rf $(GIT_TARNAME) .doc-tmp-dir
Junio C Hamano5a571cd2005-08-12 01:03:07 -0700771 rm -f $(GIT_TARNAME).tar.gz git-core_$(GIT_VERSION)-*.tar.gz
Junio C Hamano9dc21642006-06-07 12:27:53 -0700772 rm -f $(htmldocs).tar.gz $(manpages).tar.gz
Thomas Glanzmannca67f002005-05-22 20:27:28 +0200773 $(MAKE) -C Documentation/ clean
Junio C Hamano229a7ed2005-09-23 10:41:40 -0700774 $(MAKE) -C templates clean
Junio C Hamano4b7581f2005-08-02 17:24:11 -0700775 $(MAKE) -C t/ clean
Yakov Lernerca3bcab2006-06-15 01:36:00 +0300776 rm -f GIT-VERSION-FILE GIT-CFLAGS
Junio C Hamano9b88fce2005-12-27 14:40:17 -0800777
Junio C Hamano4dc00022006-01-12 21:42:25 -0800778.PHONY: all install clean strip
Yakov Lernerca3bcab2006-06-15 01:36:00 +0300779.PHONY: .FORCE-GIT-VERSION-FILE TAGS tags .FORCE-GIT-CFLAGS
Junio C Hamanod89056c2005-12-19 17:59:58 -0800780
Junio C Hamano8c989ec2006-04-13 00:17:19 -0700781### Check documentation
782#
783check-docs::
784 @for v in $(ALL_PROGRAMS) $(BUILT_INS) git$X gitk; \
785 do \
786 case "$$v" in \
Junio C Hamano8c989ec2006-04-13 00:17:19 -0700787 git-merge-octopus | git-merge-ours | git-merge-recursive | \
788 git-merge-resolve | git-merge-stupid | \
789 git-ssh-pull | git-ssh-push ) continue ;; \
790 esac ; \
791 test -f "Documentation/$$v.txt" || \
792 echo "no doc: $$v"; \
793 grep -q "^gitlink:$$v\[[0-9]\]::" Documentation/git.txt || \
794 case "$$v" in \
795 git) ;; \
796 *) echo "no link: $$v";; \
797 esac ; \
798 done | sort