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