config.mak.in: define paths without trailing slash
[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
49fa65a7 231export prefix bindir sharedir htmldir 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
320BUILT_INS += git-cherry-pick$X
321BUILT_INS += git-cherry$X
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
f4626df5 360LIB_H += compat/mingw.h
adbc0b6b 361LIB_H += compat/cygwin.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
c455c87c 386LIB_H += string-list.h
74ca5e6d
JH
387LIB_H += pkt-line.h
388LIB_H += progress.h
389LIB_H += quote.h
390LIB_H += reflog-walk.h
391LIB_H += refs.h
392LIB_H += remote.h
5b2fd956 393LIB_H += rerere.h
74ca5e6d
JH
394LIB_H += revision.h
395LIB_H += run-command.h
628522ec 396LIB_H += sha1-lookup.h
74ca5e6d 397LIB_H += sideband.h
4a16d072 398LIB_H += sigchain.h
74ca5e6d
JH
399LIB_H += strbuf.h
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
0569e9b8 438LIB_OBJS += diff-no-index.o
74ca5e6d
JH
439LIB_OBJS += diff-lib.o
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
c455c87c 471LIB_OBJS += string-list.o
74ca5e6d
JH
472LIB_OBJS += path.o
473LIB_OBJS += pkt-line.o
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
487LIB_OBJS += sha1_file.o
628522ec 488LIB_OBJS += sha1-lookup.o
74ca5e6d
JH
489LIB_OBJS += sha1_name.o
490LIB_OBJS += shallow.o
491LIB_OBJS += sideband.o
4a16d072 492LIB_OBJS += sigchain.o
74ca5e6d
JH
493LIB_OBJS += strbuf.o
494LIB_OBJS += symlinks.o
495LIB_OBJS += tag.o
496LIB_OBJS += trace.o
497LIB_OBJS += transport.o
498LIB_OBJS += tree-diff.o
499LIB_OBJS += tree.o
500LIB_OBJS += tree-walk.o
501LIB_OBJS += unpack-trees.o
be58e70d 502LIB_OBJS += userdiff.o
74ca5e6d
JH
503LIB_OBJS += usage.o
504LIB_OBJS += utf8.o
505LIB_OBJS += walker.o
112db553 506LIB_OBJS += wrapper.o
74ca5e6d
JH
507LIB_OBJS += write_or_die.o
508LIB_OBJS += ws.o
509LIB_OBJS += wt-status.o
510LIB_OBJS += xdiff-interface.o
671c9b7e 511LIB_OBJS += preload-index.o
74ca5e6d
JH
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
fe4aafba
WC
652 ifneq ($(shell expr "$(uname_R)" : '9\.'),2)
653 OLD_ICONV = UnfortunatelyYes
654 endif
817151e6 655 NO_STRLCPY = YesPlease
3d59405c 656 NO_MEMMEM = YesPlease
954597bd 657 THREADED_DELTA_SEARCH = YesPlease
597c9cc5 658endif
f7c15343 659ifeq ($(uname_S),SunOS)
f0ebff0d 660 NEEDS_SOCKET = YesPlease
5a90d4ac 661 NEEDS_NSL = YesPlease
229a7ed7
JH
662 SHELL_PATH = /bin/bash
663 NO_STRCASESTR = YesPlease
b21b9f1d 664 NO_MEMMEM = YesPlease
fa0c87c3 665 NO_HSTRERROR = YesPlease
4e0da763 666 NO_MKDTEMP = YesPlease
6e2dfb16 667 OLD_ICONV = UnfortunatelyYes
e40b61fb 668 ifeq ($(uname_R),5.8)
731043fd 669 NO_UNSETENV = YesPlease
e40b61fb 670 NO_SETENV = YesPlease
66c4509b 671 NO_C99_FORMAT = YesPlease
bc6b4f52 672 NO_STRTOUMAX = YesPlease
e40b61fb 673 endif
40d88d4f
DS
674 ifeq ($(uname_R),5.9)
675 NO_UNSETENV = YesPlease
676 NO_SETENV = YesPlease
66c4509b 677 NO_C99_FORMAT = YesPlease
bc6b4f52 678 NO_STRTOUMAX = YesPlease
40d88d4f 679 endif
229a7ed7
JH
680 INSTALL = ginstall
681 TAR = gtar
8d7f586f 682 BASIC_CFLAGS += -D__EXTENSIONS__
f0ebff0d 683endif
f7c15343 684ifeq ($(uname_O),Cygwin)
63be37b0 685 NO_D_TYPE_IN_DIRENT = YesPlease
35a730f0 686 NO_D_INO_IN_DIRENT = YesPlease
17754517 687 NO_STRCASESTR = YesPlease
b21b9f1d 688 NO_MEMMEM = YesPlease
9f0bb90d 689 NO_SYMLINK_HEAD = YesPlease
17754517 690 NEEDS_LIBICONV = YesPlease
1510fea7 691 NO_FAST_WORKING_DIRECTORY = UnfortunatelyYes
c869753e 692 NO_TRUSTABLE_FILEMODE = UnfortunatelyYes
7a4a2e1f 693 OLD_ICONV = UnfortunatelyYes
2e67a5f4
JH
694 # There are conflicting reports about this.
695 # On some boxes NO_MMAP is needed, and not so elsewhere.
87ac1390
JH
696 # Try commenting this out if you suspect MMAP is more efficient
697 NO_MMAP = YesPlease
49744d63 698 NO_IPV6 = YesPlease
a23cd8ec 699 X = .exe
7c6ef2f2 700endif
b3bf974c
AK
701ifeq ($(uname_S),FreeBSD)
702 NEEDS_LIBICONV = YesPlease
a2f22dbf 703 NO_MEMMEM = YesPlease
8d7f586f
PB
704 BASIC_CFLAGS += -I/usr/local/include
705 BASIC_LDFLAGS += -L/usr/local/lib
81a24b52 706 DIR_HAS_BSD_GROUP_SEMANTICS = YesPlease
38bd6497 707 THREADED_DELTA_SEARCH = YesPlease
069bb576 708 ifeq ($(shell expr "$(uname_R)" : '4\.'),2)
158629b2 709 PTHREAD_LIBS = -pthread
069bb576
DS
710 NO_UINTMAX_T = YesPlease
711 NO_STRTOUMAX = YesPlease
712 endif
b3bf974c 713endif
f7c15343 714ifeq ($(uname_S),OpenBSD)
5fb41e8a 715 NO_STRCASESTR = YesPlease
b21b9f1d 716 NO_MEMMEM = YesPlease
18c5a525 717 NEEDS_LIBICONV = YesPlease
8d7f586f
PB
718 BASIC_CFLAGS += -I/usr/local/include
719 BASIC_LDFLAGS += -L/usr/local/lib
38bd6497 720 THREADED_DELTA_SEARCH = YesPlease
94d23317
JH
721endif
722ifeq ($(uname_S),NetBSD)
e88856b4
DS
723 ifeq ($(shell expr "$(uname_R)" : '[01]\.'),2)
724 NEEDS_LIBICONV = YesPlease
725 endif
8d7f586f 726 BASIC_CFLAGS += -I/usr/pkg/include
f5b904db 727 BASIC_LDFLAGS += -L/usr/pkg/lib $(CC_LD_DYNPATH)/usr/pkg/lib
38bd6497 728 THREADED_DELTA_SEARCH = YesPlease
18c5a525 729endif
a6da9395
JR
730ifeq ($(uname_S),AIX)
731 NO_STRCASESTR=YesPlease
b21b9f1d 732 NO_MEMMEM = YesPlease
377d9c40 733 NO_MKDTEMP = YesPlease
817151e6 734 NO_STRLCPY = YesPlease
377d9c40
MR
735 FREAD_READS_DIRECTORIES = UnfortunatelyYes
736 INTERNAL_QSORT = UnfortunatelyYes
a6da9395 737 NEEDS_LIBICONV=YesPlease
377d9c40 738 BASIC_CFLAGS += -D_LARGE_FILES
46059cc6
JH
739 ifneq ($(shell expr "$(uname_V)" : '[1234]'),1)
740 THREADED_DELTA_SEARCH = YesPlease
741 else
742 NO_PTHREADS = YesPlease
743 endif
a6da9395 744endif
c29ba0c3
TS
745ifeq ($(uname_S),GNU)
746 # GNU/Hurd
747 NO_STRLCPY=YesPlease
748endif
289c4b36
JS
749ifeq ($(uname_S),IRIX64)
750 NO_IPV6=YesPlease
751 NO_SETENV=YesPlease
752 NO_STRCASESTR=YesPlease
b21b9f1d 753 NO_MEMMEM = YesPlease
817151e6 754 NO_STRLCPY = YesPlease
289c4b36
JS
755 NO_SOCKADDR_STORAGE=YesPlease
756 SHELL_PATH=/usr/gnu/bin/bash
8d7f586f 757 BASIC_CFLAGS += -DPATH_MAX=1024
289c4b36 758 # for now, build 32-bit version
8d7f586f 759 BASIC_LDFLAGS += -L/usr/lib32
289c4b36 760endif
81cc66a5
RS
761ifeq ($(uname_S),HP-UX)
762 NO_IPV6=YesPlease
763 NO_SETENV=YesPlease
764 NO_STRCASESTR=YesPlease
765 NO_MEMMEM = YesPlease
766 NO_STRLCPY = YesPlease
767 NO_MKDTEMP = YesPlease
768 NO_UNSETENV = YesPlease
769 NO_HSTRERROR = YesPlease
770 NO_SYS_SELECT_H = YesPlease
7d770163 771 SNPRINTF_RETURNS_BOGUS = YesPlease
81cc66a5 772endif
adbc0b6b
DP
773ifneq (,$(findstring CYGWIN,$(uname_S)))
774 COMPAT_OBJS += compat/cygwin.o
775endif
f4626df5
JS
776ifneq (,$(findstring MINGW,$(uname_S)))
777 NO_MMAP = YesPlease
778 NO_PREAD = YesPlease
779 NO_OPENSSL = YesPlease
780 NO_CURL = YesPlease
781 NO_SYMLINK_HEAD = YesPlease
782 NO_IPV6 = YesPlease
783 NO_SETENV = YesPlease
784 NO_UNSETENV = YesPlease
785 NO_STRCASESTR = YesPlease
786 NO_STRLCPY = YesPlease
787 NO_MEMMEM = YesPlease
46059cc6 788 NO_PTHREADS = YesPlease
f4626df5
JS
789 NEEDS_LIBICONV = YesPlease
790 OLD_ICONV = YesPlease
791 NO_C99_FORMAT = YesPlease
792 NO_STRTOUMAX = YesPlease
793 NO_MKDTEMP = YesPlease
794 SNPRINTF_RETURNS_BOGUS = YesPlease
795 NO_SVN_TESTS = YesPlease
796 NO_PERL_MAKEMAKER = YesPlease
25655221 797 RUNTIME_PREFIX = YesPlease
f4626df5 798 NO_POSIX_ONLY_PROGRAMS = YesPlease
fdb2a2a6 799 NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease
3632cfc2 800 COMPAT_CFLAGS += -D__USE_MINGW_ACCESS -DNOGDI -Icompat -Icompat/regex -Icompat/fnmatch
f4626df5 801 COMPAT_CFLAGS += -DSNPRINTF_SIZE_CORR=1
23326d14 802 COMPAT_CFLAGS += -DSTRIP_EXTENSION=\".exe\"
3632cfc2 803 COMPAT_OBJS += compat/mingw.o compat/fnmatch/fnmatch.o compat/regex/regex.o compat/winansi.o
f4626df5
JS
804 EXTLIBS += -lws2_32
805 X = .exe
806endif
f7c15343
JH
807ifneq (,$(findstring arm,$(uname_M)))
808 ARM_SHA1 = YesPlease
809endif
597c9cc5 810
55667714 811-include config.mak.autogen
f2d6a256 812-include config.mak
597c9cc5 813
59f86740
BG
814ifeq ($(uname_S),Darwin)
815 ifndef NO_FINK
816 ifeq ($(shell test -d /sw/lib && echo y),y)
817 BASIC_CFLAGS += -I/sw/include
818 BASIC_LDFLAGS += -L/sw/lib
819 endif
820 endif
821 ifndef NO_DARWIN_PORTS
822 ifeq ($(shell test -d /opt/local/lib && echo y),y)
823 BASIC_CFLAGS += -I/opt/local/include
824 BASIC_LDFLAGS += -L/opt/local/lib
825 endif
826 endif
f7d9d04e 827 PTHREAD_LIBS =
59f86740
BG
828endif
829
f5b904db
JH
830ifndef CC_LD_DYNPATH
831 ifdef NO_R_TO_GCC_LINKER
832 # Some gcc does not accept and pass -R to the linker to specify
833 # the runtime dynamic library path.
834 CC_LD_DYNPATH = -Wl,-rpath,
835 else
836 CC_LD_DYNPATH = -R
837 endif
bbfc63dd
JH
838endif
839
30ae764b
DB
840ifdef NO_CURL
841 BASIC_CFLAGS += -DNO_CURL
842else
229a7ed7 843 ifdef CURLDIR
10861bea 844 # Try "-Wl,-rpath=$(CURLDIR)/$(lib)" in such a case.
8d7f586f 845 BASIC_CFLAGS += -I$(CURLDIR)/include
10861bea 846 CURL_LIBCURL = -L$(CURLDIR)/$(lib) $(CC_LD_DYNPATH)$(CURLDIR)/$(lib) -lcurl
229a7ed7
JH
847 else
848 CURL_LIBCURL = -lcurl
849 endif
30ae764b
DB
850 BUILTIN_OBJS += builtin-http-fetch.o
851 EXTLIBS += $(CURL_LIBCURL)
ccfc02a3 852 LIB_OBJS += http.o http-walker.o
08900987
NH
853 curl_check := $(shell (echo 070908; curl-config --vernum) | sort -r | sed -ne 2p)
854 ifeq "$(curl_check)" "070908"
855 ifndef NO_EXPAT
08900987
NH
856 PROGRAMS += git-http-push$X
857 endif
58e60dd2 858 endif
459a21bd 859 ifndef NO_EXPAT
85b4518f
SB
860 ifdef EXPATDIR
861 BASIC_CFLAGS += -I$(EXPATDIR)/include
862 EXPAT_LIBEXPAT = -L$(EXPATDIR)/$(lib) $(CC_LD_DYNPATH)$(EXPATDIR)/$(lib) -lexpat
863 else
864 EXPAT_LIBEXPAT = -lexpat
865 endif
459a21bd 866 endif
229a7ed7
JH
867endif
868
bef19da9
RS
869ifdef ZLIB_PATH
870 BASIC_CFLAGS += -I$(ZLIB_PATH)/include
10861bea 871 EXTLIBS += -L$(ZLIB_PATH)/$(lib) $(CC_LD_DYNPATH)$(ZLIB_PATH)/$(lib)
bef19da9
RS
872endif
873EXTLIBS += -lz
874
58eda022
JS
875ifndef NO_POSIX_ONLY_PROGRAMS
876 PROGRAMS += git-daemon$X
877 PROGRAMS += git-imap-send$X
878endif
dd53c7ab 879ifndef NO_OPENSSL
215a7ad1 880 OPENSSL_LIBSSL = -lssl
455a7f32 881 ifdef OPENSSLDIR
8d7f586f 882 BASIC_CFLAGS += -I$(OPENSSLDIR)/include
10861bea 883 OPENSSL_LINK = -L$(OPENSSLDIR)/$(lib) $(CC_LD_DYNPATH)$(OPENSSLDIR)/$(lib)
455a7f32
JH
884 else
885 OPENSSL_LINK =
886 endif
dd53c7ab 887else
8d7f586f 888 BASIC_CFLAGS += -DNO_OPENSSL
215a7ad1
JH
889 MOZILLA_SHA1 = 1
890 OPENSSL_LIBSSL =
dd53c7ab 891endif
597c9cc5 892ifdef NEEDS_SSL_WITH_CRYPTO
455a7f32 893 LIB_4_CRYPTO = $(OPENSSL_LINK) -lcrypto -lssl
597c9cc5 894else
455a7f32 895 LIB_4_CRYPTO = $(OPENSSL_LINK) -lcrypto
597c9cc5
JH
896endif
897ifdef NEEDS_LIBICONV
455a7f32 898 ifdef ICONVDIR
8d7f586f 899 BASIC_CFLAGS += -I$(ICONVDIR)/include
10861bea 900 ICONV_LINK = -L$(ICONVDIR)/$(lib) $(CC_LD_DYNPATH)$(ICONVDIR)/$(lib)
455a7f32
JH
901 else
902 ICONV_LINK =
903 endif
d595a473 904 EXTLIBS += $(ICONV_LINK) -liconv
597c9cc5 905endif
f0ebff0d 906ifdef NEEDS_SOCKET
d595a473 907 EXTLIBS += -lsocket
f0ebff0d 908endif
5a90d4ac 909ifdef NEEDS_NSL
d595a473 910 EXTLIBS += -lnsl
5a90d4ac 911endif
63be37b0 912ifdef NO_D_TYPE_IN_DIRENT
8d7f586f 913 BASIC_CFLAGS += -DNO_D_TYPE_IN_DIRENT
63be37b0 914endif
35a730f0 915ifdef NO_D_INO_IN_DIRENT
8d7f586f 916 BASIC_CFLAGS += -DNO_D_INO_IN_DIRENT
35a730f0 917endif
fdb2a2a6
JH
918ifdef NO_ST_BLOCKS_IN_STRUCT_STAT
919 BASIC_CFLAGS += -DNO_ST_BLOCKS_IN_STRUCT_STAT
920endif
579d1fbf 921ifdef NO_C99_FORMAT
8188e73b 922 BASIC_CFLAGS += -DNO_C99_FORMAT
579d1fbf 923endif
c4582f93
MR
924ifdef SNPRINTF_RETURNS_BOGUS
925 COMPAT_CFLAGS += -DSNPRINTF_RETURNS_BOGUS
926 COMPAT_OBJS += compat/snprintf.o
927endif
cba22528
BC
928ifdef FREAD_READS_DIRECTORIES
929 COMPAT_CFLAGS += -DFREAD_READS_DIRECTORIES
930 COMPAT_OBJS += compat/fopen.o
931endif
9f0bb90d 932ifdef NO_SYMLINK_HEAD
8d7f586f 933 BASIC_CFLAGS += -DNO_SYMLINK_HEAD
9f0bb90d 934endif
ef34af24 935ifdef NO_STRCASESTR
4050c0df 936 COMPAT_CFLAGS += -DNO_STRCASESTR
e40b61fb
JR
937 COMPAT_OBJS += compat/strcasestr.o
938endif
817151e6
PE
939ifdef NO_STRLCPY
940 COMPAT_CFLAGS += -DNO_STRLCPY
941 COMPAT_OBJS += compat/strlcpy.o
942endif
bc6b4f52
JR
943ifdef NO_STRTOUMAX
944 COMPAT_CFLAGS += -DNO_STRTOUMAX
945 COMPAT_OBJS += compat/strtoumax.o
946endif
947ifdef NO_STRTOULL
948 COMPAT_CFLAGS += -DNO_STRTOULL
949endif
e40b61fb 950ifdef NO_SETENV
4050c0df 951 COMPAT_CFLAGS += -DNO_SETENV
e40b61fb 952 COMPAT_OBJS += compat/setenv.o
ef34af24 953endif
ca5bb5d5
SP
954ifdef NO_MKDTEMP
955 COMPAT_CFLAGS += -DNO_MKDTEMP
956 COMPAT_OBJS += compat/mkdtemp.o
957endif
104ff34a 958ifdef NO_UNSETENV
731043fd
JR
959 COMPAT_CFLAGS += -DNO_UNSETENV
960 COMPAT_OBJS += compat/unsetenv.o
961endif
2600973f
RS
962ifdef NO_SYS_SELECT_H
963 BASIC_CFLAGS += -DNO_SYS_SELECT_H
964endif
730d48a2 965ifdef NO_MMAP
4050c0df 966 COMPAT_CFLAGS += -DNO_MMAP
e40b61fb 967 COMPAT_OBJS += compat/mmap.o
730d48a2 968endif
6900679c
SH
969ifdef NO_PREAD
970 COMPAT_CFLAGS += -DNO_PREAD
971 COMPAT_OBJS += compat/pread.o
972endif
1510fea7
SP
973ifdef NO_FAST_WORKING_DIRECTORY
974 BASIC_CFLAGS += -DNO_FAST_WORKING_DIRECTORY
975endif
c869753e
SP
976ifdef NO_TRUSTABLE_FILEMODE
977 BASIC_CFLAGS += -DNO_TRUSTABLE_FILEMODE
978endif
49744d63 979ifdef NO_IPV6
8d7f586f 980 BASIC_CFLAGS += -DNO_IPV6
bdc37f5a 981endif
0bc3e781
DS
982ifdef NO_UINTMAX_T
983 BASIC_CFLAGS += -Duintmax_t=uint32_t
984endif
bdc37f5a
JH
985ifdef NO_SOCKADDR_STORAGE
986ifdef NO_IPV6
8d7f586f 987 BASIC_CFLAGS += -Dsockaddr_storage=sockaddr_in
bdc37f5a 988else
8d7f586f 989 BASIC_CFLAGS += -Dsockaddr_storage=sockaddr_in6
bdc37f5a 990endif
49744d63 991endif
6ba68ab2
YL
992ifdef NO_INET_NTOP
993 LIB_OBJS += compat/inet_ntop.o
994endif
dd467629
JL
995ifdef NO_INET_PTON
996 LIB_OBJS += compat/inet_pton.o
997endif
cef661fc 998
b6e56eca 999ifdef NO_ICONV
8d7f586f 1000 BASIC_CFLAGS += -DNO_ICONV
b6e56eca
FP
1001endif
1002
fd547a97
RJ
1003ifdef OLD_ICONV
1004 BASIC_CFLAGS += -DOLD_ICONV
1005endif
1006
609a2289
DS
1007ifdef NO_DEFLATE_BOUND
1008 BASIC_CFLAGS += -DNO_DEFLATE_BOUND
1009endif
1010
7c6ef2f2
NP
1011ifdef PPC_SHA1
1012 SHA1_HEADER = "ppc/sha1.h"
1013 LIB_OBJS += ppc/sha1.o ppc/sha1ppc.o
1014else
1015ifdef ARM_SHA1
1016 SHA1_HEADER = "arm/sha1.h"
1017 LIB_OBJS += arm/sha1.o arm/sha1_arm.o
1018else
1019ifdef MOZILLA_SHA1
1020 SHA1_HEADER = "mozilla-sha1/sha1.h"
1021 LIB_OBJS += mozilla-sha1/sha1.o
1022else
1023 SHA1_HEADER = <openssl/sha.h>
d595a473 1024 EXTLIBS += $(LIB_4_CRYPTO)
7c6ef2f2
NP
1025endif
1026endif
1027endif
f848718a
AR
1028ifdef NO_PERL_MAKEMAKER
1029 export NO_PERL_MAKEMAKER
1030endif
fa0c87c3
AR
1031ifdef NO_HSTRERROR
1032 COMPAT_CFLAGS += -DNO_HSTRERROR
1033 COMPAT_OBJS += compat/hstrerror.o
1034endif
b21b9f1d
RS
1035ifdef NO_MEMMEM
1036 COMPAT_CFLAGS += -DNO_MEMMEM
1037 COMPAT_OBJS += compat/memmem.o
1038endif
43fe901b
BD
1039ifdef INTERNAL_QSORT
1040 COMPAT_CFLAGS += -DINTERNAL_QSORT
1041 COMPAT_OBJS += compat/qsort.o
1042endif
35fb0e86
SP
1043ifdef RUNTIME_PREFIX
1044 COMPAT_CFLAGS += -DRUNTIME_PREFIX
1045endif
b7774343 1046
46059cc6
JH
1047ifdef NO_PTHREADS
1048 THREADED_DELTA_SEARCH =
1049 BASIC_CFLAGS += -DNO_PTHREADS
1050else
1051 EXTLIBS += $(PTHREAD_LIBS)
1052endif
1053
8ecce684
NP
1054ifdef THREADED_DELTA_SEARCH
1055 BASIC_CFLAGS += -DTHREADED_DELTA_SEARCH
833e3df1 1056 LIB_OBJS += thread-utils.o
8ecce684 1057endif
81a24b52
AR
1058ifdef DIR_HAS_BSD_GROUP_SEMANTICS
1059 COMPAT_CFLAGS += -DDIR_HAS_BSD_GROUP_SEMANTICS
1060endif
5f7c643a
JK
1061ifdef NO_EXTERNAL_GREP
1062 BASIC_CFLAGS += -DNO_EXTERNAL_GREP
1063endif
8ecce684 1064
81b63c70
ER
1065ifeq ($(TCLTK_PATH),)
1066NO_TCLTK=NoThanks
1067endif
1068
3b486cd2 1069QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir
b7774343
AR
1070QUIET_SUBDIR1 =
1071
a6f37099
AR
1072ifneq ($(findstring $(MAKEFLAGS),w),w)
1073PRINT_DIR = --no-print-directory
1074else # "make -w"
1075NO_SUBDIR = :
1076endif
1077
b7774343 1078ifneq ($(findstring $(MAKEFLAGS),s),s)
2314c947 1079ifndef V
31d0399c 1080 QUIET_CC = @echo ' ' CC $@;
74f2b2a8
SP
1081 QUIET_AR = @echo ' ' AR $@;
1082 QUIET_LINK = @echo ' ' LINK $@;
1083 QUIET_BUILT_IN = @echo ' ' BUILTIN $@;
1084 QUIET_GEN = @echo ' ' GEN $@;
3b486cd2 1085 QUIET_SUBDIR0 = +@subdir=
a6f37099
AR
1086 QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \
1087 $(MAKE) $(PRINT_DIR) -C $$subdir
2314c947 1088 export V
31d0399c 1089 export QUIET_GEN
b7774343
AR
1090 export QUIET_BUILT_IN
1091endif
74f2b2a8 1092endif
7c6ef2f2 1093
4c7100a9
JH
1094ifdef ASCIIDOC8
1095 export ASCIIDOC8
1096endif
1097
addf88e4 1098# Shell quote (do not use $(call) to accommodate ancient setups);
39c015c5
JS
1099
1100SHA1_HEADER_SQ = $(subst ','\'',$(SHA1_HEADER))
32043c9f 1101ETC_GITCONFIG_SQ = $(subst ','\'',$(ETC_GITCONFIG))
39c015c5
JS
1102
1103DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
1104bindir_SQ = $(subst ','\'',$(bindir))
026fa0d5 1105bindir_relative_SQ = $(subst ','\'',$(bindir_relative))
8e566f24 1106mandir_SQ = $(subst ','\'',$(mandir))
a149a1a4 1107infodir_SQ = $(subst ','\'',$(infodir))
39c015c5
JS
1108gitexecdir_SQ = $(subst ','\'',$(gitexecdir))
1109template_dir_SQ = $(subst ','\'',$(template_dir))
5d6491c7 1110htmldir_SQ = $(subst ','\'',$(htmldir))
ca3bcabf 1111prefix_SQ = $(subst ','\'',$(prefix))
39c015c5
JS
1112
1113SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
1114PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
81b63c70 1115TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH))
39c015c5 1116
d595a473
PB
1117LIBS = $(GITLIBS) $(EXTLIBS)
1118
32043c9f 1119BASIC_CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER_SQ)' \
506b17b1 1120 $(COMPAT_CFLAGS)
e40b61fb 1121LIB_OBJS += $(COMPAT_OBJS)
8d7f586f
PB
1122
1123ALL_CFLAGS += $(BASIC_CFLAGS)
1124ALL_LDFLAGS += $(BASIC_LDFLAGS)
1125
a42cbacc 1126export TAR INSTALL DESTDIR SHELL_PATH
d595a473
PB
1127
1128
28818ffa
PB
1129### Build rules
1130
c94c8e5f
BC
1131SHELL = $(SHELL_PATH)
1132
6dc4627e 1133all:: shell_compatibility_test $(ALL_PROGRAMS) $(BUILT_INS) $(OTHER_PROGRAMS) GIT-BUILD-OPTIONS
6fc301bb 1134ifneq (,$X)
0d768f7c 1135 $(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) git$X)), test '$p' -ef '$p$X' || $(RM) '$p';)
6fc301bb 1136endif
89967023 1137
6fc301bb 1138all::
3cfaf11b 1139ifndef NO_TCLTK
e84a063d 1140 $(QUIET_SUBDIR0)git-gui $(QUIET_SUBDIR1) gitexecdir='$(gitexec_instdir_SQ)' all
62ba5143 1141 $(QUIET_SUBDIR0)gitk-git $(QUIET_SUBDIR1) all
3cfaf11b 1142endif
74f2b2a8
SP
1143 $(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' all
1144 $(QUIET_SUBDIR0)templates $(QUIET_SUBDIR1)
b05701c5 1145
6dc4627e
BC
1146please_set_SHELL_PATH_to_a_more_modern_shell:
1147 @$$(:)
1148
1149shell_compatibility_test: please_set_SHELL_PATH_to_a_more_modern_shell
1150
4dc00021
JH
1151strip: $(PROGRAMS) git$X
1152 $(STRIP) $(STRIP_OPTS) $(PROGRAMS) git$X
1153
334d28ae
JH
1154git.o: git.c common-cmds.h GIT-CFLAGS
1155 $(QUIET_CC)$(CC) -DGIT_VERSION='"$(GIT_VERSION)"' \
1156 $(ALL_CFLAGS) -c $(filter %.c,$^)
1157
1158git$X: git.o $(BUILTIN_OBJS) $(GITLIBS)
54dadbdb 1159 $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ git.o \
70827b15 1160 $(BUILTIN_OBJS) $(ALL_LDFLAGS) $(LIBS)
6a2e50f9 1161
3d78d1f1 1162builtin-help.o: builtin-help.c common-cmds.h GIT-CFLAGS
a149a1a4 1163 $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) \
482cce82 1164 '-DGIT_HTML_PATH="$(htmldir_SQ)"' \
a149a1a4
JH
1165 '-DGIT_MAN_PATH="$(mandir_SQ)"' \
1166 '-DGIT_INFO_PATH="$(infodir_SQ)"' $<
08df6171 1167
91730800 1168$(BUILT_INS): git$X
3e073dc5
AF
1169 $(QUIET_BUILT_IN)$(RM) $@ && \
1170 ln git$X $@ 2>/dev/null || \
1171 ln -s git$X $@ 2>/dev/null || \
1172 cp git$X $@
91730800 1173
79d30668 1174common-cmds.h: ./generate-cmdlist.sh command-list.txt
48dd1da8 1175
766b084f 1176common-cmds.h: $(wildcard Documentation/git-*.txt)
74f2b2a8 1177 $(QUIET_GEN)./generate-cmdlist.sh > $@+ && mv $@+ $@
a87cd02c 1178
d6ebd259 1179$(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
4cb08df5 1180 $(QUIET_GEN)$(RM) $@ $@+ && \
39c015c5 1181 sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
4bf9f27d 1182 -e 's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \
d9bffc08 1183 -e 's|@@PERL@@|$(PERL_PATH_SQ)|g' \
3ff8cbed 1184 -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
6c5c62f3 1185 -e 's/@@NO_CURL@@/$(NO_CURL)/g' \
74f2b2a8
SP
1186 $@.sh >$@+ && \
1187 chmod +x $@+ && \
fc36f6a6 1188 mv $@+ $@
bc6146d2 1189
f848718a
AR
1190$(patsubst %.perl,%,$(SCRIPT_PERL)): perl/perl.mak
1191
d1a20575 1192perl/perl.mak: GIT-CFLAGS perl/Makefile perl/Makefile.PL
31d0399c 1193 $(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' $(@F)
f848718a 1194
f6276fe1 1195$(patsubst %.perl,%,$(SCRIPT_PERL)): % : %.perl
4cb08df5 1196 $(QUIET_GEN)$(RM) $@ $@+ && \
e883932f 1197 INSTLIBDIR=`MAKEFLAGS= $(MAKE) -C perl -s --no-print-directory instlibdir` && \
998c4daa
JH
1198 sed -e '1{' \
1199 -e ' s|#!.*perl|#!$(PERL_PATH_SQ)|' \
1200 -e ' h' \
1201 -e ' s=.*=use lib (split(/:/, $$ENV{GITPERLLIB} || "@@INSTLIBDIR@@"));=' \
1202 -e ' H' \
1203 -e ' x' \
1204 -e '}' \
f6276fe1 1205 -e 's|@@INSTLIBDIR@@|'"$$INSTLIBDIR"'|g' \
3ff8cbed 1206 -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
74f2b2a8
SP
1207 $@.perl >$@+ && \
1208 chmod +x $@+ && \
fc36f6a6 1209 mv $@+ $@
bc6146d2 1210
5d043a3d 1211gitweb/gitweb.cgi: gitweb/gitweb.perl
4cb08df5 1212 $(QUIET_GEN)$(RM) $@ $@+ && \
5d043a3d 1213 sed -e '1s|#!.*perl|#!$(PERL_PATH_SQ)|' \
06c084d2
JH
1214 -e 's|++GIT_VERSION++|$(GIT_VERSION)|g' \
1215 -e 's|++GIT_BINDIR++|$(bindir)|g' \
1216 -e 's|++GITWEB_CONFIG++|$(GITWEB_CONFIG)|g' \
26ffcb76 1217 -e 's|++GITWEB_CONFIG_SYSTEM++|$(GITWEB_CONFIG_SYSTEM)|g' \
2de21fac 1218 -e 's|++GITWEB_HOME_LINK_STR++|$(GITWEB_HOME_LINK_STR)|g' \
06c084d2
JH
1219 -e 's|++GITWEB_SITENAME++|$(GITWEB_SITENAME)|g' \
1220 -e 's|++GITWEB_PROJECTROOT++|$(GITWEB_PROJECTROOT)|g' \
ca5e9495 1221 -e 's|"++GITWEB_PROJECT_MAXDEPTH++"|$(GITWEB_PROJECT_MAXDEPTH)|g' \
32f4aacc
ML
1222 -e 's|++GITWEB_EXPORT_OK++|$(GITWEB_EXPORT_OK)|g' \
1223 -e 's|++GITWEB_STRICT_EXPORT++|$(GITWEB_STRICT_EXPORT)|g' \
19a8721e 1224 -e 's|++GITWEB_BASE_URL++|$(GITWEB_BASE_URL)|g' \
06c084d2
JH
1225 -e 's|++GITWEB_LIST++|$(GITWEB_LIST)|g' \
1226 -e 's|++GITWEB_HOMETEXT++|$(GITWEB_HOMETEXT)|g' \
1227 -e 's|++GITWEB_CSS++|$(GITWEB_CSS)|g' \
1228 -e 's|++GITWEB_LOGO++|$(GITWEB_LOGO)|g' \
0b5deba1 1229 -e 's|++GITWEB_FAVICON++|$(GITWEB_FAVICON)|g' \
b2d3476e
AC
1230 -e 's|++GITWEB_SITE_HEADER++|$(GITWEB_SITE_HEADER)|g' \
1231 -e 's|++GITWEB_SITE_FOOTER++|$(GITWEB_SITE_FOOTER)|g' \
74f2b2a8
SP
1232 $< >$@+ && \
1233 chmod +x $@+ && \
5d043a3d
MW
1234 mv $@+ $@
1235
a51d37c1 1236git-instaweb: git-instaweb.sh gitweb/gitweb.cgi gitweb/gitweb.css
4cb08df5 1237 $(QUIET_GEN)$(RM) $@ $@+ && \
a51d37c1
EW
1238 sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
1239 -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
1240 -e 's/@@NO_CURL@@/$(NO_CURL)/g' \
6e959ab0 1241 -e '/@@GITWEB_CGI@@/r gitweb/gitweb.cgi' \
07002287 1242 -e '/@@GITWEB_CGI@@/d' \
6e959ab0 1243 -e '/@@GITWEB_CSS@@/r gitweb/gitweb.css' \
07002287 1244 -e '/@@GITWEB_CSS@@/d' \
c5699693 1245 -e 's|@@PERL@@|$(PERL_PATH_SQ)|g' \
74f2b2a8
SP
1246 $@.sh > $@+ && \
1247 chmod +x $@+ && \
a51d37c1
EW
1248 mv $@+ $@
1249
3900145e 1250configure: configure.ac
4cb08df5 1251 $(QUIET_GEN)$(RM) $@ $<+ && \
3900145e 1252 sed -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
74f2b2a8
SP
1253 $< > $<+ && \
1254 autoconf -o $@ $<+ && \
4cb08df5 1255 $(RM) $<+
3900145e 1256
9b88fcef 1257# These can record GIT_VERSION
54dadbdb 1258git.o git.spec \
9b88fcef
JH
1259 $(patsubst %.sh,%,$(SCRIPT_SH)) \
1260 $(patsubst %.perl,%,$(SCRIPT_PERL)) \
9b88fcef 1261 : GIT-VERSION-FILE
e99fcf96 1262
ca3bcabf 1263%.o: %.c GIT-CFLAGS
74f2b2a8 1264 $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $<
e36cb1c1
LT
1265%.s: %.c GIT-CFLAGS
1266 $(QUIET_CC)$(CC) -S $(ALL_CFLAGS) $<
b05701c5 1267%.o: %.S
74f2b2a8 1268 $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $<
a310d434 1269
ca3bcabf 1270exec_cmd.o: exec_cmd.c GIT-CFLAGS
026fa0d5
SP
1271 $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) \
1272 '-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' \
1273 '-DBINDIR="$(bindir_relative_SQ)"' \
1274 '-DPREFIX="$(prefix_SQ)"' \
1275 $<
1276
c1f8064b 1277builtin-init-db.o: builtin-init-db.c GIT-CFLAGS
74f2b2a8 1278 $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir_SQ)"' $<
77cb17e9 1279
506b17b1
JS
1280config.o: config.c GIT-CFLAGS
1281 $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DETC_GITCONFIG='"$(ETC_GITCONFIG_SQ)"' $<
1282
ca3bcabf 1283http.o: http.c GIT-CFLAGS
74f2b2a8 1284 $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DGIT_USER_AGENT='"git/$(GIT_VERSION)"' $<
20fc9bc5 1285
8d9fbe57 1286ifdef NO_EXPAT
30ae764b 1287http-walker.o: http-walker.c http.h GIT-CFLAGS
74f2b2a8 1288 $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DNO_EXPAT $<
8d9fbe57
NH
1289endif
1290
8eef8e09 1291git-%$X: %.o $(GITLIBS)
74f2b2a8 1292 $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
623c8a14 1293
684ec6c6
RS
1294git-imap-send$X: imap-send.o $(GITLIBS)
1295 $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
1296 $(LIBS) $(OPENSSL_LINK) $(OPENSSL_LIBSSL)
f2561fda 1297
923e3ec8 1298http.o http-walker.o http-push.o transport.o: http.h
39c015c5 1299
8fced61c 1300git-http-push$X: revision.o http.o http-push.o $(GITLIBS)
74f2b2a8 1301 $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
39c015c5
JS
1302 $(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
1303
ccfc02a3 1304$(LIB_OBJS) $(BUILTIN_OBJS): $(LIB_H)
1f330269 1305$(patsubst git-%$X,%.o,$(PROGRAMS)): $(LIB_H) $(wildcard */*.h)
fa470160 1306builtin-revert.o wt-status.o: wt-status.h
e83c5163 1307
28818ffa 1308$(LIB_FILE): $(LIB_OBJS)
4cb08df5 1309 $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIB_OBJS)
28818ffa 1310
857b933e 1311XDIFF_OBJS=xdiff/xdiffi.o xdiff/xprepare.o xdiff/xutils.o xdiff/xemit.o \
34292bdd 1312 xdiff/xmerge.o xdiff/xpatience.o
17b96be2
AW
1313$(XDIFF_OBJS): xdiff/xinclude.h xdiff/xmacros.h xdiff/xdiff.h xdiff/xtypes.h \
1314 xdiff/xutils.h xdiff/xprepare.h xdiff/xdiffi.h xdiff/xemit.h
3443546f
LT
1315
1316$(XDIFF_LIB): $(XDIFF_OBJS)
4cb08df5 1317 $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(XDIFF_OBJS)
3443546f
LT
1318
1319
28818ffa
PB
1320doc:
1321 $(MAKE) -C Documentation all
1322
414851a4
MG
1323man:
1324 $(MAKE) -C Documentation man
1325
1326html:
1327 $(MAKE) -C Documentation html
1328
4739809c
DK
1329info:
1330 $(MAKE) -C Documentation info
1331
a325a1a7
MV
1332pdf:
1333 $(MAKE) -C Documentation pdf
1334
f81e7c62 1335TAGS:
4cb08df5 1336 $(RM) TAGS
89b2f19c 1337 $(FIND) . -name '*.[hcS]' -print | xargs etags -a
f81e7c62
FK
1338
1339tags:
4cb08df5 1340 $(RM) tags
89b2f19c 1341 $(FIND) . -name '*.[hcS]' -print | xargs ctags -a
28818ffa 1342
a2a9150b
KP
1343cscope:
1344 $(RM) cscope*
1345 $(FIND) . -name '*.[hcS]' -print | xargs cscope -b
1346
ca3bcabf 1347### Detect prefix changes
7cdbff14 1348TRACK_CFLAGS = $(subst ','\'',$(ALL_CFLAGS)):\
ca3bcabf
YL
1349 $(bindir_SQ):$(gitexecdir_SQ):$(template_dir_SQ):$(prefix_SQ)
1350
1351GIT-CFLAGS: .FORCE-GIT-CFLAGS
1352 @FLAGS='$(TRACK_CFLAGS)'; \
1353 if test x"$$FLAGS" != x"`cat GIT-CFLAGS 2>/dev/null`" ; then \
1354 echo 1>&2 " * new build flags or prefix"; \
1355 echo "$$FLAGS" >GIT-CFLAGS; \
1356 fi
1357
bfce5087
JH
1358# We need to apply sq twice, once to protect from the shell
1359# that runs GIT-BUILD-OPTIONS, and then again to protect it
1360# and the first level quoting from the shell that runs "echo".
7cf7f54a 1361GIT-BUILD-OPTIONS: .FORCE-GIT-BUILD-OPTIONS
bfce5087
JH
1362 @echo SHELL_PATH=\''$(subst ','\'',$(SHELL_PATH_SQ))'\' >$@
1363 @echo TAR=\''$(subst ','\'',$(subst ','\'',$(TAR)))'\' >>$@
7cf7f54a 1364
6bdb18a9
ER
1365### Detect Tck/Tk interpreter path changes
1366ifndef NO_TCLTK
1367TRACK_VARS = $(subst ','\'',-DTCLTK_PATH='$(TCLTK_PATH_SQ)')
1368
1369GIT-GUI-VARS: .FORCE-GIT-GUI-VARS
1370 @VARS='$(TRACK_VARS)'; \
1371 if test x"$$VARS" != x"`cat $@ 2>/dev/null`" ; then \
1372 echo 1>&2 " * new Tcl/Tk interpreter location"; \
1373 echo "$$VARS" >$@; \
1374 fi
1375
1376.PHONY: .FORCE-GIT-GUI-VARS
1377endif
1378
28818ffa
PB
1379### Testing rules
1380
9002ec3a 1381TEST_PROGRAMS += test-chmtime$X
b4285c71 1382TEST_PROGRAMS += test-ctype$X
9002ec3a
JK
1383TEST_PROGRAMS += test-date$X
1384TEST_PROGRAMS += test-delta$X
b63bc0bc 1385TEST_PROGRAMS += test-dump-cache-tree$X
9002ec3a
JK
1386TEST_PROGRAMS += test-genrandom$X
1387TEST_PROGRAMS += test-match-trees$X
1388TEST_PROGRAMS += test-parse-options$X
1389TEST_PROGRAMS += test-path-utils$X
1390TEST_PROGRAMS += test-sha1$X
4a16d072 1391TEST_PROGRAMS += test-sigchain$X
96651ef5
JH
1392
1393all:: $(TEST_PROGRAMS)
1394
abb7c7b3
JS
1395# GNU make supports exporting all variables by "export" without parameters.
1396# However, the environment gets quite big, and some programs have problems
1397# with that.
1398
140245b3 1399export NO_SVN_TESTS
abb7c7b3 1400
96651ef5 1401test: all
28818ffa
PB
1402 $(MAKE) -C t/ all
1403
b4285c71
RS
1404test-ctype$X: ctype.o
1405
5c5ba73b 1406test-date$X: date.o ctype.o
28818ffa 1407
5c5ba73b 1408test-delta$X: diff-delta.o patch-delta.o
28818ffa 1409
481424e1
AR
1410test-parse-options$X: parse-options.o
1411
fa8fe28c
JH
1412.PRECIOUS: $(patsubst test-%$X,test-%.o,$(TEST_PROGRAMS))
1413
5c5ba73b
JP
1414test-%$X: test-%.o $(GITLIBS)
1415 $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
2dca1af4 1416
b65bc21e
JH
1417check-sha1:: test-sha1$X
1418 ./test-sha1.sh
1419
7c4c9f4c 1420check: common-cmds.h
912f9980
JH
1421 if sparse; \
1422 then \
1423 for i in *.c; \
1424 do \
1425 sparse $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i || exit; \
1426 done; \
1427 else \
1428 echo 2>&1 "Did you mean 'make test'?"; \
1429 exit 1; \
1430 fi
28818ffa 1431
36e5e70e 1432remove-dashes:
b4f02d35 1433 ./fixup-builtins $(BUILT_INS) $(PROGRAMS) $(SCRIPTS)
28818ffa
PB
1434
1435### Installation rules
1436
0c0ead7e 1437ifneq ($(filter /%,$(firstword $(template_dir))),)
0b50b860 1438template_instdir = $(template_dir)
026fa0d5
SP
1439else
1440template_instdir = $(prefix)/$(template_dir)
0b50b860
JS
1441endif
1442export template_instdir
1443
0c0ead7e 1444ifneq ($(filter /%,$(firstword $(gitexecdir))),)
49fa65a7 1445gitexec_instdir = $(gitexecdir)
026fa0d5
SP
1446else
1447gitexec_instdir = $(prefix)/$(gitexecdir)
49fa65a7
JS
1448endif
1449gitexec_instdir_SQ = $(subst ','\'',$(gitexec_instdir))
1450export gitexec_instdir
1451
d6ebd259 1452install: all
41650765 1453 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'
49fa65a7
JS
1454 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
1455 $(INSTALL) $(ALL_PROGRAMS) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
ede4caf6 1456 $(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 1457 $(MAKE) -C templates DESTDIR='$(DESTDIR_SQ)' install
28072a5d 1458 $(MAKE) -C perl prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' install
3cfaf11b 1459ifndef NO_TCLTK
62ba5143 1460 $(MAKE) -C gitk-git install
49fa65a7 1461 $(MAKE) -C git-gui gitexecdir='$(gitexec_instdir_SQ)' install
3cfaf11b 1462endif
6fc301bb 1463ifneq (,$X)
49fa65a7 1464 $(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) git$X)), $(RM) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)/$p';)
6fc301bb 1465endif
46beb559 1466 bindir=$$(cd '$(DESTDIR_SQ)$(bindir_SQ)' && pwd) && \
49fa65a7 1467 execdir=$$(cd '$(DESTDIR_SQ)$(gitexec_instdir_SQ)' && pwd) && \
3e073dc5
AF
1468 { $(RM) "$$execdir/git-add$X" && \
1469 ln git-add$X "$$execdir/git-add$X" 2>/dev/null || \
1470 cp git-add$X "$$execdir/git-add$X"; } && \
b56c79cc
BC
1471 { for p in $(filter-out git-add$X,$(BUILT_INS)); do \
1472 $(RM) "$$execdir/$$p" && \
1473 ln "$$execdir/git-add$X" "$$execdir/$$p" 2>/dev/null || \
1474 ln -s "git-add$X" "$$execdir/$$p" 2>/dev/null || \
1475 cp "$$execdir/git-add$X" "$$execdir/$$p" || exit; \
1476 done } && \
7b4b59a9 1477 ./check_bindir "z$$bindir" "z$$execdir" "$$bindir/git-add$X"
28818ffa
PB
1478
1479install-doc:
1480 $(MAKE) -C Documentation install
1481
b1a46b70
MH
1482install-man:
1483 $(MAKE) -C Documentation install-man
1484
ae081f3e
TL
1485install-html:
1486 $(MAKE) -C Documentation install-html
1487
4739809c
DK
1488install-info:
1489 $(MAKE) -C Documentation install-info
1490
a325a1a7
MV
1491install-pdf:
1492 $(MAKE) -C Documentation install-pdf
1493
6538d1ef
EW
1494quick-install-doc:
1495 $(MAKE) -C Documentation quick-install
28818ffa 1496
b1a46b70
MH
1497quick-install-man:
1498 $(MAKE) -C Documentation quick-install-man
1499
6fe570de
MG
1500quick-install-html:
1501 $(MAKE) -C Documentation quick-install-html
1502
28818ffa
PB
1503
1504
1505### Maintainer's dist rules
1506
9b88fcef 1507git.spec: git.spec.in
fc36f6a6
JM
1508 sed -e 's/@@VERSION@@/$(GIT_VERSION)/g' < $< > $@+
1509 mv $@+ $@
a9db2974 1510
27dedf0c 1511GIT_TARNAME=git-$(GIT_VERSION)
6c0f8694 1512dist: git.spec git-archive$(X) configure
9ccb64c8
JH
1513 ./git-archive --format=tar \
1514 --prefix=$(GIT_TARNAME)/ HEAD^{tree} > $(GIT_TARNAME).tar
a9db2974 1515 @mkdir -p $(GIT_TARNAME)
f58494bf 1516 @cp git.spec configure $(GIT_TARNAME)
181129d2 1517 @echo $(GIT_VERSION) > $(GIT_TARNAME)/version
d647c2ea 1518 @$(MAKE) -C git-gui TARDIR=../$(GIT_TARNAME)/git-gui dist-version
181129d2 1519 $(TAR) rf $(GIT_TARNAME).tar \
d647c2ea 1520 $(GIT_TARNAME)/git.spec \
f58494bf 1521 $(GIT_TARNAME)/configure \
d647c2ea 1522 $(GIT_TARNAME)/version \
115f0fe4 1523 $(GIT_TARNAME)/git-gui/version
4cb08df5 1524 @$(RM) -r $(GIT_TARNAME)
9dce3c06 1525 gzip -f -9 $(GIT_TARNAME).tar
a9db2974
CW
1526
1527rpm: dist
27dedf0c 1528 $(RPMBUILD) -ta $(GIT_TARNAME).tar.gz
a9db2974 1529
52db0495
TS
1530htmldocs = git-htmldocs-$(GIT_VERSION)
1531manpages = git-manpages-$(GIT_VERSION)
1532dist-doc:
4cb08df5 1533 $(RM) -r .doc-tmp-dir
52db0495
TS
1534 mkdir .doc-tmp-dir
1535 $(MAKE) -C Documentation WEBDOC_DEST=../.doc-tmp-dir install-webdoc
1536 cd .doc-tmp-dir && $(TAR) cf ../$(htmldocs).tar .
1537 gzip -n -9 -f $(htmldocs).tar
1538 :
4cb08df5 1539 $(RM) -r .doc-tmp-dir
4392da4d 1540 mkdir -p .doc-tmp-dir/man1 .doc-tmp-dir/man5 .doc-tmp-dir/man7
c5360324 1541 $(MAKE) -C Documentation DESTDIR=./ \
7b8cf0cf 1542 man1dir=../.doc-tmp-dir/man1 \
4392da4d 1543 man5dir=../.doc-tmp-dir/man5 \
7b8cf0cf 1544 man7dir=../.doc-tmp-dir/man7 \
52db0495
TS
1545 install
1546 cd .doc-tmp-dir && $(TAR) cf ../$(manpages).tar .
1547 gzip -n -9 -f $(manpages).tar
4cb08df5 1548 $(RM) -r .doc-tmp-dir
52db0495 1549
28818ffa 1550### Cleaning rules
87a81c83 1551
922aa807
MM
1552distclean: clean
1553 $(RM) configure
1554
e83c5163 1555clean:
4cb08df5 1556 $(RM) *.o mozilla-sha1/*.o arm/*.o ppc/*.o compat/*.o xdiff/*.o \
4cfc24af 1557 $(LIB_FILE) $(XDIFF_LIB)
4cb08df5
EM
1558 $(RM) $(ALL_PROGRAMS) $(BUILT_INS) git$X
1559 $(RM) $(TEST_PROGRAMS)
a2a9150b 1560 $(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo common-cmds.h TAGS tags cscope*
4cb08df5 1561 $(RM) -r autom4te.cache
922aa807 1562 $(RM) config.log config.mak.autogen config.mak.append config.status config.cache
4cb08df5
EM
1563 $(RM) -r $(GIT_TARNAME) .doc-tmp-dir
1564 $(RM) $(GIT_TARNAME).tar.gz git-core_$(GIT_VERSION)-*.tar.gz
1565 $(RM) $(htmldocs).tar.gz $(manpages).tar.gz
1566 $(RM) gitweb/gitweb.cgi
ca67f002 1567 $(MAKE) -C Documentation/ clean
f848718a 1568 $(MAKE) -C perl clean
b1edc53d 1569 $(MAKE) -C templates/ clean
4b7581f0 1570 $(MAKE) -C t/ clean
3cfaf11b 1571ifndef NO_TCLTK
62ba5143 1572 $(MAKE) -C gitk-git clean
3cfaf11b
ER
1573 $(MAKE) -C git-gui clean
1574endif
7cf7f54a 1575 $(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-GUI-VARS GIT-BUILD-OPTIONS
9b88fcef 1576
4dc00021 1577.PHONY: all install clean strip
6dc4627e 1578.PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell
a2a9150b 1579.PHONY: .FORCE-GIT-VERSION-FILE TAGS tags cscope .FORCE-GIT-CFLAGS
7cf7f54a 1580.PHONY: .FORCE-GIT-BUILD-OPTIONS
d89056c2 1581
8c989ec5
JH
1582### Check documentation
1583#
1584check-docs::
3f7ce648 1585 @(for v in $(ALL_PROGRAMS) $(BUILT_INS) git gitk; \
8c989ec5
JH
1586 do \
1587 case "$$v" in \
8c989ec5 1588 git-merge-octopus | git-merge-ours | git-merge-recursive | \
51add76e 1589 git-merge-resolve | git-merge-subtree | \
5c66d0d4 1590 git-fsck-objects | git-init-db | \
5b4617c7 1591 git-?*--?* ) continue ;; \
8c989ec5
JH
1592 esac ; \
1593 test -f "Documentation/$$v.txt" || \
1594 echo "no doc: $$v"; \
79d30668 1595 sed -e '/^#/d' command-list.txt | \
4b02c529 1596 grep -q "^$$v[ ]" || \
8c989ec5
JH
1597 case "$$v" in \
1598 git) ;; \
1599 *) echo "no link: $$v";; \
1600 esac ; \
3f7ce648
JH
1601 done; \
1602 ( \
79d30668 1603 sed -e '/^#/d' \
3f7ce648 1604 -e 's/[ ].*//' \
79d30668 1605 -e 's/^/listed /' command-list.txt; \
3f7ce648
JH
1606 ls -1 Documentation/git*txt | \
1607 sed -e 's|Documentation/|documented |' \
1608 -e 's/\.txt//'; \
1609 ) | while read how cmd; \
1610 do \
1611 case "$$how,$$cmd" in \
1612 *,git-citool | \
1613 *,git-gui | \
0f6f195b 1614 *,git-help | \
3f7ce648
JH
1615 documented,gitattributes | \
1616 documented,gitignore | \
1617 documented,gitmodules | \
2f7ee089 1618 documented,gitcli | \
3f7ce648 1619 documented,git-tools | \
d0594be1
JH
1620 documented,gitcore-tutorial | \
1621 documented,gitcvs-migration | \
1622 documented,gitdiffcore | \
1623 documented,gitglossary | \
1624 documented,githooks | \
1625 documented,gitrepository-layout | \
1626 documented,gittutorial | \
1627 documented,gittutorial-2 | \
3f7ce648
JH
1628 sentinel,not,matching,is,ok ) continue ;; \
1629 esac; \
1630 case " $(ALL_PROGRAMS) $(BUILT_INS) git gitk " in \
1631 *" $$cmd "*) ;; \
1632 *) echo "removed but $$how: $$cmd" ;; \
1633 esac; \
1634 done ) | sort
c74390e4
JH
1635
1636### Make sure built-ins do not have dups and listed in git.c
1637#
1638check-builtins::
1639 ./check-builtins.sh
11c57e6a 1640