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