Makefileon commit git --version tells which version of git you have. (6a2e50f)
   1# Define MOZILLA_SHA1 environment variable when running make to make use of
   2# a bundled SHA1 routine coming from Mozilla. It is GPL'd and should be fast
   3# on non-x86 architectures (e.g. PowerPC), while the OpenSSL version (default
   4# choice) has very fast version optimized for i586.
   5#
   6# Define NO_OPENSSL environment variable if you do not have OpenSSL. You will
   7# miss out git-rev-list --merge-order. This also implies MOZILLA_SHA1.
   8#
   9# Define NO_CURL if you do not have curl installed.  git-http-pull is not
  10# built, and you cannot use http:// and https:// transports.
  11#
  12# Define PPC_SHA1 environment variable when running make to make use of
  13# a bundled SHA1 routine optimized for PowerPC.
  14#
  15# Define NEEDS_SSL_WITH_CRYPTO if you need -lcrypto with -lssl (Darwin).
  16#
  17# Define NEEDS_LIBICONV if linking with libc is not enough (Darwin).
  18#
  19# Define NEEDS_SOCKET if linking with libc is not enough (SunOS,
  20# Patrick Mauritz).
  21#
  22# Define NO_GETDOMAINNAME if your library lack it (SunOS, Patrick Mauritz).
  23#
  24# Define COLLISION_CHECK below if you believe that SHA1's
  25# 1461501637330902918203684832716283019655932542976 hashes do not give you
  26# sufficient guarantee that no collisions between objects will ever happen.
  27
  28# DEFINES += -DCOLLISION_CHECK
  29
  30# Define USE_NSEC below if you want git to care about sub-second file mtimes
  31# and ctimes. Note that you need recent glibc (at least 2.2.4) for this, and
  32# it will BREAK YOUR LOCAL DIFFS! show-diff and anything using it will likely
  33# randomly break unless your underlying filesystem supports those sub-second
  34# times (my ext3 doesn't).
  35
  36# DEFINES += -DUSE_NSEC
  37
  38# Define USE_STDEV below if you want git to care about the underlying device
  39# change being considered an inode change from the update-cache perspective.
  40
  41# DEFINES += -DUSE_STDEV
  42
  43GIT_VERSION = 0.99.6
  44
  45CFLAGS = -g -O2 -Wall
  46ALL_CFLAGS = $(CFLAGS) $(PLATFORM_DEFINES) $(DEFINES)
  47
  48prefix = $(HOME)
  49bindir = $(prefix)/bin
  50template_dir = $(prefix)/share/git-core/templates/
  51# DESTDIR=
  52
  53CC = gcc
  54AR = ar
  55INSTALL = install
  56RPMBUILD = rpmbuild
  57
  58# sparse is architecture-neutral, which means that we need to tell it
  59# explicitly what architecture to check for. Fix this up for yours..
  60SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
  61
  62
  63
  64### --- END CONFIGURATION SECTION ---
  65
  66SCRIPT_SH = \
  67        git-add.sh git-bisect.sh git-branch.sh git-checkout.sh \
  68        git-cherry.sh git-clone.sh git-commit.sh \
  69        git-count-objects.sh git-diff.sh git-fetch.sh \
  70        git-format-patch.sh git-log.sh git-ls-remote.sh \
  71        git-merge-one-file.sh git-octopus.sh git-parse-remote.sh \
  72        git-prune.sh git-pull.sh git-push.sh git-rebase.sh \
  73        git-repack.sh git-request-pull.sh git-reset.sh \
  74        git-resolve.sh git-revert.sh git-sh-setup.sh git-status.sh \
  75        git-tag.sh git-verify-tag.sh git-whatchanged.sh git.sh \
  76        git-applymbox.sh git-applypatch.sh
  77
  78SCRIPT_PERL = \
  79        git-archimport.perl git-cvsimport.perl git-relink.perl \
  80        git-rename.perl git-send-email.perl git-shortlog.perl
  81
  82# The ones that do not have to link with lcrypto nor lz.
  83SIMPLE_PROGRAMS = \
  84        git-get-tar-commit-id git-mailinfo git-mailsplit git-stripspace \
  85        git-daemon git-var
  86
  87# ... and all the rest
  88PROGRAMS = \
  89        git-apply git-build-rev-cache git-cat-file \
  90        git-checkout-index git-clone-pack git-commit-tree \
  91        git-convert-objects git-diff-files \
  92        git-diff-helper git-diff-index git-diff-stages \
  93        git-diff-tree git-export git-fetch-pack git-fsck-objects \
  94        git-hash-object git-init-db \
  95        git-local-fetch git-ls-files git-ls-tree git-merge-base \
  96        git-merge-index git-mktag git-pack-objects git-patch-id \
  97        git-peek-remote git-prune-packed git-read-tree \
  98        git-receive-pack git-rev-list git-rev-parse \
  99        git-rev-tree git-send-pack git-show-branch \
 100        git-show-index git-show-rev-cache git-ssh-fetch \
 101        git-ssh-upload git-tar-tree git-unpack-file \
 102        git-unpack-objects git-update-index git-update-server-info \
 103        git-upload-pack git-verify-pack git-write-tree \
 104        $(SIMPLE_PROGRAMS)
 105
 106ifdef WITH_SEND_EMAIL
 107        SCRIPT_PERL += git-send-email.perl
 108endif
 109
 110ifndef NO_CURL
 111        PROGRAMS += git-http-fetch
 112endif
 113
 114LIB_FILE=libgit.a
 115
 116LIB_H = \
 117        blob.h cache.h commit.h count-delta.h csum-file.h delta.h \
 118        diff.h epoch.h object.h pack.h pkt-line.h quote.h refs.h \
 119        rev-cache.h run-command.h strbuf.h tag.h tree.h
 120
 121DIFF_OBJS = \
 122        diff.o diffcore-break.o diffcore-order.o diffcore-pathspec.o \
 123        diffcore-pickaxe.o diffcore-rename.o
 124
 125LIB_OBJS = \
 126        blob.o commit.o connect.o count-delta.o csum-file.o \
 127        date.o diff-delta.o entry.o gitenv.o ident.o index.o \
 128        object.o pack-check.o patch-delta.o path.o pkt-line.o \
 129        quote.o read-cache.o refs.o rev-cache.o run-command.o \
 130        server-info.o setup.o sha1_file.o sha1_name.o strbuf.o \
 131        tag.o tree.o usage.o $(DIFF_OBJS)
 132
 133LIBS = $(LIB_FILE)
 134LIBS += -lz
 135
 136ifeq ($(shell uname -s),Darwin)
 137        NEEDS_SSL_WITH_CRYPTO = YesPlease
 138        NEEDS_LIBICONV = YesPlease
 139endif
 140ifeq ($(shell uname -s),SunOS)
 141        NEEDS_SOCKET = YesPlease
 142        PLATFORM_DEFINES += -DNO_GETDOMAINNAME=1
 143endif
 144
 145ifndef NO_OPENSSL
 146        LIB_OBJS += epoch.o
 147        OPENSSL_LIBSSL = -lssl
 148else
 149        DEFINES += '-DNO_OPENSSL'
 150        MOZILLA_SHA1 = 1
 151        OPENSSL_LIBSSL =
 152endif
 153ifdef NEEDS_SSL_WITH_CRYPTO
 154        LIB_4_CRYPTO = -lcrypto -lssl
 155else
 156        LIB_4_CRYPTO = -lcrypto
 157endif
 158ifdef NEEDS_LIBICONV
 159        LIB_4_ICONV = -liconv
 160else
 161        LIB_4_ICONV =
 162endif
 163ifdef MOZILLA_SHA1
 164        SHA1_HEADER = "mozilla-sha1/sha1.h"
 165        LIB_OBJS += mozilla-sha1/sha1.o
 166else
 167        ifdef PPC_SHA1
 168                SHA1_HEADER = "ppc/sha1.h"
 169                LIB_OBJS += ppc/sha1.o ppc/sha1ppc.o
 170        else
 171                SHA1_HEADER = <openssl/sha.h>
 172                LIBS += $(LIB_4_CRYPTO)
 173        endif
 174endif
 175ifdef NEEDS_SOCKET
 176        LIBS += -lsocket
 177        SIMPLE_LIB += -lsocket
 178endif
 179
 180DEFINES += '-DSHA1_HEADER=$(SHA1_HEADER)'
 181
 182SCRIPTS = $(SCRIPT_SH) $(SCRIPT_PERL) gitk
 183
 184### Build rules
 185
 186all: $(PROGRAMS) git.sh
 187
 188all:
 189        $(MAKE) -C templates
 190
 191git.sh: git.sh.in Makefile
 192        rm -f $@+ $@
 193        sed -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' <$@.in >$@+
 194        chmod +x $@+
 195        mv $@+ $@
 196
 197%.o: %.c
 198        $(CC) -o $*.o -c $(ALL_CFLAGS) $<
 199%.o: %.S
 200        $(CC) -o $*.o -c $(ALL_CFLAGS) $<
 201
 202git-%: %.o $(LIB_FILE)
 203        $(CC) $(ALL_CFLAGS) -o $@ $(filter %.o,$^) $(LIBS)
 204
 205git-mailinfo : SIMPLE_LIB += $(LIB_4_ICONV)
 206$(SIMPLE_PROGRAMS) : $(LIB_FILE)
 207$(SIMPLE_PROGRAMS) : git-% : %.o
 208        $(CC) $(ALL_CFLAGS) -o $@ $(filter %.o,$^) $(LIB_FILE) $(SIMPLE_LIB)
 209
 210git-http-fetch: fetch.o
 211git-local-fetch: fetch.o
 212git-ssh-fetch: rsh.o fetch.o
 213git-ssh-upload: rsh.o
 214
 215git-http-fetch: LIBS += -lcurl
 216git-rev-list: LIBS += $(OPENSSL_LIBSSL)
 217
 218init-db.o: init-db.c
 219        $(CC) -c $(ALL_CFLAGS) \
 220                -DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir)"' $*.c
 221
 222$(LIB_OBJS): $(LIB_H)
 223$(patsubst git-%,%.o,$(PROGRAMS)): $(LIB_H)
 224$(DIFF_OBJS): diffcore.h
 225
 226$(LIB_FILE): $(LIB_OBJS)
 227        $(AR) rcs $@ $(LIB_OBJS)
 228
 229doc:
 230        $(MAKE) -C Documentation all
 231
 232
 233### Testing rules
 234
 235test: all
 236        $(MAKE) -C t/ all
 237
 238test-date: test-date.c date.o
 239        $(CC) $(ALL_CFLAGS) -o $@ test-date.c date.o
 240
 241test-delta: test-delta.c diff-delta.o patch-delta.o
 242        $(CC) $(ALL_CFLAGS) -o $@ $^
 243
 244check:
 245        for i in *.c; do sparse $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i; done
 246
 247
 248
 249### Installation rules
 250
 251install: $(PROGRAMS) $(SCRIPTS)
 252        $(INSTALL) -m755 -d $(DESTDIR)$(bindir)
 253        $(INSTALL) $(PROGRAMS) $(DESTDIR)$(bindir)
 254        @for s in $(SCRIPTS); \
 255        do \
 256                case "$$s" in \
 257                *.*) \
 258                        e=`expr "$$s" : '\(.*\)\.[^.]*$$'` ;; \
 259                *) \
 260                        e="$$s" ;; \
 261                esac && \
 262                echo ": install $$s $(DESTDIR)$(bindir)/$$e" && \
 263                $(INSTALL) $$s $(DESTDIR)$(bindir)/$$e || exit; \
 264        done
 265        $(INSTALL) git-revert.sh $(DESTDIR)$(bindir)/git-cherry-pick
 266        sh ./cmd-rename.sh $(DESTDIR)$(bindir)
 267        $(MAKE) -C templates install
 268
 269install-doc:
 270        $(MAKE) -C Documentation install
 271
 272
 273
 274
 275### Maintainer's dist rules
 276
 277git-core.spec: git-core.spec.in Makefile
 278        sed -e 's/@@VERSION@@/$(GIT_VERSION)/g' < $< > $@
 279
 280GIT_TARNAME=git-core-$(GIT_VERSION)
 281dist: git-core.spec git-tar-tree
 282        ./git-tar-tree HEAD $(GIT_TARNAME) > $(GIT_TARNAME).tar
 283        @mkdir -p $(GIT_TARNAME)
 284        @cp git-core.spec $(GIT_TARNAME)
 285        tar rf $(GIT_TARNAME).tar $(GIT_TARNAME)/git-core.spec
 286        @rm -rf $(GIT_TARNAME)
 287        gzip -f -9 $(GIT_TARNAME).tar
 288
 289rpm: dist
 290        $(RPMBUILD) -ta git-core-$(GIT_VERSION).tar.gz
 291
 292deb: dist
 293        rm -rf $(GIT_TARNAME)
 294        tar zxf $(GIT_TARNAME).tar.gz
 295        dpkg-source -b $(GIT_TARNAME)
 296        cd $(GIT_TARNAME) && fakeroot debian/rules binary
 297
 298### Cleaning rules
 299
 300clean:
 301        rm -f *.o mozilla-sha1/*.o ppc/*.o $(PROGRAMS) $(LIB_FILE)
 302        rm -f git-core.spec git.sh
 303        rm -rf $(GIT_TARNAME)
 304        rm -f $(GIT_TARNAME).tar.gz git-core_$(GIT_VERSION)-*.tar.gz
 305        rm -f git-core_$(GIT_VERSION)-*.deb git-core_$(GIT_VERSION)-*.dsc
 306        rm -f git-tk_$(GIT_VERSION)-*.deb
 307        $(MAKE) -C Documentation/ clean
 308        $(MAKE) -C templates/ clean
 309        $(MAKE) -C t/ clean