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