blob: aa0618ed832e98bf520b9b4b6401b5951b208abc [file] [log] [blame]
Junio C Hamano2731d042005-12-01 12:26:41 -08001# The default target of this Makefile is...
2all:
3
Linus Torvalds765ac8e2006-02-28 15:07:20 -08004# Define NO_OPENSSL environment variable if you do not have OpenSSL.
5# This also implies MOZILLA_SHA1.
Petr Baudis5bdac8b2005-07-29 17:48:26 +02006#
Nick Hengeveld58e60dd2005-11-02 11:19:24 -08007# 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.
Johannes Schindelinb2c0bd62005-07-31 02:14:23 +020010#
Patrick Mauritz6d9bbc52005-09-19 16:11:19 +020011# Define CURLDIR=/foo/bar if your curl header and library files are in
12# /foo/bar/include and /foo/bar/lib directories.
13#
Nick Hengeveld58e60dd2005-11-02 11:19:24 -080014# 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#
Junio C Hamano35a730f2006-01-19 17:13:51 -080017# Define NO_D_INO_IN_DIRENT if you don't have d_ino in your struct dirent.
18#
Junio C Hamano63be37b2006-01-19 17:13:57 -080019# 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#
Linus Torvaldsef34af22005-09-18 18:30:50 -070022# Define NO_STRCASESTR if you don't have strcasestr.
23#
Peter Eriksen817151e2006-06-24 16:01:25 +020024# Define NO_STRLCPY if you don't have strlcpy.
25#
Jason Riedye40b61f2005-12-02 15:08:28 -080026# Define NO_SETENV if you don't have setenv in the C library.
27#
Junio C Hamano9f0bb902006-05-02 00:40:24 -070028# Define NO_SYMLINK_HEAD if you never want .git/HEAD to be a symbolic link.
29# Enable it on Windows. By default, symrefs are still used.
Pavel Roskin2fabd212005-11-15 00:59:50 -050030#
Petr Baudis5bdac8b2005-07-29 17:48:26 +020031# Define PPC_SHA1 environment variable when running make to make use of
32# a bundled SHA1 routine optimized for PowerPC.
Junio C Hamano597c9cc2005-09-07 12:22:56 -070033#
Nicolas Pitre7c6ef2f2005-09-20 12:27:13 -040034# Define ARM_SHA1 environment variable when running make to make use of
35# a bundled SHA1 routine optimized for ARM.
36#
Junio C Hamanof6af75d2006-06-23 17:57:48 -070037# Define MOZILLA_SHA1 environment variable when running make to make use of
38# a bundled SHA1 routine coming from Mozilla. It is GPL'd and should be fast
39# on non-x86 architectures (e.g. PowerPC), while the OpenSSL version (default
40# choice) has very fast version optimized for i586.
41#
42# Define USE_PIC if you need the main git objects to be built with -fPIC
43# in order to build and link perl/Git.so. x86-64 seems to need this.
44#
Junio C Hamano597c9cc2005-09-07 12:22:56 -070045# Define NEEDS_SSL_WITH_CRYPTO if you need -lcrypto with -lssl (Darwin).
Patrick Mauritzf0ebff02005-09-06 01:24:03 +020046#
Junio C Hamano597c9cc2005-09-07 12:22:56 -070047# Define NEEDS_LIBICONV if linking with libc is not enough (Darwin).
Patrick Mauritzf0ebff02005-09-06 01:24:03 +020048#
49# Define NEEDS_SOCKET if linking with libc is not enough (SunOS,
50# Patrick Mauritz).
51#
Johannes Schindelin730d48a2005-10-08 15:54:36 -070052# Define NO_MMAP if you want to avoid mmap.
53#
Junio C Hamano343d35c2005-09-19 19:47:54 -070054# Define WITH_OWN_SUBPROCESS_PY if you want to use with python 2.3.
55#
hpa49744d62005-09-28 16:52:21 -070056# Define NO_IPV6 if you lack IPv6 support and getaddrinfo().
57#
Junio C Hamanobdc37f52006-01-19 17:13:32 -080058# Define NO_SOCKADDR_STORAGE if your platform does not have struct
59# sockaddr_storage.
60#
Fernando J. Peredab6e56ec2006-02-16 09:38:01 +010061# Define NO_ICONV if your libc does not properly support iconv.
62#
Johannes Schindelin5b5d4d92006-02-17 15:23:16 +010063# Define NO_ACCURATE_DIFF if your diff program at least sometimes misses
64# a missing newline at the end of the file.
65#
Johannes Schindelinabb7c7b2006-02-18 13:01:18 +010066# Define NO_PYTHON if you want to loose all benefits of the recursive merge.
67#
Petr Baudis5bdac8b2005-07-29 17:48:26 +020068# Define COLLISION_CHECK below if you believe that SHA1's
Petr Baudis5c2a7fb2005-04-13 02:14:06 -070069# 1461501637330902918203684832716283019655932542976 hashes do not give you
Petr Baudis5bdac8b2005-07-29 17:48:26 +020070# sufficient guarantee that no collisions between objects will ever happen.
Junio C Hamanof6af75d2006-06-23 17:57:48 -070071#
Petr Baudis5bdac8b2005-07-29 17:48:26 +020072# Define USE_NSEC below if you want git to care about sub-second file mtimes
73# and ctimes. Note that you need recent glibc (at least 2.2.4) for this, and
74# it will BREAK YOUR LOCAL DIFFS! show-diff and anything using it will likely
75# randomly break unless your underlying filesystem supports those sub-second
76# times (my ext3 doesn't).
Junio C Hamanof6af75d2006-06-23 17:57:48 -070077#
Petr Baudis5bdac8b2005-07-29 17:48:26 +020078# Define USE_STDEV below if you want git to care about the underlying device
79# change being considered an inode change from the update-cache perspective.
80
Junio C Hamano9b88fce2005-12-27 14:40:17 -080081GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
Fredrik Kuivinen36546382006-02-14 00:15:14 +010082 @$(SHELL_PATH) ./GIT-VERSION-GEN
Junio C Hamano9b88fce2005-12-27 14:40:17 -080083-include GIT-VERSION-FILE
Petr Baudis5bdac8b2005-07-29 17:48:26 +020084
Paul Jakmae15f5452006-02-20 23:36:28 +000085uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
86uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not')
87uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')
88uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not')
89uname_P := $(shell sh -c 'uname -p 2>/dev/null || echo not')
90
Junio C Hamano94d23312005-11-13 01:46:13 -080091# CFLAGS and LDFLAGS are for the users to override from the command line.
Junio C Hamano12aa7452005-11-04 23:50:09 -080092
Pavel Roskinb05701c2005-08-06 01:36:15 -040093CFLAGS = -g -O2 -Wall
Junio C Hamano94d23312005-11-13 01:46:13 -080094LDFLAGS =
Junio C Hamano12aa7452005-11-04 23:50:09 -080095ALL_CFLAGS = $(CFLAGS)
Junio C Hamano94d23312005-11-13 01:46:13 -080096ALL_LDFLAGS = $(LDFLAGS)
Junio C Hamano4dc00022006-01-12 21:42:25 -080097STRIP ?= strip
Thomas Glanzmann29c2cce2005-05-07 10:41:54 +020098
Pavel Roskinb05701c2005-08-06 01:36:15 -040099prefix = $(HOME)
100bindir = $(prefix)/bin
Paul Jakmae15f5452006-02-20 23:36:28 +0000101gitexecdir = $(bindir)
Pavel Roskinb05701c2005-08-06 01:36:15 -0400102template_dir = $(prefix)/share/git-core/templates/
Junio C Hamano720d1502005-09-10 17:46:27 -0700103GIT_PYTHON_DIR = $(prefix)/share/git-core/python
Petr Baudisa682ef92005-08-05 01:56:38 +0200104# DESTDIR=
Petr Baudis5c2a7fb2005-04-13 02:14:06 -0700105
Pavel Roskinb05701c2005-08-06 01:36:15 -0400106CC = gcc
107AR = ar
Junio C Hamano229a7ed2005-09-23 10:41:40 -0700108TAR = tar
Pavel Roskinb05701c2005-08-06 01:36:15 -0400109INSTALL = install
110RPMBUILD = rpmbuild
Linus Torvaldse83c5162005-04-07 15:13:13 -0700111
Linus Torvalds44c9e852005-07-03 10:02:35 -0700112# sparse is architecture-neutral, which means that we need to tell it
113# explicitly what architecture to check for. Fix this up for yours..
Pavel Roskinb05701c2005-08-06 01:36:15 -0400114SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
Linus Torvalds44c9e852005-07-03 10:02:35 -0700115
Petr Baudis28818ff2005-07-29 17:50:24 +0200116
117
118### --- END CONFIGURATION SECTION ---
119
Junio C Hamano215a7ad2005-09-07 17:26:23 -0700120SCRIPT_SH = \
Linus Torvaldsc699f9b2006-05-17 21:21:04 -0700121 git-bisect.sh git-branch.sh git-checkout.sh \
Pavel Roskinc3b831b2006-04-05 02:00:48 -0400122 git-cherry.sh git-clean.sh git-clone.sh git-commit.sh \
Junio C Hamano230f5442006-05-03 23:54:34 -0700123 git-fetch.sh \
Junio C Hamano68563732006-05-21 02:48:21 -0700124 git-ls-remote.sh \
Junio C Hamanoe32faa82005-12-19 18:03:31 -0800125 git-merge-one-file.sh git-parse-remote.sh \
Junio C Hamano54eb2d32006-05-01 23:40:37 -0700126 git-prune.sh git-pull.sh git-rebase.sh \
Junio C Hamano215a7ad2005-09-07 17:26:23 -0700127 git-repack.sh git-request-pull.sh git-reset.sh \
Linus Torvaldsd9b814c2006-05-19 16:19:34 -0700128 git-resolve.sh git-revert.sh git-sh-setup.sh \
Junio C Hamano7b763f72006-05-01 23:14:58 -0700129 git-tag.sh git-verify-tag.sh \
Junio C Hamanod1c5f2a2005-10-07 03:44:18 -0700130 git-applymbox.sh git-applypatch.sh git-am.sh \
Junio C Hamano2276aa62005-09-10 17:56:19 -0700131 git-merge.sh git-merge-stupid.sh git-merge-octopus.sh \
Linus Torvalds63dffdf2006-05-16 16:46:31 -0700132 git-merge-resolve.sh git-merge-ours.sh \
Eric W. Biedermand3d8f362006-05-17 12:44:40 -0600133 git-lost-found.sh git-quiltimport.sh
Petr Baudis28818ff2005-07-29 17:50:24 +0200134
Junio C Hamano215a7ad2005-09-07 17:26:23 -0700135SCRIPT_PERL = \
136 git-archimport.perl git-cvsimport.perl git-relink.perl \
Junio C Hamano8389b522006-01-28 23:15:24 -0800137 git-shortlog.perl git-fmt-merge-msg.perl git-rerere.perl \
Junio C Hamano98214e92006-02-22 19:20:55 -0800138 git-annotate.perl git-cvsserver.perl \
Eric Wong15739c82006-05-14 19:26:56 -0700139 git-svnimport.perl git-mv.perl git-cvsexportcommit.perl \
140 git-send-email.perl
Junio C Hamano60036a42005-07-30 17:31:47 -0700141
Junio C Hamano720d1502005-09-10 17:46:27 -0700142SCRIPT_PYTHON = \
Fredrik Kuivinene4cf17c2005-09-13 08:22:26 +0200143 git-merge-recursive.py
Junio C Hamano720d1502005-09-10 17:46:27 -0700144
Andreas Ericssond6ebd252005-11-22 00:44:15 +0100145SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \
146 $(patsubst %.perl,%,$(SCRIPT_PERL)) \
147 $(patsubst %.py,%,$(SCRIPT_PYTHON)) \
Junio C Hamano7b763f72006-05-01 23:14:58 -0700148 git-cherry-pick git-status
Andreas Ericssond6ebd252005-11-22 00:44:15 +0100149
Junio C Hamano8eef8e02006-03-31 16:23:46 -0800150# The ones that do not have to link with lcrypto, lz nor xdiff.
Junio C Hamano597c9cc2005-09-07 12:22:56 -0700151SIMPLE_PROGRAMS = \
Lukas Sandström7499c992006-06-13 22:21:53 +0200152 git-daemon$X
Junio C Hamano597c9cc2005-09-07 12:22:56 -0700153
Junio C Hamanob42934d2006-01-12 21:37:17 -0800154# ... and all the rest that could be moved out of bindir to gitexecdir
Junio C Hamano215a7ad2005-09-07 17:26:23 -0700155PROGRAMS = \
Junio C Hamanoefc7fa52006-06-20 23:54:26 -0700156 git-checkout-index$X \
Peter Eriksene8cc9cd2006-05-23 14:15:36 +0200157 git-convert-objects$X git-fetch-pack$X git-fsck-objects$X \
Timo Hirvonenc3c88352006-05-19 13:03:57 +0300158 git-hash-object$X git-index-pack$X git-local-fetch$X \
Lukas Sandström34488e32006-06-13 22:21:50 +0200159 git-merge-base$X \
Junio C Hamano83f50532006-02-20 21:50:01 -0800160 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 +0200161 git-peek-remote$X git-prune-packed$X git-receive-pack$X \
Peter Eriksen51ce34b2006-05-23 14:15:35 +0200162 git-send-pack$X git-shell$X \
Peter Anvin79a9d8e2005-10-03 12:04:44 -0700163 git-show-index$X git-ssh-fetch$X \
Peter Eriksen56d13982006-05-23 14:15:31 +0200164 git-ssh-upload$X git-unpack-file$X \
Lukas Sandströmfefe81c2006-06-13 22:21:57 +0200165 git-unpack-objects$X git-update-server-info$X \
Lukas Sandström8ed05fb2006-06-13 22:21:42 +0200166 git-upload-pack$X git-verify-pack$X \
Lukas Sandström854b4622006-06-13 22:22:00 +0200167 git-symbolic-ref$X \
Linus Torvalds908e5312005-12-24 13:50:45 -0800168 git-name-rev$X git-pack-redundant$X git-repo-config$X git-var$X \
Mike McCormackf2561fd2006-03-10 14:32:50 +0900169 git-describe$X git-merge-tree$X git-blame$X git-imap-send$X
Andreas Ericssond6ebd252005-11-22 00:44:15 +0100170
Lukas Sandström854b4622006-06-13 22:22:00 +0200171BUILT_INS = git-log$X git-whatchanged$X git-show$X git-update-ref$X \
Lukas Sandströme690e842006-06-13 22:21:46 +0200172 git-count-objects$X git-diff$X git-push$X git-mailsplit$X \
Lukas Sandström7499c992006-06-13 22:21:53 +0200173 git-grep$X git-add$X git-rm$X git-rev-list$X git-stripspace$X \
Lukas Sandström34488e32006-06-13 22:21:50 +0200174 git-check-ref-format$X git-rev-parse$X git-mailinfo$X \
Junio C Hamano73f0a152006-05-24 12:19:47 -0700175 git-init-db$X git-tar-tree$X git-upload-tar$X git-format-patch$X \
Rene Scharfe52ba03c2006-06-10 16:13:41 +0200176 git-ls-files$X git-ls-tree$X git-get-tar-commit-id$X \
Lukas Sandström8ed05fb2006-06-13 22:21:42 +0200177 git-read-tree$X git-commit-tree$X git-write-tree$X \
Lukas Sandströmfefe81c2006-06-13 22:21:57 +0200178 git-apply$X git-show-branch$X git-diff-files$X git-update-index$X \
Timo Hirvonenf81daef2006-05-24 14:08:46 +0300179 git-diff-index$X git-diff-stages$X git-diff-tree$X git-cat-file$X
Junio C Hamano91730802006-04-10 17:37:58 -0700180
Junio C Hamanob42934d2006-01-12 21:37:17 -0800181# what 'all' will build and 'install' will install, in gitexecdir
Junio C Hamanof94fbbe2006-04-11 11:29:36 -0700182ALL_PROGRAMS = $(PROGRAMS) $(SIMPLE_PROGRAMS) $(SCRIPTS)
Linus Torvaldse83c5162005-04-07 15:13:13 -0700183
Junio C Hamano894a8a82005-09-30 00:27:11 -0700184# Backward compatibility -- to be removed after 1.0
H. Peter Anvin2f29dd52005-09-30 10:46:25 -0700185PROGRAMS += git-ssh-pull$X git-ssh-push$X
Junio C Hamanof71a69a2005-09-15 14:56:37 -0700186
Ryan Anderson3d320512005-11-21 00:11:22 -0500187# Set paths to tools early so that they can be used for version tests.
188ifndef SHELL_PATH
189 SHELL_PATH = /bin/sh
190endif
191ifndef PERL_PATH
192 PERL_PATH = /usr/bin/perl
193endif
194ifndef PYTHON_PATH
195 PYTHON_PATH = /usr/bin/python
196endif
197
Junio C Hamano720d1502005-09-10 17:46:27 -0700198PYMODULES = \
199 gitMergeCommon.py
200
Linus Torvalds0a02ce72005-04-18 12:49:39 -0700201LIB_FILE=libgit.a
Linus Torvalds34435462006-03-24 20:13:22 -0800202XDIFF_LIB=xdiff/lib.a
Linus Torvalds0a02ce72005-04-18 12:49:39 -0700203
Junio C Hamano215a7ad2005-09-07 17:26:23 -0700204LIB_H = \
Junio C Hamanof5948cf2006-03-04 02:51:19 -0800205 blob.h cache.h commit.h csum-file.h delta.h \
Linus Torvalds765ac8e2006-02-28 15:07:20 -0800206 diff.h object.h pack.h pkt-line.h quote.h refs.h \
Junio C Hamano1b0c7172006-03-29 22:55:43 -0800207 run-command.h strbuf.h tag.h tree.h git-compat-util.h revision.h \
Linus Torvalds453ec4b2006-05-16 19:02:14 -0700208 tree-walk.h log-tree.h dir.h
Junio C Hamano8f3f9b02005-07-23 17:54:41 -0700209
Junio C Hamano215a7ad2005-09-07 17:26:23 -0700210DIFF_OBJS = \
Junio C Hamano6973dca2006-04-21 23:57:45 -0700211 diff.o diff-lib.o diffcore-break.o diffcore-order.o \
Junio C Hamano65416752006-02-28 16:01:36 -0800212 diffcore-pickaxe.o diffcore-rename.o tree-diff.o combine-diff.o \
Junio C Hamano5f1c3f02006-04-09 01:11:11 -0700213 diffcore-delta.o log-tree.o
Josef Weidendorferb1bf95b2005-07-31 21:17:43 +0200214
Junio C Hamano215a7ad2005-09-07 17:26:23 -0700215LIB_OBJS = \
Junio C Hamano283c8ee2006-05-20 00:56:11 -0700216 blob.o commit.o connect.o csum-file.o cache-tree.o base85.o \
Junio C Hamano021b6e42006-06-06 12:51:49 -0700217 date.o diff-delta.o entry.o exec_cmd.o ident.o lockfile.o \
Junio C Hamano215a7ad2005-09-07 17:26:23 -0700218 object.o pack-check.o patch-delta.o path.o pkt-line.o \
Linus Torvalds3e4339e2006-06-18 11:45:02 -0700219 quote.o read-cache.o refs.o run-command.o dir.o object-refs.o \
Junio C Hamano215a7ad2005-09-07 17:26:23 -0700220 server-info.o setup.o sha1_file.o sha1_name.o strbuf.o \
Junio C Hamanof3123c42005-10-22 01:28:13 -0700221 tag.o tree.o usage.o config.o environment.o ctype.o copy.o \
Junio C Hamanod9ea73e2006-04-05 02:03:58 -0700222 fetch-clone.o revision.o pager.o tree-walk.o xdiff-interface.o \
Linus Torvalds855419f2006-06-19 10:44:15 -0700223 alloc.o $(DIFF_OBJS)
Junio C Hamanod19938a2005-05-09 17:57:56 -0700224
Linus Torvalds70827b12006-04-21 10:27:34 -0700225BUILTIN_OBJS = \
Junio C Hamanoefca5782006-05-15 18:12:06 -0700226 builtin-log.o builtin-help.o builtin-count.o builtin-diff.o builtin-push.o \
Linus Torvaldsd9b814c2006-05-19 16:19:34 -0700227 builtin-grep.o builtin-add.o builtin-rev-list.o builtin-check-ref-format.o \
Christian Couder895f10c2006-06-03 18:45:43 +0200228 builtin-rm.o builtin-init-db.o builtin-rev-parse.o \
Lukas Sandströmfefe81c2006-06-13 22:21:57 +0200229 builtin-tar-tree.o builtin-upload-tar.o builtin-update-index.o \
Lukas Sandström8ed05fb2006-06-13 22:21:42 +0200230 builtin-ls-files.o builtin-ls-tree.o builtin-write-tree.o \
Lukas Sandström34488e32006-06-13 22:21:50 +0200231 builtin-read-tree.o builtin-commit-tree.o builtin-mailinfo.o \
Peter Eriksene8cc9cd2006-05-23 14:15:36 +0200232 builtin-apply.o builtin-show-branch.o builtin-diff-files.o \
Timo Hirvonenf81daef2006-05-24 14:08:46 +0300233 builtin-diff-index.o builtin-diff-stages.o builtin-diff-tree.o \
Lukas Sandström854b4622006-06-13 22:22:00 +0200234 builtin-cat-file.o builtin-mailsplit.o builtin-stripspace.o \
235 builtin-update-ref.o
Linus Torvalds70827b12006-04-21 10:27:34 -0700236
Johannes Schindelin54c261f2006-03-27 01:14:52 +0200237GITLIBS = $(LIB_FILE) $(XDIFF_LIB)
238LIBS = $(GITLIBS) -lz
Linus Torvaldscef661f2005-04-21 12:33:22 -0700239
Junio C Hamano229a7ed2005-09-23 10:41:40 -0700240#
241# Platform specific tweaks
242#
Junio C Hamanof7c15342005-10-09 12:52:35 -0700243
244# We choose to avoid "if .. else if .. else .. endif endif"
245# because maintaining the nesting to match is a pain. If
246# we had "elif" things would have been much nicer...
Junio C Hamanof7c15342005-10-09 12:52:35 -0700247
Peter Eriksen817151e2006-06-24 16:01:25 +0200248ifeq ($(uname_S),Linux)
249 NO_STRLCPY = YesPlease
250endif
Junio C Hamanof7c15342005-10-09 12:52:35 -0700251ifeq ($(uname_S),Darwin)
Junio C Hamano597c9cc2005-09-07 12:22:56 -0700252 NEEDS_SSL_WITH_CRYPTO = YesPlease
253 NEEDS_LIBICONV = YesPlease
Peter Eriksen817151e2006-06-24 16:01:25 +0200254 NO_STRLCPY = YesPlease
Randal L. Schwartz0cfddac2005-11-06 04:33:07 -0800255 ## fink
Shawn Pearcee3601e82006-02-28 09:03:48 -0500256 ifeq ($(shell test -d /sw/lib && echo y),y)
257 ALL_CFLAGS += -I/sw/include
258 ALL_LDFLAGS += -L/sw/lib
259 endif
Randal L. Schwartz0cfddac2005-11-06 04:33:07 -0800260 ## darwinports
Shawn Pearcee3601e82006-02-28 09:03:48 -0500261 ifeq ($(shell test -d /opt/local/lib && echo y),y)
262 ALL_CFLAGS += -I/opt/local/include
263 ALL_LDFLAGS += -L/opt/local/lib
264 endif
Junio C Hamano597c9cc2005-09-07 12:22:56 -0700265endif
Junio C Hamanof7c15342005-10-09 12:52:35 -0700266ifeq ($(uname_S),SunOS)
Patrick Mauritzf0ebff02005-09-06 01:24:03 +0200267 NEEDS_SOCKET = YesPlease
Junio C Hamano5a90d4a2005-09-11 22:25:49 -0700268 NEEDS_NSL = YesPlease
Junio C Hamano229a7ed2005-09-23 10:41:40 -0700269 SHELL_PATH = /bin/bash
270 NO_STRCASESTR = YesPlease
Peter Eriksen817151e2006-06-24 16:01:25 +0200271 NO_STRLCPY = YesPlease
Jason Riedye40b61f2005-12-02 15:08:28 -0800272 ifeq ($(uname_R),5.8)
Paul Jakmae15f5452006-02-20 23:36:28 +0000273 NEEDS_LIBICONV = YesPlease
Jason Riedy731043f2006-01-25 12:38:36 -0800274 NO_UNSETENV = YesPlease
Jason Riedye40b61f2005-12-02 15:08:28 -0800275 NO_SETENV = YesPlease
276 endif
Dennis Stosberg40d88d42006-04-11 11:42:26 -0700277 ifeq ($(uname_R),5.9)
278 NO_UNSETENV = YesPlease
279 NO_SETENV = YesPlease
280 endif
Junio C Hamano229a7ed2005-09-23 10:41:40 -0700281 INSTALL = ginstall
282 TAR = gtar
Junio C Hamano12aa7452005-11-04 23:50:09 -0800283 ALL_CFLAGS += -D__EXTENSIONS__
Patrick Mauritzf0ebff02005-09-06 01:24:03 +0200284endif
Junio C Hamanof7c15342005-10-09 12:52:35 -0700285ifeq ($(uname_O),Cygwin)
Junio C Hamano63be37b2006-01-19 17:13:57 -0800286 NO_D_TYPE_IN_DIRENT = YesPlease
Junio C Hamano35a730f2006-01-19 17:13:51 -0800287 NO_D_INO_IN_DIRENT = YesPlease
hpa17754512005-09-28 16:37:37 -0700288 NO_STRCASESTR = YesPlease
Peter Eriksen817151e2006-06-24 16:01:25 +0200289 NO_STRLCPY = YesPlease
Junio C Hamano9f0bb902006-05-02 00:40:24 -0700290 NO_SYMLINK_HEAD = YesPlease
hpa17754512005-09-28 16:37:37 -0700291 NEEDS_LIBICONV = YesPlease
Junio C Hamano2e67a5f2005-11-17 11:29:47 -0800292 # There are conflicting reports about this.
293 # On some boxes NO_MMAP is needed, and not so elsewhere.
294 # Try uncommenting this if you see things break -- YMMV.
295 # NO_MMAP = YesPlease
hpa49744d62005-09-28 16:52:21 -0700296 NO_IPV6 = YesPlease
Peter Anvina23cd8e2005-09-28 19:08:37 -0700297 X = .exe
Nicolas Pitre7c6ef2f2005-09-20 12:27:13 -0400298endif
Alecs Kingb3bf9742006-01-27 02:04:30 +0800299ifeq ($(uname_S),FreeBSD)
300 NEEDS_LIBICONV = YesPlease
301 ALL_CFLAGS += -I/usr/local/include
302 ALL_LDFLAGS += -L/usr/local/lib
303endif
Junio C Hamanof7c15342005-10-09 12:52:35 -0700304ifeq ($(uname_S),OpenBSD)
Junio C Hamano5fb41e82005-10-10 11:51:11 -0700305 NO_STRCASESTR = YesPlease
Han Boetes18c5a522005-10-01 08:23:26 +0200306 NEEDS_LIBICONV = YesPlease
Junio C Hamano94d23312005-11-13 01:46:13 -0800307 ALL_CFLAGS += -I/usr/local/include
308 ALL_LDFLAGS += -L/usr/local/lib
309endif
310ifeq ($(uname_S),NetBSD)
Dennis Stosberge88856b2006-05-11 19:35:31 +0200311 ifeq ($(shell expr "$(uname_R)" : '[01]\.'),2)
312 NEEDS_LIBICONV = YesPlease
313 endif
Junio C Hamano94d23312005-11-13 01:46:13 -0800314 ALL_CFLAGS += -I/usr/pkg/include
315 ALL_LDFLAGS += -L/usr/pkg/lib -Wl,-rpath,/usr/pkg/lib
Han Boetes18c5a522005-10-01 08:23:26 +0200316endif
Jason Riedya6da9392005-12-06 14:20:16 -0800317ifeq ($(uname_S),AIX)
318 NO_STRCASESTR=YesPlease
Peter Eriksen817151e2006-06-24 16:01:25 +0200319 NO_STRLCPY = YesPlease
Jason Riedya6da9392005-12-06 14:20:16 -0800320 NEEDS_LIBICONV=YesPlease
321endif
Johannes Schindelin289c4b32006-02-17 15:23:41 +0100322ifeq ($(uname_S),IRIX64)
323 NO_IPV6=YesPlease
324 NO_SETENV=YesPlease
325 NO_STRCASESTR=YesPlease
Peter Eriksen817151e2006-06-24 16:01:25 +0200326 NO_STRLCPY = YesPlease
Johannes Schindelin289c4b32006-02-17 15:23:41 +0100327 NO_SOCKADDR_STORAGE=YesPlease
328 SHELL_PATH=/usr/gnu/bin/bash
329 ALL_CFLAGS += -DPATH_MAX=1024
330 # for now, build 32-bit version
331 ALL_LDFLAGS += -L/usr/lib32
332endif
Junio C Hamanof7c15342005-10-09 12:52:35 -0700333ifneq (,$(findstring arm,$(uname_M)))
334 ARM_SHA1 = YesPlease
335endif
Junio C Hamano597c9cc2005-09-07 12:22:56 -0700336
Johannes Schindelinf2d6a252005-10-11 15:22:47 -0700337-include config.mak
Linus Torvaldscef661f2005-04-21 12:33:22 -0700338
Timo Hirvonenb34403a2005-12-01 03:32:01 +0200339ifdef WITH_OWN_SUBPROCESS_PY
340 PYMODULES += compat/subprocess.py
341else
Johannes Schindelina348ab72006-02-19 21:13:48 +0100342 ifeq ($(NO_PYTHON),)
343 ifneq ($(shell $(PYTHON_PATH) -c 'import subprocess;print"OK"' 2>/dev/null),OK)
344 PYMODULES += compat/subprocess.py
345 endif
Timo Hirvonenb34403a2005-12-01 03:32:01 +0200346 endif
347endif
348
Junio C Hamano229a7ed2005-09-23 10:41:40 -0700349ifndef NO_CURL
350 ifdef CURLDIR
Junio C Hamano94d23312005-11-13 01:46:13 -0800351 # This is still problematic -- gcc does not always want -R.
Junio C Hamano12aa7452005-11-04 23:50:09 -0800352 ALL_CFLAGS += -I$(CURLDIR)/include
Junio C Hamano229a7ed2005-09-23 10:41:40 -0700353 CURL_LIBCURL = -L$(CURLDIR)/lib -R$(CURLDIR)/lib -lcurl
354 else
355 CURL_LIBCURL = -lcurl
356 endif
H. Peter Anvin2f29dd52005-09-30 10:46:25 -0700357 PROGRAMS += git-http-fetch$X
Nick Hengeveld08900982005-11-18 17:08:36 -0800358 curl_check := $(shell (echo 070908; curl-config --vernum) | sort -r | sed -ne 2p)
359 ifeq "$(curl_check)" "070908"
360 ifndef NO_EXPAT
Nick Hengeveld08900982005-11-18 17:08:36 -0800361 PROGRAMS += git-http-push$X
362 endif
Nick Hengeveld58e60dd2005-11-02 11:19:24 -0800363 endif
Johannes Schindelin459a21b2006-04-05 16:22:40 +0200364 ifndef NO_EXPAT
365 EXPAT_LIBEXPAT = -lexpat
366 endif
Junio C Hamano229a7ed2005-09-23 10:41:40 -0700367endif
368
Petr Baudisdd53c7a2005-07-29 17:50:51 +0200369ifndef NO_OPENSSL
Junio C Hamano215a7ad2005-09-07 17:26:23 -0700370 OPENSSL_LIBSSL = -lssl
Junio C Hamano455a7f32005-09-30 13:31:16 -0700371 ifdef OPENSSLDIR
372 # Again this may be problematic -- gcc does not always want -R.
Junio C Hamano12aa7452005-11-04 23:50:09 -0800373 ALL_CFLAGS += -I$(OPENSSLDIR)/include
Junio C Hamano455a7f32005-09-30 13:31:16 -0700374 OPENSSL_LINK = -L$(OPENSSLDIR)/lib -R$(OPENSSLDIR)/lib
375 else
376 OPENSSL_LINK =
377 endif
Petr Baudisdd53c7a2005-07-29 17:50:51 +0200378else
Junio C Hamano12aa7452005-11-04 23:50:09 -0800379 ALL_CFLAGS += -DNO_OPENSSL
Junio C Hamano215a7ad2005-09-07 17:26:23 -0700380 MOZILLA_SHA1 = 1
381 OPENSSL_LIBSSL =
Petr Baudisdd53c7a2005-07-29 17:50:51 +0200382endif
Junio C Hamano597c9cc2005-09-07 12:22:56 -0700383ifdef NEEDS_SSL_WITH_CRYPTO
Junio C Hamano455a7f32005-09-30 13:31:16 -0700384 LIB_4_CRYPTO = $(OPENSSL_LINK) -lcrypto -lssl
Junio C Hamano597c9cc2005-09-07 12:22:56 -0700385else
Junio C Hamano455a7f32005-09-30 13:31:16 -0700386 LIB_4_CRYPTO = $(OPENSSL_LINK) -lcrypto
Junio C Hamano597c9cc2005-09-07 12:22:56 -0700387endif
388ifdef NEEDS_LIBICONV
Junio C Hamano455a7f32005-09-30 13:31:16 -0700389 ifdef ICONVDIR
390 # Again this may be problematic -- gcc does not always want -R.
Junio C Hamano12aa7452005-11-04 23:50:09 -0800391 ALL_CFLAGS += -I$(ICONVDIR)/include
Junio C Hamano455a7f32005-09-30 13:31:16 -0700392 ICONV_LINK = -L$(ICONVDIR)/lib -R$(ICONVDIR)/lib
393 else
394 ICONV_LINK =
395 endif
Lukas Sandström34488e32006-06-13 22:21:50 +0200396 LIBS += $(ICONV_LINK) -liconv
Junio C Hamano597c9cc2005-09-07 12:22:56 -0700397endif
Patrick Mauritzf0ebff02005-09-06 01:24:03 +0200398ifdef NEEDS_SOCKET
399 LIBS += -lsocket
400 SIMPLE_LIB += -lsocket
401endif
Junio C Hamano5a90d4a2005-09-11 22:25:49 -0700402ifdef NEEDS_NSL
403 LIBS += -lnsl
404 SIMPLE_LIB += -lnsl
405endif
Junio C Hamano63be37b2006-01-19 17:13:57 -0800406ifdef NO_D_TYPE_IN_DIRENT
407 ALL_CFLAGS += -DNO_D_TYPE_IN_DIRENT
408endif
Junio C Hamano35a730f2006-01-19 17:13:51 -0800409ifdef NO_D_INO_IN_DIRENT
410 ALL_CFLAGS += -DNO_D_INO_IN_DIRENT
411endif
Junio C Hamano9f0bb902006-05-02 00:40:24 -0700412ifdef NO_SYMLINK_HEAD
413 ALL_CFLAGS += -DNO_SYMLINK_HEAD
414endif
Linus Torvaldsef34af22005-09-18 18:30:50 -0700415ifdef NO_STRCASESTR
Junio C Hamano4050c0d2005-12-05 11:54:29 -0800416 COMPAT_CFLAGS += -DNO_STRCASESTR
Jason Riedye40b61f2005-12-02 15:08:28 -0800417 COMPAT_OBJS += compat/strcasestr.o
418endif
Peter Eriksen817151e2006-06-24 16:01:25 +0200419ifdef NO_STRLCPY
420 COMPAT_CFLAGS += -DNO_STRLCPY
421 COMPAT_OBJS += compat/strlcpy.o
422endif
Jason Riedye40b61f2005-12-02 15:08:28 -0800423ifdef NO_SETENV
Junio C Hamano4050c0d2005-12-05 11:54:29 -0800424 COMPAT_CFLAGS += -DNO_SETENV
Jason Riedye40b61f2005-12-02 15:08:28 -0800425 COMPAT_OBJS += compat/setenv.o
Linus Torvaldsef34af22005-09-18 18:30:50 -0700426endif
Jason Riedy731043f2006-01-25 12:38:36 -0800427ifdef NO_SETENV
428 COMPAT_CFLAGS += -DNO_UNSETENV
429 COMPAT_OBJS += compat/unsetenv.o
430endif
Johannes Schindelin730d48a2005-10-08 15:54:36 -0700431ifdef NO_MMAP
Junio C Hamano4050c0d2005-12-05 11:54:29 -0800432 COMPAT_CFLAGS += -DNO_MMAP
Jason Riedye40b61f2005-12-02 15:08:28 -0800433 COMPAT_OBJS += compat/mmap.o
Johannes Schindelin730d48a2005-10-08 15:54:36 -0700434endif
hpa49744d62005-09-28 16:52:21 -0700435ifdef NO_IPV6
Junio C Hamanobdc37f52006-01-19 17:13:32 -0800436 ALL_CFLAGS += -DNO_IPV6
437endif
438ifdef NO_SOCKADDR_STORAGE
439ifdef NO_IPV6
440 ALL_CFLAGS += -Dsockaddr_storage=sockaddr_in
441else
442 ALL_CFLAGS += -Dsockaddr_storage=sockaddr_in6
443endif
hpa49744d62005-09-28 16:52:21 -0700444endif
Yakov Lerner6ba68ab2006-05-22 00:37:00 +0300445ifdef NO_INET_NTOP
446 LIB_OBJS += compat/inet_ntop.o
447endif
Linus Torvaldscef661f2005-04-21 12:33:22 -0700448
Fernando J. Peredab6e56ec2006-02-16 09:38:01 +0100449ifdef NO_ICONV
450 ALL_CFLAGS += -DNO_ICONV
451endif
452
Nicolas Pitre7c6ef2f2005-09-20 12:27:13 -0400453ifdef PPC_SHA1
454 SHA1_HEADER = "ppc/sha1.h"
455 LIB_OBJS += ppc/sha1.o ppc/sha1ppc.o
456else
457ifdef ARM_SHA1
458 SHA1_HEADER = "arm/sha1.h"
459 LIB_OBJS += arm/sha1.o arm/sha1_arm.o
460else
461ifdef MOZILLA_SHA1
462 SHA1_HEADER = "mozilla-sha1/sha1.h"
463 LIB_OBJS += mozilla-sha1/sha1.o
464else
465 SHA1_HEADER = <openssl/sha.h>
466 LIBS += $(LIB_4_CRYPTO)
467endif
468endif
469endif
Junio C Hamanof6af75d2006-06-23 17:57:48 -0700470ifdef USE_PIC
471 ALL_CFLAGS += -fPIC
472endif
Johannes Schindelin5b5d4d92006-02-17 15:23:16 +0100473ifdef NO_ACCURATE_DIFF
474 ALL_CFLAGS += -DNO_ACCURATE_DIFF
475endif
Nicolas Pitre7c6ef2f2005-09-20 12:27:13 -0400476
Johannes Schindelin39c015c2006-02-18 12:40:22 +0100477# Shell quote (do not use $(call) to accomodate ancient setups);
478
479SHA1_HEADER_SQ = $(subst ','\'',$(SHA1_HEADER))
480
481DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
482bindir_SQ = $(subst ','\'',$(bindir))
483gitexecdir_SQ = $(subst ','\'',$(gitexecdir))
484template_dir_SQ = $(subst ','\'',$(template_dir))
Yakov Lernerca3bcab2006-06-15 01:36:00 +0300485prefix_SQ = $(subst ','\'',$(prefix))
Johannes Schindelin39c015c2006-02-18 12:40:22 +0100486
487SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
488PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
489PYTHON_PATH_SQ = $(subst ','\'',$(PYTHON_PATH))
490GIT_PYTHON_DIR_SQ = $(subst ','\'',$(GIT_PYTHON_DIR))
491
492ALL_CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER_SQ)' $(COMPAT_CFLAGS)
Jason Riedye40b61f2005-12-02 15:08:28 -0800493LIB_OBJS += $(COMPAT_OBJS)
Tom Princeec2d1512005-10-11 18:47:33 -0700494export prefix TAR INSTALL DESTDIR SHELL_PATH template_dir
Petr Baudis28818ff2005-07-29 17:50:24 +0200495### Build rules
Linus Torvalds89967022005-04-30 13:19:56 -0700496
Junio C Hamanof94fbbe2006-04-11 11:29:36 -0700497all: $(ALL_PROGRAMS) $(BUILT_INS) git$X gitk
Petr Baudis28818ff2005-07-29 17:50:24 +0200498
Petr Baudisb1edc532006-06-24 04:34:29 +0200499all: perl/Makefile
500 $(MAKE) -C perl
Junio C Hamanod3af6212005-08-06 12:50:14 -0700501 $(MAKE) -C templates
Nicolas Pitrea310d432005-05-19 10:27:14 -0400502
Junio C Hamano4dc00022006-01-12 21:42:25 -0800503strip: $(PROGRAMS) git$X
504 $(STRIP) $(STRIP_OPTS) $(PROGRAMS) git$X
505
Yakov Lernerca3bcab2006-06-15 01:36:00 +0300506git$X: git.c common-cmds.h $(BUILTIN_OBJS) $(GITLIBS) GIT-CFLAGS
Michal Ostrowski77cb17e2006-01-10 21:12:17 -0500507 $(CC) -DGIT_VERSION='"$(GIT_VERSION)"' \
Junio C Hamano8eef8e02006-03-31 16:23:46 -0800508 $(ALL_CFLAGS) -o $@ $(filter %.c,$^) \
Linus Torvalds70827b12006-04-21 10:27:34 -0700509 $(BUILTIN_OBJS) $(ALL_LDFLAGS) $(LIBS)
Junio C Hamano6a2e50f2005-09-07 21:26:52 -0700510
Junio C Hamano08df6172006-04-21 21:56:13 -0700511builtin-help.o: common-cmds.h
512
Junio C Hamano91730802006-04-10 17:37:58 -0700513$(BUILT_INS): git$X
514 rm -f $@ && ln git$X $@
515
Fredrik Kuivinena87cd022006-03-09 17:24:19 +0100516common-cmds.h: Documentation/git-*.txt
Jim Meyeringfc36f6a2006-05-25 18:52:01 +0200517 ./generate-cmdlist.sh > $@+
518 mv $@+ $@
Fredrik Kuivinena87cd022006-03-09 17:24:19 +0100519
Andreas Ericssond6ebd252005-11-22 00:44:15 +0100520$(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
Jim Meyeringfc36f6a2006-05-25 18:52:01 +0200521 rm -f $@ $@+
Johannes Schindelin39c015c2006-02-18 12:40:22 +0100522 sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
Junio C Hamano3ff8cbe2005-10-04 12:41:35 -0700523 -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
Fernando J. Pereda6c5c62f2006-02-15 12:37:30 +0100524 -e 's/@@NO_CURL@@/$(NO_CURL)/g' \
Johannes Schindelinabb7c7b2006-02-18 13:01:18 +0100525 -e 's/@@NO_PYTHON@@/$(NO_PYTHON)/g' \
Jim Meyeringfc36f6a2006-05-25 18:52:01 +0200526 $@.sh >$@+
527 chmod +x $@+
528 mv $@+ $@
Junio C Hamanobc6146d2005-09-08 18:50:33 -0700529
530$(patsubst %.perl,%,$(SCRIPT_PERL)) : % : %.perl
Jim Meyeringfc36f6a2006-05-25 18:52:01 +0200531 rm -f $@ $@+
Petr Baudisb1edc532006-06-24 04:34:29 +0200532 sed -e '1s|#!.*perl\(.*\)|#!$(PERL_PATH_SQ)\1 -I'"$$(make -s -C perl instlibdir)"'|' \
Junio C Hamano3ff8cbe2005-10-04 12:41:35 -0700533 -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
Jim Meyeringfc36f6a2006-05-25 18:52:01 +0200534 $@.perl >$@+
535 chmod +x $@+
536 mv $@+ $@
Junio C Hamanobc6146d2005-09-08 18:50:33 -0700537
Yakov Lernerca3bcab2006-06-15 01:36:00 +0300538$(patsubst %.py,%,$(SCRIPT_PYTHON)) : % : %.py GIT-CFLAGS
Jim Meyeringfc36f6a2006-05-25 18:52:01 +0200539 rm -f $@ $@+
Johannes Schindelin39c015c2006-02-18 12:40:22 +0100540 sed -e '1s|#!.*python|#!$(PYTHON_PATH_SQ)|' \
541 -e 's|@@GIT_PYTHON_PATH@@|$(GIT_PYTHON_DIR_SQ)|g' \
Junio C Hamano3ff8cbe2005-10-04 12:41:35 -0700542 -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
Jim Meyeringfc36f6a2006-05-25 18:52:01 +0200543 $@.py >$@+
544 chmod +x $@+
545 mv $@+ $@
Junio C Hamano720d1502005-09-10 17:46:27 -0700546
Johannes Schindelin4eba0f32005-10-20 17:13:24 +0200547git-cherry-pick: git-revert
Jim Meyeringfc36f6a2006-05-25 18:52:01 +0200548 cp $< $@+
549 mv $@+ $@
Johannes Schindelin4eba0f32005-10-20 17:13:24 +0200550
Junio C Hamanocf7bb582006-02-10 00:45:59 -0800551git-status: git-commit
Jim Meyeringfc36f6a2006-05-25 18:52:01 +0200552 cp $< $@+
553 mv $@+ $@
Junio C Hamanocf7bb582006-02-10 00:45:59 -0800554
Junio C Hamano9b88fce2005-12-27 14:40:17 -0800555# These can record GIT_VERSION
556git$X git.spec \
557 $(patsubst %.sh,%,$(SCRIPT_SH)) \
558 $(patsubst %.perl,%,$(SCRIPT_PERL)) \
559 $(patsubst %.py,%,$(SCRIPT_PYTHON)) \
560 : GIT-VERSION-FILE
Johannes Schindeline99fcf92005-12-22 20:38:23 +0100561
Yakov Lernerca3bcab2006-06-15 01:36:00 +0300562%.o: %.c GIT-CFLAGS
Pavel Roskinb05701c2005-08-06 01:36:15 -0400563 $(CC) -o $*.o -c $(ALL_CFLAGS) $<
564%.o: %.S
565 $(CC) -o $*.o -c $(ALL_CFLAGS) $<
566
Yakov Lernerca3bcab2006-06-15 01:36:00 +0300567exec_cmd.o: exec_cmd.c GIT-CFLAGS
Johannes Schindelin39c015c2006-02-18 12:40:22 +0100568 $(CC) -o $*.o -c $(ALL_CFLAGS) '-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' $<
Yakov Lernerc1f80642006-06-22 04:47:00 +0300569builtin-init-db.o: builtin-init-db.c GIT-CFLAGS
570 $(CC) -o $*.o -c $(ALL_CFLAGS) -DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir_SQ)"' $<
Michal Ostrowski77cb17e2006-01-10 21:12:17 -0500571
Yakov Lernerca3bcab2006-06-15 01:36:00 +0300572http.o: http.c GIT-CFLAGS
Nick Hengeveld20fc9bc2006-04-04 10:11:29 -0700573 $(CC) -o $*.o -c $(ALL_CFLAGS) -DGIT_USER_AGENT='"git/$(GIT_VERSION)"' $<
574
Nick Hengeveld8d9fbe52006-04-04 05:33:18 -0700575ifdef NO_EXPAT
Yakov Lernerca3bcab2006-06-15 01:36:00 +0300576http-fetch.o: http-fetch.c http.h GIT-CFLAGS
Nick Hengeveld8d9fbe52006-04-04 05:33:18 -0700577 $(CC) -o $*.o -c $(ALL_CFLAGS) -DNO_EXPAT $<
578endif
579
Junio C Hamano8eef8e02006-03-31 16:23:46 -0800580git-%$X: %.o $(GITLIBS)
Junio C Hamano94d23312005-11-13 01:46:13 -0800581 $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
Daniel Barkalow6eb7ed52005-04-23 18:47:23 -0700582
Junio C Hamano597c9cc2005-09-07 12:22:56 -0700583$(SIMPLE_PROGRAMS) : $(LIB_FILE)
H. Peter Anvin2f29dd52005-09-30 10:46:25 -0700584$(SIMPLE_PROGRAMS) : git-%$X : %.o
Junio C Hamano94d23312005-11-13 01:46:13 -0800585 $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
586 $(LIB_FILE) $(SIMPLE_LIB)
Junio C Hamano597c9cc2005-09-07 12:22:56 -0700587
H. Peter Anvin2f29dd52005-09-30 10:46:25 -0700588git-local-fetch$X: fetch.o
589git-ssh-fetch$X: rsh.o fetch.o
590git-ssh-upload$X: rsh.o
591git-ssh-pull$X: rsh.o fetch.o
592git-ssh-push$X: rsh.o
Daniel Barkalow6eb7ed52005-04-23 18:47:23 -0700593
Mike McCormackf2561fd2006-03-10 14:32:50 +0900594git-imap-send$X: imap-send.o $(LIB_FILE)
595
Junio C Hamanodd8239f2006-06-06 14:26:57 -0700596http.o http-fetch.o http-push.o: http.h
Johannes Schindelinb9929332006-02-21 13:08:21 +0100597git-http-fetch$X: fetch.o http.o http-fetch.o $(LIB_FILE)
Johannes Schindelin39c015c2006-02-18 12:40:22 +0100598 $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
Nick Hengeveld8d9fbe52006-04-04 05:33:18 -0700599 $(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
Johannes Schindelin39c015c2006-02-18 12:40:22 +0100600
Nick Hengeveldaa1dbc92006-03-07 16:13:20 -0800601git-http-push$X: revision.o http.o http-push.o $(LIB_FILE)
Johannes Schindelin39c015c2006-02-18 12:40:22 +0100602 $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
603 $(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
604
Linus Torvalds70827b12006-04-21 10:27:34 -0700605$(LIB_OBJS) $(BUILTIN_OBJS): $(LIB_H)
Junio C Hamano1f330262006-06-22 15:43:47 -0700606$(patsubst git-%$X,%.o,$(PROGRAMS)): $(LIB_H) $(wildcard */*.h)
Petr Baudise4683052005-07-29 17:48:50 +0200607$(DIFF_OBJS): diffcore.h
Linus Torvaldse83c5162005-04-07 15:13:13 -0700608
Petr Baudis28818ff2005-07-29 17:50:24 +0200609$(LIB_FILE): $(LIB_OBJS)
Junio C Hamano71459c12006-04-25 23:11:17 -0700610 rm -f $@ && $(AR) rcs $@ $(LIB_OBJS)
Petr Baudis28818ff2005-07-29 17:50:24 +0200611
Linus Torvalds34435462006-03-24 20:13:22 -0800612XDIFF_OBJS=xdiff/xdiffi.o xdiff/xprepare.o xdiff/xutils.o xdiff/xemit.o
613
614$(XDIFF_LIB): $(XDIFF_OBJS)
Junio C Hamano2d86d2c2006-04-26 03:12:58 -0700615 rm -f $@ && $(AR) rcs $@ $(XDIFF_OBJS)
Linus Torvalds34435462006-03-24 20:13:22 -0800616
617
Petr Baudisb1edc532006-06-24 04:34:29 +0200618perl/Makefile: perl/Git.pm perl/Makefile.PL
Petr Baudis63df97a2006-06-24 04:34:36 +0200619 (cd perl && $(PERL_PATH) Makefile.PL \
620 PREFIX="$(prefix)" \
621 DEFINE="$(ALL_CFLAGS) -DGIT_VERSION=\\\"$(GIT_VERSION)\\\"" \
622 LIBS="$(LIBS)")
Petr Baudisb1edc532006-06-24 04:34:29 +0200623
Petr Baudis28818ff2005-07-29 17:50:24 +0200624doc:
625 $(MAKE) -C Documentation all
626
Fredrik Kuivinenf81e7c62006-03-18 11:07:12 +0100627TAGS:
628 rm -f TAGS
629 find . -name '*.[hcS]' -print | xargs etags -a
630
631tags:
632 rm -f tags
633 find . -name '*.[hcS]' -print | xargs ctags -a
Petr Baudis28818ff2005-07-29 17:50:24 +0200634
Yakov Lernerca3bcab2006-06-15 01:36:00 +0300635### Detect prefix changes
Junio C Hamanobbc932c2006-06-22 02:04:27 -0700636TRACK_CFLAGS = $(subst ','\'',$(ALL_CFLAGS)):$(GIT_PYTHON_DIR_SQ):\
Yakov Lernerca3bcab2006-06-15 01:36:00 +0300637 $(bindir_SQ):$(gitexecdir_SQ):$(template_dir_SQ):$(prefix_SQ)
638
639GIT-CFLAGS: .FORCE-GIT-CFLAGS
640 @FLAGS='$(TRACK_CFLAGS)'; \
641 if test x"$$FLAGS" != x"`cat GIT-CFLAGS 2>/dev/null`" ; then \
642 echo 1>&2 " * new build flags or prefix"; \
643 echo "$$FLAGS" >GIT-CFLAGS; \
644 fi
645
Petr Baudis28818ff2005-07-29 17:50:24 +0200646### Testing rules
647
Johannes Schindelinabb7c7b2006-02-18 13:01:18 +0100648# GNU make supports exporting all variables by "export" without parameters.
649# However, the environment gets quite big, and some programs have problems
650# with that.
651
652export NO_PYTHON
653
Petr Baudis28818ff2005-07-29 17:50:24 +0200654test: all
655 $(MAKE) -C t/ all
656
Junio C Hamano4ccafd72005-11-02 12:01:06 -0800657test-date$X: test-date.c date.o ctype.o
Junio C Hamano94d23312005-11-13 01:46:13 -0800658 $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) test-date.c date.o ctype.o
Petr Baudis28818ff2005-07-29 17:50:24 +0200659
H. Peter Anvin2f29dd52005-09-30 10:46:25 -0700660test-delta$X: test-delta.c diff-delta.o patch-delta.o
Nicolas Pitre3dc5a9e2006-04-29 00:58:05 -0400661 $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $^
Petr Baudis28818ff2005-07-29 17:50:24 +0200662
Junio C Hamano17448202006-04-23 20:20:25 -0700663test-dump-cache-tree$X: dump-cache-tree.o $(GITLIBS)
664 $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
665
Petr Baudis28818ff2005-07-29 17:50:24 +0200666check:
Junio C Hamano773b6332005-12-14 13:32:52 -0800667 for i in *.c; do sparse $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i || exit; done
Petr Baudis28818ff2005-07-29 17:50:24 +0200668
669
670
671### Installation rules
672
Andreas Ericssond6ebd252005-11-22 00:44:15 +0100673install: all
Johannes Schindelin39c015c2006-02-18 12:40:22 +0100674 $(INSTALL) -d -m755 '$(DESTDIR_SQ)$(bindir_SQ)'
675 $(INSTALL) -d -m755 '$(DESTDIR_SQ)$(gitexecdir_SQ)'
676 $(INSTALL) $(ALL_PROGRAMS) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
677 $(INSTALL) git$X gitk '$(DESTDIR_SQ)$(bindir_SQ)'
Junio C Hamano8d5afef2005-08-02 16:45:21 -0700678 $(MAKE) -C templates install
Petr Baudisb1edc532006-06-24 04:34:29 +0200679 $(MAKE) -C perl install
Johannes Schindelin39c015c2006-02-18 12:40:22 +0100680 $(INSTALL) -d -m755 '$(DESTDIR_SQ)$(GIT_PYTHON_DIR_SQ)'
681 $(INSTALL) $(PYMODULES) '$(DESTDIR_SQ)$(GIT_PYTHON_DIR_SQ)'
Sean7f7e6ea2006-05-22 00:42:59 -0400682 if test 'z$(bindir_SQ)' != 'z$(gitexecdir_SQ)'; \
683 then \
684 ln -f '$(DESTDIR_SQ)$(bindir_SQ)/git$X' \
685 '$(DESTDIR_SQ)$(gitexecdir_SQ)/git$X' || \
686 cp '$(DESTDIR_SQ)$(bindir_SQ)/git$X' \
687 '$(DESTDIR_SQ)$(gitexecdir_SQ)/git$X'; \
688 fi
689 $(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 +0200690
691install-doc:
692 $(MAKE) -C Documentation install
693
694
695
696
697### Maintainer's dist rules
698
Junio C Hamano9b88fce2005-12-27 14:40:17 -0800699git.spec: git.spec.in
Jim Meyeringfc36f6a2006-05-25 18:52:01 +0200700 sed -e 's/@@VERSION@@/$(GIT_VERSION)/g' < $< > $@+
701 mv $@+ $@
Chris Wrighta9db2972005-07-07 13:09:50 -0700702
Junio C Hamano27dedf02005-11-16 21:32:44 -0800703GIT_TARNAME=git-$(GIT_VERSION)
704dist: git.spec git-tar-tree
Rene Scharfe9cd625b2006-06-18 15:25:33 +0200705 ./git-tar-tree HEAD^{tree} $(GIT_TARNAME) > $(GIT_TARNAME).tar
Chris Wrighta9db2972005-07-07 13:09:50 -0700706 @mkdir -p $(GIT_TARNAME)
Junio C Hamano27dedf02005-11-16 21:32:44 -0800707 @cp git.spec $(GIT_TARNAME)
H. Peter Anvin181129d2006-01-09 18:07:01 -0800708 @echo $(GIT_VERSION) > $(GIT_TARNAME)/version
709 $(TAR) rf $(GIT_TARNAME).tar \
710 $(GIT_TARNAME)/git.spec $(GIT_TARNAME)/version
Chris Wrighta9db2972005-07-07 13:09:50 -0700711 @rm -rf $(GIT_TARNAME)
Eric W. Biederman9dce3c02005-07-14 19:20:50 -0600712 gzip -f -9 $(GIT_TARNAME).tar
Chris Wrighta9db2972005-07-07 13:09:50 -0700713
714rpm: dist
Junio C Hamano27dedf02005-11-16 21:32:44 -0800715 $(RPMBUILD) -ta $(GIT_TARNAME).tar.gz
Chris Wrighta9db2972005-07-07 13:09:50 -0700716
Tilman Sauerbeck52db0492006-05-18 12:57:04 +0200717htmldocs = git-htmldocs-$(GIT_VERSION)
718manpages = git-manpages-$(GIT_VERSION)
719dist-doc:
720 rm -fr .doc-tmp-dir
721 mkdir .doc-tmp-dir
722 $(MAKE) -C Documentation WEBDOC_DEST=../.doc-tmp-dir install-webdoc
723 cd .doc-tmp-dir && $(TAR) cf ../$(htmldocs).tar .
724 gzip -n -9 -f $(htmldocs).tar
725 :
726 rm -fr .doc-tmp-dir
727 mkdir .doc-tmp-dir .doc-tmp-dir/man1 .doc-tmp-dir/man7
Martin Waitzc5360322006-05-25 14:37:46 +0200728 $(MAKE) -C Documentation DESTDIR=./ \
Tilman Sauerbeck52db0492006-05-18 12:57:04 +0200729 man1=../.doc-tmp-dir/man1 \
730 man7=../.doc-tmp-dir/man7 \
731 install
732 cd .doc-tmp-dir && $(TAR) cf ../$(manpages).tar .
733 gzip -n -9 -f $(manpages).tar
734 rm -fr .doc-tmp-dir
735
Petr Baudis28818ff2005-07-29 17:50:24 +0200736### Cleaning rules
Eric W. Biederman87a81c82005-07-14 19:21:57 -0600737
Linus Torvaldse83c5162005-04-07 15:13:13 -0700738clean:
Junio C Hamano3467fec2006-03-26 23:41:22 -0800739 rm -f *.o mozilla-sha1/*.o arm/*.o ppc/*.o compat/*.o xdiff/*.o \
740 $(LIB_FILE) $(XDIFF_LIB)
A Large Angry SCMe6bfaf32006-04-16 20:17:38 -0700741 rm -f $(ALL_PROGRAMS) $(BUILT_INS) git$X
Fredrik Kuivinenf81e7c62006-03-18 11:07:12 +0100742 rm -f *.spec *.pyc *.pyo */*.pyc */*.pyo common-cmds.h TAGS tags
Tilman Sauerbeck52db0492006-05-18 12:57:04 +0200743 rm -rf $(GIT_TARNAME) .doc-tmp-dir
Junio C Hamano5a571cd2005-08-12 01:03:07 -0700744 rm -f $(GIT_TARNAME).tar.gz git-core_$(GIT_VERSION)-*.tar.gz
Junio C Hamano9dc21642006-06-07 12:27:53 -0700745 rm -f $(htmldocs).tar.gz $(manpages).tar.gz
Thomas Glanzmannca67f002005-05-22 20:27:28 +0200746 $(MAKE) -C Documentation/ clean
Petr Baudisb1edc532006-06-24 04:34:29 +0200747 [ ! -e perl/Makefile ] || $(MAKE) -C perl/ clean
748 $(MAKE) -C templates/ clean
Junio C Hamano4b7581f2005-08-02 17:24:11 -0700749 $(MAKE) -C t/ clean
Yakov Lernerca3bcab2006-06-15 01:36:00 +0300750 rm -f GIT-VERSION-FILE GIT-CFLAGS
Junio C Hamano9b88fce2005-12-27 14:40:17 -0800751
Junio C Hamano4dc00022006-01-12 21:42:25 -0800752.PHONY: all install clean strip
Yakov Lernerca3bcab2006-06-15 01:36:00 +0300753.PHONY: .FORCE-GIT-VERSION-FILE TAGS tags .FORCE-GIT-CFLAGS
Junio C Hamanod89056c2005-12-19 17:59:58 -0800754
Junio C Hamano8c989ec2006-04-13 00:17:19 -0700755### Check documentation
756#
757check-docs::
758 @for v in $(ALL_PROGRAMS) $(BUILT_INS) git$X gitk; \
759 do \
760 case "$$v" in \
Junio C Hamano8c989ec2006-04-13 00:17:19 -0700761 git-merge-octopus | git-merge-ours | git-merge-recursive | \
762 git-merge-resolve | git-merge-stupid | \
763 git-ssh-pull | git-ssh-push ) continue ;; \
764 esac ; \
765 test -f "Documentation/$$v.txt" || \
766 echo "no doc: $$v"; \
767 grep -q "^gitlink:$$v\[[0-9]\]::" Documentation/git.txt || \
768 case "$$v" in \
769 git) ;; \
770 *) echo "no link: $$v";; \
771 esac ; \
772 done | sort