Makefileon commit git-ls-tree: add "-t" option to always show the tree entries (0f8f45c)
   1# The default target of this Makefile is...
   2all:
   3
   4# Define MOZILLA_SHA1 environment variable when running make to make use of
   5# a bundled SHA1 routine coming from Mozilla. It is GPL'd and should be fast
   6# on non-x86 architectures (e.g. PowerPC), while the OpenSSL version (default
   7# choice) has very fast version optimized for i586.
   8#
   9# Define NO_OPENSSL environment variable if you do not have OpenSSL. You will
  10# miss out git-rev-list --merge-order. This also implies MOZILLA_SHA1.
  11#
  12# Define NO_CURL if you do not have curl installed.  git-http-pull and
  13# git-http-push are not built, and you cannot use http:// and https://
  14# transports.
  15#
  16# Define CURLDIR=/foo/bar if your curl header and library files are in
  17# /foo/bar/include and /foo/bar/lib directories.
  18#
  19# Define NO_EXPAT if you do not have expat installed.  git-http-push is
  20# not built, and you cannot push using http:// and https:// transports.
  21#
  22# Define NO_STRCASESTR if you don't have strcasestr.
  23#
  24# Define PPC_SHA1 environment variable when running make to make use of
  25# a bundled SHA1 routine optimized for PowerPC.
  26#
  27# Define ARM_SHA1 environment variable when running make to make use of
  28# a bundled SHA1 routine optimized for ARM.
  29#
  30# Define NEEDS_SSL_WITH_CRYPTO if you need -lcrypto with -lssl (Darwin).
  31#
  32# Define NEEDS_LIBICONV if linking with libc is not enough (Darwin).
  33#
  34# Define NEEDS_SOCKET if linking with libc is not enough (SunOS,
  35# Patrick Mauritz).
  36#
  37# Define NO_MMAP if you want to avoid mmap.
  38#
  39# Define WITH_OWN_SUBPROCESS_PY if you want to use with python 2.3.
  40#
  41# Define NO_IPV6 if you lack IPv6 support and getaddrinfo().
  42#
  43# Define COLLISION_CHECK below if you believe that SHA1's
  44# 1461501637330902918203684832716283019655932542976 hashes do not give you
  45# sufficient guarantee that no collisions between objects will ever happen.
  46
  47# Define USE_NSEC below if you want git to care about sub-second file mtimes
  48# and ctimes. Note that you need recent glibc (at least 2.2.4) for this, and
  49# it will BREAK YOUR LOCAL DIFFS! show-diff and anything using it will likely
  50# randomly break unless your underlying filesystem supports those sub-second
  51# times (my ext3 doesn't).
  52
  53# Define USE_STDEV below if you want git to care about the underlying device
  54# change being considered an inode change from the update-cache perspective.
  55
  56GIT_VERSION = 0.99.9.GIT
  57
  58# CFLAGS and LDFLAGS are for the users to override from the command line.
  59
  60CFLAGS = -g -O2 -Wall
  61LDFLAGS =
  62ALL_CFLAGS = $(CFLAGS)
  63ALL_LDFLAGS = $(LDFLAGS)
  64
  65prefix = $(HOME)
  66bindir = $(prefix)/bin
  67template_dir = $(prefix)/share/git-core/templates/
  68GIT_PYTHON_DIR = $(prefix)/share/git-core/python
  69# DESTDIR=
  70
  71CC = gcc
  72AR = ar
  73TAR = tar
  74INSTALL = install
  75RPMBUILD = rpmbuild
  76
  77# sparse is architecture-neutral, which means that we need to tell it
  78# explicitly what architecture to check for. Fix this up for yours..
  79SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
  80
  81
  82
  83### --- END CONFIGURATION SECTION ---
  84
  85SCRIPT_SH = \
  86        git-add.sh git-bisect.sh git-branch.sh git-checkout.sh \
  87        git-cherry.sh git-clone.sh git-commit.sh \
  88        git-count-objects.sh git-diff.sh git-fetch.sh \
  89        git-format-patch.sh git-log.sh git-ls-remote.sh \
  90        git-merge-one-file.sh git-octopus.sh git-parse-remote.sh \
  91        git-prune.sh git-pull.sh git-push.sh git-rebase.sh \
  92        git-repack.sh git-request-pull.sh git-reset.sh \
  93        git-resolve.sh git-revert.sh git-sh-setup.sh git-status.sh \
  94        git-tag.sh git-verify-tag.sh git-whatchanged.sh \
  95        git-applymbox.sh git-applypatch.sh git-am.sh \
  96        git-merge.sh git-merge-stupid.sh git-merge-octopus.sh \
  97        git-merge-resolve.sh git-merge-ours.sh git-grep.sh \
  98        git-lost-found.sh
  99
 100SCRIPT_PERL = \
 101        git-archimport.perl git-cvsimport.perl git-relink.perl \
 102        git-shortlog.perl git-fmt-merge-msg.perl \
 103        git-svnimport.perl git-mv.perl git-cvsexportcommit.perl
 104
 105SCRIPT_PYTHON = \
 106        git-merge-recursive.py
 107
 108SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \
 109          $(patsubst %.perl,%,$(SCRIPT_PERL)) \
 110          $(patsubst %.py,%,$(SCRIPT_PYTHON)) \
 111          gitk git-cherry-pick
 112
 113# The ones that do not have to link with lcrypto nor lz.
 114SIMPLE_PROGRAMS = \
 115        git-get-tar-commit-id$X git-mailinfo$X git-mailsplit$X \
 116        git-stripspace$X git-daemon$X
 117
 118# ... and all the rest
 119PROGRAMS = \
 120        git-apply$X git-cat-file$X \
 121        git-checkout-index$X git-clone-pack$X git-commit-tree$X \
 122        git-convert-objects$X git-diff-files$X \
 123        git-diff-index$X git-diff-stages$X \
 124        git-diff-tree$X git-fetch-pack$X git-fsck-objects$X \
 125        git-hash-object$X git-index-pack$X git-init-db$X \
 126        git-local-fetch$X git-ls-files$X git-ls-tree$X git-merge-base$X \
 127        git-merge-index$X git-mktag$X git-pack-objects$X git-patch-id$X \
 128        git-peek-remote$X git-prune-packed$X git-read-tree$X \
 129        git-receive-pack$X git-rev-list$X git-rev-parse$X \
 130        git-send-pack$X git-show-branch$X git-shell$X \
 131        git-show-index$X git-ssh-fetch$X \
 132        git-ssh-upload$X git-tar-tree$X git-unpack-file$X \
 133        git-unpack-objects$X git-update-index$X git-update-server-info$X \
 134        git-upload-pack$X git-verify-pack$X git-write-tree$X \
 135        git-update-ref$X git-symbolic-ref$X git-check-ref-format$X \
 136        git-name-rev$X git-pack-redundant$X git-repo-config$X git-var$X
 137
 138# what 'all' will build and 'install' will install.
 139ALL_PROGRAMS = $(PROGRAMS) $(SIMPLE_PROGRAMS) $(SCRIPTS) git$X
 140
 141# Backward compatibility -- to be removed after 1.0
 142PROGRAMS += git-ssh-pull$X git-ssh-push$X
 143
 144# Set paths to tools early so that they can be used for version tests.
 145ifndef SHELL_PATH
 146        SHELL_PATH = /bin/sh
 147endif
 148ifndef PERL_PATH
 149        PERL_PATH = /usr/bin/perl
 150endif
 151ifndef PYTHON_PATH
 152        PYTHON_PATH = /usr/bin/python
 153endif
 154
 155PYMODULES = \
 156        gitMergeCommon.py
 157
 158LIB_FILE=libgit.a
 159
 160LIB_H = \
 161        blob.h cache.h commit.h count-delta.h csum-file.h delta.h \
 162        diff.h epoch.h object.h pack.h pkt-line.h quote.h refs.h \
 163        run-command.h strbuf.h tag.h tree.h
 164
 165DIFF_OBJS = \
 166        diff.o diffcore-break.o diffcore-order.o diffcore-pathspec.o \
 167        diffcore-pickaxe.o diffcore-rename.o tree-diff.o
 168
 169LIB_OBJS = \
 170        blob.o commit.o connect.o count-delta.o csum-file.o \
 171        date.o diff-delta.o entry.o ident.o index.o \
 172        object.o pack-check.o patch-delta.o path.o pkt-line.o \
 173        quote.o read-cache.o refs.o run-command.o \
 174        server-info.o setup.o sha1_file.o sha1_name.o strbuf.o \
 175        tag.o tree.o usage.o config.o environment.o ctype.o copy.o \
 176        $(DIFF_OBJS)
 177
 178LIBS = $(LIB_FILE)
 179LIBS += -lz
 180
 181# Shell quote;
 182# Result of this needs to be placed inside ''
 183shq = $(subst ','\'',$(1))
 184# This has surrounding ''
 185shellquote = '$(call shq,$(1))'
 186
 187#
 188# Platform specific tweaks
 189#
 190
 191# We choose to avoid "if .. else if .. else .. endif endif"
 192# because maintaining the nesting to match is a pain.  If
 193# we had "elif" things would have been much nicer...
 194uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
 195uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not')
 196uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')
 197
 198ifeq ($(uname_S),Darwin)
 199        NEEDS_SSL_WITH_CRYPTO = YesPlease
 200        NEEDS_LIBICONV = YesPlease
 201        ## fink
 202        ALL_CFLAGS += -I/sw/include
 203        ALL_LDFLAGS += -L/sw/lib
 204        ## darwinports
 205        ALL_CFLAGS += -I/opt/local/include
 206        ALL_LDFLAGS += -L/opt/local/lib
 207endif
 208ifeq ($(uname_S),SunOS)
 209        NEEDS_SOCKET = YesPlease
 210        NEEDS_NSL = YesPlease
 211        NEEDS_LIBICONV = YesPlease
 212        SHELL_PATH = /bin/bash
 213        NO_STRCASESTR = YesPlease
 214        INSTALL = ginstall
 215        TAR = gtar
 216        ALL_CFLAGS += -D__EXTENSIONS__
 217endif
 218ifeq ($(uname_O),Cygwin)
 219        NO_STRCASESTR = YesPlease
 220        NEEDS_LIBICONV = YesPlease
 221        # There are conflicting reports about this.
 222        # On some boxes NO_MMAP is needed, and not so elsewhere.
 223        # Try uncommenting this if you see things break -- YMMV.
 224        # NO_MMAP = YesPlease
 225        NO_IPV6 = YesPlease
 226        X = .exe
 227        ALL_CFLAGS += -DUSE_SYMLINK_HEAD=0
 228endif
 229ifeq ($(uname_S),OpenBSD)
 230        NO_STRCASESTR = YesPlease
 231        NEEDS_LIBICONV = YesPlease
 232        ALL_CFLAGS += -I/usr/local/include
 233        ALL_LDFLAGS += -L/usr/local/lib
 234endif
 235ifeq ($(uname_S),NetBSD)
 236        NEEDS_LIBICONV = YesPlease
 237        ALL_CFLAGS += -I/usr/pkg/include
 238        ALL_LDFLAGS += -L/usr/pkg/lib -Wl,-rpath,/usr/pkg/lib
 239endif
 240ifneq (,$(findstring arm,$(uname_M)))
 241        ARM_SHA1 = YesPlease
 242endif
 243
 244-include config.mak
 245
 246ifdef WITH_OWN_SUBPROCESS_PY
 247        PYMODULES += compat/subprocess.py
 248else
 249        ifneq ($(shell $(PYTHON_PATH) -c 'import subprocess;print"OK"' 2>/dev/null),OK)
 250                PYMODULES += compat/subprocess.py
 251        endif
 252endif
 253
 254ifdef WITH_SEND_EMAIL
 255        SCRIPT_PERL += git-send-email.perl
 256endif
 257
 258ifndef NO_CURL
 259        ifdef CURLDIR
 260                # This is still problematic -- gcc does not always want -R.
 261                ALL_CFLAGS += -I$(CURLDIR)/include
 262                CURL_LIBCURL = -L$(CURLDIR)/lib -R$(CURLDIR)/lib -lcurl
 263        else
 264                CURL_LIBCURL = -lcurl
 265        endif
 266        PROGRAMS += git-http-fetch$X
 267        curl_check := $(shell (echo 070908; curl-config --vernum) | sort -r | sed -ne 2p)
 268        ifeq "$(curl_check)" "070908"
 269                ifndef NO_EXPAT
 270                        EXPAT_LIBEXPAT = -lexpat
 271                        PROGRAMS += git-http-push$X
 272                endif
 273        endif
 274endif
 275
 276ifndef NO_OPENSSL
 277        LIB_OBJS += epoch.o
 278        OPENSSL_LIBSSL = -lssl
 279        ifdef OPENSSLDIR
 280                # Again this may be problematic -- gcc does not always want -R.
 281                ALL_CFLAGS += -I$(OPENSSLDIR)/include
 282                OPENSSL_LINK = -L$(OPENSSLDIR)/lib -R$(OPENSSLDIR)/lib
 283        else
 284                OPENSSL_LINK =
 285        endif
 286else
 287        ALL_CFLAGS += -DNO_OPENSSL
 288        MOZILLA_SHA1 = 1
 289        OPENSSL_LIBSSL =
 290endif
 291ifdef NEEDS_SSL_WITH_CRYPTO
 292        LIB_4_CRYPTO = $(OPENSSL_LINK) -lcrypto -lssl
 293else
 294        LIB_4_CRYPTO = $(OPENSSL_LINK) -lcrypto
 295endif
 296ifdef NEEDS_LIBICONV
 297        ifdef ICONVDIR
 298                # Again this may be problematic -- gcc does not always want -R.
 299                ALL_CFLAGS += -I$(ICONVDIR)/include
 300                ICONV_LINK = -L$(ICONVDIR)/lib -R$(ICONVDIR)/lib
 301        else
 302                ICONV_LINK =
 303        endif
 304        LIB_4_ICONV = $(ICONV_LINK) -liconv
 305else
 306        LIB_4_ICONV =
 307endif
 308ifdef NEEDS_SOCKET
 309        LIBS += -lsocket
 310        SIMPLE_LIB += -lsocket
 311endif
 312ifdef NEEDS_NSL
 313        LIBS += -lnsl
 314        SIMPLE_LIB += -lnsl
 315endif
 316ifdef NO_STRCASESTR
 317        ALL_CFLAGS += -Dstrcasestr=gitstrcasestr -DNO_STRCASESTR=1
 318        LIB_OBJS += compat/strcasestr.o
 319endif
 320ifdef NO_MMAP
 321        ALL_CFLAGS += -Dmmap=gitfakemmap -Dmunmap=gitfakemunmap -DNO_MMAP
 322        LIB_OBJS += compat/mmap.o
 323endif
 324ifdef NO_IPV6
 325        ALL_CFLAGS += -DNO_IPV6 -Dsockaddr_storage=sockaddr_in
 326endif
 327
 328ifdef PPC_SHA1
 329        SHA1_HEADER = "ppc/sha1.h"
 330        LIB_OBJS += ppc/sha1.o ppc/sha1ppc.o
 331else
 332ifdef ARM_SHA1
 333        SHA1_HEADER = "arm/sha1.h"
 334        LIB_OBJS += arm/sha1.o arm/sha1_arm.o
 335else
 336ifdef MOZILLA_SHA1
 337        SHA1_HEADER = "mozilla-sha1/sha1.h"
 338        LIB_OBJS += mozilla-sha1/sha1.o
 339else
 340        SHA1_HEADER = <openssl/sha.h>
 341        LIBS += $(LIB_4_CRYPTO)
 342endif
 343endif
 344endif
 345
 346ALL_CFLAGS += -DSHA1_HEADER=$(call shellquote,$(SHA1_HEADER))
 347
 348export prefix TAR INSTALL DESTDIR SHELL_PATH template_dir
 349### Build rules
 350
 351all: $(ALL_PROGRAMS)
 352
 353all:
 354        $(MAKE) -C templates
 355
 356# Only use $(CFLAGS). We don't need anything else.
 357git$(X): git.c Makefile
 358        $(CC) -DGIT_EXEC_PATH='"$(bindir)"' -DGIT_VERSION='"$(GIT_VERSION)"' \
 359                $(CFLAGS) $< -o $@
 360
 361$(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
 362        rm -f $@
 363        sed -e '1s|#!.*/sh|#!$(call shq,$(SHELL_PATH))|' \
 364            -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
 365            $@.sh >$@
 366        chmod +x $@
 367
 368$(patsubst %.perl,%,$(SCRIPT_PERL)) : % : %.perl
 369        rm -f $@
 370        sed -e '1s|#!.*perl|#!$(call shq,$(PERL_PATH))|' \
 371            -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
 372            $@.perl >$@
 373        chmod +x $@
 374
 375$(patsubst %.py,%,$(SCRIPT_PYTHON)) : % : %.py
 376        rm -f $@
 377        sed -e '1s|#!.*python|#!$(call shq,$(PYTHON_PATH))|' \
 378            -e 's|@@GIT_PYTHON_PATH@@|$(call shq,$(GIT_PYTHON_DIR))|g' \
 379            -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
 380            $@.py >$@
 381        chmod +x $@
 382
 383git-cherry-pick: git-revert
 384        cp $< $@
 385
 386%.o: %.c
 387        $(CC) -o $*.o -c $(ALL_CFLAGS) $<
 388%.o: %.S
 389        $(CC) -o $*.o -c $(ALL_CFLAGS) $<
 390
 391git-%$X: %.o $(LIB_FILE)
 392        $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
 393
 394git-mailinfo$X : SIMPLE_LIB += $(LIB_4_ICONV)
 395$(SIMPLE_PROGRAMS) : $(LIB_FILE)
 396$(SIMPLE_PROGRAMS) : git-%$X : %.o
 397        $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
 398                $(LIB_FILE) $(SIMPLE_LIB)
 399
 400git-http-fetch$X: fetch.o http.o
 401git-http-push$X: http.o
 402git-local-fetch$X: fetch.o
 403git-ssh-fetch$X: rsh.o fetch.o
 404git-ssh-upload$X: rsh.o
 405git-ssh-pull$X: rsh.o fetch.o
 406git-ssh-push$X: rsh.o
 407
 408git-http-fetch$X: LIBS += $(CURL_LIBCURL)
 409git-http-push$X: LIBS += $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
 410git-rev-list$X: LIBS += $(OPENSSL_LIBSSL)
 411
 412init-db.o: init-db.c
 413        $(CC) -c $(ALL_CFLAGS) \
 414                -DDEFAULT_GIT_TEMPLATE_DIR=$(call shellquote,"$(template_dir)") $*.c
 415
 416$(LIB_OBJS): $(LIB_H)
 417$(patsubst git-%$X,%.o,$(PROGRAMS)): $(LIB_H)
 418$(DIFF_OBJS): diffcore.h
 419
 420$(LIB_FILE): $(LIB_OBJS)
 421        $(AR) rcs $@ $(LIB_OBJS)
 422
 423doc:
 424        $(MAKE) -C Documentation all
 425
 426
 427### Testing rules
 428
 429test: all
 430        $(MAKE) -C t/ all
 431
 432test-date$X: test-date.c date.o ctype.o
 433        $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) test-date.c date.o ctype.o
 434
 435test-delta$X: test-delta.c diff-delta.o patch-delta.o
 436        $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $^
 437
 438check:
 439        for i in *.c; do sparse $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i; done
 440
 441
 442
 443### Installation rules
 444
 445install: all
 446        $(INSTALL) -d -m755 $(call shellquote,$(DESTDIR)$(bindir))
 447        $(INSTALL) $(ALL_PROGRAMS) $(call shellquote,$(DESTDIR)$(bindir))
 448        $(MAKE) -C templates install
 449        $(INSTALL) -d -m755 $(call shellquote,$(DESTDIR)$(GIT_PYTHON_DIR))
 450        $(INSTALL) $(PYMODULES) $(call shellquote,$(DESTDIR)$(GIT_PYTHON_DIR))
 451
 452install-doc:
 453        $(MAKE) -C Documentation install
 454
 455
 456
 457
 458### Maintainer's dist rules
 459
 460git.spec: git.spec.in Makefile
 461        sed -e 's/@@VERSION@@/$(GIT_VERSION)/g' < $< > $@
 462
 463GIT_TARNAME=git-$(GIT_VERSION)
 464dist: git.spec git-tar-tree
 465        ./git-tar-tree HEAD $(GIT_TARNAME) > $(GIT_TARNAME).tar
 466        @mkdir -p $(GIT_TARNAME)
 467        @cp git.spec $(GIT_TARNAME)
 468        $(TAR) rf $(GIT_TARNAME).tar $(GIT_TARNAME)/git.spec
 469        @rm -rf $(GIT_TARNAME)
 470        gzip -f -9 $(GIT_TARNAME).tar
 471
 472rpm: dist
 473        $(RPMBUILD) -ta $(GIT_TARNAME).tar.gz
 474
 475deb: dist
 476        rm -rf $(GIT_TARNAME)
 477        $(TAR) zxf $(GIT_TARNAME).tar.gz
 478        dpkg-source -b $(GIT_TARNAME)
 479        cd $(GIT_TARNAME) && fakeroot debian/rules binary
 480
 481### Cleaning rules
 482
 483clean:
 484        rm -f *.o mozilla-sha1/*.o arm/*.o ppc/*.o compat/*.o $(LIB_FILE)
 485        rm -f $(PROGRAMS) $(SIMPLE_PROGRAMS) git$X
 486        rm -f $(filter-out gitk,$(SCRIPTS))
 487        rm -f *.spec *.pyc *.pyo
 488        rm -rf $(GIT_TARNAME)
 489        rm -f $(GIT_TARNAME).tar.gz git-core_$(GIT_VERSION)-*.tar.gz
 490        rm -f git-core_$(GIT_VERSION)-*.dsc
 491        rm -f git-*_$(GIT_VERSION)-*.deb
 492        $(MAKE) -C Documentation/ clean
 493        $(MAKE) -C templates clean
 494        $(MAKE) -C t/ clean