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