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