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