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