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