git-svn: Fix for rewriteRoot URL containing username.
[git/git.git] / Makefile
CommitLineData
2731d048 1# The default target of this Makefile is...
6fc301bb 2all::
2731d048 3
2314c947 4# Define V=1 to have a more verbose compile.
74f2b2a8 5#
c4582f93
MR
6# Define SNPRINTF_RETURNS_BOGUS if your are on a system which snprintf()
7# or vsnprintf() return -1 instead of number of characters which would
8# have been written to the final string if enough space had been available.
9#
cba22528
BC
10# Define FREAD_READS_DIRECTORIES if your are on a system which succeeds
11# when attempting to read from an fopen'ed directory.
12#
765ac8ec
LT
13# Define NO_OPENSSL environment variable if you do not have OpenSSL.
14# This also implies MOZILLA_SHA1.
2cb45e95 15#
8da1e212 16# Define NO_CURL if you do not have libcurl installed. git-http-pull and
58e60dd2
NH
17# git-http-push are not built, and you cannot use http:// and https://
18# transports.
b2c0bd65 19#
6d9bbc50
PM
20# Define CURLDIR=/foo/bar if your curl header and library files are in
21# /foo/bar/include and /foo/bar/lib directories.
22#
58e60dd2
NH
23# Define NO_EXPAT if you do not have expat installed. git-http-push is
24# not built, and you cannot push using http:// and https:// transports.
25#
85b4518f
SB
26# Define EXPATDIR=/foo/bar if your expat header and library files are in
27# /foo/bar/include and /foo/bar/lib directories.
28#
35a730f0
JH
29# Define NO_D_INO_IN_DIRENT if you don't have d_ino in your struct dirent.
30#
63be37b0
JH
31# Define NO_D_TYPE_IN_DIRENT if your platform defines DT_UNKNOWN but lacks
32# d_type in struct dirent (latest Cygwin -- will be fixed soonish).
33#
579d1fbf
RJ
34# Define NO_C99_FORMAT if your formatted IO functions (printf/scanf et.al.)
35# do not support the 'size specifiers' introduced by C99, namely ll, hh,
36# j, z, t. (representing long long int, char, intmax_t, size_t, ptrdiff_t).
465e649d 37# some C compilers supported these specifiers prior to C99 as an extension.
579d1fbf 38#
ef34af24
LT
39# Define NO_STRCASESTR if you don't have strcasestr.
40#
b21b9f1d
RS
41# Define NO_MEMMEM if you don't have memmem.
42#
817151e6
PE
43# Define NO_STRLCPY if you don't have strlcpy.
44#
bc6b4f52
JR
45# Define NO_STRTOUMAX if you don't have strtoumax in the C library.
46# If your compiler also does not support long long or does not have
47# strtoull, define NO_STRTOULL.
48#
e40b61fb
JR
49# Define NO_SETENV if you don't have setenv in the C library.
50#
bfa8fccf
JN
51# Define NO_UNSETENV if you don't have unsetenv in the C library.
52#
ca5bb5d5
SP
53# Define NO_MKDTEMP if you don't have mkdtemp in the C library.
54#
2600973f
RS
55# Define NO_SYS_SELECT_H if you don't have sys/select.h.
56#
9f0bb90d
JH
57# Define NO_SYMLINK_HEAD if you never want .git/HEAD to be a symbolic link.
58# Enable it on Windows. By default, symrefs are still used.
2fabd217 59#
02853588 60# Define NO_SVN_TESTS if you want to skip time-consuming SVN interoperability
60d02ccc
EW
61# tests. These tests take up a significant amount of the total test time
62# but are not needed unless you plan to talk to SVN repos.
63#
8eb38cad
SP
64# Define NO_FINK if you are building on Darwin/Mac OS X, have Fink
65# installed in /sw, but don't want GIT to link against any libraries
66# installed there. If defined you may specify your own (or Fink's)
67# include directories and library directories by defining CFLAGS
68# and LDFLAGS appropriately.
69#
70# Define NO_DARWIN_PORTS if you are building on Darwin/Mac OS X,
71# have DarwinPorts installed in /opt/local, but don't want GIT to
72# link against any libraries installed there. If defined you may
73# specify your own (or DarwinPort's) include directories and
74# library directories by defining CFLAGS and LDFLAGS appropriately.
75#
5bdac8b3
PB
76# Define PPC_SHA1 environment variable when running make to make use of
77# a bundled SHA1 routine optimized for PowerPC.
597c9cc5 78#
7c6ef2f2
NP
79# Define ARM_SHA1 environment variable when running make to make use of
80# a bundled SHA1 routine optimized for ARM.
81#
f6af75d2
JH
82# Define MOZILLA_SHA1 environment variable when running make to make use of
83# a bundled SHA1 routine coming from Mozilla. It is GPL'd and should be fast
84# on non-x86 architectures (e.g. PowerPC), while the OpenSSL version (default
85# choice) has very fast version optimized for i586.
86#
597c9cc5 87# Define NEEDS_SSL_WITH_CRYPTO if you need -lcrypto with -lssl (Darwin).
f0ebff0d 88#
597c9cc5 89# Define NEEDS_LIBICONV if linking with libc is not enough (Darwin).
f0ebff0d
PM
90#
91# Define NEEDS_SOCKET if linking with libc is not enough (SunOS,
92# Patrick Mauritz).
93#
730d48a2
JS
94# Define NO_MMAP if you want to avoid mmap.
95#
46059cc6
JH
96# Define NO_PTHREADS if you do not have or do not want to use Pthreads.
97#
6900679c
SH
98# Define NO_PREAD if you have a problem with pread() system call (e.g.
99# cygwin.dll before v1.5.22).
100#
1510fea7
SP
101# Define NO_FAST_WORKING_DIRECTORY if accessing objects in pack files is
102# generally faster on your platform than accessing the working directory.
103#
c869753e
SP
104# Define NO_TRUSTABLE_FILEMODE if your filesystem may claim to support
105# the executable mode bit, but doesn't really do so.
106#
49744d63
PA
107# Define NO_IPV6 if you lack IPv6 support and getaddrinfo().
108#
bdc37f5a
JH
109# Define NO_SOCKADDR_STORAGE if your platform does not have struct
110# sockaddr_storage.
111#
b6e56eca
FP
112# Define NO_ICONV if your libc does not properly support iconv.
113#
fd547a97
RJ
114# Define OLD_ICONV if your library has an old iconv(), where the second
115# (input buffer pointer) parameter is declared with type (const char **).
116#
609a2289
DS
117# Define NO_DEFLATE_BOUND if your zlib does not have deflateBound.
118#
20648877
MK
119# Define NO_R_TO_GCC_LINKER if your gcc does not like "-R/path/lib"
120# that tells runtime paths to dynamic libraries;
121# "-Wl,-rpath=/path/lib" is used instead.
bbfc63dd 122#
5bdac8b3
PB
123# Define USE_NSEC below if you want git to care about sub-second file mtimes
124# and ctimes. Note that you need recent glibc (at least 2.2.4) for this, and
125# it will BREAK YOUR LOCAL DIFFS! show-diff and anything using it will likely
126# randomly break unless your underlying filesystem supports those sub-second
127# times (my ext3 doesn't).
f6af75d2 128#
5bdac8b3 129# Define USE_STDEV below if you want git to care about the underlying device
10455d2a 130# change being considered an inode change from the update-index perspective.
f848718a 131#
fdb2a2a6
JH
132# Define NO_ST_BLOCKS_IN_STRUCT_STAT if your platform does not have st_blocks
133# field that counts the on-disk footprint in 512-byte blocks.
134#
4c7100a9
JH
135# Define ASCIIDOC8 if you want to format documentation with AsciiDoc 8
136#
7f55cf45
JF
137# Define DOCBOOK_XSL_172 if you want to format man pages with DocBook XSL v1.72.
138#
f848718a
AR
139# Define NO_PERL_MAKEMAKER if you cannot use Makefiles generated by perl's
140# MakeMaker (e.g. using ActiveState under Cygwin).
141#
3cfaf11b
ER
142# Define NO_TCLTK if you do not want Tcl/Tk GUI.
143#
5f5dbd71
SP
144# The TCL_PATH variable governs the location of the Tcl interpreter
145# used to optimize git-gui for your system. Only used if NO_TCLTK
146# is not set. Defaults to the bare 'tclsh'.
147#
148# The TCLTK_PATH variable governs the location of the Tcl/Tk interpreter.
81b63c70
ER
149# If not set it defaults to the bare 'wish'. If it is set to the empty
150# string then NO_TCLTK will be forced (this is used by configure script).
151#
8ecce684
NP
152# Define THREADED_DELTA_SEARCH if you have pthreads and wish to exploit
153# parallel delta searching when packing objects.
154#
43fe901b
BD
155# Define INTERNAL_QSORT to use Git's implementation of qsort(), which
156# is a simplified version of the merge sort used in glibc. This is
157# recommended if Git triggers O(n^2) behavior in your platform's qsort().
158#
5f7c643a
JK
159# Define NO_EXTERNAL_GREP if you don't want "git grep" to ever call
160# your external grep (e.g., if your system lacks grep, if its grep is
161# broken, or spawning external process is slower than built-in grep git has).
5bdac8b3 162
9b88fcef 163GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
36546385 164 @$(SHELL_PATH) ./GIT-VERSION-GEN
9b88fcef 165-include GIT-VERSION-FILE
a9db2974 166
e15f5451
PJ
167uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
168uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not')
169uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')
170uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not')
171uname_P := $(shell sh -c 'uname -p 2>/dev/null || echo not')
46059cc6 172uname_V := $(shell sh -c 'uname -v 2>/dev/null || echo not')
e15f5451 173
94d23317 174# CFLAGS and LDFLAGS are for the users to override from the command line.
12aa7456 175
b05701c5 176CFLAGS = -g -O2 -Wall
94d23317 177LDFLAGS =
12aa7456 178ALL_CFLAGS = $(CFLAGS)
94d23317 179ALL_LDFLAGS = $(LDFLAGS)
4dc00021 180STRIP ?= strip
29c2cce4 181
49fa65a7
JS
182# Among the variables below, these:
183# gitexecdir
184# template_dir
026fa0d5
SP
185# mandir
186# infodir
49fa65a7
JS
187# htmldir
188# ETC_GITCONFIG (but not sysconfdir)
026fa0d5
SP
189# can be specified as a relative path some/where/else;
190# this is interpreted as relative to $(prefix) and "git" at
49fa65a7
JS
191# runtime figures out where they are based on the path to the executable.
192# This can help installing the suite in a relocatable way.
193
b05701c5 194prefix = $(HOME)
026fa0d5
SP
195bindir_relative = bin
196bindir = $(prefix)/$(bindir_relative)
197mandir = share/man
198infodir = share/info
199gitexecdir = libexec/git-core
9354768a 200sharedir = $(prefix)/share
026fa0d5
SP
201template_dir = share/git-core/templates
202htmldir = share/doc/git-doc
b51b8bbf
JT
203ifeq ($(prefix),/usr)
204sysconfdir = /etc
026fa0d5 205ETC_GITCONFIG = $(sysconfdir)/gitconfig
b51b8bbf
JT
206else
207sysconfdir = $(prefix)/etc
026fa0d5 208ETC_GITCONFIG = etc/gitconfig
b51b8bbf 209endif
10861bea 210lib = lib
a682ef9f 211# DESTDIR=
5c2a7fbc 212
5d043a3d 213# default configuration for gitweb
c8d138a8 214GITWEB_CONFIG = gitweb_config.perl
17a8b250 215GITWEB_CONFIG_SYSTEM = /etc/gitweb.conf
2de21fac 216GITWEB_HOME_LINK_STR = projects
5d043a3d
MW
217GITWEB_SITENAME =
218GITWEB_PROJECTROOT = /pub/git
ca5e9495 219GITWEB_PROJECT_MAXDEPTH = 2007
32f4aacc
ML
220GITWEB_EXPORT_OK =
221GITWEB_STRICT_EXPORT =
19a8721e 222GITWEB_BASE_URL =
5d043a3d
MW
223GITWEB_LIST =
224GITWEB_HOMETEXT = indextext.html
225GITWEB_CSS = gitweb.css
281f2f6b 226GITWEB_LOGO = git-logo.png
0b5deba1 227GITWEB_FAVICON = git-favicon.png
b2d3476e
AC
228GITWEB_SITE_HEADER =
229GITWEB_SITE_FOOTER =
5d043a3d 230
8ea7ad69 231export prefix bindir sharedir sysconfdir
e14421b9 232
b05701c5
PR
233CC = gcc
234AR = ar
4cb08df5 235RM = rm -f
229a7ed7 236TAR = tar
89b2f19c 237FIND = find
b05701c5
PR
238INSTALL = install
239RPMBUILD = rpmbuild
5f5dbd71 240TCL_PATH = tclsh
81b63c70 241TCLTK_PATH = wish
158629b2 242PTHREAD_LIBS = -lpthread
e83c5163 243
5f5dbd71
SP
244export TCL_PATH TCLTK_PATH
245
44c9e859
LT
246# sparse is architecture-neutral, which means that we need to tell it
247# explicitly what architecture to check for. Fix this up for yours..
b05701c5 248SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
44c9e859 249
28818ffa
PB
250
251
252### --- END CONFIGURATION SECTION ---
253
8d7f586f 254# Those must not be GNU-specific; they are shared with perl/ which may
18b0fc1c
PB
255# be built by a different compiler. (Note that this is an artifact now
256# but it still might be nice to keep that distinction.)
257BASIC_CFLAGS =
258BASIC_LDFLAGS =
8d7f586f 259
74ca5e6d
JH
260SCRIPT_SH += git-am.sh
261SCRIPT_SH += git-bisect.sh
74ca5e6d
JH
262SCRIPT_SH += git-filter-branch.sh
263SCRIPT_SH += git-lost-found.sh
264SCRIPT_SH += git-merge-octopus.sh
265SCRIPT_SH += git-merge-one-file.sh
266SCRIPT_SH += git-merge-resolve.sh
74ca5e6d
JH
267SCRIPT_SH += git-mergetool.sh
268SCRIPT_SH += git-parse-remote.sh
269SCRIPT_SH += git-pull.sh
270SCRIPT_SH += git-quiltimport.sh
271SCRIPT_SH += git-rebase--interactive.sh
272SCRIPT_SH += git-rebase.sh
273SCRIPT_SH += git-repack.sh
274SCRIPT_SH += git-request-pull.sh
275SCRIPT_SH += git-sh-setup.sh
276SCRIPT_SH += git-stash.sh
277SCRIPT_SH += git-submodule.sh
278SCRIPT_SH += git-web--browse.sh
279
280SCRIPT_PERL += git-add--interactive.perl
281SCRIPT_PERL += git-archimport.perl
282SCRIPT_PERL += git-cvsexportcommit.perl
283SCRIPT_PERL += git-cvsimport.perl
284SCRIPT_PERL += git-cvsserver.perl
285SCRIPT_PERL += git-relink.perl
286SCRIPT_PERL += git-send-email.perl
287SCRIPT_PERL += git-svn.perl
60036a41 288
d6ebd259
AE
289SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \
290 $(patsubst %.perl,%,$(SCRIPT_PERL)) \
e475fe16 291 git-instaweb
d6ebd259 292
42f77406
JH
293# Empty...
294EXTRA_PROGRAMS =
d6ebd259 295
74ca5e6d
JH
296# ... and all the rest that could be moved out of bindir to gitexecdir
297PROGRAMS += $(EXTRA_PROGRAMS)
74ca5e6d
JH
298PROGRAMS += git-fast-import$X
299PROGRAMS += git-fetch-pack$X
300PROGRAMS += git-hash-object$X
74ca5e6d
JH
301PROGRAMS += git-index-pack$X
302PROGRAMS += git-merge-index$X
303PROGRAMS += git-merge-tree$X
304PROGRAMS += git-mktag$X
305PROGRAMS += git-mktree$X
306PROGRAMS += git-pack-redundant$X
307PROGRAMS += git-patch-id$X
74ca5e6d 308PROGRAMS += git-send-pack$X
e705d757 309PROGRAMS += git-shell$X
74ca5e6d
JH
310PROGRAMS += git-show-index$X
311PROGRAMS += git-unpack-file$X
312PROGRAMS += git-update-server-info$X
313PROGRAMS += git-upload-pack$X
314PROGRAMS += git-var$X
315
1736855c
JH
316# List built-in command $C whose implementation cmd_$C() is not in
317# builtin-$C.o but is linked in as part of some other command.
74ca5e6d
JH
318BUILT_INS += $(patsubst builtin-%.o,git-%$X,$(BUILTIN_OBJS))
319
74ca5e6d 320BUILT_INS += git-cherry$X
fcb6c076 321BUILT_INS += git-cherry-pick$X
74ca5e6d
JH
322BUILT_INS += git-format-patch$X
323BUILT_INS += git-fsck-objects$X
324BUILT_INS += git-get-tar-commit-id$X
325BUILT_INS += git-init$X
326BUILT_INS += git-merge-subtree$X
327BUILT_INS += git-peek-remote$X
328BUILT_INS += git-repo-config$X
329BUILT_INS += git-show$X
24b1f65f 330BUILT_INS += git-stage$X
74ca5e6d
JH
331BUILT_INS += git-status$X
332BUILT_INS += git-whatchanged$X
91730800 333
b42934d6 334# what 'all' will build and 'install' will install, in gitexecdir
6506e156 335ALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS)
e83c5163 336
3cfaf11b
ER
337# what 'all' will build but not install in gitexecdir
338OTHER_PROGRAMS = git$X gitweb/gitweb.cgi
3cfaf11b 339
3d32051f
RA
340# Set paths to tools early so that they can be used for version tests.
341ifndef SHELL_PATH
342 SHELL_PATH = /bin/sh
343endif
344ifndef PERL_PATH
345 PERL_PATH = /usr/bin/perl
346endif
720d150c 347
3a793478
LT
348export PERL_PATH
349
0a02ce72 350LIB_FILE=libgit.a
3443546f 351XDIFF_LIB=xdiff/lib.a
8f3f9b09 352
74ca5e6d
JH
353LIB_H += archive.h
354LIB_H += attr.h
355LIB_H += blob.h
356LIB_H += builtin.h
357LIB_H += cache.h
358LIB_H += cache-tree.h
359LIB_H += commit.h
adbc0b6b 360LIB_H += compat/cygwin.h
fcb6c076 361LIB_H += compat/mingw.h
74ca5e6d
JH
362LIB_H += csum-file.h
363LIB_H += decorate.h
364LIB_H += delta.h
365LIB_H += diffcore.h
366LIB_H += diff.h
367LIB_H += dir.h
368LIB_H += fsck.h
369LIB_H += git-compat-util.h
c12172d2 370LIB_H += graph.h
74ca5e6d
JH
371LIB_H += grep.h
372LIB_H += hash.h
940208a7 373LIB_H += help.h
8af84dad 374LIB_H += levenshtein.h
74ca5e6d
JH
375LIB_H += list-objects.h
376LIB_H += ll-merge.h
377LIB_H += log-tree.h
378LIB_H += mailmap.h
db3a9545 379LIB_H += merge-recursive.h
74ca5e6d
JH
380LIB_H += object.h
381LIB_H += pack.h
94e724a7 382LIB_H += pack-refs.h
74ca5e6d
JH
383LIB_H += pack-revindex.h
384LIB_H += parse-options.h
385LIB_H += patch-ids.h
74ca5e6d
JH
386LIB_H += pkt-line.h
387LIB_H += progress.h
388LIB_H += quote.h
389LIB_H += reflog-walk.h
390LIB_H += refs.h
391LIB_H += remote.h
5b2fd956 392LIB_H += rerere.h
74ca5e6d
JH
393LIB_H += revision.h
394LIB_H += run-command.h
628522ec 395LIB_H += sha1-lookup.h
74ca5e6d 396LIB_H += sideband.h
4a16d072 397LIB_H += sigchain.h
74ca5e6d 398LIB_H += strbuf.h
fcb6c076 399LIB_H += string-list.h
74ca5e6d
JH
400LIB_H += tag.h
401LIB_H += transport.h
402LIB_H += tree.h
403LIB_H += tree-walk.h
404LIB_H += unpack-trees.h
be58e70d 405LIB_H += userdiff.h
74ca5e6d 406LIB_H += utf8.h
d3d20b84 407LIB_H += wt-status.h
74ca5e6d 408
5b8e6f85 409LIB_OBJS += abspath.o
74ca5e6d
JH
410LIB_OBJS += alias.o
411LIB_OBJS += alloc.o
412LIB_OBJS += archive.o
413LIB_OBJS += archive-tar.o
414LIB_OBJS += archive-zip.o
415LIB_OBJS += attr.o
416LIB_OBJS += base85.o
417LIB_OBJS += blob.o
418LIB_OBJS += branch.o
419LIB_OBJS += bundle.o
420LIB_OBJS += cache-tree.o
421LIB_OBJS += color.o
422LIB_OBJS += combine-diff.o
423LIB_OBJS += commit.o
424LIB_OBJS += config.o
425LIB_OBJS += connect.o
426LIB_OBJS += convert.o
427LIB_OBJS += copy.o
428LIB_OBJS += csum-file.o
429LIB_OBJS += ctype.o
430LIB_OBJS += date.o
431LIB_OBJS += decorate.o
432LIB_OBJS += diffcore-break.o
433LIB_OBJS += diffcore-delta.o
434LIB_OBJS += diffcore-order.o
435LIB_OBJS += diffcore-pickaxe.o
436LIB_OBJS += diffcore-rename.o
437LIB_OBJS += diff-delta.o
438LIB_OBJS += diff-lib.o
fcb6c076 439LIB_OBJS += diff-no-index.o
74ca5e6d
JH
440LIB_OBJS += diff.o
441LIB_OBJS += dir.o
d82f33e2 442LIB_OBJS += editor.o
74ca5e6d
JH
443LIB_OBJS += entry.o
444LIB_OBJS += environment.o
445LIB_OBJS += exec_cmd.o
446LIB_OBJS += fsck.o
c12172d2 447LIB_OBJS += graph.o
74ca5e6d
JH
448LIB_OBJS += grep.o
449LIB_OBJS += hash.o
450LIB_OBJS += help.o
451LIB_OBJS += ident.o
8af84dad 452LIB_OBJS += levenshtein.o
74ca5e6d
JH
453LIB_OBJS += list-objects.o
454LIB_OBJS += ll-merge.o
455LIB_OBJS += lockfile.o
456LIB_OBJS += log-tree.o
457LIB_OBJS += mailmap.o
458LIB_OBJS += match-trees.o
459LIB_OBJS += merge-file.o
9047ebbc 460LIB_OBJS += merge-recursive.o
96872bc2 461LIB_OBJS += name-hash.o
74ca5e6d
JH
462LIB_OBJS += object.o
463LIB_OBJS += pack-check.o
94e724a7 464LIB_OBJS += pack-refs.o
74ca5e6d
JH
465LIB_OBJS += pack-revindex.o
466LIB_OBJS += pack-write.o
467LIB_OBJS += pager.o
468LIB_OBJS += parse-options.o
469LIB_OBJS += patch-delta.o
470LIB_OBJS += patch-ids.o
74ca5e6d
JH
471LIB_OBJS += path.o
472LIB_OBJS += pkt-line.o
fcb6c076 473LIB_OBJS += preload-index.o
74ca5e6d
JH
474LIB_OBJS += pretty.o
475LIB_OBJS += progress.o
476LIB_OBJS += quote.o
477LIB_OBJS += reachable.o
478LIB_OBJS += read-cache.o
479LIB_OBJS += reflog-walk.o
480LIB_OBJS += refs.o
481LIB_OBJS += remote.o
5b2fd956 482LIB_OBJS += rerere.o
74ca5e6d
JH
483LIB_OBJS += revision.o
484LIB_OBJS += run-command.o
485LIB_OBJS += server-info.o
486LIB_OBJS += setup.o
628522ec 487LIB_OBJS += sha1-lookup.o
fcb6c076 488LIB_OBJS += sha1_file.o
74ca5e6d
JH
489LIB_OBJS += sha1_name.o
490LIB_OBJS += shallow.o
491LIB_OBJS += sideband.o
4a16d072 492LIB_OBJS += sigchain.o
74ca5e6d 493LIB_OBJS += strbuf.o
fcb6c076 494LIB_OBJS += string-list.o
74ca5e6d
JH
495LIB_OBJS += symlinks.o
496LIB_OBJS += tag.o
497LIB_OBJS += trace.o
498LIB_OBJS += transport.o
499LIB_OBJS += tree-diff.o
500LIB_OBJS += tree.o
501LIB_OBJS += tree-walk.o
502LIB_OBJS += unpack-trees.o
503LIB_OBJS += usage.o
fcb6c076 504LIB_OBJS += userdiff.o
74ca5e6d
JH
505LIB_OBJS += utf8.o
506LIB_OBJS += walker.o
112db553 507LIB_OBJS += wrapper.o
74ca5e6d
JH
508LIB_OBJS += write_or_die.o
509LIB_OBJS += ws.o
510LIB_OBJS += wt-status.o
511LIB_OBJS += xdiff-interface.o
512
513BUILTIN_OBJS += builtin-add.o
514BUILTIN_OBJS += builtin-annotate.o
515BUILTIN_OBJS += builtin-apply.o
516BUILTIN_OBJS += builtin-archive.o
517BUILTIN_OBJS += builtin-blame.o
518BUILTIN_OBJS += builtin-branch.o
519BUILTIN_OBJS += builtin-bundle.o
520BUILTIN_OBJS += builtin-cat-file.o
521BUILTIN_OBJS += builtin-check-attr.o
522BUILTIN_OBJS += builtin-check-ref-format.o
523BUILTIN_OBJS += builtin-checkout-index.o
524BUILTIN_OBJS += builtin-checkout.o
525BUILTIN_OBJS += builtin-clean.o
8434c2f1 526BUILTIN_OBJS += builtin-clone.o
74ca5e6d
JH
527BUILTIN_OBJS += builtin-commit-tree.o
528BUILTIN_OBJS += builtin-commit.o
529BUILTIN_OBJS += builtin-config.o
530BUILTIN_OBJS += builtin-count-objects.o
531BUILTIN_OBJS += builtin-describe.o
532BUILTIN_OBJS += builtin-diff-files.o
533BUILTIN_OBJS += builtin-diff-index.o
534BUILTIN_OBJS += builtin-diff-tree.o
535BUILTIN_OBJS += builtin-diff.o
536BUILTIN_OBJS += builtin-fast-export.o
537BUILTIN_OBJS += builtin-fetch--tool.o
538BUILTIN_OBJS += builtin-fetch-pack.o
539BUILTIN_OBJS += builtin-fetch.o
540BUILTIN_OBJS += builtin-fmt-merge-msg.o
541BUILTIN_OBJS += builtin-for-each-ref.o
542BUILTIN_OBJS += builtin-fsck.o
543BUILTIN_OBJS += builtin-gc.o
544BUILTIN_OBJS += builtin-grep.o
3d78d1f1 545BUILTIN_OBJS += builtin-help.o
74ca5e6d
JH
546BUILTIN_OBJS += builtin-init-db.o
547BUILTIN_OBJS += builtin-log.o
548BUILTIN_OBJS += builtin-ls-files.o
549BUILTIN_OBJS += builtin-ls-remote.o
550BUILTIN_OBJS += builtin-ls-tree.o
551BUILTIN_OBJS += builtin-mailinfo.o
552BUILTIN_OBJS += builtin-mailsplit.o
1c7b76be 553BUILTIN_OBJS += builtin-merge.o
74ca5e6d
JH
554BUILTIN_OBJS += builtin-merge-base.o
555BUILTIN_OBJS += builtin-merge-file.o
556BUILTIN_OBJS += builtin-merge-ours.o
557BUILTIN_OBJS += builtin-merge-recursive.o
558BUILTIN_OBJS += builtin-mv.o
559BUILTIN_OBJS += builtin-name-rev.o
560BUILTIN_OBJS += builtin-pack-objects.o
561BUILTIN_OBJS += builtin-pack-refs.o
562BUILTIN_OBJS += builtin-prune-packed.o
563BUILTIN_OBJS += builtin-prune.o
564BUILTIN_OBJS += builtin-push.o
565BUILTIN_OBJS += builtin-read-tree.o
be5908ae 566BUILTIN_OBJS += builtin-receive-pack.o
74ca5e6d
JH
567BUILTIN_OBJS += builtin-reflog.o
568BUILTIN_OBJS += builtin-remote.o
569BUILTIN_OBJS += builtin-rerere.o
570BUILTIN_OBJS += builtin-reset.o
571BUILTIN_OBJS += builtin-rev-list.o
572BUILTIN_OBJS += builtin-rev-parse.o
573BUILTIN_OBJS += builtin-revert.o
574BUILTIN_OBJS += builtin-rm.o
575BUILTIN_OBJS += builtin-send-pack.o
576BUILTIN_OBJS += builtin-shortlog.o
577BUILTIN_OBJS += builtin-show-branch.o
578BUILTIN_OBJS += builtin-show-ref.o
579BUILTIN_OBJS += builtin-stripspace.o
580BUILTIN_OBJS += builtin-symbolic-ref.o
581BUILTIN_OBJS += builtin-tag.o
582BUILTIN_OBJS += builtin-tar-tree.o
583BUILTIN_OBJS += builtin-unpack-objects.o
584BUILTIN_OBJS += builtin-update-index.o
585BUILTIN_OBJS += builtin-update-ref.o
586BUILTIN_OBJS += builtin-upload-archive.o
587BUILTIN_OBJS += builtin-verify-pack.o
588BUILTIN_OBJS += builtin-verify-tag.o
589BUILTIN_OBJS += builtin-write-tree.o
70827b15 590
54c261f9 591GITLIBS = $(LIB_FILE) $(XDIFF_LIB)
bef19da9 592EXTLIBS =
cef661fc 593
229a7ed7
JH
594#
595# Platform specific tweaks
596#
f7c15343
JH
597
598# We choose to avoid "if .. else if .. else .. endif endif"
599# because maintaining the nesting to match is a pain. If
600# we had "elif" things would have been much nicer...
f7c15343 601
817151e6
PE
602ifeq ($(uname_S),Linux)
603 NO_STRLCPY = YesPlease
38bd6497 604 THREADED_DELTA_SEARCH = YesPlease
817151e6 605endif
ca7a7416
GP
606ifeq ($(uname_S),GNU/kFreeBSD)
607 NO_STRLCPY = YesPlease
38bd6497 608 THREADED_DELTA_SEARCH = YesPlease
ca7a7416 609endif
457bb452
BLG
610ifeq ($(uname_S),UnixWare)
611 CC = cc
612 NEEDS_SOCKET = YesPlease
613 NEEDS_NSL = YesPlease
614 NEEDS_SSL_WITH_CRYPTO = YesPlease
615 NEEDS_LIBICONV = YesPlease
616 SHELL_PATH = /usr/local/bin/bash
617 NO_IPV6 = YesPlease
618 NO_HSTRERROR = YesPlease
619 BASIC_CFLAGS += -Kthread
620 BASIC_CFLAGS += -I/usr/local/include
621 BASIC_LDFLAGS += -L/usr/local/lib
622 INSTALL = ginstall
623 TAR = gtar
624 NO_STRCASESTR = YesPlease
625 NO_MEMMEM = YesPlease
626endif
627ifeq ($(uname_S),SCO_SV)
628 ifeq ($(uname_R),3.2)
629 CFLAGS = -O2
630 endif
631 ifeq ($(uname_R),5)
632 CC = cc
633 BASIC_CFLAGS += -Kthread
634 endif
635 NEEDS_SOCKET = YesPlease
636 NEEDS_NSL = YesPlease
637 NEEDS_SSL_WITH_CRYPTO = YesPlease
638 NEEDS_LIBICONV = YesPlease
639 SHELL_PATH = /usr/bin/bash
640 NO_IPV6 = YesPlease
641 NO_HSTRERROR = YesPlease
642 BASIC_CFLAGS += -I/usr/local/include
643 BASIC_LDFLAGS += -L/usr/local/lib
644 NO_STRCASESTR = YesPlease
645 NO_MEMMEM = YesPlease
646 INSTALL = ginstall
647 TAR = gtar
648endif
f7c15343 649ifeq ($(uname_S),Darwin)
597c9cc5
JH
650 NEEDS_SSL_WITH_CRYPTO = YesPlease
651 NEEDS_LIBICONV = YesPlease
7233d221 652 ifeq ($(shell expr "$(uname_R)" : '[15678]\.'),2)
fe4aafba
WC
653 OLD_ICONV = UnfortunatelyYes
654 endif
7233d221
JS
655 ifeq ($(shell expr "$(uname_R)" : '[15]\.'),2)
656 NO_STRLCPY = YesPlease
657 endif
3d59405c 658 NO_MEMMEM = YesPlease
954597bd 659 THREADED_DELTA_SEARCH = YesPlease
597c9cc5 660endif
f7c15343 661ifeq ($(uname_S),SunOS)
f0ebff0d 662 NEEDS_SOCKET = YesPlease
5a90d4ac 663 NEEDS_NSL = YesPlease
229a7ed7
JH
664 SHELL_PATH = /bin/bash
665 NO_STRCASESTR = YesPlease
b21b9f1d 666 NO_MEMMEM = YesPlease
fa0c87c3 667 NO_HSTRERROR = YesPlease
4e0da763 668 NO_MKDTEMP = YesPlease
6e2dfb16 669 OLD_ICONV = UnfortunatelyYes
e40b61fb 670 ifeq ($(uname_R),5.8)
731043fd 671 NO_UNSETENV = YesPlease
e40b61fb 672 NO_SETENV = YesPlease
66c4509b 673 NO_C99_FORMAT = YesPlease
bc6b4f52 674 NO_STRTOUMAX = YesPlease
e40b61fb 675 endif
40d88d4f
DS
676 ifeq ($(uname_R),5.9)
677 NO_UNSETENV = YesPlease
678 NO_SETENV = YesPlease
66c4509b 679 NO_C99_FORMAT = YesPlease
bc6b4f52 680 NO_STRTOUMAX = YesPlease
40d88d4f 681 endif
229a7ed7
JH
682 INSTALL = ginstall
683 TAR = gtar
8d7f586f 684 BASIC_CFLAGS += -D__EXTENSIONS__
f0ebff0d 685endif
f7c15343 686ifeq ($(uname_O),Cygwin)
63be37b0 687 NO_D_TYPE_IN_DIRENT = YesPlease
35a730f0 688 NO_D_INO_IN_DIRENT = YesPlease
17754517 689 NO_STRCASESTR = YesPlease
b21b9f1d 690 NO_MEMMEM = YesPlease
9f0bb90d 691 NO_SYMLINK_HEAD = YesPlease
17754517 692 NEEDS_LIBICONV = YesPlease
1510fea7 693 NO_FAST_WORKING_DIRECTORY = UnfortunatelyYes
c869753e 694 NO_TRUSTABLE_FILEMODE = UnfortunatelyYes
7a4a2e1f 695 OLD_ICONV = UnfortunatelyYes
2e67a5f4
JH
696 # There are conflicting reports about this.
697 # On some boxes NO_MMAP is needed, and not so elsewhere.
87ac1390
JH
698 # Try commenting this out if you suspect MMAP is more efficient
699 NO_MMAP = YesPlease
49744d63 700 NO_IPV6 = YesPlease
a23cd8ec 701 X = .exe
7c6ef2f2 702endif
b3bf974c
AK
703ifeq ($(uname_S),FreeBSD)
704 NEEDS_LIBICONV = YesPlease
a2f22dbf 705 NO_MEMMEM = YesPlease
8d7f586f
PB
706 BASIC_CFLAGS += -I/usr/local/include
707 BASIC_LDFLAGS += -L/usr/local/lib
81a24b52 708 DIR_HAS_BSD_GROUP_SEMANTICS = YesPlease
38bd6497 709 THREADED_DELTA_SEARCH = YesPlease
069bb576 710 ifeq ($(shell expr "$(uname_R)" : '4\.'),2)
158629b2 711 PTHREAD_LIBS = -pthread
069bb576
DS
712 NO_UINTMAX_T = YesPlease
713 NO_STRTOUMAX = YesPlease
714 endif
b3bf974c 715endif
f7c15343 716ifeq ($(uname_S),OpenBSD)
5fb41e8a 717 NO_STRCASESTR = YesPlease
b21b9f1d 718 NO_MEMMEM = YesPlease
18c5a525 719 NEEDS_LIBICONV = YesPlease
8d7f586f
PB
720 BASIC_CFLAGS += -I/usr/local/include
721 BASIC_LDFLAGS += -L/usr/local/lib
38bd6497 722 THREADED_DELTA_SEARCH = YesPlease
94d23317
JH
723endif
724ifeq ($(uname_S),NetBSD)
e88856b4
DS
725 ifeq ($(shell expr "$(uname_R)" : '[01]\.'),2)
726 NEEDS_LIBICONV = YesPlease
727 endif
8d7f586f 728 BASIC_CFLAGS += -I/usr/pkg/include
f5b904db 729 BASIC_LDFLAGS += -L/usr/pkg/lib $(CC_LD_DYNPATH)/usr/pkg/lib
38bd6497 730 THREADED_DELTA_SEARCH = YesPlease
18c5a525 731endif
a6da9395
JR
732ifeq ($(uname_S),AIX)
733 NO_STRCASESTR=YesPlease
b21b9f1d 734 NO_MEMMEM = YesPlease
377d9c40 735 NO_MKDTEMP = YesPlease
817151e6 736 NO_STRLCPY = YesPlease
377d9c40
MR
737 FREAD_READS_DIRECTORIES = UnfortunatelyYes
738 INTERNAL_QSORT = UnfortunatelyYes
a6da9395 739 NEEDS_LIBICONV=YesPlease
377d9c40 740 BASIC_CFLAGS += -D_LARGE_FILES
46059cc6
JH
741 ifneq ($(shell expr "$(uname_V)" : '[1234]'),1)
742 THREADED_DELTA_SEARCH = YesPlease
743 else
744 NO_PTHREADS = YesPlease
745 endif
a6da9395 746endif
c29ba0c3
TS
747ifeq ($(uname_S),GNU)
748 # GNU/Hurd
749 NO_STRLCPY=YesPlease
750endif
289c4b36
JS
751ifeq ($(uname_S),IRIX64)
752 NO_IPV6=YesPlease
753 NO_SETENV=YesPlease
754 NO_STRCASESTR=YesPlease
b21b9f1d 755 NO_MEMMEM = YesPlease
817151e6 756 NO_STRLCPY = YesPlease
289c4b36
JS
757 NO_SOCKADDR_STORAGE=YesPlease
758 SHELL_PATH=/usr/gnu/bin/bash
8d7f586f 759 BASIC_CFLAGS += -DPATH_MAX=1024
289c4b36 760 # for now, build 32-bit version
8d7f586f 761 BASIC_LDFLAGS += -L/usr/lib32
289c4b36 762endif
81cc66a5
RS
763ifeq ($(uname_S),HP-UX)
764 NO_IPV6=YesPlease
765 NO_SETENV=YesPlease
766 NO_STRCASESTR=YesPlease
767 NO_MEMMEM = YesPlease
768 NO_STRLCPY = YesPlease
769 NO_MKDTEMP = YesPlease
770 NO_UNSETENV = YesPlease
771 NO_HSTRERROR = YesPlease
772 NO_SYS_SELECT_H = YesPlease
7d770163 773 SNPRINTF_RETURNS_BOGUS = YesPlease
81cc66a5 774endif
adbc0b6b
DP
775ifneq (,$(findstring CYGWIN,$(uname_S)))
776 COMPAT_OBJS += compat/cygwin.o
777endif
f4626df5
JS
778ifneq (,$(findstring MINGW,$(uname_S)))
779 NO_MMAP = YesPlease
780 NO_PREAD = YesPlease
781 NO_OPENSSL = YesPlease
782 NO_CURL = YesPlease
783 NO_SYMLINK_HEAD = YesPlease
784 NO_IPV6 = YesPlease
785 NO_SETENV = YesPlease
786 NO_UNSETENV = YesPlease
787 NO_STRCASESTR = YesPlease
788 NO_STRLCPY = YesPlease
789 NO_MEMMEM = YesPlease
46059cc6 790 NO_PTHREADS = YesPlease
f4626df5
JS
791 NEEDS_LIBICONV = YesPlease
792 OLD_ICONV = YesPlease
793 NO_C99_FORMAT = YesPlease
794 NO_STRTOUMAX = YesPlease
795 NO_MKDTEMP = YesPlease
796 SNPRINTF_RETURNS_BOGUS = YesPlease
797 NO_SVN_TESTS = YesPlease
798 NO_PERL_MAKEMAKER = YesPlease
25655221 799 RUNTIME_PREFIX = YesPlease
f4626df5 800 NO_POSIX_ONLY_PROGRAMS = YesPlease
fdb2a2a6 801 NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease
3632cfc2 802 COMPAT_CFLAGS += -D__USE_MINGW_ACCESS -DNOGDI -Icompat -Icompat/regex -Icompat/fnmatch
f4626df5 803 COMPAT_CFLAGS += -DSNPRINTF_SIZE_CORR=1
23326d14 804 COMPAT_CFLAGS += -DSTRIP_EXTENSION=\".exe\"
3632cfc2 805 COMPAT_OBJS += compat/mingw.o compat/fnmatch/fnmatch.o compat/regex/regex.o compat/winansi.o
f4626df5
JS
806 EXTLIBS += -lws2_32
807 X = .exe
808endif
f7c15343
JH
809ifneq (,$(findstring arm,$(uname_M)))
810 ARM_SHA1 = YesPlease
811endif
597c9cc5 812
55667714 813-include config.mak.autogen
f2d6a256 814-include config.mak
597c9cc5 815
59f86740
BG
816ifeq ($(uname_S),Darwin)
817 ifndef NO_FINK
818 ifeq ($(shell test -d /sw/lib && echo y),y)
819 BASIC_CFLAGS += -I/sw/include
820 BASIC_LDFLAGS += -L/sw/lib
821 endif
822 endif
823 ifndef NO_DARWIN_PORTS
824 ifeq ($(shell test -d /opt/local/lib && echo y),y)
825 BASIC_CFLAGS += -I/opt/local/include
826 BASIC_LDFLAGS += -L/opt/local/lib
827 endif
828 endif
f7d9d04e 829 PTHREAD_LIBS =
59f86740
BG
830endif
831
f5b904db
JH
832ifndef CC_LD_DYNPATH
833 ifdef NO_R_TO_GCC_LINKER
834 # Some gcc does not accept and pass -R to the linker to specify
835 # the runtime dynamic library path.
836 CC_LD_DYNPATH = -Wl,-rpath,
837 else
838 CC_LD_DYNPATH = -R
839 endif
bbfc63dd
JH
840endif
841
30ae764b
DB
842ifdef NO_CURL
843 BASIC_CFLAGS += -DNO_CURL
844else
229a7ed7 845 ifdef CURLDIR
10861bea 846 # Try "-Wl,-rpath=$(CURLDIR)/$(lib)" in such a case.
8d7f586f 847 BASIC_CFLAGS += -I$(CURLDIR)/include
10861bea 848 CURL_LIBCURL = -L$(CURLDIR)/$(lib) $(CC_LD_DYNPATH)$(CURLDIR)/$(lib) -lcurl
229a7ed7
JH
849 else
850 CURL_LIBCURL = -lcurl
851 endif
30ae764b
DB
852 BUILTIN_OBJS += builtin-http-fetch.o
853 EXTLIBS += $(CURL_LIBCURL)
ccfc02a3 854 LIB_OBJS += http.o http-walker.o
08900987
NH
855 curl_check := $(shell (echo 070908; curl-config --vernum) | sort -r | sed -ne 2p)
856 ifeq "$(curl_check)" "070908"
857 ifndef NO_EXPAT
08900987
NH
858 PROGRAMS += git-http-push$X
859 endif
58e60dd2 860 endif
459a21bd 861 ifndef NO_EXPAT
85b4518f
SB
862 ifdef EXPATDIR
863 BASIC_CFLAGS += -I$(EXPATDIR)/include
864 EXPAT_LIBEXPAT = -L$(EXPATDIR)/$(lib) $(CC_LD_DYNPATH)$(EXPATDIR)/$(lib) -lexpat
865 else
866 EXPAT_LIBEXPAT = -lexpat
867 endif
459a21bd 868 endif
229a7ed7
JH
869endif
870
bef19da9
RS
871ifdef ZLIB_PATH
872 BASIC_CFLAGS += -I$(ZLIB_PATH)/include
10861bea 873 EXTLIBS += -L$(ZLIB_PATH)/$(lib) $(CC_LD_DYNPATH)$(ZLIB_PATH)/$(lib)
bef19da9
RS
874endif
875EXTLIBS += -lz
876
58eda022
JS
877ifndef NO_POSIX_ONLY_PROGRAMS
878 PROGRAMS += git-daemon$X
879 PROGRAMS += git-imap-send$X
880endif
dd53c7ab 881ifndef NO_OPENSSL
215a7ad1 882 OPENSSL_LIBSSL = -lssl
455a7f32 883 ifdef OPENSSLDIR
8d7f586f 884 BASIC_CFLAGS += -I$(OPENSSLDIR)/include
10861bea 885 OPENSSL_LINK = -L$(OPENSSLDIR)/$(lib) $(CC_LD_DYNPATH)$(OPENSSLDIR)/$(lib)
455a7f32
JH
886 else
887 OPENSSL_LINK =
888 endif
dd53c7ab 889else
8d7f586f 890 BASIC_CFLAGS += -DNO_OPENSSL
215a7ad1
JH
891 MOZILLA_SHA1 = 1
892 OPENSSL_LIBSSL =
dd53c7ab 893endif
597c9cc5 894ifdef NEEDS_SSL_WITH_CRYPTO
455a7f32 895 LIB_4_CRYPTO = $(OPENSSL_LINK) -lcrypto -lssl
597c9cc5 896else
455a7f32 897 LIB_4_CRYPTO = $(OPENSSL_LINK) -lcrypto
597c9cc5
JH
898endif
899ifdef NEEDS_LIBICONV
455a7f32 900 ifdef ICONVDIR
8d7f586f 901 BASIC_CFLAGS += -I$(ICONVDIR)/include
10861bea 902 ICONV_LINK = -L$(ICONVDIR)/$(lib) $(CC_LD_DYNPATH)$(ICONVDIR)/$(lib)
455a7f32
JH
903 else
904 ICONV_LINK =
905 endif
d595a473 906 EXTLIBS += $(ICONV_LINK) -liconv
597c9cc5 907endif
f0ebff0d 908ifdef NEEDS_SOCKET
d595a473 909 EXTLIBS += -lsocket
f0ebff0d 910endif
5a90d4ac 911ifdef NEEDS_NSL
d595a473 912 EXTLIBS += -lnsl
5a90d4ac 913endif
63be37b0 914ifdef NO_D_TYPE_IN_DIRENT
8d7f586f 915 BASIC_CFLAGS += -DNO_D_TYPE_IN_DIRENT
63be37b0 916endif
35a730f0 917ifdef NO_D_INO_IN_DIRENT
8d7f586f 918 BASIC_CFLAGS += -DNO_D_INO_IN_DIRENT
35a730f0 919endif
fdb2a2a6
JH
920ifdef NO_ST_BLOCKS_IN_STRUCT_STAT
921 BASIC_CFLAGS += -DNO_ST_BLOCKS_IN_STRUCT_STAT
922endif
579d1fbf 923ifdef NO_C99_FORMAT
8188e73b 924 BASIC_CFLAGS += -DNO_C99_FORMAT
579d1fbf 925endif
c4582f93
MR
926ifdef SNPRINTF_RETURNS_BOGUS
927 COMPAT_CFLAGS += -DSNPRINTF_RETURNS_BOGUS
928 COMPAT_OBJS += compat/snprintf.o
929endif
cba22528
BC
930ifdef FREAD_READS_DIRECTORIES
931 COMPAT_CFLAGS += -DFREAD_READS_DIRECTORIES
932 COMPAT_OBJS += compat/fopen.o
933endif
9f0bb90d 934ifdef NO_SYMLINK_HEAD
8d7f586f 935 BASIC_CFLAGS += -DNO_SYMLINK_HEAD
9f0bb90d 936endif
ef34af24 937ifdef NO_STRCASESTR
4050c0df 938 COMPAT_CFLAGS += -DNO_STRCASESTR
e40b61fb
JR
939 COMPAT_OBJS += compat/strcasestr.o
940endif
817151e6
PE
941ifdef NO_STRLCPY
942 COMPAT_CFLAGS += -DNO_STRLCPY
943 COMPAT_OBJS += compat/strlcpy.o
944endif
bc6b4f52
JR
945ifdef NO_STRTOUMAX
946 COMPAT_CFLAGS += -DNO_STRTOUMAX
947 COMPAT_OBJS += compat/strtoumax.o
948endif
949ifdef NO_STRTOULL
950 COMPAT_CFLAGS += -DNO_STRTOULL
951endif
e40b61fb 952ifdef NO_SETENV
4050c0df 953 COMPAT_CFLAGS += -DNO_SETENV
e40b61fb 954 COMPAT_OBJS += compat/setenv.o
ef34af24 955endif
ca5bb5d5
SP
956ifdef NO_MKDTEMP
957 COMPAT_CFLAGS += -DNO_MKDTEMP
958 COMPAT_OBJS += compat/mkdtemp.o
959endif
104ff34a 960ifdef NO_UNSETENV
731043fd
JR
961 COMPAT_CFLAGS += -DNO_UNSETENV
962 COMPAT_OBJS += compat/unsetenv.o
963endif
2600973f
RS
964ifdef NO_SYS_SELECT_H
965 BASIC_CFLAGS += -DNO_SYS_SELECT_H
966endif
730d48a2 967ifdef NO_MMAP
4050c0df 968 COMPAT_CFLAGS += -DNO_MMAP
e40b61fb 969 COMPAT_OBJS += compat/mmap.o
730d48a2 970endif
6900679c
SH
971ifdef NO_PREAD
972 COMPAT_CFLAGS += -DNO_PREAD
973 COMPAT_OBJS += compat/pread.o
974endif
1510fea7
SP
975ifdef NO_FAST_WORKING_DIRECTORY
976 BASIC_CFLAGS += -DNO_FAST_WORKING_DIRECTORY
977endif
c869753e
SP
978ifdef NO_TRUSTABLE_FILEMODE
979 BASIC_CFLAGS += -DNO_TRUSTABLE_FILEMODE
980endif
49744d63 981ifdef NO_IPV6
8d7f586f 982 BASIC_CFLAGS += -DNO_IPV6
bdc37f5a 983endif
0bc3e781
DS
984ifdef NO_UINTMAX_T
985 BASIC_CFLAGS += -Duintmax_t=uint32_t
986endif
bdc37f5a
JH
987ifdef NO_SOCKADDR_STORAGE
988ifdef NO_IPV6
8d7f586f 989 BASIC_CFLAGS += -Dsockaddr_storage=sockaddr_in
bdc37f5a 990else
8d7f586f 991 BASIC_CFLAGS += -Dsockaddr_storage=sockaddr_in6
bdc37f5a 992endif
49744d63 993endif
6ba68ab2
YL
994ifdef NO_INET_NTOP
995 LIB_OBJS += compat/inet_ntop.o
996endif
dd467629
JL
997ifdef NO_INET_PTON
998 LIB_OBJS += compat/inet_pton.o
999endif
cef661fc 1000
b6e56eca 1001ifdef NO_ICONV
8d7f586f 1002 BASIC_CFLAGS += -DNO_ICONV
b6e56eca
FP
1003endif
1004
fd547a97
RJ
1005ifdef OLD_ICONV
1006 BASIC_CFLAGS += -DOLD_ICONV
1007endif
1008
609a2289
DS
1009ifdef NO_DEFLATE_BOUND
1010 BASIC_CFLAGS += -DNO_DEFLATE_BOUND
1011endif
1012
7c6ef2f2
NP
1013ifdef PPC_SHA1
1014 SHA1_HEADER = "ppc/sha1.h"
1015 LIB_OBJS += ppc/sha1.o ppc/sha1ppc.o
1016else
1017ifdef ARM_SHA1
1018 SHA1_HEADER = "arm/sha1.h"
1019 LIB_OBJS += arm/sha1.o arm/sha1_arm.o
1020else
1021ifdef MOZILLA_SHA1
1022 SHA1_HEADER = "mozilla-sha1/sha1.h"
1023 LIB_OBJS += mozilla-sha1/sha1.o
1024else
1025 SHA1_HEADER = <openssl/sha.h>
d595a473 1026 EXTLIBS += $(LIB_4_CRYPTO)
7c6ef2f2
NP
1027endif
1028endif
1029endif
f848718a
AR
1030ifdef NO_PERL_MAKEMAKER
1031 export NO_PERL_MAKEMAKER
1032endif
fa0c87c3
AR
1033ifdef NO_HSTRERROR
1034 COMPAT_CFLAGS += -DNO_HSTRERROR
1035 COMPAT_OBJS += compat/hstrerror.o
1036endif
b21b9f1d
RS
1037ifdef NO_MEMMEM
1038 COMPAT_CFLAGS += -DNO_MEMMEM
1039 COMPAT_OBJS += compat/memmem.o
1040endif
43fe901b
BD
1041ifdef INTERNAL_QSORT
1042 COMPAT_CFLAGS += -DINTERNAL_QSORT
1043 COMPAT_OBJS += compat/qsort.o
1044endif
35fb0e86
SP
1045ifdef RUNTIME_PREFIX
1046 COMPAT_CFLAGS += -DRUNTIME_PREFIX
1047endif
b7774343 1048
46059cc6
JH
1049ifdef NO_PTHREADS
1050 THREADED_DELTA_SEARCH =
1051 BASIC_CFLAGS += -DNO_PTHREADS
1052else
1053 EXTLIBS += $(PTHREAD_LIBS)
1054endif
1055
8ecce684
NP
1056ifdef THREADED_DELTA_SEARCH
1057 BASIC_CFLAGS += -DTHREADED_DELTA_SEARCH
833e3df1 1058 LIB_OBJS += thread-utils.o
8ecce684 1059endif
81a24b52
AR
1060ifdef DIR_HAS_BSD_GROUP_SEMANTICS
1061 COMPAT_CFLAGS += -DDIR_HAS_BSD_GROUP_SEMANTICS
1062endif
5f7c643a
JK
1063ifdef NO_EXTERNAL_GREP
1064 BASIC_CFLAGS += -DNO_EXTERNAL_GREP
1065endif
8ecce684 1066
81b63c70
ER
1067ifeq ($(TCLTK_PATH),)
1068NO_TCLTK=NoThanks
1069endif
1070
3b486cd2 1071QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir
b7774343
AR
1072QUIET_SUBDIR1 =
1073
a6f37099
AR
1074ifneq ($(findstring $(MAKEFLAGS),w),w)
1075PRINT_DIR = --no-print-directory
1076else # "make -w"
1077NO_SUBDIR = :
1078endif
1079
b7774343 1080ifneq ($(findstring $(MAKEFLAGS),s),s)
2314c947 1081ifndef V
31d0399c 1082 QUIET_CC = @echo ' ' CC $@;
74f2b2a8
SP
1083 QUIET_AR = @echo ' ' AR $@;
1084 QUIET_LINK = @echo ' ' LINK $@;
1085 QUIET_BUILT_IN = @echo ' ' BUILTIN $@;
1086 QUIET_GEN = @echo ' ' GEN $@;
3b486cd2 1087 QUIET_SUBDIR0 = +@subdir=
a6f37099
AR
1088 QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \
1089 $(MAKE) $(PRINT_DIR) -C $$subdir
2314c947 1090 export V
31d0399c 1091 export QUIET_GEN
b7774343
AR
1092 export QUIET_BUILT_IN
1093endif
74f2b2a8 1094endif
7c6ef2f2 1095
4c7100a9
JH
1096ifdef ASCIIDOC8
1097 export ASCIIDOC8
1098endif
1099
addf88e4 1100# Shell quote (do not use $(call) to accommodate ancient setups);
39c015c5
JS
1101
1102SHA1_HEADER_SQ = $(subst ','\'',$(SHA1_HEADER))
32043c9f 1103ETC_GITCONFIG_SQ = $(subst ','\'',$(ETC_GITCONFIG))
39c015c5
JS
1104
1105DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
1106bindir_SQ = $(subst ','\'',$(bindir))
026fa0d5 1107bindir_relative_SQ = $(subst ','\'',$(bindir_relative))
8e566f24 1108mandir_SQ = $(subst ','\'',$(mandir))
a149a1a4 1109infodir_SQ = $(subst ','\'',$(infodir))
39c015c5
JS
1110gitexecdir_SQ = $(subst ','\'',$(gitexecdir))
1111template_dir_SQ = $(subst ','\'',$(template_dir))
5d6491c7 1112htmldir_SQ = $(subst ','\'',$(htmldir))
ca3bcabf 1113prefix_SQ = $(subst ','\'',$(prefix))
39c015c5
JS
1114
1115SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
1116PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
81b63c70 1117TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH))
39c015c5 1118
d595a473
PB
1119LIBS = $(GITLIBS) $(EXTLIBS)
1120
32043c9f 1121BASIC_CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER_SQ)' \
506b17b1 1122 $(COMPAT_CFLAGS)
e40b61fb 1123LIB_OBJS += $(COMPAT_OBJS)
8d7f586f
PB
1124
1125ALL_CFLAGS += $(BASIC_CFLAGS)
1126ALL_LDFLAGS += $(BASIC_LDFLAGS)
1127
a42cbacc 1128export TAR INSTALL DESTDIR SHELL_PATH
d595a473
PB
1129
1130
28818ffa
PB
1131### Build rules
1132
c94c8e5f
BC
1133SHELL = $(SHELL_PATH)
1134
6dc4627e 1135all:: shell_compatibility_test $(ALL_PROGRAMS) $(BUILT_INS) $(OTHER_PROGRAMS) GIT-BUILD-OPTIONS
6fc301bb 1136ifneq (,$X)
0d768f7c 1137 $(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) git$X)), test '$p' -ef '$p$X' || $(RM) '$p';)
6fc301bb 1138endif
89967023 1139
6fc301bb 1140all::
3cfaf11b 1141ifndef NO_TCLTK
e84a063d 1142 $(QUIET_SUBDIR0)git-gui $(QUIET_SUBDIR1) gitexecdir='$(gitexec_instdir_SQ)' all
62ba5143 1143 $(QUIET_SUBDIR0)gitk-git $(QUIET_SUBDIR1) all
3cfaf11b 1144endif
74f2b2a8
SP
1145 $(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' all
1146 $(QUIET_SUBDIR0)templates $(QUIET_SUBDIR1)
b05701c5 1147
6dc4627e
BC
1148please_set_SHELL_PATH_to_a_more_modern_shell:
1149 @$$(:)
1150
1151shell_compatibility_test: please_set_SHELL_PATH_to_a_more_modern_shell
1152
4dc00021
JH
1153strip: $(PROGRAMS) git$X
1154 $(STRIP) $(STRIP_OPTS) $(PROGRAMS) git$X
1155
334d28ae
JH
1156git.o: git.c common-cmds.h GIT-CFLAGS
1157 $(QUIET_CC)$(CC) -DGIT_VERSION='"$(GIT_VERSION)"' \
1158 $(ALL_CFLAGS) -c $(filter %.c,$^)
1159
1160git$X: git.o $(BUILTIN_OBJS) $(GITLIBS)
54dadbdb 1161 $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ git.o \
70827b15 1162 $(BUILTIN_OBJS) $(ALL_LDFLAGS) $(LIBS)
6a2e50f9 1163
3d78d1f1 1164builtin-help.o: builtin-help.c common-cmds.h GIT-CFLAGS
a149a1a4 1165 $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) \
482cce82 1166 '-DGIT_HTML_PATH="$(htmldir_SQ)"' \
a149a1a4
JH
1167 '-DGIT_MAN_PATH="$(mandir_SQ)"' \
1168 '-DGIT_INFO_PATH="$(infodir_SQ)"' $<
08df6171 1169
91730800 1170$(BUILT_INS): git$X
3e073dc5
AF
1171 $(QUIET_BUILT_IN)$(RM) $@ && \
1172 ln git$X $@ 2>/dev/null || \
1173 ln -s git$X $@ 2>/dev/null || \
1174 cp git$X $@
91730800 1175
79d30668 1176common-cmds.h: ./generate-cmdlist.sh command-list.txt
48dd1da8 1177
766b084f 1178common-cmds.h: $(wildcard Documentation/git-*.txt)
74f2b2a8 1179 $(QUIET_GEN)./generate-cmdlist.sh > $@+ && mv $@+ $@
a87cd02c 1180
d6ebd259 1181$(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
4cb08df5 1182 $(QUIET_GEN)$(RM) $@ $@+ && \
39c015c5 1183 sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
4bf9f27d 1184 -e 's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \
d9bffc08 1185 -e 's|@@PERL@@|$(PERL_PATH_SQ)|g' \
3ff8cbed 1186 -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
6c5c62f3 1187 -e 's/@@NO_CURL@@/$(NO_CURL)/g' \
74f2b2a8
SP
1188 $@.sh >$@+ && \
1189 chmod +x $@+ && \
fc36f6a6 1190 mv $@+ $@
bc6146d2 1191
f848718a
AR
1192$(patsubst %.perl,%,$(SCRIPT_PERL)): perl/perl.mak
1193
d1a20575 1194perl/perl.mak: GIT-CFLAGS perl/Makefile perl/Makefile.PL
31d0399c 1195 $(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' $(@F)
f848718a 1196
f6276fe1 1197$(patsubst %.perl,%,$(SCRIPT_PERL)): % : %.perl
4cb08df5 1198 $(QUIET_GEN)$(RM) $@ $@+ && \
e883932f 1199 INSTLIBDIR=`MAKEFLAGS= $(MAKE) -C perl -s --no-print-directory instlibdir` && \
998c4daa
JH
1200 sed -e '1{' \
1201 -e ' s|#!.*perl|#!$(PERL_PATH_SQ)|' \
1202 -e ' h' \
1203 -e ' s=.*=use lib (split(/:/, $$ENV{GITPERLLIB} || "@@INSTLIBDIR@@"));=' \
1204 -e ' H' \
1205 -e ' x' \
1206 -e '}' \
f6276fe1 1207 -e 's|@@INSTLIBDIR@@|'"$$INSTLIBDIR"'|g' \
3ff8cbed 1208 -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
74f2b2a8
SP
1209 $@.perl >$@+ && \
1210 chmod +x $@+ && \
fc36f6a6 1211 mv $@+ $@
bc6146d2 1212
5d043a3d 1213gitweb/gitweb.cgi: gitweb/gitweb.perl
4cb08df5 1214 $(QUIET_GEN)$(RM) $@ $@+ && \
5d043a3d 1215 sed -e '1s|#!.*perl|#!$(PERL_PATH_SQ)|' \
06c084d2
JH
1216 -e 's|++GIT_VERSION++|$(GIT_VERSION)|g' \
1217 -e 's|++GIT_BINDIR++|$(bindir)|g' \
1218 -e 's|++GITWEB_CONFIG++|$(GITWEB_CONFIG)|g' \
26ffcb76 1219 -e 's|++GITWEB_CONFIG_SYSTEM++|$(GITWEB_CONFIG_SYSTEM)|g' \
2de21fac 1220 -e 's|++GITWEB_HOME_LINK_STR++|$(GITWEB_HOME_LINK_STR)|g' \
06c084d2
JH
1221 -e 's|++GITWEB_SITENAME++|$(GITWEB_SITENAME)|g' \
1222 -e 's|++GITWEB_PROJECTROOT++|$(GITWEB_PROJECTROOT)|g' \
ca5e9495 1223 -e 's|"++GITWEB_PROJECT_MAXDEPTH++"|$(GITWEB_PROJECT_MAXDEPTH)|g' \
32f4aacc
ML
1224 -e 's|++GITWEB_EXPORT_OK++|$(GITWEB_EXPORT_OK)|g' \
1225 -e 's|++GITWEB_STRICT_EXPORT++|$(GITWEB_STRICT_EXPORT)|g' \
19a8721e 1226 -e 's|++GITWEB_BASE_URL++|$(GITWEB_BASE_URL)|g' \
06c084d2
JH
1227 -e 's|++GITWEB_LIST++|$(GITWEB_LIST)|g' \
1228 -e 's|++GITWEB_HOMETEXT++|$(GITWEB_HOMETEXT)|g' \
1229 -e 's|++GITWEB_CSS++|$(GITWEB_CSS)|g' \
1230 -e 's|++GITWEB_LOGO++|$(GITWEB_LOGO)|g' \
0b5deba1 1231 -e 's|++GITWEB_FAVICON++|$(GITWEB_FAVICON)|g' \
b2d3476e
AC
1232 -e 's|++GITWEB_SITE_HEADER++|$(GITWEB_SITE_HEADER)|g' \
1233 -e 's|++GITWEB_SITE_FOOTER++|$(GITWEB_SITE_FOOTER)|g' \
74f2b2a8
SP
1234 $< >$@+ && \
1235 chmod +x $@+ && \
5d043a3d
MW
1236 mv $@+ $@
1237
a51d37c1 1238git-instaweb: git-instaweb.sh gitweb/gitweb.cgi gitweb/gitweb.css
4cb08df5 1239 $(QUIET_GEN)$(RM) $@ $@+ && \
a51d37c1
EW
1240 sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
1241 -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
1242 -e 's/@@NO_CURL@@/$(NO_CURL)/g' \
6e959ab0 1243 -e '/@@GITWEB_CGI@@/r gitweb/gitweb.cgi' \
07002287 1244 -e '/@@GITWEB_CGI@@/d' \
6e959ab0 1245 -e '/@@GITWEB_CSS@@/r gitweb/gitweb.css' \
07002287 1246 -e '/@@GITWEB_CSS@@/d' \
c5699693 1247 -e 's|@@PERL@@|$(PERL_PATH_SQ)|g' \
74f2b2a8
SP
1248 $@.sh > $@+ && \
1249 chmod +x $@+ && \
a51d37c1
EW
1250 mv $@+ $@
1251
3900145e 1252configure: configure.ac
4cb08df5 1253 $(QUIET_GEN)$(RM) $@ $<+ && \
3900145e 1254 sed -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
74f2b2a8
SP
1255 $< > $<+ && \
1256 autoconf -o $@ $<+ && \
4cb08df5 1257 $(RM) $<+
3900145e 1258
9b88fcef 1259# These can record GIT_VERSION
54dadbdb 1260git.o git.spec \
9b88fcef
JH
1261 $(patsubst %.sh,%,$(SCRIPT_SH)) \
1262 $(patsubst %.perl,%,$(SCRIPT_PERL)) \
9b88fcef 1263 : GIT-VERSION-FILE
e99fcf96 1264
ca3bcabf 1265%.o: %.c GIT-CFLAGS
74f2b2a8 1266 $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $<
e36cb1c1
LT
1267%.s: %.c GIT-CFLAGS
1268 $(QUIET_CC)$(CC) -S $(ALL_CFLAGS) $<
b05701c5 1269%.o: %.S
74f2b2a8 1270 $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $<
a310d434 1271
ca3bcabf 1272exec_cmd.o: exec_cmd.c GIT-CFLAGS
026fa0d5
SP
1273 $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) \
1274 '-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' \
1275 '-DBINDIR="$(bindir_relative_SQ)"' \
1276 '-DPREFIX="$(prefix_SQ)"' \
1277 $<
1278
c1f8064b 1279builtin-init-db.o: builtin-init-db.c GIT-CFLAGS
74f2b2a8 1280 $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir_SQ)"' $<
77cb17e9 1281
506b17b1
JS
1282config.o: config.c GIT-CFLAGS
1283 $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DETC_GITCONFIG='"$(ETC_GITCONFIG_SQ)"' $<
1284
ca3bcabf 1285http.o: http.c GIT-CFLAGS
74f2b2a8 1286 $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DGIT_USER_AGENT='"git/$(GIT_VERSION)"' $<
20fc9bc5 1287
8d9fbe57 1288ifdef NO_EXPAT
30ae764b 1289http-walker.o: http-walker.c http.h GIT-CFLAGS
74f2b2a8 1290 $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DNO_EXPAT $<
8d9fbe57
NH
1291endif
1292
8eef8e09 1293git-%$X: %.o $(GITLIBS)
74f2b2a8 1294 $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
623c8a14 1295
684ec6c6
RS
1296git-imap-send$X: imap-send.o $(GITLIBS)
1297 $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
1298 $(LIBS) $(OPENSSL_LINK) $(OPENSSL_LIBSSL)
f2561fda 1299
923e3ec8 1300http.o http-walker.o http-push.o transport.o: http.h
39c015c5 1301
8fced61c 1302git-http-push$X: revision.o http.o http-push.o $(GITLIBS)
74f2b2a8 1303 $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
39c015c5
JS
1304 $(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
1305
ccfc02a3 1306$(LIB_OBJS) $(BUILTIN_OBJS): $(LIB_H)
1f330269 1307$(patsubst git-%$X,%.o,$(PROGRAMS)): $(LIB_H) $(wildcard */*.h)
fa470160 1308builtin-revert.o wt-status.o: wt-status.h
e83c5163 1309
28818ffa 1310$(LIB_FILE): $(LIB_OBJS)
4cb08df5 1311 $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIB_OBJS)
28818ffa 1312
857b933e 1313XDIFF_OBJS=xdiff/xdiffi.o xdiff/xprepare.o xdiff/xutils.o xdiff/xemit.o \
34292bdd 1314 xdiff/xmerge.o xdiff/xpatience.o
17b96be2
AW
1315$(XDIFF_OBJS): xdiff/xinclude.h xdiff/xmacros.h xdiff/xdiff.h xdiff/xtypes.h \
1316 xdiff/xutils.h xdiff/xprepare.h xdiff/xdiffi.h xdiff/xemit.h
3443546f
LT
1317
1318$(XDIFF_LIB): $(XDIFF_OBJS)
4cb08df5 1319 $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(XDIFF_OBJS)
3443546f
LT
1320
1321
28818ffa
PB
1322doc:
1323 $(MAKE) -C Documentation all
1324
414851a4
MG
1325man:
1326 $(MAKE) -C Documentation man
1327
1328html:
1329 $(MAKE) -C Documentation html
1330
4739809c
DK
1331info:
1332 $(MAKE) -C Documentation info
1333
a325a1a7
MV
1334pdf:
1335 $(MAKE) -C Documentation pdf
1336
f81e7c62 1337TAGS:
4cb08df5 1338 $(RM) TAGS
89b2f19c 1339 $(FIND) . -name '*.[hcS]' -print | xargs etags -a
f81e7c62
FK
1340
1341tags:
4cb08df5 1342 $(RM) tags
89b2f19c 1343 $(FIND) . -name '*.[hcS]' -print | xargs ctags -a
28818ffa 1344
a2a9150b
KP
1345cscope:
1346 $(RM) cscope*
1347 $(FIND) . -name '*.[hcS]' -print | xargs cscope -b
1348
ca3bcabf 1349### Detect prefix changes
7cdbff14 1350TRACK_CFLAGS = $(subst ','\'',$(ALL_CFLAGS)):\
ca3bcabf
YL
1351 $(bindir_SQ):$(gitexecdir_SQ):$(template_dir_SQ):$(prefix_SQ)
1352
1353GIT-CFLAGS: .FORCE-GIT-CFLAGS
1354 @FLAGS='$(TRACK_CFLAGS)'; \
1355 if test x"$$FLAGS" != x"`cat GIT-CFLAGS 2>/dev/null`" ; then \
1356 echo 1>&2 " * new build flags or prefix"; \
1357 echo "$$FLAGS" >GIT-CFLAGS; \
1358 fi
1359
bfce5087
JH
1360# We need to apply sq twice, once to protect from the shell
1361# that runs GIT-BUILD-OPTIONS, and then again to protect it
1362# and the first level quoting from the shell that runs "echo".
7cf7f54a 1363GIT-BUILD-OPTIONS: .FORCE-GIT-BUILD-OPTIONS
bfce5087
JH
1364 @echo SHELL_PATH=\''$(subst ','\'',$(SHELL_PATH_SQ))'\' >$@
1365 @echo TAR=\''$(subst ','\'',$(subst ','\'',$(TAR)))'\' >>$@
7cf7f54a 1366
6bdb18a9
ER
1367### Detect Tck/Tk interpreter path changes
1368ifndef NO_TCLTK
1369TRACK_VARS = $(subst ','\'',-DTCLTK_PATH='$(TCLTK_PATH_SQ)')
1370
1371GIT-GUI-VARS: .FORCE-GIT-GUI-VARS
1372 @VARS='$(TRACK_VARS)'; \
1373 if test x"$$VARS" != x"`cat $@ 2>/dev/null`" ; then \
1374 echo 1>&2 " * new Tcl/Tk interpreter location"; \
1375 echo "$$VARS" >$@; \
1376 fi
1377
1378.PHONY: .FORCE-GIT-GUI-VARS
1379endif
1380
28818ffa
PB
1381### Testing rules
1382
9002ec3a 1383TEST_PROGRAMS += test-chmtime$X
b4285c71 1384TEST_PROGRAMS += test-ctype$X
9002ec3a
JK
1385TEST_PROGRAMS += test-date$X
1386TEST_PROGRAMS += test-delta$X
b63bc0bc 1387TEST_PROGRAMS += test-dump-cache-tree$X
9002ec3a
JK
1388TEST_PROGRAMS += test-genrandom$X
1389TEST_PROGRAMS += test-match-trees$X
1390TEST_PROGRAMS += test-parse-options$X
1391TEST_PROGRAMS += test-path-utils$X
1392TEST_PROGRAMS += test-sha1$X
4a16d072 1393TEST_PROGRAMS += test-sigchain$X
96651ef5
JH
1394
1395all:: $(TEST_PROGRAMS)
1396
abb7c7b3
JS
1397# GNU make supports exporting all variables by "export" without parameters.
1398# However, the environment gets quite big, and some programs have problems
1399# with that.
1400
140245b3 1401export NO_SVN_TESTS
abb7c7b3 1402
96651ef5 1403test: all
28818ffa
PB
1404 $(MAKE) -C t/ all
1405
b4285c71
RS
1406test-ctype$X: ctype.o
1407
5c5ba73b 1408test-date$X: date.o ctype.o
28818ffa 1409
5c5ba73b 1410test-delta$X: diff-delta.o patch-delta.o
28818ffa 1411
481424e1
AR
1412test-parse-options$X: parse-options.o
1413
fa8fe28c
JH
1414.PRECIOUS: $(patsubst test-%$X,test-%.o,$(TEST_PROGRAMS))
1415
5c5ba73b
JP
1416test-%$X: test-%.o $(GITLIBS)
1417 $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
2dca1af4 1418
b65bc21e
JH
1419check-sha1:: test-sha1$X
1420 ./test-sha1.sh
1421
7c4c9f4c 1422check: common-cmds.h
912f9980
JH
1423 if sparse; \
1424 then \
1425 for i in *.c; \
1426 do \
1427 sparse $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i || exit; \
1428 done; \
1429 else \
1430 echo 2>&1 "Did you mean 'make test'?"; \
1431 exit 1; \
1432 fi
28818ffa 1433
36e5e70e 1434remove-dashes:
b4f02d35 1435 ./fixup-builtins $(BUILT_INS) $(PROGRAMS) $(SCRIPTS)
28818ffa
PB
1436
1437### Installation rules
1438
0c0ead7e 1439ifneq ($(filter /%,$(firstword $(template_dir))),)
0b50b860 1440template_instdir = $(template_dir)
026fa0d5
SP
1441else
1442template_instdir = $(prefix)/$(template_dir)
0b50b860
JS
1443endif
1444export template_instdir
1445
0c0ead7e 1446ifneq ($(filter /%,$(firstword $(gitexecdir))),)
49fa65a7 1447gitexec_instdir = $(gitexecdir)
026fa0d5
SP
1448else
1449gitexec_instdir = $(prefix)/$(gitexecdir)
49fa65a7
JS
1450endif
1451gitexec_instdir_SQ = $(subst ','\'',$(gitexec_instdir))
1452export gitexec_instdir
1453
d6ebd259 1454install: all
41650765 1455 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'
49fa65a7
JS
1456 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
1457 $(INSTALL) $(ALL_PROGRAMS) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
ede4caf6 1458 $(INSTALL) git$X git-upload-pack$X git-receive-pack$X git-upload-archive$X git-shell$X git-cvsserver '$(DESTDIR_SQ)$(bindir_SQ)'
7ffe7098 1459 $(MAKE) -C templates DESTDIR='$(DESTDIR_SQ)' install
28072a5d 1460 $(MAKE) -C perl prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' install
3cfaf11b 1461ifndef NO_TCLTK
62ba5143 1462 $(MAKE) -C gitk-git install
49fa65a7 1463 $(MAKE) -C git-gui gitexecdir='$(gitexec_instdir_SQ)' install
3cfaf11b 1464endif
6fc301bb 1465ifneq (,$X)
49fa65a7 1466 $(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) git$X)), $(RM) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)/$p';)
6fc301bb 1467endif
46beb559 1468 bindir=$$(cd '$(DESTDIR_SQ)$(bindir_SQ)' && pwd) && \
49fa65a7 1469 execdir=$$(cd '$(DESTDIR_SQ)$(gitexec_instdir_SQ)' && pwd) && \
3e073dc5
AF
1470 { $(RM) "$$execdir/git-add$X" && \
1471 ln git-add$X "$$execdir/git-add$X" 2>/dev/null || \
1472 cp git-add$X "$$execdir/git-add$X"; } && \
b56c79cc
BC
1473 { for p in $(filter-out git-add$X,$(BUILT_INS)); do \
1474 $(RM) "$$execdir/$$p" && \
1475 ln "$$execdir/git-add$X" "$$execdir/$$p" 2>/dev/null || \
1476 ln -s "git-add$X" "$$execdir/$$p" 2>/dev/null || \
1477 cp "$$execdir/git-add$X" "$$execdir/$$p" || exit; \
1478 done } && \
7b4b59a9 1479 ./check_bindir "z$$bindir" "z$$execdir" "$$bindir/git-add$X"
28818ffa
PB
1480
1481install-doc:
1482 $(MAKE) -C Documentation install
1483
b1a46b70
MH
1484install-man:
1485 $(MAKE) -C Documentation install-man
1486
ae081f3e
TL
1487install-html:
1488 $(MAKE) -C Documentation install-html
1489
4739809c
DK
1490install-info:
1491 $(MAKE) -C Documentation install-info
1492
a325a1a7
MV
1493install-pdf:
1494 $(MAKE) -C Documentation install-pdf
1495
6538d1ef
EW
1496quick-install-doc:
1497 $(MAKE) -C Documentation quick-install
28818ffa 1498
b1a46b70
MH
1499quick-install-man:
1500 $(MAKE) -C Documentation quick-install-man
1501
6fe570de
MG
1502quick-install-html:
1503 $(MAKE) -C Documentation quick-install-html
1504
28818ffa
PB
1505
1506
1507### Maintainer's dist rules
1508
9b88fcef 1509git.spec: git.spec.in
fc36f6a6
JM
1510 sed -e 's/@@VERSION@@/$(GIT_VERSION)/g' < $< > $@+
1511 mv $@+ $@
a9db2974 1512
27dedf0c 1513GIT_TARNAME=git-$(GIT_VERSION)
6c0f8694 1514dist: git.spec git-archive$(X) configure
9ccb64c8
JH
1515 ./git-archive --format=tar \
1516 --prefix=$(GIT_TARNAME)/ HEAD^{tree} > $(GIT_TARNAME).tar
a9db2974 1517 @mkdir -p $(GIT_TARNAME)
f58494bf 1518 @cp git.spec configure $(GIT_TARNAME)
181129d2 1519 @echo $(GIT_VERSION) > $(GIT_TARNAME)/version
d647c2ea 1520 @$(MAKE) -C git-gui TARDIR=../$(GIT_TARNAME)/git-gui dist-version
181129d2 1521 $(TAR) rf $(GIT_TARNAME).tar \
d647c2ea 1522 $(GIT_TARNAME)/git.spec \
f58494bf 1523 $(GIT_TARNAME)/configure \
d647c2ea 1524 $(GIT_TARNAME)/version \
115f0fe4 1525 $(GIT_TARNAME)/git-gui/version
4cb08df5 1526 @$(RM) -r $(GIT_TARNAME)
9dce3c06 1527 gzip -f -9 $(GIT_TARNAME).tar
a9db2974
CW
1528
1529rpm: dist
27dedf0c 1530 $(RPMBUILD) -ta $(GIT_TARNAME).tar.gz
a9db2974 1531
52db0495
TS
1532htmldocs = git-htmldocs-$(GIT_VERSION)
1533manpages = git-manpages-$(GIT_VERSION)
1534dist-doc:
4cb08df5 1535 $(RM) -r .doc-tmp-dir
52db0495
TS
1536 mkdir .doc-tmp-dir
1537 $(MAKE) -C Documentation WEBDOC_DEST=../.doc-tmp-dir install-webdoc
1538 cd .doc-tmp-dir && $(TAR) cf ../$(htmldocs).tar .
1539 gzip -n -9 -f $(htmldocs).tar
1540 :
4cb08df5 1541 $(RM) -r .doc-tmp-dir
4392da4d 1542 mkdir -p .doc-tmp-dir/man1 .doc-tmp-dir/man5 .doc-tmp-dir/man7
c5360324 1543 $(MAKE) -C Documentation DESTDIR=./ \
7b8cf0cf 1544 man1dir=../.doc-tmp-dir/man1 \
4392da4d 1545 man5dir=../.doc-tmp-dir/man5 \
7b8cf0cf 1546 man7dir=../.doc-tmp-dir/man7 \
52db0495
TS
1547 install
1548 cd .doc-tmp-dir && $(TAR) cf ../$(manpages).tar .
1549 gzip -n -9 -f $(manpages).tar
4cb08df5 1550 $(RM) -r .doc-tmp-dir
52db0495 1551
28818ffa 1552### Cleaning rules
87a81c83 1553
922aa807
MM
1554distclean: clean
1555 $(RM) configure
1556
e83c5163 1557clean:
4cb08df5 1558 $(RM) *.o mozilla-sha1/*.o arm/*.o ppc/*.o compat/*.o xdiff/*.o \
4cfc24af 1559 $(LIB_FILE) $(XDIFF_LIB)
4cb08df5
EM
1560 $(RM) $(ALL_PROGRAMS) $(BUILT_INS) git$X
1561 $(RM) $(TEST_PROGRAMS)
a2a9150b 1562 $(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo common-cmds.h TAGS tags cscope*
4cb08df5 1563 $(RM) -r autom4te.cache
922aa807 1564 $(RM) config.log config.mak.autogen config.mak.append config.status config.cache
4cb08df5
EM
1565 $(RM) -r $(GIT_TARNAME) .doc-tmp-dir
1566 $(RM) $(GIT_TARNAME).tar.gz git-core_$(GIT_VERSION)-*.tar.gz
1567 $(RM) $(htmldocs).tar.gz $(manpages).tar.gz
1568 $(RM) gitweb/gitweb.cgi
ca67f002 1569 $(MAKE) -C Documentation/ clean
f848718a 1570 $(MAKE) -C perl clean
b1edc53d 1571 $(MAKE) -C templates/ clean
4b7581f0 1572 $(MAKE) -C t/ clean
3cfaf11b 1573ifndef NO_TCLTK
62ba5143 1574 $(MAKE) -C gitk-git clean
3cfaf11b
ER
1575 $(MAKE) -C git-gui clean
1576endif
7cf7f54a 1577 $(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-GUI-VARS GIT-BUILD-OPTIONS
9b88fcef 1578
4dc00021 1579.PHONY: all install clean strip
6dc4627e 1580.PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell
a2a9150b 1581.PHONY: .FORCE-GIT-VERSION-FILE TAGS tags cscope .FORCE-GIT-CFLAGS
7cf7f54a 1582.PHONY: .FORCE-GIT-BUILD-OPTIONS
d89056c2 1583
8c989ec5
JH
1584### Check documentation
1585#
1586check-docs::
3f7ce648 1587 @(for v in $(ALL_PROGRAMS) $(BUILT_INS) git gitk; \
8c989ec5
JH
1588 do \
1589 case "$$v" in \
8c989ec5 1590 git-merge-octopus | git-merge-ours | git-merge-recursive | \
51add76e 1591 git-merge-resolve | git-merge-subtree | \
5c66d0d4 1592 git-fsck-objects | git-init-db | \
5b4617c7 1593 git-?*--?* ) continue ;; \
8c989ec5
JH
1594 esac ; \
1595 test -f "Documentation/$$v.txt" || \
1596 echo "no doc: $$v"; \
79d30668 1597 sed -e '/^#/d' command-list.txt | \
4b02c529 1598 grep -q "^$$v[ ]" || \
8c989ec5
JH
1599 case "$$v" in \
1600 git) ;; \
1601 *) echo "no link: $$v";; \
1602 esac ; \
3f7ce648
JH
1603 done; \
1604 ( \
79d30668 1605 sed -e '/^#/d' \
3f7ce648 1606 -e 's/[ ].*//' \
79d30668 1607 -e 's/^/listed /' command-list.txt; \
3f7ce648
JH
1608 ls -1 Documentation/git*txt | \
1609 sed -e 's|Documentation/|documented |' \
1610 -e 's/\.txt//'; \
1611 ) | while read how cmd; \
1612 do \
1613 case "$$how,$$cmd" in \
1614 *,git-citool | \
1615 *,git-gui | \
0f6f195b 1616 *,git-help | \
3f7ce648
JH
1617 documented,gitattributes | \
1618 documented,gitignore | \
1619 documented,gitmodules | \
2f7ee089 1620 documented,gitcli | \
3f7ce648 1621 documented,git-tools | \
d0594be1
JH
1622 documented,gitcore-tutorial | \
1623 documented,gitcvs-migration | \
1624 documented,gitdiffcore | \
1625 documented,gitglossary | \
1626 documented,githooks | \
1627 documented,gitrepository-layout | \
1628 documented,gittutorial | \
1629 documented,gittutorial-2 | \
3f7ce648
JH
1630 sentinel,not,matching,is,ok ) continue ;; \
1631 esac; \
1632 case " $(ALL_PROGRAMS) $(BUILT_INS) git gitk " in \
1633 *" $$cmd "*) ;; \
1634 *) echo "removed but $$how: $$cmd" ;; \
1635 esac; \
1636 done ) | sort
c74390e4
JH
1637
1638### Make sure built-ins do not have dups and listed in git.c
1639#
1640check-builtins::
1641 ./check-builtins.sh
11c57e6a 1642