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