Merge branch 'jn/block-sha1'
authorJunio C Hamano <gitster@pobox.com>
Tue, 24 Jul 2012 03:56:46 +0000 (20:56 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 24 Jul 2012 03:56:47 +0000 (20:56 -0700)
The code to load a word one-byte-at-a-time was optimized into a
word-wide load instruction even when the pointer was not aligned,
which caused issues on architectures that do not like unaligned
access.

* jn/block-sha1:
Makefile: BLK_SHA1 does not require fast htonl() and unaligned loads
block-sha1: put expanded macro parameters in parentheses
block-sha1: avoid pointer conversion that violates alignment constraints

1  2 
Makefile
block-sha1/sha1.c
diff --combined Makefile
index 34ca6e551f9221622ae6c3c8e1385c06e3df2963,eadcc70aced782d93ae00c717ff210f064574d5e..b0b3493364550f9f443039708974902df1896413
+++ b/Makefile
@@@ -8,12 -8,6 +8,12 @@@ all:
  # Define SANE_TOOL_PATH to a colon-separated list of paths to prepend
  # to PATH if your tools in /usr/bin are broken.
  #
 +# Define SOCKLEN_T to a suitable type (such as 'size_t') if your
 +# system headers do not define a socklen_t type.
 +#
 +# Define INLINE to a suitable substitute (such as '__inline' or '') if git
 +# fails to compile with errors about undefined inline functions or similar.
 +#
  # Define SNPRINTF_RETURNS_BOGUS if your are on a system which snprintf()
  # or vsnprintf() return -1 instead of number of characters which would
  # have been written to the final string if enough space had been available.
  # Define NO_OPENSSL environment variable if you do not have OpenSSL.
  # This also implies BLK_SHA1.
  #
 -# Define NO_CURL if you do not have libcurl installed.  git-http-pull and
 +# Define USE_LIBPCRE if you have and want to use libpcre. git-grep will be
 +# able to use Perl-compatible regular expressions.
 +#
 +# Define LIBPCREDIR=/foo/bar if your libpcre header and library files are in
 +# /foo/bar/include and /foo/bar/lib directories.
 +#
 +# Define NO_CURL if you do not have libcurl installed.  git-http-fetch and
  # git-http-push are not built, and you cannot use http:// and https://
 -# transports.
 +# transports (neither smart nor dumb).
  #
  # Define CURLDIR=/foo/bar if your curl header and library files are in
  # /foo/bar/include and /foo/bar/lib directories.
  #
  # Define NO_EXPAT if you do not have expat installed.  git-http-push is
 -# not built, and you cannot push using http:// and https:// transports.
 +# not built, and you cannot push using http:// and https:// transports (dumb).
  #
  # Define EXPATDIR=/foo/bar if your expat header and library files are in
  # /foo/bar/include and /foo/bar/lib directories.
  #
 +# Define NO_GETTEXT if you don't want Git output to be translated.
 +# A translated Git requires GNU libintl or another gettext implementation,
 +# plus libintl-perl at runtime.
 +#
 +# Define USE_GETTEXT_SCHEME and set it to 'fallthrough', if you don't trust
 +# the installed gettext translation of the shell scripts output.
 +#
 +# Define HAVE_LIBCHARSET_H if you haven't set NO_GETTEXT and you can't
 +# trust the langinfo.h's nl_langinfo(CODESET) function to return the
 +# current character set. GNU and Solaris have a nl_langinfo(CODESET),
 +# FreeBSD can use either, but MinGW and some others need to use
 +# libcharset.h's locale_charset() instead.
 +#
 +# Define CHARSET_LIB to you need to link with library other than -liconv to
 +# use locale_charset() function.  On some platforms this needs to set to
 +# -lcharset
 +#
 +# Define LIBC_CONTAINS_LIBINTL if your gettext implementation doesn't
 +# need -lintl when linking.
 +#
 +# Define NO_MSGFMT_EXTENDED_OPTIONS if your implementation of msgfmt
 +# doesn't support GNU extensions like --check and --statistics
 +#
 +# Define HAVE_PATHS_H if you have paths.h and want to use the default PATH
 +# it specifies.
 +#
  # Define NO_D_INO_IN_DIRENT if you don't have d_ino in your struct dirent.
  #
  # Define NO_D_TYPE_IN_DIRENT if your platform defines DT_UNKNOWN but lacks
 -# d_type in struct dirent (latest Cygwin -- will be fixed soonish).
 -#
 -# Define NO_C99_FORMAT if your formatted IO functions (printf/scanf et.al.)
 -# do not support the 'size specifiers' introduced by C99, namely ll, hh,
 -# j, z, t. (representing long long int, char, intmax_t, size_t, ptrdiff_t).
 -# some C compilers supported these specifiers prior to C99 as an extension.
 +# d_type in struct dirent (Cygwin 1.5, fixed in Cygwin 1.7).
  #
  # Define NO_STRCASESTR if you don't have strcasestr.
  #
@@@ -80,8 -47,8 +80,8 @@@
  #
  # Define NO_STRLCPY if you don't have strlcpy.
  #
 -# Define NO_STRTOUMAX if you don't have strtoumax in the C library.
 -# If your compiler also does not support long long or does not have
 +# Define NO_STRTOUMAX if you don't have both strtoimax and strtoumax in the
 +# C library. If your compiler also does not support long long or does not have
  # strtoull, define NO_STRTOULL.
  #
  # Define NO_SETENV if you don't have setenv in the C library.
  #
  # Define NO_MKSTEMPS if you don't have mkstemps in the C library.
  #
 +# Define NO_STRTOK_R if you don't have strtok_r in the C library.
 +#
 +# Define NO_FNMATCH if you don't have fnmatch in the C library.
 +#
 +# Define NO_FNMATCH_CASEFOLD if your fnmatch function doesn't have the
 +# FNM_CASEFOLD GNU extension.
 +#
 +# Define NO_GECOS_IN_PWENT if you don't have pw_gecos in struct passwd
 +# in the C library.
 +#
  # Define NO_LIBGEN_H if you don't have libgen.h.
  #
  # Define NEEDS_LIBGEN if your libgen needs -lgen when linking
  # specify your own (or DarwinPort's) include directories and
  # library directories by defining CFLAGS and LDFLAGS appropriately.
  #
- # Define BLK_SHA1 environment variable if you want the C version
- # of the SHA1 that assumes you can do unaligned 32-bit loads and
- # have a fast htonl() function.
+ # Define BLK_SHA1 environment variable to make use of the bundled
+ # optimized C SHA1 routine.
  #
  # Define PPC_SHA1 environment variable when running make to make use of
  # a bundled SHA1 routine optimized for PowerPC.
  #
 -# Define NEEDS_SSL_WITH_CRYPTO if you need -lcrypto with -lssl (Darwin).
 +# Define NEEDS_CRYPTO_WITH_SSL if you need -lcrypto when using -lssl (Darwin).
 +#
 +# Define NEEDS_SSL_WITH_CRYPTO if you need -lssl when using -lcrypto (Darwin).
 +#
 +# Define NEEDS_SSL_WITH_CURL if you need -lssl with -lcurl (Minix).
 +#
 +# Define NEEDS_IDN_WITH_CURL if you need -lidn when using -lcurl (Minix).
  #
  # Define NEEDS_LIBICONV if linking with libc is not enough (Darwin).
  #
  # Define NO_PTHREADS if you do not have or do not want to use Pthreads.
  #
  # Define NO_PREAD if you have a problem with pread() system call (e.g.
 -# cygwin.dll before v1.5.22).
 +# cygwin1.dll before v1.5.22).
 +#
 +# Define NO_THREAD_SAFE_PREAD if your pread() implementation is not
 +# thread-safe. (e.g. compat/pread.c or cygwin)
  #
  # Define NO_FAST_WORKING_DIRECTORY if accessing objects in pack files is
  # generally faster on your platform than accessing the working directory.
  #
  # Define NO_IPV6 if you lack IPv6 support and getaddrinfo().
  #
 +# Define NO_UNIX_SOCKETS if your system does not offer unix sockets.
 +#
  # Define NO_SOCKADDR_STORAGE if your platform does not have struct
  # sockaddr_storage.
  #
  # that tells runtime paths to dynamic libraries;
  # "-Wl,-rpath=/path/lib" is used instead.
  #
 +# Define NO_NORETURN if using buggy versions of gcc 4.6+ and profile feedback,
 +# as the compiler can crash (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49299)
 +#
  # Define USE_NSEC below if you want git to care about sub-second file mtimes
  # and ctimes. Note that you need recent glibc (at least 2.2.4) for this, and
  # it will BREAK YOUR LOCAL DIFFS! show-diff and anything using it will likely
  # Define NO_ST_BLOCKS_IN_STRUCT_STAT if your platform does not have st_blocks
  # field that counts the on-disk footprint in 512-byte blocks.
  #
 -# Define ASCIIDOC8 if you want to format documentation with AsciiDoc 8
 +# Define DOCBOOK_XSL_172 if you want to format man pages with DocBook XSL v1.72
 +# (not v1.73 or v1.71).
 +#
 +# Define ASCIIDOC_ROFF if your DocBook XSL does not escape raw roff directives
 +# (versions 1.68.1 through v1.72).
  #
 -# Define DOCBOOK_XSL_172 if you want to format man pages with DocBook XSL v1.72.
 +# Define GNU_ROFF if your target system uses GNU groff.  This forces
 +# apostrophes to be ASCII so that cut&pasting examples to the shell
 +# will work.
  #
  # Define NO_PERL_MAKEMAKER if you cannot use Makefiles generated by perl's
  # MakeMaker (e.g. using ActiveState under Cygwin).
  #
  # Define NO_PERL if you do not want Perl scripts or libraries at all.
  #
 +# Define NO_PYTHON if you do not want Python scripts or libraries at all.
 +#
  # Define NO_TCLTK if you do not want Tcl/Tk GUI.
  #
  # The TCL_PATH variable governs the location of the Tcl interpreter
  # If not set it defaults to the bare 'wish'. If it is set to the empty
  # string then NO_TCLTK will be forced (this is used by configure script).
  #
 -# Define THREADED_DELTA_SEARCH if you have pthreads and wish to exploit
 -# parallel delta searching when packing objects.
 -#
  # Define INTERNAL_QSORT to use Git's implementation of qsort(), which
  # is a simplified version of the merge sort used in glibc. This is
  # recommended if Git triggers O(n^2) behavior in your platform's qsort().
  #
 -# Define NO_EXTERNAL_GREP if you don't want "git grep" to ever call
 -# your external grep (e.g., if your system lacks grep, if its grep is
 -# broken, or spawning external process is slower than built-in grep git has).
 -#
  # Define UNRELIABLE_FSTAT if your system's fstat does not return the same
  # information on a not yet closed file that lstat would return for the same
  # file after it was closed.
  # Define NO_CROSS_DIRECTORY_HARDLINKS if you plan to distribute the installed
  # programs as a tar, where bin/ and libexec/ might be on different file systems.
  #
 +# Define NO_INSTALL_HARDLINKS if you prefer to use either symbolic links or
 +# copies to install built-in git commands e.g. git-cat-file.
 +#
  # Define USE_NED_ALLOCATOR if you want to replace the platforms default
  # memory allocators with the nedmalloc allocator written by Niall Douglas.
  #
  # Define NO_REGEX if you have no or inferior regex support in your C library.
 +#
 +# Define HAVE_DEV_TTY if your system can open /dev/tty to interact with the
 +# user.
 +#
 +# Define GETTEXT_POISON if you are debugging the choice of strings marked
 +# for translation.  In a GETTEXT_POISON build, you can turn all strings marked
 +# for translation into gibberish by setting the GIT_GETTEXT_POISON variable
 +# (to any value) in your environment.
 +#
 +# Define JSMIN to point to JavaScript minifier that functions as
 +# a filter to have gitweb.js minified.
 +#
 +# Define CSSMIN to point to a CSS minifier in order to generate a minified
 +# version of gitweb.css
 +#
 +# Define DEFAULT_PAGER to a sensible pager command (defaults to "less") if
 +# you want to use something different.  The value will be interpreted by the
 +# shell at runtime when it is used.
 +#
 +# Define DEFAULT_EDITOR to a sensible editor command (defaults to "vi") if you
 +# want to use something different.  The value will be interpreted by the shell
 +# if necessary when it is used.  Examples:
 +#
 +#   DEFAULT_EDITOR='~/bin/vi',
 +#   DEFAULT_EDITOR='$GIT_FALLBACK_EDITOR',
 +#   DEFAULT_EDITOR='"C:\Program Files\Vim\gvim.exe" --nofork'
 +#
 +# Define COMPUTE_HEADER_DEPENDENCIES to "yes" if you want dependencies on
 +# header files to be automatically computed, to avoid rebuilding objects when
 +# an unrelated header file changes.  Define it to "no" to use the hard-coded
 +# dependency rules.  The default is "auto", which means to use computed header
 +# dependencies if your compiler is detected to support it.
 +#
 +# Define CHECK_HEADER_DEPENDENCIES to check for problems in the hard-coded
 +# dependency rules.
 +#
 +# Define NATIVE_CRLF if your platform uses CRLF for line endings.
 +#
 +# Define XDL_FAST_HASH to use an alternative line-hashing method in
 +# the diff algorithm.  It gives a nice speedup if your processor has
 +# fast unaligned word loads.  Does NOT work on big-endian systems!
 +# Enabled by default on x86_64.
 +#
 +# Define GIT_USER_AGENT if you want to change how git identifies itself during
 +# network interactions.  The default is "git/$(GIT_VERSION)".
 +#
 +# Define DEFAULT_HELP_FORMAT to "man", "info" or "html"
 +# (defaults to "man") if you want to have a different default when
 +# "git help" is called without a parameter specifying the format.
  
 -GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
 +GIT-VERSION-FILE: FORCE
        @$(SHELL_PATH) ./GIT-VERSION-GEN
  -include GIT-VERSION-FILE
  
@@@ -316,17 -205,11 +315,17 @@@ uname_R := $(shell sh -c 'uname -r 2>/d
  uname_P := $(shell sh -c 'uname -p 2>/dev/null || echo not')
  uname_V := $(shell sh -c 'uname -v 2>/dev/null || echo not')
  
 +ifdef MSVC
 +      # avoid the MingW and Cygwin configuration sections
 +      uname_S := Windows
 +      uname_O := Windows
 +endif
 +
  # CFLAGS and LDFLAGS are for the users to override from the command line.
  
  CFLAGS = -g -O2 -Wall
  LDFLAGS =
 -ALL_CFLAGS = $(CFLAGS)
 +ALL_CFLAGS = $(CPPFLAGS) $(CFLAGS)
  ALL_LDFLAGS = $(LDFLAGS)
  STRIP ?= strip
  
  #   mandir
  #   infodir
  #   htmldir
 -#   ETC_GITCONFIG (but not sysconfdir)
 +#   sysconfdir
  # can be specified as a relative path some/where/else;
  # this is interpreted as relative to $(prefix) and "git" at
  # runtime figures out where they are based on the path to the executable.
@@@ -348,39 -231,56 +347,39 @@@ bindir = $(prefix)/$(bindir_relative
  mandir = share/man
  infodir = share/info
  gitexecdir = libexec/git-core
 +mergetoolsdir = $(gitexecdir)/mergetools
  sharedir = $(prefix)/share
 +gitwebdir = $(sharedir)/gitweb
 +localedir = $(sharedir)/locale
  template_dir = share/git-core/templates
  htmldir = share/doc/git-doc
 -ifeq ($(prefix),/usr)
 -sysconfdir = /etc
  ETC_GITCONFIG = $(sysconfdir)/gitconfig
 -else
 -sysconfdir = $(prefix)/etc
 -ETC_GITCONFIG = etc/gitconfig
 -endif
 +ETC_GITATTRIBUTES = $(sysconfdir)/gitattributes
  lib = lib
  # DESTDIR=
  pathsep = :
  
 -# default configuration for gitweb
 -GITWEB_CONFIG = gitweb_config.perl
 -GITWEB_CONFIG_SYSTEM = /etc/gitweb.conf
 -GITWEB_HOME_LINK_STR = projects
 -GITWEB_SITENAME =
 -GITWEB_PROJECTROOT = /pub/git
 -GITWEB_PROJECT_MAXDEPTH = 2007
 -GITWEB_EXPORT_OK =
 -GITWEB_STRICT_EXPORT =
 -GITWEB_BASE_URL =
 -GITWEB_LIST =
 -GITWEB_HOMETEXT = indextext.html
 -GITWEB_CSS = gitweb.css
 -GITWEB_LOGO = git-logo.png
 -GITWEB_FAVICON = git-favicon.png
 -GITWEB_SITE_HEADER =
 -GITWEB_SITE_FOOTER =
 -
 -export prefix bindir sharedir sysconfdir
 -
 -CC = gcc
 +export prefix bindir sharedir sysconfdir gitwebdir localedir
 +
 +CC = cc
  AR = ar
  RM = rm -f
 +DIFF = diff
  TAR = tar
  FIND = find
  INSTALL = install
  RPMBUILD = rpmbuild
  TCL_PATH = tclsh
  TCLTK_PATH = wish
 +XGETTEXT = xgettext
 +MSGFMT = msgfmt
  PTHREAD_LIBS = -lpthread
 +PTHREAD_CFLAGS =
 +GCOV = gcov
  
  export TCL_PATH TCLTK_PATH
  
 -# sparse is architecture-neutral, which means that we need to tell it
 -# explicitly what architecture to check for. Fix this up for yours..
 -SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
 +SPARSE_FLAGS =
  
  
  
  # Those must not be GNU-specific; they are shared with perl/ which may
  # be built by a different compiler. (Note that this is an artifact now
  # but it still might be nice to keep that distinction.)
 -BASIC_CFLAGS =
 +BASIC_CFLAGS = -I.
  BASIC_LDFLAGS =
  
  # Guard against environment variables
@@@ -397,25 -297,12 +396,25 @@@ BUILTIN_OBJS 
  BUILT_INS =
  COMPAT_CFLAGS =
  COMPAT_OBJS =
 +XDIFF_OBJS =
 +VCSSVN_OBJS =
 +GENERATED_H =
 +EXTRA_CPPFLAGS =
  LIB_H =
  LIB_OBJS =
 +PROGRAM_OBJS =
  PROGRAMS =
  SCRIPT_PERL =
 +SCRIPT_PYTHON =
  SCRIPT_SH =
 -TEST_PROGRAMS =
 +SCRIPT_LIB =
 +TEST_PROGRAMS_NEED_X =
 +
 +# Having this variable in your environment would break pipelines because
 +# you cause "cd" to echo its destination to stdout.  It can also take
 +# scripts to unexpected places.  If you like CDPATH, define it for your
 +# interactive shell sessions without exporting it.
 +unexport CDPATH
  
  SCRIPT_SH += git-am.sh
  SCRIPT_SH += git-bisect.sh
@@@ -426,23 -313,19 +425,23 @@@ SCRIPT_SH += git-merge-octopus.s
  SCRIPT_SH += git-merge-one-file.sh
  SCRIPT_SH += git-merge-resolve.sh
  SCRIPT_SH += git-mergetool.sh
 -SCRIPT_SH += git-mergetool--lib.sh
 -SCRIPT_SH += git-parse-remote.sh
  SCRIPT_SH += git-pull.sh
  SCRIPT_SH += git-quiltimport.sh
 -SCRIPT_SH += git-rebase--interactive.sh
  SCRIPT_SH += git-rebase.sh
  SCRIPT_SH += git-repack.sh
  SCRIPT_SH += git-request-pull.sh
 -SCRIPT_SH += git-sh-setup.sh
  SCRIPT_SH += git-stash.sh
  SCRIPT_SH += git-submodule.sh
  SCRIPT_SH += git-web--browse.sh
  
 +SCRIPT_LIB += git-mergetool--lib
 +SCRIPT_LIB += git-parse-remote
 +SCRIPT_LIB += git-rebase--am
 +SCRIPT_LIB += git-rebase--interactive
 +SCRIPT_LIB += git-rebase--merge
 +SCRIPT_LIB += git-sh-setup
 +SCRIPT_LIB += git-sh-i18n
 +
  SCRIPT_PERL += git-add--interactive.perl
  SCRIPT_PERL += git-difftool.perl
  SCRIPT_PERL += git-archimport.perl
@@@ -453,63 -336,33 +452,63 @@@ SCRIPT_PERL += git-relink.per
  SCRIPT_PERL += git-send-email.perl
  SCRIPT_PERL += git-svn.perl
  
 +SCRIPT_PYTHON += git-remote-testgit.py
 +SCRIPT_PYTHON += git-p4.py
 +
  SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \
          $(patsubst %.perl,%,$(SCRIPT_PERL)) \
 +        $(patsubst %.py,%,$(SCRIPT_PYTHON)) \
          git-instaweb
  
 +ETAGS_TARGET = TAGS
 +
  # Empty...
  EXTRA_PROGRAMS =
  
  # ... and all the rest that could be moved out of bindir to gitexecdir
  PROGRAMS += $(EXTRA_PROGRAMS)
 -PROGRAMS += git-fast-import$X
 -PROGRAMS += git-hash-object$X
 -PROGRAMS += git-index-pack$X
 -PROGRAMS += git-merge-index$X
 -PROGRAMS += git-merge-tree$X
 -PROGRAMS += git-mktag$X
 -PROGRAMS += git-pack-redundant$X
 -PROGRAMS += git-patch-id$X
 -PROGRAMS += git-shell$X
 -PROGRAMS += git-show-index$X
 -PROGRAMS += git-unpack-file$X
 -PROGRAMS += git-update-server-info$X
 -PROGRAMS += git-upload-pack$X
 -PROGRAMS += git-var$X
 +
 +PROGRAM_OBJS += credential-store.o
 +PROGRAM_OBJS += daemon.o
 +PROGRAM_OBJS += fast-import.o
 +PROGRAM_OBJS += http-backend.o
 +PROGRAM_OBJS += imap-send.o
 +PROGRAM_OBJS += sh-i18n--envsubst.o
 +PROGRAM_OBJS += shell.o
 +PROGRAM_OBJS += show-index.o
 +PROGRAM_OBJS += upload-pack.o
 +
 +# Binary suffix, set to .exe for Windows builds
 +X =
 +
 +PROGRAMS += $(patsubst %.o,git-%$X,$(PROGRAM_OBJS))
 +
 +TEST_PROGRAMS_NEED_X += test-chmtime
 +TEST_PROGRAMS_NEED_X += test-ctype
 +TEST_PROGRAMS_NEED_X += test-date
 +TEST_PROGRAMS_NEED_X += test-delta
 +TEST_PROGRAMS_NEED_X += test-dump-cache-tree
 +TEST_PROGRAMS_NEED_X += test-genrandom
 +TEST_PROGRAMS_NEED_X += test-index-version
 +TEST_PROGRAMS_NEED_X += test-line-buffer
 +TEST_PROGRAMS_NEED_X += test-match-trees
 +TEST_PROGRAMS_NEED_X += test-mergesort
 +TEST_PROGRAMS_NEED_X += test-mktemp
 +TEST_PROGRAMS_NEED_X += test-parse-options
 +TEST_PROGRAMS_NEED_X += test-path-utils
 +TEST_PROGRAMS_NEED_X += test-revision-walking
 +TEST_PROGRAMS_NEED_X += test-run-command
 +TEST_PROGRAMS_NEED_X += test-scrap-cache-tree
 +TEST_PROGRAMS_NEED_X += test-sha1
 +TEST_PROGRAMS_NEED_X += test-sigchain
 +TEST_PROGRAMS_NEED_X += test-subprocess
 +TEST_PROGRAMS_NEED_X += test-svn-fe
 +
 +TEST_PROGRAMS = $(patsubst %,%$X,$(TEST_PROGRAMS_NEED_X))
  
  # List built-in command $C whose implementation cmd_$C() is not in
 -# builtin-$C.o but is linked in as part of some other command.
 -BUILT_INS += $(patsubst builtin-%.o,git-%$X,$(BUILTIN_OBJS))
 +# builtin/$C.o but is linked in as part of some other command.
 +BUILT_INS += $(patsubst builtin/%.o,git-%$X,$(BUILTIN_OBJS))
  
  BUILT_INS += git-cherry$X
  BUILT_INS += git-cherry-pick$X
@@@ -525,22 -378,12 +524,22 @@@ BUILT_INS += git-stage$
  BUILT_INS += git-status$X
  BUILT_INS += git-whatchanged$X
  
 -# what 'all' will build and 'install' will install, in gitexecdir
 +# what 'all' will build and 'install' will install in gitexecdir,
 +# excluding programs for built-in commands
  ALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS)
  
  # what 'all' will build but not install in gitexecdir
  OTHER_PROGRAMS = git$X
  
 +# what test wrappers are needed and 'install' will install, in bindir
 +BINDIR_PROGRAMS_NEED_X += git
 +BINDIR_PROGRAMS_NEED_X += git-upload-pack
 +BINDIR_PROGRAMS_NEED_X += git-receive-pack
 +BINDIR_PROGRAMS_NEED_X += git-upload-archive
 +BINDIR_PROGRAMS_NEED_X += git-shell
 +
 +BINDIR_PROGRAMS_NO_X += git-cvsserver
 +
  # Set paths to tools early so that they can be used for version tests.
  ifndef SHELL_PATH
        SHELL_PATH = /bin/sh
@@@ -548,166 -391,88 +547,166 @@@ endi
  ifndef PERL_PATH
        PERL_PATH = /usr/bin/perl
  endif
 +ifndef PYTHON_PATH
 +      PYTHON_PATH = /usr/bin/python
 +endif
  
  export PERL_PATH
 +export PYTHON_PATH
  
  LIB_FILE=libgit.a
  XDIFF_LIB=xdiff/lib.a
 -
 +VCSSVN_LIB=vcs-svn/lib.a
 +
 +LIB_H += xdiff/xinclude.h
 +LIB_H += xdiff/xmacros.h
 +LIB_H += xdiff/xdiff.h
 +LIB_H += xdiff/xtypes.h
 +LIB_H += xdiff/xutils.h
 +LIB_H += xdiff/xprepare.h
 +LIB_H += xdiff/xdiffi.h
 +LIB_H += xdiff/xemit.h
 +
 +LIB_H += vcs-svn/line_buffer.h
 +LIB_H += vcs-svn/sliding_window.h
 +LIB_H += vcs-svn/repo_tree.h
 +LIB_H += vcs-svn/fast_export.h
 +LIB_H += vcs-svn/svndiff.h
 +LIB_H += vcs-svn/svndump.h
 +
 +GENERATED_H += common-cmds.h
 +
 +LIB_H += advice.h
  LIB_H += archive.h
 +LIB_H += argv-array.h
  LIB_H += attr.h
 +LIB_H += bisect.h
  LIB_H += blob.h
 +LIB_H += branch.h
  LIB_H += builtin.h
 -LIB_H += cache.h
 +LIB_H += bulk-checkin.h
 +LIB_H += bundle.h
  LIB_H += cache-tree.h
 +LIB_H += cache.h
 +LIB_H += color.h
 +LIB_H += column.h
  LIB_H += commit.h
 +LIB_H += compat/bswap.h
  LIB_H += compat/cygwin.h
  LIB_H += compat/mingw.h
 +LIB_H += compat/obstack.h
 +LIB_H += compat/precompose_utf8.h
 +LIB_H += compat/terminal.h
 +LIB_H += compat/win32/dirent.h
 +LIB_H += compat/win32/poll.h
 +LIB_H += compat/win32/pthread.h
 +LIB_H += compat/win32/syslog.h
 +LIB_H += connected.h
 +LIB_H += convert.h
 +LIB_H += credential.h
  LIB_H += csum-file.h
  LIB_H += decorate.h
  LIB_H += delta.h
 -LIB_H += diffcore.h
  LIB_H += diff.h
 +LIB_H += diffcore.h
  LIB_H += dir.h
 +LIB_H += exec_cmd.h
 +LIB_H += fetch-pack.h
 +LIB_H += fmt-merge-msg.h
  LIB_H += fsck.h
 +LIB_H += gettext.h
  LIB_H += git-compat-util.h
 +LIB_H += gpg-interface.h
  LIB_H += graph.h
  LIB_H += grep.h
  LIB_H += hash.h
  LIB_H += help.h
 +LIB_H += http.h
 +LIB_H += kwset.h
  LIB_H += levenshtein.h
  LIB_H += list-objects.h
  LIB_H += ll-merge.h
  LIB_H += log-tree.h
  LIB_H += mailmap.h
 +LIB_H += merge-file.h
  LIB_H += merge-recursive.h
 +LIB_H += mergesort.h
 +LIB_H += notes-cache.h
 +LIB_H += notes-merge.h
 +LIB_H += notes.h
  LIB_H += object.h
 -LIB_H += pack.h
  LIB_H += pack-refs.h
  LIB_H += pack-revindex.h
 +LIB_H += pack.h
  LIB_H += parse-options.h
  LIB_H += patch-ids.h
  LIB_H += pkt-line.h
  LIB_H += progress.h
 +LIB_H += prompt.h
  LIB_H += quote.h
 +LIB_H += reachable.h
  LIB_H += reflog-walk.h
  LIB_H += refs.h
  LIB_H += remote.h
  LIB_H += rerere.h
 +LIB_H += resolve-undo.h
  LIB_H += revision.h
  LIB_H += run-command.h
 +LIB_H += send-pack.h
 +LIB_H += sequencer.h
 +LIB_H += sha1-array.h
  LIB_H += sha1-lookup.h
 +LIB_H += shortlog.h
  LIB_H += sideband.h
  LIB_H += sigchain.h
  LIB_H += strbuf.h
 +LIB_H += streaming.h
  LIB_H += string-list.h
 +LIB_H += submodule.h
  LIB_H += tag.h
 +LIB_H += tar.h
 +LIB_H += thread-utils.h
  LIB_H += transport.h
 -LIB_H += tree.h
  LIB_H += tree-walk.h
 +LIB_H += tree.h
  LIB_H += unpack-trees.h
 +LIB_H += url.h
  LIB_H += userdiff.h
  LIB_H += utf8.h
 +LIB_H += varint.h
 +LIB_H += walker.h
  LIB_H += wt-status.h
 +LIB_H += xdiff-interface.h
 +LIB_H += xdiff/xdiff.h
  
  LIB_OBJS += abspath.o
 +LIB_OBJS += advice.o
  LIB_OBJS += alias.o
  LIB_OBJS += alloc.o
  LIB_OBJS += archive.o
  LIB_OBJS += archive-tar.o
  LIB_OBJS += archive-zip.o
 +LIB_OBJS += argv-array.o
  LIB_OBJS += attr.o
  LIB_OBJS += base85.o
  LIB_OBJS += bisect.o
  LIB_OBJS += blob.o
  LIB_OBJS += branch.o
 +LIB_OBJS += bulk-checkin.o
  LIB_OBJS += bundle.o
  LIB_OBJS += cache-tree.o
  LIB_OBJS += color.o
 +LIB_OBJS += column.o
  LIB_OBJS += combine-diff.o
  LIB_OBJS += commit.o
 +LIB_OBJS += compat/obstack.o
 +LIB_OBJS += compat/terminal.o
  LIB_OBJS += config.o
  LIB_OBJS += connect.o
 +LIB_OBJS += connected.o
  LIB_OBJS += convert.o
  LIB_OBJS += copy.o
 +LIB_OBJS += credential.o
  LIB_OBJS += csum-file.o
  LIB_OBJS += ctype.o
  LIB_OBJS += date.o
@@@ -727,15 -492,11 +726,15 @@@ LIB_OBJS += entry.
  LIB_OBJS += environment.o
  LIB_OBJS += exec_cmd.o
  LIB_OBJS += fsck.o
 +LIB_OBJS += gettext.o
 +LIB_OBJS += gpg-interface.o
  LIB_OBJS += graph.o
  LIB_OBJS += grep.o
  LIB_OBJS += hash.o
  LIB_OBJS += help.o
 +LIB_OBJS += hex.o
  LIB_OBJS += ident.o
 +LIB_OBJS += kwset.o
  LIB_OBJS += levenshtein.o
  LIB_OBJS += list-objects.o
  LIB_OBJS += ll-merge.o
@@@ -745,11 -506,7 +744,11 @@@ LIB_OBJS += mailmap.
  LIB_OBJS += match-trees.o
  LIB_OBJS += merge-file.o
  LIB_OBJS += merge-recursive.o
 +LIB_OBJS += mergesort.o
  LIB_OBJS += name-hash.o
 +LIB_OBJS += notes.o
 +LIB_OBJS += notes-cache.o
 +LIB_OBJS += notes-merge.o
  LIB_OBJS += object.o
  LIB_OBJS += pack-check.o
  LIB_OBJS += pack-refs.o
@@@ -757,7 -514,6 +756,7 @@@ LIB_OBJS += pack-revindex.
  LIB_OBJS += pack-write.o
  LIB_OBJS += pager.o
  LIB_OBJS += parse-options.o
 +LIB_OBJS += parse-options-cb.o
  LIB_OBJS += patch-delta.o
  LIB_OBJS += patch-ids.o
  LIB_OBJS += path.o
@@@ -765,22 -521,17 +764,22 @@@ LIB_OBJS += pkt-line.
  LIB_OBJS += preload-index.o
  LIB_OBJS += pretty.o
  LIB_OBJS += progress.o
 +LIB_OBJS += prompt.o
  LIB_OBJS += quote.o
  LIB_OBJS += reachable.o
  LIB_OBJS += read-cache.o
  LIB_OBJS += reflog-walk.o
  LIB_OBJS += refs.o
  LIB_OBJS += remote.o
 +LIB_OBJS += replace_object.o
  LIB_OBJS += rerere.o
 +LIB_OBJS += resolve-undo.o
  LIB_OBJS += revision.o
  LIB_OBJS += run-command.o
 +LIB_OBJS += sequencer.o
  LIB_OBJS += server-info.o
  LIB_OBJS += setup.o
 +LIB_OBJS += sha1-array.o
  LIB_OBJS += sha1-lookup.o
  LIB_OBJS += sha1_file.o
  LIB_OBJS += sha1_name.o
@@@ -788,132 -539,108 +787,132 @@@ LIB_OBJS += shallow.
  LIB_OBJS += sideband.o
  LIB_OBJS += sigchain.o
  LIB_OBJS += strbuf.o
 +LIB_OBJS += streaming.o
  LIB_OBJS += string-list.o
 +LIB_OBJS += submodule.o
  LIB_OBJS += symlinks.o
  LIB_OBJS += tag.o
  LIB_OBJS += trace.o
  LIB_OBJS += transport.o
 +LIB_OBJS += transport-helper.o
  LIB_OBJS += tree-diff.o
  LIB_OBJS += tree.o
  LIB_OBJS += tree-walk.o
  LIB_OBJS += unpack-trees.o
 +LIB_OBJS += url.o
  LIB_OBJS += usage.o
  LIB_OBJS += userdiff.o
  LIB_OBJS += utf8.o
 +LIB_OBJS += varint.o
 +LIB_OBJS += version.o
  LIB_OBJS += walker.o
  LIB_OBJS += wrapper.o
  LIB_OBJS += write_or_die.o
  LIB_OBJS += ws.o
  LIB_OBJS += wt-status.o
  LIB_OBJS += xdiff-interface.o
 -
 -BUILTIN_OBJS += builtin-add.o
 -BUILTIN_OBJS += builtin-annotate.o
 -BUILTIN_OBJS += builtin-apply.o
 -BUILTIN_OBJS += builtin-archive.o
 -BUILTIN_OBJS += builtin-bisect--helper.o
 -BUILTIN_OBJS += builtin-blame.o
 -BUILTIN_OBJS += builtin-branch.o
 -BUILTIN_OBJS += builtin-bundle.o
 -BUILTIN_OBJS += builtin-cat-file.o
 -BUILTIN_OBJS += builtin-check-attr.o
 -BUILTIN_OBJS += builtin-check-ref-format.o
 -BUILTIN_OBJS += builtin-checkout-index.o
 -BUILTIN_OBJS += builtin-checkout.o
 -BUILTIN_OBJS += builtin-clean.o
 -BUILTIN_OBJS += builtin-clone.o
 -BUILTIN_OBJS += builtin-commit-tree.o
 -BUILTIN_OBJS += builtin-commit.o
 -BUILTIN_OBJS += builtin-config.o
 -BUILTIN_OBJS += builtin-count-objects.o
 -BUILTIN_OBJS += builtin-describe.o
 -BUILTIN_OBJS += builtin-diff-files.o
 -BUILTIN_OBJS += builtin-diff-index.o
 -BUILTIN_OBJS += builtin-diff-tree.o
 -BUILTIN_OBJS += builtin-diff.o
 -BUILTIN_OBJS += builtin-fast-export.o
 -BUILTIN_OBJS += builtin-fetch--tool.o
 -BUILTIN_OBJS += builtin-fetch-pack.o
 -BUILTIN_OBJS += builtin-fetch.o
 -BUILTIN_OBJS += builtin-fmt-merge-msg.o
 -BUILTIN_OBJS += builtin-for-each-ref.o
 -BUILTIN_OBJS += builtin-fsck.o
 -BUILTIN_OBJS += builtin-gc.o
 -BUILTIN_OBJS += builtin-grep.o
 -BUILTIN_OBJS += builtin-help.o
 -BUILTIN_OBJS += builtin-init-db.o
 -BUILTIN_OBJS += builtin-log.o
 -BUILTIN_OBJS += builtin-ls-files.o
 -BUILTIN_OBJS += builtin-ls-remote.o
 -BUILTIN_OBJS += builtin-ls-tree.o
 -BUILTIN_OBJS += builtin-mailinfo.o
 -BUILTIN_OBJS += builtin-mailsplit.o
 -BUILTIN_OBJS += builtin-merge.o
 -BUILTIN_OBJS += builtin-merge-base.o
 -BUILTIN_OBJS += builtin-merge-file.o
 -BUILTIN_OBJS += builtin-merge-ours.o
 -BUILTIN_OBJS += builtin-merge-recursive.o
 -BUILTIN_OBJS += builtin-mktree.o
 -BUILTIN_OBJS += builtin-mv.o
 -BUILTIN_OBJS += builtin-name-rev.o
 -BUILTIN_OBJS += builtin-pack-objects.o
 -BUILTIN_OBJS += builtin-pack-refs.o
 -BUILTIN_OBJS += builtin-prune-packed.o
 -BUILTIN_OBJS += builtin-prune.o
 -BUILTIN_OBJS += builtin-push.o
 -BUILTIN_OBJS += builtin-read-tree.o
 -BUILTIN_OBJS += builtin-receive-pack.o
 -BUILTIN_OBJS += builtin-reflog.o
 -BUILTIN_OBJS += builtin-remote.o
 -BUILTIN_OBJS += builtin-rerere.o
 -BUILTIN_OBJS += builtin-reset.o
 -BUILTIN_OBJS += builtin-rev-list.o
 -BUILTIN_OBJS += builtin-rev-parse.o
 -BUILTIN_OBJS += builtin-revert.o
 -BUILTIN_OBJS += builtin-rm.o
 -BUILTIN_OBJS += builtin-send-pack.o
 -BUILTIN_OBJS += builtin-shortlog.o
 -BUILTIN_OBJS += builtin-show-branch.o
 -BUILTIN_OBJS += builtin-show-ref.o
 -BUILTIN_OBJS += builtin-stripspace.o
 -BUILTIN_OBJS += builtin-symbolic-ref.o
 -BUILTIN_OBJS += builtin-tag.o
 -BUILTIN_OBJS += builtin-tar-tree.o
 -BUILTIN_OBJS += builtin-unpack-objects.o
 -BUILTIN_OBJS += builtin-update-index.o
 -BUILTIN_OBJS += builtin-update-ref.o
 -BUILTIN_OBJS += builtin-upload-archive.o
 -BUILTIN_OBJS += builtin-verify-pack.o
 -BUILTIN_OBJS += builtin-verify-tag.o
 -BUILTIN_OBJS += builtin-write-tree.o
 +LIB_OBJS += zlib.o
 +
 +BUILTIN_OBJS += builtin/add.o
 +BUILTIN_OBJS += builtin/annotate.o
 +BUILTIN_OBJS += builtin/apply.o
 +BUILTIN_OBJS += builtin/archive.o
 +BUILTIN_OBJS += builtin/bisect--helper.o
 +BUILTIN_OBJS += builtin/blame.o
 +BUILTIN_OBJS += builtin/branch.o
 +BUILTIN_OBJS += builtin/bundle.o
 +BUILTIN_OBJS += builtin/cat-file.o
 +BUILTIN_OBJS += builtin/check-attr.o
 +BUILTIN_OBJS += builtin/check-ref-format.o
 +BUILTIN_OBJS += builtin/checkout-index.o
 +BUILTIN_OBJS += builtin/checkout.o
 +BUILTIN_OBJS += builtin/clean.o
 +BUILTIN_OBJS += builtin/clone.o
 +BUILTIN_OBJS += builtin/column.o
 +BUILTIN_OBJS += builtin/commit-tree.o
 +BUILTIN_OBJS += builtin/commit.o
 +BUILTIN_OBJS += builtin/config.o
 +BUILTIN_OBJS += builtin/count-objects.o
 +BUILTIN_OBJS += builtin/credential.o
 +BUILTIN_OBJS += builtin/describe.o
 +BUILTIN_OBJS += builtin/diff-files.o
 +BUILTIN_OBJS += builtin/diff-index.o
 +BUILTIN_OBJS += builtin/diff-tree.o
 +BUILTIN_OBJS += builtin/diff.o
 +BUILTIN_OBJS += builtin/fast-export.o
 +BUILTIN_OBJS += builtin/fetch-pack.o
 +BUILTIN_OBJS += builtin/fetch.o
 +BUILTIN_OBJS += builtin/fmt-merge-msg.o
 +BUILTIN_OBJS += builtin/for-each-ref.o
 +BUILTIN_OBJS += builtin/fsck.o
 +BUILTIN_OBJS += builtin/gc.o
 +BUILTIN_OBJS += builtin/grep.o
 +BUILTIN_OBJS += builtin/hash-object.o
 +BUILTIN_OBJS += builtin/help.o
 +BUILTIN_OBJS += builtin/index-pack.o
 +BUILTIN_OBJS += builtin/init-db.o
 +BUILTIN_OBJS += builtin/log.o
 +BUILTIN_OBJS += builtin/ls-files.o
 +BUILTIN_OBJS += builtin/ls-remote.o
 +BUILTIN_OBJS += builtin/ls-tree.o
 +BUILTIN_OBJS += builtin/mailinfo.o
 +BUILTIN_OBJS += builtin/mailsplit.o
 +BUILTIN_OBJS += builtin/merge.o
 +BUILTIN_OBJS += builtin/merge-base.o
 +BUILTIN_OBJS += builtin/merge-file.o
 +BUILTIN_OBJS += builtin/merge-index.o
 +BUILTIN_OBJS += builtin/merge-ours.o
 +BUILTIN_OBJS += builtin/merge-recursive.o
 +BUILTIN_OBJS += builtin/merge-tree.o
 +BUILTIN_OBJS += builtin/mktag.o
 +BUILTIN_OBJS += builtin/mktree.o
 +BUILTIN_OBJS += builtin/mv.o
 +BUILTIN_OBJS += builtin/name-rev.o
 +BUILTIN_OBJS += builtin/notes.o
 +BUILTIN_OBJS += builtin/pack-objects.o
 +BUILTIN_OBJS += builtin/pack-redundant.o
 +BUILTIN_OBJS += builtin/pack-refs.o
 +BUILTIN_OBJS += builtin/patch-id.o
 +BUILTIN_OBJS += builtin/prune-packed.o
 +BUILTIN_OBJS += builtin/prune.o
 +BUILTIN_OBJS += builtin/push.o
 +BUILTIN_OBJS += builtin/read-tree.o
 +BUILTIN_OBJS += builtin/receive-pack.o
 +BUILTIN_OBJS += builtin/reflog.o
 +BUILTIN_OBJS += builtin/remote.o
 +BUILTIN_OBJS += builtin/remote-ext.o
 +BUILTIN_OBJS += builtin/remote-fd.o
 +BUILTIN_OBJS += builtin/replace.o
 +BUILTIN_OBJS += builtin/rerere.o
 +BUILTIN_OBJS += builtin/reset.o
 +BUILTIN_OBJS += builtin/rev-list.o
 +BUILTIN_OBJS += builtin/rev-parse.o
 +BUILTIN_OBJS += builtin/revert.o
 +BUILTIN_OBJS += builtin/rm.o
 +BUILTIN_OBJS += builtin/send-pack.o
 +BUILTIN_OBJS += builtin/shortlog.o
 +BUILTIN_OBJS += builtin/show-branch.o
 +BUILTIN_OBJS += builtin/show-ref.o
 +BUILTIN_OBJS += builtin/stripspace.o
 +BUILTIN_OBJS += builtin/symbolic-ref.o
 +BUILTIN_OBJS += builtin/tag.o
 +BUILTIN_OBJS += builtin/tar-tree.o
 +BUILTIN_OBJS += builtin/unpack-file.o
 +BUILTIN_OBJS += builtin/unpack-objects.o
 +BUILTIN_OBJS += builtin/update-index.o
 +BUILTIN_OBJS += builtin/update-ref.o
 +BUILTIN_OBJS += builtin/update-server-info.o
 +BUILTIN_OBJS += builtin/upload-archive.o
 +BUILTIN_OBJS += builtin/var.o
 +BUILTIN_OBJS += builtin/verify-pack.o
 +BUILTIN_OBJS += builtin/verify-tag.o
 +BUILTIN_OBJS += builtin/write-tree.o
  
  GITLIBS = $(LIB_FILE) $(XDIFF_LIB)
  EXTLIBS =
  
 +GIT_USER_AGENT = git/$(GIT_VERSION)
 +
  #
  # Platform specific tweaks
  #
  # because maintaining the nesting to match is a pain.  If
  # we had "elif" things would have been much nicer...
  
 +ifeq ($(uname_M),x86_64)
 +      XDL_FAST_HASH = YesPlease
 +endif
 +ifeq ($(uname_S),OSF1)
 +      # Need this for u_short definitions et al
 +      BASIC_CFLAGS += -D_OSF_SOURCE
 +      SOCKLEN_T = int
 +      NO_STRTOULL = YesPlease
 +      NO_NSEC = YesPlease
 +endif
  ifeq ($(uname_S),Linux)
        NO_STRLCPY = YesPlease
        NO_MKSTEMPS = YesPlease
 -      THREADED_DELTA_SEARCH = YesPlease
 +      HAVE_PATHS_H = YesPlease
 +      LIBC_CONTAINS_LIBINTL = YesPlease
 +      HAVE_DEV_TTY = YesPlease
  endif
  ifeq ($(uname_S),GNU/kFreeBSD)
        NO_STRLCPY = YesPlease
        NO_MKSTEMPS = YesPlease
 -      THREADED_DELTA_SEARCH = YesPlease
 +      HAVE_PATHS_H = YesPlease
 +      DIR_HAS_BSD_GROUP_SEMANTICS = YesPlease
 +      LIBC_CONTAINS_LIBINTL = YesPlease
  endif
  ifeq ($(uname_S),UnixWare)
        CC = cc
@@@ -988,7 -701,6 +987,7 @@@ ifeq ($(uname_S),SCO_SV
        TAR = gtar
  endif
  ifeq ($(uname_S),Darwin)
 +      NEEDS_CRYPTO_WITH_SSL = YesPlease
        NEEDS_SSL_WITH_CRYPTO = YesPlease
        NEEDS_LIBICONV = YesPlease
        ifeq ($(shell expr "$(uname_R)" : '[15678]\.'),2)
                NO_STRLCPY = YesPlease
        endif
        NO_MEMMEM = YesPlease
 -      THREADED_DELTA_SEARCH = YesPlease
        USE_ST_TIMESPEC = YesPlease
 +      HAVE_DEV_TTY = YesPlease
 +      COMPAT_OBJS += compat/precompose_utf8.o
 +      BASIC_CFLAGS += -DPRECOMPOSE_UNICODE
  endif
  ifeq ($(uname_S),SunOS)
        NEEDS_SOCKET = YesPlease
        NO_MKDTEMP = YesPlease
        NO_MKSTEMPS = YesPlease
        NO_REGEX = YesPlease
 -      NO_EXTERNAL_GREP = YesPlease
 +      NO_FNMATCH_CASEFOLD = YesPlease
 +      NO_MSGFMT_EXTENDED_OPTIONS = YesPlease
 +      ifeq ($(uname_R),5.6)
 +              SOCKLEN_T = int
 +              NO_HSTRERROR = YesPlease
 +              NO_IPV6 = YesPlease
 +              NO_SOCKADDR_STORAGE = YesPlease
 +              NO_UNSETENV = YesPlease
 +              NO_SETENV = YesPlease
 +              NO_STRLCPY = YesPlease
 +              NO_STRTOUMAX = YesPlease
 +              GIT_TEST_CMP = cmp
 +      endif
        ifeq ($(uname_R),5.7)
                NEEDS_RESOLV = YesPlease
                NO_IPV6 = YesPlease
                NO_UNSETENV = YesPlease
                NO_SETENV = YesPlease
                NO_STRLCPY = YesPlease
 -              NO_C99_FORMAT = YesPlease
                NO_STRTOUMAX = YesPlease
 +              GIT_TEST_CMP = cmp
        endif
        ifeq ($(uname_R),5.8)
                NO_UNSETENV = YesPlease
                NO_SETENV = YesPlease
 -              NO_C99_FORMAT = YesPlease
                NO_STRTOUMAX = YesPlease
 +              GIT_TEST_CMP = cmp
        endif
        ifeq ($(uname_R),5.9)
                NO_UNSETENV = YesPlease
                NO_SETENV = YesPlease
 -              NO_C99_FORMAT = YesPlease
                NO_STRTOUMAX = YesPlease
 -      endif
 -      ifdef NO_IPV6
 -              NEEDS_RESOLV = YesPlease
 +              GIT_TEST_CMP = cmp
        endif
        INSTALL = /usr/ucb/install
        TAR = gtar
        BASIC_CFLAGS += -D__EXTENSIONS__ -D__sun__ -DHAVE_ALLOCA_H
  endif
  ifeq ($(uname_O),Cygwin)
 -      NO_D_TYPE_IN_DIRENT = YesPlease
 -      NO_D_INO_IN_DIRENT = YesPlease
 -      NO_STRCASESTR = YesPlease
 -      NO_MEMMEM = YesPlease
 -      NO_MKSTEMPS = YesPlease
 -      NO_SYMLINK_HEAD = YesPlease
 +      ifeq ($(shell expr "$(uname_R)" : '1\.[1-6]\.'),4)
 +              NO_D_TYPE_IN_DIRENT = YesPlease
 +              NO_D_INO_IN_DIRENT = YesPlease
 +              NO_STRCASESTR = YesPlease
 +              NO_MEMMEM = YesPlease
 +              NO_MKSTEMPS = YesPlease
 +              NO_SYMLINK_HEAD = YesPlease
 +              NO_IPV6 = YesPlease
 +              OLD_ICONV = UnfortunatelyYes
 +      endif
 +      NO_THREAD_SAFE_PREAD = YesPlease
        NEEDS_LIBICONV = YesPlease
        NO_FAST_WORKING_DIRECTORY = UnfortunatelyYes
        NO_TRUSTABLE_FILEMODE = UnfortunatelyYes
 -      OLD_ICONV = UnfortunatelyYes
 +      NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease
        # There are conflicting reports about this.
        # On some boxes NO_MMAP is needed, and not so elsewhere.
        # Try commenting this out if you suspect MMAP is more efficient
        NO_MMAP = YesPlease
 -      NO_IPV6 = YesPlease
        X = .exe
 +      COMPAT_OBJS += compat/cygwin.o
 +      UNRELIABLE_FSTAT = UnfortunatelyYes
 +      SPARSE_FLAGS = -isystem /usr/include/w32api -Wno-one-bit-signed-bitfield
  endif
  ifeq ($(uname_S),FreeBSD)
        NEEDS_LIBICONV = YesPlease
 +      OLD_ICONV = YesPlease
        NO_MEMMEM = YesPlease
        BASIC_CFLAGS += -I/usr/local/include
        BASIC_LDFLAGS += -L/usr/local/lib
        DIR_HAS_BSD_GROUP_SEMANTICS = YesPlease
        USE_ST_TIMESPEC = YesPlease
 -      THREADED_DELTA_SEARCH = YesPlease
        ifeq ($(shell expr "$(uname_R)" : '4\.'),2)
                PTHREAD_LIBS = -pthread
                NO_UINTMAX_T = YesPlease
                NO_STRTOUMAX = YesPlease
        endif
 +      PYTHON_PATH = /usr/local/bin/python
 +      HAVE_PATHS_H = YesPlease
  endif
  ifeq ($(uname_S),OpenBSD)
        NO_STRCASESTR = YesPlease
        NEEDS_LIBICONV = YesPlease
        BASIC_CFLAGS += -I/usr/local/include
        BASIC_LDFLAGS += -L/usr/local/lib
 -      THREADED_DELTA_SEARCH = YesPlease
 +      HAVE_PATHS_H = YesPlease
  endif
  ifeq ($(uname_S),NetBSD)
        ifeq ($(shell expr "$(uname_R)" : '[01]\.'),2)
        endif
        BASIC_CFLAGS += -I/usr/pkg/include
        BASIC_LDFLAGS += -L/usr/pkg/lib $(CC_LD_DYNPATH)/usr/pkg/lib
 -      THREADED_DELTA_SEARCH = YesPlease
        USE_ST_TIMESPEC = YesPlease
        NO_MKSTEMPS = YesPlease
 +      HAVE_PATHS_H = YesPlease
  endif
  ifeq ($(uname_S),AIX)
 +      DEFAULT_PAGER = more
        NO_STRCASESTR=YesPlease
        NO_MEMMEM = YesPlease
        NO_MKDTEMP = YesPlease
        INTERNAL_QSORT = UnfortunatelyYes
        NEEDS_LIBICONV=YesPlease
        BASIC_CFLAGS += -D_LARGE_FILES
 -      ifneq ($(shell expr "$(uname_V)" : '[1234]'),1)
 -              THREADED_DELTA_SEARCH = YesPlease
 -      else
 +      ifeq ($(shell expr "$(uname_V)" : '[1234]'),1)
                NO_PTHREADS = YesPlease
 +      else
 +              PTHREAD_LIBS = -lpthread
 +      endif
 +      ifeq ($(shell expr "$(uname_V).$(uname_R)" : '5\.1'),3)
 +              INLINE=''
        endif
 +      GIT_TEST_CMP = cmp
  endif
  ifeq ($(uname_S),GNU)
        # GNU/Hurd
        NO_STRLCPY=YesPlease
        NO_MKSTEMPS = YesPlease
 +      HAVE_PATHS_H = YesPlease
 +      LIBC_CONTAINS_LIBINTL = YesPlease
  endif
  ifeq ($(uname_S),IRIX)
        NO_SETENV = YesPlease
        NO_MEMMEM = YesPlease
        NO_MKSTEMPS = YesPlease
        NO_MKDTEMP = YesPlease
 +      # When compiled with the MIPSpro 7.4.4m compiler, and without pthreads
 +      # (i.e. NO_PTHREADS is set), and _with_ MMAP (i.e. NO_MMAP is not set),
 +      # git dies with a segmentation fault when trying to access the first
 +      # entry of a reflog.  The conservative choice is made to always set
 +      # NO_MMAP.  If you suspect that your compiler is not affected by this
 +      # issue, comment out the NO_MMAP statement.
        NO_MMAP = YesPlease
 -      NO_EXTERNAL_GREP = UnfortunatelyYes
 +      NO_REGEX = YesPlease
 +      NO_FNMATCH_CASEFOLD = YesPlease
        SNPRINTF_RETURNS_BOGUS = YesPlease
        SHELL_PATH = /usr/gnu/bin/bash
        NEEDS_LIBGEN = YesPlease
@@@ -1168,21 -846,13 +1167,21 @@@ ifeq ($(uname_S),IRIX64
        NO_MEMMEM = YesPlease
        NO_MKSTEMPS = YesPlease
        NO_MKDTEMP = YesPlease
 +      # When compiled with the MIPSpro 7.4.4m compiler, and without pthreads
 +      # (i.e. NO_PTHREADS is set), and _with_ MMAP (i.e. NO_MMAP is not set),
 +      # git dies with a segmentation fault when trying to access the first
 +      # entry of a reflog.  The conservative choice is made to always set
 +      # NO_MMAP.  If you suspect that your compiler is not affected by this
 +      # issue, comment out the NO_MMAP statement.
        NO_MMAP = YesPlease
 -      NO_EXTERNAL_GREP = UnfortunatelyYes
 +      NO_REGEX = YesPlease
 +      NO_FNMATCH_CASEFOLD = YesPlease
        SNPRINTF_RETURNS_BOGUS = YesPlease
        SHELL_PATH=/usr/gnu/bin/bash
        NEEDS_LIBGEN = YesPlease
  endif
  ifeq ($(uname_S),HP-UX)
 +      INLINE = __inline
        NO_IPV6=YesPlease
        NO_SETENV=YesPlease
        NO_STRCASESTR=YesPlease
        NO_UNSETENV = YesPlease
        NO_HSTRERROR = YesPlease
        NO_SYS_SELECT_H = YesPlease
 +      NO_FNMATCH_CASEFOLD = YesPlease
        SNPRINTF_RETURNS_BOGUS = YesPlease
 +      NO_NSEC = YesPlease
 +      ifeq ($(uname_R),B.11.00)
 +              NO_INET_NTOP = YesPlease
 +              NO_INET_PTON = YesPlease
 +      endif
 +      ifeq ($(uname_R),B.10.20)
 +              # Override HP-UX 11.x setting:
 +              INLINE =
 +              SOCKLEN_T = size_t
 +              NO_PREAD = YesPlease
 +              NO_INET_NTOP = YesPlease
 +              NO_INET_PTON = YesPlease
 +      endif
 +      GIT_TEST_CMP = cmp
  endif
 -ifneq (,$(findstring CYGWIN,$(uname_S)))
 -      COMPAT_OBJS += compat/cygwin.o
 +ifeq ($(uname_S),Windows)
 +      GIT_VERSION := $(GIT_VERSION).MSVC
 +      pathsep = ;
 +      NO_PREAD = YesPlease
 +      NEEDS_CRYPTO_WITH_SSL = YesPlease
 +      NO_LIBGEN_H = YesPlease
 +      NO_SYS_POLL_H = YesPlease
 +      NO_SYMLINK_HEAD = YesPlease
 +      NO_IPV6 = YesPlease
 +      NO_UNIX_SOCKETS = YesPlease
 +      NO_SETENV = YesPlease
 +      NO_UNSETENV = YesPlease
 +      NO_STRCASESTR = YesPlease
 +      NO_STRLCPY = YesPlease
 +      NO_STRTOK_R = YesPlease
 +      NO_FNMATCH = YesPlease
 +      NO_MEMMEM = YesPlease
 +      # NEEDS_LIBICONV = YesPlease
 +      NO_ICONV = YesPlease
 +      NO_STRTOUMAX = YesPlease
 +      NO_STRTOULL = YesPlease
 +      NO_MKDTEMP = YesPlease
 +      NO_MKSTEMPS = YesPlease
 +      SNPRINTF_RETURNS_BOGUS = YesPlease
 +      NO_SVN_TESTS = YesPlease
 +      NO_PERL_MAKEMAKER = YesPlease
 +      RUNTIME_PREFIX = YesPlease
 +      NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease
 +      NO_NSEC = YesPlease
 +      USE_WIN32_MMAP = YesPlease
 +      # USE_NED_ALLOCATOR = YesPlease
        UNRELIABLE_FSTAT = UnfortunatelyYes
 +      OBJECT_CREATION_USES_RENAMES = UnfortunatelyNeedsTo
 +      NO_REGEX = YesPlease
 +      NO_CURL = YesPlease
 +      NO_PYTHON = YesPlease
 +      BLK_SHA1 = YesPlease
 +      NO_POSIX_GOODIES = UnfortunatelyYes
 +      NATIVE_CRLF = YesPlease
 +      DEFAULT_HELP_FORMAT = html
 +
 +      CC = compat/vcbuild/scripts/clink.pl
 +      AR = compat/vcbuild/scripts/lib.pl
 +      CFLAGS =
 +      BASIC_CFLAGS = -nologo -I. -I../zlib -Icompat/vcbuild -Icompat/vcbuild/include -DWIN32 -D_CONSOLE -DHAVE_STRING_H -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE
 +      COMPAT_OBJS = compat/msvc.o compat/winansi.o \
 +              compat/win32/pthread.o compat/win32/syslog.o \
 +              compat/win32/poll.o compat/win32/dirent.o
 +      COMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DNOGDI -DHAVE_STRING_H -DHAVE_ALLOCA_H -Icompat -Icompat/regex -Icompat/win32 -DSTRIP_EXTENSION=\".exe\"
 +      BASIC_LDFLAGS = -IGNORE:4217 -IGNORE:4049 -NOLOGO -SUBSYSTEM:CONSOLE -NODEFAULTLIB:MSVCRT.lib
 +      EXTLIBS = user32.lib advapi32.lib shell32.lib wininet.lib ws2_32.lib
 +      PTHREAD_LIBS =
 +      lib =
 +ifndef DEBUG
 +      BASIC_CFLAGS += -GL -Os -MT
 +      BASIC_LDFLAGS += -LTCG
 +      AR += -LTCG
 +else
 +      BASIC_CFLAGS += -Zi -MTd
 +endif
 +      X = .exe
 +endif
 +ifeq ($(uname_S),Interix)
 +      NO_INITGROUPS = YesPlease
 +      NO_IPV6 = YesPlease
 +      NO_MEMMEM = YesPlease
 +      NO_MKDTEMP = YesPlease
 +      NO_STRTOUMAX = YesPlease
 +      NO_NSEC = YesPlease
 +      NO_MKSTEMPS = YesPlease
 +      ifeq ($(uname_R),3.5)
 +              NO_INET_NTOP = YesPlease
 +              NO_INET_PTON = YesPlease
 +              NO_SOCKADDR_STORAGE = YesPlease
 +              NO_FNMATCH_CASEFOLD = YesPlease
 +      endif
 +      ifeq ($(uname_R),5.2)
 +              NO_INET_NTOP = YesPlease
 +              NO_INET_PTON = YesPlease
 +              NO_SOCKADDR_STORAGE = YesPlease
 +              NO_FNMATCH_CASEFOLD = YesPlease
 +      endif
 +endif
 +ifeq ($(uname_S),Minix)
 +      NO_IPV6 = YesPlease
 +      NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease
 +      NO_NSEC = YesPlease
 +      NEEDS_LIBGEN =
 +      NEEDS_CRYPTO_WITH_SSL = YesPlease
 +      NEEDS_IDN_WITH_CURL = YesPlease
 +      NEEDS_SSL_WITH_CURL = YesPlease
 +      NEEDS_RESOLV =
 +      NO_HSTRERROR = YesPlease
 +      NO_MMAP = YesPlease
 +      NO_CURL =
 +      NO_EXPAT =
  endif
  ifneq (,$(findstring MINGW,$(uname_S)))
        pathsep = ;
        NO_PREAD = YesPlease
 -      NO_OPENSSL = YesPlease
 +      NEEDS_CRYPTO_WITH_SSL = YesPlease
        NO_LIBGEN_H = YesPlease
 +      NO_SYS_POLL_H = YesPlease
        NO_SYMLINK_HEAD = YesPlease
 -      NO_IPV6 = YesPlease
 +      NO_UNIX_SOCKETS = YesPlease
        NO_SETENV = YesPlease
        NO_UNSETENV = YesPlease
        NO_STRCASESTR = YesPlease
        NO_STRLCPY = YesPlease
 +      NO_STRTOK_R = YesPlease
 +      NO_FNMATCH = YesPlease
        NO_MEMMEM = YesPlease
        NEEDS_LIBICONV = YesPlease
        OLD_ICONV = YesPlease
 -      NO_C99_FORMAT = YesPlease
        NO_STRTOUMAX = YesPlease
        NO_MKDTEMP = YesPlease
        NO_MKSTEMPS = YesPlease
 -      SNPRINTF_RETURNS_BOGUS = YesPlease
        NO_SVN_TESTS = YesPlease
        NO_PERL_MAKEMAKER = YesPlease
        RUNTIME_PREFIX = YesPlease
 -      NO_POSIX_ONLY_PROGRAMS = YesPlease
        NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease
        NO_NSEC = YesPlease
        USE_WIN32_MMAP = YesPlease
        UNRELIABLE_FSTAT = UnfortunatelyYes
        OBJECT_CREATION_USES_RENAMES = UnfortunatelyNeedsTo
        NO_REGEX = YesPlease
 -      COMPAT_CFLAGS += -D__USE_MINGW_ACCESS -DNOGDI -Icompat -Icompat/fnmatch
 +      NO_PYTHON = YesPlease
 +      BLK_SHA1 = YesPlease
 +      ETAGS_TARGET = ETAGS
 +      NO_INET_PTON = YesPlease
 +      NO_INET_NTOP = YesPlease
 +      NO_POSIX_GOODIES = UnfortunatelyYes
 +      COMPAT_CFLAGS += -D__USE_MINGW_ACCESS -DNOGDI -Icompat -Icompat/win32
        COMPAT_CFLAGS += -DSTRIP_EXTENSION=\".exe\"
 -      COMPAT_OBJS += compat/mingw.o compat/fnmatch/fnmatch.o compat/winansi.o
 +      COMPAT_OBJS += compat/mingw.o compat/winansi.o \
 +              compat/win32/pthread.o compat/win32/syslog.o \
 +              compat/win32/poll.o compat/win32/dirent.o
        EXTLIBS += -lws2_32
 +      PTHREAD_LIBS =
        X = .exe
 +      SPARSE_FLAGS = -Wno-one-bit-signed-bitfield
  ifneq (,$(wildcard ../THIS_IS_MSYSGIT))
        htmldir=doc/git/html/
        prefix =
        EXTLIBS += /mingw/lib/libz.a
        NO_R_TO_GCC_LINKER = YesPlease
        INTERNAL_QSORT = YesPlease
 -      THREADED_DELTA_SEARCH = YesPlease
 +      HAVE_LIBCHARSET_H = YesPlease
  else
        NO_CURL = YesPlease
 -      NO_PTHREADS = YesPlease
  endif
  endif
  
  -include config.mak.autogen
  -include config.mak
  
 +ifndef sysconfdir
 +ifeq ($(prefix),/usr)
 +sysconfdir = /etc
 +else
 +sysconfdir = etc
 +endif
 +endif
 +
 +ifdef CHECK_HEADER_DEPENDENCIES
 +COMPUTE_HEADER_DEPENDENCIES = no
 +USE_COMPUTED_HEADER_DEPENDENCIES =
 +endif
 +
 +ifndef COMPUTE_HEADER_DEPENDENCIES
 +COMPUTE_HEADER_DEPENDENCIES = auto
 +endif
 +
 +ifeq ($(COMPUTE_HEADER_DEPENDENCIES),auto)
 +dep_check = $(shell $(CC) $(ALL_CFLAGS) \
 +      -c -MF /dev/null -MMD -MP -x c /dev/null -o /dev/null 2>&1; \
 +      echo $$?)
 +ifeq ($(dep_check),0)
 +override COMPUTE_HEADER_DEPENDENCIES = yes
 +else
 +override COMPUTE_HEADER_DEPENDENCIES = no
 +endif
 +endif
 +
 +ifeq ($(COMPUTE_HEADER_DEPENDENCIES),yes)
 +USE_COMPUTED_HEADER_DEPENDENCIES = YesPlease
 +else
 +ifneq ($(COMPUTE_HEADER_DEPENDENCIES),no)
 +$(error please set COMPUTE_HEADER_DEPENDENCIES to yes, no, or auto \
 +(not "$(COMPUTE_HEADER_DEPENDENCIES)"))
 +endif
 +endif
 +
  ifdef SANE_TOOL_PATH
  SANE_TOOL_PATH_SQ = $(subst ','\'',$(SANE_TOOL_PATH))
  BROKEN_PATH_FIX = 's|^\# @@BROKEN_PATH_FIX@@$$|git_broken_path_fix $(SANE_TOOL_PATH_SQ)|'
@@@ -1413,14 -929,6 +1412,14 @@@ els
  BROKEN_PATH_FIX = '/^\# @@BROKEN_PATH_FIX@@$$/d'
  endif
  
 +ifneq (,$(INLINE))
 +      BASIC_CFLAGS += -Dinline=$(INLINE)
 +endif
 +
 +ifneq (,$(SOCKLEN_T))
 +      BASIC_CFLAGS += -Dsocklen_t=$(SOCKLEN_T)
 +endif
 +
  ifeq ($(uname_S),Darwin)
        ifndef NO_FINK
                ifeq ($(shell test -d /sw/lib && echo y),y)
@@@ -1452,20 -960,8 +1451,20 @@@ ifdef NO_LIBGEN_
        COMPAT_OBJS += compat/basename.o
  endif
  
 +ifdef USE_LIBPCRE
 +      BASIC_CFLAGS += -DUSE_LIBPCRE
 +      ifdef LIBPCREDIR
 +              BASIC_CFLAGS += -I$(LIBPCREDIR)/include
 +              EXTLIBS += -L$(LIBPCREDIR)/$(lib) $(CC_LD_DYNPATH)$(LIBPCREDIR)/$(lib)
 +      endif
 +      EXTLIBS += -lpcre
 +endif
 +
  ifdef NO_CURL
        BASIC_CFLAGS += -DNO_CURL
 +      REMOTE_CURL_PRIMARY =
 +      REMOTE_CURL_ALIASES =
 +      REMOTE_CURL_NAMES =
  else
        ifdef CURLDIR
                # Try "-Wl,-rpath=$(CURLDIR)/$(lib)" in such a case.
        else
                CURL_LIBCURL = -lcurl
        endif
 -      BUILTIN_OBJS += builtin-http-fetch.o
 -      EXTLIBS += $(CURL_LIBCURL)
 -      LIB_OBJS += http.o http-walker.o
 +      ifdef NEEDS_SSL_WITH_CURL
 +              CURL_LIBCURL += -lssl
 +              ifdef NEEDS_CRYPTO_WITH_SSL
 +                      CURL_LIBCURL += -lcrypto
 +              endif
 +      endif
 +      ifdef NEEDS_IDN_WITH_CURL
 +              CURL_LIBCURL += -lidn
 +      endif
 +
 +      REMOTE_CURL_PRIMARY = git-remote-http$X
 +      REMOTE_CURL_ALIASES = git-remote-https$X git-remote-ftp$X git-remote-ftps$X
 +      REMOTE_CURL_NAMES = $(REMOTE_CURL_PRIMARY) $(REMOTE_CURL_ALIASES)
 +      PROGRAM_OBJS += http-fetch.o
 +      PROGRAMS += $(REMOTE_CURL_NAMES)
        curl_check := $(shell (echo 070908; curl-config --vernum) | sort -r | sed -ne 2p)
        ifeq "$(curl_check)" "070908"
                ifndef NO_EXPAT
 -                      PROGRAMS += git-http-push$X
 +                      PROGRAM_OBJS += http-push.o
                endif
        endif
        ifndef NO_EXPAT
@@@ -1511,6 -995,10 +1510,6 @@@ ifdef ZLIB_PAT
  endif
  EXTLIBS += -lz
  
 -ifndef NO_POSIX_ONLY_PROGRAMS
 -      PROGRAMS += git-daemon$X
 -      PROGRAMS += git-imap-send$X
 -endif
  ifndef NO_OPENSSL
        OPENSSL_LIBSSL = -lssl
        ifdef OPENSSLDIR
        else
                OPENSSL_LINK =
        endif
 +      ifdef NEEDS_CRYPTO_WITH_SSL
 +              OPENSSL_LIBSSL += -lcrypto
 +      endif
  else
        BASIC_CFLAGS += -DNO_OPENSSL
        BLK_SHA1 = 1
        OPENSSL_LIBSSL =
  endif
 +ifdef NO_OPENSSL
 +      LIB_4_CRYPTO =
 +else
  ifdef NEEDS_SSL_WITH_CRYPTO
        LIB_4_CRYPTO = $(OPENSSL_LINK) -lcrypto -lssl
  else
        LIB_4_CRYPTO = $(OPENSSL_LINK) -lcrypto
  endif
 +endif
  ifdef NEEDS_LIBICONV
        ifdef ICONVDIR
                BASIC_CFLAGS += -I$(ICONVDIR)/include
@@@ -1548,11 -1029,6 +1547,11 @@@ endi
  ifdef NEEDS_LIBGEN
        EXTLIBS += -lgen
  endif
 +ifndef NO_GETTEXT
 +ifndef LIBC_CONTAINS_LIBINTL
 +      EXTLIBS += -lintl
 +endif
 +endif
  ifdef NEEDS_SOCKET
        EXTLIBS += -lsocket
  endif
@@@ -1577,12 -1053,12 +1576,12 @@@ endi
  ifdef USE_ST_TIMESPEC
        BASIC_CFLAGS += -DUSE_ST_TIMESPEC
  endif
 +ifdef NO_NORETURN
 +      BASIC_CFLAGS += -DNO_NORETURN
 +endif
  ifdef NO_NSEC
        BASIC_CFLAGS += -DNO_NSEC
  endif
 -ifdef NO_C99_FORMAT
 -      BASIC_CFLAGS += -DNO_C99_FORMAT
 -endif
  ifdef SNPRINTF_RETURNS_BOGUS
        COMPAT_CFLAGS += -DSNPRINTF_RETURNS_BOGUS
        COMPAT_OBJS += compat/snprintf.o
@@@ -1594,13 -1070,6 +1593,13 @@@ endi
  ifdef NO_SYMLINK_HEAD
        BASIC_CFLAGS += -DNO_SYMLINK_HEAD
  endif
 +ifdef GETTEXT_POISON
 +      BASIC_CFLAGS += -DGETTEXT_POISON
 +endif
 +ifdef NO_GETTEXT
 +      BASIC_CFLAGS += -DNO_GETTEXT
 +      USE_GETTEXT_SCHEME ?= fallthrough
 +endif
  ifdef NO_STRCASESTR
        COMPAT_CFLAGS += -DNO_STRCASESTR
        COMPAT_OBJS += compat/strcasestr.o
@@@ -1611,26 -1080,11 +1610,26 @@@ ifdef NO_STRLCP
  endif
  ifdef NO_STRTOUMAX
        COMPAT_CFLAGS += -DNO_STRTOUMAX
 -      COMPAT_OBJS += compat/strtoumax.o
 +      COMPAT_OBJS += compat/strtoumax.o compat/strtoimax.o
  endif
  ifdef NO_STRTOULL
        COMPAT_CFLAGS += -DNO_STRTOULL
  endif
 +ifdef NO_STRTOK_R
 +      COMPAT_CFLAGS += -DNO_STRTOK_R
 +      COMPAT_OBJS += compat/strtok_r.o
 +endif
 +ifdef NO_FNMATCH
 +      COMPAT_CFLAGS += -Icompat/fnmatch
 +      COMPAT_CFLAGS += -DNO_FNMATCH
 +      COMPAT_OBJS += compat/fnmatch/fnmatch.o
 +else
 +ifdef NO_FNMATCH_CASEFOLD
 +      COMPAT_CFLAGS += -Icompat/fnmatch
 +      COMPAT_CFLAGS += -DNO_FNMATCH_CASEFOLD
 +      COMPAT_OBJS += compat/fnmatch/fnmatch.o
 +endif
 +endif
  ifdef NO_SETENV
        COMPAT_CFLAGS += -DNO_SETENV
        COMPAT_OBJS += compat/setenv.o
@@@ -1641,6 -1095,7 +1640,6 @@@ ifdef NO_MKDTEM
  endif
  ifdef NO_MKSTEMPS
        COMPAT_CFLAGS += -DNO_MKSTEMPS
 -      COMPAT_OBJS += compat/mkstemps.o
  endif
  ifdef NO_UNSETENV
        COMPAT_CFLAGS += -DNO_UNSETENV
@@@ -1649,15 -1104,6 +1648,15 @@@ endi
  ifdef NO_SYS_SELECT_H
        BASIC_CFLAGS += -DNO_SYS_SELECT_H
  endif
 +ifdef NO_SYS_POLL_H
 +      BASIC_CFLAGS += -DNO_SYS_POLL_H
 +endif
 +ifdef NO_INTTYPES_H
 +      BASIC_CFLAGS += -DNO_INTTYPES_H
 +endif
 +ifdef NO_INITGROUPS
 +      BASIC_CFLAGS += -DNO_INITGROUPS
 +endif
  ifdef NO_MMAP
        COMPAT_CFLAGS += -DNO_MMAP
        COMPAT_OBJS += compat/mmap.o
@@@ -1673,10 -1119,6 +1672,10 @@@ endi
  ifdef NO_PREAD
        COMPAT_CFLAGS += -DNO_PREAD
        COMPAT_OBJS += compat/pread.o
 +      NO_THREAD_SAFE_PREAD = YesPlease
 +endif
 +ifdef NO_THREAD_SAFE_PREAD
 +      BASIC_CFLAGS += -DNO_THREAD_SAFE_PREAD
  endif
  ifdef NO_FAST_WORKING_DIRECTORY
        BASIC_CFLAGS += -DNO_FAST_WORKING_DIRECTORY
@@@ -1699,17 -1141,9 +1698,17 @@@ endi
  endif
  ifdef NO_INET_NTOP
        LIB_OBJS += compat/inet_ntop.o
 +      BASIC_CFLAGS += -DNO_INET_NTOP
  endif
  ifdef NO_INET_PTON
        LIB_OBJS += compat/inet_pton.o
 +      BASIC_CFLAGS += -DNO_INET_PTON
 +endif
 +ifndef NO_UNIX_SOCKETS
 +      LIB_OBJS += unix-socket.o
 +      LIB_H += unix-socket.h
 +      PROGRAM_OBJS += credential-cache.o
 +      PROGRAM_OBJS += credential-cache--daemon.o
  endif
  
  ifdef NO_ICONV
@@@ -1724,19 -1158,13 +1723,19 @@@ ifdef NO_DEFLATE_BOUN
        BASIC_CFLAGS += -DNO_DEFLATE_BOUND
  endif
  
 +ifdef NO_POSIX_GOODIES
 +      BASIC_CFLAGS += -DNO_POSIX_GOODIES
 +endif
 +
  ifdef BLK_SHA1
        SHA1_HEADER = "block-sha1/sha1.h"
        LIB_OBJS += block-sha1/sha1.o
 +      LIB_H += block-sha1/sha1.h
  else
  ifdef PPC_SHA1
        SHA1_HEADER = "ppc/sha1.h"
        LIB_OBJS += ppc/sha1.o ppc/sha1ppc.o
 +      LIB_H += ppc/sha1.h
  else
        SHA1_HEADER = <openssl/sha.h>
        EXTLIBS += $(LIB_4_CRYPTO)
@@@ -1762,29 -1190,22 +1761,29 @@@ ifdef RUNTIME_PREFI
  endif
  
  ifdef NO_PTHREADS
 -      THREADED_DELTA_SEARCH =
        BASIC_CFLAGS += -DNO_PTHREADS
  else
 +      BASIC_CFLAGS += $(PTHREAD_CFLAGS)
        EXTLIBS += $(PTHREAD_LIBS)
 +      LIB_OBJS += thread-utils.o
  endif
  
 -ifdef THREADED_DELTA_SEARCH
 -      BASIC_CFLAGS += -DTHREADED_DELTA_SEARCH
 -      LIB_OBJS += thread-utils.o
 +ifdef HAVE_PATHS_H
 +      BASIC_CFLAGS += -DHAVE_PATHS_H
 +endif
 +
 +ifdef HAVE_LIBCHARSET_H
 +      BASIC_CFLAGS += -DHAVE_LIBCHARSET_H
 +      EXTLIBS += $(CHARSET_LIB)
 +endif
 +
 +ifdef HAVE_DEV_TTY
 +      BASIC_CFLAGS += -DHAVE_DEV_TTY
  endif
 +
  ifdef DIR_HAS_BSD_GROUP_SEMANTICS
        COMPAT_CFLAGS += -DDIR_HAS_BSD_GROUP_SEMANTICS
  endif
 -ifdef NO_EXTERNAL_GREP
 -      BASIC_CFLAGS += -DNO_EXTERNAL_GREP
 -endif
  ifdef UNRELIABLE_FSTAT
        BASIC_CFLAGS += -DUNRELIABLE_FSTAT
  endif
@@@ -1794,22 -1215,10 +1793,22 @@@ ifdef NO_REGE
  endif
  
  ifdef USE_NED_ALLOCATOR
 -       COMPAT_CFLAGS += -DUSE_NED_ALLOCATOR -DOVERRIDE_STRDUP -DNDEBUG -DREPLACE_SYSTEM_ALLOCATOR -Icompat/nedmalloc
 +       COMPAT_CFLAGS += -Icompat/nedmalloc
         COMPAT_OBJS += compat/nedmalloc/nedmalloc.o
  endif
  
 +ifdef GIT_TEST_CMP_USE_COPIED_CONTEXT
 +      export GIT_TEST_CMP_USE_COPIED_CONTEXT
 +endif
 +
 +ifndef NO_MSGFMT_EXTENDED_OPTIONS
 +      MSGFMT += --check --statistics
 +endif
 +
 +ifneq (,$(XDL_FAST_HASH))
 +      BASIC_CFLAGS += -DXDL_FAST_HASH
 +endif
 +
  ifeq ($(TCLTK_PATH),)
  NO_TCLTK=NoThanks
  endif
@@@ -1818,10 -1227,6 +1817,10 @@@ ifeq ($(PERL_PATH),
  NO_PERL=NoThanks
  endif
  
 +ifeq ($(PYTHON_PATH),)
 +NO_PYTHON=NoThanks
 +endif
 +
  QUIET_SUBDIR0  = +$(MAKE) -C # space to separate -C and subdir
  QUIET_SUBDIR1  =
  
@@@ -1838,11 -1243,6 +1837,11 @@@ ifndef 
        QUIET_LINK     = @echo '   ' LINK $@;
        QUIET_BUILT_IN = @echo '   ' BUILTIN $@;
        QUIET_GEN      = @echo '   ' GEN $@;
 +      QUIET_LNCP     = @echo '   ' LN/CP $@;
 +      QUIET_XGETTEXT = @echo '   ' XGETTEXT $@;
 +      QUIET_MSGFMT   = @echo '   ' MSGFMT $@;
 +      QUIET_GCOV     = @echo '   ' GCOV $@;
 +      QUIET_SP       = @echo '   ' SP $<;
        QUIET_SUBDIR0  = +@subdir=
        QUIET_SUBDIR1  = ;$(NO_SUBDIR) echo '   ' SUBDIR $$subdir; \
                         $(MAKE) $(PRINT_DIR) -C $$subdir
  endif
  endif
  
 -ifdef ASCIIDOC8
 -      export ASCIIDOC8
 +ifdef NO_INSTALL_HARDLINKS
 +      export NO_INSTALL_HARDLINKS
 +endif
 +
 +### profile feedback build
 +#
 +
 +# Can adjust this to be a global directory if you want to do extended
 +# data gathering
 +PROFILE_DIR := $(CURDIR)
 +
 +ifeq ("$(PROFILE)","GEN")
 +      CFLAGS += -fprofile-generate=$(PROFILE_DIR) -DNO_NORETURN=1
 +      EXTLIBS += -lgcov
 +      export CCACHE_DISABLE=t
 +      V=1
 +else
 +ifneq ("$(PROFILE)","")
 +      CFLAGS += -fprofile-use=$(PROFILE_DIR) -fprofile-correction -DNO_NORETURN=1
 +      export CCACHE_DISABLE=t
 +      V=1
 +endif
  endif
  
  # Shell quote (do not use $(call) to accommodate ancient setups);
  
  SHA1_HEADER_SQ = $(subst ','\'',$(SHA1_HEADER))
  ETC_GITCONFIG_SQ = $(subst ','\'',$(ETC_GITCONFIG))
 +ETC_GITATTRIBUTES_SQ = $(subst ','\'',$(ETC_GITATTRIBUTES))
  
  DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
  bindir_SQ = $(subst ','\'',$(bindir))
  bindir_relative_SQ = $(subst ','\'',$(bindir_relative))
  mandir_SQ = $(subst ','\'',$(mandir))
  infodir_SQ = $(subst ','\'',$(infodir))
 +localedir_SQ = $(subst ','\'',$(localedir))
  gitexecdir_SQ = $(subst ','\'',$(gitexecdir))
  template_dir_SQ = $(subst ','\'',$(template_dir))
  htmldir_SQ = $(subst ','\'',$(htmldir))
  prefix_SQ = $(subst ','\'',$(prefix))
 +gitwebdir_SQ = $(subst ','\'',$(gitwebdir))
  
  SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
  PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
 +PYTHON_PATH_SQ = $(subst ','\'',$(PYTHON_PATH))
  TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH))
 +DIFF_SQ = $(subst ','\'',$(DIFF))
  
  LIBS = $(GITLIBS) $(EXTLIBS)
  
@@@ -1906,64 -1281,19 +1905,64 @@@ BASIC_CFLAGS += -DSHA1_HEADER='$(SHA1_H
        $(COMPAT_CFLAGS)
  LIB_OBJS += $(COMPAT_OBJS)
  
 +# Quote for C
 +
 +ifdef DEFAULT_EDITOR
 +DEFAULT_EDITOR_CQ = "$(subst ",\",$(subst \,\\,$(DEFAULT_EDITOR)))"
 +DEFAULT_EDITOR_CQ_SQ = $(subst ','\'',$(DEFAULT_EDITOR_CQ))
 +
 +BASIC_CFLAGS += -DDEFAULT_EDITOR='$(DEFAULT_EDITOR_CQ_SQ)'
 +endif
 +
 +ifdef DEFAULT_PAGER
 +DEFAULT_PAGER_CQ = "$(subst ",\",$(subst \,\\,$(DEFAULT_PAGER)))"
 +DEFAULT_PAGER_CQ_SQ = $(subst ','\'',$(DEFAULT_PAGER_CQ))
 +
 +BASIC_CFLAGS += -DDEFAULT_PAGER='$(DEFAULT_PAGER_CQ_SQ)'
 +endif
 +
 +ifdef SHELL_PATH
 +SHELL_PATH_CQ = "$(subst ",\",$(subst \,\\,$(SHELL_PATH)))"
 +SHELL_PATH_CQ_SQ = $(subst ','\'',$(SHELL_PATH_CQ))
 +
 +BASIC_CFLAGS += -DSHELL_PATH='$(SHELL_PATH_CQ_SQ)'
 +endif
 +
 +GIT_USER_AGENT_SQ = $(subst ','\'',$(GIT_USER_AGENT))
 +GIT_USER_AGENT_CQ = "$(subst ",\",$(subst \,\\,$(GIT_USER_AGENT)))"
 +GIT_USER_AGENT_CQ_SQ = $(subst ','\'',$(GIT_USER_AGENT_CQ))
 +GIT-USER-AGENT: FORCE
 +      @if test x'$(GIT_USER_AGENT_SQ)' != x"`cat GIT-USER-AGENT 2>/dev/null`"; then \
 +              echo '$(GIT_USER_AGENT_SQ)' >GIT-USER-AGENT; \
 +      fi
 +
 +ifdef DEFAULT_HELP_FORMAT
 +BASIC_CFLAGS += -DDEFAULT_HELP_FORMAT='"$(DEFAULT_HELP_FORMAT)"'
 +endif
 +
  ALL_CFLAGS += $(BASIC_CFLAGS)
  ALL_LDFLAGS += $(BASIC_LDFLAGS)
  
 -export TAR INSTALL DESTDIR SHELL_PATH
 +export DIFF TAR INSTALL DESTDIR SHELL_PATH
  
  
  ### Build rules
  
  SHELL = $(SHELL_PATH)
  
 -all:: shell_compatibility_test $(ALL_PROGRAMS) $(BUILT_INS) $(OTHER_PROGRAMS) GIT-BUILD-OPTIONS
 +all:: shell_compatibility_test
 +
 +ifeq "$(PROFILE)" "BUILD"
 +ifeq ($(filter all,$(MAKECMDGOALS)),all)
 +all:: profile-clean
 +      $(MAKE) PROFILE=GEN all
 +      $(MAKE) PROFILE=GEN -j1 test
 +endif
 +endif
 +
 +all:: $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) $(OTHER_PROGRAMS) GIT-BUILD-OPTIONS
  ifneq (,$X)
 -      $(QUIET_BUILT_IN)$(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) git$X)), test '$p' -ef '$p$X' || $(RM) '$p';)
 +      $(QUIET_BUILT_IN)$(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) git$X)), test -d '$p' -o '$p' -ef '$p$X' || $(RM) '$p';)
  endif
  
  all::
@@@ -1972,12 -1302,9 +1971,12 @@@ ifndef NO_TCLT
        $(QUIET_SUBDIR0)gitk-git $(QUIET_SUBDIR1) all
  endif
  ifndef NO_PERL
 -      $(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' all
 +      $(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' localedir='$(localedir_SQ)' all
  endif
 -      $(QUIET_SUBDIR0)templates $(QUIET_SUBDIR1)
 +ifndef NO_PYTHON
 +      $(QUIET_SUBDIR0)git_remote_helpers $(QUIET_SUBDIR1) PYTHON_PATH='$(PYTHON_PATH_SQ)' prefix='$(prefix_SQ)' all
 +endif
 +      $(QUIET_SUBDIR0)templates $(QUIET_SUBDIR1) SHELL_PATH='$(SHELL_PATH_SQ)' PERL_PATH='$(PERL_PATH_SQ)'
  
  please_set_SHELL_PATH_to_a_more_modern_shell:
        @$$(:)
@@@ -1987,61 -1314,20 +1986,61 @@@ shell_compatibility_test: please_set_SH
  strip: $(PROGRAMS) git$X
        $(STRIP) $(STRIP_OPTS) $(PROGRAMS) git$X
  
 -git.o: git.c common-cmds.h GIT-CFLAGS
 -      $(QUIET_CC)$(CC) -DGIT_VERSION='"$(GIT_VERSION)"' \
 -              '-DGIT_HTML_PATH="$(htmldir_SQ)"' \
 -              $(ALL_CFLAGS) -c $(filter %.c,$^)
 -
 -git$X: git.o $(BUILTIN_OBJS) $(GITLIBS)
 +### Target-specific flags and dependencies
 +
 +# The generic compilation pattern rule and automatically
 +# computed header dependencies (falling back to a dependency on
 +# LIB_H) are enough to describe how most targets should be built,
 +# but some targets are special enough to need something a little
 +# different.
 +#
 +# - When a source file "foo.c" #includes a generated header file,
 +#   we need to list that dependency for the "foo.o" target.
 +#
 +#   We also list it from other targets that are built from foo.c
 +#   like "foo.sp" and "foo.s", even though that is easy to forget
 +#   to do because the generated header is already present around
 +#   after a regular build attempt.
 +#
 +# - Some code depends on configuration kept in makefile
 +#   variables. The target-specific variable EXTRA_CPPFLAGS can
 +#   be used to convey that information to the C preprocessor
 +#   using -D options.
 +#
 +#   The "foo.o" target should have a corresponding dependency on
 +#   a file that changes when the value of the makefile variable
 +#   changes.  For example, targets making use of the
 +#   $(GIT_VERSION) variable depend on GIT-VERSION-FILE.
 +#
 +#   Technically the ".sp" and ".s" targets do not need this
 +#   dependency because they are force-built, but they get the
 +#   same dependency for consistency. This way, you do not have to
 +#   know how each target is implemented. And it means the
 +#   dependencies here will not need to change if the force-build
 +#   details change some day.
 +
 +git.sp git.s git.o: GIT-PREFIX
 +git.sp git.s git.o: EXTRA_CPPFLAGS = \
 +      '-DGIT_HTML_PATH="$(htmldir_SQ)"' \
 +      '-DGIT_MAN_PATH="$(mandir_SQ)"' \
 +      '-DGIT_INFO_PATH="$(infodir_SQ)"'
 +
 +git$X: git.o GIT-LDFLAGS $(BUILTIN_OBJS) $(GITLIBS)
        $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ git.o \
                $(BUILTIN_OBJS) $(ALL_LDFLAGS) $(LIBS)
  
 -builtin-help.o: builtin-help.c common-cmds.h GIT-CFLAGS
 -      $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) \
 -              '-DGIT_HTML_PATH="$(htmldir_SQ)"' \
 -              '-DGIT_MAN_PATH="$(mandir_SQ)"' \
 -              '-DGIT_INFO_PATH="$(infodir_SQ)"' $<
 +help.sp help.s help.o: common-cmds.h
 +
 +builtin/help.sp builtin/help.s builtin/help.o: common-cmds.h GIT-PREFIX
 +builtin/help.sp builtin/help.s builtin/help.o: EXTRA_CPPFLAGS = \
 +      '-DGIT_HTML_PATH="$(htmldir_SQ)"' \
 +      '-DGIT_MAN_PATH="$(mandir_SQ)"' \
 +      '-DGIT_INFO_PATH="$(infodir_SQ)"'
 +
 +version.sp version.s version.o: GIT-VERSION-FILE GIT-USER-AGENT
 +version.sp version.s version.o: EXTRA_CPPFLAGS = \
 +      '-DGIT_VERSION="$(GIT_VERSION)"' \
 +      '-DGIT_USER_AGENT=$(GIT_USER_AGENT_CQ_SQ)'
  
  $(BUILT_INS): git$X
        $(QUIET_BUILT_IN)$(RM) $@ && \
@@@ -2054,68 -1340,76 +2053,68 @@@ common-cmds.h: ./generate-cmdlist.sh co
  common-cmds.h: $(wildcard Documentation/git-*.txt)
        $(QUIET_GEN)./generate-cmdlist.sh > $@+ && mv $@+ $@
  
 -$(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
 -      $(QUIET_GEN)$(RM) $@ $@+ && \
 -      sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
 -          -e 's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \
 -          -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
 -          -e 's/@@NO_CURL@@/$(NO_CURL)/g' \
 -          -e $(BROKEN_PATH_FIX) \
 -          $@.sh >$@+ && \
 +SCRIPT_DEFINES = $(SHELL_PATH_SQ):$(DIFF_SQ):$(GIT_VERSION):\
 +      $(localedir_SQ):$(NO_CURL):$(USE_GETTEXT_SCHEME):$(SANE_TOOL_PATH_SQ):\
 +      $(gitwebdir_SQ):$(PERL_PATH_SQ)
 +define cmd_munge_script
 +$(RM) $@ $@+ && \
 +sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
 +    -e 's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \
 +    -e 's|@@DIFF@@|$(DIFF_SQ)|' \
 +    -e 's|@@LOCALEDIR@@|$(localedir_SQ)|g' \
 +    -e 's/@@NO_CURL@@/$(NO_CURL)/g' \
 +    -e 's/@@USE_GETTEXT_SCHEME@@/$(USE_GETTEXT_SCHEME)/g' \
 +    -e $(BROKEN_PATH_FIX) \
 +    -e 's|@@GITWEBDIR@@|$(gitwebdir_SQ)|g' \
 +    -e 's|@@PERL@@|$(PERL_PATH_SQ)|g' \
 +    $@.sh >$@+
 +endef
 +
 +GIT-SCRIPT-DEFINES: FORCE
 +      @FLAGS='$(SCRIPT_DEFINES)'; \
 +          if test x"$$FLAGS" != x"`cat $@ 2>/dev/null`" ; then \
 +              echo 1>&2 "    * new script parameters"; \
 +              echo "$$FLAGS" >$@; \
 +            fi
 +
 +
 +$(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh GIT-SCRIPT-DEFINES
 +      $(QUIET_GEN)$(cmd_munge_script) && \
        chmod +x $@+ && \
        mv $@+ $@
  
 +$(SCRIPT_LIB) : % : %.sh GIT-SCRIPT-DEFINES
 +      $(QUIET_GEN)$(cmd_munge_script) && \
 +      mv $@+ $@
 +
  ifndef NO_PERL
  $(patsubst %.perl,%,$(SCRIPT_PERL)): perl/perl.mak
  
 -perl/perl.mak: GIT-CFLAGS perl/Makefile perl/Makefile.PL
 +perl/perl.mak: GIT-CFLAGS GIT-PREFIX perl/Makefile perl/Makefile.PL
        $(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' $(@F)
  
 -$(patsubst %.perl,%,$(SCRIPT_PERL)): % : %.perl
 +$(patsubst %.perl,%,$(SCRIPT_PERL)): % : %.perl GIT-VERSION-FILE
        $(QUIET_GEN)$(RM) $@ $@+ && \
        INSTLIBDIR=`MAKEFLAGS= $(MAKE) -C perl -s --no-print-directory instlibdir` && \
        sed -e '1{' \
            -e '        s|#!.*perl|#!$(PERL_PATH_SQ)|' \
            -e '        h' \
 -          -e '        s=.*=use lib (split(/$(pathsep)/, $$ENV{GITPERLLIB} || "@@INSTLIBDIR@@"));=' \
 +          -e '        s=.*=use lib (split(/$(pathsep)/, $$ENV{GITPERLLIB} || "'"$$INSTLIBDIR"'"));=' \
            -e '        H' \
            -e '        x' \
            -e '}' \
 -          -e 's|@@INSTLIBDIR@@|'"$$INSTLIBDIR"'|g' \
            -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
            $@.perl >$@+ && \
        chmod +x $@+ && \
        mv $@+ $@
  
 -OTHER_PROGRAMS += gitweb/gitweb.cgi
 -gitweb/gitweb.cgi: gitweb/gitweb.perl
 -      $(QUIET_GEN)$(RM) $@ $@+ && \
 -      sed -e '1s|#!.*perl|#!$(PERL_PATH_SQ)|' \
 -          -e 's|++GIT_VERSION++|$(GIT_VERSION)|g' \
 -          -e 's|++GIT_BINDIR++|$(bindir)|g' \
 -          -e 's|++GITWEB_CONFIG++|$(GITWEB_CONFIG)|g' \
 -          -e 's|++GITWEB_CONFIG_SYSTEM++|$(GITWEB_CONFIG_SYSTEM)|g' \
 -          -e 's|++GITWEB_HOME_LINK_STR++|$(GITWEB_HOME_LINK_STR)|g' \
 -          -e 's|++GITWEB_SITENAME++|$(GITWEB_SITENAME)|g' \
 -          -e 's|++GITWEB_PROJECTROOT++|$(GITWEB_PROJECTROOT)|g' \
 -          -e 's|"++GITWEB_PROJECT_MAXDEPTH++"|$(GITWEB_PROJECT_MAXDEPTH)|g' \
 -          -e 's|++GITWEB_EXPORT_OK++|$(GITWEB_EXPORT_OK)|g' \
 -          -e 's|++GITWEB_STRICT_EXPORT++|$(GITWEB_STRICT_EXPORT)|g' \
 -          -e 's|++GITWEB_BASE_URL++|$(GITWEB_BASE_URL)|g' \
 -          -e 's|++GITWEB_LIST++|$(GITWEB_LIST)|g' \
 -          -e 's|++GITWEB_HOMETEXT++|$(GITWEB_HOMETEXT)|g' \
 -          -e 's|++GITWEB_CSS++|$(GITWEB_CSS)|g' \
 -          -e 's|++GITWEB_LOGO++|$(GITWEB_LOGO)|g' \
 -          -e 's|++GITWEB_FAVICON++|$(GITWEB_FAVICON)|g' \
 -          -e 's|++GITWEB_SITE_HEADER++|$(GITWEB_SITE_HEADER)|g' \
 -          -e 's|++GITWEB_SITE_FOOTER++|$(GITWEB_SITE_FOOTER)|g' \
 -          $< >$@+ && \
 -      chmod +x $@+ && \
 -      mv $@+ $@
  
 -git-instaweb: git-instaweb.sh gitweb/gitweb.cgi gitweb/gitweb.css
 -      $(QUIET_GEN)$(RM) $@ $@+ && \
 -      sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
 -          -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
 -          -e 's/@@NO_CURL@@/$(NO_CURL)/g' \
 -          -e '/@@GITWEB_CGI@@/r gitweb/gitweb.cgi' \
 -          -e '/@@GITWEB_CGI@@/d' \
 -          -e '/@@GITWEB_CSS@@/r gitweb/gitweb.css' \
 -          -e '/@@GITWEB_CSS@@/d' \
 -          -e 's|@@PERL@@|$(PERL_PATH_SQ)|g' \
 -          $@.sh > $@+ && \
 +.PHONY: gitweb
 +gitweb:
 +      $(QUIET_SUBDIR0)gitweb $(QUIET_SUBDIR1) all
 +
 +git-instaweb: git-instaweb.sh gitweb GIT-SCRIPT-DEFINES
 +      $(QUIET_GEN)$(cmd_munge_script) && \
        chmod +x $@+ && \
        mv $@+ $@
  else # NO_PERL
@@@ -2128,243 -1422,75 +2127,243 @@@ $(patsubst %.perl,%,$(SCRIPT_PERL)) git
        mv $@+ $@
  endif # NO_PERL
  
 -configure: configure.ac
 +ifndef NO_PYTHON
 +$(patsubst %.py,%,$(SCRIPT_PYTHON)): GIT-CFLAGS GIT-PREFIX
 +$(patsubst %.py,%,$(SCRIPT_PYTHON)): % : %.py
 +      $(QUIET_GEN)$(RM) $@ $@+ && \
 +      INSTLIBDIR=`MAKEFLAGS= $(MAKE) -C git_remote_helpers -s \
 +              --no-print-directory prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' \
 +              instlibdir` && \
 +      sed -e '1s|#!.*python|#!$(PYTHON_PATH_SQ)|' \
 +          -e 's|\(os\.getenv("GITPYTHONLIB"\)[^)]*)|\1,"@@INSTLIBDIR@@")|' \
 +          -e 's|@@INSTLIBDIR@@|'"$$INSTLIBDIR"'|g' \
 +          $@.py >$@+ && \
 +      chmod +x $@+ && \
 +      mv $@+ $@
 +else # NO_PYTHON
 +$(patsubst %.py,%,$(SCRIPT_PYTHON)): % : unimplemented.sh
 +      $(QUIET_GEN)$(RM) $@ $@+ && \
 +      sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
 +          -e 's|@@REASON@@|NO_PYTHON=$(NO_PYTHON)|g' \
 +          unimplemented.sh >$@+ && \
 +      chmod +x $@+ && \
 +      mv $@+ $@
 +endif # NO_PYTHON
 +
 +configure: configure.ac GIT-VERSION-FILE
        $(QUIET_GEN)$(RM) $@ $<+ && \
        sed -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
            $< > $<+ && \
        autoconf -o $@ $<+ && \
        $(RM) $<+
  
 -# These can record GIT_VERSION
 -git.o git.spec \
 -      $(patsubst %.sh,%,$(SCRIPT_SH)) \
 -      $(patsubst %.perl,%,$(SCRIPT_PERL)) \
 -      : GIT-VERSION-FILE
 +ifdef AUTOCONFIGURED
 +config.status: configure
 +      $(QUIET_GEN)if test -f config.status; then \
 +        ./config.status --recheck; \
 +      else \
 +        ./configure; \
 +      fi
 +reconfigure config.mak.autogen: config.status
 +      $(QUIET_GEN)./config.status
 +.PHONY: reconfigure # This is a convenience target.
 +endif
 +
 +XDIFF_OBJS += xdiff/xdiffi.o
 +XDIFF_OBJS += xdiff/xprepare.o
 +XDIFF_OBJS += xdiff/xutils.o
 +XDIFF_OBJS += xdiff/xemit.o
 +XDIFF_OBJS += xdiff/xmerge.o
 +XDIFF_OBJS += xdiff/xpatience.o
 +XDIFF_OBJS += xdiff/xhistogram.o
  
 -%.o: %.c GIT-CFLAGS
 -      $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $<
 -%.s: %.c GIT-CFLAGS
 -      $(QUIET_CC)$(CC) -S $(ALL_CFLAGS) $<
 -%.o: %.S
 -      $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $<
 +VCSSVN_OBJS += vcs-svn/line_buffer.o
 +VCSSVN_OBJS += vcs-svn/sliding_window.o
 +VCSSVN_OBJS += vcs-svn/repo_tree.o
 +VCSSVN_OBJS += vcs-svn/fast_export.o
 +VCSSVN_OBJS += vcs-svn/svndiff.o
 +VCSSVN_OBJS += vcs-svn/svndump.o
  
 -exec_cmd.o: exec_cmd.c GIT-CFLAGS
 -      $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) \
 -              '-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' \
 -              '-DBINDIR="$(bindir_relative_SQ)"' \
 -              '-DPREFIX="$(prefix_SQ)"' \
 -              $<
 +TEST_OBJS := $(patsubst test-%$X,test-%.o,$(TEST_PROGRAMS))
 +OBJECTS := $(LIB_OBJS) $(BUILTIN_OBJS) $(PROGRAM_OBJS) $(TEST_OBJS) \
 +      $(XDIFF_OBJS) \
 +      $(VCSSVN_OBJS) \
 +      git.o
 +ifndef NO_CURL
 +      OBJECTS += http.o http-walker.o remote-curl.o
 +endif
  
 -builtin-init-db.o: builtin-init-db.c GIT-CFLAGS
 -      $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir_SQ)"' $<
 +dep_files := $(foreach f,$(OBJECTS),$(dir $f).depend/$(notdir $f).d)
 +dep_dirs := $(addsuffix .depend,$(sort $(dir $(OBJECTS))))
  
 -config.o: config.c GIT-CFLAGS
 -      $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DETC_GITCONFIG='"$(ETC_GITCONFIG_SQ)"' $<
 +ifeq ($(COMPUTE_HEADER_DEPENDENCIES),yes)
 +$(dep_dirs):
 +      @mkdir -p $@
  
 -http.o: http.c GIT-CFLAGS
 -      $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DGIT_USER_AGENT='"git/$(GIT_VERSION)"' $<
 +missing_dep_dirs := $(filter-out $(wildcard $(dep_dirs)),$(dep_dirs))
 +dep_file = $(dir $@).depend/$(notdir $@).d
 +dep_args = -MF $(dep_file) -MMD -MP
 +ifdef CHECK_HEADER_DEPENDENCIES
 +$(error cannot compute header dependencies outside a normal build. \
 +Please unset CHECK_HEADER_DEPENDENCIES and try again)
 +endif
 +endif
 +
 +ifneq ($(COMPUTE_HEADER_DEPENDENCIES),yes)
 +ifndef CHECK_HEADER_DEPENDENCIES
 +dep_dirs =
 +missing_dep_dirs =
 +dep_args =
 +endif
 +endif
 +
 +ifdef CHECK_HEADER_DEPENDENCIES
 +ifndef PRINT_HEADER_DEPENDENCIES
 +missing_deps = $(filter-out $(notdir $^), \
 +      $(notdir $(shell $(MAKE) -s $@ \
 +              CHECK_HEADER_DEPENDENCIES=YesPlease \
 +              USE_COMPUTED_HEADER_DEPENDENCIES=YesPlease \
 +              PRINT_HEADER_DEPENDENCIES=YesPlease)))
 +endif
 +endif
 +
 +ASM_SRC := $(wildcard $(OBJECTS:o=S))
 +ASM_OBJ := $(ASM_SRC:S=o)
 +C_OBJ := $(filter-out $(ASM_OBJ),$(OBJECTS))
 +
 +.SUFFIXES:
 +
 +ifdef PRINT_HEADER_DEPENDENCIES
 +$(C_OBJ): %.o: %.c FORCE
 +      echo $^
 +$(ASM_OBJ): %.o: %.S FORCE
 +      echo $^
 +
 +ifndef CHECK_HEADER_DEPENDENCIES
 +$(error cannot print header dependencies during a normal build. \
 +Please set CHECK_HEADER_DEPENDENCIES and try again)
 +endif
 +endif
 +
 +ifndef PRINT_HEADER_DEPENDENCIES
 +ifdef CHECK_HEADER_DEPENDENCIES
 +$(C_OBJ): %.o: %.c $(dep_files) FORCE
 +      @set -e; echo CHECK $@; \
 +      missing_deps="$(missing_deps)"; \
 +      if test "$$missing_deps"; \
 +      then \
 +              echo missing dependencies: $$missing_deps; \
 +              false; \
 +      fi
 +$(ASM_OBJ): %.o: %.S $(dep_files) FORCE
 +      @set -e; echo CHECK $@; \
 +      missing_deps="$(missing_deps)"; \
 +      if test "$$missing_deps"; \
 +      then \
 +              echo missing dependencies: $$missing_deps; \
 +              false; \
 +      fi
 +endif
 +endif
 +
 +ifndef CHECK_HEADER_DEPENDENCIES
 +$(C_OBJ): %.o: %.c GIT-CFLAGS $(missing_dep_dirs)
 +      $(QUIET_CC)$(CC) -o $*.o -c $(dep_args) $(ALL_CFLAGS) $(EXTRA_CPPFLAGS) $<
 +$(ASM_OBJ): %.o: %.S GIT-CFLAGS $(missing_dep_dirs)
 +      $(QUIET_CC)$(CC) -o $*.o -c $(dep_args) $(ALL_CFLAGS) $(EXTRA_CPPFLAGS) $<
 +endif
 +
 +%.s: %.c GIT-CFLAGS FORCE
 +      $(QUIET_CC)$(CC) -o $@ -S $(ALL_CFLAGS) $(EXTRA_CPPFLAGS) $<
 +
 +ifdef USE_COMPUTED_HEADER_DEPENDENCIES
 +# Take advantage of gcc's on-the-fly dependency generation
 +# See <http://gcc.gnu.org/gcc-3.0/features.html>.
 +dep_files_present := $(wildcard $(dep_files))
 +ifneq ($(dep_files_present),)
 +include $(dep_files_present)
 +endif
 +else
 +# Dependencies on header files, for platforms that do not support
 +# the gcc -MMD option.
 +#
 +# Dependencies on automatically generated headers such as common-cmds.h
 +# should _not_ be included here, since they are necessary even when
 +# building an object for the first time.
 +
 +$(OBJECTS): $(LIB_H)
 +endif
 +
 +exec_cmd.sp exec_cmd.s exec_cmd.o: GIT-PREFIX
 +exec_cmd.sp exec_cmd.s exec_cmd.o: EXTRA_CPPFLAGS = \
 +      '-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' \
 +      '-DBINDIR="$(bindir_relative_SQ)"' \
 +      '-DPREFIX="$(prefix_SQ)"'
 +
 +builtin/init-db.sp builtin/init-db.s builtin/init-db.o: GIT-PREFIX
 +builtin/init-db.sp builtin/init-db.s builtin/init-db.o: EXTRA_CPPFLAGS = \
 +      -DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir_SQ)"'
 +
 +config.sp config.s config.o: GIT-PREFIX
 +config.sp config.s config.o: EXTRA_CPPFLAGS = \
 +      -DETC_GITCONFIG='"$(ETC_GITCONFIG_SQ)"'
 +
 +attr.sp attr.s attr.o: GIT-PREFIX
 +attr.sp attr.s attr.o: EXTRA_CPPFLAGS = \
 +      -DETC_GITATTRIBUTES='"$(ETC_GITATTRIBUTES_SQ)"'
 +
 +gettext.sp gettext.s gettext.o: GIT-PREFIX
 +gettext.sp gettext.s gettext.o: EXTRA_CPPFLAGS = \
 +      -DGIT_LOCALE_PATH='"$(localedir_SQ)"'
  
  ifdef NO_EXPAT
 -http-walker.o: http-walker.c http.h GIT-CFLAGS
 -      $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DNO_EXPAT $<
 +http-walker.sp http-walker.s http-walker.o: EXTRA_CPPFLAGS = -DNO_EXPAT
 +endif
 +
 +ifdef NO_REGEX
 +compat/regex/regex.sp compat/regex/regex.o: EXTRA_CPPFLAGS = \
 +      -DGAWK -DNO_MBSUPPORT
  endif
  
 -git-%$X: %.o $(GITLIBS)
 +ifdef USE_NED_ALLOCATOR
 +compat/nedmalloc/nedmalloc.sp compat/nedmalloc/nedmalloc.o: EXTRA_CPPFLAGS = \
 +      -DNDEBUG -DOVERRIDE_STRDUP -DREPLACE_SYSTEM_ALLOCATOR
 +endif
 +
 +git-%$X: %.o GIT-LDFLAGS $(GITLIBS)
        $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
  
 -git-imap-send$X: imap-send.o $(GITLIBS)
 +git-imap-send$X: imap-send.o GIT-LDFLAGS $(GITLIBS)
        $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
 -              $(LIBS) $(OPENSSL_LINK) $(OPENSSL_LIBSSL)
 -
 -http.o http-walker.o http-push.o transport.o: http.h
 +              $(LIBS) $(OPENSSL_LINK) $(OPENSSL_LIBSSL) $(LIB_4_CRYPTO)
  
 -git-http-push$X: revision.o http.o http-push.o $(GITLIBS)
 +git-http-fetch$X: revision.o http.o http-walker.o http-fetch.o GIT-LDFLAGS $(GITLIBS)
 +      $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
 +              $(LIBS) $(CURL_LIBCURL)
 +git-http-push$X: revision.o http.o http-push.o GIT-LDFLAGS $(GITLIBS)
        $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
                $(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
  
 -$(LIB_OBJS) $(BUILTIN_OBJS): $(LIB_H)
 -$(patsubst git-%$X,%.o,$(PROGRAMS)) git.o: $(LIB_H) $(wildcard */*.h)
 -builtin-revert.o wt-status.o: wt-status.h
 +$(REMOTE_CURL_ALIASES): $(REMOTE_CURL_PRIMARY)
 +      $(QUIET_LNCP)$(RM) $@ && \
 +      ln $< $@ 2>/dev/null || \
 +      ln -s $< $@ 2>/dev/null || \
 +      cp $< $@
 +
 +$(REMOTE_CURL_PRIMARY): remote-curl.o http.o http-walker.o GIT-LDFLAGS $(GITLIBS)
 +      $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
 +              $(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
  
  $(LIB_FILE): $(LIB_OBJS)
        $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIB_OBJS)
  
 -XDIFF_OBJS=xdiff/xdiffi.o xdiff/xprepare.o xdiff/xutils.o xdiff/xemit.o \
 -      xdiff/xmerge.o xdiff/xpatience.o
 -$(XDIFF_OBJS): xdiff/xinclude.h xdiff/xmacros.h xdiff/xdiff.h xdiff/xtypes.h \
 -      xdiff/xutils.h xdiff/xprepare.h xdiff/xdiffi.h xdiff/xemit.h
 -
  $(XDIFF_LIB): $(XDIFF_OBJS)
        $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(XDIFF_OBJS)
  
 +$(VCSSVN_LIB): $(VCSSVN_OBJS)
 +      $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(VCSSVN_OBJS)
 +
 +export DEFAULT_EDITOR DEFAULT_PAGER
  
  doc:
        $(MAKE) -C Documentation all
  pdf:
        $(MAKE) -C Documentation pdf
  
 -TAGS:
 -      $(RM) TAGS
 -      $(FIND) . -name '*.[hcS]' -print | xargs etags -a
 +XGETTEXT_FLAGS = \
 +      --force-po \
 +      --add-comments \
 +      --msgid-bugs-address="Git Mailing List <git@vger.kernel.org>" \
 +      --from-code=UTF-8
 +XGETTEXT_FLAGS_C = $(XGETTEXT_FLAGS) --language=C \
 +      --keyword=_ --keyword=N_ --keyword="Q_:1,2"
 +XGETTEXT_FLAGS_SH = $(XGETTEXT_FLAGS) --language=Shell
 +XGETTEXT_FLAGS_PERL = $(XGETTEXT_FLAGS) --keyword=__ --language=Perl
 +LOCALIZED_C := $(C_OBJ:o=c) $(LIB_H) $(GENERATED_H)
 +LOCALIZED_SH := $(SCRIPT_SH)
 +LOCALIZED_PERL := $(SCRIPT_PERL)
 +
 +ifdef XGETTEXT_INCLUDE_TESTS
 +LOCALIZED_C += t/t0200/test.c
 +LOCALIZED_SH += t/t0200/test.sh
 +LOCALIZED_PERL += t/t0200/test.perl
 +endif
 +
 +po/git.pot: $(LOCALIZED_C)
 +      $(QUIET_XGETTEXT)$(XGETTEXT) -o$@+ $(XGETTEXT_FLAGS_C) $(LOCALIZED_C)
 +      $(QUIET_XGETTEXT)$(XGETTEXT) -o$@+ --join-existing $(XGETTEXT_FLAGS_SH) \
 +              $(LOCALIZED_SH)
 +      $(QUIET_XGETTEXT)$(XGETTEXT) -o$@+ --join-existing $(XGETTEXT_FLAGS_PERL) \
 +              $(LOCALIZED_PERL)
 +      mv $@+ $@
 +
 +pot: po/git.pot
 +
 +POFILES := $(wildcard po/*.po)
 +MOFILES := $(patsubst po/%.po,po/build/locale/%/LC_MESSAGES/git.mo,$(POFILES))
  
 -tags:
 +ifndef NO_GETTEXT
 +all:: $(MOFILES)
 +endif
 +
 +po/build/locale/%/LC_MESSAGES/git.mo: po/%.po
 +      $(QUIET_MSGFMT)mkdir -p $(dir $@) && $(MSGFMT) -o $@ $<
 +
 +FIND_SOURCE_FILES = ( git ls-files '*.[hcS]' 2>/dev/null || \
 +                      $(FIND) . \( -name .git -type d -prune \) \
 +                              -o \( -name '*.[hcS]' -type f -print \) )
 +
 +$(ETAGS_TARGET): FORCE
 +      $(RM) $(ETAGS_TARGET)
 +      $(FIND_SOURCE_FILES) | xargs etags -a -o $(ETAGS_TARGET)
 +
 +tags: FORCE
        $(RM) tags
 -      $(FIND) . -name '*.[hcS]' -print | xargs ctags -a
 +      $(FIND_SOURCE_FILES) | xargs ctags -a
  
  cscope:
        $(RM) cscope*
 -      $(FIND) . -name '*.[hcS]' -print | xargs cscope -b
 +      $(FIND_SOURCE_FILES) | xargs cscope -b
  
  ### Detect prefix changes
 -TRACK_CFLAGS = $(subst ','\'',$(ALL_CFLAGS)):\
 -             $(bindir_SQ):$(gitexecdir_SQ):$(template_dir_SQ):$(prefix_SQ)
 +TRACK_PREFIX = $(bindir_SQ):$(gitexecdir_SQ):$(template_dir_SQ):$(prefix_SQ):\
 +              $(localedir_SQ)
 +
 +GIT-PREFIX: FORCE
 +      @FLAGS='$(TRACK_PREFIX)'; \
 +      if test x"$$FLAGS" != x"`cat GIT-PREFIX 2>/dev/null`" ; then \
 +              echo 1>&2 "    * new prefix flags"; \
 +              echo "$$FLAGS" >GIT-PREFIX; \
 +      fi
  
 -GIT-CFLAGS: .FORCE-GIT-CFLAGS
 +TRACK_CFLAGS = $(CC):$(subst ','\'',$(ALL_CFLAGS)):$(USE_GETTEXT_SCHEME)
 +
 +GIT-CFLAGS: FORCE
        @FLAGS='$(TRACK_CFLAGS)'; \
            if test x"$$FLAGS" != x"`cat GIT-CFLAGS 2>/dev/null`" ; then \
 -              echo 1>&2 "    * new build flags or prefix"; \
 +              echo 1>&2 "    * new build flags"; \
                echo "$$FLAGS" >GIT-CFLAGS; \
              fi
  
 +TRACK_LDFLAGS = $(subst ','\'',$(ALL_LDFLAGS))
 +
 +GIT-LDFLAGS: FORCE
 +      @FLAGS='$(TRACK_LDFLAGS)'; \
 +          if test x"$$FLAGS" != x"`cat GIT-LDFLAGS 2>/dev/null`" ; then \
 +              echo 1>&2 "    * new link flags"; \
 +              echo "$$FLAGS" >GIT-LDFLAGS; \
 +            fi
 +
  # We need to apply sq twice, once to protect from the shell
  # that runs GIT-BUILD-OPTIONS, and then again to protect it
  # and the first level quoting from the shell that runs "echo".
 -GIT-BUILD-OPTIONS: .FORCE-GIT-BUILD-OPTIONS
 +GIT-BUILD-OPTIONS: FORCE
        @echo SHELL_PATH=\''$(subst ','\'',$(SHELL_PATH_SQ))'\' >$@
 +      @echo PERL_PATH=\''$(subst ','\'',$(PERL_PATH_SQ))'\' >>$@
 +      @echo DIFF=\''$(subst ','\'',$(subst ','\'',$(DIFF)))'\' >>$@
 +      @echo PYTHON_PATH=\''$(subst ','\'',$(PYTHON_PATH_SQ))'\' >>$@
        @echo TAR=\''$(subst ','\'',$(subst ','\'',$(TAR)))'\' >>$@
        @echo NO_CURL=\''$(subst ','\'',$(subst ','\'',$(NO_CURL)))'\' >>$@
 +      @echo USE_LIBPCRE=\''$(subst ','\'',$(subst ','\'',$(USE_LIBPCRE)))'\' >>$@
        @echo NO_PERL=\''$(subst ','\'',$(subst ','\'',$(NO_PERL)))'\' >>$@
 +      @echo NO_PYTHON=\''$(subst ','\'',$(subst ','\'',$(NO_PYTHON)))'\' >>$@
 +      @echo NO_UNIX_SOCKETS=\''$(subst ','\'',$(subst ','\'',$(NO_UNIX_SOCKETS)))'\' >>$@
 +ifdef GIT_TEST_OPTS
 +      @echo GIT_TEST_OPTS=\''$(subst ','\'',$(subst ','\'',$(GIT_TEST_OPTS)))'\' >>$@
 +endif
 +ifdef GIT_TEST_CMP
 +      @echo GIT_TEST_CMP=\''$(subst ','\'',$(subst ','\'',$(GIT_TEST_CMP)))'\' >>$@
 +endif
 +ifdef GIT_TEST_CMP_USE_COPIED_CONTEXT
 +      @echo GIT_TEST_CMP_USE_COPIED_CONTEXT=YesPlease >>$@
 +endif
 +      @echo NO_GETTEXT=\''$(subst ','\'',$(subst ','\'',$(NO_GETTEXT)))'\' >>$@
 +      @echo GETTEXT_POISON=\''$(subst ','\'',$(subst ','\'',$(GETTEXT_POISON)))'\' >>$@
 +ifdef GIT_PERF_REPEAT_COUNT
 +      @echo GIT_PERF_REPEAT_COUNT=\''$(subst ','\'',$(subst ','\'',$(GIT_PERF_REPEAT_COUNT)))'\' >>$@
 +endif
 +ifdef GIT_PERF_REPO
 +      @echo GIT_PERF_REPO=\''$(subst ','\'',$(subst ','\'',$(GIT_PERF_REPO)))'\' >>$@
 +endif
 +ifdef GIT_PERF_LARGE_REPO
 +      @echo GIT_PERF_LARGE_REPO=\''$(subst ','\'',$(subst ','\'',$(GIT_PERF_LARGE_REPO)))'\' >>$@
 +endif
 +ifdef GIT_PERF_MAKE_OPTS
 +      @echo GIT_PERF_MAKE_OPTS=\''$(subst ','\'',$(subst ','\'',$(GIT_PERF_MAKE_OPTS)))'\' >>$@
 +endif
  
  ### Detect Tck/Tk interpreter path changes
  ifndef NO_TCLTK
  TRACK_VARS = $(subst ','\'',-DTCLTK_PATH='$(TCLTK_PATH_SQ)')
  
 -GIT-GUI-VARS: .FORCE-GIT-GUI-VARS
 +GIT-GUI-VARS: FORCE
        @VARS='$(TRACK_VARS)'; \
            if test x"$$VARS" != x"`cat $@ 2>/dev/null`" ; then \
                echo 1>&2 "    * new Tcl/Tk interpreter location"; \
                echo "$$VARS" >$@; \
              fi
 -
 -.PHONY: .FORCE-GIT-GUI-VARS
  endif
  
 -### Testing rules
 +test_bindir_programs := $(patsubst %,bin-wrappers/%,$(BINDIR_PROGRAMS_NEED_X) $(BINDIR_PROGRAMS_NO_X) $(TEST_PROGRAMS_NEED_X))
  
 -TEST_PROGRAMS += test-chmtime$X
 -TEST_PROGRAMS += test-ctype$X
 -TEST_PROGRAMS += test-date$X
 -TEST_PROGRAMS += test-delta$X
 -TEST_PROGRAMS += test-dump-cache-tree$X
 -TEST_PROGRAMS += test-genrandom$X
 -TEST_PROGRAMS += test-match-trees$X
 -TEST_PROGRAMS += test-parse-options$X
 -TEST_PROGRAMS += test-path-utils$X
 -TEST_PROGRAMS += test-sha1$X
 -TEST_PROGRAMS += test-sigchain$X
 +all:: $(TEST_PROGRAMS) $(test_bindir_programs)
  
 -all:: $(TEST_PROGRAMS)
 +bin-wrappers/%: wrap-for-bin.sh
 +      @mkdir -p bin-wrappers
 +      $(QUIET_GEN)sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
 +           -e 's|@@BUILD_DIR@@|$(shell pwd)|' \
 +           -e 's|@@PROG@@|$(@F)|' < $< > $@ && \
 +      chmod +x $@
  
  # GNU make supports exporting all variables by "export" without parameters.
  # However, the environment gets quite big, and some programs have problems
  
  export NO_SVN_TESTS
  
 +### Testing rules
 +
  test: all
        $(MAKE) -C t/ all
  
 +perf: all
 +      $(MAKE) -C t/perf/ all
 +
 +.PHONY: test perf
 +
  test-ctype$X: ctype.o
  
  test-date$X: date.o ctype.o
  
  test-delta$X: diff-delta.o patch-delta.o
  
 -test-parse-options$X: parse-options.o
 +test-line-buffer$X: vcs-svn/lib.a
  
 -test-parse-options.o: parse-options.h
 +test-parse-options$X: parse-options.o parse-options-cb.o
  
 -.PRECIOUS: $(patsubst test-%$X,test-%.o,$(TEST_PROGRAMS))
 +test-svn-fe$X: vcs-svn/lib.a
  
 -test-%$X: test-%.o $(GITLIBS)
 -      $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
 +.PRECIOUS: $(TEST_OBJS)
 +
 +test-%$X: test-%.o GIT-LDFLAGS $(GITLIBS)
 +      $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(filter %.a,$^) $(LIBS)
  
  check-sha1:: test-sha1$X
        ./test-sha1.sh
  
 +SP_OBJ = $(patsubst %.o,%.sp,$(C_OBJ))
 +
 +$(SP_OBJ): %.sp: %.c GIT-CFLAGS FORCE
 +      $(QUIET_SP)cgcc -no-compile $(ALL_CFLAGS) $(EXTRA_CPPFLAGS) \
 +              $(SPARSE_FLAGS) $<
 +
 +.PHONY: sparse $(SP_OBJ)
 +sparse: $(SP_OBJ)
 +
  check: common-cmds.h
 -      if sparse; \
 +      @if sparse; \
        then \
 -              for i in *.c; \
 -              do \
 -                      sparse $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i || exit; \
 -              done; \
 +              echo 2>&1 "Use 'make sparse' instead"; \
 +              $(MAKE) --no-print-directory sparse; \
        else \
                echo 2>&1 "Did you mean 'make test'?"; \
                exit 1; \
@@@ -2601,35 -1628,14 +2600,35 @@@ endi
  gitexec_instdir_SQ = $(subst ','\'',$(gitexec_instdir))
  export gitexec_instdir
  
 +ifneq ($(filter /%,$(firstword $(mergetoolsdir))),)
 +mergetools_instdir = $(mergetoolsdir)
 +else
 +mergetools_instdir = $(prefix)/$(mergetoolsdir)
 +endif
 +mergetools_instdir_SQ = $(subst ','\'',$(mergetools_instdir))
 +
 +install_bindir_programs := $(patsubst %,%$X,$(BINDIR_PROGRAMS_NEED_X)) $(BINDIR_PROGRAMS_NO_X)
 +
  install: all
        $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'
        $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
        $(INSTALL) $(ALL_PROGRAMS) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
 -      $(INSTALL) git$X git-upload-pack$X git-receive-pack$X git-upload-archive$X git-shell$X git-cvsserver '$(DESTDIR_SQ)$(bindir_SQ)'
 +      $(INSTALL) -m 644 $(SCRIPT_LIB) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
 +      $(INSTALL) $(install_bindir_programs) '$(DESTDIR_SQ)$(bindir_SQ)'
        $(MAKE) -C templates DESTDIR='$(DESTDIR_SQ)' install
 +      $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(mergetools_instdir_SQ)'
 +      $(INSTALL) -m 644 mergetools/* '$(DESTDIR_SQ)$(mergetools_instdir_SQ)'
 +ifndef NO_GETTEXT
 +      $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(localedir_SQ)'
 +      (cd po/build/locale && $(TAR) cf - .) | \
 +      (cd '$(DESTDIR_SQ)$(localedir_SQ)' && umask 022 && $(TAR) xof -)
 +endif
  ifndef NO_PERL
        $(MAKE) -C perl prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' install
 +      $(MAKE) -C gitweb install
 +endif
 +ifndef NO_PYTHON
 +      $(MAKE) -C git_remote_helpers prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' install
  endif
  ifndef NO_TCLTK
        $(MAKE) -C gitk-git install
@@@ -2638,44 -1644,21 +2637,44 @@@ endi
  ifneq (,$X)
        $(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';)
  endif
 +
        bindir=$$(cd '$(DESTDIR_SQ)$(bindir_SQ)' && pwd) && \
        execdir=$$(cd '$(DESTDIR_SQ)$(gitexec_instdir_SQ)' && pwd) && \
        { test "$$bindir/" = "$$execdir/" || \
 -              { $(RM) "$$execdir/git$X" && \
 -              test -z "$(NO_CROSS_DIRECTORY_HARDLINKS)" && \
 -              ln "$$bindir/git$X" "$$execdir/git$X" 2>/dev/null || \
 -              cp "$$bindir/git$X" "$$execdir/git$X"; } ; } && \
 -      { for p in $(BUILT_INS); do \
 +        for p in git$X $(filter $(install_bindir_programs),$(ALL_PROGRAMS)); do \
                $(RM) "$$execdir/$$p" && \
 +              test -z "$(NO_INSTALL_HARDLINKS)$(NO_CROSS_DIRECTORY_HARDLINKS)" && \
 +              ln "$$bindir/$$p" "$$execdir/$$p" 2>/dev/null || \
 +              cp "$$bindir/$$p" "$$execdir/$$p" || exit; \
 +        done; \
 +      } && \
 +      for p in $(filter $(install_bindir_programs),$(BUILT_INS)); do \
 +              $(RM) "$$bindir/$$p" && \
 +              test -z "$(NO_INSTALL_HARDLINKS)" && \
 +              ln "$$bindir/git$X" "$$bindir/$$p" 2>/dev/null || \
 +              ln -s "git$X" "$$bindir/$$p" 2>/dev/null || \
 +              cp "$$bindir/git$X" "$$bindir/$$p" || exit; \
 +      done && \
 +      for p in $(BUILT_INS); do \
 +              $(RM) "$$execdir/$$p" && \
 +              test -z "$(NO_INSTALL_HARDLINKS)" && \
                ln "$$execdir/git$X" "$$execdir/$$p" 2>/dev/null || \
                ln -s "git$X" "$$execdir/$$p" 2>/dev/null || \
                cp "$$execdir/git$X" "$$execdir/$$p" || exit; \
 -        done; } && \
 +      done && \
 +      remote_curl_aliases="$(REMOTE_CURL_ALIASES)" && \
 +      for p in $$remote_curl_aliases; do \
 +              $(RM) "$$execdir/$$p" && \
 +              test -z "$(NO_INSTALL_HARDLINKS)" && \
 +              ln "$$execdir/git-remote-http$X" "$$execdir/$$p" 2>/dev/null || \
 +              ln -s "git-remote-http$X" "$$execdir/$$p" 2>/dev/null || \
 +              cp "$$execdir/git-remote-http$X" "$$execdir/$$p" || exit; \
 +      done && \
        ./check_bindir "z$$bindir" "z$$execdir" "$$bindir/git-add$X"
  
 +install-gitweb:
 +      $(MAKE) -C gitweb install
 +
  install-doc:
        $(MAKE) -C Documentation install
  
@@@ -2704,7 -1687,7 +2703,7 @@@ quick-install-html
  
  ### Maintainer's dist rules
  
 -git.spec: git.spec.in
 +git.spec: git.spec.in GIT-VERSION-FILE
        sed -e 's/@@VERSION@@/$(GIT_VERSION)/g' < $< > $@+
        mv $@+ $@
  
@@@ -2725,10 -1708,7 +2724,10 @@@ dist: git.spec git-archive$(X) configur
        gzip -f -9 $(GIT_TARNAME).tar
  
  rpm: dist
 -      $(RPMBUILD) -ta $(GIT_TARNAME).tar.gz
 +      $(RPMBUILD) \
 +              --define "_source_filedigest_algorithm md5" \
 +              --define "_binary_filedigest_algorithm md5" \
 +              -ta $(GIT_TARNAME).tar.gz
  
  htmldocs = git-htmldocs-$(GIT_VERSION)
  manpages = git-manpages-$(GIT_VERSION)
@@@ -2754,33 -1734,22 +2753,33 @@@ dist-doc
  
  distclean: clean
        $(RM) configure
 +      $(RM) config.log config.status config.cache
 +      $(RM) config.mak.autogen config.mak.append
 +      $(RM) -r autom4te.cache
 +
 +profile-clean:
 +      $(RM) $(addsuffix *.gcda,$(addprefix $(PROFILE_DIR)/, $(object_dirs)))
 +      $(RM) $(addsuffix *.gcno,$(addprefix $(PROFILE_DIR)/, $(object_dirs)))
  
 -clean:
 -      $(RM) *.o mozilla-sha1/*.o arm/*.o ppc/*.o compat/*.o compat/*/*.o xdiff/*.o \
 -              $(LIB_FILE) $(XDIFF_LIB)
 -      $(RM) $(ALL_PROGRAMS) $(BUILT_INS) git$X
 +clean: profile-clean
 +      $(RM) *.o block-sha1/*.o ppc/*.o compat/*.o compat/*/*.o xdiff/*.o vcs-svn/*.o \
 +              builtin/*.o $(LIB_FILE) $(XDIFF_LIB) $(VCSSVN_LIB)
 +      $(RM) $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) git$X
        $(RM) $(TEST_PROGRAMS)
 -      $(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo common-cmds.h TAGS tags cscope*
 -      $(RM) -r autom4te.cache
 -      $(RM) config.log config.mak.autogen config.mak.append config.status config.cache
 +      $(RM) -r bin-wrappers
 +      $(RM) -r $(dep_dirs)
 +      $(RM) -r po/build/
 +      $(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo common-cmds.h $(ETAGS_TARGET) tags cscope*
        $(RM) -r $(GIT_TARNAME) .doc-tmp-dir
        $(RM) $(GIT_TARNAME).tar.gz git-core_$(GIT_VERSION)-*.tar.gz
        $(RM) $(htmldocs).tar.gz $(manpages).tar.gz
        $(MAKE) -C Documentation/ clean
  ifndef NO_PERL
 -      $(RM) gitweb/gitweb.cgi
 +      $(MAKE) -C gitweb clean
        $(MAKE) -C perl clean
 +endif
 +ifndef NO_PYTHON
 +      $(MAKE) -C git_remote_helpers clean
  endif
        $(MAKE) -C templates/ clean
        $(MAKE) -C t/ clean
@@@ -2788,23 -1757,22 +2787,23 @@@ ifndef NO_TCLT
        $(MAKE) -C gitk-git clean
        $(MAKE) -C git-gui clean
  endif
 -      $(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-GUI-VARS GIT-BUILD-OPTIONS
 +      $(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-LDFLAGS GIT-GUI-VARS GIT-BUILD-OPTIONS
 +      $(RM) GIT-USER-AGENT GIT-PREFIX GIT-SCRIPT-DEFINES
  
 -.PHONY: all install clean strip
 +.PHONY: all install profile-clean clean strip
  .PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell
 -.PHONY: .FORCE-GIT-VERSION-FILE TAGS tags cscope .FORCE-GIT-CFLAGS
 -.PHONY: .FORCE-GIT-BUILD-OPTIONS
 +.PHONY: FORCE cscope
  
  ### Check documentation
  #
  check-docs::
 -      @(for v in $(ALL_PROGRAMS) $(BUILT_INS) git gitk; \
 +      @(for v in $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) git gitk; \
        do \
                case "$$v" in \
                git-merge-octopus | git-merge-ours | git-merge-recursive | \
                git-merge-resolve | git-merge-subtree | \
                git-fsck-objects | git-init-db | \
 +              git-remote-* | git-stage | \
                git-?*--?* ) continue ;; \
                esac ; \
                test -f "Documentation/$$v.txt" || \
                documented,gitglossary | \
                documented,githooks | \
                documented,gitrepository-layout | \
 +              documented,gitrevisions | \
                documented,gittutorial | \
                documented,gittutorial-2 | \
 +              documented,git-bisect-lk2009 | \
 +              documented,git-remote-helpers | \
 +              documented,gitworkflows | \
                sentinel,not,matching,is,ok ) continue ;; \
                esac; \
 -              case " $(ALL_PROGRAMS) $(BUILT_INS) git gitk " in \
 +              case " $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) git gitk " in \
                *" $$cmd "*)    ;; \
                *) echo "removed but $$how: $$cmd" ;; \
                esac; \
@@@ -2867,18 -1831,11 +2866,18 @@@ coverage
        $(MAKE) coverage-build
        $(MAKE) coverage-report
  
 +object_dirs := $(sort $(dir $(OBJECTS)))
  coverage-clean:
 -      rm -f *.gcda *.gcno
 +      $(RM) $(addsuffix *.gcov,$(object_dirs))
 +      $(RM) $(addsuffix *.gcda,$(object_dirs))
 +      $(RM) $(addsuffix *.gcno,$(object_dirs))
 +      $(RM) coverage-untested-functions
 +      $(RM) -r cover_db/
 +      $(RM) -r cover_db_html/
  
  COVERAGE_CFLAGS = $(CFLAGS) -O0 -ftest-coverage -fprofile-arcs
  COVERAGE_LDFLAGS = $(CFLAGS)  -O0 -lgcov
 +GCOVFLAGS = --preserve-paths --branch-probabilities --all-blocks
  
  coverage-build: coverage-clean
        $(MAKE) CFLAGS="$(COVERAGE_CFLAGS)" LDFLAGS="$(COVERAGE_LDFLAGS)" all
                -j1 test
  
  coverage-report:
 -      gcov -b *.c
 +      $(QUIET_GCOV)for dir in $(object_dirs); do \
 +              $(GCOV) $(GCOVFLAGS) --object-directory=$$dir $$dir*.c || exit; \
 +      done
 +
 +coverage-untested-functions: coverage-report
        grep '^function.*called 0 ' *.c.gcov \
                | sed -e 's/\([^:]*\)\.gcov: *function \([^ ]*\) called.*/\1: \2/' \
 -              | tee coverage-untested-functions
 +              > coverage-untested-functions
 +
 +cover_db: coverage-report
 +      gcov2perl -db cover_db *.gcov
 +
 +cover_db_html: cover_db
 +      cover -report html -outputdir cover_db_html cover_db
 +
diff --combined block-sha1/sha1.c
index c0054a0b0a441090184a141ee73954a94a2904d5,6f885c43338d29fb8ef02afb233841d3a2750b14..a8d4bf9301d25de60c02718b9d446edf5c665184
@@@ -70,7 -70,6 +70,7 @@@
   */
  
  #if defined(__i386__) || defined(__x86_64__) || \
 +    defined(_M_IX86) || defined(_M_X64) || \
      defined(__ppc__) || defined(__ppc64__) || \
      defined(__powerpc__) || defined(__powerpc64__) || \
      defined(__s390__) || defined(__s390x__)
   * Where do we get the source from? The first 16 iterations get it from
   * the input data, the next mix it from the 512-bit array.
   */
- #define SHA_SRC(t) get_be32(data + t)
- #define SHA_MIX(t) SHA_ROL(W(t+13) ^ W(t+8) ^ W(t+2) ^ W(t), 1)
+ #define SHA_SRC(t) get_be32((unsigned char *) block + (t)*4)
+ #define SHA_MIX(t) SHA_ROL(W((t)+13) ^ W((t)+8) ^ W((t)+2) ^ W(t), 1);
  
  #define SHA_ROUND(t, input, fn, constant, A, B, C, D, E) do { \
        unsigned int TEMP = input(t); setW(t, TEMP); \
  #define T_40_59(t, A, B, C, D, E) SHA_ROUND(t, SHA_MIX, ((B&C)+(D&(B^C))) , 0x8f1bbcdc, A, B, C, D, E )
  #define T_60_79(t, A, B, C, D, E) SHA_ROUND(t, SHA_MIX, (B^C^D) ,  0xca62c1d6, A, B, C, D, E )
  
- static void blk_SHA1_Block(blk_SHA_CTX *ctx, const unsigned int *data)
+ static void blk_SHA1_Block(blk_SHA_CTX *ctx, const void *block)
  {
        unsigned int A,B,C,D,E;
        unsigned int array[16];
        D = ctx->H[3];
        E = ctx->H[4];
  
-       /* Round 1 - iterations 0-16 take their input from 'data' */
+       /* Round 1 - iterations 0-16 take their input from 'block' */
        T_0_15( 0, A, B, C, D, E);
        T_0_15( 1, E, A, B, C, D);
        T_0_15( 2, D, E, A, B, C);
@@@ -237,13 -236,13 +237,13 @@@ void blk_SHA1_Init(blk_SHA_CTX *ctx
  
  void blk_SHA1_Update(blk_SHA_CTX *ctx, const void *data, unsigned long len)
  {
 -      int lenW = ctx->size & 63;
 +      unsigned int lenW = ctx->size & 63;
  
        ctx->size += len;
  
        /* Read the data into W and process blocks as they get full */
        if (lenW) {
 -              int left = 64 - lenW;
 +              unsigned int left = 64 - lenW;
                if (len < left)
                        left = len;
                memcpy(lenW + (char *)ctx->W, data, left);
@@@ -270,8 -269,8 +270,8 @@@ void blk_SHA1_Final(unsigned char hasho
        int i;
  
        /* Pad with a binary 1 (ie 0x80), then zeroes, then length */
 -      padlen[0] = htonl(ctx->size >> 29);
 -      padlen[1] = htonl(ctx->size << 3);
 +      padlen[0] = htonl((uint32_t)(ctx->size >> 29));
 +      padlen[1] = htonl((uint32_t)(ctx->size << 3));
  
        i = ctx->size & 63;
        blk_SHA1_Update(ctx, pad, 1+ (63 & (55 - i)));