Makefileon commit Merge branch 'db/make-with-curl' (e425521)
   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 SOCKLEN_T to a suitable type (such as 'size_t') if your
  12# system headers do not define a socklen_t type.
  13#
  14# Define INLINE to a suitable substitute (such as '__inline' or '') if git
  15# fails to compile with errors about undefined inline functions or similar.
  16#
  17# Define SNPRINTF_RETURNS_BOGUS if your are on a system which snprintf()
  18# or vsnprintf() return -1 instead of number of characters which would
  19# have been written to the final string if enough space had been available.
  20#
  21# Define FREAD_READS_DIRECTORIES if your are on a system which succeeds
  22# when attempting to read from an fopen'ed directory.
  23#
  24# Define NO_OPENSSL environment variable if you do not have OpenSSL.
  25# This also implies BLK_SHA1.
  26#
  27# Define USE_LIBPCRE if you have and want to use libpcre. git-grep will be
  28# able to use Perl-compatible regular expressions.
  29#
  30# Define LIBPCREDIR=/foo/bar if your libpcre header and library files are in
  31# /foo/bar/include and /foo/bar/lib directories.
  32#
  33# Define NO_CURL if you do not have libcurl installed.  git-http-fetch and
  34# git-http-push are not built, and you cannot use http:// and https://
  35# transports (neither smart nor dumb).
  36#
  37# Define CURL_CONFIG to the path to a curl-config binary other than the
  38# default 'curl-config'.
  39#
  40# Define CURL_STATIC to statically link libcurl.  Only applies if
  41# CURL_CONFIG is used.
  42#
  43# Define CURLDIR=/foo/bar if your curl header and library files are in
  44# /foo/bar/include and /foo/bar/lib directories.  This overrides CURL_CONFIG,
  45# but is less robust.
  46#
  47# Define NO_EXPAT if you do not have expat installed.  git-http-push is
  48# not built, and you cannot push using http:// and https:// transports (dumb).
  49#
  50# Define EXPATDIR=/foo/bar if your expat header and library files are in
  51# /foo/bar/include and /foo/bar/lib directories.
  52#
  53# Define EXPAT_NEEDS_XMLPARSE_H if you have an old version of expat (e.g.,
  54# 1.1 or 1.2) that provides xmlparse.h instead of expat.h.
  55#
  56# Define NO_GETTEXT if you don't want Git output to be translated.
  57# A translated Git requires GNU libintl or another gettext implementation,
  58# plus libintl-perl at runtime.
  59#
  60# Define USE_GETTEXT_SCHEME and set it to 'fallthrough', if you don't trust
  61# the installed gettext translation of the shell scripts output.
  62#
  63# Define HAVE_LIBCHARSET_H if you haven't set NO_GETTEXT and you can't
  64# trust the langinfo.h's nl_langinfo(CODESET) function to return the
  65# current character set. GNU and Solaris have a nl_langinfo(CODESET),
  66# FreeBSD can use either, but MinGW and some others need to use
  67# libcharset.h's locale_charset() instead.
  68#
  69# Define CHARSET_LIB to the library you need to link with in order to
  70# use locale_charset() function.  On some platforms this needs to set to
  71# -lcharset, on others to -liconv .
  72#
  73# Define LIBC_CONTAINS_LIBINTL if your gettext implementation doesn't
  74# need -lintl when linking.
  75#
  76# Define NO_MSGFMT_EXTENDED_OPTIONS if your implementation of msgfmt
  77# doesn't support GNU extensions like --check and --statistics
  78#
  79# Define HAVE_PATHS_H if you have paths.h and want to use the default PATH
  80# it specifies.
  81#
  82# Define NO_D_INO_IN_DIRENT if you don't have d_ino in your struct dirent.
  83#
  84# Define NO_D_TYPE_IN_DIRENT if your platform defines DT_UNKNOWN but lacks
  85# d_type in struct dirent (Cygwin 1.5, fixed in Cygwin 1.7).
  86#
  87# Define HAVE_STRINGS_H if you have strings.h and need it for strcasecmp.
  88#
  89# Define NO_STRCASESTR if you don't have strcasestr.
  90#
  91# Define NO_MEMMEM if you don't have memmem.
  92#
  93# Define NO_GETPAGESIZE if you don't have getpagesize.
  94#
  95# Define NO_STRLCPY if you don't have strlcpy.
  96#
  97# Define NO_STRTOUMAX if you don't have both strtoimax and strtoumax in the
  98# C library. If your compiler also does not support long long or does not have
  99# strtoull, define NO_STRTOULL.
 100#
 101# Define NO_SETENV if you don't have setenv in the C library.
 102#
 103# Define NO_UNSETENV if you don't have unsetenv in the C library.
 104#
 105# Define NO_MKDTEMP if you don't have mkdtemp in the C library.
 106#
 107# Define MKDIR_WO_TRAILING_SLASH if your mkdir() can't deal with trailing slash.
 108#
 109# Define NO_MKSTEMPS if you don't have mkstemps in the C library.
 110#
 111# Define NO_GECOS_IN_PWENT if you don't have pw_gecos in struct passwd
 112# in the C library.
 113#
 114# Define NO_LIBGEN_H if you don't have libgen.h.
 115#
 116# Define NEEDS_LIBGEN if your libgen needs -lgen when linking
 117#
 118# Define NO_SYS_SELECT_H if you don't have sys/select.h.
 119#
 120# Define NO_SYMLINK_HEAD if you never want .git/HEAD to be a symbolic link.
 121# Enable it on Windows.  By default, symrefs are still used.
 122#
 123# Define NO_SVN_TESTS if you want to skip time-consuming SVN interoperability
 124# tests.  These tests take up a significant amount of the total test time
 125# but are not needed unless you plan to talk to SVN repos.
 126#
 127# Define NO_FINK if you are building on Darwin/Mac OS X, have Fink
 128# installed in /sw, but don't want GIT to link against any libraries
 129# installed there.  If defined you may specify your own (or Fink's)
 130# include directories and library directories by defining CFLAGS
 131# and LDFLAGS appropriately.
 132#
 133# Define NO_DARWIN_PORTS if you are building on Darwin/Mac OS X,
 134# have DarwinPorts installed in /opt/local, but don't want GIT to
 135# link against any libraries installed there.  If defined you may
 136# specify your own (or DarwinPort's) include directories and
 137# library directories by defining CFLAGS and LDFLAGS appropriately.
 138#
 139# Define NO_APPLE_COMMON_CRYPTO if you are building on Darwin/Mac OS X
 140# and do not want to use Apple's CommonCrypto library.  This allows you
 141# to provide your own OpenSSL library, for example from MacPorts.
 142#
 143# Define BLK_SHA1 environment variable to make use of the bundled
 144# optimized C SHA1 routine.
 145#
 146# Define PPC_SHA1 environment variable when running make to make use of
 147# a bundled SHA1 routine optimized for PowerPC.
 148#
 149# Define NEEDS_CRYPTO_WITH_SSL if you need -lcrypto when using -lssl (Darwin).
 150#
 151# Define NEEDS_SSL_WITH_CRYPTO if you need -lssl when using -lcrypto (Darwin).
 152#
 153# Define NEEDS_SSL_WITH_CURL if you need -lssl with -lcurl (Minix).  Only used
 154# if CURLDIR is set.
 155#
 156# Define NEEDS_IDN_WITH_CURL if you need -lidn when using -lcurl (Minix).  Only
 157# used if CURLDIR is set.
 158#
 159# Define NEEDS_LIBICONV if linking with libc is not enough (Darwin).
 160#
 161# Define NEEDS_LIBINTL_BEFORE_LIBICONV if you need libintl before libiconv.
 162#
 163# Define NO_INTPTR_T if you don't have intptr_t or uintptr_t.
 164#
 165# Define NO_UINTMAX_T if you don't have uintmax_t.
 166#
 167# Define NEEDS_SOCKET if linking with libc is not enough (SunOS,
 168# Patrick Mauritz).
 169#
 170# Define NEEDS_RESOLV if linking with -lnsl and/or -lsocket is not enough.
 171# Notably on Solaris hstrerror resides in libresolv and on Solaris 7
 172# inet_ntop and inet_pton additionally reside there.
 173#
 174# Define NO_MMAP if you want to avoid mmap.
 175#
 176# Define NO_SYS_POLL_H if you don't have sys/poll.h.
 177#
 178# Define NO_POLL if you do not have or don't want to use poll().
 179# This also implies NO_SYS_POLL_H.
 180#
 181# Define NEEDS_SYS_PARAM_H if you need to include sys/param.h to compile,
 182# *PLEASE* REPORT to git@vger.kernel.org if your platform needs this;
 183# we want to know more about the issue.
 184#
 185# Define NO_PTHREADS if you do not have or do not want to use Pthreads.
 186#
 187# Define NO_PREAD if you have a problem with pread() system call (e.g.
 188# cygwin1.dll before v1.5.22).
 189#
 190# Define NO_SETITIMER if you don't have setitimer()
 191#
 192# Define NO_STRUCT_ITIMERVAL if you don't have struct itimerval
 193# This also implies NO_SETITIMER
 194#
 195# Define NO_THREAD_SAFE_PREAD if your pread() implementation is not
 196# thread-safe. (e.g. compat/pread.c or cygwin)
 197#
 198# Define NO_FAST_WORKING_DIRECTORY if accessing objects in pack files is
 199# generally faster on your platform than accessing the working directory.
 200#
 201# Define NO_TRUSTABLE_FILEMODE if your filesystem may claim to support
 202# the executable mode bit, but doesn't really do so.
 203#
 204# Define NO_IPV6 if you lack IPv6 support and getaddrinfo().
 205#
 206# Define NO_UNIX_SOCKETS if your system does not offer unix sockets.
 207#
 208# Define NO_SOCKADDR_STORAGE if your platform does not have struct
 209# sockaddr_storage.
 210#
 211# Define NO_ICONV if your libc does not properly support iconv.
 212#
 213# Define OLD_ICONV if your library has an old iconv(), where the second
 214# (input buffer pointer) parameter is declared with type (const char **).
 215#
 216# Define NO_DEFLATE_BOUND if your zlib does not have deflateBound.
 217#
 218# Define NO_R_TO_GCC_LINKER if your gcc does not like "-R/path/lib"
 219# that tells runtime paths to dynamic libraries;
 220# "-Wl,-rpath=/path/lib" is used instead.
 221#
 222# Define NO_NORETURN if using buggy versions of gcc 4.6+ and profile feedback,
 223# as the compiler can crash (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49299)
 224#
 225# Define USE_NSEC below if you want git to care about sub-second file mtimes
 226# and ctimes. Note that you need recent glibc (at least 2.2.4) for this, and
 227# it will BREAK YOUR LOCAL DIFFS! show-diff and anything using it will likely
 228# randomly break unless your underlying filesystem supports those sub-second
 229# times (my ext3 doesn't).
 230#
 231# Define USE_ST_TIMESPEC if your "struct stat" uses "st_ctimespec" instead of
 232# "st_ctim"
 233#
 234# Define NO_NSEC if your "struct stat" does not have "st_ctim.tv_nsec"
 235# available.  This automatically turns USE_NSEC off.
 236#
 237# Define USE_STDEV below if you want git to care about the underlying device
 238# change being considered an inode change from the update-index perspective.
 239#
 240# Define NO_ST_BLOCKS_IN_STRUCT_STAT if your platform does not have st_blocks
 241# field that counts the on-disk footprint in 512-byte blocks.
 242#
 243# Define DOCBOOK_XSL_172 if you want to format man pages with DocBook XSL v1.72
 244# (not v1.73 or v1.71).
 245#
 246# Define ASCIIDOC_ROFF if your DocBook XSL does not escape raw roff directives
 247# (versions 1.68.1 through v1.72).
 248#
 249# Define GNU_ROFF if your target system uses GNU groff.  This forces
 250# apostrophes to be ASCII so that cut&pasting examples to the shell
 251# will work.
 252#
 253# Define PERL_PATH to the path of your Perl binary (usually /usr/bin/perl).
 254#
 255# Define NO_PERL_MAKEMAKER if you cannot use Makefiles generated by perl's
 256# MakeMaker (e.g. using ActiveState under Cygwin).
 257#
 258# Define NO_PERL if you do not want Perl scripts or libraries at all.
 259#
 260# Define PYTHON_PATH to the path of your Python binary (often /usr/bin/python
 261# but /usr/bin/python2.7 on some platforms).
 262#
 263# Define NO_PYTHON if you do not want Python scripts or libraries at all.
 264#
 265# Define NO_TCLTK if you do not want Tcl/Tk GUI.
 266#
 267# The TCL_PATH variable governs the location of the Tcl interpreter
 268# used to optimize git-gui for your system.  Only used if NO_TCLTK
 269# is not set.  Defaults to the bare 'tclsh'.
 270#
 271# The TCLTK_PATH variable governs the location of the Tcl/Tk interpreter.
 272# If not set it defaults to the bare 'wish'. If it is set to the empty
 273# string then NO_TCLTK will be forced (this is used by configure script).
 274#
 275# Define INTERNAL_QSORT to use Git's implementation of qsort(), which
 276# is a simplified version of the merge sort used in glibc. This is
 277# recommended if Git triggers O(n^2) behavior in your platform's qsort().
 278#
 279# Define UNRELIABLE_FSTAT if your system's fstat does not return the same
 280# information on a not yet closed file that lstat would return for the same
 281# file after it was closed.
 282#
 283# Define OBJECT_CREATION_USES_RENAMES if your operating systems has problems
 284# when hardlinking a file to another name and unlinking the original file right
 285# away (some NTFS drivers seem to zero the contents in that scenario).
 286#
 287# Define NO_CROSS_DIRECTORY_HARDLINKS if you plan to distribute the installed
 288# programs as a tar, where bin/ and libexec/ might be on different file systems.
 289#
 290# Define NO_INSTALL_HARDLINKS if you prefer to use either symbolic links or
 291# copies to install built-in git commands e.g. git-cat-file.
 292#
 293# Define USE_NED_ALLOCATOR if you want to replace the platforms default
 294# memory allocators with the nedmalloc allocator written by Niall Douglas.
 295#
 296# Define NO_REGEX if you have no or inferior regex support in your C library.
 297#
 298# Define HAVE_DEV_TTY if your system can open /dev/tty to interact with the
 299# user.
 300#
 301# Define GETTEXT_POISON if you are debugging the choice of strings marked
 302# for translation.  In a GETTEXT_POISON build, you can turn all strings marked
 303# for translation into gibberish by setting the GIT_GETTEXT_POISON variable
 304# (to any value) in your environment.
 305#
 306# Define JSMIN to point to JavaScript minifier that functions as
 307# a filter to have gitweb.js minified.
 308#
 309# Define CSSMIN to point to a CSS minifier in order to generate a minified
 310# version of gitweb.css
 311#
 312# Define DEFAULT_PAGER to a sensible pager command (defaults to "less") if
 313# you want to use something different.  The value will be interpreted by the
 314# shell at runtime when it is used.
 315#
 316# Define DEFAULT_EDITOR to a sensible editor command (defaults to "vi") if you
 317# want to use something different.  The value will be interpreted by the shell
 318# if necessary when it is used.  Examples:
 319#
 320#   DEFAULT_EDITOR='~/bin/vi',
 321#   DEFAULT_EDITOR='$GIT_FALLBACK_EDITOR',
 322#   DEFAULT_EDITOR='"C:\Program Files\Vim\gvim.exe" --nofork'
 323#
 324# Define COMPUTE_HEADER_DEPENDENCIES to "yes" if you want dependencies on
 325# header files to be automatically computed, to avoid rebuilding objects when
 326# an unrelated header file changes.  Define it to "no" to use the hard-coded
 327# dependency rules.  The default is "auto", which means to use computed header
 328# dependencies if your compiler is detected to support it.
 329#
 330# Define CHECK_HEADER_DEPENDENCIES to check for problems in the hard-coded
 331# dependency rules.
 332#
 333# Define NATIVE_CRLF if your platform uses CRLF for line endings.
 334#
 335# Define XDL_FAST_HASH to use an alternative line-hashing method in
 336# the diff algorithm.  It gives a nice speedup if your processor has
 337# fast unaligned word loads.  Does NOT work on big-endian systems!
 338# Enabled by default on x86_64.
 339#
 340# Define GIT_USER_AGENT if you want to change how git identifies itself during
 341# network interactions.  The default is "git/$(GIT_VERSION)".
 342#
 343# Define DEFAULT_HELP_FORMAT to "man", "info" or "html"
 344# (defaults to "man") if you want to have a different default when
 345# "git help" is called without a parameter specifying the format.
 346#
 347# Define TEST_GIT_INDEX_VERSION to 2, 3 or 4 to run the test suite
 348# with a different indexfile format version.  If it isn't set the index
 349# file format used is index-v[23].
 350#
 351# Define GMTIME_UNRELIABLE_ERRORS if your gmtime() function does not
 352# return NULL when it receives a bogus time_t.
 353
 354GIT-VERSION-FILE: FORCE
 355        @$(SHELL_PATH) ./GIT-VERSION-GEN
 356-include GIT-VERSION-FILE
 357
 358# CFLAGS and LDFLAGS are for the users to override from the command line.
 359
 360CFLAGS = -g -O2 -Wall
 361LDFLAGS =
 362ALL_CFLAGS = $(CPPFLAGS) $(CFLAGS)
 363ALL_LDFLAGS = $(LDFLAGS)
 364STRIP ?= strip
 365
 366# Among the variables below, these:
 367#   gitexecdir
 368#   template_dir
 369#   sysconfdir
 370# can be specified as a relative path some/where/else;
 371# this is interpreted as relative to $(prefix) and "git" at
 372# runtime figures out where they are based on the path to the executable.
 373# Additionally, the following will be treated as relative by "git" if they
 374# begin with "$(prefix)/":
 375#   mandir
 376#   infodir
 377#   htmldir
 378# This can help installing the suite in a relocatable way.
 379
 380prefix = $(HOME)
 381bindir_relative = bin
 382bindir = $(prefix)/$(bindir_relative)
 383mandir = $(prefix)/share/man
 384infodir = $(prefix)/share/info
 385gitexecdir = libexec/git-core
 386mergetoolsdir = $(gitexecdir)/mergetools
 387sharedir = $(prefix)/share
 388gitwebdir = $(sharedir)/gitweb
 389localedir = $(sharedir)/locale
 390template_dir = share/git-core/templates
 391htmldir = $(prefix)/share/doc/git-doc
 392ETC_GITCONFIG = $(sysconfdir)/gitconfig
 393ETC_GITATTRIBUTES = $(sysconfdir)/gitattributes
 394lib = lib
 395# DESTDIR =
 396pathsep = :
 397
 398mandir_relative = $(patsubst $(prefix)/%,%,$(mandir))
 399infodir_relative = $(patsubst $(prefix)/%,%,$(infodir))
 400htmldir_relative = $(patsubst $(prefix)/%,%,$(htmldir))
 401
 402export prefix bindir sharedir sysconfdir gitwebdir localedir
 403
 404CC = cc
 405AR = ar
 406RM = rm -f
 407DIFF = diff
 408TAR = tar
 409FIND = find
 410INSTALL = install
 411RPMBUILD = rpmbuild
 412TCL_PATH = tclsh
 413TCLTK_PATH = wish
 414XGETTEXT = xgettext
 415MSGFMT = msgfmt
 416PTHREAD_LIBS = -lpthread
 417PTHREAD_CFLAGS =
 418GCOV = gcov
 419
 420export TCL_PATH TCLTK_PATH
 421
 422SPARSE_FLAGS =
 423
 424
 425
 426### --- END CONFIGURATION SECTION ---
 427
 428# Those must not be GNU-specific; they are shared with perl/ which may
 429# be built by a different compiler. (Note that this is an artifact now
 430# but it still might be nice to keep that distinction.)
 431BASIC_CFLAGS = -I.
 432BASIC_LDFLAGS =
 433
 434# Guard against environment variables
 435BUILTIN_OBJS =
 436BUILT_INS =
 437COMPAT_CFLAGS =
 438COMPAT_OBJS =
 439XDIFF_OBJS =
 440VCSSVN_OBJS =
 441GENERATED_H =
 442EXTRA_CPPFLAGS =
 443LIB_H =
 444LIB_OBJS =
 445PROGRAM_OBJS =
 446PROGRAMS =
 447SCRIPT_PERL =
 448SCRIPT_PYTHON =
 449SCRIPT_SH =
 450SCRIPT_LIB =
 451TEST_PROGRAMS_NEED_X =
 452
 453# Having this variable in your environment would break pipelines because
 454# you cause "cd" to echo its destination to stdout.  It can also take
 455# scripts to unexpected places.  If you like CDPATH, define it for your
 456# interactive shell sessions without exporting it.
 457unexport CDPATH
 458
 459SCRIPT_SH += git-am.sh
 460SCRIPT_SH += git-bisect.sh
 461SCRIPT_SH += git-difftool--helper.sh
 462SCRIPT_SH += git-filter-branch.sh
 463SCRIPT_SH += git-merge-octopus.sh
 464SCRIPT_SH += git-merge-one-file.sh
 465SCRIPT_SH += git-merge-resolve.sh
 466SCRIPT_SH += git-mergetool.sh
 467SCRIPT_SH += git-pull.sh
 468SCRIPT_SH += git-quiltimport.sh
 469SCRIPT_SH += git-rebase.sh
 470SCRIPT_SH += git-remote-testgit.sh
 471SCRIPT_SH += git-request-pull.sh
 472SCRIPT_SH += git-stash.sh
 473SCRIPT_SH += git-submodule.sh
 474SCRIPT_SH += git-web--browse.sh
 475
 476SCRIPT_LIB += git-mergetool--lib
 477SCRIPT_LIB += git-parse-remote
 478SCRIPT_LIB += git-rebase--am
 479SCRIPT_LIB += git-rebase--interactive
 480SCRIPT_LIB += git-rebase--merge
 481SCRIPT_LIB += git-sh-setup
 482SCRIPT_LIB += git-sh-i18n
 483
 484SCRIPT_PERL += git-add--interactive.perl
 485SCRIPT_PERL += git-difftool.perl
 486SCRIPT_PERL += git-archimport.perl
 487SCRIPT_PERL += git-cvsexportcommit.perl
 488SCRIPT_PERL += git-cvsimport.perl
 489SCRIPT_PERL += git-cvsserver.perl
 490SCRIPT_PERL += git-relink.perl
 491SCRIPT_PERL += git-send-email.perl
 492SCRIPT_PERL += git-svn.perl
 493
 494SCRIPT_PYTHON += git-p4.py
 495
 496NO_INSTALL += git-remote-testgit
 497
 498# Generated files for scripts
 499SCRIPT_SH_GEN = $(patsubst %.sh,%,$(SCRIPT_SH))
 500SCRIPT_PERL_GEN = $(patsubst %.perl,%,$(SCRIPT_PERL))
 501SCRIPT_PYTHON_GEN = $(patsubst %.py,%,$(SCRIPT_PYTHON))
 502
 503SCRIPT_SH_INS = $(filter-out $(NO_INSTALL),$(SCRIPT_SH_GEN))
 504SCRIPT_PERL_INS = $(filter-out $(NO_INSTALL),$(SCRIPT_PERL_GEN))
 505SCRIPT_PYTHON_INS = $(filter-out $(NO_INSTALL),$(SCRIPT_PYTHON_GEN))
 506
 507# Individual rules to allow e.g.
 508# "make -C ../.. SCRIPT_PERL=contrib/foo/bar.perl build-perl-script"
 509# from subdirectories like contrib/*/
 510.PHONY: build-perl-script build-sh-script build-python-script
 511build-perl-script: $(SCRIPT_PERL_GEN)
 512build-sh-script: $(SCRIPT_SH_GEN)
 513build-python-script: $(SCRIPT_PYTHON_GEN)
 514
 515.PHONY: install-perl-script install-sh-script install-python-script
 516install-sh-script: $(SCRIPT_SH_INS)
 517        $(INSTALL) $^ '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
 518install-perl-script: $(SCRIPT_PERL_INS)
 519        $(INSTALL) $^ '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
 520install-python-script: $(SCRIPT_PYTHON_INS)
 521        $(INSTALL) $^ '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
 522
 523.PHONY: clean-perl-script clean-sh-script clean-python-script
 524clean-sh-script:
 525        $(RM) $(SCRIPT_SH_GEN)
 526clean-perl-script:
 527        $(RM) $(SCRIPT_PERL_GEN)
 528clean-python-script:
 529        $(RM) $(SCRIPT_PYTHON_GEN)
 530
 531SCRIPTS = $(SCRIPT_SH_INS) \
 532          $(SCRIPT_PERL_INS) \
 533          $(SCRIPT_PYTHON_INS) \
 534          git-instaweb
 535
 536ETAGS_TARGET = TAGS
 537
 538# Empty...
 539EXTRA_PROGRAMS =
 540
 541# ... and all the rest that could be moved out of bindir to gitexecdir
 542PROGRAMS += $(EXTRA_PROGRAMS)
 543
 544PROGRAM_OBJS += credential-store.o
 545PROGRAM_OBJS += daemon.o
 546PROGRAM_OBJS += fast-import.o
 547PROGRAM_OBJS += http-backend.o
 548PROGRAM_OBJS += imap-send.o
 549PROGRAM_OBJS += sh-i18n--envsubst.o
 550PROGRAM_OBJS += shell.o
 551PROGRAM_OBJS += show-index.o
 552PROGRAM_OBJS += upload-pack.o
 553PROGRAM_OBJS += remote-testsvn.o
 554
 555# Binary suffix, set to .exe for Windows builds
 556X =
 557
 558PROGRAMS += $(patsubst %.o,git-%$X,$(PROGRAM_OBJS))
 559
 560TEST_PROGRAMS_NEED_X += test-chmtime
 561TEST_PROGRAMS_NEED_X += test-ctype
 562TEST_PROGRAMS_NEED_X += test-date
 563TEST_PROGRAMS_NEED_X += test-delta
 564TEST_PROGRAMS_NEED_X += test-dump-cache-tree
 565TEST_PROGRAMS_NEED_X += test-genrandom
 566TEST_PROGRAMS_NEED_X += test-hashmap
 567TEST_PROGRAMS_NEED_X += test-index-version
 568TEST_PROGRAMS_NEED_X += test-line-buffer
 569TEST_PROGRAMS_NEED_X += test-match-trees
 570TEST_PROGRAMS_NEED_X += test-mergesort
 571TEST_PROGRAMS_NEED_X += test-mktemp
 572TEST_PROGRAMS_NEED_X += test-parse-options
 573TEST_PROGRAMS_NEED_X += test-path-utils
 574TEST_PROGRAMS_NEED_X += test-prio-queue
 575TEST_PROGRAMS_NEED_X += test-read-cache
 576TEST_PROGRAMS_NEED_X += test-regex
 577TEST_PROGRAMS_NEED_X += test-revision-walking
 578TEST_PROGRAMS_NEED_X += test-run-command
 579TEST_PROGRAMS_NEED_X += test-scrap-cache-tree
 580TEST_PROGRAMS_NEED_X += test-sha1
 581TEST_PROGRAMS_NEED_X += test-sigchain
 582TEST_PROGRAMS_NEED_X += test-string-list
 583TEST_PROGRAMS_NEED_X += test-subprocess
 584TEST_PROGRAMS_NEED_X += test-svn-fe
 585TEST_PROGRAMS_NEED_X += test-urlmatch-normalization
 586TEST_PROGRAMS_NEED_X += test-wildmatch
 587
 588TEST_PROGRAMS = $(patsubst %,%$X,$(TEST_PROGRAMS_NEED_X))
 589
 590# List built-in command $C whose implementation cmd_$C() is not in
 591# builtin/$C.o but is linked in as part of some other command.
 592BUILT_INS += $(patsubst builtin/%.o,git-%$X,$(BUILTIN_OBJS))
 593
 594BUILT_INS += git-cherry$X
 595BUILT_INS += git-cherry-pick$X
 596BUILT_INS += git-format-patch$X
 597BUILT_INS += git-fsck-objects$X
 598BUILT_INS += git-init$X
 599BUILT_INS += git-merge-subtree$X
 600BUILT_INS += git-show$X
 601BUILT_INS += git-stage$X
 602BUILT_INS += git-status$X
 603BUILT_INS += git-whatchanged$X
 604
 605# what 'all' will build and 'install' will install in gitexecdir,
 606# excluding programs for built-in commands
 607ALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS)
 608
 609# what 'all' will build but not install in gitexecdir
 610OTHER_PROGRAMS = git$X
 611
 612# what test wrappers are needed and 'install' will install, in bindir
 613BINDIR_PROGRAMS_NEED_X += git
 614BINDIR_PROGRAMS_NEED_X += git-upload-pack
 615BINDIR_PROGRAMS_NEED_X += git-receive-pack
 616BINDIR_PROGRAMS_NEED_X += git-upload-archive
 617BINDIR_PROGRAMS_NEED_X += git-shell
 618
 619BINDIR_PROGRAMS_NO_X += git-cvsserver
 620
 621# Set paths to tools early so that they can be used for version tests.
 622ifndef SHELL_PATH
 623        SHELL_PATH = /bin/sh
 624endif
 625ifndef PERL_PATH
 626        PERL_PATH = /usr/bin/perl
 627endif
 628ifndef PYTHON_PATH
 629        PYTHON_PATH = /usr/bin/python
 630endif
 631
 632export PERL_PATH
 633export PYTHON_PATH
 634
 635LIB_FILE = libgit.a
 636XDIFF_LIB = xdiff/lib.a
 637VCSSVN_LIB = vcs-svn/lib.a
 638
 639GENERATED_H += common-cmds.h
 640
 641LIB_H += advice.h
 642LIB_H += archive.h
 643LIB_H += argv-array.h
 644LIB_H += attr.h
 645LIB_H += bisect.h
 646LIB_H += blob.h
 647LIB_H += branch.h
 648LIB_H += builtin.h
 649LIB_H += bulk-checkin.h
 650LIB_H += bundle.h
 651LIB_H += cache-tree.h
 652LIB_H += cache.h
 653LIB_H += color.h
 654LIB_H += column.h
 655LIB_H += commit.h
 656LIB_H += compat/bswap.h
 657LIB_H += compat/mingw.h
 658LIB_H += compat/obstack.h
 659LIB_H += compat/poll/poll.h
 660LIB_H += compat/precompose_utf8.h
 661LIB_H += compat/terminal.h
 662LIB_H += compat/win32/dirent.h
 663LIB_H += compat/win32/pthread.h
 664LIB_H += compat/win32/syslog.h
 665LIB_H += connected.h
 666LIB_H += convert.h
 667LIB_H += credential.h
 668LIB_H += csum-file.h
 669LIB_H += decorate.h
 670LIB_H += delta.h
 671LIB_H += diff.h
 672LIB_H += diffcore.h
 673LIB_H += dir.h
 674LIB_H += exec_cmd.h
 675LIB_H += ewah/ewok.h
 676LIB_H += ewah/ewok_rlw.h
 677LIB_H += fetch-pack.h
 678LIB_H += fmt-merge-msg.h
 679LIB_H += fsck.h
 680LIB_H += gettext.h
 681LIB_H += git-compat-util.h
 682LIB_H += gpg-interface.h
 683LIB_H += graph.h
 684LIB_H += grep.h
 685LIB_H += hashmap.h
 686LIB_H += help.h
 687LIB_H += http.h
 688LIB_H += kwset.h
 689LIB_H += levenshtein.h
 690LIB_H += line-log.h
 691LIB_H += line-range.h
 692LIB_H += list-objects.h
 693LIB_H += ll-merge.h
 694LIB_H += log-tree.h
 695LIB_H += mailmap.h
 696LIB_H += merge-blobs.h
 697LIB_H += merge-recursive.h
 698LIB_H += mergesort.h
 699LIB_H += notes-cache.h
 700LIB_H += notes-merge.h
 701LIB_H += notes-utils.h
 702LIB_H += notes.h
 703LIB_H += object.h
 704LIB_H += pack-objects.h
 705LIB_H += pack-revindex.h
 706LIB_H += pack.h
 707LIB_H += pack-bitmap.h
 708LIB_H += parse-options.h
 709LIB_H += patch-ids.h
 710LIB_H += pathspec.h
 711LIB_H += pkt-line.h
 712LIB_H += prio-queue.h
 713LIB_H += progress.h
 714LIB_H += prompt.h
 715LIB_H += quote.h
 716LIB_H += reachable.h
 717LIB_H += reflog-walk.h
 718LIB_H += refs.h
 719LIB_H += remote.h
 720LIB_H += rerere.h
 721LIB_H += resolve-undo.h
 722LIB_H += revision.h
 723LIB_H += run-command.h
 724LIB_H += send-pack.h
 725LIB_H += sequencer.h
 726LIB_H += sha1-array.h
 727LIB_H += sha1-lookup.h
 728LIB_H += shortlog.h
 729LIB_H += sideband.h
 730LIB_H += sigchain.h
 731LIB_H += strbuf.h
 732LIB_H += streaming.h
 733LIB_H += string-list.h
 734LIB_H += submodule.h
 735LIB_H += tag.h
 736LIB_H += tar.h
 737LIB_H += thread-utils.h
 738LIB_H += transport.h
 739LIB_H += tree-walk.h
 740LIB_H += tree.h
 741LIB_H += unpack-trees.h
 742LIB_H += url.h
 743LIB_H += urlmatch.h
 744LIB_H += userdiff.h
 745LIB_H += utf8.h
 746LIB_H += varint.h
 747LIB_H += vcs-svn/fast_export.h
 748LIB_H += vcs-svn/line_buffer.h
 749LIB_H += vcs-svn/repo_tree.h
 750LIB_H += vcs-svn/sliding_window.h
 751LIB_H += vcs-svn/svndiff.h
 752LIB_H += vcs-svn/svndump.h
 753LIB_H += walker.h
 754LIB_H += wildmatch.h
 755LIB_H += wt-status.h
 756LIB_H += xdiff-interface.h
 757LIB_H += xdiff/xdiff.h
 758LIB_H += xdiff/xdiffi.h
 759LIB_H += xdiff/xemit.h
 760LIB_H += xdiff/xinclude.h
 761LIB_H += xdiff/xmacros.h
 762LIB_H += xdiff/xprepare.h
 763LIB_H += xdiff/xtypes.h
 764LIB_H += xdiff/xutils.h
 765
 766LIB_OBJS += abspath.o
 767LIB_OBJS += advice.o
 768LIB_OBJS += alias.o
 769LIB_OBJS += alloc.o
 770LIB_OBJS += archive.o
 771LIB_OBJS += archive-tar.o
 772LIB_OBJS += archive-zip.o
 773LIB_OBJS += argv-array.o
 774LIB_OBJS += attr.o
 775LIB_OBJS += base85.o
 776LIB_OBJS += bisect.o
 777LIB_OBJS += blob.o
 778LIB_OBJS += branch.o
 779LIB_OBJS += bulk-checkin.o
 780LIB_OBJS += bundle.o
 781LIB_OBJS += cache-tree.o
 782LIB_OBJS += color.o
 783LIB_OBJS += column.o
 784LIB_OBJS += combine-diff.o
 785LIB_OBJS += commit.o
 786LIB_OBJS += compat/obstack.o
 787LIB_OBJS += compat/terminal.o
 788LIB_OBJS += config.o
 789LIB_OBJS += connect.o
 790LIB_OBJS += connected.o
 791LIB_OBJS += convert.o
 792LIB_OBJS += copy.o
 793LIB_OBJS += credential.o
 794LIB_OBJS += csum-file.o
 795LIB_OBJS += ctype.o
 796LIB_OBJS += date.o
 797LIB_OBJS += decorate.o
 798LIB_OBJS += diffcore-break.o
 799LIB_OBJS += diffcore-delta.o
 800LIB_OBJS += diffcore-order.o
 801LIB_OBJS += diffcore-pickaxe.o
 802LIB_OBJS += diffcore-rename.o
 803LIB_OBJS += diff-delta.o
 804LIB_OBJS += diff-lib.o
 805LIB_OBJS += diff-no-index.o
 806LIB_OBJS += diff.o
 807LIB_OBJS += dir.o
 808LIB_OBJS += editor.o
 809LIB_OBJS += entry.o
 810LIB_OBJS += environment.o
 811LIB_OBJS += ewah/bitmap.o
 812LIB_OBJS += ewah/ewah_bitmap.o
 813LIB_OBJS += ewah/ewah_io.o
 814LIB_OBJS += ewah/ewah_rlw.o
 815LIB_OBJS += exec_cmd.o
 816LIB_OBJS += fetch-pack.o
 817LIB_OBJS += fsck.o
 818LIB_OBJS += gettext.o
 819LIB_OBJS += gpg-interface.o
 820LIB_OBJS += graph.o
 821LIB_OBJS += grep.o
 822LIB_OBJS += hashmap.o
 823LIB_OBJS += help.o
 824LIB_OBJS += hex.o
 825LIB_OBJS += ident.o
 826LIB_OBJS += kwset.o
 827LIB_OBJS += levenshtein.o
 828LIB_OBJS += line-log.o
 829LIB_OBJS += line-range.o
 830LIB_OBJS += list-objects.o
 831LIB_OBJS += ll-merge.o
 832LIB_OBJS += lockfile.o
 833LIB_OBJS += log-tree.o
 834LIB_OBJS += mailmap.o
 835LIB_OBJS += match-trees.o
 836LIB_OBJS += merge.o
 837LIB_OBJS += merge-blobs.o
 838LIB_OBJS += merge-recursive.o
 839LIB_OBJS += mergesort.o
 840LIB_OBJS += name-hash.o
 841LIB_OBJS += notes.o
 842LIB_OBJS += notes-cache.o
 843LIB_OBJS += notes-merge.o
 844LIB_OBJS += notes-utils.o
 845LIB_OBJS += object.o
 846LIB_OBJS += pack-bitmap.o
 847LIB_OBJS += pack-bitmap-write.o
 848LIB_OBJS += pack-check.o
 849LIB_OBJS += pack-objects.o
 850LIB_OBJS += pack-revindex.o
 851LIB_OBJS += pack-write.o
 852LIB_OBJS += pager.o
 853LIB_OBJS += parse-options.o
 854LIB_OBJS += parse-options-cb.o
 855LIB_OBJS += patch-delta.o
 856LIB_OBJS += patch-ids.o
 857LIB_OBJS += path.o
 858LIB_OBJS += pathspec.o
 859LIB_OBJS += pkt-line.o
 860LIB_OBJS += preload-index.o
 861LIB_OBJS += pretty.o
 862LIB_OBJS += prio-queue.o
 863LIB_OBJS += progress.o
 864LIB_OBJS += prompt.o
 865LIB_OBJS += quote.o
 866LIB_OBJS += reachable.o
 867LIB_OBJS += read-cache.o
 868LIB_OBJS += reflog-walk.o
 869LIB_OBJS += refs.o
 870LIB_OBJS += remote.o
 871LIB_OBJS += replace_object.o
 872LIB_OBJS += rerere.o
 873LIB_OBJS += resolve-undo.o
 874LIB_OBJS += revision.o
 875LIB_OBJS += run-command.o
 876LIB_OBJS += send-pack.o
 877LIB_OBJS += sequencer.o
 878LIB_OBJS += server-info.o
 879LIB_OBJS += setup.o
 880LIB_OBJS += sha1-array.o
 881LIB_OBJS += sha1-lookup.o
 882LIB_OBJS += sha1_file.o
 883LIB_OBJS += sha1_name.o
 884LIB_OBJS += shallow.o
 885LIB_OBJS += sideband.o
 886LIB_OBJS += sigchain.o
 887LIB_OBJS += strbuf.o
 888LIB_OBJS += streaming.o
 889LIB_OBJS += string-list.o
 890LIB_OBJS += submodule.o
 891LIB_OBJS += symlinks.o
 892LIB_OBJS += tag.o
 893LIB_OBJS += trace.o
 894LIB_OBJS += transport.o
 895LIB_OBJS += transport-helper.o
 896LIB_OBJS += tree-diff.o
 897LIB_OBJS += tree.o
 898LIB_OBJS += tree-walk.o
 899LIB_OBJS += unpack-trees.o
 900LIB_OBJS += url.o
 901LIB_OBJS += urlmatch.o
 902LIB_OBJS += usage.o
 903LIB_OBJS += userdiff.o
 904LIB_OBJS += utf8.o
 905LIB_OBJS += varint.o
 906LIB_OBJS += version.o
 907LIB_OBJS += versioncmp.o
 908LIB_OBJS += walker.o
 909LIB_OBJS += wildmatch.o
 910LIB_OBJS += wrapper.o
 911LIB_OBJS += write_or_die.o
 912LIB_OBJS += ws.o
 913LIB_OBJS += wt-status.o
 914LIB_OBJS += xdiff-interface.o
 915LIB_OBJS += zlib.o
 916
 917BUILTIN_OBJS += builtin/add.o
 918BUILTIN_OBJS += builtin/annotate.o
 919BUILTIN_OBJS += builtin/apply.o
 920BUILTIN_OBJS += builtin/archive.o
 921BUILTIN_OBJS += builtin/bisect--helper.o
 922BUILTIN_OBJS += builtin/blame.o
 923BUILTIN_OBJS += builtin/branch.o
 924BUILTIN_OBJS += builtin/bundle.o
 925BUILTIN_OBJS += builtin/cat-file.o
 926BUILTIN_OBJS += builtin/check-attr.o
 927BUILTIN_OBJS += builtin/check-ignore.o
 928BUILTIN_OBJS += builtin/check-mailmap.o
 929BUILTIN_OBJS += builtin/check-ref-format.o
 930BUILTIN_OBJS += builtin/checkout-index.o
 931BUILTIN_OBJS += builtin/checkout.o
 932BUILTIN_OBJS += builtin/clean.o
 933BUILTIN_OBJS += builtin/clone.o
 934BUILTIN_OBJS += builtin/column.o
 935BUILTIN_OBJS += builtin/commit-tree.o
 936BUILTIN_OBJS += builtin/commit.o
 937BUILTIN_OBJS += builtin/config.o
 938BUILTIN_OBJS += builtin/count-objects.o
 939BUILTIN_OBJS += builtin/credential.o
 940BUILTIN_OBJS += builtin/describe.o
 941BUILTIN_OBJS += builtin/diff-files.o
 942BUILTIN_OBJS += builtin/diff-index.o
 943BUILTIN_OBJS += builtin/diff-tree.o
 944BUILTIN_OBJS += builtin/diff.o
 945BUILTIN_OBJS += builtin/fast-export.o
 946BUILTIN_OBJS += builtin/fetch-pack.o
 947BUILTIN_OBJS += builtin/fetch.o
 948BUILTIN_OBJS += builtin/fmt-merge-msg.o
 949BUILTIN_OBJS += builtin/for-each-ref.o
 950BUILTIN_OBJS += builtin/fsck.o
 951BUILTIN_OBJS += builtin/gc.o
 952BUILTIN_OBJS += builtin/get-tar-commit-id.o
 953BUILTIN_OBJS += builtin/grep.o
 954BUILTIN_OBJS += builtin/hash-object.o
 955BUILTIN_OBJS += builtin/help.o
 956BUILTIN_OBJS += builtin/index-pack.o
 957BUILTIN_OBJS += builtin/init-db.o
 958BUILTIN_OBJS += builtin/log.o
 959BUILTIN_OBJS += builtin/ls-files.o
 960BUILTIN_OBJS += builtin/ls-remote.o
 961BUILTIN_OBJS += builtin/ls-tree.o
 962BUILTIN_OBJS += builtin/mailinfo.o
 963BUILTIN_OBJS += builtin/mailsplit.o
 964BUILTIN_OBJS += builtin/merge.o
 965BUILTIN_OBJS += builtin/merge-base.o
 966BUILTIN_OBJS += builtin/merge-file.o
 967BUILTIN_OBJS += builtin/merge-index.o
 968BUILTIN_OBJS += builtin/merge-ours.o
 969BUILTIN_OBJS += builtin/merge-recursive.o
 970BUILTIN_OBJS += builtin/merge-tree.o
 971BUILTIN_OBJS += builtin/mktag.o
 972BUILTIN_OBJS += builtin/mktree.o
 973BUILTIN_OBJS += builtin/mv.o
 974BUILTIN_OBJS += builtin/name-rev.o
 975BUILTIN_OBJS += builtin/notes.o
 976BUILTIN_OBJS += builtin/pack-objects.o
 977BUILTIN_OBJS += builtin/pack-redundant.o
 978BUILTIN_OBJS += builtin/pack-refs.o
 979BUILTIN_OBJS += builtin/patch-id.o
 980BUILTIN_OBJS += builtin/prune-packed.o
 981BUILTIN_OBJS += builtin/prune.o
 982BUILTIN_OBJS += builtin/push.o
 983BUILTIN_OBJS += builtin/read-tree.o
 984BUILTIN_OBJS += builtin/receive-pack.o
 985BUILTIN_OBJS += builtin/reflog.o
 986BUILTIN_OBJS += builtin/remote.o
 987BUILTIN_OBJS += builtin/remote-ext.o
 988BUILTIN_OBJS += builtin/remote-fd.o
 989BUILTIN_OBJS += builtin/repack.o
 990BUILTIN_OBJS += builtin/replace.o
 991BUILTIN_OBJS += builtin/rerere.o
 992BUILTIN_OBJS += builtin/reset.o
 993BUILTIN_OBJS += builtin/rev-list.o
 994BUILTIN_OBJS += builtin/rev-parse.o
 995BUILTIN_OBJS += builtin/revert.o
 996BUILTIN_OBJS += builtin/rm.o
 997BUILTIN_OBJS += builtin/send-pack.o
 998BUILTIN_OBJS += builtin/shortlog.o
 999BUILTIN_OBJS += builtin/show-branch.o
1000BUILTIN_OBJS += builtin/show-ref.o
1001BUILTIN_OBJS += builtin/stripspace.o
1002BUILTIN_OBJS += builtin/symbolic-ref.o
1003BUILTIN_OBJS += builtin/tag.o
1004BUILTIN_OBJS += builtin/unpack-file.o
1005BUILTIN_OBJS += builtin/unpack-objects.o
1006BUILTIN_OBJS += builtin/update-index.o
1007BUILTIN_OBJS += builtin/update-ref.o
1008BUILTIN_OBJS += builtin/update-server-info.o
1009BUILTIN_OBJS += builtin/upload-archive.o
1010BUILTIN_OBJS += builtin/var.o
1011BUILTIN_OBJS += builtin/verify-pack.o
1012BUILTIN_OBJS += builtin/verify-tag.o
1013BUILTIN_OBJS += builtin/write-tree.o
1014
1015GITLIBS = $(LIB_FILE) $(XDIFF_LIB)
1016EXTLIBS =
1017
1018GIT_USER_AGENT = git/$(GIT_VERSION)
1019
1020include config.mak.uname
1021-include config.mak.autogen
1022-include config.mak
1023
1024ifndef sysconfdir
1025ifeq ($(prefix),/usr)
1026sysconfdir = /etc
1027else
1028sysconfdir = etc
1029endif
1030endif
1031
1032ifdef CHECK_HEADER_DEPENDENCIES
1033COMPUTE_HEADER_DEPENDENCIES = no
1034USE_COMPUTED_HEADER_DEPENDENCIES =
1035endif
1036
1037ifndef COMPUTE_HEADER_DEPENDENCIES
1038COMPUTE_HEADER_DEPENDENCIES = auto
1039endif
1040
1041ifeq ($(COMPUTE_HEADER_DEPENDENCIES),auto)
1042dep_check = $(shell $(CC) $(ALL_CFLAGS) \
1043        -c -MF /dev/null -MQ /dev/null -MMD -MP \
1044        -x c /dev/null -o /dev/null 2>&1; \
1045        echo $$?)
1046ifeq ($(dep_check),0)
1047override COMPUTE_HEADER_DEPENDENCIES = yes
1048else
1049override COMPUTE_HEADER_DEPENDENCIES = no
1050endif
1051endif
1052
1053ifeq ($(COMPUTE_HEADER_DEPENDENCIES),yes)
1054USE_COMPUTED_HEADER_DEPENDENCIES = YesPlease
1055else
1056ifneq ($(COMPUTE_HEADER_DEPENDENCIES),no)
1057$(error please set COMPUTE_HEADER_DEPENDENCIES to yes, no, or auto \
1058(not "$(COMPUTE_HEADER_DEPENDENCIES)"))
1059endif
1060endif
1061
1062ifdef SANE_TOOL_PATH
1063SANE_TOOL_PATH_SQ = $(subst ','\'',$(SANE_TOOL_PATH))
1064BROKEN_PATH_FIX = 's|^\# @@BROKEN_PATH_FIX@@$$|git_broken_path_fix $(SANE_TOOL_PATH_SQ)|'
1065PATH := $(SANE_TOOL_PATH):${PATH}
1066else
1067BROKEN_PATH_FIX = '/^\# @@BROKEN_PATH_FIX@@$$/d'
1068endif
1069
1070ifneq (,$(INLINE))
1071        BASIC_CFLAGS += -Dinline=$(INLINE)
1072endif
1073
1074ifneq (,$(SOCKLEN_T))
1075        BASIC_CFLAGS += -Dsocklen_t=$(SOCKLEN_T)
1076endif
1077
1078ifeq ($(uname_S),Darwin)
1079        ifndef NO_FINK
1080                ifeq ($(shell test -d /sw/lib && echo y),y)
1081                        BASIC_CFLAGS += -I/sw/include
1082                        BASIC_LDFLAGS += -L/sw/lib
1083                endif
1084        endif
1085        ifndef NO_DARWIN_PORTS
1086                ifeq ($(shell test -d /opt/local/lib && echo y),y)
1087                        BASIC_CFLAGS += -I/opt/local/include
1088                        BASIC_LDFLAGS += -L/opt/local/lib
1089                endif
1090        endif
1091        ifndef NO_APPLE_COMMON_CRYPTO
1092                APPLE_COMMON_CRYPTO = YesPlease
1093                COMPAT_CFLAGS += -DAPPLE_COMMON_CRYPTO
1094        endif
1095        NO_REGEX = YesPlease
1096        PTHREAD_LIBS =
1097endif
1098
1099ifndef CC_LD_DYNPATH
1100        ifdef NO_R_TO_GCC_LINKER
1101                # Some gcc does not accept and pass -R to the linker to specify
1102                # the runtime dynamic library path.
1103                CC_LD_DYNPATH = -Wl,-rpath,
1104        else
1105                CC_LD_DYNPATH = -R
1106        endif
1107endif
1108
1109ifdef NO_LIBGEN_H
1110        COMPAT_CFLAGS += -DNO_LIBGEN_H
1111        COMPAT_OBJS += compat/basename.o
1112endif
1113
1114ifdef USE_LIBPCRE
1115        BASIC_CFLAGS += -DUSE_LIBPCRE
1116        ifdef LIBPCREDIR
1117                BASIC_CFLAGS += -I$(LIBPCREDIR)/include
1118                EXTLIBS += -L$(LIBPCREDIR)/$(lib) $(CC_LD_DYNPATH)$(LIBPCREDIR)/$(lib)
1119        endif
1120        EXTLIBS += -lpcre
1121endif
1122
1123ifdef NO_CURL
1124        BASIC_CFLAGS += -DNO_CURL
1125        REMOTE_CURL_PRIMARY =
1126        REMOTE_CURL_ALIASES =
1127        REMOTE_CURL_NAMES =
1128else
1129        ifdef CURLDIR
1130                # Try "-Wl,-rpath=$(CURLDIR)/$(lib)" in such a case.
1131                BASIC_CFLAGS += -I$(CURLDIR)/include
1132                CURL_LIBCURL = -L$(CURLDIR)/$(lib) $(CC_LD_DYNPATH)$(CURLDIR)/$(lib) -lcurl
1133                ifdef NEEDS_SSL_WITH_CURL
1134                        CURL_LIBCURL += -lssl
1135                        ifdef NEEDS_CRYPTO_WITH_SSL
1136                                CURL_LIBCURL += -lcrypto
1137                        endif
1138                endif
1139                ifdef NEEDS_IDN_WITH_CURL
1140                        CURL_LIBCURL += -lidn
1141                endif
1142        else
1143                CURL_CONFIG ?= curl-config
1144                BASIC_CFLAGS += $(shell $(CURL_CONFIG) --cflags)
1145                ifdef CURL_STATIC
1146                        CURL_LIBCURL = $(shell $(CURL_CONFIG) --static-libs)
1147                        ifeq "$(CURL_LIBCURL)" ""
1148                                $(error libcurl not detected or not compiled with static support)
1149                        endif
1150                else
1151                        CURL_LIBCURL = $(shell $(CURL_CONFIG) --libs)
1152                        ifeq "$(CURL_LIBCURL)" ""
1153                                $(error libcurl not detected; try setting CURLDIR)
1154                        endif
1155                endif
1156        endif
1157
1158        REMOTE_CURL_PRIMARY = git-remote-http$X
1159        REMOTE_CURL_ALIASES = git-remote-https$X git-remote-ftp$X git-remote-ftps$X
1160        REMOTE_CURL_NAMES = $(REMOTE_CURL_PRIMARY) $(REMOTE_CURL_ALIASES)
1161        PROGRAM_OBJS += http-fetch.o
1162        PROGRAMS += $(REMOTE_CURL_NAMES)
1163        curl_check := $(shell (echo 070908; curl-config --vernum) 2>/dev/null | sort -r | sed -ne 2p)
1164        ifeq "$(curl_check)" "070908"
1165                ifndef NO_EXPAT
1166                        PROGRAM_OBJS += http-push.o
1167                endif
1168        endif
1169        ifndef NO_EXPAT
1170                ifdef EXPATDIR
1171                        BASIC_CFLAGS += -I$(EXPATDIR)/include
1172                        EXPAT_LIBEXPAT = -L$(EXPATDIR)/$(lib) $(CC_LD_DYNPATH)$(EXPATDIR)/$(lib) -lexpat
1173                else
1174                        EXPAT_LIBEXPAT = -lexpat
1175                endif
1176                ifdef EXPAT_NEEDS_XMLPARSE_H
1177                        BASIC_CFLAGS += -DEXPAT_NEEDS_XMLPARSE_H
1178                endif
1179        endif
1180endif
1181
1182ifdef ZLIB_PATH
1183        BASIC_CFLAGS += -I$(ZLIB_PATH)/include
1184        EXTLIBS += -L$(ZLIB_PATH)/$(lib) $(CC_LD_DYNPATH)$(ZLIB_PATH)/$(lib)
1185endif
1186EXTLIBS += -lz
1187
1188ifndef NO_OPENSSL
1189        OPENSSL_LIBSSL = -lssl
1190        ifdef OPENSSLDIR
1191                BASIC_CFLAGS += -I$(OPENSSLDIR)/include
1192                OPENSSL_LINK = -L$(OPENSSLDIR)/$(lib) $(CC_LD_DYNPATH)$(OPENSSLDIR)/$(lib)
1193        else
1194                OPENSSL_LINK =
1195        endif
1196        ifdef NEEDS_CRYPTO_WITH_SSL
1197                OPENSSL_LIBSSL += -lcrypto
1198        endif
1199else
1200        BASIC_CFLAGS += -DNO_OPENSSL
1201        BLK_SHA1 = 1
1202        OPENSSL_LIBSSL =
1203endif
1204ifdef NO_OPENSSL
1205        LIB_4_CRYPTO =
1206else
1207ifdef NEEDS_SSL_WITH_CRYPTO
1208        LIB_4_CRYPTO = $(OPENSSL_LINK) -lcrypto -lssl
1209else
1210        LIB_4_CRYPTO = $(OPENSSL_LINK) -lcrypto
1211endif
1212ifdef APPLE_COMMON_CRYPTO
1213        LIB_4_CRYPTO += -framework Security -framework CoreFoundation
1214endif
1215endif
1216ifdef NEEDS_LIBICONV
1217        ifdef ICONVDIR
1218                BASIC_CFLAGS += -I$(ICONVDIR)/include
1219                ICONV_LINK = -L$(ICONVDIR)/$(lib) $(CC_LD_DYNPATH)$(ICONVDIR)/$(lib)
1220        else
1221                ICONV_LINK =
1222        endif
1223        ifdef NEEDS_LIBINTL_BEFORE_LIBICONV
1224                ICONV_LINK += -lintl
1225        endif
1226        EXTLIBS += $(ICONV_LINK) -liconv
1227endif
1228ifdef NEEDS_LIBGEN
1229        EXTLIBS += -lgen
1230endif
1231ifndef NO_GETTEXT
1232ifndef LIBC_CONTAINS_LIBINTL
1233        EXTLIBS += -lintl
1234endif
1235endif
1236ifdef NEEDS_SOCKET
1237        EXTLIBS += -lsocket
1238endif
1239ifdef NEEDS_NSL
1240        EXTLIBS += -lnsl
1241endif
1242ifdef NEEDS_RESOLV
1243        EXTLIBS += -lresolv
1244endif
1245ifdef NO_D_TYPE_IN_DIRENT
1246        BASIC_CFLAGS += -DNO_D_TYPE_IN_DIRENT
1247endif
1248ifdef NO_D_INO_IN_DIRENT
1249        BASIC_CFLAGS += -DNO_D_INO_IN_DIRENT
1250endif
1251ifdef NO_GECOS_IN_PWENT
1252        BASIC_CFLAGS += -DNO_GECOS_IN_PWENT
1253endif
1254ifdef NO_ST_BLOCKS_IN_STRUCT_STAT
1255        BASIC_CFLAGS += -DNO_ST_BLOCKS_IN_STRUCT_STAT
1256endif
1257ifdef USE_NSEC
1258        BASIC_CFLAGS += -DUSE_NSEC
1259endif
1260ifdef USE_ST_TIMESPEC
1261        BASIC_CFLAGS += -DUSE_ST_TIMESPEC
1262endif
1263ifdef NO_NORETURN
1264        BASIC_CFLAGS += -DNO_NORETURN
1265endif
1266ifdef NO_NSEC
1267        BASIC_CFLAGS += -DNO_NSEC
1268endif
1269ifdef SNPRINTF_RETURNS_BOGUS
1270        COMPAT_CFLAGS += -DSNPRINTF_RETURNS_BOGUS
1271        COMPAT_OBJS += compat/snprintf.o
1272endif
1273ifdef FREAD_READS_DIRECTORIES
1274        COMPAT_CFLAGS += -DFREAD_READS_DIRECTORIES
1275        COMPAT_OBJS += compat/fopen.o
1276endif
1277ifdef NO_SYMLINK_HEAD
1278        BASIC_CFLAGS += -DNO_SYMLINK_HEAD
1279endif
1280ifdef GETTEXT_POISON
1281        BASIC_CFLAGS += -DGETTEXT_POISON
1282endif
1283ifdef NO_GETTEXT
1284        BASIC_CFLAGS += -DNO_GETTEXT
1285        USE_GETTEXT_SCHEME ?= fallthrough
1286endif
1287ifdef NO_POLL
1288        NO_SYS_POLL_H = YesPlease
1289        COMPAT_CFLAGS += -DNO_POLL -Icompat/poll
1290        COMPAT_OBJS += compat/poll/poll.o
1291endif
1292ifdef NO_STRCASESTR
1293        COMPAT_CFLAGS += -DNO_STRCASESTR
1294        COMPAT_OBJS += compat/strcasestr.o
1295endif
1296ifdef NO_STRLCPY
1297        COMPAT_CFLAGS += -DNO_STRLCPY
1298        COMPAT_OBJS += compat/strlcpy.o
1299endif
1300ifdef NO_STRTOUMAX
1301        COMPAT_CFLAGS += -DNO_STRTOUMAX
1302        COMPAT_OBJS += compat/strtoumax.o compat/strtoimax.o
1303endif
1304ifdef NO_STRTOULL
1305        COMPAT_CFLAGS += -DNO_STRTOULL
1306endif
1307ifdef NO_SETENV
1308        COMPAT_CFLAGS += -DNO_SETENV
1309        COMPAT_OBJS += compat/setenv.o
1310endif
1311ifdef NO_MKDTEMP
1312        COMPAT_CFLAGS += -DNO_MKDTEMP
1313        COMPAT_OBJS += compat/mkdtemp.o
1314endif
1315ifdef MKDIR_WO_TRAILING_SLASH
1316        COMPAT_CFLAGS += -DMKDIR_WO_TRAILING_SLASH
1317        COMPAT_OBJS += compat/mkdir.o
1318endif
1319ifdef NO_MKSTEMPS
1320        COMPAT_CFLAGS += -DNO_MKSTEMPS
1321endif
1322ifdef NO_UNSETENV
1323        COMPAT_CFLAGS += -DNO_UNSETENV
1324        COMPAT_OBJS += compat/unsetenv.o
1325endif
1326ifdef NO_SYS_SELECT_H
1327        BASIC_CFLAGS += -DNO_SYS_SELECT_H
1328endif
1329ifdef NO_SYS_POLL_H
1330        BASIC_CFLAGS += -DNO_SYS_POLL_H
1331endif
1332ifdef NEEDS_SYS_PARAM_H
1333        BASIC_CFLAGS += -DNEEDS_SYS_PARAM_H
1334endif
1335ifdef NO_INTTYPES_H
1336        BASIC_CFLAGS += -DNO_INTTYPES_H
1337endif
1338ifdef NO_INITGROUPS
1339        BASIC_CFLAGS += -DNO_INITGROUPS
1340endif
1341ifdef NO_MMAP
1342        COMPAT_CFLAGS += -DNO_MMAP
1343        COMPAT_OBJS += compat/mmap.o
1344else
1345        ifdef USE_WIN32_MMAP
1346                COMPAT_CFLAGS += -DUSE_WIN32_MMAP
1347                COMPAT_OBJS += compat/win32mmap.o
1348        endif
1349endif
1350ifdef OBJECT_CREATION_USES_RENAMES
1351        COMPAT_CFLAGS += -DOBJECT_CREATION_MODE=1
1352endif
1353ifdef NO_STRUCT_ITIMERVAL
1354        COMPAT_CFLAGS += -DNO_STRUCT_ITIMERVAL
1355        NO_SETITIMER = YesPlease
1356endif
1357ifdef NO_SETITIMER
1358        COMPAT_CFLAGS += -DNO_SETITIMER
1359endif
1360ifdef NO_PREAD
1361        COMPAT_CFLAGS += -DNO_PREAD
1362        COMPAT_OBJS += compat/pread.o
1363        NO_THREAD_SAFE_PREAD = YesPlease
1364endif
1365ifdef NO_THREAD_SAFE_PREAD
1366        BASIC_CFLAGS += -DNO_THREAD_SAFE_PREAD
1367endif
1368ifdef NO_FAST_WORKING_DIRECTORY
1369        BASIC_CFLAGS += -DNO_FAST_WORKING_DIRECTORY
1370endif
1371ifdef NO_TRUSTABLE_FILEMODE
1372        BASIC_CFLAGS += -DNO_TRUSTABLE_FILEMODE
1373endif
1374ifdef NO_IPV6
1375        BASIC_CFLAGS += -DNO_IPV6
1376endif
1377ifdef NO_INTPTR_T
1378        COMPAT_CFLAGS += -DNO_INTPTR_T
1379endif
1380ifdef NO_UINTMAX_T
1381        BASIC_CFLAGS += -Duintmax_t=uint32_t
1382endif
1383ifdef NO_SOCKADDR_STORAGE
1384ifdef NO_IPV6
1385        BASIC_CFLAGS += -Dsockaddr_storage=sockaddr_in
1386else
1387        BASIC_CFLAGS += -Dsockaddr_storage=sockaddr_in6
1388endif
1389endif
1390ifdef NO_INET_NTOP
1391        LIB_OBJS += compat/inet_ntop.o
1392        BASIC_CFLAGS += -DNO_INET_NTOP
1393endif
1394ifdef NO_INET_PTON
1395        LIB_OBJS += compat/inet_pton.o
1396        BASIC_CFLAGS += -DNO_INET_PTON
1397endif
1398ifndef NO_UNIX_SOCKETS
1399        LIB_OBJS += unix-socket.o
1400        LIB_H += unix-socket.h
1401        PROGRAM_OBJS += credential-cache.o
1402        PROGRAM_OBJS += credential-cache--daemon.o
1403endif
1404
1405ifdef NO_ICONV
1406        BASIC_CFLAGS += -DNO_ICONV
1407endif
1408
1409ifdef OLD_ICONV
1410        BASIC_CFLAGS += -DOLD_ICONV
1411endif
1412
1413ifdef NO_DEFLATE_BOUND
1414        BASIC_CFLAGS += -DNO_DEFLATE_BOUND
1415endif
1416
1417ifdef NO_POSIX_GOODIES
1418        BASIC_CFLAGS += -DNO_POSIX_GOODIES
1419endif
1420
1421ifdef BLK_SHA1
1422        SHA1_HEADER = "block-sha1/sha1.h"
1423        LIB_OBJS += block-sha1/sha1.o
1424        LIB_H += block-sha1/sha1.h
1425else
1426ifdef PPC_SHA1
1427        SHA1_HEADER = "ppc/sha1.h"
1428        LIB_OBJS += ppc/sha1.o ppc/sha1ppc.o
1429        LIB_H += ppc/sha1.h
1430else
1431ifdef APPLE_COMMON_CRYPTO
1432        COMPAT_CFLAGS += -DCOMMON_DIGEST_FOR_OPENSSL
1433        SHA1_HEADER = <CommonCrypto/CommonDigest.h>
1434else
1435        SHA1_HEADER = <openssl/sha.h>
1436        EXTLIBS += $(LIB_4_CRYPTO)
1437endif
1438endif
1439endif
1440
1441ifdef NO_PERL_MAKEMAKER
1442        export NO_PERL_MAKEMAKER
1443endif
1444ifdef NO_HSTRERROR
1445        COMPAT_CFLAGS += -DNO_HSTRERROR
1446        COMPAT_OBJS += compat/hstrerror.o
1447endif
1448ifdef NO_MEMMEM
1449        COMPAT_CFLAGS += -DNO_MEMMEM
1450        COMPAT_OBJS += compat/memmem.o
1451endif
1452ifdef NO_GETPAGESIZE
1453        COMPAT_CFLAGS += -DNO_GETPAGESIZE
1454endif
1455ifdef INTERNAL_QSORT
1456        COMPAT_CFLAGS += -DINTERNAL_QSORT
1457        COMPAT_OBJS += compat/qsort.o
1458endif
1459ifdef RUNTIME_PREFIX
1460        COMPAT_CFLAGS += -DRUNTIME_PREFIX
1461endif
1462
1463ifdef NO_PTHREADS
1464        BASIC_CFLAGS += -DNO_PTHREADS
1465else
1466        BASIC_CFLAGS += $(PTHREAD_CFLAGS)
1467        EXTLIBS += $(PTHREAD_LIBS)
1468        LIB_OBJS += thread-utils.o
1469endif
1470
1471ifdef HAVE_PATHS_H
1472        BASIC_CFLAGS += -DHAVE_PATHS_H
1473endif
1474
1475ifdef HAVE_LIBCHARSET_H
1476        BASIC_CFLAGS += -DHAVE_LIBCHARSET_H
1477        EXTLIBS += $(CHARSET_LIB)
1478endif
1479
1480ifdef HAVE_STRINGS_H
1481        BASIC_CFLAGS += -DHAVE_STRINGS_H
1482endif
1483
1484ifdef HAVE_DEV_TTY
1485        BASIC_CFLAGS += -DHAVE_DEV_TTY
1486endif
1487
1488ifdef DIR_HAS_BSD_GROUP_SEMANTICS
1489        COMPAT_CFLAGS += -DDIR_HAS_BSD_GROUP_SEMANTICS
1490endif
1491ifdef UNRELIABLE_FSTAT
1492        BASIC_CFLAGS += -DUNRELIABLE_FSTAT
1493endif
1494ifdef NO_REGEX
1495        COMPAT_CFLAGS += -Icompat/regex
1496        COMPAT_OBJS += compat/regex/regex.o
1497endif
1498
1499ifdef USE_NED_ALLOCATOR
1500       COMPAT_CFLAGS += -Icompat/nedmalloc
1501       COMPAT_OBJS += compat/nedmalloc/nedmalloc.o
1502endif
1503
1504ifdef GIT_TEST_CMP_USE_COPIED_CONTEXT
1505        export GIT_TEST_CMP_USE_COPIED_CONTEXT
1506endif
1507
1508ifndef NO_MSGFMT_EXTENDED_OPTIONS
1509        MSGFMT += --check --statistics
1510endif
1511
1512ifneq (,$(XDL_FAST_HASH))
1513        BASIC_CFLAGS += -DXDL_FAST_HASH
1514endif
1515
1516ifdef GMTIME_UNRELIABLE_ERRORS
1517        COMPAT_OBJS += compat/gmtime.o
1518        BASIC_CFLAGS += -DGMTIME_UNRELIABLE_ERRORS
1519endif
1520
1521ifeq ($(TCLTK_PATH),)
1522NO_TCLTK = NoThanks
1523endif
1524
1525ifeq ($(PERL_PATH),)
1526NO_PERL = NoThanks
1527endif
1528
1529ifeq ($(PYTHON_PATH),)
1530NO_PYTHON = NoThanks
1531endif
1532
1533QUIET_SUBDIR0  = +$(MAKE) -C # space to separate -C and subdir
1534QUIET_SUBDIR1  =
1535
1536ifneq ($(findstring $(MAKEFLAGS),w),w)
1537PRINT_DIR = --no-print-directory
1538else # "make -w"
1539NO_SUBDIR = :
1540endif
1541
1542ifneq ($(findstring $(MAKEFLAGS),s),s)
1543ifndef V
1544        QUIET_CC       = @echo '   ' CC $@;
1545        QUIET_AR       = @echo '   ' AR $@;
1546        QUIET_LINK     = @echo '   ' LINK $@;
1547        QUIET_BUILT_IN = @echo '   ' BUILTIN $@;
1548        QUIET_GEN      = @echo '   ' GEN $@;
1549        QUIET_LNCP     = @echo '   ' LN/CP $@;
1550        QUIET_XGETTEXT = @echo '   ' XGETTEXT $@;
1551        QUIET_MSGFMT   = @echo '   ' MSGFMT $@;
1552        QUIET_GCOV     = @echo '   ' GCOV $@;
1553        QUIET_SP       = @echo '   ' SP $<;
1554        QUIET_RC       = @echo '   ' RC $@;
1555        QUIET_SUBDIR0  = +@subdir=
1556        QUIET_SUBDIR1  = ;$(NO_SUBDIR) echo '   ' SUBDIR $$subdir; \
1557                         $(MAKE) $(PRINT_DIR) -C $$subdir
1558        export V
1559        export QUIET_GEN
1560        export QUIET_BUILT_IN
1561endif
1562endif
1563
1564ifdef NO_INSTALL_HARDLINKS
1565        export NO_INSTALL_HARDLINKS
1566endif
1567
1568### profile feedback build
1569#
1570
1571# Can adjust this to be a global directory if you want to do extended
1572# data gathering
1573PROFILE_DIR := $(CURDIR)
1574
1575ifeq ("$(PROFILE)","GEN")
1576        CFLAGS += -fprofile-generate=$(PROFILE_DIR) -DNO_NORETURN=1
1577        EXTLIBS += -lgcov
1578        export CCACHE_DISABLE = t
1579        V = 1
1580else
1581ifneq ("$(PROFILE)","")
1582        CFLAGS += -fprofile-use=$(PROFILE_DIR) -fprofile-correction -DNO_NORETURN=1
1583        export CCACHE_DISABLE = t
1584        V = 1
1585endif
1586endif
1587
1588# Shell quote (do not use $(call) to accommodate ancient setups);
1589
1590SHA1_HEADER_SQ = $(subst ','\'',$(SHA1_HEADER))
1591ETC_GITCONFIG_SQ = $(subst ','\'',$(ETC_GITCONFIG))
1592ETC_GITATTRIBUTES_SQ = $(subst ','\'',$(ETC_GITATTRIBUTES))
1593
1594DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
1595bindir_SQ = $(subst ','\'',$(bindir))
1596bindir_relative_SQ = $(subst ','\'',$(bindir_relative))
1597mandir_relative_SQ = $(subst ','\'',$(mandir_relative))
1598infodir_relative_SQ = $(subst ','\'',$(infodir_relative))
1599localedir_SQ = $(subst ','\'',$(localedir))
1600gitexecdir_SQ = $(subst ','\'',$(gitexecdir))
1601template_dir_SQ = $(subst ','\'',$(template_dir))
1602htmldir_relative_SQ = $(subst ','\'',$(htmldir_relative))
1603prefix_SQ = $(subst ','\'',$(prefix))
1604gitwebdir_SQ = $(subst ','\'',$(gitwebdir))
1605
1606SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
1607PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
1608PYTHON_PATH_SQ = $(subst ','\'',$(PYTHON_PATH))
1609TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH))
1610DIFF_SQ = $(subst ','\'',$(DIFF))
1611PERLLIB_EXTRA_SQ = $(subst ','\'',$(PERLLIB_EXTRA))
1612
1613LIBS = $(GITLIBS) $(EXTLIBS)
1614
1615BASIC_CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER_SQ)' \
1616        $(COMPAT_CFLAGS)
1617LIB_OBJS += $(COMPAT_OBJS)
1618
1619# Quote for C
1620
1621ifdef DEFAULT_EDITOR
1622DEFAULT_EDITOR_CQ = "$(subst ",\",$(subst \,\\,$(DEFAULT_EDITOR)))"
1623DEFAULT_EDITOR_CQ_SQ = $(subst ','\'',$(DEFAULT_EDITOR_CQ))
1624
1625BASIC_CFLAGS += -DDEFAULT_EDITOR='$(DEFAULT_EDITOR_CQ_SQ)'
1626endif
1627
1628ifdef DEFAULT_PAGER
1629DEFAULT_PAGER_CQ = "$(subst ",\",$(subst \,\\,$(DEFAULT_PAGER)))"
1630DEFAULT_PAGER_CQ_SQ = $(subst ','\'',$(DEFAULT_PAGER_CQ))
1631
1632BASIC_CFLAGS += -DDEFAULT_PAGER='$(DEFAULT_PAGER_CQ_SQ)'
1633endif
1634
1635ifdef SHELL_PATH
1636SHELL_PATH_CQ = "$(subst ",\",$(subst \,\\,$(SHELL_PATH)))"
1637SHELL_PATH_CQ_SQ = $(subst ','\'',$(SHELL_PATH_CQ))
1638
1639BASIC_CFLAGS += -DSHELL_PATH='$(SHELL_PATH_CQ_SQ)'
1640endif
1641
1642GIT_USER_AGENT_SQ = $(subst ','\'',$(GIT_USER_AGENT))
1643GIT_USER_AGENT_CQ = "$(subst ",\",$(subst \,\\,$(GIT_USER_AGENT)))"
1644GIT_USER_AGENT_CQ_SQ = $(subst ','\'',$(GIT_USER_AGENT_CQ))
1645GIT-USER-AGENT: FORCE
1646        @if test x'$(GIT_USER_AGENT_SQ)' != x"`cat GIT-USER-AGENT 2>/dev/null`"; then \
1647                echo '$(GIT_USER_AGENT_SQ)' >GIT-USER-AGENT; \
1648        fi
1649
1650ifdef DEFAULT_HELP_FORMAT
1651BASIC_CFLAGS += -DDEFAULT_HELP_FORMAT='"$(DEFAULT_HELP_FORMAT)"'
1652endif
1653
1654ALL_CFLAGS += $(BASIC_CFLAGS)
1655ALL_LDFLAGS += $(BASIC_LDFLAGS)
1656
1657export DIFF TAR INSTALL DESTDIR SHELL_PATH
1658
1659
1660### Build rules
1661
1662SHELL = $(SHELL_PATH)
1663
1664all:: shell_compatibility_test
1665
1666ifeq "$(PROFILE)" "BUILD"
1667ifeq ($(filter all,$(MAKECMDGOALS)),all)
1668all:: profile-clean
1669        $(MAKE) PROFILE=GEN all
1670        $(MAKE) PROFILE=GEN -j1 test
1671endif
1672endif
1673
1674all:: $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) $(OTHER_PROGRAMS) GIT-BUILD-OPTIONS
1675ifneq (,$X)
1676        $(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';)
1677endif
1678
1679all::
1680ifndef NO_TCLTK
1681        $(QUIET_SUBDIR0)git-gui $(QUIET_SUBDIR1) gitexecdir='$(gitexec_instdir_SQ)' all
1682        $(QUIET_SUBDIR0)gitk-git $(QUIET_SUBDIR1) all
1683endif
1684ifndef NO_PERL
1685        $(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' localedir='$(localedir_SQ)' all
1686endif
1687        $(QUIET_SUBDIR0)templates $(QUIET_SUBDIR1) SHELL_PATH='$(SHELL_PATH_SQ)' PERL_PATH='$(PERL_PATH_SQ)'
1688
1689please_set_SHELL_PATH_to_a_more_modern_shell:
1690        @$$(:)
1691
1692shell_compatibility_test: please_set_SHELL_PATH_to_a_more_modern_shell
1693
1694strip: $(PROGRAMS) git$X
1695        $(STRIP) $(STRIP_OPTS) $^
1696
1697### Target-specific flags and dependencies
1698
1699# The generic compilation pattern rule and automatically
1700# computed header dependencies (falling back to a dependency on
1701# LIB_H) are enough to describe how most targets should be built,
1702# but some targets are special enough to need something a little
1703# different.
1704#
1705# - When a source file "foo.c" #includes a generated header file,
1706#   we need to list that dependency for the "foo.o" target.
1707#
1708#   We also list it from other targets that are built from foo.c
1709#   like "foo.sp" and "foo.s", even though that is easy to forget
1710#   to do because the generated header is already present around
1711#   after a regular build attempt.
1712#
1713# - Some code depends on configuration kept in makefile
1714#   variables. The target-specific variable EXTRA_CPPFLAGS can
1715#   be used to convey that information to the C preprocessor
1716#   using -D options.
1717#
1718#   The "foo.o" target should have a corresponding dependency on
1719#   a file that changes when the value of the makefile variable
1720#   changes.  For example, targets making use of the
1721#   $(GIT_VERSION) variable depend on GIT-VERSION-FILE.
1722#
1723#   Technically the ".sp" and ".s" targets do not need this
1724#   dependency because they are force-built, but they get the
1725#   same dependency for consistency. This way, you do not have to
1726#   know how each target is implemented. And it means the
1727#   dependencies here will not need to change if the force-build
1728#   details change some day.
1729
1730git.sp git.s git.o: GIT-PREFIX
1731git.sp git.s git.o: EXTRA_CPPFLAGS = \
1732        '-DGIT_HTML_PATH="$(htmldir_relative_SQ)"' \
1733        '-DGIT_MAN_PATH="$(mandir_relative_SQ)"' \
1734        '-DGIT_INFO_PATH="$(infodir_relative_SQ)"'
1735
1736git$X: git.o GIT-LDFLAGS $(BUILTIN_OBJS) $(GITLIBS)
1737        $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ git.o \
1738                $(BUILTIN_OBJS) $(ALL_LDFLAGS) $(LIBS)
1739
1740help.sp help.s help.o: common-cmds.h
1741
1742builtin/help.sp builtin/help.s builtin/help.o: common-cmds.h GIT-PREFIX
1743builtin/help.sp builtin/help.s builtin/help.o: EXTRA_CPPFLAGS = \
1744        '-DGIT_HTML_PATH="$(htmldir_relative_SQ)"' \
1745        '-DGIT_MAN_PATH="$(mandir_relative_SQ)"' \
1746        '-DGIT_INFO_PATH="$(infodir_relative_SQ)"'
1747
1748version.sp version.s version.o: GIT-VERSION-FILE GIT-USER-AGENT
1749version.sp version.s version.o: EXTRA_CPPFLAGS = \
1750        '-DGIT_VERSION="$(GIT_VERSION)"' \
1751        '-DGIT_USER_AGENT=$(GIT_USER_AGENT_CQ_SQ)'
1752
1753$(BUILT_INS): git$X
1754        $(QUIET_BUILT_IN)$(RM) $@ && \
1755        ln $< $@ 2>/dev/null || \
1756        ln -s $< $@ 2>/dev/null || \
1757        cp $< $@
1758
1759common-cmds.h: ./generate-cmdlist.sh command-list.txt
1760
1761common-cmds.h: $(wildcard Documentation/git-*.txt)
1762        $(QUIET_GEN)./generate-cmdlist.sh > $@+ && mv $@+ $@
1763
1764SCRIPT_DEFINES = $(SHELL_PATH_SQ):$(DIFF_SQ):$(GIT_VERSION):\
1765        $(localedir_SQ):$(NO_CURL):$(USE_GETTEXT_SCHEME):$(SANE_TOOL_PATH_SQ):\
1766        $(gitwebdir_SQ):$(PERL_PATH_SQ)
1767define cmd_munge_script
1768$(RM) $@ $@+ && \
1769sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
1770    -e 's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \
1771    -e 's|@@DIFF@@|$(DIFF_SQ)|' \
1772    -e 's|@@LOCALEDIR@@|$(localedir_SQ)|g' \
1773    -e 's/@@NO_CURL@@/$(NO_CURL)/g' \
1774    -e 's/@@USE_GETTEXT_SCHEME@@/$(USE_GETTEXT_SCHEME)/g' \
1775    -e $(BROKEN_PATH_FIX) \
1776    -e 's|@@GITWEBDIR@@|$(gitwebdir_SQ)|g' \
1777    -e 's|@@PERL@@|$(PERL_PATH_SQ)|g' \
1778    $@.sh >$@+
1779endef
1780
1781GIT-SCRIPT-DEFINES: FORCE
1782        @FLAGS='$(SCRIPT_DEFINES)'; \
1783            if test x"$$FLAGS" != x"`cat $@ 2>/dev/null`" ; then \
1784                echo >&2 "    * new script parameters"; \
1785                echo "$$FLAGS" >$@; \
1786            fi
1787
1788
1789$(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh GIT-SCRIPT-DEFINES
1790        $(QUIET_GEN)$(cmd_munge_script) && \
1791        chmod +x $@+ && \
1792        mv $@+ $@
1793
1794$(SCRIPT_LIB) : % : %.sh GIT-SCRIPT-DEFINES
1795        $(QUIET_GEN)$(cmd_munge_script) && \
1796        mv $@+ $@
1797
1798git.res: git.rc GIT-VERSION-FILE
1799        $(QUIET_RC)$(RC) \
1800          $(join -DMAJOR= -DMINOR=, $(wordlist 1,2,$(subst -, ,$(subst ., ,$(GIT_VERSION))))) \
1801          -DGIT_VERSION="\\\"$(GIT_VERSION)\\\"" $< -o $@
1802
1803ifndef NO_PERL
1804$(patsubst %.perl,%,$(SCRIPT_PERL)): perl/perl.mak
1805
1806perl/perl.mak: perl/PM.stamp
1807
1808perl/PM.stamp: FORCE
1809        $(QUIET_GEN)$(FIND) perl -type f -name '*.pm' | sort >$@+ && \
1810        { cmp $@+ $@ >/dev/null 2>/dev/null || mv $@+ $@; } && \
1811        $(RM) $@+
1812
1813perl/perl.mak: GIT-CFLAGS GIT-PREFIX perl/Makefile perl/Makefile.PL
1814        $(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' $(@F)
1815
1816PERL_DEFINES = $(PERL_PATH_SQ):$(PERLLIB_EXTRA_SQ)
1817$(patsubst %.perl,%,$(SCRIPT_PERL)): % : %.perl perl/perl.mak GIT-PERL-DEFINES GIT-VERSION-FILE
1818        $(QUIET_GEN)$(RM) $@ $@+ && \
1819        INSTLIBDIR=`MAKEFLAGS= $(MAKE) -C perl -s --no-print-directory instlibdir` && \
1820        INSTLIBDIR_EXTRA='$(PERLLIB_EXTRA_SQ)' && \
1821        INSTLIBDIR="$$INSTLIBDIR$${INSTLIBDIR_EXTRA:+:$$INSTLIBDIR_EXTRA}" && \
1822        sed -e '1{' \
1823            -e '        s|#!.*perl|#!$(PERL_PATH_SQ)|' \
1824            -e '        h' \
1825            -e '        s=.*=use lib (split(/$(pathsep)/, $$ENV{GITPERLLIB} || "'"$$INSTLIBDIR"'"));=' \
1826            -e '        H' \
1827            -e '        x' \
1828            -e '}' \
1829            -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
1830            $< >$@+ && \
1831        chmod +x $@+ && \
1832        mv $@+ $@
1833
1834GIT-PERL-DEFINES: FORCE
1835        @FLAGS='$(PERL_DEFINES)'; \
1836            if test x"$$FLAGS" != x"`cat $@ 2>/dev/null`" ; then \
1837                echo >&2 "    * new perl-specific parameters"; \
1838                echo "$$FLAGS" >$@; \
1839            fi
1840
1841
1842.PHONY: gitweb
1843gitweb:
1844        $(QUIET_SUBDIR0)gitweb $(QUIET_SUBDIR1) all
1845
1846git-instaweb: git-instaweb.sh gitweb GIT-SCRIPT-DEFINES
1847        $(QUIET_GEN)$(cmd_munge_script) && \
1848        chmod +x $@+ && \
1849        mv $@+ $@
1850else # NO_PERL
1851$(patsubst %.perl,%,$(SCRIPT_PERL)) git-instaweb: % : unimplemented.sh
1852        $(QUIET_GEN)$(RM) $@ $@+ && \
1853        sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
1854            -e 's|@@REASON@@|NO_PERL=$(NO_PERL)|g' \
1855            unimplemented.sh >$@+ && \
1856        chmod +x $@+ && \
1857        mv $@+ $@
1858endif # NO_PERL
1859
1860ifndef NO_PYTHON
1861$(SCRIPT_PYTHON_GEN): GIT-CFLAGS GIT-PREFIX GIT-PYTHON-VARS
1862$(SCRIPT_PYTHON_GEN): % : %.py
1863        $(QUIET_GEN)$(RM) $@ $@+ && \
1864        sed -e '1s|#!.*python|#!$(PYTHON_PATH_SQ)|' \
1865            $< >$@+ && \
1866        chmod +x $@+ && \
1867        mv $@+ $@
1868else # NO_PYTHON
1869$(SCRIPT_PYTHON_GEN): % : unimplemented.sh
1870        $(QUIET_GEN)$(RM) $@ $@+ && \
1871        sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
1872            -e 's|@@REASON@@|NO_PYTHON=$(NO_PYTHON)|g' \
1873            unimplemented.sh >$@+ && \
1874        chmod +x $@+ && \
1875        mv $@+ $@
1876endif # NO_PYTHON
1877
1878CONFIGURE_RECIPE = $(RM) configure configure.ac+ && \
1879                   sed -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
1880                        configure.ac >configure.ac+ && \
1881                   autoconf -o configure configure.ac+ && \
1882                   $(RM) configure.ac+
1883
1884configure: configure.ac GIT-VERSION-FILE
1885        $(QUIET_GEN)$(CONFIGURE_RECIPE)
1886
1887ifdef AUTOCONFIGURED
1888# We avoid depending on 'configure' here, because it gets rebuilt
1889# every time GIT-VERSION-FILE is modified, only to update the embedded
1890# version number string, which config.status does not care about.  We
1891# do want to recheck when the platform/environment detection logic
1892# changes, hence this depends on configure.ac.
1893config.status: configure.ac
1894        $(QUIET_GEN)$(CONFIGURE_RECIPE) && \
1895        if test -f config.status; then \
1896          ./config.status --recheck; \
1897        else \
1898          ./configure; \
1899        fi
1900reconfigure config.mak.autogen: config.status
1901        $(QUIET_GEN)./config.status
1902.PHONY: reconfigure # This is a convenience target.
1903endif
1904
1905XDIFF_OBJS += xdiff/xdiffi.o
1906XDIFF_OBJS += xdiff/xprepare.o
1907XDIFF_OBJS += xdiff/xutils.o
1908XDIFF_OBJS += xdiff/xemit.o
1909XDIFF_OBJS += xdiff/xmerge.o
1910XDIFF_OBJS += xdiff/xpatience.o
1911XDIFF_OBJS += xdiff/xhistogram.o
1912
1913VCSSVN_OBJS += vcs-svn/line_buffer.o
1914VCSSVN_OBJS += vcs-svn/sliding_window.o
1915VCSSVN_OBJS += vcs-svn/repo_tree.o
1916VCSSVN_OBJS += vcs-svn/fast_export.o
1917VCSSVN_OBJS += vcs-svn/svndiff.o
1918VCSSVN_OBJS += vcs-svn/svndump.o
1919
1920TEST_OBJS := $(patsubst test-%$X,test-%.o,$(TEST_PROGRAMS))
1921OBJECTS := $(LIB_OBJS) $(BUILTIN_OBJS) $(PROGRAM_OBJS) $(TEST_OBJS) \
1922        $(XDIFF_OBJS) \
1923        $(VCSSVN_OBJS) \
1924        git.o
1925ifndef NO_CURL
1926        OBJECTS += http.o http-walker.o remote-curl.o
1927endif
1928
1929dep_files := $(foreach f,$(OBJECTS),$(dir $f).depend/$(notdir $f).d)
1930dep_dirs := $(addsuffix .depend,$(sort $(dir $(OBJECTS))))
1931
1932ifeq ($(COMPUTE_HEADER_DEPENDENCIES),yes)
1933$(dep_dirs):
1934        @mkdir -p $@
1935
1936missing_dep_dirs := $(filter-out $(wildcard $(dep_dirs)),$(dep_dirs))
1937dep_file = $(dir $@).depend/$(notdir $@).d
1938dep_args = -MF $(dep_file) -MQ $@ -MMD -MP
1939ifdef CHECK_HEADER_DEPENDENCIES
1940$(error cannot compute header dependencies outside a normal build. \
1941Please unset CHECK_HEADER_DEPENDENCIES and try again)
1942endif
1943endif
1944
1945ifneq ($(COMPUTE_HEADER_DEPENDENCIES),yes)
1946ifndef CHECK_HEADER_DEPENDENCIES
1947dep_dirs =
1948missing_dep_dirs =
1949dep_args =
1950endif
1951endif
1952
1953ifdef CHECK_HEADER_DEPENDENCIES
1954ifndef PRINT_HEADER_DEPENDENCIES
1955missing_deps = $(filter-out $(notdir $^), \
1956        $(notdir $(shell $(MAKE) -s $@ \
1957                CHECK_HEADER_DEPENDENCIES=YesPlease \
1958                USE_COMPUTED_HEADER_DEPENDENCIES=YesPlease \
1959                PRINT_HEADER_DEPENDENCIES=YesPlease)))
1960endif
1961endif
1962
1963ASM_SRC := $(wildcard $(OBJECTS:o=S))
1964ASM_OBJ := $(ASM_SRC:S=o)
1965C_OBJ := $(filter-out $(ASM_OBJ),$(OBJECTS))
1966
1967.SUFFIXES:
1968
1969ifdef PRINT_HEADER_DEPENDENCIES
1970$(C_OBJ): %.o: %.c FORCE
1971        echo $^
1972$(ASM_OBJ): %.o: %.S FORCE
1973        echo $^
1974
1975ifndef CHECK_HEADER_DEPENDENCIES
1976$(error cannot print header dependencies during a normal build. \
1977Please set CHECK_HEADER_DEPENDENCIES and try again)
1978endif
1979endif
1980
1981ifndef PRINT_HEADER_DEPENDENCIES
1982ifdef CHECK_HEADER_DEPENDENCIES
1983$(C_OBJ): %.o: %.c $(dep_files) FORCE
1984        @set -e; echo CHECK $@; \
1985        missing_deps="$(missing_deps)"; \
1986        if test "$$missing_deps"; \
1987        then \
1988                echo missing dependencies: $$missing_deps; \
1989                false; \
1990        fi
1991$(ASM_OBJ): %.o: %.S $(dep_files) FORCE
1992        @set -e; echo CHECK $@; \
1993        missing_deps="$(missing_deps)"; \
1994        if test "$$missing_deps"; \
1995        then \
1996                echo missing dependencies: $$missing_deps; \
1997                false; \
1998        fi
1999endif
2000endif
2001
2002ifndef CHECK_HEADER_DEPENDENCIES
2003$(C_OBJ): %.o: %.c GIT-CFLAGS $(missing_dep_dirs)
2004        $(QUIET_CC)$(CC) -o $*.o -c $(dep_args) $(ALL_CFLAGS) $(EXTRA_CPPFLAGS) $<
2005$(ASM_OBJ): %.o: %.S GIT-CFLAGS $(missing_dep_dirs)
2006        $(QUIET_CC)$(CC) -o $*.o -c $(dep_args) $(ALL_CFLAGS) $(EXTRA_CPPFLAGS) $<
2007endif
2008
2009%.s: %.c GIT-CFLAGS FORCE
2010        $(QUIET_CC)$(CC) -o $@ -S $(ALL_CFLAGS) $(EXTRA_CPPFLAGS) $<
2011
2012ifdef USE_COMPUTED_HEADER_DEPENDENCIES
2013# Take advantage of gcc's on-the-fly dependency generation
2014# See <http://gcc.gnu.org/gcc-3.0/features.html>.
2015dep_files_present := $(wildcard $(dep_files))
2016ifneq ($(dep_files_present),)
2017include $(dep_files_present)
2018endif
2019else
2020# Dependencies on header files, for platforms that do not support
2021# the gcc -MMD option.
2022#
2023# Dependencies on automatically generated headers such as common-cmds.h
2024# should _not_ be included here, since they are necessary even when
2025# building an object for the first time.
2026
2027$(OBJECTS): $(LIB_H)
2028endif
2029
2030exec_cmd.sp exec_cmd.s exec_cmd.o: GIT-PREFIX
2031exec_cmd.sp exec_cmd.s exec_cmd.o: EXTRA_CPPFLAGS = \
2032        '-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' \
2033        '-DBINDIR="$(bindir_relative_SQ)"' \
2034        '-DPREFIX="$(prefix_SQ)"'
2035
2036builtin/init-db.sp builtin/init-db.s builtin/init-db.o: GIT-PREFIX
2037builtin/init-db.sp builtin/init-db.s builtin/init-db.o: EXTRA_CPPFLAGS = \
2038        -DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir_SQ)"'
2039
2040config.sp config.s config.o: GIT-PREFIX
2041config.sp config.s config.o: EXTRA_CPPFLAGS = \
2042        -DETC_GITCONFIG='"$(ETC_GITCONFIG_SQ)"'
2043
2044attr.sp attr.s attr.o: GIT-PREFIX
2045attr.sp attr.s attr.o: EXTRA_CPPFLAGS = \
2046        -DETC_GITATTRIBUTES='"$(ETC_GITATTRIBUTES_SQ)"'
2047
2048gettext.sp gettext.s gettext.o: GIT-PREFIX
2049gettext.sp gettext.s gettext.o: EXTRA_CPPFLAGS = \
2050        -DGIT_LOCALE_PATH='"$(localedir_SQ)"'
2051
2052http-push.sp http.sp http-walker.sp remote-curl.sp: SPARSE_FLAGS += \
2053        -DCURL_DISABLE_TYPECHECK
2054
2055ifdef NO_EXPAT
2056http-walker.sp http-walker.s http-walker.o: EXTRA_CPPFLAGS = -DNO_EXPAT
2057endif
2058
2059ifdef NO_REGEX
2060compat/regex/regex.sp compat/regex/regex.o: EXTRA_CPPFLAGS = \
2061        -DGAWK -DNO_MBSUPPORT
2062endif
2063
2064ifdef USE_NED_ALLOCATOR
2065compat/nedmalloc/nedmalloc.sp compat/nedmalloc/nedmalloc.o: EXTRA_CPPFLAGS = \
2066        -DNDEBUG -DOVERRIDE_STRDUP -DREPLACE_SYSTEM_ALLOCATOR
2067compat/nedmalloc/nedmalloc.sp: SPARSE_FLAGS += -Wno-non-pointer-null
2068endif
2069
2070git-%$X: %.o GIT-LDFLAGS $(GITLIBS)
2071        $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
2072
2073git-imap-send$X: imap-send.o GIT-LDFLAGS $(GITLIBS)
2074        $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
2075                $(LIBS) $(OPENSSL_LINK) $(OPENSSL_LIBSSL) $(LIB_4_CRYPTO)
2076
2077git-http-fetch$X: http.o http-walker.o http-fetch.o GIT-LDFLAGS $(GITLIBS)
2078        $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
2079                $(LIBS) $(CURL_LIBCURL)
2080git-http-push$X: http.o http-push.o GIT-LDFLAGS $(GITLIBS)
2081        $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
2082                $(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
2083
2084git-remote-testsvn$X: remote-testsvn.o GIT-LDFLAGS $(GITLIBS) $(VCSSVN_LIB)
2085        $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS) \
2086        $(VCSSVN_LIB)
2087
2088$(REMOTE_CURL_ALIASES): $(REMOTE_CURL_PRIMARY)
2089        $(QUIET_LNCP)$(RM) $@ && \
2090        ln $< $@ 2>/dev/null || \
2091        ln -s $< $@ 2>/dev/null || \
2092        cp $< $@
2093
2094$(REMOTE_CURL_PRIMARY): remote-curl.o http.o http-walker.o GIT-LDFLAGS $(GITLIBS)
2095        $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
2096                $(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
2097
2098$(LIB_FILE): $(LIB_OBJS)
2099        $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $^
2100
2101$(XDIFF_LIB): $(XDIFF_OBJS)
2102        $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $^
2103
2104$(VCSSVN_LIB): $(VCSSVN_OBJS)
2105        $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $^
2106
2107export DEFAULT_EDITOR DEFAULT_PAGER
2108
2109doc:
2110        $(MAKE) -C Documentation all
2111
2112man:
2113        $(MAKE) -C Documentation man
2114
2115html:
2116        $(MAKE) -C Documentation html
2117
2118info:
2119        $(MAKE) -C Documentation info
2120
2121pdf:
2122        $(MAKE) -C Documentation pdf
2123
2124XGETTEXT_FLAGS = \
2125        --force-po \
2126        --add-comments=TRANSLATORS: \
2127        --msgid-bugs-address="Git Mailing List <git@vger.kernel.org>" \
2128        --from-code=UTF-8
2129XGETTEXT_FLAGS_C = $(XGETTEXT_FLAGS) --language=C \
2130        --keyword=_ --keyword=N_ --keyword="Q_:1,2"
2131XGETTEXT_FLAGS_SH = $(XGETTEXT_FLAGS) --language=Shell \
2132        --keyword=gettextln --keyword=eval_gettextln
2133XGETTEXT_FLAGS_PERL = $(XGETTEXT_FLAGS) --keyword=__ --language=Perl
2134LOCALIZED_C := $(C_OBJ:o=c) $(LIB_H) $(GENERATED_H)
2135LOCALIZED_SH := $(SCRIPT_SH)
2136LOCALIZED_PERL := $(SCRIPT_PERL)
2137
2138ifdef XGETTEXT_INCLUDE_TESTS
2139LOCALIZED_C += t/t0200/test.c
2140LOCALIZED_SH += t/t0200/test.sh
2141LOCALIZED_PERL += t/t0200/test.perl
2142endif
2143
2144po/git.pot: $(LOCALIZED_C)
2145        $(QUIET_XGETTEXT)$(XGETTEXT) -o$@+ $(XGETTEXT_FLAGS_C) $(LOCALIZED_C)
2146        $(QUIET_XGETTEXT)$(XGETTEXT) -o$@+ --join-existing $(XGETTEXT_FLAGS_SH) \
2147                $(LOCALIZED_SH)
2148        $(QUIET_XGETTEXT)$(XGETTEXT) -o$@+ --join-existing $(XGETTEXT_FLAGS_PERL) \
2149                $(LOCALIZED_PERL)
2150        mv $@+ $@
2151
2152pot: po/git.pot
2153
2154POFILES := $(wildcard po/*.po)
2155MOFILES := $(patsubst po/%.po,po/build/locale/%/LC_MESSAGES/git.mo,$(POFILES))
2156
2157ifndef NO_GETTEXT
2158all:: $(MOFILES)
2159endif
2160
2161po/build/locale/%/LC_MESSAGES/git.mo: po/%.po
2162        $(QUIET_MSGFMT)mkdir -p $(dir $@) && $(MSGFMT) -o $@ $<
2163
2164FIND_SOURCE_FILES = ( git ls-files '*.[hcS]' 2>/dev/null || \
2165                        $(FIND) . \( -name .git -type d -prune \) \
2166                                -o \( -name '*.[hcS]' -type f -print \) )
2167
2168$(ETAGS_TARGET): FORCE
2169        $(RM) $(ETAGS_TARGET)
2170        $(FIND_SOURCE_FILES) | xargs etags -a -o $(ETAGS_TARGET)
2171
2172tags: FORCE
2173        $(RM) tags
2174        $(FIND_SOURCE_FILES) | xargs ctags -a
2175
2176cscope:
2177        $(RM) cscope*
2178        $(FIND_SOURCE_FILES) | xargs cscope -b
2179
2180### Detect prefix changes
2181TRACK_PREFIX = $(bindir_SQ):$(gitexecdir_SQ):$(template_dir_SQ):$(prefix_SQ):\
2182                $(localedir_SQ)
2183
2184GIT-PREFIX: FORCE
2185        @FLAGS='$(TRACK_PREFIX)'; \
2186        if test x"$$FLAGS" != x"`cat GIT-PREFIX 2>/dev/null`" ; then \
2187                echo >&2 "    * new prefix flags"; \
2188                echo "$$FLAGS" >GIT-PREFIX; \
2189        fi
2190
2191TRACK_CFLAGS = $(CC):$(subst ','\'',$(ALL_CFLAGS)):$(USE_GETTEXT_SCHEME)
2192
2193GIT-CFLAGS: FORCE
2194        @FLAGS='$(TRACK_CFLAGS)'; \
2195            if test x"$$FLAGS" != x"`cat GIT-CFLAGS 2>/dev/null`" ; then \
2196                echo >&2 "    * new build flags"; \
2197                echo "$$FLAGS" >GIT-CFLAGS; \
2198            fi
2199
2200TRACK_LDFLAGS = $(subst ','\'',$(ALL_LDFLAGS))
2201
2202GIT-LDFLAGS: FORCE
2203        @FLAGS='$(TRACK_LDFLAGS)'; \
2204            if test x"$$FLAGS" != x"`cat GIT-LDFLAGS 2>/dev/null`" ; then \
2205                echo >&2 "    * new link flags"; \
2206                echo "$$FLAGS" >GIT-LDFLAGS; \
2207            fi
2208
2209# We need to apply sq twice, once to protect from the shell
2210# that runs GIT-BUILD-OPTIONS, and then again to protect it
2211# and the first level quoting from the shell that runs "echo".
2212GIT-BUILD-OPTIONS: FORCE
2213        @echo SHELL_PATH=\''$(subst ','\'',$(SHELL_PATH_SQ))'\' >$@
2214        @echo PERL_PATH=\''$(subst ','\'',$(PERL_PATH_SQ))'\' >>$@
2215        @echo DIFF=\''$(subst ','\'',$(subst ','\'',$(DIFF)))'\' >>$@
2216        @echo PYTHON_PATH=\''$(subst ','\'',$(PYTHON_PATH_SQ))'\' >>$@
2217        @echo TAR=\''$(subst ','\'',$(subst ','\'',$(TAR)))'\' >>$@
2218        @echo NO_CURL=\''$(subst ','\'',$(subst ','\'',$(NO_CURL)))'\' >>$@
2219        @echo USE_LIBPCRE=\''$(subst ','\'',$(subst ','\'',$(USE_LIBPCRE)))'\' >>$@
2220        @echo NO_PERL=\''$(subst ','\'',$(subst ','\'',$(NO_PERL)))'\' >>$@
2221        @echo NO_PYTHON=\''$(subst ','\'',$(subst ','\'',$(NO_PYTHON)))'\' >>$@
2222        @echo NO_UNIX_SOCKETS=\''$(subst ','\'',$(subst ','\'',$(NO_UNIX_SOCKETS)))'\' >>$@
2223ifdef TEST_OUTPUT_DIRECTORY
2224        @echo TEST_OUTPUT_DIRECTORY=\''$(subst ','\'',$(subst ','\'',$(TEST_OUTPUT_DIRECTORY)))'\' >>$@
2225endif
2226ifdef GIT_TEST_OPTS
2227        @echo GIT_TEST_OPTS=\''$(subst ','\'',$(subst ','\'',$(GIT_TEST_OPTS)))'\' >>$@
2228endif
2229ifdef GIT_TEST_CMP
2230        @echo GIT_TEST_CMP=\''$(subst ','\'',$(subst ','\'',$(GIT_TEST_CMP)))'\' >>$@
2231endif
2232ifdef GIT_TEST_CMP_USE_COPIED_CONTEXT
2233        @echo GIT_TEST_CMP_USE_COPIED_CONTEXT=YesPlease >>$@
2234endif
2235        @echo NO_GETTEXT=\''$(subst ','\'',$(subst ','\'',$(NO_GETTEXT)))'\' >>$@
2236        @echo GETTEXT_POISON=\''$(subst ','\'',$(subst ','\'',$(GETTEXT_POISON)))'\' >>$@
2237ifdef GIT_PERF_REPEAT_COUNT
2238        @echo GIT_PERF_REPEAT_COUNT=\''$(subst ','\'',$(subst ','\'',$(GIT_PERF_REPEAT_COUNT)))'\' >>$@
2239endif
2240ifdef GIT_PERF_REPO
2241        @echo GIT_PERF_REPO=\''$(subst ','\'',$(subst ','\'',$(GIT_PERF_REPO)))'\' >>$@
2242endif
2243ifdef GIT_PERF_LARGE_REPO
2244        @echo GIT_PERF_LARGE_REPO=\''$(subst ','\'',$(subst ','\'',$(GIT_PERF_LARGE_REPO)))'\' >>$@
2245endif
2246ifdef GIT_PERF_MAKE_OPTS
2247        @echo GIT_PERF_MAKE_OPTS=\''$(subst ','\'',$(subst ','\'',$(GIT_PERF_MAKE_OPTS)))'\' >>$@
2248endif
2249ifdef TEST_GIT_INDEX_VERSION
2250        @echo TEST_GIT_INDEX_VERSION=\''$(subst ','\'',$(subst ','\'',$(TEST_GIT_INDEX_VERSION)))'\' >>$@
2251endif
2252
2253### Detect Python interpreter path changes
2254ifndef NO_PYTHON
2255TRACK_PYTHON = $(subst ','\'',-DPYTHON_PATH='$(PYTHON_PATH_SQ)')
2256
2257GIT-PYTHON-VARS: FORCE
2258        @VARS='$(TRACK_PYTHON)'; \
2259            if test x"$$VARS" != x"`cat $@ 2>/dev/null`" ; then \
2260                echo >&2 "    * new Python interpreter location"; \
2261                echo "$$VARS" >$@; \
2262            fi
2263endif
2264
2265test_bindir_programs := $(patsubst %,bin-wrappers/%,$(BINDIR_PROGRAMS_NEED_X) $(BINDIR_PROGRAMS_NO_X) $(TEST_PROGRAMS_NEED_X))
2266
2267all:: $(TEST_PROGRAMS) $(test_bindir_programs)
2268all:: $(NO_INSTALL)
2269
2270bin-wrappers/%: wrap-for-bin.sh
2271        @mkdir -p bin-wrappers
2272        $(QUIET_GEN)sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
2273             -e 's|@@BUILD_DIR@@|$(shell pwd)|' \
2274             -e 's|@@PROG@@|$(@F)|' < $< > $@ && \
2275        chmod +x $@
2276
2277# GNU make supports exporting all variables by "export" without parameters.
2278# However, the environment gets quite big, and some programs have problems
2279# with that.
2280
2281export NO_SVN_TESTS
2282export TEST_NO_MALLOC_CHECK
2283
2284### Testing rules
2285
2286test: all
2287        $(MAKE) -C t/ all
2288
2289perf: all
2290        $(MAKE) -C t/perf/ all
2291
2292.PHONY: test perf
2293
2294test-ctype$X: ctype.o
2295
2296test-date$X: date.o ctype.o
2297
2298test-delta$X: diff-delta.o patch-delta.o
2299
2300test-line-buffer$X: vcs-svn/lib.a
2301
2302test-parse-options$X: parse-options.o parse-options-cb.o
2303
2304test-svn-fe$X: vcs-svn/lib.a
2305
2306.PRECIOUS: $(TEST_OBJS)
2307
2308test-%$X: test-%.o GIT-LDFLAGS $(GITLIBS)
2309        $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(filter %.a,$^) $(LIBS)
2310
2311check-sha1:: test-sha1$X
2312        ./test-sha1.sh
2313
2314SP_OBJ = $(patsubst %.o,%.sp,$(C_OBJ))
2315
2316$(SP_OBJ): %.sp: %.c GIT-CFLAGS FORCE
2317        $(QUIET_SP)cgcc -no-compile $(ALL_CFLAGS) $(EXTRA_CPPFLAGS) \
2318                $(SPARSE_FLAGS) $<
2319
2320.PHONY: sparse $(SP_OBJ)
2321sparse: $(SP_OBJ)
2322
2323check: common-cmds.h
2324        @if sparse; \
2325        then \
2326                echo 2>&1 "Use 'make sparse' instead"; \
2327                $(MAKE) --no-print-directory sparse; \
2328        else \
2329                echo 2>&1 "Did you mean 'make test'?"; \
2330                exit 1; \
2331        fi
2332
2333### Installation rules
2334
2335ifneq ($(filter /%,$(firstword $(template_dir))),)
2336template_instdir = $(template_dir)
2337else
2338template_instdir = $(prefix)/$(template_dir)
2339endif
2340export template_instdir
2341
2342ifneq ($(filter /%,$(firstword $(gitexecdir))),)
2343gitexec_instdir = $(gitexecdir)
2344else
2345gitexec_instdir = $(prefix)/$(gitexecdir)
2346endif
2347gitexec_instdir_SQ = $(subst ','\'',$(gitexec_instdir))
2348export gitexec_instdir
2349
2350ifneq ($(filter /%,$(firstword $(mergetoolsdir))),)
2351mergetools_instdir = $(mergetoolsdir)
2352else
2353mergetools_instdir = $(prefix)/$(mergetoolsdir)
2354endif
2355mergetools_instdir_SQ = $(subst ','\'',$(mergetools_instdir))
2356
2357install_bindir_programs := $(patsubst %,%$X,$(BINDIR_PROGRAMS_NEED_X)) $(BINDIR_PROGRAMS_NO_X)
2358
2359install: all
2360        $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'
2361        $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
2362        $(INSTALL) $(ALL_PROGRAMS) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
2363        $(INSTALL) -m 644 $(SCRIPT_LIB) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
2364        $(INSTALL) $(install_bindir_programs) '$(DESTDIR_SQ)$(bindir_SQ)'
2365        $(MAKE) -C templates DESTDIR='$(DESTDIR_SQ)' install
2366        $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(mergetools_instdir_SQ)'
2367        $(INSTALL) -m 644 mergetools/* '$(DESTDIR_SQ)$(mergetools_instdir_SQ)'
2368ifndef NO_GETTEXT
2369        $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(localedir_SQ)'
2370        (cd po/build/locale && $(TAR) cf - .) | \
2371        (cd '$(DESTDIR_SQ)$(localedir_SQ)' && umask 022 && $(TAR) xof -)
2372endif
2373ifndef NO_PERL
2374        $(MAKE) -C perl prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' install
2375        $(MAKE) -C gitweb install
2376endif
2377ifndef NO_TCLTK
2378        $(MAKE) -C gitk-git install
2379        $(MAKE) -C git-gui gitexecdir='$(gitexec_instdir_SQ)' install
2380endif
2381ifneq (,$X)
2382        $(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';)
2383endif
2384
2385        bindir=$$(cd '$(DESTDIR_SQ)$(bindir_SQ)' && pwd) && \
2386        execdir=$$(cd '$(DESTDIR_SQ)$(gitexec_instdir_SQ)' && pwd) && \
2387        { test "$$bindir/" = "$$execdir/" || \
2388          for p in git$X $(filter $(install_bindir_programs),$(ALL_PROGRAMS)); do \
2389                $(RM) "$$execdir/$$p" && \
2390                test -z "$(NO_INSTALL_HARDLINKS)$(NO_CROSS_DIRECTORY_HARDLINKS)" && \
2391                ln "$$bindir/$$p" "$$execdir/$$p" 2>/dev/null || \
2392                cp "$$bindir/$$p" "$$execdir/$$p" || exit; \
2393          done; \
2394        } && \
2395        for p in $(filter $(install_bindir_programs),$(BUILT_INS)); do \
2396                $(RM) "$$bindir/$$p" && \
2397                test -z "$(NO_INSTALL_HARDLINKS)" && \
2398                ln "$$bindir/git$X" "$$bindir/$$p" 2>/dev/null || \
2399                ln -s "git$X" "$$bindir/$$p" 2>/dev/null || \
2400                cp "$$bindir/git$X" "$$bindir/$$p" || exit; \
2401        done && \
2402        for p in $(BUILT_INS); do \
2403                $(RM) "$$execdir/$$p" && \
2404                test -z "$(NO_INSTALL_HARDLINKS)" && \
2405                ln "$$execdir/git$X" "$$execdir/$$p" 2>/dev/null || \
2406                ln -s "git$X" "$$execdir/$$p" 2>/dev/null || \
2407                cp "$$execdir/git$X" "$$execdir/$$p" || exit; \
2408        done && \
2409        remote_curl_aliases="$(REMOTE_CURL_ALIASES)" && \
2410        for p in $$remote_curl_aliases; do \
2411                $(RM) "$$execdir/$$p" && \
2412                test -z "$(NO_INSTALL_HARDLINKS)" && \
2413                ln "$$execdir/git-remote-http$X" "$$execdir/$$p" 2>/dev/null || \
2414                ln -s "git-remote-http$X" "$$execdir/$$p" 2>/dev/null || \
2415                cp "$$execdir/git-remote-http$X" "$$execdir/$$p" || exit; \
2416        done && \
2417        ./check_bindir "z$$bindir" "z$$execdir" "$$bindir/git-add$X"
2418
2419install-gitweb:
2420        $(MAKE) -C gitweb install
2421
2422install-doc:
2423        $(MAKE) -C Documentation install
2424
2425install-man:
2426        $(MAKE) -C Documentation install-man
2427
2428install-html:
2429        $(MAKE) -C Documentation install-html
2430
2431install-info:
2432        $(MAKE) -C Documentation install-info
2433
2434install-pdf:
2435        $(MAKE) -C Documentation install-pdf
2436
2437quick-install-doc:
2438        $(MAKE) -C Documentation quick-install
2439
2440quick-install-man:
2441        $(MAKE) -C Documentation quick-install-man
2442
2443quick-install-html:
2444        $(MAKE) -C Documentation quick-install-html
2445
2446
2447
2448### Maintainer's dist rules
2449
2450git.spec: git.spec.in GIT-VERSION-FILE
2451        sed -e 's/@@VERSION@@/$(GIT_VERSION)/g' < $< > $@+
2452        mv $@+ $@
2453
2454GIT_TARNAME = git-$(GIT_VERSION)
2455dist: git.spec git-archive$(X) configure
2456        ./git-archive --format=tar \
2457                --prefix=$(GIT_TARNAME)/ HEAD^{tree} > $(GIT_TARNAME).tar
2458        @mkdir -p $(GIT_TARNAME)
2459        @cp git.spec configure $(GIT_TARNAME)
2460        @echo $(GIT_VERSION) > $(GIT_TARNAME)/version
2461        @$(MAKE) -C git-gui TARDIR=../$(GIT_TARNAME)/git-gui dist-version
2462        $(TAR) rf $(GIT_TARNAME).tar \
2463                $(GIT_TARNAME)/git.spec \
2464                $(GIT_TARNAME)/configure \
2465                $(GIT_TARNAME)/version \
2466                $(GIT_TARNAME)/git-gui/version
2467        @$(RM) -r $(GIT_TARNAME)
2468        gzip -f -9 $(GIT_TARNAME).tar
2469
2470rpm: dist
2471        $(RPMBUILD) \
2472                --define "_source_filedigest_algorithm md5" \
2473                --define "_binary_filedigest_algorithm md5" \
2474                -ta $(GIT_TARNAME).tar.gz
2475
2476htmldocs = git-htmldocs-$(GIT_VERSION)
2477manpages = git-manpages-$(GIT_VERSION)
2478dist-doc:
2479        $(RM) -r .doc-tmp-dir
2480        mkdir .doc-tmp-dir
2481        $(MAKE) -C Documentation WEBDOC_DEST=../.doc-tmp-dir install-webdoc
2482        cd .doc-tmp-dir && $(TAR) cf ../$(htmldocs).tar .
2483        gzip -n -9 -f $(htmldocs).tar
2484        :
2485        $(RM) -r .doc-tmp-dir
2486        mkdir -p .doc-tmp-dir/man1 .doc-tmp-dir/man5 .doc-tmp-dir/man7
2487        $(MAKE) -C Documentation DESTDIR=./ \
2488                man1dir=../.doc-tmp-dir/man1 \
2489                man5dir=../.doc-tmp-dir/man5 \
2490                man7dir=../.doc-tmp-dir/man7 \
2491                install
2492        cd .doc-tmp-dir && $(TAR) cf ../$(manpages).tar .
2493        gzip -n -9 -f $(manpages).tar
2494        $(RM) -r .doc-tmp-dir
2495
2496### Cleaning rules
2497
2498distclean: clean
2499        $(RM) configure
2500        $(RM) config.log config.status config.cache
2501        $(RM) config.mak.autogen config.mak.append
2502        $(RM) -r autom4te.cache
2503
2504profile-clean:
2505        $(RM) $(addsuffix *.gcda,$(addprefix $(PROFILE_DIR)/, $(object_dirs)))
2506        $(RM) $(addsuffix *.gcno,$(addprefix $(PROFILE_DIR)/, $(object_dirs)))
2507
2508clean: profile-clean coverage-clean
2509        $(RM) *.o *.res block-sha1/*.o ppc/*.o compat/*.o compat/*/*.o
2510        $(RM) xdiff/*.o vcs-svn/*.o ewah/*.o builtin/*.o
2511        $(RM) $(LIB_FILE) $(XDIFF_LIB) $(VCSSVN_LIB)
2512        $(RM) $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) git$X
2513        $(RM) $(TEST_PROGRAMS) $(NO_INSTALL)
2514        $(RM) -r bin-wrappers $(dep_dirs)
2515        $(RM) -r po/build/
2516        $(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo common-cmds.h $(ETAGS_TARGET) tags cscope*
2517        $(RM) -r $(GIT_TARNAME) .doc-tmp-dir
2518        $(RM) $(GIT_TARNAME).tar.gz git-core_$(GIT_VERSION)-*.tar.gz
2519        $(RM) $(htmldocs).tar.gz $(manpages).tar.gz
2520        $(MAKE) -C Documentation/ clean
2521ifndef NO_PERL
2522        $(MAKE) -C gitweb clean
2523        $(MAKE) -C perl clean
2524endif
2525        $(MAKE) -C templates/ clean
2526        $(MAKE) -C t/ clean
2527ifndef NO_TCLTK
2528        $(MAKE) -C gitk-git clean
2529        $(MAKE) -C git-gui clean
2530endif
2531        $(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-LDFLAGS GIT-BUILD-OPTIONS
2532        $(RM) GIT-USER-AGENT GIT-PREFIX
2533        $(RM) GIT-SCRIPT-DEFINES GIT-PERL-DEFINES GIT-PYTHON-VARS
2534
2535.PHONY: all install profile-clean clean strip
2536.PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell
2537.PHONY: FORCE cscope
2538
2539### Check documentation
2540#
2541ALL_COMMANDS = $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS)
2542ALL_COMMANDS += git
2543ALL_COMMANDS += gitk
2544ALL_COMMANDS += gitweb
2545ALL_COMMANDS += git-gui git-citool
2546check-docs::
2547        @(for v in $(ALL_COMMANDS); \
2548        do \
2549                case "$$v" in \
2550                git-merge-octopus | git-merge-ours | git-merge-recursive | \
2551                git-merge-resolve | git-merge-subtree | \
2552                git-fsck-objects | git-init-db | \
2553                git-remote-* | git-stage | \
2554                git-?*--?* ) continue ;; \
2555                esac ; \
2556                test -f "Documentation/$$v.txt" || \
2557                echo "no doc: $$v"; \
2558                sed -e '/^#/d' command-list.txt | \
2559                grep -q "^$$v[  ]" || \
2560                case "$$v" in \
2561                git) ;; \
2562                *) echo "no link: $$v";; \
2563                esac ; \
2564        done; \
2565        ( \
2566                sed -e '/^#/d' \
2567                    -e 's/[     ].*//' \
2568                    -e 's/^/listed /' command-list.txt; \
2569                $(MAKE) -C Documentation print-man1 | \
2570                grep '\.txt$$' | \
2571                sed -e 's|Documentation/|documented |' \
2572                    -e 's/\.txt//'; \
2573        ) | while read how cmd; \
2574        do \
2575                case " $(ALL_COMMANDS) " in \
2576                *" $$cmd "*)    ;; \
2577                *) echo "removed but $$how: $$cmd" ;; \
2578                esac; \
2579        done ) | sort
2580
2581### Make sure built-ins do not have dups and listed in git.c
2582#
2583check-builtins::
2584        ./check-builtins.sh
2585
2586### Test suite coverage testing
2587#
2588.PHONY: coverage coverage-clean coverage-compile coverage-test coverage-report
2589.PHONY: coverage-clean-results
2590
2591coverage:
2592        $(MAKE) coverage-test
2593        $(MAKE) coverage-untested-functions
2594
2595object_dirs := $(sort $(dir $(OBJECTS)))
2596coverage-clean-results:
2597        $(RM) $(addsuffix *.gcov,$(object_dirs))
2598        $(RM) $(addsuffix *.gcda,$(object_dirs))
2599        $(RM) coverage-untested-functions
2600        $(RM) -r cover_db/
2601        $(RM) -r cover_db_html/
2602
2603coverage-clean: coverage-clean-results
2604        $(RM) $(addsuffix *.gcno,$(object_dirs))
2605
2606COVERAGE_CFLAGS = $(CFLAGS) -O0 -ftest-coverage -fprofile-arcs
2607COVERAGE_LDFLAGS = $(CFLAGS)  -O0 -lgcov
2608GCOVFLAGS = --preserve-paths --branch-probabilities --all-blocks
2609
2610coverage-compile:
2611        $(MAKE) CFLAGS="$(COVERAGE_CFLAGS)" LDFLAGS="$(COVERAGE_LDFLAGS)" all
2612
2613coverage-test: coverage-clean-results coverage-compile
2614        $(MAKE) CFLAGS="$(COVERAGE_CFLAGS)" LDFLAGS="$(COVERAGE_LDFLAGS)" \
2615                DEFAULT_TEST_TARGET=test -j1 test
2616
2617coverage-report:
2618        $(QUIET_GCOV)for dir in $(object_dirs); do \
2619                $(GCOV) $(GCOVFLAGS) --object-directory=$$dir $$dir*.c || exit; \
2620        done
2621
2622coverage-untested-functions: coverage-report
2623        grep '^function.*called 0 ' *.c.gcov \
2624                | sed -e 's/\([^:]*\)\.gcov: *function \([^ ]*\) called.*/\1: \2/' \
2625                > coverage-untested-functions
2626
2627cover_db: coverage-report
2628        gcov2perl -db cover_db *.gcov
2629
2630cover_db_html: cover_db
2631        cover -report html -outputdir cover_db_html cover_db
2632