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