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