Makefile 34.2 KB
Newer Older
1
# The default target of this Makefile is...
2
all::
3

S
Shawn O. Pearce 已提交
4
# Define V=1 to have a more verbose compile.
5
#
6 7 8
# Define FREAD_READS_DIRECTORIES if your are on a system which succeeds
# when attempting to read from an fopen'ed directory.
#
9 10
# Define NO_OPENSSL environment variable if you do not have OpenSSL.
# This also implies MOZILLA_SHA1.
11
#
12 13 14
# Define NO_CURL if you do not have curl installed.  git-http-pull and
# git-http-push are not built, and you cannot use http:// and https://
# transports.
15
#
P
Patrick Mauritz 已提交
16 17 18
# Define CURLDIR=/foo/bar if your curl header and library files are in
# /foo/bar/include and /foo/bar/lib directories.
#
19 20 21
# Define NO_EXPAT if you do not have expat installed.  git-http-push is
# not built, and you cannot push using http:// and https:// transports.
#
22 23
# Define NO_D_INO_IN_DIRENT if you don't have d_ino in your struct dirent.
#
24 25 26
# Define NO_D_TYPE_IN_DIRENT if your platform defines DT_UNKNOWN but lacks
# d_type in struct dirent (latest Cygwin -- will be fixed soonish).
#
27 28 29
# Define NO_C99_FORMAT if your formatted IO functions (printf/scanf et.al.)
# do not support the 'size specifiers' introduced by C99, namely ll, hh,
# j, z, t. (representing long long int, char, intmax_t, size_t, ptrdiff_t).
30
# some C compilers supported these specifiers prior to C99 as an extension.
31
#
32 33
# Define NO_STRCASESTR if you don't have strcasestr.
#
R
René Scharfe 已提交
34 35
# Define NO_MEMMEM if you don't have memmem.
#
36 37
# Define NO_STRLCPY if you don't have strlcpy.
#
38 39 40 41
# Define NO_STRTOUMAX if you don't have strtoumax in the C library.
# If your compiler also does not support long long or does not have
# strtoull, define NO_STRTOULL.
#
J
Jason Riedy 已提交
42 43
# Define NO_SETENV if you don't have setenv in the C library.
#
44 45
# Define NO_UNSETENV if you don't have unsetenv in the C library.
#
46 47
# Define NO_MKDTEMP if you don't have mkdtemp in the C library.
#
48 49
# Define NO_SYS_SELECT_H if you don't have sys/select.h.
#
50 51
# Define NO_SYMLINK_HEAD if you never want .git/HEAD to be a symbolic link.
# Enable it on Windows.  By default, symrefs are still used.
52
#
P
Pavel Roskin 已提交
53
# Define NO_SVN_TESTS if you want to skip time-consuming SVN interoperability
E
Eric Wong 已提交
54 55 56
# tests.  These tests take up a significant amount of the total test time
# but are not needed unless you plan to talk to SVN repos.
#
57 58 59 60 61 62 63 64 65 66 67 68
# Define NO_FINK if you are building on Darwin/Mac OS X, have Fink
# installed in /sw, but don't want GIT to link against any libraries
# installed there.  If defined you may specify your own (or Fink's)
# include directories and library directories by defining CFLAGS
# and LDFLAGS appropriately.
#
# Define NO_DARWIN_PORTS if you are building on Darwin/Mac OS X,
# have DarwinPorts installed in /opt/local, but don't want GIT to
# link against any libraries installed there.  If defined you may
# specify your own (or DarwinPort's) include directories and
# library directories by defining CFLAGS and LDFLAGS appropriately.
#
69 70
# Define PPC_SHA1 environment variable when running make to make use of
# a bundled SHA1 routine optimized for PowerPC.
71
#
72 73 74
# Define ARM_SHA1 environment variable when running make to make use of
# a bundled SHA1 routine optimized for ARM.
#
75 76 77 78 79
# Define MOZILLA_SHA1 environment variable when running make to make use of
# a bundled SHA1 routine coming from Mozilla. It is GPL'd and should be fast
# on non-x86 architectures (e.g. PowerPC), while the OpenSSL version (default
# choice) has very fast version optimized for i586.
#
80
# Define NEEDS_SSL_WITH_CRYPTO if you need -lcrypto with -lssl (Darwin).
81
#
82
# Define NEEDS_LIBICONV if linking with libc is not enough (Darwin).
83 84 85 86
#
# Define NEEDS_SOCKET if linking with libc is not enough (SunOS,
# Patrick Mauritz).
#
87 88
# Define NO_MMAP if you want to avoid mmap.
#
89 90 91
# Define NO_PREAD if you have a problem with pread() system call (e.g.
# cygwin.dll before v1.5.22).
#
92 93 94
# Define NO_FAST_WORKING_DIRECTORY if accessing objects in pack files is
# generally faster on your platform than accessing the working directory.
#
95 96 97
# Define NO_TRUSTABLE_FILEMODE if your filesystem may claim to support
# the executable mode bit, but doesn't really do so.
#
98 99
# Define NO_IPV6 if you lack IPv6 support and getaddrinfo().
#
100 101 102
# Define NO_SOCKADDR_STORAGE if your platform does not have struct
# sockaddr_storage.
#
103 104
# Define NO_ICONV if your libc does not properly support iconv.
#
105 106 107
# Define OLD_ICONV if your library has an old iconv(), where the second
# (input buffer pointer) parameter is declared with type (const char **).
#
108 109
# Define NO_DEFLATE_BOUND if your zlib does not have deflateBound.
#
110 111 112
# Define NO_R_TO_GCC_LINKER if your gcc does not like "-R/path/lib"
# that tells runtime paths to dynamic libraries;
# "-Wl,-rpath=/path/lib" is used instead.
113
#
114 115 116 117 118
# Define USE_NSEC below if you want git to care about sub-second file mtimes
# and ctimes. Note that you need recent glibc (at least 2.2.4) for this, and
# it will BREAK YOUR LOCAL DIFFS! show-diff and anything using it will likely
# randomly break unless your underlying filesystem supports those sub-second
# times (my ext3 doesn't).
119
#
120
# Define USE_STDEV below if you want git to care about the underlying device
121
# change being considered an inode change from the update-index perspective.
122
#
123 124
# Define ASCIIDOC8 if you want to format documentation with AsciiDoc 8
#
125 126
# Define DOCBOOK_XSL_172 if you want to format man pages with DocBook XSL v1.72.
#
127 128 129
# Define NO_PERL_MAKEMAKER if you cannot use Makefiles generated by perl's
# MakeMaker (e.g. using ActiveState under Cygwin).
#
E
Eygene Ryabinkin 已提交
130 131
# Define NO_TCLTK if you do not want Tcl/Tk GUI.
#
132 133 134 135 136
# The TCL_PATH variable governs the location of the Tcl interpreter
# used to optimize git-gui for your system.  Only used if NO_TCLTK
# is not set.  Defaults to the bare 'tclsh'.
#
# The TCLTK_PATH variable governs the location of the Tcl/Tk interpreter.
137 138 139
# If not set it defaults to the bare 'wish'. If it is set to the empty
# string then NO_TCLTK will be forced (this is used by configure script).
#
N
Nicolas Pitre 已提交
140 141 142
# Define THREADED_DELTA_SEARCH if you have pthreads and wish to exploit
# parallel delta searching when packing objects.
#
143 144 145 146
# Define INTERNAL_QSORT to use Git's implementation of qsort(), which
# is a simplified version of the merge sort used in glibc. This is
# recommended if Git triggers O(n^2) behavior in your platform's qsort().
#
147

148
GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
149
	@$(SHELL_PATH) ./GIT-VERSION-GEN
150
-include GIT-VERSION-FILE
151

152 153 154 155 156 157
uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not')
uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')
uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not')
uname_P := $(shell sh -c 'uname -p 2>/dev/null || echo not')

J
Junio C Hamano 已提交
158
# CFLAGS and LDFLAGS are for the users to override from the command line.
159

160
CFLAGS = -g -O2 -Wall
J
Junio C Hamano 已提交
161
LDFLAGS =
162
ALL_CFLAGS = $(CFLAGS)
J
Junio C Hamano 已提交
163
ALL_LDFLAGS = $(LDFLAGS)
J
Junio C Hamano 已提交
164
STRIP ?= strip
165

166 167
prefix = $(HOME)
bindir = $(prefix)/bin
168
mandir = $(prefix)/share/man
169
infodir = $(prefix)/share/info
170
gitexecdir = $(bindir)
171
sharedir = $(prefix)/share
172
template_dir = $(sharedir)/git-core/templates
173
htmldir=$(sharedir)/doc/git-doc
174 175 176 177 178
ifeq ($(prefix),/usr)
sysconfdir = /etc
else
sysconfdir = $(prefix)/etc
endif
179
lib = lib
180
ETC_GITCONFIG = $(sysconfdir)/gitconfig
181
# DESTDIR=
182

183
# default configuration for gitweb
184
GITWEB_CONFIG = gitweb_config.perl
185
GITWEB_HOME_LINK_STR = projects
186 187
GITWEB_SITENAME =
GITWEB_PROJECTROOT = /pub/git
188
GITWEB_PROJECT_MAXDEPTH = 2007
M
Matthias Lederhofer 已提交
189 190
GITWEB_EXPORT_OK =
GITWEB_STRICT_EXPORT =
191
GITWEB_BASE_URL =
192 193 194
GITWEB_LIST =
GITWEB_HOMETEXT = indextext.html
GITWEB_CSS = gitweb.css
M
Martin Waitz 已提交
195
GITWEB_LOGO = git-logo.png
196
GITWEB_FAVICON = git-favicon.png
197 198
GITWEB_SITE_HEADER =
GITWEB_SITE_FOOTER =
199

200
export prefix bindir gitexecdir sharedir template_dir htmldir sysconfdir
201

202 203
CC = gcc
AR = ar
204
RM = rm -f
205
TAR = tar
206
FIND = find
207 208
INSTALL = install
RPMBUILD = rpmbuild
209
TCL_PATH = tclsh
210
TCLTK_PATH = wish
211

212 213
export TCL_PATH TCLTK_PATH

214 215
# sparse is architecture-neutral, which means that we need to tell it
# explicitly what architecture to check for. Fix this up for yours..
216
SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
217

P
Petr Baudis 已提交
218 219 220 221


### --- END CONFIGURATION SECTION ---

222
# Those must not be GNU-specific; they are shared with perl/ which may
P
Petr Baudis 已提交
223 224 225 226
# be built by a different compiler. (Note that this is an artifact now
# but it still might be nice to keep that distinction.)
BASIC_CFLAGS =
BASIC_LDFLAGS =
227

J
Junio C Hamano 已提交
228
SCRIPT_SH = \
L
Lars Hjemli 已提交
229
	git-bisect.sh git-checkout.sh \
J
Junio C Hamano 已提交
230
	git-clone.sh \
231
	git-merge-one-file.sh git-mergetool.sh git-parse-remote.sh \
232
	git-pull.sh git-rebase.sh git-rebase--interactive.sh \
C
Carlos Rica 已提交
233
	git-repack.sh git-request-pull.sh \
234
	git-sh-setup.sh \
J
Junio C Hamano 已提交
235
	git-am.sh \
236
	git-merge.sh git-merge-stupid.sh git-merge-octopus.sh \
237
	git-merge-resolve.sh \
J
Johannes Schindelin 已提交
238
	git-lost-found.sh git-quiltimport.sh git-submodule.sh \
しらいしななこ 已提交
239
	git-filter-branch.sh \
240
	git-stash.sh \
241
	git-web--browse.sh
J
Junio C Hamano 已提交
242 243

SCRIPT_PERL = \
J
Junio C Hamano 已提交
244
	git-add--interactive.perl \
J
Junio C Hamano 已提交
245
	git-archimport.perl git-cvsimport.perl git-relink.perl \
246
	git-cvsserver.perl git-remote.perl git-cvsexportcommit.perl \
E
Eric Wong 已提交
247
	git-send-email.perl git-svn.perl
248

249 250
SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \
	  $(patsubst %.perl,%,$(SCRIPT_PERL)) \
251
	  git-instaweb
252

J
Junio C Hamano 已提交
253
# ... and all the rest that could be moved out of bindir to gitexecdir
J
Junio C Hamano 已提交
254
PROGRAMS = \
M
Matt Kraai 已提交
255
	git-fetch-pack$X \
D
Daniel Barkalow 已提交
256
	git-hash-object$X git-index-pack$X \
257
	git-fast-import$X \
258
	git-daemon$X \
259
	git-merge-index$X git-mktag$X git-mktree$X git-patch-id$X \
260
	git-receive-pack$X \
P
Peter Eriksen 已提交
261
	git-send-pack$X git-shell$X \
D
Daniel Barkalow 已提交
262 263
	git-show-index$X \
	git-unpack-file$X \
264
	git-update-server-info$X \
265
	git-upload-pack$X \
266
	git-pack-redundant$X git-var$X \
S
Shawn O. Pearce 已提交
267
	git-merge-tree$X git-imap-send$X \
J
Junio C Hamano 已提交
268
	git-merge-recursive$X \
269 270 271 272
	$(EXTRA_PROGRAMS)

# Empty...
EXTRA_PROGRAMS =
273

274
BUILT_INS = \
R
Rene Scharfe 已提交
275
	git-format-patch$X git-show$X git-whatchanged$X git-cherry$X \
276
	git-get-tar-commit-id$X git-init$X git-repo-config$X \
J
Junio C Hamano 已提交
277
	git-fsck-objects$X git-cherry-pick$X git-peek-remote$X git-status$X \
J
Junio C Hamano 已提交
278
	$(patsubst builtin-%.o,git-%$X,$(BUILTIN_OBJS))
J
Junio C Hamano 已提交
279

J
Junio C Hamano 已提交
280
# what 'all' will build and 'install' will install, in gitexecdir
J
Junio C Hamano 已提交
281
ALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS)
282

J
Junio C Hamano 已提交
283 284
ALL_PROGRAMS += git-merge-subtree$X

E
Eygene Ryabinkin 已提交
285 286 287
# what 'all' will build but not install in gitexecdir
OTHER_PROGRAMS = git$X gitweb/gitweb.cgi

288 289 290 291 292 293 294
# Set paths to tools early so that they can be used for version tests.
ifndef SHELL_PATH
	SHELL_PATH = /bin/sh
endif
ifndef PERL_PATH
	PERL_PATH = /usr/bin/perl
endif
295

L
Luben Tuikov 已提交
296 297
export PERL_PATH

L
Linus Torvalds 已提交
298
LIB_FILE=libgit.a
299
XDIFF_LIB=xdiff/lib.a
J
Junio C Hamano 已提交
300

J
Junio C Hamano 已提交
301
LIB_H = \
302
	archive.h blob.h cache.h cache-tree.h commit.h csum-file.h delta.h grep.h \
J
Junio C Hamano 已提交
303
	diff.h object.h pack.h pkt-line.h quote.h refs.h list-objects.h sideband.h \
J
Junio C Hamano 已提交
304
	run-command.h strbuf.h tag.h tree.h git-compat-util.h revision.h \
305
	tree-walk.h log-tree.h dir.h path-list.h unpack-trees.h builtin.h \
306
	utf8.h reflog-walk.h patch-ids.h attr.h decorate.h progress.h \
J
Junio C Hamano 已提交
307
	mailmap.h remote.h parse-options.h transport.h diffcore.h hash.h
308

J
Junio C Hamano 已提交
309
DIFF_OBJS = \
J
Junio C Hamano 已提交
310
	diff.o diff-lib.o diffcore-break.o diffcore-order.o \
311
	diffcore-pickaxe.o diffcore-rename.o tree-diff.o combine-diff.o \
312
	diffcore-delta.o log-tree.o
313

J
Junio C Hamano 已提交
314
LIB_OBJS = \
315
	blob.o commit.o connect.o csum-file.o cache-tree.o base85.o \
316
	date.o diff-delta.o entry.o exec_cmd.o ident.o \
317
	pretty.o interpolate.o hash.o \
318
	lockfile.o \
319
	patch-ids.o \
320 321
	object.o pack-check.o pack-write.o patch-delta.o path.o pkt-line.o \
	sideband.o reachable.o reflog-walk.o \
322
	quote.o read-cache.o refs.o run-command.o dir.o object-refs.o \
J
Junio C Hamano 已提交
323
	server-info.o setup.o sha1_file.o sha1_name.o strbuf.o \
324
	tag.o tree.o usage.o config.o environment.o ctype.o copy.o \
325
	revision.o pager.o tree-walk.o xdiff-interface.o \
J
Junio C Hamano 已提交
326
	write_or_die.o trace.o list-objects.o grep.o match-trees.o \
327
	alloc.o merge-file.o path-list.o help.o unpack-trees.o $(DIFF_OBJS) \
L
Linus Torvalds 已提交
328
	color.o wt-status.o archive-zip.o archive-tar.o shallow.o utf8.o \
329
	convert.o attr.o decorate.o progress.o mailmap.o symlinks.o remote.o \
330 331
	transport.o bundle.o walker.o parse-options.o ws.o archive.o \
	alias.o
J
Junio C Hamano 已提交
332

333
BUILTIN_OBJS = \
J
Junio C Hamano 已提交
334
	builtin-add.o \
335
	builtin-annotate.o \
J
Junio C Hamano 已提交
336
	builtin-apply.o \
F
Franck Bui-Huu 已提交
337
	builtin-archive.o \
J
Junio C Hamano 已提交
338
	builtin-blame.o \
L
Lars Hjemli 已提交
339
	builtin-branch.o \
340
	builtin-bundle.o \
J
Junio C Hamano 已提交
341
	builtin-cat-file.o \
342
	builtin-check-attr.o \
343
	builtin-checkout-index.o \
J
Junio C Hamano 已提交
344
	builtin-check-ref-format.o \
S
Shawn Bohrer 已提交
345
	builtin-clean.o \
K
Kristian Høgsberg 已提交
346
	builtin-commit.o \
J
Junio C Hamano 已提交
347 348
	builtin-commit-tree.o \
	builtin-count-objects.o \
S
Shawn O. Pearce 已提交
349
	builtin-describe.o \
J
Junio C Hamano 已提交
350 351 352 353
	builtin-diff.o \
	builtin-diff-files.o \
	builtin-diff-index.o \
	builtin-diff-tree.o \
354
	builtin-fast-export.o \
D
Daniel Barkalow 已提交
355
	builtin-fetch.o \
356
	builtin-fetch-pack.o \
357
	builtin-fetch--tool.o \
J
Junio C Hamano 已提交
358
	builtin-fmt-merge-msg.o \
359
	builtin-for-each-ref.o \
360
	builtin-fsck.o \
J
James Bowes 已提交
361
	builtin-gc.o \
J
Junio C Hamano 已提交
362 363 364 365 366
	builtin-grep.o \
	builtin-init-db.o \
	builtin-log.o \
	builtin-ls-files.o \
	builtin-ls-tree.o \
D
Daniel Barkalow 已提交
367
	builtin-ls-remote.o \
J
Junio C Hamano 已提交
368 369
	builtin-mailinfo.o \
	builtin-mailsplit.o \
J
Junio C Hamano 已提交
370
	builtin-merge-base.o \
371
	builtin-merge-file.o \
372
	builtin-merge-ours.o \
J
Junio C Hamano 已提交
373 374 375 376 377 378 379
	builtin-mv.o \
	builtin-name-rev.o \
	builtin-pack-objects.o \
	builtin-prune.o \
	builtin-prune-packed.o \
	builtin-push.o \
	builtin-read-tree.o \
J
Junio C Hamano 已提交
380
	builtin-reflog.o \
381
	builtin-send-pack.o \
382
	builtin-config.o \
J
Johannes Schindelin 已提交
383
	builtin-rerere.o \
C
Carlos Rica 已提交
384
	builtin-reset.o \
J
Junio C Hamano 已提交
385 386
	builtin-rev-list.o \
	builtin-rev-parse.o \
387
	builtin-revert.o \
J
Junio C Hamano 已提交
388
	builtin-rm.o \
J
Johannes Schindelin 已提交
389
	builtin-shortlog.o \
J
Junio C Hamano 已提交
390 391 392
	builtin-show-branch.o \
	builtin-stripspace.o \
	builtin-symbolic-ref.o \
C
Carlos Rica 已提交
393
	builtin-tag.o \
J
Junio C Hamano 已提交
394 395 396 397
	builtin-tar-tree.o \
	builtin-unpack-objects.o \
	builtin-update-index.o \
	builtin-update-ref.o \
F
Franck Bui-Huu 已提交
398
	builtin-upload-archive.o \
R
Rene Scharfe 已提交
399
	builtin-verify-pack.o \
C
Carlos Rica 已提交
400
	builtin-verify-tag.o \
R
Rene Scharfe 已提交
401
	builtin-write-tree.o \
402
	builtin-show-ref.o \
403
	builtin-pack-refs.o
404

405
GITLIBS = $(LIB_FILE) $(XDIFF_LIB)
406
EXTLIBS =
407

408 409 410
#
# Platform specific tweaks
#
411 412 413 414 415

# We choose to avoid "if .. else if .. else .. endif endif"
# because maintaining the nesting to match is a pain.  If
# we had "elif" things would have been much nicer...

416 417 418
ifeq ($(uname_S),Linux)
	NO_STRLCPY = YesPlease
endif
G
Gerrit Pape 已提交
419 420 421
ifeq ($(uname_S),GNU/kFreeBSD)
	NO_STRLCPY = YesPlease
endif
422
ifeq ($(uname_S),Darwin)
423 424
	NEEDS_SSL_WITH_CRYPTO = YesPlease
	NEEDS_LIBICONV = YesPlease
425 426 427
	ifneq ($(shell expr "$(uname_R)" : '9\.'),2)
		OLD_ICONV = UnfortunatelyYes
	endif
428
	NO_STRLCPY = YesPlease
429
	NO_MEMMEM = YesPlease
430
endif
431
ifeq ($(uname_S),SunOS)
432
	NEEDS_SOCKET = YesPlease
433
	NEEDS_NSL = YesPlease
434 435
	SHELL_PATH = /bin/bash
	NO_STRCASESTR = YesPlease
R
René Scharfe 已提交
436
	NO_MEMMEM = YesPlease
437
	NO_HSTRERROR = YesPlease
438
	NO_MKDTEMP = YesPlease
J
Jason Riedy 已提交
439
	ifeq ($(uname_R),5.8)
440
		NEEDS_LIBICONV = YesPlease
J
Jason Riedy 已提交
441
		NO_UNSETENV = YesPlease
J
Jason Riedy 已提交
442
		NO_SETENV = YesPlease
443
		NO_C99_FORMAT = YesPlease
444
		NO_STRTOUMAX = YesPlease
J
Jason Riedy 已提交
445
	endif
446 447 448
	ifeq ($(uname_R),5.9)
		NO_UNSETENV = YesPlease
		NO_SETENV = YesPlease
449
		NO_C99_FORMAT = YesPlease
450
		NO_STRTOUMAX = YesPlease
451
	endif
452 453
	INSTALL = ginstall
	TAR = gtar
454
	BASIC_CFLAGS += -D__EXTENSIONS__
455
endif
456
ifeq ($(uname_O),Cygwin)
457
	NO_D_TYPE_IN_DIRENT = YesPlease
458
	NO_D_INO_IN_DIRENT = YesPlease
H
hpa 已提交
459
	NO_STRCASESTR = YesPlease
R
René Scharfe 已提交
460
	NO_MEMMEM = YesPlease
461
	NO_SYMLINK_HEAD = YesPlease
H
hpa 已提交
462
	NEEDS_LIBICONV = YesPlease
463
	NO_FAST_WORKING_DIRECTORY = UnfortunatelyYes
464
	NO_TRUSTABLE_FILEMODE = UnfortunatelyYes
P
Pascal Obry 已提交
465
	OLD_ICONV = UnfortunatelyYes
466 467
	# There are conflicting reports about this.
	# On some boxes NO_MMAP is needed, and not so elsewhere.
J
Junio C Hamano 已提交
468 469
	# Try commenting this out if you suspect MMAP is more efficient
	NO_MMAP = YesPlease
470
	NO_IPV6 = YesPlease
P
Peter Anvin 已提交
471
	X = .exe
472
endif
A
Alecs King 已提交
473 474
ifeq ($(uname_S),FreeBSD)
	NEEDS_LIBICONV = YesPlease
475
	NO_MEMMEM = YesPlease
476 477
	BASIC_CFLAGS += -I/usr/local/include
	BASIC_LDFLAGS += -L/usr/local/lib
A
Alecs King 已提交
478
endif
479
ifeq ($(uname_S),OpenBSD)
480
	NO_STRCASESTR = YesPlease
R
René Scharfe 已提交
481
	NO_MEMMEM = YesPlease
H
Han Boetes 已提交
482
	NEEDS_LIBICONV = YesPlease
483 484
	BASIC_CFLAGS += -I/usr/local/include
	BASIC_LDFLAGS += -L/usr/local/lib
J
Junio C Hamano 已提交
485 486
endif
ifeq ($(uname_S),NetBSD)
487 488 489
	ifeq ($(shell expr "$(uname_R)" : '[01]\.'),2)
		NEEDS_LIBICONV = YesPlease
	endif
490 491 492
	BASIC_CFLAGS += -I/usr/pkg/include
	BASIC_LDFLAGS += -L/usr/pkg/lib
	ALL_LDFLAGS += -Wl,-rpath,/usr/pkg/lib
H
Han Boetes 已提交
493
endif
494 495
ifeq ($(uname_S),AIX)
	NO_STRCASESTR=YesPlease
R
René Scharfe 已提交
496
	NO_MEMMEM = YesPlease
497
	NO_STRLCPY = YesPlease
498 499
	NEEDS_LIBICONV=YesPlease
endif
T
Thomas Schwinge 已提交
500 501 502 503
ifeq ($(uname_S),GNU)
	# GNU/Hurd
	NO_STRLCPY=YesPlease
endif
J
Johannes Schindelin 已提交
504 505 506 507
ifeq ($(uname_S),IRIX64)
	NO_IPV6=YesPlease
	NO_SETENV=YesPlease
	NO_STRCASESTR=YesPlease
R
René Scharfe 已提交
508
	NO_MEMMEM = YesPlease
509
	NO_STRLCPY = YesPlease
J
Johannes Schindelin 已提交
510 511
	NO_SOCKADDR_STORAGE=YesPlease
	SHELL_PATH=/usr/gnu/bin/bash
512
	BASIC_CFLAGS += -DPATH_MAX=1024
J
Johannes Schindelin 已提交
513
	# for now, build 32-bit version
514
	BASIC_LDFLAGS += -L/usr/lib32
J
Johannes Schindelin 已提交
515
endif
516 517 518 519 520 521 522 523 524 525 526
ifeq ($(uname_S),HP-UX)
	NO_IPV6=YesPlease
	NO_SETENV=YesPlease
	NO_STRCASESTR=YesPlease
	NO_MEMMEM = YesPlease
	NO_STRLCPY = YesPlease
	NO_MKDTEMP = YesPlease
	NO_UNSETENV = YesPlease
	NO_HSTRERROR = YesPlease
	NO_SYS_SELECT_H = YesPlease
endif
527 528 529
ifneq (,$(findstring arm,$(uname_M)))
	ARM_SHA1 = YesPlease
endif
530

531
-include config.mak.autogen
532
-include config.mak
533

534 535 536 537 538 539 540 541 542 543 544 545 546 547 548
ifeq ($(uname_S),Darwin)
	ifndef NO_FINK
		ifeq ($(shell test -d /sw/lib && echo y),y)
			BASIC_CFLAGS += -I/sw/include
			BASIC_LDFLAGS += -L/sw/lib
		endif
	endif
	ifndef NO_DARWIN_PORTS
		ifeq ($(shell test -d /opt/local/lib && echo y),y)
			BASIC_CFLAGS += -I/opt/local/include
			BASIC_LDFLAGS += -L/opt/local/lib
		endif
	endif
endif

549 550 551 552 553 554 555 556
ifdef NO_R_TO_GCC_LINKER
	# Some gcc does not accept and pass -R to the linker to specify
	# the runtime dynamic library path.
	CC_LD_DYNPATH = -Wl,-rpath=
else
	CC_LD_DYNPATH = -R
endif

D
Daniel Barkalow 已提交
557 558 559
ifdef NO_CURL
	BASIC_CFLAGS += -DNO_CURL
else
560
	ifdef CURLDIR
561
		# Try "-Wl,-rpath=$(CURLDIR)/$(lib)" in such a case.
562
		BASIC_CFLAGS += -I$(CURLDIR)/include
563
		CURL_LIBCURL = -L$(CURLDIR)/$(lib) $(CC_LD_DYNPATH)$(CURLDIR)/$(lib) -lcurl
564 565 566
	else
		CURL_LIBCURL = -lcurl
	endif
D
Daniel Barkalow 已提交
567 568
	BUILTIN_OBJS += builtin-http-fetch.o
	EXTLIBS += $(CURL_LIBCURL)
569
	LIB_OBJS += http.o http-walker.o
570 571 572 573 574
	curl_check := $(shell (echo 070908; curl-config --vernum) | sort -r | sed -ne 2p)
	ifeq "$(curl_check)" "070908"
		ifndef NO_EXPAT
			PROGRAMS += git-http-push$X
		endif
575
	endif
576 577 578
	ifndef NO_EXPAT
		EXPAT_LIBEXPAT = -lexpat
	endif
579 580
endif

581 582
ifdef ZLIB_PATH
	BASIC_CFLAGS += -I$(ZLIB_PATH)/include
583
	EXTLIBS += -L$(ZLIB_PATH)/$(lib) $(CC_LD_DYNPATH)$(ZLIB_PATH)/$(lib)
584 585 586
endif
EXTLIBS += -lz

P
Petr Baudis 已提交
587
ifndef NO_OPENSSL
J
Junio C Hamano 已提交
588
	OPENSSL_LIBSSL = -lssl
J
Junio C Hamano 已提交
589
	ifdef OPENSSLDIR
590
		BASIC_CFLAGS += -I$(OPENSSLDIR)/include
591
		OPENSSL_LINK = -L$(OPENSSLDIR)/$(lib) $(CC_LD_DYNPATH)$(OPENSSLDIR)/$(lib)
J
Junio C Hamano 已提交
592 593 594
	else
		OPENSSL_LINK =
	endif
P
Petr Baudis 已提交
595
else
596
	BASIC_CFLAGS += -DNO_OPENSSL
J
Junio C Hamano 已提交
597 598
	MOZILLA_SHA1 = 1
	OPENSSL_LIBSSL =
P
Petr Baudis 已提交
599
endif
600
ifdef NEEDS_SSL_WITH_CRYPTO
J
Junio C Hamano 已提交
601
	LIB_4_CRYPTO = $(OPENSSL_LINK) -lcrypto -lssl
602
else
J
Junio C Hamano 已提交
603
	LIB_4_CRYPTO = $(OPENSSL_LINK) -lcrypto
604 605
endif
ifdef NEEDS_LIBICONV
J
Junio C Hamano 已提交
606
	ifdef ICONVDIR
607
		BASIC_CFLAGS += -I$(ICONVDIR)/include
608
		ICONV_LINK = -L$(ICONVDIR)/$(lib) $(CC_LD_DYNPATH)$(ICONVDIR)/$(lib)
J
Junio C Hamano 已提交
609 610 611
	else
		ICONV_LINK =
	endif
612
	EXTLIBS += $(ICONV_LINK) -liconv
613
endif
614
ifdef NEEDS_SOCKET
615
	EXTLIBS += -lsocket
616
endif
617
ifdef NEEDS_NSL
618
	EXTLIBS += -lnsl
619
endif
620
ifdef NO_D_TYPE_IN_DIRENT
621
	BASIC_CFLAGS += -DNO_D_TYPE_IN_DIRENT
622
endif
623
ifdef NO_D_INO_IN_DIRENT
624
	BASIC_CFLAGS += -DNO_D_INO_IN_DIRENT
625
endif
626
ifdef NO_C99_FORMAT
627
	BASIC_CFLAGS += -DNO_C99_FORMAT
628
endif
629 630 631 632
ifdef FREAD_READS_DIRECTORIES
	COMPAT_CFLAGS += -DFREAD_READS_DIRECTORIES
	COMPAT_OBJS += compat/fopen.o
endif
633
ifdef NO_SYMLINK_HEAD
634
	BASIC_CFLAGS += -DNO_SYMLINK_HEAD
635
endif
636
ifdef NO_STRCASESTR
637
	COMPAT_CFLAGS += -DNO_STRCASESTR
J
Jason Riedy 已提交
638 639
	COMPAT_OBJS += compat/strcasestr.o
endif
640 641 642 643
ifdef NO_STRLCPY
	COMPAT_CFLAGS += -DNO_STRLCPY
	COMPAT_OBJS += compat/strlcpy.o
endif
644 645 646 647 648 649 650
ifdef NO_STRTOUMAX
	COMPAT_CFLAGS += -DNO_STRTOUMAX
	COMPAT_OBJS += compat/strtoumax.o
endif
ifdef NO_STRTOULL
	COMPAT_CFLAGS += -DNO_STRTOULL
endif
J
Jason Riedy 已提交
651
ifdef NO_SETENV
652
	COMPAT_CFLAGS += -DNO_SETENV
J
Jason Riedy 已提交
653
	COMPAT_OBJS += compat/setenv.o
654
endif
655 656 657 658
ifdef NO_MKDTEMP
	COMPAT_CFLAGS += -DNO_MKDTEMP
	COMPAT_OBJS += compat/mkdtemp.o
endif
J
Johannes Schindelin 已提交
659
ifdef NO_UNSETENV
J
Jason Riedy 已提交
660 661 662
	COMPAT_CFLAGS += -DNO_UNSETENV
	COMPAT_OBJS += compat/unsetenv.o
endif
663 664 665
ifdef NO_SYS_SELECT_H
	BASIC_CFLAGS += -DNO_SYS_SELECT_H
endif
666
ifdef NO_MMAP
667
	COMPAT_CFLAGS += -DNO_MMAP
J
Jason Riedy 已提交
668
	COMPAT_OBJS += compat/mmap.o
669
endif
670 671 672 673
ifdef NO_PREAD
	COMPAT_CFLAGS += -DNO_PREAD
	COMPAT_OBJS += compat/pread.o
endif
674 675 676
ifdef NO_FAST_WORKING_DIRECTORY
	BASIC_CFLAGS += -DNO_FAST_WORKING_DIRECTORY
endif
677 678 679
ifdef NO_TRUSTABLE_FILEMODE
	BASIC_CFLAGS += -DNO_TRUSTABLE_FILEMODE
endif
680
ifdef NO_IPV6
681
	BASIC_CFLAGS += -DNO_IPV6
682 683 684
endif
ifdef NO_SOCKADDR_STORAGE
ifdef NO_IPV6
685
	BASIC_CFLAGS += -Dsockaddr_storage=sockaddr_in
686
else
687
	BASIC_CFLAGS += -Dsockaddr_storage=sockaddr_in6
688
endif
689
endif
690 691 692
ifdef NO_INET_NTOP
	LIB_OBJS += compat/inet_ntop.o
endif
693 694 695
ifdef NO_INET_PTON
	LIB_OBJS += compat/inet_pton.o
endif
696

697
ifdef NO_ICONV
698
	BASIC_CFLAGS += -DNO_ICONV
699 700
endif

701 702 703 704
ifdef OLD_ICONV
	BASIC_CFLAGS += -DOLD_ICONV
endif

705 706 707 708
ifdef NO_DEFLATE_BOUND
	BASIC_CFLAGS += -DNO_DEFLATE_BOUND
endif

709 710 711 712 713 714 715 716 717 718 719 720 721
ifdef PPC_SHA1
	SHA1_HEADER = "ppc/sha1.h"
	LIB_OBJS += ppc/sha1.o ppc/sha1ppc.o
else
ifdef ARM_SHA1
	SHA1_HEADER = "arm/sha1.h"
	LIB_OBJS += arm/sha1.o arm/sha1_arm.o
else
ifdef MOZILLA_SHA1
	SHA1_HEADER = "mozilla-sha1/sha1.h"
	LIB_OBJS += mozilla-sha1/sha1.o
else
	SHA1_HEADER = <openssl/sha.h>
722
	EXTLIBS += $(LIB_4_CRYPTO)
723 724 725
endif
endif
endif
726 727 728
ifdef NO_PERL_MAKEMAKER
	export NO_PERL_MAKEMAKER
endif
729 730 731 732
ifdef NO_HSTRERROR
	COMPAT_CFLAGS += -DNO_HSTRERROR
	COMPAT_OBJS += compat/hstrerror.o
endif
R
René Scharfe 已提交
733 734 735 736
ifdef NO_MEMMEM
	COMPAT_CFLAGS += -DNO_MEMMEM
	COMPAT_OBJS += compat/memmem.o
endif
737 738 739 740
ifdef INTERNAL_QSORT
	COMPAT_CFLAGS += -DINTERNAL_QSORT
	COMPAT_OBJS += compat/qsort.o
endif
741

N
Nicolas Pitre 已提交
742 743 744 745 746
ifdef THREADED_DELTA_SEARCH
	BASIC_CFLAGS += -DTHREADED_DELTA_SEARCH
	EXTLIBS += -lpthread
endif

747 748 749 750
ifeq ($(TCLTK_PATH),)
NO_TCLTK=NoThanks
endif

751
QUIET_SUBDIR0  = +$(MAKE) -C # space to separate -C and subdir
752 753
QUIET_SUBDIR1  =

754 755 756 757 758 759
ifneq ($(findstring $(MAKEFLAGS),w),w)
PRINT_DIR = --no-print-directory
else # "make -w"
NO_SUBDIR = :
endif

760
ifneq ($(findstring $(MAKEFLAGS),s),s)
S
Shawn O. Pearce 已提交
761
ifndef V
A
Alex Riesen 已提交
762
	QUIET_CC       = @echo '   ' CC $@;
763 764 765 766
	QUIET_AR       = @echo '   ' AR $@;
	QUIET_LINK     = @echo '   ' LINK $@;
	QUIET_BUILT_IN = @echo '   ' BUILTIN $@;
	QUIET_GEN      = @echo '   ' GEN $@;
767
	QUIET_SUBDIR0  = +@subdir=
768 769
	QUIET_SUBDIR1  = ;$(NO_SUBDIR) echo '   ' SUBDIR $$subdir; \
			 $(MAKE) $(PRINT_DIR) -C $$subdir
S
Shawn O. Pearce 已提交
770
	export V
A
Alex Riesen 已提交
771
	export QUIET_GEN
772 773
	export QUIET_BUILT_IN
endif
774
endif
775

776 777 778 779
ifdef ASCIIDOC8
	export ASCIIDOC8
endif

P
Pavel Roskin 已提交
780
# Shell quote (do not use $(call) to accommodate ancient setups);
781 782

SHA1_HEADER_SQ = $(subst ','\'',$(SHA1_HEADER))
783
ETC_GITCONFIG_SQ = $(subst ','\'',$(ETC_GITCONFIG))
784 785 786

DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
bindir_SQ = $(subst ','\'',$(bindir))
787
mandir_SQ = $(subst ','\'',$(mandir))
788
infodir_SQ = $(subst ','\'',$(infodir))
789 790
gitexecdir_SQ = $(subst ','\'',$(gitexecdir))
template_dir_SQ = $(subst ','\'',$(template_dir))
791
htmldir_SQ = $(subst ','\'',$(htmldir))
792
prefix_SQ = $(subst ','\'',$(prefix))
793 794 795

SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
796
TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH))
797

798 799
LIBS = $(GITLIBS) $(EXTLIBS)

800
BASIC_CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER_SQ)' \
801
	$(COMPAT_CFLAGS)
J
Jason Riedy 已提交
802
LIB_OBJS += $(COMPAT_OBJS)
803 804 805 806

ALL_CFLAGS += $(BASIC_CFLAGS)
ALL_LDFLAGS += $(BASIC_LDFLAGS)

807
export TAR INSTALL DESTDIR SHELL_PATH
808 809


P
Petr Baudis 已提交
810 811
### Build rules

E
Eygene Ryabinkin 已提交
812
all:: $(ALL_PROGRAMS) $(BUILT_INS) $(OTHER_PROGRAMS)
813
ifneq (,$X)
814
	$(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) git$X)), $(RM) '$p';)
815
endif
816

817
all::
E
Eygene Ryabinkin 已提交
818
ifndef NO_TCLTK
819
	$(QUIET_SUBDIR0)git-gui $(QUIET_SUBDIR1) all
J
Junio C Hamano 已提交
820
	$(QUIET_SUBDIR0)gitk-git $(QUIET_SUBDIR1) all
E
Eygene Ryabinkin 已提交
821
endif
822 823
	$(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' all
	$(QUIET_SUBDIR0)templates $(QUIET_SUBDIR1)
824

J
Junio C Hamano 已提交
825 826 827
strip: $(PROGRAMS) git$X
	$(STRIP) $(STRIP_OPTS) $(PROGRAMS) git$X

828 829 830 831 832
git.o: git.c common-cmds.h GIT-CFLAGS
	$(QUIET_CC)$(CC) -DGIT_VERSION='"$(GIT_VERSION)"' \
		$(ALL_CFLAGS) -c $(filter %.c,$^)

git$X: git.o $(BUILTIN_OBJS) $(GITLIBS)
833
	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ git.o \
834
		$(BUILTIN_OBJS) $(ALL_LDFLAGS) $(LIBS)
835

836
help.o: help.c common-cmds.h GIT-CFLAGS
837
	$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) \
838
		'-DGIT_HTML_PATH="$(htmldir_SQ)"' \
839 840
		'-DGIT_MAN_PATH="$(mandir_SQ)"' \
		'-DGIT_INFO_PATH="$(infodir_SQ)"' $<
841

J
Junio C Hamano 已提交
842
git-merge-subtree$X: git-merge-recursive$X
843
	$(QUIET_BUILT_IN)$(RM) $@ && ln git-merge-recursive$X $@
J
Junio C Hamano 已提交
844

J
Junio C Hamano 已提交
845
$(BUILT_INS): git$X
846
	$(QUIET_BUILT_IN)$(RM) $@ && ln git$X $@
J
Junio C Hamano 已提交
847

J
Junio C Hamano 已提交
848
common-cmds.h: ./generate-cmdlist.sh command-list.txt
849

J
Junio C Hamano 已提交
850
common-cmds.h: $(wildcard Documentation/git-*.txt)
851
	$(QUIET_GEN)./generate-cmdlist.sh > $@+ && mv $@+ $@
F
Fredrik Kuivinen 已提交
852

853
$(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
854
	$(QUIET_GEN)$(RM) $@ $@+ && \
855
	sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
M
Michal Rokos 已提交
856
	    -e 's|@@PERL@@|$(PERL_PATH_SQ)|g' \
857
	    -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
858
	    -e 's/@@NO_CURL@@/$(NO_CURL)/g' \
859 860
	    $@.sh >$@+ && \
	chmod +x $@+ && \
861
	mv $@+ $@
862

863 864
$(patsubst %.perl,%,$(SCRIPT_PERL)): perl/perl.mak

A
Alex Riesen 已提交
865
perl/perl.mak: GIT-CFLAGS perl/Makefile perl/Makefile.PL
A
Alex Riesen 已提交
866
	$(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' $(@F)
867

868
$(patsubst %.perl,%,$(SCRIPT_PERL)): % : %.perl
869
	$(QUIET_GEN)$(RM) $@ $@+ && \
870
	INSTLIBDIR=`MAKEFLAGS= $(MAKE) -C perl -s --no-print-directory instlibdir` && \
871 872 873 874 875 876 877
	sed -e '1{' \
	    -e '	s|#!.*perl|#!$(PERL_PATH_SQ)|' \
	    -e '	h' \
	    -e '	s=.*=use lib (split(/:/, $$ENV{GITPERLLIB} || "@@INSTLIBDIR@@"));=' \
	    -e '	H' \
	    -e '	x' \
	    -e '}' \
878
	    -e 's|@@INSTLIBDIR@@|'"$$INSTLIBDIR"'|g' \
879
	    -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
880 881
	    $@.perl >$@+ && \
	chmod +x $@+ && \
882
	mv $@+ $@
883

884
gitweb/gitweb.cgi: gitweb/gitweb.perl
885
	$(QUIET_GEN)$(RM) $@ $@+ && \
886
	sed -e '1s|#!.*perl|#!$(PERL_PATH_SQ)|' \
887 888 889
	    -e 's|++GIT_VERSION++|$(GIT_VERSION)|g' \
	    -e 's|++GIT_BINDIR++|$(bindir)|g' \
	    -e 's|++GITWEB_CONFIG++|$(GITWEB_CONFIG)|g' \
890
	    -e 's|++GITWEB_HOME_LINK_STR++|$(GITWEB_HOME_LINK_STR)|g' \
891 892
	    -e 's|++GITWEB_SITENAME++|$(GITWEB_SITENAME)|g' \
	    -e 's|++GITWEB_PROJECTROOT++|$(GITWEB_PROJECTROOT)|g' \
893
	    -e 's|"++GITWEB_PROJECT_MAXDEPTH++"|$(GITWEB_PROJECT_MAXDEPTH)|g' \
M
Matthias Lederhofer 已提交
894 895
	    -e 's|++GITWEB_EXPORT_OK++|$(GITWEB_EXPORT_OK)|g' \
	    -e 's|++GITWEB_STRICT_EXPORT++|$(GITWEB_STRICT_EXPORT)|g' \
896
	    -e 's|++GITWEB_BASE_URL++|$(GITWEB_BASE_URL)|g' \
897 898 899 900
	    -e 's|++GITWEB_LIST++|$(GITWEB_LIST)|g' \
	    -e 's|++GITWEB_HOMETEXT++|$(GITWEB_HOMETEXT)|g' \
	    -e 's|++GITWEB_CSS++|$(GITWEB_CSS)|g' \
	    -e 's|++GITWEB_LOGO++|$(GITWEB_LOGO)|g' \
901
	    -e 's|++GITWEB_FAVICON++|$(GITWEB_FAVICON)|g' \
902 903
	    -e 's|++GITWEB_SITE_HEADER++|$(GITWEB_SITE_HEADER)|g' \
	    -e 's|++GITWEB_SITE_FOOTER++|$(GITWEB_SITE_FOOTER)|g' \
904 905
	    $< >$@+ && \
	chmod +x $@+ && \
906 907
	mv $@+ $@

908
git-instaweb: git-instaweb.sh gitweb/gitweb.cgi gitweb/gitweb.css
909
	$(QUIET_GEN)$(RM) $@ $@+ && \
910 911 912
	sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
	    -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
	    -e 's/@@NO_CURL@@/$(NO_CURL)/g' \
913
	    -e '/@@GITWEB_CGI@@/r gitweb/gitweb.cgi' \
914
	    -e '/@@GITWEB_CGI@@/d' \
915
	    -e '/@@GITWEB_CSS@@/r gitweb/gitweb.css' \
916
	    -e '/@@GITWEB_CSS@@/d' \
917
	    -e 's|@@PERL@@|$(PERL_PATH_SQ)|g' \
918 919
	    $@.sh > $@+ && \
	chmod +x $@+ && \
920 921
	mv $@+ $@

922
configure: configure.ac
923
	$(QUIET_GEN)$(RM) $@ $<+ && \
924
	sed -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
925 926
	    $< > $<+ && \
	autoconf -o $@ $<+ && \
927
	$(RM) $<+
928

929
# These can record GIT_VERSION
930
git.o git.spec \
931 932 933
	$(patsubst %.sh,%,$(SCRIPT_SH)) \
	$(patsubst %.perl,%,$(SCRIPT_PERL)) \
	: GIT-VERSION-FILE
934

935
%.o: %.c GIT-CFLAGS
936
	$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $<
937 938
%.s: %.c GIT-CFLAGS
	$(QUIET_CC)$(CC) -S $(ALL_CFLAGS) $<
939
%.o: %.S
940
	$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $<
941

942
exec_cmd.o: exec_cmd.c GIT-CFLAGS
943
	$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) '-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' $<
944
builtin-init-db.o: builtin-init-db.c GIT-CFLAGS
945
	$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir_SQ)"' $<
946

947 948 949
config.o: config.c GIT-CFLAGS
	$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DETC_GITCONFIG='"$(ETC_GITCONFIG_SQ)"' $<

950
http.o: http.c GIT-CFLAGS
951
	$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DGIT_USER_AGENT='"git/$(GIT_VERSION)"' $<
952

953
ifdef NO_EXPAT
D
Daniel Barkalow 已提交
954
http-walker.o: http-walker.c http.h GIT-CFLAGS
955
	$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DNO_EXPAT $<
956 957
endif

958
git-%$X: %.o $(GITLIBS)
959
	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
960

961 962
git-imap-send$X: imap-send.o $(LIB_FILE)

M
Mike Hommey 已提交
963
http.o http-walker.o http-push.o transport.o: http.h
964

965
git-http-push$X: revision.o http.o http-push.o $(GITLIBS)
966
	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
967 968
		$(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)

969
$(LIB_OBJS) $(BUILTIN_OBJS): $(LIB_H)
970
$(patsubst git-%$X,%.o,$(PROGRAMS)): $(LIB_H) $(wildcard */*.h)
J
Junio C Hamano 已提交
971
builtin-revert.o wt-status.o: wt-status.h
972

P
Petr Baudis 已提交
973
$(LIB_FILE): $(LIB_OBJS)
974
	$(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIB_OBJS)
P
Petr Baudis 已提交
975

J
Johannes Schindelin 已提交
976 977
XDIFF_OBJS=xdiff/xdiffi.o xdiff/xprepare.o xdiff/xutils.o xdiff/xemit.o \
	xdiff/xmerge.o
978 979
$(XDIFF_OBJS): xdiff/xinclude.h xdiff/xmacros.h xdiff/xdiff.h xdiff/xtypes.h \
	xdiff/xutils.h xdiff/xprepare.h xdiff/xdiffi.h xdiff/xemit.h
980 981

$(XDIFF_LIB): $(XDIFF_OBJS)
982
	$(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(XDIFF_OBJS)
983 984


P
Petr Baudis 已提交
985 986 987
doc:
	$(MAKE) -C Documentation all

988 989 990
info:
	$(MAKE) -C Documentation info

991
TAGS:
992
	$(RM) TAGS
993
	$(FIND) . -name '*.[hcS]' -print | xargs etags -a
994 995

tags:
996
	$(RM) tags
997
	$(FIND) . -name '*.[hcS]' -print | xargs ctags -a
P
Petr Baudis 已提交
998

K
Kristof Provost 已提交
999 1000 1001 1002
cscope:
	$(RM) cscope*
	$(FIND) . -name '*.[hcS]' -print | xargs cscope -b

1003
### Detect prefix changes
J
Junio C Hamano 已提交
1004
TRACK_CFLAGS = $(subst ','\'',$(ALL_CFLAGS)):\
1005 1006 1007 1008 1009 1010 1011 1012 1013
             $(bindir_SQ):$(gitexecdir_SQ):$(template_dir_SQ):$(prefix_SQ)

GIT-CFLAGS: .FORCE-GIT-CFLAGS
	@FLAGS='$(TRACK_CFLAGS)'; \
	    if test x"$$FLAGS" != x"`cat GIT-CFLAGS 2>/dev/null`" ; then \
		echo 1>&2 "    * new build flags or prefix"; \
		echo "$$FLAGS" >GIT-CFLAGS; \
            fi

1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027
### Detect Tck/Tk interpreter path changes
ifndef NO_TCLTK
TRACK_VARS = $(subst ','\'',-DTCLTK_PATH='$(TCLTK_PATH_SQ)')

GIT-GUI-VARS: .FORCE-GIT-GUI-VARS
	@VARS='$(TRACK_VARS)'; \
	    if test x"$$VARS" != x"`cat $@ 2>/dev/null`" ; then \
		echo 1>&2 "    * new Tcl/Tk interpreter location"; \
		echo "$$VARS" >$@; \
            fi

.PHONY: .FORCE-GIT-GUI-VARS
endif

P
Petr Baudis 已提交
1028 1029
### Testing rules

1030
TEST_PROGRAMS = test-chmtime$X test-genrandom$X test-date$X test-delta$X test-sha1$X test-match-trees$X test-absolute-path$X test-parse-options$X
1031 1032 1033

all:: $(TEST_PROGRAMS)

1034 1035 1036 1037
# GNU make supports exporting all variables by "export" without parameters.
# However, the environment gets quite big, and some programs have problems
# with that.

1038
export NO_SVN_TESTS
1039

1040
test: all
P
Petr Baudis 已提交
1041 1042
	$(MAKE) -C t/ all

1043
test-date$X: date.o ctype.o
P
Petr Baudis 已提交
1044

1045
test-delta$X: diff-delta.o patch-delta.o
P
Petr Baudis 已提交
1046

1047 1048
test-parse-options$X: parse-options.o

1049 1050
.PRECIOUS: $(patsubst test-%$X,test-%.o,$(TEST_PROGRAMS))

1051 1052
test-%$X: test-%.o $(GITLIBS)
	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
1053

1054 1055 1056
check-sha1:: test-sha1$X
	./test-sha1.sh

1057
check: common-cmds.h
1058
	for i in *.c; do sparse $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i || exit; done
P
Petr Baudis 已提交
1059

1060 1061
remove-dashes:
	./fixup-builtins $(BUILT_INS)
P
Petr Baudis 已提交
1062 1063 1064

### Installation rules

1065
install: all
1066 1067
	$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'
	$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitexecdir_SQ)'
1068
	$(INSTALL) $(ALL_PROGRAMS) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
E
Eygene Ryabinkin 已提交
1069
	$(INSTALL) git$X '$(DESTDIR_SQ)$(bindir_SQ)'
1070
	$(MAKE) -C templates DESTDIR='$(DESTDIR_SQ)' install
1071
	$(MAKE) -C perl prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' install
E
Eygene Ryabinkin 已提交
1072
ifndef NO_TCLTK
J
Junio C Hamano 已提交
1073
	$(MAKE) -C gitk-git install
1074
	$(MAKE) -C git-gui install
E
Eygene Ryabinkin 已提交
1075
endif
1076 1077 1078 1079 1080 1081 1082
	if test 'z$(bindir_SQ)' != 'z$(gitexecdir_SQ)'; \
	then \
		ln -f '$(DESTDIR_SQ)$(bindir_SQ)/git$X' \
			'$(DESTDIR_SQ)$(gitexecdir_SQ)/git$X' || \
		cp '$(DESTDIR_SQ)$(bindir_SQ)/git$X' \
			'$(DESTDIR_SQ)$(gitexecdir_SQ)/git$X'; \
	fi
1083
	$(foreach p,$(BUILT_INS), $(RM) '$(DESTDIR_SQ)$(gitexecdir_SQ)/$p' && ln '$(DESTDIR_SQ)$(gitexecdir_SQ)/git$X' '$(DESTDIR_SQ)$(gitexecdir_SQ)/$p' ;)
1084
ifneq (,$X)
1085
	$(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) git$X)), $(RM) '$(DESTDIR_SQ)$(gitexecdir_SQ)/$p';)
1086
endif
P
Petr Baudis 已提交
1087 1088 1089 1090

install-doc:
	$(MAKE) -C Documentation install

1091 1092 1093
install-info:
	$(MAKE) -C Documentation install-info

1094 1095
quick-install-doc:
	$(MAKE) -C Documentation quick-install
P
Petr Baudis 已提交
1096 1097 1098 1099 1100



### Maintainer's dist rules

1101
git.spec: git.spec.in
1102 1103
	sed -e 's/@@VERSION@@/$(GIT_VERSION)/g' < $< > $@+
	mv $@+ $@
1104

J
Junio C Hamano 已提交
1105
GIT_TARNAME=git-$(GIT_VERSION)
1106
dist: git.spec git-archive configure
1107 1108
	./git-archive --format=tar \
		--prefix=$(GIT_TARNAME)/ HEAD^{tree} > $(GIT_TARNAME).tar
1109
	@mkdir -p $(GIT_TARNAME)
1110
	@cp git.spec configure $(GIT_TARNAME)
1111
	@echo $(GIT_VERSION) > $(GIT_TARNAME)/version
1112
	@$(MAKE) -C git-gui TARDIR=../$(GIT_TARNAME)/git-gui dist-version
1113
	$(TAR) rf $(GIT_TARNAME).tar \
1114
		$(GIT_TARNAME)/git.spec \
1115
		$(GIT_TARNAME)/configure \
1116
		$(GIT_TARNAME)/version \
1117
		$(GIT_TARNAME)/git-gui/version
1118
	@$(RM) -r $(GIT_TARNAME)
1119
	gzip -f -9 $(GIT_TARNAME).tar
1120 1121

rpm: dist
J
Junio C Hamano 已提交
1122
	$(RPMBUILD) -ta $(GIT_TARNAME).tar.gz
1123

1124 1125 1126
htmldocs = git-htmldocs-$(GIT_VERSION)
manpages = git-manpages-$(GIT_VERSION)
dist-doc:
1127
	$(RM) -r .doc-tmp-dir
1128 1129 1130 1131 1132
	mkdir .doc-tmp-dir
	$(MAKE) -C Documentation WEBDOC_DEST=../.doc-tmp-dir install-webdoc
	cd .doc-tmp-dir && $(TAR) cf ../$(htmldocs).tar .
	gzip -n -9 -f $(htmldocs).tar
	:
1133
	$(RM) -r .doc-tmp-dir
1134
	mkdir -p .doc-tmp-dir/man1 .doc-tmp-dir/man5 .doc-tmp-dir/man7
1135
	$(MAKE) -C Documentation DESTDIR=./ \
1136
		man1dir=../.doc-tmp-dir/man1 \
1137
		man5dir=../.doc-tmp-dir/man5 \
1138
		man7dir=../.doc-tmp-dir/man7 \
1139 1140 1141
		install
	cd .doc-tmp-dir && $(TAR) cf ../$(manpages).tar .
	gzip -n -9 -f $(manpages).tar
1142
	$(RM) -r .doc-tmp-dir
1143

P
Petr Baudis 已提交
1144
### Cleaning rules
1145

1146 1147 1148
distclean: clean
	$(RM) configure

1149
clean:
1150
	$(RM) *.o mozilla-sha1/*.o arm/*.o ppc/*.o compat/*.o xdiff/*.o \
1151
		$(LIB_FILE) $(XDIFF_LIB)
1152 1153
	$(RM) $(ALL_PROGRAMS) $(BUILT_INS) git$X
	$(RM) $(TEST_PROGRAMS)
K
Kristof Provost 已提交
1154
	$(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo common-cmds.h TAGS tags cscope*
1155
	$(RM) -r autom4te.cache
1156
	$(RM) config.log config.mak.autogen config.mak.append config.status config.cache
1157 1158 1159 1160
	$(RM) -r $(GIT_TARNAME) .doc-tmp-dir
	$(RM) $(GIT_TARNAME).tar.gz git-core_$(GIT_VERSION)-*.tar.gz
	$(RM) $(htmldocs).tar.gz $(manpages).tar.gz
	$(RM) gitweb/gitweb.cgi
1161
	$(MAKE) -C Documentation/ clean
1162
	$(MAKE) -C perl clean
P
Petr Baudis 已提交
1163
	$(MAKE) -C templates/ clean
1164
	$(MAKE) -C t/ clean
E
Eygene Ryabinkin 已提交
1165
ifndef NO_TCLTK
J
Junio C Hamano 已提交
1166
	$(MAKE) -C gitk-git clean
E
Eygene Ryabinkin 已提交
1167 1168
	$(MAKE) -C git-gui clean
endif
1169
	$(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-GUI-VARS
1170

J
Junio C Hamano 已提交
1171
.PHONY: all install clean strip
K
Kristof Provost 已提交
1172
.PHONY: .FORCE-GIT-VERSION-FILE TAGS tags cscope .FORCE-GIT-CFLAGS
J
Junio C Hamano 已提交
1173

J
Junio C Hamano 已提交
1174 1175 1176
### Check documentation
#
check-docs::
1177
	@(for v in $(ALL_PROGRAMS) $(BUILT_INS) git gitk; \
J
Junio C Hamano 已提交
1178 1179 1180
	do \
		case "$$v" in \
		git-merge-octopus | git-merge-ours | git-merge-recursive | \
1181
		git-merge-resolve | git-merge-stupid | git-merge-subtree | \
1182
		git-fsck-objects | git-init-db | \
1183
		git-?*--?* ) continue ;; \
J
Junio C Hamano 已提交
1184 1185 1186
		esac ; \
		test -f "Documentation/$$v.txt" || \
		echo "no doc: $$v"; \
J
Junio C Hamano 已提交
1187
		sed -e '/^#/d' command-list.txt | \
1188
		grep -q "^$$v[ 	]" || \
J
Junio C Hamano 已提交
1189 1190 1191 1192
		case "$$v" in \
		git) ;; \
		*) echo "no link: $$v";; \
		esac ; \
1193 1194
	done; \
	( \
J
Junio C Hamano 已提交
1195
		sed -e '/^#/d' \
1196
		    -e 's/[ 	].*//' \
J
Junio C Hamano 已提交
1197
		    -e 's/^/listed /' command-list.txt; \
1198 1199 1200 1201 1202 1203 1204 1205
		ls -1 Documentation/git*txt | \
		sed -e 's|Documentation/|documented |' \
		    -e 's/\.txt//'; \
	) | while read how cmd; \
	do \
		case "$$how,$$cmd" in \
		*,git-citool | \
		*,git-gui | \
1206
		*,git-help | \
1207 1208 1209
		documented,gitattributes | \
		documented,gitignore | \
		documented,gitmodules | \
1210
		documented,gitcli | \
1211 1212 1213 1214 1215 1216 1217 1218
		documented,git-tools | \
		sentinel,not,matching,is,ok ) continue ;; \
		esac; \
		case " $(ALL_PROGRAMS) $(BUILT_INS) git gitk " in \
		*" $$cmd "*)	;; \
		*) echo "removed but $$how: $$cmd" ;; \
		esac; \
	done ) | sort
1219 1220 1221 1222 1223

### Make sure built-ins do not have dups and listed in git.c
#
check-builtins::
	./check-builtins.sh
J
Junio C Hamano 已提交
1224