Makefileon commit Makefile: clarify definition of TEST_OBJS (5b8805e)
   1# The default target of this Makefile is...
   2all::
   3
   4# Define V=1 to have a more verbose compile.
   5#
   6# Define SHELL_PATH to a POSIX shell if your /bin/sh is broken.
   7#
   8# Define SANE_TOOL_PATH to a colon-separated list of paths to prepend
   9# to PATH if your tools in /usr/bin are broken.
  10#
  11# Define SNPRINTF_RETURNS_BOGUS if your are on a system which snprintf()
  12# or vsnprintf() return -1 instead of number of characters which would
  13# have been written to the final string if enough space had been available.
  14#
  15# Define FREAD_READS_DIRECTORIES if your are on a system which succeeds
  16# when attempting to read from an fopen'ed directory.
  17#
  18# Define NO_OPENSSL environment variable if you do not have OpenSSL.
  19# This also implies BLK_SHA1.
  20#
  21# Define NO_CURL if you do not have libcurl installed.  git-http-pull and
  22# git-http-push are not built, and you cannot use http:// and https://
  23# transports.
  24#
  25# Define CURLDIR=/foo/bar if your curl header and library files are in
  26# /foo/bar/include and /foo/bar/lib directories.
  27#
  28# Define NO_EXPAT if you do not have expat installed.  git-http-push is
  29# not built, and you cannot push using http:// and https:// transports.
  30#
  31# Define EXPATDIR=/foo/bar if your expat header and library files are in
  32# /foo/bar/include and /foo/bar/lib directories.
  33#
  34# Define NO_D_INO_IN_DIRENT if you don't have d_ino in your struct dirent.
  35#
  36# Define NO_D_TYPE_IN_DIRENT if your platform defines DT_UNKNOWN but lacks
  37# d_type in struct dirent (latest Cygwin -- will be fixed soonish).
  38#
  39# Define NO_C99_FORMAT if your formatted IO functions (printf/scanf et.al.)
  40# do not support the 'size specifiers' introduced by C99, namely ll, hh,
  41# j, z, t. (representing long long int, char, intmax_t, size_t, ptrdiff_t).
  42# some C compilers supported these specifiers prior to C99 as an extension.
  43#
  44# Define NO_STRCASESTR if you don't have strcasestr.
  45#
  46# Define NO_MEMMEM if you don't have memmem.
  47#
  48# Define NO_STRLCPY if you don't have strlcpy.
  49#
  50# Define NO_STRTOUMAX if you don't have strtoumax in the C library.
  51# If your compiler also does not support long long or does not have
  52# strtoull, define NO_STRTOULL.
  53#
  54# Define NO_SETENV if you don't have setenv in the C library.
  55#
  56# Define NO_UNSETENV if you don't have unsetenv in the C library.
  57#
  58# Define NO_MKDTEMP if you don't have mkdtemp in the C library.
  59#
  60# Define NO_MKSTEMPS if you don't have mkstemps in the C library.
  61#
  62# Define NO_LIBGEN_H if you don't have libgen.h.
  63#
  64# Define NEEDS_LIBGEN if your libgen needs -lgen when linking
  65#
  66# Define NO_SYS_SELECT_H if you don't have sys/select.h.
  67#
  68# Define NO_SYMLINK_HEAD if you never want .git/HEAD to be a symbolic link.
  69# Enable it on Windows.  By default, symrefs are still used.
  70#
  71# Define NO_SVN_TESTS if you want to skip time-consuming SVN interoperability
  72# tests.  These tests take up a significant amount of the total test time
  73# but are not needed unless you plan to talk to SVN repos.
  74#
  75# Define NO_FINK if you are building on Darwin/Mac OS X, have Fink
  76# installed in /sw, but don't want GIT to link against any libraries
  77# installed there.  If defined you may specify your own (or Fink's)
  78# include directories and library directories by defining CFLAGS
  79# and LDFLAGS appropriately.
  80#
  81# Define NO_DARWIN_PORTS if you are building on Darwin/Mac OS X,
  82# have DarwinPorts installed in /opt/local, but don't want GIT to
  83# link against any libraries installed there.  If defined you may
  84# specify your own (or DarwinPort's) include directories and
  85# library directories by defining CFLAGS and LDFLAGS appropriately.
  86#
  87# Define BLK_SHA1 environment variable if you want the C version
  88# of the SHA1 that assumes you can do unaligned 32-bit loads and
  89# have a fast htonl() function.
  90#
  91# Define PPC_SHA1 environment variable when running make to make use of
  92# a bundled SHA1 routine optimized for PowerPC.
  93#
  94# Define NEEDS_CRYPTO_WITH_SSL if you need -lcrypto when using -lssl (Darwin).
  95#
  96# Define NEEDS_SSL_WITH_CRYPTO if you need -lssl when using -lcrypto (Darwin).
  97#
  98# Define NEEDS_LIBICONV if linking with libc is not enough (Darwin).
  99#
 100# Define NEEDS_SOCKET if linking with libc is not enough (SunOS,
 101# Patrick Mauritz).
 102#
 103# Define NEEDS_RESOLV if linking with -lnsl and/or -lsocket is not enough.
 104# Notably on Solaris hstrerror resides in libresolv and on Solaris 7
 105# inet_ntop and inet_pton additionally reside there.
 106#
 107# Define NO_MMAP if you want to avoid mmap.
 108#
 109# Define NO_PTHREADS if you do not have or do not want to use Pthreads.
 110#
 111# Define NO_PREAD if you have a problem with pread() system call (e.g.
 112# cygwin.dll before v1.5.22).
 113#
 114# Define NO_FAST_WORKING_DIRECTORY if accessing objects in pack files is
 115# generally faster on your platform than accessing the working directory.
 116#
 117# Define NO_TRUSTABLE_FILEMODE if your filesystem may claim to support
 118# the executable mode bit, but doesn't really do so.
 119#
 120# Define NO_IPV6 if you lack IPv6 support and getaddrinfo().
 121#
 122# Define NO_SOCKADDR_STORAGE if your platform does not have struct
 123# sockaddr_storage.
 124#
 125# Define NO_ICONV if your libc does not properly support iconv.
 126#
 127# Define OLD_ICONV if your library has an old iconv(), where the second
 128# (input buffer pointer) parameter is declared with type (const char **).
 129#
 130# Define NO_DEFLATE_BOUND if your zlib does not have deflateBound.
 131#
 132# Define NO_R_TO_GCC_LINKER if your gcc does not like "-R/path/lib"
 133# that tells runtime paths to dynamic libraries;
 134# "-Wl,-rpath=/path/lib" is used instead.
 135#
 136# Define USE_NSEC below if you want git to care about sub-second file mtimes
 137# and ctimes. Note that you need recent glibc (at least 2.2.4) for this, and
 138# it will BREAK YOUR LOCAL DIFFS! show-diff and anything using it will likely
 139# randomly break unless your underlying filesystem supports those sub-second
 140# times (my ext3 doesn't).
 141#
 142# Define USE_ST_TIMESPEC if your "struct stat" uses "st_ctimespec" instead of
 143# "st_ctim"
 144#
 145# Define NO_NSEC if your "struct stat" does not have "st_ctim.tv_nsec"
 146# available.  This automatically turns USE_NSEC off.
 147#
 148# Define USE_STDEV below if you want git to care about the underlying device
 149# change being considered an inode change from the update-index perspective.
 150#
 151# Define NO_ST_BLOCKS_IN_STRUCT_STAT if your platform does not have st_blocks
 152# field that counts the on-disk footprint in 512-byte blocks.
 153#
 154# Define ASCIIDOC8 if you want to format documentation with AsciiDoc 8
 155#
 156# Define DOCBOOK_XSL_172 if you want to format man pages with DocBook XSL v1.72
 157# (not v1.73 or v1.71).
 158#
 159# Define ASCIIDOC_NO_ROFF if your DocBook XSL escapes raw roff directives
 160# (versions 1.72 and later and 1.68.1 and earlier).
 161#
 162# Define GNU_ROFF if your target system uses GNU groff.  This forces
 163# apostrophes to be ASCII so that cut&pasting examples to the shell
 164# will work.
 165#
 166# Define NO_PERL_MAKEMAKER if you cannot use Makefiles generated by perl's
 167# MakeMaker (e.g. using ActiveState under Cygwin).
 168#
 169# Define NO_PERL if you do not want Perl scripts or libraries at all.
 170#
 171# Define NO_PYTHON if you do not want Python scripts or libraries at all.
 172#
 173# Define NO_TCLTK if you do not want Tcl/Tk GUI.
 174#
 175# The TCL_PATH variable governs the location of the Tcl interpreter
 176# used to optimize git-gui for your system.  Only used if NO_TCLTK
 177# is not set.  Defaults to the bare 'tclsh'.
 178#
 179# The TCLTK_PATH variable governs the location of the Tcl/Tk interpreter.
 180# If not set it defaults to the bare 'wish'. If it is set to the empty
 181# string then NO_TCLTK will be forced (this is used by configure script).
 182#
 183# Define THREADED_DELTA_SEARCH if you have pthreads and wish to exploit
 184# parallel delta searching when packing objects.
 185#
 186# Define INTERNAL_QSORT to use Git's implementation of qsort(), which
 187# is a simplified version of the merge sort used in glibc. This is
 188# recommended if Git triggers O(n^2) behavior in your platform's qsort().
 189#
 190# Define UNRELIABLE_FSTAT if your system's fstat does not return the same
 191# information on a not yet closed file that lstat would return for the same
 192# file after it was closed.
 193#
 194# Define OBJECT_CREATION_USES_RENAMES if your operating systems has problems
 195# when hardlinking a file to another name and unlinking the original file right
 196# away (some NTFS drivers seem to zero the contents in that scenario).
 197#
 198# Define NO_CROSS_DIRECTORY_HARDLINKS if you plan to distribute the installed
 199# programs as a tar, where bin/ and libexec/ might be on different file systems.
 200#
 201# Define USE_NED_ALLOCATOR if you want to replace the platforms default
 202# memory allocators with the nedmalloc allocator written by Niall Douglas.
 203#
 204# Define NO_REGEX if you have no or inferior regex support in your C library.
 205#
 206# Define JSMIN to point to JavaScript minifier that functions as
 207# a filter to have gitweb.js minified.
 208#
 209# Define DEFAULT_PAGER to a sensible pager command (defaults to "less") if
 210# you want to use something different.  The value will be interpreted by the
 211# shell at runtime when it is used.
 212#
 213# Define DEFAULT_EDITOR to a sensible editor command (defaults to "vi") if you
 214# want to use something different.  The value will be interpreted by the shell
 215# if necessary when it is used.  Examples:
 216#
 217#   DEFAULT_EDITOR='~/bin/vi',
 218#   DEFAULT_EDITOR='$GIT_FALLBACK_EDITOR',
 219#   DEFAULT_EDITOR='"C:\Program Files\Vim\gvim.exe" --nofork'
 220#
 221# Define COMPUTE_HEADER_DEPENDENCIES if your compiler supports the -MMD option
 222# and you want to avoid rebuilding objects when an unrelated header file
 223# changes.
 224#
 225# Define CHECK_HEADER_DEPENDENCIES to check for problems in the hard-coded
 226# dependency rules.
 227
 228GIT-VERSION-FILE: FORCE
 229        @$(SHELL_PATH) ./GIT-VERSION-GEN
 230-include GIT-VERSION-FILE
 231
 232uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
 233uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not')
 234uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')
 235uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not')
 236uname_P := $(shell sh -c 'uname -p 2>/dev/null || echo not')
 237uname_V := $(shell sh -c 'uname -v 2>/dev/null || echo not')
 238
 239ifdef MSVC
 240        # avoid the MingW and Cygwin configuration sections
 241        uname_S := Windows
 242        uname_O := Windows
 243endif
 244
 245# CFLAGS and LDFLAGS are for the users to override from the command line.
 246
 247CFLAGS = -g -O2 -Wall
 248LDFLAGS =
 249ALL_CFLAGS = $(CFLAGS)
 250ALL_LDFLAGS = $(LDFLAGS)
 251STRIP ?= strip
 252
 253# Among the variables below, these:
 254#   gitexecdir
 255#   template_dir
 256#   mandir
 257#   infodir
 258#   htmldir
 259#   ETC_GITCONFIG (but not sysconfdir)
 260# can be specified as a relative path some/where/else;
 261# this is interpreted as relative to $(prefix) and "git" at
 262# runtime figures out where they are based on the path to the executable.
 263# This can help installing the suite in a relocatable way.
 264
 265prefix = $(HOME)
 266bindir_relative = bin
 267bindir = $(prefix)/$(bindir_relative)
 268mandir = share/man
 269infodir = share/info
 270gitexecdir = libexec/git-core
 271sharedir = $(prefix)/share
 272template_dir = share/git-core/templates
 273htmldir = share/doc/git-doc
 274ifeq ($(prefix),/usr)
 275sysconfdir = /etc
 276ETC_GITCONFIG = $(sysconfdir)/gitconfig
 277else
 278sysconfdir = $(prefix)/etc
 279ETC_GITCONFIG = etc/gitconfig
 280endif
 281lib = lib
 282# DESTDIR=
 283pathsep = :
 284
 285# JavaScript minifier invocation that can function as filter
 286JSMIN =
 287
 288# default configuration for gitweb
 289GITWEB_CONFIG = gitweb_config.perl
 290GITWEB_CONFIG_SYSTEM = /etc/gitweb.conf
 291GITWEB_HOME_LINK_STR = projects
 292GITWEB_SITENAME =
 293GITWEB_PROJECTROOT = /pub/git
 294GITWEB_PROJECT_MAXDEPTH = 2007
 295GITWEB_EXPORT_OK =
 296GITWEB_STRICT_EXPORT =
 297GITWEB_BASE_URL =
 298GITWEB_LIST =
 299GITWEB_HOMETEXT = indextext.html
 300GITWEB_CSS = gitweb.css
 301GITWEB_LOGO = git-logo.png
 302GITWEB_FAVICON = git-favicon.png
 303ifdef JSMIN
 304GITWEB_JS = gitweb.min.js
 305else
 306GITWEB_JS = gitweb.js
 307endif
 308GITWEB_SITE_HEADER =
 309GITWEB_SITE_FOOTER =
 310
 311export prefix bindir sharedir sysconfdir
 312
 313CC = gcc
 314AR = ar
 315RM = rm -f
 316TAR = tar
 317FIND = find
 318INSTALL = install
 319RPMBUILD = rpmbuild
 320TCL_PATH = tclsh
 321TCLTK_PATH = wish
 322PTHREAD_LIBS = -lpthread
 323
 324export TCL_PATH TCLTK_PATH
 325
 326# sparse is architecture-neutral, which means that we need to tell it
 327# explicitly what architecture to check for. Fix this up for yours..
 328SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
 329
 330
 331
 332### --- END CONFIGURATION SECTION ---
 333
 334# Those must not be GNU-specific; they are shared with perl/ which may
 335# be built by a different compiler. (Note that this is an artifact now
 336# but it still might be nice to keep that distinction.)
 337BASIC_CFLAGS =
 338BASIC_LDFLAGS =
 339
 340# Guard against environment variables
 341BUILTIN_OBJS =
 342BUILT_INS =
 343COMPAT_CFLAGS =
 344COMPAT_OBJS =
 345LIB_H =
 346LIB_OBJS =
 347PROGRAM_OBJS =
 348PROGRAMS =
 349SCRIPT_PERL =
 350SCRIPT_PYTHON =
 351SCRIPT_SH =
 352TEST_PROGRAMS_NEED_X =
 353
 354SCRIPT_SH += git-am.sh
 355SCRIPT_SH += git-bisect.sh
 356SCRIPT_SH += git-difftool--helper.sh
 357SCRIPT_SH += git-filter-branch.sh
 358SCRIPT_SH += git-lost-found.sh
 359SCRIPT_SH += git-merge-octopus.sh
 360SCRIPT_SH += git-merge-one-file.sh
 361SCRIPT_SH += git-merge-resolve.sh
 362SCRIPT_SH += git-mergetool.sh
 363SCRIPT_SH += git-mergetool--lib.sh
 364SCRIPT_SH += git-notes.sh
 365SCRIPT_SH += git-parse-remote.sh
 366SCRIPT_SH += git-pull.sh
 367SCRIPT_SH += git-quiltimport.sh
 368SCRIPT_SH += git-rebase--interactive.sh
 369SCRIPT_SH += git-rebase.sh
 370SCRIPT_SH += git-repack.sh
 371SCRIPT_SH += git-request-pull.sh
 372SCRIPT_SH += git-sh-setup.sh
 373SCRIPT_SH += git-stash.sh
 374SCRIPT_SH += git-submodule.sh
 375SCRIPT_SH += git-web--browse.sh
 376
 377SCRIPT_PERL += git-add--interactive.perl
 378SCRIPT_PERL += git-difftool.perl
 379SCRIPT_PERL += git-archimport.perl
 380SCRIPT_PERL += git-cvsexportcommit.perl
 381SCRIPT_PERL += git-cvsimport.perl
 382SCRIPT_PERL += git-cvsserver.perl
 383SCRIPT_PERL += git-relink.perl
 384SCRIPT_PERL += git-send-email.perl
 385SCRIPT_PERL += git-svn.perl
 386
 387SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \
 388          $(patsubst %.perl,%,$(SCRIPT_PERL)) \
 389          $(patsubst %.py,%,$(SCRIPT_PYTHON)) \
 390          git-instaweb
 391
 392# Empty...
 393EXTRA_PROGRAMS =
 394
 395# ... and all the rest that could be moved out of bindir to gitexecdir
 396PROGRAMS += $(EXTRA_PROGRAMS)
 397
 398PROGRAM_OBJS += fast-import.o
 399PROGRAM_OBJS += imap-send.o
 400PROGRAM_OBJS += shell.o
 401PROGRAM_OBJS += show-index.o
 402PROGRAM_OBJS += upload-pack.o
 403PROGRAM_OBJS += http-backend.o
 404
 405PROGRAMS += $(patsubst %.o,git-%$X,$(PROGRAM_OBJS))
 406
 407TEST_PROGRAMS_NEED_X += test-chmtime
 408TEST_PROGRAMS_NEED_X += test-ctype
 409TEST_PROGRAMS_NEED_X += test-date
 410TEST_PROGRAMS_NEED_X += test-delta
 411TEST_PROGRAMS_NEED_X += test-dump-cache-tree
 412TEST_PROGRAMS_NEED_X += test-genrandom
 413TEST_PROGRAMS_NEED_X += test-match-trees
 414TEST_PROGRAMS_NEED_X += test-parse-options
 415TEST_PROGRAMS_NEED_X += test-path-utils
 416TEST_PROGRAMS_NEED_X += test-run-command
 417TEST_PROGRAMS_NEED_X += test-sha1
 418TEST_PROGRAMS_NEED_X += test-sigchain
 419TEST_PROGRAMS_NEED_X += test-index-version
 420
 421TEST_PROGRAMS := $(patsubst %,%$X,$(TEST_PROGRAMS_NEED_X))
 422
 423# List built-in command $C whose implementation cmd_$C() is not in
 424# builtin-$C.o but is linked in as part of some other command.
 425BUILT_INS += $(patsubst builtin-%.o,git-%$X,$(BUILTIN_OBJS))
 426
 427BUILT_INS += git-cherry$X
 428BUILT_INS += git-cherry-pick$X
 429BUILT_INS += git-format-patch$X
 430BUILT_INS += git-fsck-objects$X
 431BUILT_INS += git-get-tar-commit-id$X
 432BUILT_INS += git-init$X
 433BUILT_INS += git-merge-subtree$X
 434BUILT_INS += git-peek-remote$X
 435BUILT_INS += git-repo-config$X
 436BUILT_INS += git-show$X
 437BUILT_INS += git-stage$X
 438BUILT_INS += git-status$X
 439BUILT_INS += git-whatchanged$X
 440
 441# what 'all' will build and 'install' will install in gitexecdir,
 442# excluding programs for built-in commands
 443ALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS)
 444
 445# what 'all' will build but not install in gitexecdir
 446OTHER_PROGRAMS = git$X
 447
 448# what test wrappers are needed and 'install' will install, in bindir
 449BINDIR_PROGRAMS_NEED_X += git
 450BINDIR_PROGRAMS_NEED_X += git-upload-pack
 451BINDIR_PROGRAMS_NEED_X += git-receive-pack
 452BINDIR_PROGRAMS_NEED_X += git-upload-archive
 453BINDIR_PROGRAMS_NEED_X += git-shell
 454
 455BINDIR_PROGRAMS_NO_X += git-cvsserver
 456
 457# Set paths to tools early so that they can be used for version tests.
 458ifndef SHELL_PATH
 459        SHELL_PATH = /bin/sh
 460endif
 461ifndef PERL_PATH
 462        PERL_PATH = /usr/bin/perl
 463endif
 464ifndef PYTHON_PATH
 465        PYTHON_PATH = /usr/bin/python
 466endif
 467
 468export PERL_PATH
 469export PYTHON_PATH
 470
 471LIB_FILE=libgit.a
 472XDIFF_LIB=xdiff/lib.a
 473
 474LIB_H += advice.h
 475LIB_H += archive.h
 476LIB_H += attr.h
 477LIB_H += blob.h
 478LIB_H += builtin.h
 479LIB_H += cache.h
 480LIB_H += cache-tree.h
 481LIB_H += color.h
 482LIB_H += commit.h
 483LIB_H += compat/bswap.h
 484LIB_H += compat/cygwin.h
 485LIB_H += compat/mingw.h
 486LIB_H += compat/win32/pthread.h
 487LIB_H += csum-file.h
 488LIB_H += decorate.h
 489LIB_H += delta.h
 490LIB_H += diffcore.h
 491LIB_H += diff.h
 492LIB_H += dir.h
 493LIB_H += exec_cmd.h
 494LIB_H += fsck.h
 495LIB_H += git-compat-util.h
 496LIB_H += graph.h
 497LIB_H += grep.h
 498LIB_H += hash.h
 499LIB_H += help.h
 500LIB_H += levenshtein.h
 501LIB_H += list-objects.h
 502LIB_H += ll-merge.h
 503LIB_H += log-tree.h
 504LIB_H += mailmap.h
 505LIB_H += merge-recursive.h
 506LIB_H += notes.h
 507LIB_H += object.h
 508LIB_H += pack.h
 509LIB_H += pack-refs.h
 510LIB_H += pack-revindex.h
 511LIB_H += parse-options.h
 512LIB_H += patch-ids.h
 513LIB_H += pkt-line.h
 514LIB_H += progress.h
 515LIB_H += quote.h
 516LIB_H += reflog-walk.h
 517LIB_H += refs.h
 518LIB_H += remote.h
 519LIB_H += rerere.h
 520LIB_H += resolve-undo.h
 521LIB_H += revision.h
 522LIB_H += run-command.h
 523LIB_H += sha1-lookup.h
 524LIB_H += sideband.h
 525LIB_H += sigchain.h
 526LIB_H += strbuf.h
 527LIB_H += string-list.h
 528LIB_H += submodule.h
 529LIB_H += tag.h
 530LIB_H += transport.h
 531LIB_H += tree.h
 532LIB_H += tree-walk.h
 533LIB_H += unpack-trees.h
 534LIB_H += userdiff.h
 535LIB_H += utf8.h
 536LIB_H += xdiff-interface.h
 537LIB_H += xdiff/xdiff.h
 538
 539LIB_OBJS += abspath.o
 540LIB_OBJS += advice.o
 541LIB_OBJS += alias.o
 542LIB_OBJS += alloc.o
 543LIB_OBJS += archive.o
 544LIB_OBJS += archive-tar.o
 545LIB_OBJS += archive-zip.o
 546LIB_OBJS += attr.o
 547LIB_OBJS += base85.o
 548LIB_OBJS += bisect.o
 549LIB_OBJS += blob.o
 550LIB_OBJS += branch.o
 551LIB_OBJS += bundle.o
 552LIB_OBJS += cache-tree.o
 553LIB_OBJS += color.o
 554LIB_OBJS += combine-diff.o
 555LIB_OBJS += commit.o
 556LIB_OBJS += config.o
 557LIB_OBJS += connect.o
 558LIB_OBJS += convert.o
 559LIB_OBJS += copy.o
 560LIB_OBJS += csum-file.o
 561LIB_OBJS += ctype.o
 562LIB_OBJS += date.o
 563LIB_OBJS += decorate.o
 564LIB_OBJS += diffcore-break.o
 565LIB_OBJS += diffcore-delta.o
 566LIB_OBJS += diffcore-order.o
 567LIB_OBJS += diffcore-pickaxe.o
 568LIB_OBJS += diffcore-rename.o
 569LIB_OBJS += diff-delta.o
 570LIB_OBJS += diff-lib.o
 571LIB_OBJS += diff-no-index.o
 572LIB_OBJS += diff.o
 573LIB_OBJS += dir.o
 574LIB_OBJS += editor.o
 575LIB_OBJS += entry.o
 576LIB_OBJS += environment.o
 577LIB_OBJS += exec_cmd.o
 578LIB_OBJS += fsck.o
 579LIB_OBJS += graph.o
 580LIB_OBJS += grep.o
 581LIB_OBJS += hash.o
 582LIB_OBJS += help.o
 583LIB_OBJS += hex.o
 584LIB_OBJS += ident.o
 585LIB_OBJS += levenshtein.o
 586LIB_OBJS += list-objects.o
 587LIB_OBJS += ll-merge.o
 588LIB_OBJS += lockfile.o
 589LIB_OBJS += log-tree.o
 590LIB_OBJS += mailmap.o
 591LIB_OBJS += match-trees.o
 592LIB_OBJS += merge-file.o
 593LIB_OBJS += merge-recursive.o
 594LIB_OBJS += name-hash.o
 595LIB_OBJS += notes.o
 596LIB_OBJS += object.o
 597LIB_OBJS += pack-check.o
 598LIB_OBJS += pack-refs.o
 599LIB_OBJS += pack-revindex.o
 600LIB_OBJS += pack-write.o
 601LIB_OBJS += pager.o
 602LIB_OBJS += parse-options.o
 603LIB_OBJS += patch-delta.o
 604LIB_OBJS += patch-ids.o
 605LIB_OBJS += path.o
 606LIB_OBJS += pkt-line.o
 607LIB_OBJS += preload-index.o
 608LIB_OBJS += pretty.o
 609LIB_OBJS += progress.o
 610LIB_OBJS += quote.o
 611LIB_OBJS += reachable.o
 612LIB_OBJS += read-cache.o
 613LIB_OBJS += reflog-walk.o
 614LIB_OBJS += refs.o
 615LIB_OBJS += remote.o
 616LIB_OBJS += replace_object.o
 617LIB_OBJS += rerere.o
 618LIB_OBJS += resolve-undo.o
 619LIB_OBJS += revision.o
 620LIB_OBJS += run-command.o
 621LIB_OBJS += server-info.o
 622LIB_OBJS += setup.o
 623LIB_OBJS += sha1-lookup.o
 624LIB_OBJS += sha1_file.o
 625LIB_OBJS += sha1_name.o
 626LIB_OBJS += shallow.o
 627LIB_OBJS += sideband.o
 628LIB_OBJS += sigchain.o
 629LIB_OBJS += strbuf.o
 630LIB_OBJS += string-list.o
 631LIB_OBJS += submodule.o
 632LIB_OBJS += symlinks.o
 633LIB_OBJS += tag.o
 634LIB_OBJS += trace.o
 635LIB_OBJS += transport.o
 636LIB_OBJS += transport-helper.o
 637LIB_OBJS += tree-diff.o
 638LIB_OBJS += tree.o
 639LIB_OBJS += tree-walk.o
 640LIB_OBJS += unpack-trees.o
 641LIB_OBJS += usage.o
 642LIB_OBJS += userdiff.o
 643LIB_OBJS += utf8.o
 644LIB_OBJS += walker.o
 645LIB_OBJS += wrapper.o
 646LIB_OBJS += write_or_die.o
 647LIB_OBJS += ws.o
 648LIB_OBJS += wt-status.o
 649LIB_OBJS += xdiff-interface.o
 650
 651BUILTIN_OBJS += builtin-add.o
 652BUILTIN_OBJS += builtin-annotate.o
 653BUILTIN_OBJS += builtin-apply.o
 654BUILTIN_OBJS += builtin-archive.o
 655BUILTIN_OBJS += builtin-bisect--helper.o
 656BUILTIN_OBJS += builtin-blame.o
 657BUILTIN_OBJS += builtin-branch.o
 658BUILTIN_OBJS += builtin-bundle.o
 659BUILTIN_OBJS += builtin-cat-file.o
 660BUILTIN_OBJS += builtin-check-attr.o
 661BUILTIN_OBJS += builtin-check-ref-format.o
 662BUILTIN_OBJS += builtin-checkout-index.o
 663BUILTIN_OBJS += builtin-checkout.o
 664BUILTIN_OBJS += builtin-clean.o
 665BUILTIN_OBJS += builtin-clone.o
 666BUILTIN_OBJS += builtin-commit-tree.o
 667BUILTIN_OBJS += builtin-commit.o
 668BUILTIN_OBJS += builtin-config.o
 669BUILTIN_OBJS += builtin-count-objects.o
 670BUILTIN_OBJS += builtin-describe.o
 671BUILTIN_OBJS += builtin-diff-files.o
 672BUILTIN_OBJS += builtin-diff-index.o
 673BUILTIN_OBJS += builtin-diff-tree.o
 674BUILTIN_OBJS += builtin-diff.o
 675BUILTIN_OBJS += builtin-fast-export.o
 676BUILTIN_OBJS += builtin-fetch-pack.o
 677BUILTIN_OBJS += builtin-fetch.o
 678BUILTIN_OBJS += builtin-fmt-merge-msg.o
 679BUILTIN_OBJS += builtin-for-each-ref.o
 680BUILTIN_OBJS += builtin-fsck.o
 681BUILTIN_OBJS += builtin-gc.o
 682BUILTIN_OBJS += builtin-grep.o
 683BUILTIN_OBJS += builtin-hash-object.o
 684BUILTIN_OBJS += builtin-help.o
 685BUILTIN_OBJS += builtin-index-pack.o
 686BUILTIN_OBJS += builtin-init-db.o
 687BUILTIN_OBJS += builtin-log.o
 688BUILTIN_OBJS += builtin-ls-files.o
 689BUILTIN_OBJS += builtin-ls-remote.o
 690BUILTIN_OBJS += builtin-ls-tree.o
 691BUILTIN_OBJS += builtin-mailinfo.o
 692BUILTIN_OBJS += builtin-mailsplit.o
 693BUILTIN_OBJS += builtin-merge.o
 694BUILTIN_OBJS += builtin-merge-base.o
 695BUILTIN_OBJS += builtin-merge-file.o
 696BUILTIN_OBJS += builtin-merge-index.o
 697BUILTIN_OBJS += builtin-merge-ours.o
 698BUILTIN_OBJS += builtin-merge-recursive.o
 699BUILTIN_OBJS += builtin-merge-tree.o
 700BUILTIN_OBJS += builtin-mktag.o
 701BUILTIN_OBJS += builtin-mktree.o
 702BUILTIN_OBJS += builtin-mv.o
 703BUILTIN_OBJS += builtin-name-rev.o
 704BUILTIN_OBJS += builtin-pack-objects.o
 705BUILTIN_OBJS += builtin-pack-redundant.o
 706BUILTIN_OBJS += builtin-pack-refs.o
 707BUILTIN_OBJS += builtin-patch-id.o
 708BUILTIN_OBJS += builtin-prune-packed.o
 709BUILTIN_OBJS += builtin-prune.o
 710BUILTIN_OBJS += builtin-push.o
 711BUILTIN_OBJS += builtin-read-tree.o
 712BUILTIN_OBJS += builtin-receive-pack.o
 713BUILTIN_OBJS += builtin-reflog.o
 714BUILTIN_OBJS += builtin-remote.o
 715BUILTIN_OBJS += builtin-replace.o
 716BUILTIN_OBJS += builtin-rerere.o
 717BUILTIN_OBJS += builtin-reset.o
 718BUILTIN_OBJS += builtin-rev-list.o
 719BUILTIN_OBJS += builtin-rev-parse.o
 720BUILTIN_OBJS += builtin-revert.o
 721BUILTIN_OBJS += builtin-rm.o
 722BUILTIN_OBJS += builtin-send-pack.o
 723BUILTIN_OBJS += builtin-shortlog.o
 724BUILTIN_OBJS += builtin-show-branch.o
 725BUILTIN_OBJS += builtin-show-ref.o
 726BUILTIN_OBJS += builtin-stripspace.o
 727BUILTIN_OBJS += builtin-symbolic-ref.o
 728BUILTIN_OBJS += builtin-tag.o
 729BUILTIN_OBJS += builtin-tar-tree.o
 730BUILTIN_OBJS += builtin-unpack-file.o
 731BUILTIN_OBJS += builtin-unpack-objects.o
 732BUILTIN_OBJS += builtin-update-index.o
 733BUILTIN_OBJS += builtin-update-ref.o
 734BUILTIN_OBJS += builtin-update-server-info.o
 735BUILTIN_OBJS += builtin-upload-archive.o
 736BUILTIN_OBJS += builtin-var.o
 737BUILTIN_OBJS += builtin-verify-pack.o
 738BUILTIN_OBJS += builtin-verify-tag.o
 739BUILTIN_OBJS += builtin-write-tree.o
 740
 741GITLIBS = $(LIB_FILE) $(XDIFF_LIB)
 742EXTLIBS =
 743
 744#
 745# Platform specific tweaks
 746#
 747
 748# We choose to avoid "if .. else if .. else .. endif endif"
 749# because maintaining the nesting to match is a pain.  If
 750# we had "elif" things would have been much nicer...
 751
 752ifeq ($(uname_S),Linux)
 753        NO_STRLCPY = YesPlease
 754        NO_MKSTEMPS = YesPlease
 755        THREADED_DELTA_SEARCH = YesPlease
 756endif
 757ifeq ($(uname_S),GNU/kFreeBSD)
 758        NO_STRLCPY = YesPlease
 759        NO_MKSTEMPS = YesPlease
 760        THREADED_DELTA_SEARCH = YesPlease
 761endif
 762ifeq ($(uname_S),UnixWare)
 763        CC = cc
 764        NEEDS_SOCKET = YesPlease
 765        NEEDS_NSL = YesPlease
 766        NEEDS_SSL_WITH_CRYPTO = YesPlease
 767        NEEDS_LIBICONV = YesPlease
 768        SHELL_PATH = /usr/local/bin/bash
 769        NO_IPV6 = YesPlease
 770        NO_HSTRERROR = YesPlease
 771        NO_MKSTEMPS = YesPlease
 772        BASIC_CFLAGS += -Kthread
 773        BASIC_CFLAGS += -I/usr/local/include
 774        BASIC_LDFLAGS += -L/usr/local/lib
 775        INSTALL = ginstall
 776        TAR = gtar
 777        NO_STRCASESTR = YesPlease
 778        NO_MEMMEM = YesPlease
 779endif
 780ifeq ($(uname_S),SCO_SV)
 781        ifeq ($(uname_R),3.2)
 782                CFLAGS = -O2
 783        endif
 784        ifeq ($(uname_R),5)
 785                CC = cc
 786                BASIC_CFLAGS += -Kthread
 787        endif
 788        NEEDS_SOCKET = YesPlease
 789        NEEDS_NSL = YesPlease
 790        NEEDS_SSL_WITH_CRYPTO = YesPlease
 791        NEEDS_LIBICONV = YesPlease
 792        SHELL_PATH = /usr/bin/bash
 793        NO_IPV6 = YesPlease
 794        NO_HSTRERROR = YesPlease
 795        NO_MKSTEMPS = YesPlease
 796        BASIC_CFLAGS += -I/usr/local/include
 797        BASIC_LDFLAGS += -L/usr/local/lib
 798        NO_STRCASESTR = YesPlease
 799        NO_MEMMEM = YesPlease
 800        INSTALL = ginstall
 801        TAR = gtar
 802endif
 803ifeq ($(uname_S),Darwin)
 804        NEEDS_CRYPTO_WITH_SSL = YesPlease
 805        NEEDS_SSL_WITH_CRYPTO = YesPlease
 806        NEEDS_LIBICONV = YesPlease
 807        ifeq ($(shell expr "$(uname_R)" : '[15678]\.'),2)
 808                OLD_ICONV = UnfortunatelyYes
 809        endif
 810        ifeq ($(shell expr "$(uname_R)" : '[15]\.'),2)
 811                NO_STRLCPY = YesPlease
 812        endif
 813        NO_MEMMEM = YesPlease
 814        THREADED_DELTA_SEARCH = YesPlease
 815        USE_ST_TIMESPEC = YesPlease
 816endif
 817ifeq ($(uname_S),SunOS)
 818        NEEDS_SOCKET = YesPlease
 819        NEEDS_NSL = YesPlease
 820        SHELL_PATH = /bin/bash
 821        SANE_TOOL_PATH = /usr/xpg6/bin:/usr/xpg4/bin
 822        NO_STRCASESTR = YesPlease
 823        NO_MEMMEM = YesPlease
 824        NO_MKDTEMP = YesPlease
 825        NO_MKSTEMPS = YesPlease
 826        NO_REGEX = YesPlease
 827        THREADED_DELTA_SEARCH = YesPlease
 828        ifeq ($(uname_R),5.7)
 829                NEEDS_RESOLV = YesPlease
 830                NO_IPV6 = YesPlease
 831                NO_SOCKADDR_STORAGE = YesPlease
 832                NO_UNSETENV = YesPlease
 833                NO_SETENV = YesPlease
 834                NO_STRLCPY = YesPlease
 835                NO_C99_FORMAT = YesPlease
 836                NO_STRTOUMAX = YesPlease
 837        endif
 838        ifeq ($(uname_R),5.8)
 839                NO_UNSETENV = YesPlease
 840                NO_SETENV = YesPlease
 841                NO_C99_FORMAT = YesPlease
 842                NO_STRTOUMAX = YesPlease
 843        endif
 844        ifeq ($(uname_R),5.9)
 845                NO_UNSETENV = YesPlease
 846                NO_SETENV = YesPlease
 847                NO_C99_FORMAT = YesPlease
 848                NO_STRTOUMAX = YesPlease
 849        endif
 850        INSTALL = /usr/ucb/install
 851        TAR = gtar
 852        BASIC_CFLAGS += -D__EXTENSIONS__ -D__sun__ -DHAVE_ALLOCA_H
 853endif
 854ifeq ($(uname_O),Cygwin)
 855        NO_D_TYPE_IN_DIRENT = YesPlease
 856        NO_D_INO_IN_DIRENT = YesPlease
 857        NO_STRCASESTR = YesPlease
 858        NO_MEMMEM = YesPlease
 859        NO_MKSTEMPS = YesPlease
 860        NO_SYMLINK_HEAD = YesPlease
 861        NEEDS_LIBICONV = YesPlease
 862        NO_FAST_WORKING_DIRECTORY = UnfortunatelyYes
 863        NO_TRUSTABLE_FILEMODE = UnfortunatelyYes
 864        OLD_ICONV = UnfortunatelyYes
 865        NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease
 866        # There are conflicting reports about this.
 867        # On some boxes NO_MMAP is needed, and not so elsewhere.
 868        # Try commenting this out if you suspect MMAP is more efficient
 869        NO_MMAP = YesPlease
 870        NO_IPV6 = YesPlease
 871        X = .exe
 872        COMPAT_OBJS += compat/cygwin.o
 873        UNRELIABLE_FSTAT = UnfortunatelyYes
 874endif
 875ifeq ($(uname_S),FreeBSD)
 876        NEEDS_LIBICONV = YesPlease
 877        OLD_ICONV = YesPlease
 878        NO_MEMMEM = YesPlease
 879        BASIC_CFLAGS += -I/usr/local/include
 880        BASIC_LDFLAGS += -L/usr/local/lib
 881        DIR_HAS_BSD_GROUP_SEMANTICS = YesPlease
 882        USE_ST_TIMESPEC = YesPlease
 883        THREADED_DELTA_SEARCH = YesPlease
 884        ifeq ($(shell expr "$(uname_R)" : '4\.'),2)
 885                PTHREAD_LIBS = -pthread
 886                NO_UINTMAX_T = YesPlease
 887                NO_STRTOUMAX = YesPlease
 888        endif
 889endif
 890ifeq ($(uname_S),OpenBSD)
 891        NO_STRCASESTR = YesPlease
 892        NO_MEMMEM = YesPlease
 893        USE_ST_TIMESPEC = YesPlease
 894        NEEDS_LIBICONV = YesPlease
 895        BASIC_CFLAGS += -I/usr/local/include
 896        BASIC_LDFLAGS += -L/usr/local/lib
 897        THREADED_DELTA_SEARCH = YesPlease
 898endif
 899ifeq ($(uname_S),NetBSD)
 900        ifeq ($(shell expr "$(uname_R)" : '[01]\.'),2)
 901                NEEDS_LIBICONV = YesPlease
 902        endif
 903        BASIC_CFLAGS += -I/usr/pkg/include
 904        BASIC_LDFLAGS += -L/usr/pkg/lib $(CC_LD_DYNPATH)/usr/pkg/lib
 905        THREADED_DELTA_SEARCH = YesPlease
 906        USE_ST_TIMESPEC = YesPlease
 907        NO_MKSTEMPS = YesPlease
 908endif
 909ifeq ($(uname_S),AIX)
 910        NO_STRCASESTR=YesPlease
 911        NO_MEMMEM = YesPlease
 912        NO_MKDTEMP = YesPlease
 913        NO_MKSTEMPS = YesPlease
 914        NO_STRLCPY = YesPlease
 915        NO_NSEC = YesPlease
 916        FREAD_READS_DIRECTORIES = UnfortunatelyYes
 917        INTERNAL_QSORT = UnfortunatelyYes
 918        NEEDS_LIBICONV=YesPlease
 919        BASIC_CFLAGS += -D_LARGE_FILES
 920        ifneq ($(shell expr "$(uname_V)" : '[1234]'),1)
 921                THREADED_DELTA_SEARCH = YesPlease
 922        else
 923                NO_PTHREADS = YesPlease
 924        endif
 925endif
 926ifeq ($(uname_S),GNU)
 927        # GNU/Hurd
 928        NO_STRLCPY=YesPlease
 929        NO_MKSTEMPS = YesPlease
 930endif
 931ifeq ($(uname_S),IRIX)
 932        NO_SETENV = YesPlease
 933        NO_UNSETENV = YesPlease
 934        NO_STRCASESTR = YesPlease
 935        NO_MEMMEM = YesPlease
 936        NO_MKSTEMPS = YesPlease
 937        NO_MKDTEMP = YesPlease
 938        # When compiled with the MIPSpro 7.4.4m compiler, and without pthreads
 939        # (i.e. NO_PTHREADS is set), and _with_ MMAP (i.e. NO_MMAP is not set),
 940        # git dies with a segmentation fault when trying to access the first
 941        # entry of a reflog.  The conservative choice is made to always set
 942        # NO_MMAP.  If you suspect that your compiler is not affected by this
 943        # issue, comment out the NO_MMAP statement.
 944        NO_MMAP = YesPlease
 945        SNPRINTF_RETURNS_BOGUS = YesPlease
 946        SHELL_PATH = /usr/gnu/bin/bash
 947        NEEDS_LIBGEN = YesPlease
 948        THREADED_DELTA_SEARCH = YesPlease
 949endif
 950ifeq ($(uname_S),IRIX64)
 951        NO_SETENV=YesPlease
 952        NO_UNSETENV = YesPlease
 953        NO_STRCASESTR=YesPlease
 954        NO_MEMMEM = YesPlease
 955        NO_MKSTEMPS = YesPlease
 956        NO_MKDTEMP = YesPlease
 957        # When compiled with the MIPSpro 7.4.4m compiler, and without pthreads
 958        # (i.e. NO_PTHREADS is set), and _with_ MMAP (i.e. NO_MMAP is not set),
 959        # git dies with a segmentation fault when trying to access the first
 960        # entry of a reflog.  The conservative choice is made to always set
 961        # NO_MMAP.  If you suspect that your compiler is not affected by this
 962        # issue, comment out the NO_MMAP statement.
 963        NO_MMAP = YesPlease
 964        SNPRINTF_RETURNS_BOGUS = YesPlease
 965        SHELL_PATH=/usr/gnu/bin/bash
 966        NEEDS_LIBGEN = YesPlease
 967        THREADED_DELTA_SEARCH = YesPlease
 968endif
 969ifeq ($(uname_S),HP-UX)
 970        NO_IPV6=YesPlease
 971        NO_SETENV=YesPlease
 972        NO_STRCASESTR=YesPlease
 973        NO_MEMMEM = YesPlease
 974        NO_MKSTEMPS = YesPlease
 975        NO_STRLCPY = YesPlease
 976        NO_MKDTEMP = YesPlease
 977        NO_UNSETENV = YesPlease
 978        NO_HSTRERROR = YesPlease
 979        NO_SYS_SELECT_H = YesPlease
 980        SNPRINTF_RETURNS_BOGUS = YesPlease
 981endif
 982ifeq ($(uname_S),Windows)
 983        GIT_VERSION := $(GIT_VERSION).MSVC
 984        pathsep = ;
 985        NO_PREAD = YesPlease
 986        NEEDS_CRYPTO_WITH_SSL = YesPlease
 987        NO_LIBGEN_H = YesPlease
 988        NO_SYMLINK_HEAD = YesPlease
 989        NO_IPV6 = YesPlease
 990        NO_SETENV = YesPlease
 991        NO_UNSETENV = YesPlease
 992        NO_STRCASESTR = YesPlease
 993        NO_STRLCPY = YesPlease
 994        NO_MEMMEM = YesPlease
 995        # NEEDS_LIBICONV = YesPlease
 996        NO_ICONV = YesPlease
 997        NO_C99_FORMAT = YesPlease
 998        NO_STRTOUMAX = YesPlease
 999        NO_STRTOULL = YesPlease
1000        NO_MKDTEMP = YesPlease
1001        NO_MKSTEMPS = YesPlease
1002        SNPRINTF_RETURNS_BOGUS = YesPlease
1003        NO_SVN_TESTS = YesPlease
1004        NO_PERL_MAKEMAKER = YesPlease
1005        RUNTIME_PREFIX = YesPlease
1006        NO_POSIX_ONLY_PROGRAMS = YesPlease
1007        NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease
1008        NO_NSEC = YesPlease
1009        USE_WIN32_MMAP = YesPlease
1010        # USE_NED_ALLOCATOR = YesPlease
1011        UNRELIABLE_FSTAT = UnfortunatelyYes
1012        OBJECT_CREATION_USES_RENAMES = UnfortunatelyNeedsTo
1013        NO_REGEX = YesPlease
1014        NO_CURL = YesPlease
1015        NO_PYTHON = YesPlease
1016        BLK_SHA1 = YesPlease
1017        THREADED_DELTA_SEARCH = YesPlease
1018
1019        CC = compat/vcbuild/scripts/clink.pl
1020        AR = compat/vcbuild/scripts/lib.pl
1021        CFLAGS =
1022        BASIC_CFLAGS = -nologo -I. -I../zlib -Icompat/vcbuild -Icompat/vcbuild/include -DWIN32 -D_CONSOLE -DHAVE_STRING_H -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE
1023        COMPAT_OBJS = compat/msvc.o compat/fnmatch/fnmatch.o compat/winansi.o compat/win32/pthread.o
1024        COMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DNOGDI -DHAVE_STRING_H -DHAVE_ALLOCA_H -Icompat -Icompat/fnmatch -Icompat/regex -Icompat/fnmatch -Icompat/win32 -DSTRIP_EXTENSION=\".exe\"
1025        BASIC_LDFLAGS = -IGNORE:4217 -IGNORE:4049 -NOLOGO -SUBSYSTEM:CONSOLE -NODEFAULTLIB:MSVCRT.lib
1026        EXTLIBS = advapi32.lib shell32.lib wininet.lib ws2_32.lib
1027        PTHREAD_LIBS =
1028        lib =
1029ifndef DEBUG
1030        BASIC_CFLAGS += -GL -Os -MT
1031        BASIC_LDFLAGS += -LTCG
1032        AR += -LTCG
1033else
1034        BASIC_CFLAGS += -Zi -MTd
1035endif
1036        X = .exe
1037endif
1038ifneq (,$(findstring MINGW,$(uname_S)))
1039        pathsep = ;
1040        NO_PREAD = YesPlease
1041        NEEDS_CRYPTO_WITH_SSL = YesPlease
1042        NO_LIBGEN_H = YesPlease
1043        NO_SYMLINK_HEAD = YesPlease
1044        NO_SETENV = YesPlease
1045        NO_UNSETENV = YesPlease
1046        NO_STRCASESTR = YesPlease
1047        NO_STRLCPY = YesPlease
1048        NO_MEMMEM = YesPlease
1049        NEEDS_LIBICONV = YesPlease
1050        OLD_ICONV = YesPlease
1051        NO_C99_FORMAT = YesPlease
1052        NO_STRTOUMAX = YesPlease
1053        NO_MKDTEMP = YesPlease
1054        NO_MKSTEMPS = YesPlease
1055        SNPRINTF_RETURNS_BOGUS = YesPlease
1056        NO_SVN_TESTS = YesPlease
1057        NO_PERL_MAKEMAKER = YesPlease
1058        RUNTIME_PREFIX = YesPlease
1059        NO_POSIX_ONLY_PROGRAMS = YesPlease
1060        NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease
1061        NO_NSEC = YesPlease
1062        USE_WIN32_MMAP = YesPlease
1063        USE_NED_ALLOCATOR = YesPlease
1064        UNRELIABLE_FSTAT = UnfortunatelyYes
1065        OBJECT_CREATION_USES_RENAMES = UnfortunatelyNeedsTo
1066        NO_REGEX = YesPlease
1067        NO_PYTHON = YesPlease
1068        BLK_SHA1 = YesPlease
1069        THREADED_DELTA_SEARCH = YesPlease
1070        COMPAT_CFLAGS += -D__USE_MINGW_ACCESS -DNOGDI -Icompat -Icompat/fnmatch -Icompat/win32
1071        COMPAT_CFLAGS += -DSTRIP_EXTENSION=\".exe\"
1072        COMPAT_OBJS += compat/mingw.o compat/fnmatch/fnmatch.o compat/winansi.o \
1073                compat/win32/pthread.o
1074        EXTLIBS += -lws2_32
1075        PTHREAD_LIBS =
1076        X = .exe
1077ifneq (,$(wildcard ../THIS_IS_MSYSGIT))
1078        htmldir=doc/git/html/
1079        prefix =
1080        INSTALL = /bin/install
1081        EXTLIBS += /mingw/lib/libz.a
1082        NO_R_TO_GCC_LINKER = YesPlease
1083        INTERNAL_QSORT = YesPlease
1084else
1085        NO_CURL = YesPlease
1086endif
1087endif
1088
1089-include config.mak.autogen
1090-include config.mak
1091
1092ifdef CHECK_HEADER_DEPENDENCIES
1093USE_COMPUTED_HEADER_DEPENDENCIES =
1094endif
1095
1096ifdef COMPUTE_HEADER_DEPENDENCIES
1097USE_COMPUTED_HEADER_DEPENDENCIES = YesPlease
1098endif
1099
1100ifdef SANE_TOOL_PATH
1101SANE_TOOL_PATH_SQ = $(subst ','\'',$(SANE_TOOL_PATH))
1102BROKEN_PATH_FIX = 's|^\# @@BROKEN_PATH_FIX@@$$|git_broken_path_fix $(SANE_TOOL_PATH_SQ)|'
1103PATH := $(SANE_TOOL_PATH):${PATH}
1104else
1105BROKEN_PATH_FIX = '/^\# @@BROKEN_PATH_FIX@@$$/d'
1106endif
1107
1108ifeq ($(uname_S),Darwin)
1109        ifndef NO_FINK
1110                ifeq ($(shell test -d /sw/lib && echo y),y)
1111                        BASIC_CFLAGS += -I/sw/include
1112                        BASIC_LDFLAGS += -L/sw/lib
1113                endif
1114        endif
1115        ifndef NO_DARWIN_PORTS
1116                ifeq ($(shell test -d /opt/local/lib && echo y),y)
1117                        BASIC_CFLAGS += -I/opt/local/include
1118                        BASIC_LDFLAGS += -L/opt/local/lib
1119                endif
1120        endif
1121        PTHREAD_LIBS =
1122endif
1123
1124ifndef CC_LD_DYNPATH
1125        ifdef NO_R_TO_GCC_LINKER
1126                # Some gcc does not accept and pass -R to the linker to specify
1127                # the runtime dynamic library path.
1128                CC_LD_DYNPATH = -Wl,-rpath,
1129        else
1130                CC_LD_DYNPATH = -R
1131        endif
1132endif
1133
1134ifdef NO_LIBGEN_H
1135        COMPAT_CFLAGS += -DNO_LIBGEN_H
1136        COMPAT_OBJS += compat/basename.o
1137endif
1138
1139ifdef NO_CURL
1140        BASIC_CFLAGS += -DNO_CURL
1141        REMOTE_CURL_PRIMARY =
1142        REMOTE_CURL_ALIASES =
1143        REMOTE_CURL_NAMES =
1144else
1145        ifdef CURLDIR
1146                # Try "-Wl,-rpath=$(CURLDIR)/$(lib)" in such a case.
1147                BASIC_CFLAGS += -I$(CURLDIR)/include
1148                CURL_LIBCURL = -L$(CURLDIR)/$(lib) $(CC_LD_DYNPATH)$(CURLDIR)/$(lib) -lcurl
1149        else
1150                CURL_LIBCURL = -lcurl
1151        endif
1152        REMOTE_CURL_PRIMARY = git-remote-http$X
1153        REMOTE_CURL_ALIASES = git-remote-https$X git-remote-ftp$X git-remote-ftps$X
1154        REMOTE_CURL_NAMES = $(REMOTE_CURL_PRIMARY) $(REMOTE_CURL_ALIASES)
1155        PROGRAM_OBJS += http-fetch.o
1156        PROGRAMS += $(REMOTE_CURL_NAMES)
1157        curl_check := $(shell (echo 070908; curl-config --vernum) | sort -r | sed -ne 2p)
1158        ifeq "$(curl_check)" "070908"
1159                ifndef NO_EXPAT
1160                        PROGRAM_OBJS += http-push.o
1161                endif
1162        endif
1163        ifndef NO_EXPAT
1164                ifdef EXPATDIR
1165                        BASIC_CFLAGS += -I$(EXPATDIR)/include
1166                        EXPAT_LIBEXPAT = -L$(EXPATDIR)/$(lib) $(CC_LD_DYNPATH)$(EXPATDIR)/$(lib) -lexpat
1167                else
1168                        EXPAT_LIBEXPAT = -lexpat
1169                endif
1170        endif
1171endif
1172
1173ifdef ZLIB_PATH
1174        BASIC_CFLAGS += -I$(ZLIB_PATH)/include
1175        EXTLIBS += -L$(ZLIB_PATH)/$(lib) $(CC_LD_DYNPATH)$(ZLIB_PATH)/$(lib)
1176endif
1177EXTLIBS += -lz
1178
1179ifndef NO_POSIX_ONLY_PROGRAMS
1180        PROGRAM_OBJS += daemon.o
1181endif
1182ifndef NO_OPENSSL
1183        OPENSSL_LIBSSL = -lssl
1184        ifdef OPENSSLDIR
1185                BASIC_CFLAGS += -I$(OPENSSLDIR)/include
1186                OPENSSL_LINK = -L$(OPENSSLDIR)/$(lib) $(CC_LD_DYNPATH)$(OPENSSLDIR)/$(lib)
1187        else
1188                OPENSSL_LINK =
1189        endif
1190        ifdef NEEDS_CRYPTO_WITH_SSL
1191                OPENSSL_LINK += -lcrypto
1192        endif
1193else
1194        BASIC_CFLAGS += -DNO_OPENSSL
1195        BLK_SHA1 = 1
1196        OPENSSL_LIBSSL =
1197endif
1198ifdef NEEDS_SSL_WITH_CRYPTO
1199        LIB_4_CRYPTO = $(OPENSSL_LINK) -lcrypto -lssl
1200else
1201        LIB_4_CRYPTO = $(OPENSSL_LINK) -lcrypto
1202endif
1203ifdef NEEDS_LIBICONV
1204        ifdef ICONVDIR
1205                BASIC_CFLAGS += -I$(ICONVDIR)/include
1206                ICONV_LINK = -L$(ICONVDIR)/$(lib) $(CC_LD_DYNPATH)$(ICONVDIR)/$(lib)
1207        else
1208                ICONV_LINK =
1209        endif
1210        EXTLIBS += $(ICONV_LINK) -liconv
1211endif
1212ifdef NEEDS_LIBGEN
1213        EXTLIBS += -lgen
1214endif
1215ifdef NEEDS_SOCKET
1216        EXTLIBS += -lsocket
1217endif
1218ifdef NEEDS_NSL
1219        EXTLIBS += -lnsl
1220endif
1221ifdef NEEDS_RESOLV
1222        EXTLIBS += -lresolv
1223endif
1224ifdef NO_D_TYPE_IN_DIRENT
1225        BASIC_CFLAGS += -DNO_D_TYPE_IN_DIRENT
1226endif
1227ifdef NO_D_INO_IN_DIRENT
1228        BASIC_CFLAGS += -DNO_D_INO_IN_DIRENT
1229endif
1230ifdef NO_ST_BLOCKS_IN_STRUCT_STAT
1231        BASIC_CFLAGS += -DNO_ST_BLOCKS_IN_STRUCT_STAT
1232endif
1233ifdef USE_NSEC
1234        BASIC_CFLAGS += -DUSE_NSEC
1235endif
1236ifdef USE_ST_TIMESPEC
1237        BASIC_CFLAGS += -DUSE_ST_TIMESPEC
1238endif
1239ifdef NO_NSEC
1240        BASIC_CFLAGS += -DNO_NSEC
1241endif
1242ifdef NO_C99_FORMAT
1243        BASIC_CFLAGS += -DNO_C99_FORMAT
1244endif
1245ifdef SNPRINTF_RETURNS_BOGUS
1246        COMPAT_CFLAGS += -DSNPRINTF_RETURNS_BOGUS
1247        COMPAT_OBJS += compat/snprintf.o
1248endif
1249ifdef FREAD_READS_DIRECTORIES
1250        COMPAT_CFLAGS += -DFREAD_READS_DIRECTORIES
1251        COMPAT_OBJS += compat/fopen.o
1252endif
1253ifdef NO_SYMLINK_HEAD
1254        BASIC_CFLAGS += -DNO_SYMLINK_HEAD
1255endif
1256ifdef NO_STRCASESTR
1257        COMPAT_CFLAGS += -DNO_STRCASESTR
1258        COMPAT_OBJS += compat/strcasestr.o
1259endif
1260ifdef NO_STRLCPY
1261        COMPAT_CFLAGS += -DNO_STRLCPY
1262        COMPAT_OBJS += compat/strlcpy.o
1263endif
1264ifdef NO_STRTOUMAX
1265        COMPAT_CFLAGS += -DNO_STRTOUMAX
1266        COMPAT_OBJS += compat/strtoumax.o
1267endif
1268ifdef NO_STRTOULL
1269        COMPAT_CFLAGS += -DNO_STRTOULL
1270endif
1271ifdef NO_SETENV
1272        COMPAT_CFLAGS += -DNO_SETENV
1273        COMPAT_OBJS += compat/setenv.o
1274endif
1275ifdef NO_MKDTEMP
1276        COMPAT_CFLAGS += -DNO_MKDTEMP
1277        COMPAT_OBJS += compat/mkdtemp.o
1278endif
1279ifdef NO_MKSTEMPS
1280        COMPAT_CFLAGS += -DNO_MKSTEMPS
1281        COMPAT_OBJS += compat/mkstemps.o
1282endif
1283ifdef NO_UNSETENV
1284        COMPAT_CFLAGS += -DNO_UNSETENV
1285        COMPAT_OBJS += compat/unsetenv.o
1286endif
1287ifdef NO_SYS_SELECT_H
1288        BASIC_CFLAGS += -DNO_SYS_SELECT_H
1289endif
1290ifdef NO_MMAP
1291        COMPAT_CFLAGS += -DNO_MMAP
1292        COMPAT_OBJS += compat/mmap.o
1293else
1294        ifdef USE_WIN32_MMAP
1295                COMPAT_CFLAGS += -DUSE_WIN32_MMAP
1296                COMPAT_OBJS += compat/win32mmap.o
1297        endif
1298endif
1299ifdef OBJECT_CREATION_USES_RENAMES
1300        COMPAT_CFLAGS += -DOBJECT_CREATION_MODE=1
1301endif
1302ifdef NO_PREAD
1303        COMPAT_CFLAGS += -DNO_PREAD
1304        COMPAT_OBJS += compat/pread.o
1305endif
1306ifdef NO_FAST_WORKING_DIRECTORY
1307        BASIC_CFLAGS += -DNO_FAST_WORKING_DIRECTORY
1308endif
1309ifdef NO_TRUSTABLE_FILEMODE
1310        BASIC_CFLAGS += -DNO_TRUSTABLE_FILEMODE
1311endif
1312ifdef NO_IPV6
1313        BASIC_CFLAGS += -DNO_IPV6
1314endif
1315ifdef NO_UINTMAX_T
1316        BASIC_CFLAGS += -Duintmax_t=uint32_t
1317endif
1318ifdef NO_SOCKADDR_STORAGE
1319ifdef NO_IPV6
1320        BASIC_CFLAGS += -Dsockaddr_storage=sockaddr_in
1321else
1322        BASIC_CFLAGS += -Dsockaddr_storage=sockaddr_in6
1323endif
1324endif
1325ifdef NO_INET_NTOP
1326        LIB_OBJS += compat/inet_ntop.o
1327endif
1328ifdef NO_INET_PTON
1329        LIB_OBJS += compat/inet_pton.o
1330endif
1331
1332ifdef NO_ICONV
1333        BASIC_CFLAGS += -DNO_ICONV
1334endif
1335
1336ifdef OLD_ICONV
1337        BASIC_CFLAGS += -DOLD_ICONV
1338endif
1339
1340ifdef NO_DEFLATE_BOUND
1341        BASIC_CFLAGS += -DNO_DEFLATE_BOUND
1342endif
1343
1344ifdef BLK_SHA1
1345        SHA1_HEADER = "block-sha1/sha1.h"
1346        LIB_OBJS += block-sha1/sha1.o
1347        LIB_H += block-sha1/sha1.h
1348else
1349ifdef PPC_SHA1
1350        SHA1_HEADER = "ppc/sha1.h"
1351        LIB_OBJS += ppc/sha1.o ppc/sha1ppc.o
1352        LIB_H += ppc/sha1.h
1353else
1354        SHA1_HEADER = <openssl/sha.h>
1355        EXTLIBS += $(LIB_4_CRYPTO)
1356endif
1357endif
1358ifdef NO_PERL_MAKEMAKER
1359        export NO_PERL_MAKEMAKER
1360endif
1361ifdef NO_HSTRERROR
1362        COMPAT_CFLAGS += -DNO_HSTRERROR
1363        COMPAT_OBJS += compat/hstrerror.o
1364endif
1365ifdef NO_MEMMEM
1366        COMPAT_CFLAGS += -DNO_MEMMEM
1367        COMPAT_OBJS += compat/memmem.o
1368endif
1369ifdef INTERNAL_QSORT
1370        COMPAT_CFLAGS += -DINTERNAL_QSORT
1371        COMPAT_OBJS += compat/qsort.o
1372endif
1373ifdef RUNTIME_PREFIX
1374        COMPAT_CFLAGS += -DRUNTIME_PREFIX
1375endif
1376
1377ifdef NO_PTHREADS
1378        THREADED_DELTA_SEARCH =
1379        BASIC_CFLAGS += -DNO_PTHREADS
1380else
1381        EXTLIBS += $(PTHREAD_LIBS)
1382endif
1383
1384ifdef THREADED_DELTA_SEARCH
1385        BASIC_CFLAGS += -DTHREADED_DELTA_SEARCH
1386        LIB_OBJS += thread-utils.o
1387endif
1388ifdef DIR_HAS_BSD_GROUP_SEMANTICS
1389        COMPAT_CFLAGS += -DDIR_HAS_BSD_GROUP_SEMANTICS
1390endif
1391ifdef UNRELIABLE_FSTAT
1392        BASIC_CFLAGS += -DUNRELIABLE_FSTAT
1393endif
1394ifdef NO_REGEX
1395        COMPAT_CFLAGS += -Icompat/regex
1396        COMPAT_OBJS += compat/regex/regex.o
1397endif
1398
1399ifdef USE_NED_ALLOCATOR
1400       COMPAT_CFLAGS += -DUSE_NED_ALLOCATOR -DOVERRIDE_STRDUP -DNDEBUG -DREPLACE_SYSTEM_ALLOCATOR -Icompat/nedmalloc
1401       COMPAT_OBJS += compat/nedmalloc/nedmalloc.o
1402endif
1403
1404ifeq ($(TCLTK_PATH),)
1405NO_TCLTK=NoThanks
1406endif
1407
1408ifeq ($(PERL_PATH),)
1409NO_PERL=NoThanks
1410endif
1411
1412ifeq ($(PYTHON_PATH),)
1413NO_PYTHON=NoThanks
1414endif
1415
1416QUIET_SUBDIR0  = +$(MAKE) -C # space to separate -C and subdir
1417QUIET_SUBDIR1  =
1418
1419ifneq ($(findstring $(MAKEFLAGS),w),w)
1420PRINT_DIR = --no-print-directory
1421else # "make -w"
1422NO_SUBDIR = :
1423endif
1424
1425ifneq ($(findstring $(MAKEFLAGS),s),s)
1426ifndef V
1427        QUIET_CC       = @echo '   ' CC $@;
1428        QUIET_AR       = @echo '   ' AR $@;
1429        QUIET_LINK     = @echo '   ' LINK $@;
1430        QUIET_BUILT_IN = @echo '   ' BUILTIN $@;
1431        QUIET_GEN      = @echo '   ' GEN $@;
1432        QUIET_LNCP     = @echo '   ' LN/CP $@;
1433        QUIET_SUBDIR0  = +@subdir=
1434        QUIET_SUBDIR1  = ;$(NO_SUBDIR) echo '   ' SUBDIR $$subdir; \
1435                         $(MAKE) $(PRINT_DIR) -C $$subdir
1436        export V
1437        export QUIET_GEN
1438        export QUIET_BUILT_IN
1439endif
1440endif
1441
1442ifdef ASCIIDOC8
1443        export ASCIIDOC8
1444endif
1445
1446# Shell quote (do not use $(call) to accommodate ancient setups);
1447
1448SHA1_HEADER_SQ = $(subst ','\'',$(SHA1_HEADER))
1449ETC_GITCONFIG_SQ = $(subst ','\'',$(ETC_GITCONFIG))
1450
1451DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
1452bindir_SQ = $(subst ','\'',$(bindir))
1453bindir_relative_SQ = $(subst ','\'',$(bindir_relative))
1454mandir_SQ = $(subst ','\'',$(mandir))
1455infodir_SQ = $(subst ','\'',$(infodir))
1456gitexecdir_SQ = $(subst ','\'',$(gitexecdir))
1457template_dir_SQ = $(subst ','\'',$(template_dir))
1458htmldir_SQ = $(subst ','\'',$(htmldir))
1459prefix_SQ = $(subst ','\'',$(prefix))
1460
1461SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
1462PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
1463PYTHON_PATH_SQ = $(subst ','\'',$(PYTHON_PATH))
1464TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH))
1465
1466LIBS = $(GITLIBS) $(EXTLIBS)
1467
1468BASIC_CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER_SQ)' \
1469        $(COMPAT_CFLAGS)
1470LIB_OBJS += $(COMPAT_OBJS)
1471
1472# Quote for C
1473
1474ifdef DEFAULT_EDITOR
1475DEFAULT_EDITOR_CQ = "$(subst ",\",$(subst \,\\,$(DEFAULT_EDITOR)))"
1476DEFAULT_EDITOR_CQ_SQ = $(subst ','\'',$(DEFAULT_EDITOR_CQ))
1477
1478BASIC_CFLAGS += -DDEFAULT_EDITOR='$(DEFAULT_EDITOR_CQ_SQ)'
1479endif
1480
1481ifdef DEFAULT_PAGER
1482DEFAULT_PAGER_CQ = "$(subst ",\",$(subst \,\\,$(DEFAULT_PAGER)))"
1483DEFAULT_PAGER_CQ_SQ = $(subst ','\'',$(DEFAULT_PAGER_CQ))
1484
1485BASIC_CFLAGS += -DDEFAULT_PAGER='$(DEFAULT_PAGER_CQ_SQ)'
1486endif
1487
1488ALL_CFLAGS += $(BASIC_CFLAGS)
1489ALL_LDFLAGS += $(BASIC_LDFLAGS)
1490
1491export TAR INSTALL DESTDIR SHELL_PATH
1492
1493
1494### Build rules
1495
1496SHELL = $(SHELL_PATH)
1497
1498all:: shell_compatibility_test $(ALL_PROGRAMS) $(BUILT_INS) $(OTHER_PROGRAMS) GIT-BUILD-OPTIONS
1499ifneq (,$X)
1500        $(QUIET_BUILT_IN)$(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) git$X)), test -d '$p' -o '$p' -ef '$p$X' || $(RM) '$p';)
1501endif
1502
1503all::
1504ifndef NO_TCLTK
1505        $(QUIET_SUBDIR0)git-gui $(QUIET_SUBDIR1) gitexecdir='$(gitexec_instdir_SQ)' all
1506        $(QUIET_SUBDIR0)gitk-git $(QUIET_SUBDIR1) all
1507endif
1508ifndef NO_PERL
1509        $(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' all
1510endif
1511ifndef NO_PYTHON
1512        $(QUIET_SUBDIR0)git_remote_helpers $(QUIET_SUBDIR1) PYTHON_PATH='$(PYTHON_PATH_SQ)' prefix='$(prefix_SQ)' all
1513endif
1514        $(QUIET_SUBDIR0)templates $(QUIET_SUBDIR1)
1515
1516please_set_SHELL_PATH_to_a_more_modern_shell:
1517        @$$(:)
1518
1519shell_compatibility_test: please_set_SHELL_PATH_to_a_more_modern_shell
1520
1521strip: $(PROGRAMS) git$X
1522        $(STRIP) $(STRIP_OPTS) $(PROGRAMS) git$X
1523
1524git.o: common-cmds.h
1525git.s git.o: ALL_CFLAGS += -DGIT_VERSION='"$(GIT_VERSION)"' \
1526        '-DGIT_HTML_PATH="$(htmldir_SQ)"'
1527
1528git$X: git.o $(BUILTIN_OBJS) $(GITLIBS)
1529        $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ git.o \
1530                $(BUILTIN_OBJS) $(ALL_LDFLAGS) $(LIBS)
1531
1532builtin-help.o: common-cmds.h
1533builtin-help.s builtin-help.o: ALL_CFLAGS += \
1534        '-DGIT_HTML_PATH="$(htmldir_SQ)"' \
1535        '-DGIT_MAN_PATH="$(mandir_SQ)"' \
1536        '-DGIT_INFO_PATH="$(infodir_SQ)"'
1537
1538$(BUILT_INS): git$X
1539        $(QUIET_BUILT_IN)$(RM) $@ && \
1540        ln git$X $@ 2>/dev/null || \
1541        ln -s git$X $@ 2>/dev/null || \
1542        cp git$X $@
1543
1544common-cmds.h: ./generate-cmdlist.sh command-list.txt
1545
1546common-cmds.h: $(wildcard Documentation/git-*.txt)
1547        $(QUIET_GEN)./generate-cmdlist.sh > $@+ && mv $@+ $@
1548
1549$(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
1550        $(QUIET_GEN)$(RM) $@ $@+ && \
1551        sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
1552            -e 's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \
1553            -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
1554            -e 's/@@NO_CURL@@/$(NO_CURL)/g' \
1555            -e $(BROKEN_PATH_FIX) \
1556            $@.sh >$@+ && \
1557        chmod +x $@+ && \
1558        mv $@+ $@
1559
1560ifndef NO_PERL
1561$(patsubst %.perl,%,$(SCRIPT_PERL)): perl/perl.mak
1562
1563perl/perl.mak: GIT-CFLAGS perl/Makefile perl/Makefile.PL
1564        $(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' $(@F)
1565
1566$(patsubst %.perl,%,$(SCRIPT_PERL)): % : %.perl
1567        $(QUIET_GEN)$(RM) $@ $@+ && \
1568        INSTLIBDIR=`MAKEFLAGS= $(MAKE) -C perl -s --no-print-directory instlibdir` && \
1569        sed -e '1{' \
1570            -e '        s|#!.*perl|#!$(PERL_PATH_SQ)|' \
1571            -e '        h' \
1572            -e '        s=.*=use lib (split(/$(pathsep)/, $$ENV{GITPERLLIB} || "@@INSTLIBDIR@@"));=' \
1573            -e '        H' \
1574            -e '        x' \
1575            -e '}' \
1576            -e 's|@@INSTLIBDIR@@|'"$$INSTLIBDIR"'|g' \
1577            -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
1578            $@.perl >$@+ && \
1579        chmod +x $@+ && \
1580        mv $@+ $@
1581
1582ifdef JSMIN
1583OTHER_PROGRAMS += gitweb/gitweb.cgi   gitweb/gitweb.min.js
1584gitweb/gitweb.cgi: gitweb/gitweb.perl gitweb/gitweb.min.js
1585else
1586OTHER_PROGRAMS += gitweb/gitweb.cgi
1587gitweb/gitweb.cgi: gitweb/gitweb.perl
1588endif
1589        $(QUIET_GEN)$(RM) $@ $@+ && \
1590        sed -e '1s|#!.*perl|#!$(PERL_PATH_SQ)|' \
1591            -e 's|++GIT_VERSION++|$(GIT_VERSION)|g' \
1592            -e 's|++GIT_BINDIR++|$(bindir)|g' \
1593            -e 's|++GITWEB_CONFIG++|$(GITWEB_CONFIG)|g' \
1594            -e 's|++GITWEB_CONFIG_SYSTEM++|$(GITWEB_CONFIG_SYSTEM)|g' \
1595            -e 's|++GITWEB_HOME_LINK_STR++|$(GITWEB_HOME_LINK_STR)|g' \
1596            -e 's|++GITWEB_SITENAME++|$(GITWEB_SITENAME)|g' \
1597            -e 's|++GITWEB_PROJECTROOT++|$(GITWEB_PROJECTROOT)|g' \
1598            -e 's|"++GITWEB_PROJECT_MAXDEPTH++"|$(GITWEB_PROJECT_MAXDEPTH)|g' \
1599            -e 's|++GITWEB_EXPORT_OK++|$(GITWEB_EXPORT_OK)|g' \
1600            -e 's|++GITWEB_STRICT_EXPORT++|$(GITWEB_STRICT_EXPORT)|g' \
1601            -e 's|++GITWEB_BASE_URL++|$(GITWEB_BASE_URL)|g' \
1602            -e 's|++GITWEB_LIST++|$(GITWEB_LIST)|g' \
1603            -e 's|++GITWEB_HOMETEXT++|$(GITWEB_HOMETEXT)|g' \
1604            -e 's|++GITWEB_CSS++|$(GITWEB_CSS)|g' \
1605            -e 's|++GITWEB_LOGO++|$(GITWEB_LOGO)|g' \
1606            -e 's|++GITWEB_FAVICON++|$(GITWEB_FAVICON)|g' \
1607            -e 's|++GITWEB_JS++|$(GITWEB_JS)|g' \
1608            -e 's|++GITWEB_SITE_HEADER++|$(GITWEB_SITE_HEADER)|g' \
1609            -e 's|++GITWEB_SITE_FOOTER++|$(GITWEB_SITE_FOOTER)|g' \
1610            $< >$@+ && \
1611        chmod +x $@+ && \
1612        mv $@+ $@
1613
1614git-instaweb: git-instaweb.sh gitweb/gitweb.cgi gitweb/gitweb.css gitweb/gitweb.js
1615        $(QUIET_GEN)$(RM) $@ $@+ && \
1616        sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
1617            -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
1618            -e 's/@@NO_CURL@@/$(NO_CURL)/g' \
1619            -e '/@@GITWEB_CGI@@/r gitweb/gitweb.cgi' \
1620            -e '/@@GITWEB_CGI@@/d' \
1621            -e '/@@GITWEB_CSS@@/r gitweb/gitweb.css' \
1622            -e '/@@GITWEB_CSS@@/d' \
1623            -e '/@@GITWEB_JS@@/r gitweb/gitweb.js' \
1624            -e '/@@GITWEB_JS@@/d' \
1625            -e 's|@@PERL@@|$(PERL_PATH_SQ)|g' \
1626            $@.sh > $@+ && \
1627        chmod +x $@+ && \
1628        mv $@+ $@
1629else # NO_PERL
1630$(patsubst %.perl,%,$(SCRIPT_PERL)) git-instaweb: % : unimplemented.sh
1631        $(QUIET_GEN)$(RM) $@ $@+ && \
1632        sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
1633            -e 's|@@REASON@@|NO_PERL=$(NO_PERL)|g' \
1634            unimplemented.sh >$@+ && \
1635        chmod +x $@+ && \
1636        mv $@+ $@
1637endif # NO_PERL
1638
1639
1640ifdef JSMIN
1641gitweb/gitweb.min.js: gitweb/gitweb.js
1642        $(QUIET_GEN)$(JSMIN) <$< >$@
1643endif # JSMIN
1644
1645ifndef NO_PYTHON
1646$(patsubst %.py,%,$(SCRIPT_PYTHON)): GIT-CFLAGS
1647$(patsubst %.py,%,$(SCRIPT_PYTHON)): % : %.py
1648        $(QUIET_GEN)$(RM) $@ $@+ && \
1649        INSTLIBDIR=`MAKEFLAGS= $(MAKE) -C git_remote_helpers -s \
1650                --no-print-directory prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' \
1651                instlibdir` && \
1652        sed -e '1{' \
1653            -e '        s|#!.*python|#!$(PYTHON_PATH_SQ)|' \
1654            -e '}' \
1655            -e 's|^import sys.*|&; \\\
1656                   import os; \\\
1657                   sys.path[0] = os.environ.has_key("GITPYTHONLIB") and \\\
1658                                 os.environ["GITPYTHONLIB"] or \\\
1659                                 "@@INSTLIBDIR@@"|' \
1660            -e 's|@@INSTLIBDIR@@|'"$$INSTLIBDIR"'|g' \
1661            $@.py >$@+ && \
1662        chmod +x $@+ && \
1663        mv $@+ $@
1664else # NO_PYTHON
1665$(patsubst %.py,%,$(SCRIPT_PYTHON)): % : unimplemented.sh
1666        $(QUIET_GEN)$(RM) $@ $@+ && \
1667        sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
1668            -e 's|@@REASON@@|NO_PYTHON=$(NO_PYTHON)|g' \
1669            unimplemented.sh >$@+ && \
1670        chmod +x $@+ && \
1671        mv $@+ $@
1672endif # NO_PYTHON
1673
1674configure: configure.ac
1675        $(QUIET_GEN)$(RM) $@ $<+ && \
1676        sed -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
1677            $< > $<+ && \
1678        autoconf -o $@ $<+ && \
1679        $(RM) $<+
1680
1681# These can record GIT_VERSION
1682git.o git.spec \
1683        $(patsubst %.sh,%,$(SCRIPT_SH)) \
1684        $(patsubst %.perl,%,$(SCRIPT_PERL)) \
1685        : GIT-VERSION-FILE
1686
1687TEST_OBJS := $(patsubst test-%$X,test-%.o,$(TEST_PROGRAMS))
1688GIT_OBJS := $(LIB_OBJS) $(BUILTIN_OBJS) $(PROGRAM_OBJS) $(TEST_OBJS) \
1689        git.o http.o http-walker.o remote-curl.o
1690XDIFF_OBJS = xdiff/xdiffi.o xdiff/xprepare.o xdiff/xutils.o xdiff/xemit.o \
1691        xdiff/xmerge.o xdiff/xpatience.o
1692OBJECTS := $(GIT_OBJS) $(XDIFF_OBJS)
1693
1694dep_files := $(foreach f,$(OBJECTS),$(dir $f).depend/$(notdir $f).d)
1695dep_dirs := $(addsuffix .depend,$(sort $(dir $(OBJECTS))))
1696
1697ifdef COMPUTE_HEADER_DEPENDENCIES
1698$(dep_dirs):
1699        mkdir -p $@
1700
1701missing_dep_dirs := $(filter-out $(wildcard $(dep_dirs)),$(dep_dirs))
1702dep_file = $(dir $@).depend/$(notdir $@).d
1703dep_args = -MF $(dep_file) -MMD -MP
1704ifdef CHECK_HEADER_DEPENDENCIES
1705$(error cannot compute header dependencies outside a normal build. \
1706Please unset CHECK_HEADER_DEPENDENCIES and try again)
1707endif
1708endif
1709
1710ifndef COMPUTE_HEADER_DEPENDENCIES
1711ifndef CHECK_HEADER_DEPENDENCIES
1712dep_dirs =
1713missing_dep_dirs =
1714dep_args =
1715endif
1716endif
1717
1718ifdef CHECK_HEADER_DEPENDENCIES
1719ifndef PRINT_HEADER_DEPENDENCIES
1720missing_deps = $(filter-out $(notdir $^), \
1721        $(notdir $(shell $(MAKE) -s $@ \
1722                CHECK_HEADER_DEPENDENCIES=YesPlease \
1723                USE_COMPUTED_HEADER_DEPENDENCIES=YesPlease \
1724                PRINT_HEADER_DEPENDENCIES=YesPlease)))
1725endif
1726endif
1727
1728ASM_SRC := $(wildcard $(OBJECTS:o=S))
1729ASM_OBJ := $(ASM_SRC:S=o)
1730C_OBJ := $(filter-out $(ASM_OBJ),$(OBJECTS))
1731
1732.SUFFIXES:
1733
1734ifdef PRINT_HEADER_DEPENDENCIES
1735$(C_OBJ): %.o: %.c FORCE
1736        echo $^
1737$(ASM_OBJ): %.o: %.S FORCE
1738        echo $^
1739
1740ifndef CHECK_HEADER_DEPENDENCIES
1741$(error cannot print header dependencies during a normal build. \
1742Please set CHECK_HEADER_DEPENDENCIES and try again)
1743endif
1744endif
1745
1746ifndef PRINT_HEADER_DEPENDENCIES
1747ifdef CHECK_HEADER_DEPENDENCIES
1748$(C_OBJ): %.o: %.c $(dep_files) FORCE
1749        @set -e; echo CHECK $@; \
1750        missing_deps="$(missing_deps)"; \
1751        if test "$$missing_deps"; \
1752        then \
1753                echo missing dependencies: $$missing_deps; \
1754                false; \
1755        fi
1756$(ASM_OBJ): %.o: %.S $(dep_files) FORCE
1757        @set -e; echo CHECK $@; \
1758        missing_deps="$(missing_deps)"; \
1759        if test "$$missing_deps"; \
1760        then \
1761                echo missing dependencies: $$missing_deps; \
1762                false; \
1763        fi
1764endif
1765endif
1766
1767ifndef CHECK_HEADER_DEPENDENCIES
1768$(C_OBJ): %.o: %.c GIT-CFLAGS $(missing_dep_dirs)
1769        $(QUIET_CC)$(CC) -o $*.o -c $(dep_args) $(ALL_CFLAGS) $<
1770$(ASM_OBJ): %.o: %.S GIT-CFLAGS $(missing_dep_dirs)
1771        $(QUIET_CC)$(CC) -o $*.o -c $(dep_args) $(ALL_CFLAGS) $<
1772endif
1773
1774%.s: %.c GIT-CFLAGS FORCE
1775        $(QUIET_CC)$(CC) -S $(ALL_CFLAGS) $<
1776
1777ifdef USE_COMPUTED_HEADER_DEPENDENCIES
1778# Take advantage of gcc's on-the-fly dependency generation
1779# See <http://gcc.gnu.org/gcc-3.0/features.html>.
1780dep_files_present := $(wildcard $(dep_files))
1781ifneq ($(dep_files_present),)
1782include $(dep_files_present)
1783endif
1784else
1785# Dependencies on header files, for platforms that do not support
1786# the gcc -MMD option.
1787#
1788# Dependencies on automatically generated headers such as common-cmds.h
1789# should _not_ be included here, since they are necessary even when
1790# building an object for the first time.
1791#
1792# XXX. Please check occasionally that these include all dependencies
1793# gcc detects!
1794
1795$(GIT_OBJS): $(LIB_H)
1796builtin-branch.o builtin-checkout.o builtin-clone.o builtin-reset.o branch.o transport.o: branch.h
1797builtin-bundle.o bundle.o transport.o: bundle.h
1798builtin-bisect--helper.o builtin-rev-list.o bisect.o: bisect.h
1799builtin-clone.o builtin-fetch-pack.o transport.o: fetch-pack.h
1800builtin-send-pack.o transport.o: send-pack.h
1801builtin-log.o builtin-shortlog.o: shortlog.h
1802builtin-prune.o builtin-reflog.o reachable.o: reachable.h
1803builtin-commit.o builtin-revert.o wt-status.o: wt-status.h
1804builtin-tar-tree.o archive-tar.o: tar.h
1805builtin-pack-objects.o: thread-utils.h
1806http-fetch.o http-walker.o remote-curl.o transport.o walker.o: walker.h
1807http.o http-walker.o http-push.o remote-curl.o: http.h
1808
1809xdiff-interface.o $(XDIFF_OBJS): \
1810        xdiff/xinclude.h xdiff/xmacros.h xdiff/xdiff.h xdiff/xtypes.h \
1811        xdiff/xutils.h xdiff/xprepare.h xdiff/xdiffi.h xdiff/xemit.h
1812endif
1813
1814exec_cmd.s exec_cmd.o: ALL_CFLAGS += \
1815        '-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' \
1816        '-DBINDIR="$(bindir_relative_SQ)"' \
1817        '-DPREFIX="$(prefix_SQ)"'
1818
1819builtin-init-db.s builtin-init-db.o: ALL_CFLAGS += \
1820        -DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir_SQ)"'
1821
1822config.s config.o: ALL_CFLAGS += -DETC_GITCONFIG='"$(ETC_GITCONFIG_SQ)"'
1823
1824http.s http.o: ALL_CFLAGS += -DGIT_USER_AGENT='"git/$(GIT_VERSION)"'
1825
1826ifdef NO_EXPAT
1827http-walker.s http-walker.o: ALL_CFLAGS += -DNO_EXPAT
1828endif
1829
1830git-%$X: %.o $(GITLIBS)
1831        $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
1832
1833git-imap-send$X: imap-send.o $(GITLIBS)
1834        $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
1835                $(LIBS) $(OPENSSL_LINK) $(OPENSSL_LIBSSL)
1836
1837git-http-fetch$X: revision.o http.o http-walker.o http-fetch.o $(GITLIBS)
1838        $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
1839                $(LIBS) $(CURL_LIBCURL)
1840git-http-push$X: revision.o http.o http-push.o $(GITLIBS)
1841        $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
1842                $(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
1843
1844$(REMOTE_CURL_ALIASES): $(REMOTE_CURL_PRIMARY)
1845        $(QUIET_LNCP)$(RM) $@ && \
1846        ln $< $@ 2>/dev/null || \
1847        ln -s $< $@ 2>/dev/null || \
1848        cp $< $@
1849
1850$(REMOTE_CURL_PRIMARY): remote-curl.o http.o http-walker.o $(GITLIBS)
1851        $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
1852                $(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
1853
1854$(LIB_FILE): $(LIB_OBJS)
1855        $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIB_OBJS)
1856
1857$(XDIFF_LIB): $(XDIFF_OBJS)
1858        $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(XDIFF_OBJS)
1859
1860
1861doc:
1862        $(MAKE) -C Documentation all
1863
1864man:
1865        $(MAKE) -C Documentation man
1866
1867html:
1868        $(MAKE) -C Documentation html
1869
1870info:
1871        $(MAKE) -C Documentation info
1872
1873pdf:
1874        $(MAKE) -C Documentation pdf
1875
1876TAGS:
1877        $(RM) TAGS
1878        $(FIND) . -name '*.[hcS]' -print | xargs etags -a
1879
1880tags:
1881        $(RM) tags
1882        $(FIND) . -name '*.[hcS]' -print | xargs ctags -a
1883
1884cscope:
1885        $(RM) cscope*
1886        $(FIND) . -name '*.[hcS]' -print | xargs cscope -b
1887
1888### Detect prefix changes
1889TRACK_CFLAGS = $(subst ','\'',$(ALL_CFLAGS)):\
1890             $(bindir_SQ):$(gitexecdir_SQ):$(template_dir_SQ):$(prefix_SQ)
1891
1892GIT-CFLAGS: FORCE
1893        @FLAGS='$(TRACK_CFLAGS)'; \
1894            if test x"$$FLAGS" != x"`cat GIT-CFLAGS 2>/dev/null`" ; then \
1895                echo 1>&2 "    * new build flags or prefix"; \
1896                echo "$$FLAGS" >GIT-CFLAGS; \
1897            fi
1898
1899# We need to apply sq twice, once to protect from the shell
1900# that runs GIT-BUILD-OPTIONS, and then again to protect it
1901# and the first level quoting from the shell that runs "echo".
1902GIT-BUILD-OPTIONS: FORCE
1903        @echo SHELL_PATH=\''$(subst ','\'',$(SHELL_PATH_SQ))'\' >$@
1904        @echo PERL_PATH=\''$(subst ','\'',$(PERL_PATH_SQ))'\' >>$@
1905        @echo TAR=\''$(subst ','\'',$(subst ','\'',$(TAR)))'\' >>$@
1906        @echo NO_CURL=\''$(subst ','\'',$(subst ','\'',$(NO_CURL)))'\' >>$@
1907        @echo NO_PERL=\''$(subst ','\'',$(subst ','\'',$(NO_PERL)))'\' >>$@
1908        @echo NO_PYTHON=\''$(subst ','\'',$(subst ','\'',$(NO_PYTHON)))'\' >>$@
1909
1910### Detect Tck/Tk interpreter path changes
1911ifndef NO_TCLTK
1912TRACK_VARS = $(subst ','\'',-DTCLTK_PATH='$(TCLTK_PATH_SQ)')
1913
1914GIT-GUI-VARS: FORCE
1915        @VARS='$(TRACK_VARS)'; \
1916            if test x"$$VARS" != x"`cat $@ 2>/dev/null`" ; then \
1917                echo 1>&2 "    * new Tcl/Tk interpreter location"; \
1918                echo "$$VARS" >$@; \
1919            fi
1920endif
1921
1922test_bindir_programs := $(patsubst %,bin-wrappers/%,$(BINDIR_PROGRAMS_NEED_X) $(BINDIR_PROGRAMS_NO_X) $(TEST_PROGRAMS_NEED_X))
1923
1924all:: $(TEST_PROGRAMS) $(test_bindir_programs)
1925
1926bin-wrappers/%: wrap-for-bin.sh
1927        @mkdir -p bin-wrappers
1928        $(QUIET_GEN)sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
1929             -e 's|@@BUILD_DIR@@|$(shell pwd)|' \
1930             -e 's|@@PROG@@|$(@F)|' < $< > $@ && \
1931        chmod +x $@
1932
1933# GNU make supports exporting all variables by "export" without parameters.
1934# However, the environment gets quite big, and some programs have problems
1935# with that.
1936
1937export NO_SVN_TESTS
1938
1939### Testing rules
1940
1941test: all
1942        $(MAKE) -C t/ all
1943
1944test-ctype$X: ctype.o
1945
1946test-date$X: date.o ctype.o
1947
1948test-delta$X: diff-delta.o patch-delta.o
1949
1950test-parse-options$X: parse-options.o
1951
1952.PRECIOUS: $(TEST_OBJS)
1953
1954test-%$X: test-%.o $(GITLIBS)
1955        $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
1956
1957check-sha1:: test-sha1$X
1958        ./test-sha1.sh
1959
1960check: common-cmds.h
1961        if sparse; \
1962        then \
1963                for i in *.c; \
1964                do \
1965                        sparse $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i || exit; \
1966                done; \
1967        else \
1968                echo 2>&1 "Did you mean 'make test'?"; \
1969                exit 1; \
1970        fi
1971
1972remove-dashes:
1973        ./fixup-builtins $(BUILT_INS) $(PROGRAMS) $(SCRIPTS)
1974
1975### Installation rules
1976
1977ifneq ($(filter /%,$(firstword $(template_dir))),)
1978template_instdir = $(template_dir)
1979else
1980template_instdir = $(prefix)/$(template_dir)
1981endif
1982export template_instdir
1983
1984ifneq ($(filter /%,$(firstword $(gitexecdir))),)
1985gitexec_instdir = $(gitexecdir)
1986else
1987gitexec_instdir = $(prefix)/$(gitexecdir)
1988endif
1989gitexec_instdir_SQ = $(subst ','\'',$(gitexec_instdir))
1990export gitexec_instdir
1991
1992install_bindir_programs := $(patsubst %,%$X,$(BINDIR_PROGRAMS_NEED_X)) $(BINDIR_PROGRAMS_NO_X)
1993
1994install: all
1995        $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'
1996        $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
1997        $(INSTALL) $(ALL_PROGRAMS) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
1998        $(INSTALL) $(install_bindir_programs) '$(DESTDIR_SQ)$(bindir_SQ)'
1999        $(MAKE) -C templates DESTDIR='$(DESTDIR_SQ)' install
2000ifndef NO_PERL
2001        $(MAKE) -C perl prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' install
2002endif
2003ifndef NO_PYTHON
2004        $(MAKE) -C git_remote_helpers prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' install
2005endif
2006ifndef NO_TCLTK
2007        $(MAKE) -C gitk-git install
2008        $(MAKE) -C git-gui gitexecdir='$(gitexec_instdir_SQ)' install
2009endif
2010ifneq (,$X)
2011        $(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) git$X)), test '$(DESTDIR_SQ)$(gitexec_instdir_SQ)/$p' -ef '$(DESTDIR_SQ)$(gitexec_instdir_SQ)/$p$X' || $(RM) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)/$p';)
2012endif
2013
2014        bindir=$$(cd '$(DESTDIR_SQ)$(bindir_SQ)' && pwd) && \
2015        execdir=$$(cd '$(DESTDIR_SQ)$(gitexec_instdir_SQ)' && pwd) && \
2016        { test "$$bindir/" = "$$execdir/" || \
2017                { $(RM) "$$execdir/git$X" && \
2018                test -z "$(NO_CROSS_DIRECTORY_HARDLINKS)" && \
2019                ln "$$bindir/git$X" "$$execdir/git$X" 2>/dev/null || \
2020                cp "$$bindir/git$X" "$$execdir/git$X"; } ; } && \
2021        { for p in $(BUILT_INS); do \
2022                $(RM) "$$execdir/$$p" && \
2023                ln "$$execdir/git$X" "$$execdir/$$p" 2>/dev/null || \
2024                ln -s "git$X" "$$execdir/$$p" 2>/dev/null || \
2025                cp "$$execdir/git$X" "$$execdir/$$p" || exit; \
2026          done; } && \
2027        { for p in $(REMOTE_CURL_ALIASES); do \
2028                $(RM) "$$execdir/$$p" && \
2029                ln "$$execdir/git-remote-http$X" "$$execdir/$$p" 2>/dev/null || \
2030                ln -s "git-remote-http$X" "$$execdir/$$p" 2>/dev/null || \
2031                cp "$$execdir/git-remote-http$X" "$$execdir/$$p" || exit; \
2032          done; } && \
2033        ./check_bindir "z$$bindir" "z$$execdir" "$$bindir/git-add$X"
2034
2035install-doc:
2036        $(MAKE) -C Documentation install
2037
2038install-man:
2039        $(MAKE) -C Documentation install-man
2040
2041install-html:
2042        $(MAKE) -C Documentation install-html
2043
2044install-info:
2045        $(MAKE) -C Documentation install-info
2046
2047install-pdf:
2048        $(MAKE) -C Documentation install-pdf
2049
2050quick-install-doc:
2051        $(MAKE) -C Documentation quick-install
2052
2053quick-install-man:
2054        $(MAKE) -C Documentation quick-install-man
2055
2056quick-install-html:
2057        $(MAKE) -C Documentation quick-install-html
2058
2059
2060
2061### Maintainer's dist rules
2062
2063git.spec: git.spec.in
2064        sed -e 's/@@VERSION@@/$(GIT_VERSION)/g' < $< > $@+
2065        mv $@+ $@
2066
2067GIT_TARNAME=git-$(GIT_VERSION)
2068dist: git.spec git-archive$(X) configure
2069        ./git-archive --format=tar \
2070                --prefix=$(GIT_TARNAME)/ HEAD^{tree} > $(GIT_TARNAME).tar
2071        @mkdir -p $(GIT_TARNAME)
2072        @cp git.spec configure $(GIT_TARNAME)
2073        @echo $(GIT_VERSION) > $(GIT_TARNAME)/version
2074        @$(MAKE) -C git-gui TARDIR=../$(GIT_TARNAME)/git-gui dist-version
2075        $(TAR) rf $(GIT_TARNAME).tar \
2076                $(GIT_TARNAME)/git.spec \
2077                $(GIT_TARNAME)/configure \
2078                $(GIT_TARNAME)/version \
2079                $(GIT_TARNAME)/git-gui/version
2080        @$(RM) -r $(GIT_TARNAME)
2081        gzip -f -9 $(GIT_TARNAME).tar
2082
2083rpm: dist
2084        $(RPMBUILD) \
2085                --define "_source_filedigest_algorithm md5" \
2086                --define "_binary_filedigest_algorithm md5" \
2087                -ta $(GIT_TARNAME).tar.gz
2088
2089htmldocs = git-htmldocs-$(GIT_VERSION)
2090manpages = git-manpages-$(GIT_VERSION)
2091dist-doc:
2092        $(RM) -r .doc-tmp-dir
2093        mkdir .doc-tmp-dir
2094        $(MAKE) -C Documentation WEBDOC_DEST=../.doc-tmp-dir install-webdoc
2095        cd .doc-tmp-dir && $(TAR) cf ../$(htmldocs).tar .
2096        gzip -n -9 -f $(htmldocs).tar
2097        :
2098        $(RM) -r .doc-tmp-dir
2099        mkdir -p .doc-tmp-dir/man1 .doc-tmp-dir/man5 .doc-tmp-dir/man7
2100        $(MAKE) -C Documentation DESTDIR=./ \
2101                man1dir=../.doc-tmp-dir/man1 \
2102                man5dir=../.doc-tmp-dir/man5 \
2103                man7dir=../.doc-tmp-dir/man7 \
2104                install
2105        cd .doc-tmp-dir && $(TAR) cf ../$(manpages).tar .
2106        gzip -n -9 -f $(manpages).tar
2107        $(RM) -r .doc-tmp-dir
2108
2109### Cleaning rules
2110
2111distclean: clean
2112        $(RM) configure
2113
2114clean:
2115        $(RM) *.o block-sha1/*.o ppc/*.o compat/*.o compat/*/*.o xdiff/*.o \
2116                $(LIB_FILE) $(XDIFF_LIB)
2117        $(RM) $(ALL_PROGRAMS) $(BUILT_INS) git$X
2118        $(RM) $(TEST_PROGRAMS)
2119        $(RM) -r bin-wrappers
2120        $(RM) -r $(dep_dirs)
2121        $(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo common-cmds.h TAGS tags cscope*
2122        $(RM) -r autom4te.cache
2123        $(RM) config.log config.mak.autogen config.mak.append config.status config.cache
2124        $(RM) -r $(GIT_TARNAME) .doc-tmp-dir
2125        $(RM) $(GIT_TARNAME).tar.gz git-core_$(GIT_VERSION)-*.tar.gz
2126        $(RM) $(htmldocs).tar.gz $(manpages).tar.gz
2127        $(MAKE) -C Documentation/ clean
2128ifndef NO_PERL
2129        $(RM) gitweb/gitweb.cgi
2130        $(MAKE) -C perl clean
2131endif
2132ifndef NO_PYTHON
2133        $(MAKE) -C git_remote_helpers clean
2134endif
2135        $(MAKE) -C templates/ clean
2136        $(MAKE) -C t/ clean
2137ifndef NO_TCLTK
2138        $(MAKE) -C gitk-git clean
2139        $(MAKE) -C git-gui clean
2140endif
2141        $(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-GUI-VARS GIT-BUILD-OPTIONS
2142
2143.PHONY: all install clean strip
2144.PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell
2145.PHONY: FORCE TAGS tags cscope
2146
2147### Check documentation
2148#
2149check-docs::
2150        @(for v in $(ALL_PROGRAMS) $(BUILT_INS) git gitk; \
2151        do \
2152                case "$$v" in \
2153                git-merge-octopus | git-merge-ours | git-merge-recursive | \
2154                git-merge-resolve | git-merge-subtree | \
2155                git-fsck-objects | git-init-db | \
2156                git-?*--?* ) continue ;; \
2157                esac ; \
2158                test -f "Documentation/$$v.txt" || \
2159                echo "no doc: $$v"; \
2160                sed -e '/^#/d' command-list.txt | \
2161                grep -q "^$$v[  ]" || \
2162                case "$$v" in \
2163                git) ;; \
2164                *) echo "no link: $$v";; \
2165                esac ; \
2166        done; \
2167        ( \
2168                sed -e '/^#/d' \
2169                    -e 's/[     ].*//' \
2170                    -e 's/^/listed /' command-list.txt; \
2171                ls -1 Documentation/git*txt | \
2172                sed -e 's|Documentation/|documented |' \
2173                    -e 's/\.txt//'; \
2174        ) | while read how cmd; \
2175        do \
2176                case "$$how,$$cmd" in \
2177                *,git-citool | \
2178                *,git-gui | \
2179                *,git-help | \
2180                documented,gitattributes | \
2181                documented,gitignore | \
2182                documented,gitmodules | \
2183                documented,gitcli | \
2184                documented,git-tools | \
2185                documented,gitcore-tutorial | \
2186                documented,gitcvs-migration | \
2187                documented,gitdiffcore | \
2188                documented,gitglossary | \
2189                documented,githooks | \
2190                documented,gitrepository-layout | \
2191                documented,gittutorial | \
2192                documented,gittutorial-2 | \
2193                sentinel,not,matching,is,ok ) continue ;; \
2194                esac; \
2195                case " $(ALL_PROGRAMS) $(BUILT_INS) git gitk " in \
2196                *" $$cmd "*)    ;; \
2197                *) echo "removed but $$how: $$cmd" ;; \
2198                esac; \
2199        done ) | sort
2200
2201### Make sure built-ins do not have dups and listed in git.c
2202#
2203check-builtins::
2204        ./check-builtins.sh
2205
2206### Test suite coverage testing
2207#
2208.PHONY: coverage coverage-clean coverage-build coverage-report
2209
2210coverage:
2211        $(MAKE) coverage-build
2212        $(MAKE) coverage-report
2213
2214coverage-clean:
2215        rm -f *.gcda *.gcno
2216
2217COVERAGE_CFLAGS = $(CFLAGS) -O0 -ftest-coverage -fprofile-arcs
2218COVERAGE_LDFLAGS = $(CFLAGS)  -O0 -lgcov
2219
2220coverage-build: coverage-clean
2221        $(MAKE) CFLAGS="$(COVERAGE_CFLAGS)" LDFLAGS="$(COVERAGE_LDFLAGS)" all
2222        $(MAKE) CFLAGS="$(COVERAGE_CFLAGS)" LDFLAGS="$(COVERAGE_LDFLAGS)" \
2223                -j1 test
2224
2225coverage-report:
2226        gcov -b *.c
2227        grep '^function.*called 0 ' *.c.gcov \
2228                | sed -e 's/\([^:]*\)\.gcov: *function \([^ ]*\) called.*/\1: \2/' \
2229                | tee coverage-untested-functions