Makefileon commit Add history graph API (c12172d)
   1# The default target of this Makefile is...
   2all::
   3
   4# Define V=1 to have a more verbose compile.
   5#
   6# Define SNPRINTF_RETURNS_BOGUS if your are on a system which snprintf()
   7# or vsnprintf() return -1 instead of number of characters which would
   8# have been written to the final string if enough space had been available.
   9#
  10# Define FREAD_READS_DIRECTORIES if your are on a system which succeeds
  11# when attempting to read from an fopen'ed directory.
  12#
  13# Define NO_OPENSSL environment variable if you do not have OpenSSL.
  14# This also implies MOZILLA_SHA1.
  15#
  16# Define NO_CURL if you do not have curl installed.  git-http-pull and
  17# git-http-push are not built, and you cannot use http:// and https://
  18# transports.
  19#
  20# Define CURLDIR=/foo/bar if your curl header and library files are in
  21# /foo/bar/include and /foo/bar/lib directories.
  22#
  23# Define NO_EXPAT if you do not have expat installed.  git-http-push is
  24# not built, and you cannot push using http:// and https:// transports.
  25#
  26# Define NO_D_INO_IN_DIRENT if you don't have d_ino in your struct dirent.
  27#
  28# Define NO_D_TYPE_IN_DIRENT if your platform defines DT_UNKNOWN but lacks
  29# d_type in struct dirent (latest Cygwin -- will be fixed soonish).
  30#
  31# Define NO_C99_FORMAT if your formatted IO functions (printf/scanf et.al.)
  32# do not support the 'size specifiers' introduced by C99, namely ll, hh,
  33# j, z, t. (representing long long int, char, intmax_t, size_t, ptrdiff_t).
  34# some C compilers supported these specifiers prior to C99 as an extension.
  35#
  36# Define NO_STRCASESTR if you don't have strcasestr.
  37#
  38# Define NO_MEMMEM if you don't have memmem.
  39#
  40# Define NO_STRLCPY if you don't have strlcpy.
  41#
  42# Define NO_STRTOUMAX if you don't have strtoumax in the C library.
  43# If your compiler also does not support long long or does not have
  44# strtoull, define NO_STRTOULL.
  45#
  46# Define NO_SETENV if you don't have setenv in the C library.
  47#
  48# Define NO_UNSETENV if you don't have unsetenv in the C library.
  49#
  50# Define NO_MKDTEMP if you don't have mkdtemp in the C library.
  51#
  52# Define NO_SYS_SELECT_H if you don't have sys/select.h.
  53#
  54# Define NO_SYMLINK_HEAD if you never want .git/HEAD to be a symbolic link.
  55# Enable it on Windows.  By default, symrefs are still used.
  56#
  57# Define NO_SVN_TESTS if you want to skip time-consuming SVN interoperability
  58# tests.  These tests take up a significant amount of the total test time
  59# but are not needed unless you plan to talk to SVN repos.
  60#
  61# Define NO_FINK if you are building on Darwin/Mac OS X, have Fink
  62# installed in /sw, but don't want GIT to link against any libraries
  63# installed there.  If defined you may specify your own (or Fink's)
  64# include directories and library directories by defining CFLAGS
  65# and LDFLAGS appropriately.
  66#
  67# Define NO_DARWIN_PORTS if you are building on Darwin/Mac OS X,
  68# have DarwinPorts installed in /opt/local, but don't want GIT to
  69# link against any libraries installed there.  If defined you may
  70# specify your own (or DarwinPort's) include directories and
  71# library directories by defining CFLAGS and LDFLAGS appropriately.
  72#
  73# Define PPC_SHA1 environment variable when running make to make use of
  74# a bundled SHA1 routine optimized for PowerPC.
  75#
  76# Define ARM_SHA1 environment variable when running make to make use of
  77# a bundled SHA1 routine optimized for ARM.
  78#
  79# Define MOZILLA_SHA1 environment variable when running make to make use of
  80# a bundled SHA1 routine coming from Mozilla. It is GPL'd and should be fast
  81# on non-x86 architectures (e.g. PowerPC), while the OpenSSL version (default
  82# choice) has very fast version optimized for i586.
  83#
  84# Define NEEDS_SSL_WITH_CRYPTO if you need -lcrypto with -lssl (Darwin).
  85#
  86# Define NEEDS_LIBICONV if linking with libc is not enough (Darwin).
  87#
  88# Define NEEDS_SOCKET if linking with libc is not enough (SunOS,
  89# Patrick Mauritz).
  90#
  91# Define NO_MMAP if you want to avoid mmap.
  92#
  93# Define NO_PREAD if you have a problem with pread() system call (e.g.
  94# cygwin.dll before v1.5.22).
  95#
  96# Define NO_FAST_WORKING_DIRECTORY if accessing objects in pack files is
  97# generally faster on your platform than accessing the working directory.
  98#
  99# Define NO_TRUSTABLE_FILEMODE if your filesystem may claim to support
 100# the executable mode bit, but doesn't really do so.
 101#
 102# Define NO_IPV6 if you lack IPv6 support and getaddrinfo().
 103#
 104# Define NO_SOCKADDR_STORAGE if your platform does not have struct
 105# sockaddr_storage.
 106#
 107# Define NO_ICONV if your libc does not properly support iconv.
 108#
 109# Define OLD_ICONV if your library has an old iconv(), where the second
 110# (input buffer pointer) parameter is declared with type (const char **).
 111#
 112# Define NO_DEFLATE_BOUND if your zlib does not have deflateBound.
 113#
 114# Define NO_R_TO_GCC_LINKER if your gcc does not like "-R/path/lib"
 115# that tells runtime paths to dynamic libraries;
 116# "-Wl,-rpath=/path/lib" is used instead.
 117#
 118# Define USE_NSEC below if you want git to care about sub-second file mtimes
 119# and ctimes. Note that you need recent glibc (at least 2.2.4) for this, and
 120# it will BREAK YOUR LOCAL DIFFS! show-diff and anything using it will likely
 121# randomly break unless your underlying filesystem supports those sub-second
 122# times (my ext3 doesn't).
 123#
 124# Define USE_STDEV below if you want git to care about the underlying device
 125# change being considered an inode change from the update-index perspective.
 126#
 127# Define ASCIIDOC8 if you want to format documentation with AsciiDoc 8
 128#
 129# Define DOCBOOK_XSL_172 if you want to format man pages with DocBook XSL v1.72.
 130#
 131# Define NO_PERL_MAKEMAKER if you cannot use Makefiles generated by perl's
 132# MakeMaker (e.g. using ActiveState under Cygwin).
 133#
 134# Define NO_TCLTK if you do not want Tcl/Tk GUI.
 135#
 136# The TCL_PATH variable governs the location of the Tcl interpreter
 137# used to optimize git-gui for your system.  Only used if NO_TCLTK
 138# is not set.  Defaults to the bare 'tclsh'.
 139#
 140# The TCLTK_PATH variable governs the location of the Tcl/Tk interpreter.
 141# If not set it defaults to the bare 'wish'. If it is set to the empty
 142# string then NO_TCLTK will be forced (this is used by configure script).
 143#
 144# Define THREADED_DELTA_SEARCH if you have pthreads and wish to exploit
 145# parallel delta searching when packing objects.
 146#
 147# Define INTERNAL_QSORT to use Git's implementation of qsort(), which
 148# is a simplified version of the merge sort used in glibc. This is
 149# recommended if Git triggers O(n^2) behavior in your platform's qsort().
 150#
 151# Define NO_EXTERNAL_GREP if you don't want "git grep" to ever call
 152# your external grep (e.g., if your system lacks grep, if its grep is
 153# broken, or spawning external process is slower than built-in grep git has).
 154
 155GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
 156        @$(SHELL_PATH) ./GIT-VERSION-GEN
 157-include GIT-VERSION-FILE
 158
 159uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
 160uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not')
 161uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')
 162uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not')
 163uname_P := $(shell sh -c 'uname -p 2>/dev/null || echo not')
 164
 165# CFLAGS and LDFLAGS are for the users to override from the command line.
 166
 167CFLAGS = -g -O2 -Wall
 168LDFLAGS =
 169ALL_CFLAGS = $(CFLAGS)
 170ALL_LDFLAGS = $(LDFLAGS)
 171STRIP ?= strip
 172
 173prefix = $(HOME)
 174bindir = $(prefix)/bin
 175mandir = $(prefix)/share/man
 176infodir = $(prefix)/share/info
 177gitexecdir = $(bindir)
 178sharedir = $(prefix)/share
 179template_dir = $(sharedir)/git-core/templates
 180htmldir=$(sharedir)/doc/git-doc
 181ifeq ($(prefix),/usr)
 182sysconfdir = /etc
 183else
 184sysconfdir = $(prefix)/etc
 185endif
 186lib = lib
 187ETC_GITCONFIG = $(sysconfdir)/gitconfig
 188# DESTDIR=
 189
 190# default configuration for gitweb
 191GITWEB_CONFIG = gitweb_config.perl
 192GITWEB_CONFIG_SYSTEM = /etc/gitweb.conf
 193GITWEB_HOME_LINK_STR = projects
 194GITWEB_SITENAME =
 195GITWEB_PROJECTROOT = /pub/git
 196GITWEB_PROJECT_MAXDEPTH = 2007
 197GITWEB_EXPORT_OK =
 198GITWEB_STRICT_EXPORT =
 199GITWEB_BASE_URL =
 200GITWEB_LIST =
 201GITWEB_HOMETEXT = indextext.html
 202GITWEB_CSS = gitweb.css
 203GITWEB_LOGO = git-logo.png
 204GITWEB_FAVICON = git-favicon.png
 205GITWEB_SITE_HEADER =
 206GITWEB_SITE_FOOTER =
 207
 208export prefix bindir gitexecdir sharedir template_dir htmldir sysconfdir
 209
 210CC = gcc
 211AR = ar
 212RM = rm -f
 213TAR = tar
 214FIND = find
 215INSTALL = install
 216RPMBUILD = rpmbuild
 217TCL_PATH = tclsh
 218TCLTK_PATH = wish
 219
 220export TCL_PATH TCLTK_PATH
 221
 222# sparse is architecture-neutral, which means that we need to tell it
 223# explicitly what architecture to check for. Fix this up for yours..
 224SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
 225
 226
 227
 228### --- END CONFIGURATION SECTION ---
 229
 230# Those must not be GNU-specific; they are shared with perl/ which may
 231# be built by a different compiler. (Note that this is an artifact now
 232# but it still might be nice to keep that distinction.)
 233BASIC_CFLAGS =
 234BASIC_LDFLAGS =
 235
 236SCRIPT_SH += git-am.sh
 237SCRIPT_SH += git-bisect.sh
 238SCRIPT_SH += git-clone.sh
 239SCRIPT_SH += git-filter-branch.sh
 240SCRIPT_SH += git-lost-found.sh
 241SCRIPT_SH += git-merge-octopus.sh
 242SCRIPT_SH += git-merge-one-file.sh
 243SCRIPT_SH += git-merge-resolve.sh
 244SCRIPT_SH += git-merge.sh
 245SCRIPT_SH += git-merge-stupid.sh
 246SCRIPT_SH += git-mergetool.sh
 247SCRIPT_SH += git-parse-remote.sh
 248SCRIPT_SH += git-pull.sh
 249SCRIPT_SH += git-quiltimport.sh
 250SCRIPT_SH += git-rebase--interactive.sh
 251SCRIPT_SH += git-rebase.sh
 252SCRIPT_SH += git-repack.sh
 253SCRIPT_SH += git-request-pull.sh
 254SCRIPT_SH += git-sh-setup.sh
 255SCRIPT_SH += git-stash.sh
 256SCRIPT_SH += git-submodule.sh
 257SCRIPT_SH += git-web--browse.sh
 258
 259SCRIPT_PERL += git-add--interactive.perl
 260SCRIPT_PERL += git-archimport.perl
 261SCRIPT_PERL += git-cvsexportcommit.perl
 262SCRIPT_PERL += git-cvsimport.perl
 263SCRIPT_PERL += git-cvsserver.perl
 264SCRIPT_PERL += git-relink.perl
 265SCRIPT_PERL += git-send-email.perl
 266SCRIPT_PERL += git-svn.perl
 267
 268SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \
 269          $(patsubst %.perl,%,$(SCRIPT_PERL)) \
 270          git-instaweb
 271
 272# Empty...
 273EXTRA_PROGRAMS =
 274
 275# ... and all the rest that could be moved out of bindir to gitexecdir
 276PROGRAMS += $(EXTRA_PROGRAMS)
 277PROGRAMS += git-daemon$X
 278PROGRAMS += git-fast-import$X
 279PROGRAMS += git-fetch-pack$X
 280PROGRAMS += git-hash-object$X
 281PROGRAMS += git-imap-send$X
 282PROGRAMS += git-index-pack$X
 283PROGRAMS += git-merge-index$X
 284PROGRAMS += git-merge-tree$X
 285PROGRAMS += git-mktag$X
 286PROGRAMS += git-mktree$X
 287PROGRAMS += git-pack-redundant$X
 288PROGRAMS += git-patch-id$X
 289PROGRAMS += git-receive-pack$X
 290PROGRAMS += git-send-pack$X
 291PROGRAMS += git-shell$X
 292PROGRAMS += git-show-index$X
 293PROGRAMS += git-unpack-file$X
 294PROGRAMS += git-update-server-info$X
 295PROGRAMS += git-upload-pack$X
 296PROGRAMS += git-var$X
 297
 298# List built-in command $C whose implementation cmd_$C() is not in
 299# builtin-$C.o but is linked in as part of some other command.
 300BUILT_INS += $(patsubst builtin-%.o,git-%$X,$(BUILTIN_OBJS))
 301
 302BUILT_INS += git-cherry-pick$X
 303BUILT_INS += git-cherry$X
 304BUILT_INS += git-format-patch$X
 305BUILT_INS += git-fsck-objects$X
 306BUILT_INS += git-get-tar-commit-id$X
 307BUILT_INS += git-init$X
 308BUILT_INS += git-merge-subtree$X
 309BUILT_INS += git-peek-remote$X
 310BUILT_INS += git-repo-config$X
 311BUILT_INS += git-show$X
 312BUILT_INS += git-status$X
 313BUILT_INS += git-whatchanged$X
 314
 315# what 'all' will build and 'install' will install, in gitexecdir
 316ALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS)
 317
 318# what 'all' will build but not install in gitexecdir
 319OTHER_PROGRAMS = git$X gitweb/gitweb.cgi
 320
 321# Set paths to tools early so that they can be used for version tests.
 322ifndef SHELL_PATH
 323        SHELL_PATH = /bin/sh
 324endif
 325ifndef PERL_PATH
 326        PERL_PATH = /usr/bin/perl
 327endif
 328
 329export PERL_PATH
 330
 331LIB_FILE=libgit.a
 332XDIFF_LIB=xdiff/lib.a
 333
 334LIB_H += archive.h
 335LIB_H += attr.h
 336LIB_H += blob.h
 337LIB_H += builtin.h
 338LIB_H += cache.h
 339LIB_H += cache-tree.h
 340LIB_H += commit.h
 341LIB_H += csum-file.h
 342LIB_H += decorate.h
 343LIB_H += delta.h
 344LIB_H += diffcore.h
 345LIB_H += diff.h
 346LIB_H += dir.h
 347LIB_H += fsck.h
 348LIB_H += git-compat-util.h
 349LIB_H += graph.h
 350LIB_H += grep.h
 351LIB_H += hash.h
 352LIB_H += list-objects.h
 353LIB_H += ll-merge.h
 354LIB_H += log-tree.h
 355LIB_H += mailmap.h
 356LIB_H += object.h
 357LIB_H += pack.h
 358LIB_H += pack-revindex.h
 359LIB_H += parse-options.h
 360LIB_H += patch-ids.h
 361LIB_H += path-list.h
 362LIB_H += pkt-line.h
 363LIB_H += progress.h
 364LIB_H += quote.h
 365LIB_H += reflog-walk.h
 366LIB_H += refs.h
 367LIB_H += remote.h
 368LIB_H += revision.h
 369LIB_H += run-command.h
 370LIB_H += sha1-lookup.h
 371LIB_H += sideband.h
 372LIB_H += strbuf.h
 373LIB_H += tag.h
 374LIB_H += transport.h
 375LIB_H += tree.h
 376LIB_H += tree-walk.h
 377LIB_H += unpack-trees.h
 378LIB_H += utf8.h
 379
 380LIB_OBJS += alias.o
 381LIB_OBJS += alloc.o
 382LIB_OBJS += archive.o
 383LIB_OBJS += archive-tar.o
 384LIB_OBJS += archive-zip.o
 385LIB_OBJS += attr.o
 386LIB_OBJS += base85.o
 387LIB_OBJS += blob.o
 388LIB_OBJS += branch.o
 389LIB_OBJS += bundle.o
 390LIB_OBJS += cache-tree.o
 391LIB_OBJS += color.o
 392LIB_OBJS += combine-diff.o
 393LIB_OBJS += commit.o
 394LIB_OBJS += config.o
 395LIB_OBJS += connect.o
 396LIB_OBJS += convert.o
 397LIB_OBJS += copy.o
 398LIB_OBJS += csum-file.o
 399LIB_OBJS += ctype.o
 400LIB_OBJS += date.o
 401LIB_OBJS += decorate.o
 402LIB_OBJS += diffcore-break.o
 403LIB_OBJS += diffcore-delta.o
 404LIB_OBJS += diffcore-order.o
 405LIB_OBJS += diffcore-pickaxe.o
 406LIB_OBJS += diffcore-rename.o
 407LIB_OBJS += diff-delta.o
 408LIB_OBJS += diff-lib.o
 409LIB_OBJS += diff.o
 410LIB_OBJS += dir.o
 411LIB_OBJS += entry.o
 412LIB_OBJS += environment.o
 413LIB_OBJS += exec_cmd.o
 414LIB_OBJS += fsck.o
 415LIB_OBJS += graph.o
 416LIB_OBJS += grep.o
 417LIB_OBJS += hash.o
 418LIB_OBJS += help.o
 419LIB_OBJS += ident.o
 420LIB_OBJS += interpolate.o
 421LIB_OBJS += list-objects.o
 422LIB_OBJS += ll-merge.o
 423LIB_OBJS += lockfile.o
 424LIB_OBJS += log-tree.o
 425LIB_OBJS += mailmap.o
 426LIB_OBJS += match-trees.o
 427LIB_OBJS += merge-file.o
 428LIB_OBJS += object.o
 429LIB_OBJS += pack-check.o
 430LIB_OBJS += pack-revindex.o
 431LIB_OBJS += pack-write.o
 432LIB_OBJS += pager.o
 433LIB_OBJS += parse-options.o
 434LIB_OBJS += patch-delta.o
 435LIB_OBJS += patch-ids.o
 436LIB_OBJS += path-list.o
 437LIB_OBJS += path.o
 438LIB_OBJS += pkt-line.o
 439LIB_OBJS += pretty.o
 440LIB_OBJS += progress.o
 441LIB_OBJS += quote.o
 442LIB_OBJS += reachable.o
 443LIB_OBJS += read-cache.o
 444LIB_OBJS += reflog-walk.o
 445LIB_OBJS += refs.o
 446LIB_OBJS += remote.o
 447LIB_OBJS += revision.o
 448LIB_OBJS += run-command.o
 449LIB_OBJS += server-info.o
 450LIB_OBJS += setup.o
 451LIB_OBJS += sha1_file.o
 452LIB_OBJS += sha1-lookup.o
 453LIB_OBJS += sha1_name.o
 454LIB_OBJS += shallow.o
 455LIB_OBJS += sideband.o
 456LIB_OBJS += strbuf.o
 457LIB_OBJS += symlinks.o
 458LIB_OBJS += tag.o
 459LIB_OBJS += trace.o
 460LIB_OBJS += transport.o
 461LIB_OBJS += tree-diff.o
 462LIB_OBJS += tree.o
 463LIB_OBJS += tree-walk.o
 464LIB_OBJS += unpack-trees.o
 465LIB_OBJS += usage.o
 466LIB_OBJS += utf8.o
 467LIB_OBJS += walker.o
 468LIB_OBJS += write_or_die.o
 469LIB_OBJS += ws.o
 470LIB_OBJS += wt-status.o
 471LIB_OBJS += xdiff-interface.o
 472
 473BUILTIN_OBJS += builtin-add.o
 474BUILTIN_OBJS += builtin-annotate.o
 475BUILTIN_OBJS += builtin-apply.o
 476BUILTIN_OBJS += builtin-archive.o
 477BUILTIN_OBJS += builtin-blame.o
 478BUILTIN_OBJS += builtin-branch.o
 479BUILTIN_OBJS += builtin-bundle.o
 480BUILTIN_OBJS += builtin-cat-file.o
 481BUILTIN_OBJS += builtin-check-attr.o
 482BUILTIN_OBJS += builtin-check-ref-format.o
 483BUILTIN_OBJS += builtin-checkout-index.o
 484BUILTIN_OBJS += builtin-checkout.o
 485BUILTIN_OBJS += builtin-clean.o
 486BUILTIN_OBJS += builtin-commit-tree.o
 487BUILTIN_OBJS += builtin-commit.o
 488BUILTIN_OBJS += builtin-config.o
 489BUILTIN_OBJS += builtin-count-objects.o
 490BUILTIN_OBJS += builtin-describe.o
 491BUILTIN_OBJS += builtin-diff-files.o
 492BUILTIN_OBJS += builtin-diff-index.o
 493BUILTIN_OBJS += builtin-diff-tree.o
 494BUILTIN_OBJS += builtin-diff.o
 495BUILTIN_OBJS += builtin-fast-export.o
 496BUILTIN_OBJS += builtin-fetch--tool.o
 497BUILTIN_OBJS += builtin-fetch-pack.o
 498BUILTIN_OBJS += builtin-fetch.o
 499BUILTIN_OBJS += builtin-fmt-merge-msg.o
 500BUILTIN_OBJS += builtin-for-each-ref.o
 501BUILTIN_OBJS += builtin-fsck.o
 502BUILTIN_OBJS += builtin-gc.o
 503BUILTIN_OBJS += builtin-grep.o
 504BUILTIN_OBJS += builtin-init-db.o
 505BUILTIN_OBJS += builtin-log.o
 506BUILTIN_OBJS += builtin-ls-files.o
 507BUILTIN_OBJS += builtin-ls-remote.o
 508BUILTIN_OBJS += builtin-ls-tree.o
 509BUILTIN_OBJS += builtin-mailinfo.o
 510BUILTIN_OBJS += builtin-mailsplit.o
 511BUILTIN_OBJS += builtin-merge-base.o
 512BUILTIN_OBJS += builtin-merge-file.o
 513BUILTIN_OBJS += builtin-merge-ours.o
 514BUILTIN_OBJS += builtin-merge-recursive.o
 515BUILTIN_OBJS += builtin-mv.o
 516BUILTIN_OBJS += builtin-name-rev.o
 517BUILTIN_OBJS += builtin-pack-objects.o
 518BUILTIN_OBJS += builtin-pack-refs.o
 519BUILTIN_OBJS += builtin-prune-packed.o
 520BUILTIN_OBJS += builtin-prune.o
 521BUILTIN_OBJS += builtin-push.o
 522BUILTIN_OBJS += builtin-read-tree.o
 523BUILTIN_OBJS += builtin-reflog.o
 524BUILTIN_OBJS += builtin-remote.o
 525BUILTIN_OBJS += builtin-rerere.o
 526BUILTIN_OBJS += builtin-reset.o
 527BUILTIN_OBJS += builtin-rev-list.o
 528BUILTIN_OBJS += builtin-rev-parse.o
 529BUILTIN_OBJS += builtin-revert.o
 530BUILTIN_OBJS += builtin-rm.o
 531BUILTIN_OBJS += builtin-send-pack.o
 532BUILTIN_OBJS += builtin-shortlog.o
 533BUILTIN_OBJS += builtin-show-branch.o
 534BUILTIN_OBJS += builtin-show-ref.o
 535BUILTIN_OBJS += builtin-stripspace.o
 536BUILTIN_OBJS += builtin-symbolic-ref.o
 537BUILTIN_OBJS += builtin-tag.o
 538BUILTIN_OBJS += builtin-tar-tree.o
 539BUILTIN_OBJS += builtin-unpack-objects.o
 540BUILTIN_OBJS += builtin-update-index.o
 541BUILTIN_OBJS += builtin-update-ref.o
 542BUILTIN_OBJS += builtin-upload-archive.o
 543BUILTIN_OBJS += builtin-verify-pack.o
 544BUILTIN_OBJS += builtin-verify-tag.o
 545BUILTIN_OBJS += builtin-write-tree.o
 546
 547GITLIBS = $(LIB_FILE) $(XDIFF_LIB)
 548EXTLIBS =
 549
 550#
 551# Platform specific tweaks
 552#
 553
 554# We choose to avoid "if .. else if .. else .. endif endif"
 555# because maintaining the nesting to match is a pain.  If
 556# we had "elif" things would have been much nicer...
 557
 558ifeq ($(uname_S),Linux)
 559        NO_STRLCPY = YesPlease
 560endif
 561ifeq ($(uname_S),GNU/kFreeBSD)
 562        NO_STRLCPY = YesPlease
 563endif
 564ifeq ($(uname_S),Darwin)
 565        NEEDS_SSL_WITH_CRYPTO = YesPlease
 566        NEEDS_LIBICONV = YesPlease
 567        ifneq ($(shell expr "$(uname_R)" : '9\.'),2)
 568                OLD_ICONV = UnfortunatelyYes
 569        endif
 570        NO_STRLCPY = YesPlease
 571        NO_MEMMEM = YesPlease
 572endif
 573ifeq ($(uname_S),SunOS)
 574        NEEDS_SOCKET = YesPlease
 575        NEEDS_NSL = YesPlease
 576        SHELL_PATH = /bin/bash
 577        NO_STRCASESTR = YesPlease
 578        NO_MEMMEM = YesPlease
 579        NO_HSTRERROR = YesPlease
 580        NO_MKDTEMP = YesPlease
 581        ifeq ($(uname_R),5.8)
 582                NEEDS_LIBICONV = YesPlease
 583                NO_UNSETENV = YesPlease
 584                NO_SETENV = YesPlease
 585                NO_C99_FORMAT = YesPlease
 586                NO_STRTOUMAX = YesPlease
 587        endif
 588        ifeq ($(uname_R),5.9)
 589                NO_UNSETENV = YesPlease
 590                NO_SETENV = YesPlease
 591                NO_C99_FORMAT = YesPlease
 592                NO_STRTOUMAX = YesPlease
 593        endif
 594        INSTALL = ginstall
 595        TAR = gtar
 596        BASIC_CFLAGS += -D__EXTENSIONS__
 597endif
 598ifeq ($(uname_O),Cygwin)
 599        NO_D_TYPE_IN_DIRENT = YesPlease
 600        NO_D_INO_IN_DIRENT = YesPlease
 601        NO_STRCASESTR = YesPlease
 602        NO_MEMMEM = YesPlease
 603        NO_SYMLINK_HEAD = YesPlease
 604        NEEDS_LIBICONV = YesPlease
 605        NO_FAST_WORKING_DIRECTORY = UnfortunatelyYes
 606        NO_TRUSTABLE_FILEMODE = UnfortunatelyYes
 607        OLD_ICONV = UnfortunatelyYes
 608        # There are conflicting reports about this.
 609        # On some boxes NO_MMAP is needed, and not so elsewhere.
 610        # Try commenting this out if you suspect MMAP is more efficient
 611        NO_MMAP = YesPlease
 612        NO_IPV6 = YesPlease
 613        X = .exe
 614endif
 615ifeq ($(uname_S),FreeBSD)
 616        NEEDS_LIBICONV = YesPlease
 617        NO_MEMMEM = YesPlease
 618        BASIC_CFLAGS += -I/usr/local/include
 619        BASIC_LDFLAGS += -L/usr/local/lib
 620        DIR_HAS_BSD_GROUP_SEMANTICS = YesPlease
 621endif
 622ifeq ($(uname_S),OpenBSD)
 623        NO_STRCASESTR = YesPlease
 624        NO_MEMMEM = YesPlease
 625        NEEDS_LIBICONV = YesPlease
 626        BASIC_CFLAGS += -I/usr/local/include
 627        BASIC_LDFLAGS += -L/usr/local/lib
 628endif
 629ifeq ($(uname_S),NetBSD)
 630        ifeq ($(shell expr "$(uname_R)" : '[01]\.'),2)
 631                NEEDS_LIBICONV = YesPlease
 632        endif
 633        BASIC_CFLAGS += -I/usr/pkg/include
 634        BASIC_LDFLAGS += -L/usr/pkg/lib
 635        ALL_LDFLAGS += -Wl,-rpath,/usr/pkg/lib
 636endif
 637ifeq ($(uname_S),AIX)
 638        NO_STRCASESTR=YesPlease
 639        NO_MEMMEM = YesPlease
 640        NO_STRLCPY = YesPlease
 641        NEEDS_LIBICONV=YesPlease
 642endif
 643ifeq ($(uname_S),GNU)
 644        # GNU/Hurd
 645        NO_STRLCPY=YesPlease
 646endif
 647ifeq ($(uname_S),IRIX64)
 648        NO_IPV6=YesPlease
 649        NO_SETENV=YesPlease
 650        NO_STRCASESTR=YesPlease
 651        NO_MEMMEM = YesPlease
 652        NO_STRLCPY = YesPlease
 653        NO_SOCKADDR_STORAGE=YesPlease
 654        SHELL_PATH=/usr/gnu/bin/bash
 655        BASIC_CFLAGS += -DPATH_MAX=1024
 656        # for now, build 32-bit version
 657        BASIC_LDFLAGS += -L/usr/lib32
 658endif
 659ifeq ($(uname_S),HP-UX)
 660        NO_IPV6=YesPlease
 661        NO_SETENV=YesPlease
 662        NO_STRCASESTR=YesPlease
 663        NO_MEMMEM = YesPlease
 664        NO_STRLCPY = YesPlease
 665        NO_MKDTEMP = YesPlease
 666        NO_UNSETENV = YesPlease
 667        NO_HSTRERROR = YesPlease
 668        NO_SYS_SELECT_H = YesPlease
 669endif
 670ifneq (,$(findstring arm,$(uname_M)))
 671        ARM_SHA1 = YesPlease
 672endif
 673
 674-include config.mak.autogen
 675-include config.mak
 676
 677ifeq ($(uname_S),Darwin)
 678        ifndef NO_FINK
 679                ifeq ($(shell test -d /sw/lib && echo y),y)
 680                        BASIC_CFLAGS += -I/sw/include
 681                        BASIC_LDFLAGS += -L/sw/lib
 682                endif
 683        endif
 684        ifndef NO_DARWIN_PORTS
 685                ifeq ($(shell test -d /opt/local/lib && echo y),y)
 686                        BASIC_CFLAGS += -I/opt/local/include
 687                        BASIC_LDFLAGS += -L/opt/local/lib
 688                endif
 689        endif
 690endif
 691
 692ifdef NO_R_TO_GCC_LINKER
 693        # Some gcc does not accept and pass -R to the linker to specify
 694        # the runtime dynamic library path.
 695        CC_LD_DYNPATH = -Wl,-rpath=
 696else
 697        CC_LD_DYNPATH = -R
 698endif
 699
 700ifdef NO_CURL
 701        BASIC_CFLAGS += -DNO_CURL
 702else
 703        ifdef CURLDIR
 704                # Try "-Wl,-rpath=$(CURLDIR)/$(lib)" in such a case.
 705                BASIC_CFLAGS += -I$(CURLDIR)/include
 706                CURL_LIBCURL = -L$(CURLDIR)/$(lib) $(CC_LD_DYNPATH)$(CURLDIR)/$(lib) -lcurl
 707        else
 708                CURL_LIBCURL = -lcurl
 709        endif
 710        BUILTIN_OBJS += builtin-http-fetch.o
 711        EXTLIBS += $(CURL_LIBCURL)
 712        LIB_OBJS += http.o http-walker.o
 713        curl_check := $(shell (echo 070908; curl-config --vernum) | sort -r | sed -ne 2p)
 714        ifeq "$(curl_check)" "070908"
 715                ifndef NO_EXPAT
 716                        PROGRAMS += git-http-push$X
 717                endif
 718        endif
 719        ifndef NO_EXPAT
 720                EXPAT_LIBEXPAT = -lexpat
 721        endif
 722endif
 723
 724ifdef ZLIB_PATH
 725        BASIC_CFLAGS += -I$(ZLIB_PATH)/include
 726        EXTLIBS += -L$(ZLIB_PATH)/$(lib) $(CC_LD_DYNPATH)$(ZLIB_PATH)/$(lib)
 727endif
 728EXTLIBS += -lz
 729
 730ifndef NO_OPENSSL
 731        OPENSSL_LIBSSL = -lssl
 732        ifdef OPENSSLDIR
 733                BASIC_CFLAGS += -I$(OPENSSLDIR)/include
 734                OPENSSL_LINK = -L$(OPENSSLDIR)/$(lib) $(CC_LD_DYNPATH)$(OPENSSLDIR)/$(lib)
 735        else
 736                OPENSSL_LINK =
 737        endif
 738else
 739        BASIC_CFLAGS += -DNO_OPENSSL
 740        MOZILLA_SHA1 = 1
 741        OPENSSL_LIBSSL =
 742endif
 743ifdef NEEDS_SSL_WITH_CRYPTO
 744        LIB_4_CRYPTO = $(OPENSSL_LINK) -lcrypto -lssl
 745else
 746        LIB_4_CRYPTO = $(OPENSSL_LINK) -lcrypto
 747endif
 748ifdef NEEDS_LIBICONV
 749        ifdef ICONVDIR
 750                BASIC_CFLAGS += -I$(ICONVDIR)/include
 751                ICONV_LINK = -L$(ICONVDIR)/$(lib) $(CC_LD_DYNPATH)$(ICONVDIR)/$(lib)
 752        else
 753                ICONV_LINK =
 754        endif
 755        EXTLIBS += $(ICONV_LINK) -liconv
 756endif
 757ifdef NEEDS_SOCKET
 758        EXTLIBS += -lsocket
 759endif
 760ifdef NEEDS_NSL
 761        EXTLIBS += -lnsl
 762endif
 763ifdef NO_D_TYPE_IN_DIRENT
 764        BASIC_CFLAGS += -DNO_D_TYPE_IN_DIRENT
 765endif
 766ifdef NO_D_INO_IN_DIRENT
 767        BASIC_CFLAGS += -DNO_D_INO_IN_DIRENT
 768endif
 769ifdef NO_C99_FORMAT
 770        BASIC_CFLAGS += -DNO_C99_FORMAT
 771endif
 772ifdef SNPRINTF_RETURNS_BOGUS
 773        COMPAT_CFLAGS += -DSNPRINTF_RETURNS_BOGUS
 774        COMPAT_OBJS += compat/snprintf.o
 775endif
 776ifdef FREAD_READS_DIRECTORIES
 777        COMPAT_CFLAGS += -DFREAD_READS_DIRECTORIES
 778        COMPAT_OBJS += compat/fopen.o
 779endif
 780ifdef NO_SYMLINK_HEAD
 781        BASIC_CFLAGS += -DNO_SYMLINK_HEAD
 782endif
 783ifdef NO_STRCASESTR
 784        COMPAT_CFLAGS += -DNO_STRCASESTR
 785        COMPAT_OBJS += compat/strcasestr.o
 786endif
 787ifdef NO_STRLCPY
 788        COMPAT_CFLAGS += -DNO_STRLCPY
 789        COMPAT_OBJS += compat/strlcpy.o
 790endif
 791ifdef NO_STRTOUMAX
 792        COMPAT_CFLAGS += -DNO_STRTOUMAX
 793        COMPAT_OBJS += compat/strtoumax.o
 794endif
 795ifdef NO_STRTOULL
 796        COMPAT_CFLAGS += -DNO_STRTOULL
 797endif
 798ifdef NO_SETENV
 799        COMPAT_CFLAGS += -DNO_SETENV
 800        COMPAT_OBJS += compat/setenv.o
 801endif
 802ifdef NO_MKDTEMP
 803        COMPAT_CFLAGS += -DNO_MKDTEMP
 804        COMPAT_OBJS += compat/mkdtemp.o
 805endif
 806ifdef NO_UNSETENV
 807        COMPAT_CFLAGS += -DNO_UNSETENV
 808        COMPAT_OBJS += compat/unsetenv.o
 809endif
 810ifdef NO_SYS_SELECT_H
 811        BASIC_CFLAGS += -DNO_SYS_SELECT_H
 812endif
 813ifdef NO_MMAP
 814        COMPAT_CFLAGS += -DNO_MMAP
 815        COMPAT_OBJS += compat/mmap.o
 816endif
 817ifdef NO_PREAD
 818        COMPAT_CFLAGS += -DNO_PREAD
 819        COMPAT_OBJS += compat/pread.o
 820endif
 821ifdef NO_FAST_WORKING_DIRECTORY
 822        BASIC_CFLAGS += -DNO_FAST_WORKING_DIRECTORY
 823endif
 824ifdef NO_TRUSTABLE_FILEMODE
 825        BASIC_CFLAGS += -DNO_TRUSTABLE_FILEMODE
 826endif
 827ifdef NO_IPV6
 828        BASIC_CFLAGS += -DNO_IPV6
 829endif
 830ifdef NO_SOCKADDR_STORAGE
 831ifdef NO_IPV6
 832        BASIC_CFLAGS += -Dsockaddr_storage=sockaddr_in
 833else
 834        BASIC_CFLAGS += -Dsockaddr_storage=sockaddr_in6
 835endif
 836endif
 837ifdef NO_INET_NTOP
 838        LIB_OBJS += compat/inet_ntop.o
 839endif
 840ifdef NO_INET_PTON
 841        LIB_OBJS += compat/inet_pton.o
 842endif
 843
 844ifdef NO_ICONV
 845        BASIC_CFLAGS += -DNO_ICONV
 846endif
 847
 848ifdef OLD_ICONV
 849        BASIC_CFLAGS += -DOLD_ICONV
 850endif
 851
 852ifdef NO_DEFLATE_BOUND
 853        BASIC_CFLAGS += -DNO_DEFLATE_BOUND
 854endif
 855
 856ifdef PPC_SHA1
 857        SHA1_HEADER = "ppc/sha1.h"
 858        LIB_OBJS += ppc/sha1.o ppc/sha1ppc.o
 859else
 860ifdef ARM_SHA1
 861        SHA1_HEADER = "arm/sha1.h"
 862        LIB_OBJS += arm/sha1.o arm/sha1_arm.o
 863else
 864ifdef MOZILLA_SHA1
 865        SHA1_HEADER = "mozilla-sha1/sha1.h"
 866        LIB_OBJS += mozilla-sha1/sha1.o
 867else
 868        SHA1_HEADER = <openssl/sha.h>
 869        EXTLIBS += $(LIB_4_CRYPTO)
 870endif
 871endif
 872endif
 873ifdef NO_PERL_MAKEMAKER
 874        export NO_PERL_MAKEMAKER
 875endif
 876ifdef NO_HSTRERROR
 877        COMPAT_CFLAGS += -DNO_HSTRERROR
 878        COMPAT_OBJS += compat/hstrerror.o
 879endif
 880ifdef NO_MEMMEM
 881        COMPAT_CFLAGS += -DNO_MEMMEM
 882        COMPAT_OBJS += compat/memmem.o
 883endif
 884ifdef INTERNAL_QSORT
 885        COMPAT_CFLAGS += -DINTERNAL_QSORT
 886        COMPAT_OBJS += compat/qsort.o
 887endif
 888
 889ifdef THREADED_DELTA_SEARCH
 890        BASIC_CFLAGS += -DTHREADED_DELTA_SEARCH
 891        EXTLIBS += -lpthread
 892        LIB_OBJS += thread-utils.o
 893endif
 894ifdef DIR_HAS_BSD_GROUP_SEMANTICS
 895        COMPAT_CFLAGS += -DDIR_HAS_BSD_GROUP_SEMANTICS
 896endif
 897ifdef NO_EXTERNAL_GREP
 898        BASIC_CFLAGS += -DNO_EXTERNAL_GREP
 899endif
 900
 901ifeq ($(TCLTK_PATH),)
 902NO_TCLTK=NoThanks
 903endif
 904
 905QUIET_SUBDIR0  = +$(MAKE) -C # space to separate -C and subdir
 906QUIET_SUBDIR1  =
 907
 908ifneq ($(findstring $(MAKEFLAGS),w),w)
 909PRINT_DIR = --no-print-directory
 910else # "make -w"
 911NO_SUBDIR = :
 912endif
 913
 914ifneq ($(findstring $(MAKEFLAGS),s),s)
 915ifndef V
 916        QUIET_CC       = @echo '   ' CC $@;
 917        QUIET_AR       = @echo '   ' AR $@;
 918        QUIET_LINK     = @echo '   ' LINK $@;
 919        QUIET_BUILT_IN = @echo '   ' BUILTIN $@;
 920        QUIET_GEN      = @echo '   ' GEN $@;
 921        QUIET_SUBDIR0  = +@subdir=
 922        QUIET_SUBDIR1  = ;$(NO_SUBDIR) echo '   ' SUBDIR $$subdir; \
 923                         $(MAKE) $(PRINT_DIR) -C $$subdir
 924        export V
 925        export QUIET_GEN
 926        export QUIET_BUILT_IN
 927endif
 928endif
 929
 930ifdef ASCIIDOC8
 931        export ASCIIDOC8
 932endif
 933
 934# Shell quote (do not use $(call) to accommodate ancient setups);
 935
 936SHA1_HEADER_SQ = $(subst ','\'',$(SHA1_HEADER))
 937ETC_GITCONFIG_SQ = $(subst ','\'',$(ETC_GITCONFIG))
 938
 939DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
 940bindir_SQ = $(subst ','\'',$(bindir))
 941mandir_SQ = $(subst ','\'',$(mandir))
 942infodir_SQ = $(subst ','\'',$(infodir))
 943gitexecdir_SQ = $(subst ','\'',$(gitexecdir))
 944template_dir_SQ = $(subst ','\'',$(template_dir))
 945htmldir_SQ = $(subst ','\'',$(htmldir))
 946prefix_SQ = $(subst ','\'',$(prefix))
 947
 948SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
 949PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
 950TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH))
 951
 952LIBS = $(GITLIBS) $(EXTLIBS)
 953
 954BASIC_CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER_SQ)' \
 955        $(COMPAT_CFLAGS)
 956LIB_OBJS += $(COMPAT_OBJS)
 957
 958ALL_CFLAGS += $(BASIC_CFLAGS)
 959ALL_LDFLAGS += $(BASIC_LDFLAGS)
 960
 961export TAR INSTALL DESTDIR SHELL_PATH
 962
 963
 964### Build rules
 965
 966all:: $(ALL_PROGRAMS) $(BUILT_INS) $(OTHER_PROGRAMS) GIT-BUILD-OPTIONS
 967ifneq (,$X)
 968        $(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) git$X)), $(RM) '$p';)
 969endif
 970
 971all::
 972ifndef NO_TCLTK
 973        $(QUIET_SUBDIR0)git-gui $(QUIET_SUBDIR1) all
 974        $(QUIET_SUBDIR0)gitk-git $(QUIET_SUBDIR1) all
 975endif
 976        $(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' all
 977        $(QUIET_SUBDIR0)templates $(QUIET_SUBDIR1)
 978
 979strip: $(PROGRAMS) git$X
 980        $(STRIP) $(STRIP_OPTS) $(PROGRAMS) git$X
 981
 982git.o: git.c common-cmds.h GIT-CFLAGS
 983        $(QUIET_CC)$(CC) -DGIT_VERSION='"$(GIT_VERSION)"' \
 984                $(ALL_CFLAGS) -c $(filter %.c,$^)
 985
 986git$X: git.o $(BUILTIN_OBJS) $(GITLIBS)
 987        $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ git.o \
 988                $(BUILTIN_OBJS) $(ALL_LDFLAGS) $(LIBS)
 989
 990help.o: help.c common-cmds.h GIT-CFLAGS
 991        $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) \
 992                '-DGIT_HTML_PATH="$(htmldir_SQ)"' \
 993                '-DGIT_MAN_PATH="$(mandir_SQ)"' \
 994                '-DGIT_INFO_PATH="$(infodir_SQ)"' $<
 995
 996$(BUILT_INS): git$X
 997        $(QUIET_BUILT_IN)$(RM) $@ && ln git$X $@
 998
 999common-cmds.h: ./generate-cmdlist.sh command-list.txt
1000
1001common-cmds.h: $(wildcard Documentation/git-*.txt)
1002        $(QUIET_GEN)./generate-cmdlist.sh > $@+ && mv $@+ $@
1003
1004$(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
1005        $(QUIET_GEN)$(RM) $@ $@+ && \
1006        sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
1007            -e 's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \
1008            -e 's|@@PERL@@|$(PERL_PATH_SQ)|g' \
1009            -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
1010            -e 's/@@NO_CURL@@/$(NO_CURL)/g' \
1011            $@.sh >$@+ && \
1012        chmod +x $@+ && \
1013        mv $@+ $@
1014
1015$(patsubst %.perl,%,$(SCRIPT_PERL)): perl/perl.mak
1016
1017perl/perl.mak: GIT-CFLAGS perl/Makefile perl/Makefile.PL
1018        $(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' $(@F)
1019
1020$(patsubst %.perl,%,$(SCRIPT_PERL)): % : %.perl
1021        $(QUIET_GEN)$(RM) $@ $@+ && \
1022        INSTLIBDIR=`MAKEFLAGS= $(MAKE) -C perl -s --no-print-directory instlibdir` && \
1023        sed -e '1{' \
1024            -e '        s|#!.*perl|#!$(PERL_PATH_SQ)|' \
1025            -e '        h' \
1026            -e '        s=.*=use lib (split(/:/, $$ENV{GITPERLLIB} || "@@INSTLIBDIR@@"));=' \
1027            -e '        H' \
1028            -e '        x' \
1029            -e '}' \
1030            -e 's|@@INSTLIBDIR@@|'"$$INSTLIBDIR"'|g' \
1031            -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
1032            $@.perl >$@+ && \
1033        chmod +x $@+ && \
1034        mv $@+ $@
1035
1036gitweb/gitweb.cgi: gitweb/gitweb.perl
1037        $(QUIET_GEN)$(RM) $@ $@+ && \
1038        sed -e '1s|#!.*perl|#!$(PERL_PATH_SQ)|' \
1039            -e 's|++GIT_VERSION++|$(GIT_VERSION)|g' \
1040            -e 's|++GIT_BINDIR++|$(bindir)|g' \
1041            -e 's|++GITWEB_CONFIG++|$(GITWEB_CONFIG)|g' \
1042            -e 's|++GITWEB_CONFIG_SYSTEM++|$(GITWEB_CONFIG_SYSTEM)|g' \
1043            -e 's|++GITWEB_HOME_LINK_STR++|$(GITWEB_HOME_LINK_STR)|g' \
1044            -e 's|++GITWEB_SITENAME++|$(GITWEB_SITENAME)|g' \
1045            -e 's|++GITWEB_PROJECTROOT++|$(GITWEB_PROJECTROOT)|g' \
1046            -e 's|"++GITWEB_PROJECT_MAXDEPTH++"|$(GITWEB_PROJECT_MAXDEPTH)|g' \
1047            -e 's|++GITWEB_EXPORT_OK++|$(GITWEB_EXPORT_OK)|g' \
1048            -e 's|++GITWEB_STRICT_EXPORT++|$(GITWEB_STRICT_EXPORT)|g' \
1049            -e 's|++GITWEB_BASE_URL++|$(GITWEB_BASE_URL)|g' \
1050            -e 's|++GITWEB_LIST++|$(GITWEB_LIST)|g' \
1051            -e 's|++GITWEB_HOMETEXT++|$(GITWEB_HOMETEXT)|g' \
1052            -e 's|++GITWEB_CSS++|$(GITWEB_CSS)|g' \
1053            -e 's|++GITWEB_LOGO++|$(GITWEB_LOGO)|g' \
1054            -e 's|++GITWEB_FAVICON++|$(GITWEB_FAVICON)|g' \
1055            -e 's|++GITWEB_SITE_HEADER++|$(GITWEB_SITE_HEADER)|g' \
1056            -e 's|++GITWEB_SITE_FOOTER++|$(GITWEB_SITE_FOOTER)|g' \
1057            $< >$@+ && \
1058        chmod +x $@+ && \
1059        mv $@+ $@
1060
1061git-instaweb: git-instaweb.sh gitweb/gitweb.cgi gitweb/gitweb.css
1062        $(QUIET_GEN)$(RM) $@ $@+ && \
1063        sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
1064            -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
1065            -e 's/@@NO_CURL@@/$(NO_CURL)/g' \
1066            -e '/@@GITWEB_CGI@@/r gitweb/gitweb.cgi' \
1067            -e '/@@GITWEB_CGI@@/d' \
1068            -e '/@@GITWEB_CSS@@/r gitweb/gitweb.css' \
1069            -e '/@@GITWEB_CSS@@/d' \
1070            -e 's|@@PERL@@|$(PERL_PATH_SQ)|g' \
1071            $@.sh > $@+ && \
1072        chmod +x $@+ && \
1073        mv $@+ $@
1074
1075configure: configure.ac
1076        $(QUIET_GEN)$(RM) $@ $<+ && \
1077        sed -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
1078            $< > $<+ && \
1079        autoconf -o $@ $<+ && \
1080        $(RM) $<+
1081
1082# These can record GIT_VERSION
1083git.o git.spec \
1084        $(patsubst %.sh,%,$(SCRIPT_SH)) \
1085        $(patsubst %.perl,%,$(SCRIPT_PERL)) \
1086        : GIT-VERSION-FILE
1087
1088%.o: %.c GIT-CFLAGS
1089        $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $<
1090%.s: %.c GIT-CFLAGS
1091        $(QUIET_CC)$(CC) -S $(ALL_CFLAGS) $<
1092%.o: %.S
1093        $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $<
1094
1095exec_cmd.o: exec_cmd.c GIT-CFLAGS
1096        $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) '-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' $<
1097builtin-init-db.o: builtin-init-db.c GIT-CFLAGS
1098        $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir_SQ)"' $<
1099
1100config.o: config.c GIT-CFLAGS
1101        $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DETC_GITCONFIG='"$(ETC_GITCONFIG_SQ)"' $<
1102
1103http.o: http.c GIT-CFLAGS
1104        $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DGIT_USER_AGENT='"git/$(GIT_VERSION)"' $<
1105
1106ifdef NO_EXPAT
1107http-walker.o: http-walker.c http.h GIT-CFLAGS
1108        $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DNO_EXPAT $<
1109endif
1110
1111git-%$X: %.o $(GITLIBS)
1112        $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
1113
1114git-imap-send$X: imap-send.o $(LIB_FILE)
1115
1116http.o http-walker.o http-push.o transport.o: http.h
1117
1118git-http-push$X: revision.o http.o http-push.o $(GITLIBS)
1119        $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
1120                $(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
1121
1122$(LIB_OBJS) $(BUILTIN_OBJS): $(LIB_H)
1123$(patsubst git-%$X,%.o,$(PROGRAMS)): $(LIB_H) $(wildcard */*.h)
1124builtin-revert.o wt-status.o: wt-status.h
1125
1126$(LIB_FILE): $(LIB_OBJS)
1127        $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIB_OBJS)
1128
1129XDIFF_OBJS=xdiff/xdiffi.o xdiff/xprepare.o xdiff/xutils.o xdiff/xemit.o \
1130        xdiff/xmerge.o
1131$(XDIFF_OBJS): xdiff/xinclude.h xdiff/xmacros.h xdiff/xdiff.h xdiff/xtypes.h \
1132        xdiff/xutils.h xdiff/xprepare.h xdiff/xdiffi.h xdiff/xemit.h
1133
1134$(XDIFF_LIB): $(XDIFF_OBJS)
1135        $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(XDIFF_OBJS)
1136
1137
1138doc:
1139        $(MAKE) -C Documentation all
1140
1141info:
1142        $(MAKE) -C Documentation info
1143
1144TAGS:
1145        $(RM) TAGS
1146        $(FIND) . -name '*.[hcS]' -print | xargs etags -a
1147
1148tags:
1149        $(RM) tags
1150        $(FIND) . -name '*.[hcS]' -print | xargs ctags -a
1151
1152cscope:
1153        $(RM) cscope*
1154        $(FIND) . -name '*.[hcS]' -print | xargs cscope -b
1155
1156### Detect prefix changes
1157TRACK_CFLAGS = $(subst ','\'',$(ALL_CFLAGS)):\
1158             $(bindir_SQ):$(gitexecdir_SQ):$(template_dir_SQ):$(prefix_SQ)
1159
1160GIT-CFLAGS: .FORCE-GIT-CFLAGS
1161        @FLAGS='$(TRACK_CFLAGS)'; \
1162            if test x"$$FLAGS" != x"`cat GIT-CFLAGS 2>/dev/null`" ; then \
1163                echo 1>&2 "    * new build flags or prefix"; \
1164                echo "$$FLAGS" >GIT-CFLAGS; \
1165            fi
1166
1167GIT-BUILD-OPTIONS: .FORCE-GIT-BUILD-OPTIONS
1168        @echo SHELL_PATH=\''$(SHELL_PATH_SQ)'\' >$@
1169
1170### Detect Tck/Tk interpreter path changes
1171ifndef NO_TCLTK
1172TRACK_VARS = $(subst ','\'',-DTCLTK_PATH='$(TCLTK_PATH_SQ)')
1173
1174GIT-GUI-VARS: .FORCE-GIT-GUI-VARS
1175        @VARS='$(TRACK_VARS)'; \
1176            if test x"$$VARS" != x"`cat $@ 2>/dev/null`" ; then \
1177                echo 1>&2 "    * new Tcl/Tk interpreter location"; \
1178                echo "$$VARS" >$@; \
1179            fi
1180
1181.PHONY: .FORCE-GIT-GUI-VARS
1182endif
1183
1184### Testing rules
1185
1186TEST_PROGRAMS = test-chmtime$X test-genrandom$X test-date$X test-delta$X test-sha1$X test-match-trees$X test-absolute-path$X test-parse-options$X
1187
1188all:: $(TEST_PROGRAMS)
1189
1190# GNU make supports exporting all variables by "export" without parameters.
1191# However, the environment gets quite big, and some programs have problems
1192# with that.
1193
1194export NO_SVN_TESTS
1195
1196test: all
1197        $(MAKE) -C t/ all
1198
1199test-date$X: date.o ctype.o
1200
1201test-delta$X: diff-delta.o patch-delta.o
1202
1203test-parse-options$X: parse-options.o
1204
1205.PRECIOUS: $(patsubst test-%$X,test-%.o,$(TEST_PROGRAMS))
1206
1207test-%$X: test-%.o $(GITLIBS)
1208        $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
1209
1210check-sha1:: test-sha1$X
1211        ./test-sha1.sh
1212
1213check: common-cmds.h
1214        for i in *.c; do sparse $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i || exit; done
1215
1216remove-dashes:
1217        ./fixup-builtins $(BUILT_INS)
1218
1219### Installation rules
1220
1221install: all
1222        $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'
1223        $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitexecdir_SQ)'
1224        $(INSTALL) $(ALL_PROGRAMS) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
1225        $(INSTALL) git$X '$(DESTDIR_SQ)$(bindir_SQ)'
1226        $(MAKE) -C templates DESTDIR='$(DESTDIR_SQ)' install
1227        $(MAKE) -C perl prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' install
1228ifndef NO_TCLTK
1229        $(MAKE) -C gitk-git install
1230        $(MAKE) -C git-gui install
1231endif
1232        if test 'z$(bindir_SQ)' != 'z$(gitexecdir_SQ)'; \
1233        then \
1234                ln -f '$(DESTDIR_SQ)$(bindir_SQ)/git$X' \
1235                        '$(DESTDIR_SQ)$(gitexecdir_SQ)/git$X' || \
1236                cp '$(DESTDIR_SQ)$(bindir_SQ)/git$X' \
1237                        '$(DESTDIR_SQ)$(gitexecdir_SQ)/git$X'; \
1238        fi
1239        $(foreach p,$(BUILT_INS), $(RM) '$(DESTDIR_SQ)$(gitexecdir_SQ)/$p' && ln '$(DESTDIR_SQ)$(gitexecdir_SQ)/git$X' '$(DESTDIR_SQ)$(gitexecdir_SQ)/$p' ;)
1240ifneq (,$X)
1241        $(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) git$X)), $(RM) '$(DESTDIR_SQ)$(gitexecdir_SQ)/$p';)
1242endif
1243
1244install-doc:
1245        $(MAKE) -C Documentation install
1246
1247install-info:
1248        $(MAKE) -C Documentation install-info
1249
1250quick-install-doc:
1251        $(MAKE) -C Documentation quick-install
1252
1253
1254
1255### Maintainer's dist rules
1256
1257git.spec: git.spec.in
1258        sed -e 's/@@VERSION@@/$(GIT_VERSION)/g' < $< > $@+
1259        mv $@+ $@
1260
1261GIT_TARNAME=git-$(GIT_VERSION)
1262dist: git.spec git-archive$(X) configure
1263        ./git-archive --format=tar \
1264                --prefix=$(GIT_TARNAME)/ HEAD^{tree} > $(GIT_TARNAME).tar
1265        @mkdir -p $(GIT_TARNAME)
1266        @cp git.spec configure $(GIT_TARNAME)
1267        @echo $(GIT_VERSION) > $(GIT_TARNAME)/version
1268        @$(MAKE) -C git-gui TARDIR=../$(GIT_TARNAME)/git-gui dist-version
1269        $(TAR) rf $(GIT_TARNAME).tar \
1270                $(GIT_TARNAME)/git.spec \
1271                $(GIT_TARNAME)/configure \
1272                $(GIT_TARNAME)/version \
1273                $(GIT_TARNAME)/git-gui/version
1274        @$(RM) -r $(GIT_TARNAME)
1275        gzip -f -9 $(GIT_TARNAME).tar
1276
1277rpm: dist
1278        $(RPMBUILD) -ta $(GIT_TARNAME).tar.gz
1279
1280htmldocs = git-htmldocs-$(GIT_VERSION)
1281manpages = git-manpages-$(GIT_VERSION)
1282dist-doc:
1283        $(RM) -r .doc-tmp-dir
1284        mkdir .doc-tmp-dir
1285        $(MAKE) -C Documentation WEBDOC_DEST=../.doc-tmp-dir install-webdoc
1286        cd .doc-tmp-dir && $(TAR) cf ../$(htmldocs).tar .
1287        gzip -n -9 -f $(htmldocs).tar
1288        :
1289        $(RM) -r .doc-tmp-dir
1290        mkdir -p .doc-tmp-dir/man1 .doc-tmp-dir/man5 .doc-tmp-dir/man7
1291        $(MAKE) -C Documentation DESTDIR=./ \
1292                man1dir=../.doc-tmp-dir/man1 \
1293                man5dir=../.doc-tmp-dir/man5 \
1294                man7dir=../.doc-tmp-dir/man7 \
1295                install
1296        cd .doc-tmp-dir && $(TAR) cf ../$(manpages).tar .
1297        gzip -n -9 -f $(manpages).tar
1298        $(RM) -r .doc-tmp-dir
1299
1300### Cleaning rules
1301
1302distclean: clean
1303        $(RM) configure
1304
1305clean:
1306        $(RM) *.o mozilla-sha1/*.o arm/*.o ppc/*.o compat/*.o xdiff/*.o \
1307                $(LIB_FILE) $(XDIFF_LIB)
1308        $(RM) $(ALL_PROGRAMS) $(BUILT_INS) git$X
1309        $(RM) $(TEST_PROGRAMS)
1310        $(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo common-cmds.h TAGS tags cscope*
1311        $(RM) -r autom4te.cache
1312        $(RM) config.log config.mak.autogen config.mak.append config.status config.cache
1313        $(RM) -r $(GIT_TARNAME) .doc-tmp-dir
1314        $(RM) $(GIT_TARNAME).tar.gz git-core_$(GIT_VERSION)-*.tar.gz
1315        $(RM) $(htmldocs).tar.gz $(manpages).tar.gz
1316        $(RM) gitweb/gitweb.cgi
1317        $(MAKE) -C Documentation/ clean
1318        $(MAKE) -C perl clean
1319        $(MAKE) -C templates/ clean
1320        $(MAKE) -C t/ clean
1321ifndef NO_TCLTK
1322        $(MAKE) -C gitk-git clean
1323        $(MAKE) -C git-gui clean
1324endif
1325        $(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-GUI-VARS GIT-BUILD-OPTIONS
1326
1327.PHONY: all install clean strip
1328.PHONY: .FORCE-GIT-VERSION-FILE TAGS tags cscope .FORCE-GIT-CFLAGS
1329.PHONY: .FORCE-GIT-BUILD-OPTIONS
1330
1331### Check documentation
1332#
1333check-docs::
1334        @(for v in $(ALL_PROGRAMS) $(BUILT_INS) git gitk; \
1335        do \
1336                case "$$v" in \
1337                git-merge-octopus | git-merge-ours | git-merge-recursive | \
1338                git-merge-resolve | git-merge-stupid | git-merge-subtree | \
1339                git-fsck-objects | git-init-db | \
1340                git-?*--?* ) continue ;; \
1341                esac ; \
1342                test -f "Documentation/$$v.txt" || \
1343                echo "no doc: $$v"; \
1344                sed -e '/^#/d' command-list.txt | \
1345                grep -q "^$$v[  ]" || \
1346                case "$$v" in \
1347                git) ;; \
1348                *) echo "no link: $$v";; \
1349                esac ; \
1350        done; \
1351        ( \
1352                sed -e '/^#/d' \
1353                    -e 's/[     ].*//' \
1354                    -e 's/^/listed /' command-list.txt; \
1355                ls -1 Documentation/git*txt | \
1356                sed -e 's|Documentation/|documented |' \
1357                    -e 's/\.txt//'; \
1358        ) | while read how cmd; \
1359        do \
1360                case "$$how,$$cmd" in \
1361                *,git-citool | \
1362                *,git-gui | \
1363                *,git-help | \
1364                documented,gitattributes | \
1365                documented,gitignore | \
1366                documented,gitmodules | \
1367                documented,gitcli | \
1368                documented,git-tools | \
1369                sentinel,not,matching,is,ok ) continue ;; \
1370                esac; \
1371                case " $(ALL_PROGRAMS) $(BUILT_INS) git gitk " in \
1372                *" $$cmd "*)    ;; \
1373                *) echo "removed but $$how: $$cmd" ;; \
1374                esac; \
1375        done ) | sort
1376
1377### Make sure built-ins do not have dups and listed in git.c
1378#
1379check-builtins::
1380        ./check-builtins.sh
1381