From 29de20504e9790785fe1698300755323f74972aa Mon Sep 17 00:00:00 2001 From: David Aguilar Date: Sat, 11 May 2013 01:22:26 -0700 Subject: [PATCH 1/4] Makefile: fix default regex settings on Darwin t0070-fundamental.sh fails on Mac OS X 10.8: $ uname -a Darwin lustrous 12.2.0 Darwin Kernel Version 12.2.0: Sat Aug 25 00:48:52 PDT 2012; root:xnu-2050.18.24~1/RELEASE_X86_64 x86_64 $ ./t0070-fundamental.sh -v fatal: regex bug confirmed: re-build git with NO_REGEX=1 Fix it by using Git's regex library. Reviewed-by: Jonathan Nieder Signed-off-by: David Aguilar Signed-off-by: Junio C Hamano --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 0f931a2030..f698c1a59e 100644 --- a/Makefile +++ b/Makefile @@ -1054,6 +1054,7 @@ ifeq ($(uname_S),Darwin) BASIC_LDFLAGS += -L/opt/local/lib endif endif + NO_REGEX = YesPlease PTHREAD_LIBS = endif From 4dcd7732db071c8e1e0466b98eaf9501f7fe1a7e Mon Sep 17 00:00:00 2001 From: David Aguilar Date: Sun, 19 May 2013 06:23:34 -0400 Subject: [PATCH 2/4] Makefile: add support for Apple CommonCrypto facility As of Mac OS X 10.7, Apple deprecated all OpenSSL functions due to OpenSSL ABI instability, thus leading to build warnings. As a replacement, Apple encourages developers to migrate to its own (stable) CommonCrypto facility. Introduce boilerplate which controls whether Apple's CommonCrypto facility is employed (enabled by default). Also add a NO_APPLE_COMMON_CRYPTO build flag with which the user can opt out to use OpenSSL instead. [es: extracted CommonCrypto-related Makefile boilerplate into separate introductory patch] Signed-off-by: David Aguilar Signed-off-by: Eric Sunshine Signed-off-by: Junio C Hamano --- Makefile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Makefile b/Makefile index f698c1a59e..cd24c94224 100644 --- a/Makefile +++ b/Makefile @@ -137,6 +137,10 @@ all:: # specify your own (or DarwinPort's) include directories and # library directories by defining CFLAGS and LDFLAGS appropriately. # +# Define NO_APPLE_COMMON_CRYPTO if you are building on Darwin/Mac OS X +# and do not want to use Apple's CommonCrypto library. This allows you +# to provide your own OpenSSL library, for example from MacPorts. +# # Define BLK_SHA1 environment variable to make use of the bundled # optimized C SHA1 routine. # @@ -1054,6 +1058,10 @@ ifeq ($(uname_S),Darwin) BASIC_LDFLAGS += -L/opt/local/lib endif endif + ifndef NO_APPLE_COMMON_CRYPTO + APPLE_COMMON_CRYPTO = YesPlease + COMPAT_CFLAGS += -DAPPLE_COMMON_CRYPTO + endif NO_REGEX = YesPlease PTHREAD_LIBS = endif From 61067954ce166e8a6fbcd109376fe2d9681ca333 Mon Sep 17 00:00:00 2001 From: David Aguilar Date: Sun, 19 May 2013 06:23:35 -0400 Subject: [PATCH 3/4] cache.h: eliminate SHA-1 deprecation warnings on Mac OS X As of Mac OS X 10.7, Apple deprecated all OpenSSL functions due to OpenSSL ABI instability, thus leading to build diagnostics such as: warning: 'SHA1_Init' is deprecated (declared at /usr/include/openssl/sha.h:121) Silence the warnings by using Apple's CommonCrypto SHA-1 replacement functions for SHA1_Init(), SHA1_Update(), and SHA1_Final(). COMMON_DIGEST_FOR_OPENSSL is defined to instruct to provide compatibility macros associating OpenSSL SHA-1 functions with their CommonCrypto counterparts. [es: reworded commit message] Signed-off-by: David Aguilar Signed-off-by: Eric Sunshine Signed-off-by: Junio C Hamano --- Makefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Makefile b/Makefile index cd24c94224..5e7cadf017 100644 --- a/Makefile +++ b/Makefile @@ -1396,11 +1396,17 @@ ifdef PPC_SHA1 SHA1_HEADER = "ppc/sha1.h" LIB_OBJS += ppc/sha1.o ppc/sha1ppc.o LIB_H += ppc/sha1.h +else +ifdef APPLE_COMMON_CRYPTO + COMPAT_CFLAGS += -DCOMMON_DIGEST_FOR_OPENSSL + SHA1_HEADER = else SHA1_HEADER = EXTLIBS += $(LIB_4_CRYPTO) endif endif +endif + ifdef NO_PERL_MAKEMAKER export NO_PERL_MAKEMAKER endif From be4c828b761a7c65edcff75b008051b6d027e64a Mon Sep 17 00:00:00 2001 From: David Aguilar Date: Sun, 19 May 2013 06:23:36 -0400 Subject: [PATCH 4/4] imap-send: eliminate HMAC deprecation warnings on Mac OS X As of Mac OS X 10.7, Apple deprecated all OpenSSL functions due to OpenSSL ABI instability. Silence the warnings by using Apple's CommonCrypto HMAC replacement functions. [es: reworded commit message; check APPLE_COMMON_CRYPTO instead of abusing COMMON_DIGEST_FOR_OPENSSL] Signed-off-by: David Aguilar Signed-off-by: Eric Sunshine Signed-off-by: Junio C Hamano --- imap-send.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/imap-send.c b/imap-send.c index d9bcfb44dc..d6b65e204c 100644 --- a/imap-send.c +++ b/imap-send.c @@ -29,8 +29,18 @@ #ifdef NO_OPENSSL typedef void *SSL; #else +#ifdef APPLE_COMMON_CRYPTO +#include +#define HMAC_CTX CCHmacContext +#define HMAC_Init(hmac, key, len, algo) CCHmacInit(hmac, algo, key, len) +#define HMAC_Update CCHmacUpdate +#define HMAC_Final(hmac, hash, ptr) CCHmacFinal(hmac, hash) +#define HMAC_CTX_cleanup(ignore) +#define EVP_md5() kCCHmacAlgMD5 +#else #include #include +#endif #include #endif