Merge branch 'fixes'
[git.git] / Makefile
index fd4e163..ac384c7 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -27,6 +27,8 @@
 # Define NEEDS_SOCKET if linking with libc is not enough (SunOS,
 # Patrick Mauritz).
 #
+# Define NO_MMAP if you want to avoid mmap.
+#
 # Define WITH_OWN_SUBPROCESS_PY if you want to use with python 2.3.
 #
 # Define NO_IPV6 if you lack IPv6 support and getaddrinfo().
@@ -85,7 +87,7 @@ SCRIPT_SH = \
        git-repack.sh git-request-pull.sh git-reset.sh \
        git-resolve.sh git-revert.sh git-sh-setup.sh git-status.sh \
        git-tag.sh git-verify-tag.sh git-whatchanged.sh git.sh \
-       git-applymbox.sh git-applypatch.sh \
+       git-applymbox.sh git-applypatch.sh git-am.sh \
        git-merge.sh git-merge-stupid.sh git-merge-octopus.sh \
        git-merge-resolve.sh git-grep.sh
 
@@ -164,11 +166,19 @@ LIBS += -lz
 #
 # Platform specific tweaks
 #
-ifeq ($(shell uname -s),Darwin)
+
+# We choose to avoid "if .. else if .. else .. endif endif"
+# because maintaining the nesting to match is a pain.  If
+# we had "elif" things would have been much nicer...
+uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
+uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not')
+uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')
+
+ifeq ($(uname_S),Darwin)
        NEEDS_SSL_WITH_CRYPTO = YesPlease
        NEEDS_LIBICONV = YesPlease
 endif
-ifeq ($(shell uname -s),SunOS)
+ifeq ($(uname_S),SunOS)
        NEEDS_SOCKET = YesPlease
        NEEDS_NSL = YesPlease
        SHELL_PATH = /bin/bash
@@ -178,20 +188,20 @@ ifeq ($(shell uname -s),SunOS)
        TAR = gtar
        PLATFORM_DEFINES += -D__EXTENSIONS__
 endif
-ifeq ($(shell uname -o),Cygwin)
+ifeq ($(uname_O),Cygwin)
        NO_STRCASESTR = YesPlease
        NEEDS_LIBICONV = YesPlease
        NO_IPV6 = YesPlease
        X = .exe
        PLATFORM_DEFINES += -DUSE_SYMLINK_HEAD=0
 endif
-ifneq (,$(findstring arm,$(shell uname -m)))
-       ARM_SHA1 = YesPlease
-endif
-ifeq ($(shell uname -s),OpenBSD)
+ifeq ($(uname_S),OpenBSD)
        NEEDS_LIBICONV = YesPlease
        PLATFORM_DEFINES += -I/usr/local/include -L/usr/local/lib
 endif
+ifneq (,$(findstring arm,$(uname_M)))
+       ARM_SHA1 = YesPlease
+endif
 
 ifndef NO_CURL
        ifdef CURLDIR
@@ -255,9 +265,13 @@ ifdef NEEDS_NSL
        SIMPLE_LIB += -lnsl
 endif
 ifdef NO_STRCASESTR
-       DEFINES += -Dstrcasestr=gitstrcasestr
+       DEFINES += -Dstrcasestr=gitstrcasestr -DNO_STRCASESTR=1
        LIB_OBJS += compat/strcasestr.o
 endif
+ifdef NO_MMAP
+       DEFINES += -Dmmap=gitfakemmap -Dmunmap=gitfakemunmap -DNO_MMAP
+       LIB_OBJS += compat/mmap.o
+endif
 ifdef NO_IPV6
        DEFINES += -DNO_IPV6 -Dsockaddr_storage=sockaddr_in
 endif
@@ -287,7 +301,7 @@ SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \
          $(patsubst %.py,%,$(SCRIPT_PYTHON)) \
          gitk
 
-export TAR INSTALL DESTDIR SHELL_PATH
+export prefix TAR INSTALL DESTDIR SHELL_PATH
 ### Build rules
 
 all: $(PROGRAMS) $(SCRIPTS)