threads / patch / 20607

patchMakefile: Add NEEDS_CRYPTO_WITH_SSL

Subject: [PATCH] Makefile: Add NEEDS_CRYPTO_WITH_SSL

## tl;dr

3 messages between Aug 15, 2009 and Aug 24, 2009. Diffs are folded; open one to read it.

replies: 2people: 2as markdown or json

Brian Gernhardt· Aug 15, 2009, 16:46 UTC · lore

The Makefile comment for NEEDS_SSL_WITH_CRYPTO says to define it "if you need -lcrypto with -lssl (Darwin)." However, what it actually does is add -lssl when you use -lcrypto and not the other way around. However, libcrypto contains a majority of the ERR_* functions from OpenSSL (at least on OS X) so we need it both ways.

So, add NEEDS_CRYPTO_WITH_SSL which adds -lcrypto to the OpenSSL link flags and clarify the difference between it and NEEDS_SSL_WITH_CRYPTO. ---

 After adding BLK_SHA1 to my config.mak, git-imap-send started giving me link
 errors:
  Undefined symbols:
    "_ERR_get_error", referenced from:
        _ssl_socket_perror in imap-send.o
    "_ERR_error_string", referenced from:
        _ssl_socket_perror in imap-send.o
 Some investigation led me to the fact that BLK_SHA1 removes LIB_4_CRYPTO from
 EXTLIBS.  That let me find the missing functions in libcrypto.  At first I
 considered making NEEDS_SSL_WITH_CRYPTO add -lcrypto to the SSL build flags
 but decided to go this route in case there are platforms that need it one way
 around and not the other.
 I've enabled this build option by default on Darwin but nowhere else.  If you
 can't build git-imap-send (with SSL) after enabling BLK_SHA1, your platform
 may need this flag as well.
 Makefile |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
Show changes to Makefile +7 −1
diff --git a/Makefile b/Makefile
index f94fe05..bc745fb 100644
--- a/Makefile
+++ b/Makefile
@@ -99,7 +99,9 @@ all::
 # on non-x86 architectures (e.g. PowerPC), while the OpenSSL version (default
 # choice) has very fast version optimized for i586.
 #
-# Define NEEDS_SSL_WITH_CRYPTO if you need -lcrypto with -lssl (Darwin).
+# Define NEEDS_CRYPTO_WITH_SSL if you need -lcrypto when using -lssl (Darwin).
+#
+# Define NEEDS_SSL_WITH_CRYPTO if you need -lssl when using -lcrypto (Darwin).
 #
 # Define NEEDS_LIBICONV if linking with libc is not enough (Darwin).
 #
@@ -714,6 +716,7 @@ ifeq ($(uname_S),SCO_SV)
 	TAR = gtar
 endif
 ifeq ($(uname_S),Darwin)
+	NEEDS_CRYPTO_WITH_SSL = YesPlease
 	NEEDS_SSL_WITH_CRYPTO = YesPlease
 	NEEDS_LIBICONV = YesPlease
 	ifeq ($(shell expr "$(uname_R)" : '[15678]\.'),2)
@@ -1023,6 +1026,9 @@ ifndef NO_OPENSSL
 	else
 		OPENSSL_LINK =
 	endif
+	ifdef NEEDS_CRYPTO_WITH_SSL
+		OPENSSL_LINK += -lcrypto
+	endif
 else
 	BASIC_CFLAGS += -DNO_OPENSSL
 	MOZILLA_SHA1 = 1
-- 
1.6.4.244.ge5cd0
Alex Riesen· Aug 24, 2009, 09:45 UTC · re: Brian Gernhardt · lore

Re: [PATCH] Makefile: Add NEEDS_CRYPTO_WITH_SSL

On Sat, Aug 15, 2009 at 18:46, Brian Gernhardt<brian@gernhardtsoftware.com> wrote:

Show 15 quoted lines
>
>  After adding BLK_SHA1 to my config.mak, git-imap-send started giving me link
>  errors:
>
>  Undefined symbols:
>    "_ERR_get_error", referenced from:
>        _ssl_socket_perror in imap-send.o
>    "_ERR_error_string", referenced from:
>        _ssl_socket_perror in imap-send.o
>
>  Some investigation led me to the fact that BLK_SHA1 removes LIB_4_CRYPTO from
>  EXTLIBS.  That let me find the missing functions in libcrypto.  At first I
>  considered making NEEDS_SSL_WITH_CRYPTO add -lcrypto to the SSL build flags
>  but decided to go this route in case there are platforms that need it one way
>  around and not the other.

As imap-send is the only one which uses the symbols, why not just add LIB_4_CRYPTO to its linking command? Like in the broken GMail-patch below:

Show changes to Makefile +1 −1
diff --git a/Makefile b/Makefile
index 02ff867..33971f3 100644
--- a/Makefile
+++ b/Makefile
@@ -1503,7 +1503,7 @@ git-%$X: %.o $(GITLIBS)

 git-imap-send$X: imap-send.o $(GITLIBS)
 	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
-		$(LIBS) $(OPENSSL_LINK) $(OPENSSL_LIBSSL)
+		$(LIBS) $(OPENSSL_LINK) $(OPENSSL_LIBSSL) $(LIB_4_CRYPTO)

 http.o http-walker.o http-push.o: http.h
Brian Gernhardt· Aug 24, 2009, 14:22 UTC · re: Alex Riesen · lore

Re: [PATCH] Makefile: Add NEEDS_CRYPTO_WITH_SSL

On Aug 24, 2009, at 5:45 AM, Alex Riesen wrote:
> As imap-send is the only one which uses the symbols, why not just add
> LIB_4_CRYPTO
> to its linking command? Like in the broken GMail-patch below:

I didn't do this because I didn't know if all platforms needed libcrypto to compile imap-send. If it is, then this is obviously the simpler solution.

Show 13 quoted lines
> diff --git a/Makefile b/Makefile
> index 02ff867..33971f3 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1503,7 +1503,7 @@ git-%$X: %.o $(GITLIBS)
>
> git-imap-send$X: imap-send.o $(GITLIBS)
> 	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o, 
> $^) \
> -		$(LIBS) $(OPENSSL_LINK) $(OPENSSL_LIBSSL)
> +		$(LIBS) $(OPENSSL_LINK) $(OPENSSL_LIBSSL) $(LIB_4_CRYPTO)
>
> http.o http-walker.o http-push.o: http.h

← back to recent threads