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