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