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