{"thread":{"id":"20607","subject":"[PATCH] Makefile: Add NEEDS_CRYPTO_WITH_SSL","startedAt":"2009-08-15T16:46:53Z","lastAt":"2009-08-24T14:22:26Z","messageCount":3,"participants":["Brian Gernhardt","Alex Riesen"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"120718","messageId":"1250354813-81349-1-git-send-email-brian@gernhardtsoftware.com","threadId":"20607","inReplyTo":null,"subject":"[PATCH] Makefile: Add NEEDS_CRYPTO_WITH_SSL","fromName":"Brian Gernhardt","fromEmail":"brian@gernhardtsoftware.com","sentAt":"2009-08-15T16:46:53Z","receivedAt":"2009-08-15T16:46:53Z","isPatch":true,"sender":{"key":"brian@gernhardtsoftware.com","avatar":"https://avatars.githubusercontent.com/u/133455?v=4"},"body":"The Makefile comment for NEEDS_SSL_WITH_CRYPTO says to define it \"if\nyou need -lcrypto with -lssl (Darwin).\"  However, what it actually\ndoes is add -lssl when you use -lcrypto and not the other way around.\nHowever, libcrypto contains a majority of the ERR_* functions from\nOpenSSL (at least on OS X) so we need it both ways.\n\nSo, add NEEDS_CRYPTO_WITH_SSL which adds -lcrypto to the OpenSSL link\nflags and clarify the difference between it and NEEDS_SSL_WITH_CRYPTO.\n---\n\n After adding BLK_SHA1 to my config.mak, git-imap-send started giving me link\n errors:\n\n  Undefined symbols:\n    \"_ERR_get_error\", referenced from:\n        _ssl_socket_perror in imap-send.o\n    \"_ERR_error_string\", referenced from:\n        _ssl_socket_perror in imap-send.o\n\n Some investigation led me to the fact that BLK_SHA1 removes LIB_4_CRYPTO from\n EXTLIBS.  That let me find the missing functions in libcrypto.  At first I\n considered making NEEDS_SSL_WITH_CRYPTO add -lcrypto to the SSL build flags\n but decided to go this route in case there are platforms that need it one way\n around and not the other.\n\n I've enabled this build option by default on Darwin but nowhere else.  If you\n can't build git-imap-send (with SSL) after enabling BLK_SHA1, your platform\n may need this flag as well.\n\n Makefile |    8 +++++++-\n 1 files changed, 7 insertions(+), 1 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex f94fe05..bc745fb 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -99,7 +99,9 @@ all::\n # on non-x86 architectures (e.g. PowerPC), while the OpenSSL version (default\n # choice) has very fast version optimized for i586.\n #\n-# Define NEEDS_SSL_WITH_CRYPTO if you need -lcrypto with -lssl (Darwin).\n+# Define NEEDS_CRYPTO_WITH_SSL if you need -lcrypto when using -lssl (Darwin).\n+#\n+# Define NEEDS_SSL_WITH_CRYPTO if you need -lssl when using -lcrypto (Darwin).\n #\n # Define NEEDS_LIBICONV if linking with libc is not enough (Darwin).\n #\n@@ -714,6 +716,7 @@ ifeq ($(uname_S),SCO_SV)\n \tTAR = gtar\n endif\n ifeq ($(uname_S),Darwin)\n+\tNEEDS_CRYPTO_WITH_SSL = YesPlease\n \tNEEDS_SSL_WITH_CRYPTO = YesPlease\n \tNEEDS_LIBICONV = YesPlease\n \tifeq ($(shell expr \"$(uname_R)\" : '[15678]\\.'),2)\n@@ -1023,6 +1026,9 @@ ifndef NO_OPENSSL\n \telse\n \t\tOPENSSL_LINK =\n \tendif\n+\tifdef NEEDS_CRYPTO_WITH_SSL\n+\t\tOPENSSL_LINK += -lcrypto\n+\tendif\n else\n \tBASIC_CFLAGS += -DNO_OPENSSL\n \tMOZILLA_SHA1 = 1\n-- \n1.6.4.244.ge5cd0\n"},{"id":"298986","messageId":"81b0412b0908240245l33b04322l923084362197406a@mail.gmail.com","threadId":"20607","inReplyTo":"1250354813-81349-1-git-send-email-brian@gernhardtsoftware.com","subject":"Re: [PATCH] Makefile: Add NEEDS_CRYPTO_WITH_SSL","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2009-08-24T09:45:13Z","receivedAt":"2009-08-24T09:45:13Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"On Sat, Aug 15, 2009 at 18:46, Brian\nGernhardt<brian@gernhardtsoftware.com> wrote:\n>\n>  After adding BLK_SHA1 to my config.mak, git-imap-send started giving me link\n>  errors:\n>\n>  Undefined symbols:\n>    \"_ERR_get_error\", referenced from:\n>        _ssl_socket_perror in imap-send.o\n>    \"_ERR_error_string\", referenced from:\n>        _ssl_socket_perror in imap-send.o\n>\n>  Some investigation led me to the fact that BLK_SHA1 removes LIB_4_CRYPTO from\n>  EXTLIBS.  That let me find the missing functions in libcrypto.  At first I\n>  considered making NEEDS_SSL_WITH_CRYPTO add -lcrypto to the SSL build flags\n>  but decided to go this route in case there are platforms that need it one way\n>  around and not the other.\n\nAs imap-send is the only one which uses the symbols, why not just add\nLIB_4_CRYPTO\nto its linking command? Like in the broken GMail-patch below:\n\ndiff --git a/Makefile b/Makefile\nindex 02ff867..33971f3 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -1503,7 +1503,7 @@ git-%$X: %.o $(GITLIBS)\n\n git-imap-send$X: imap-send.o $(GITLIBS)\n \t$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \\\n-\t\t$(LIBS) $(OPENSSL_LINK) $(OPENSSL_LIBSSL)\n+\t\t$(LIBS) $(OPENSSL_LINK) $(OPENSSL_LIBSSL) $(LIB_4_CRYPTO)\n\n http.o http-walker.o http-push.o: http.h\n"},{"id":"121636","messageId":"4E04F1F2-132A-4695-BCFF-C1F3159671AF@gernhardtsoftware.com","threadId":"20607","inReplyTo":"81b0412b0908240245l33b04322l923084362197406a@mail.gmail.com","subject":"Re: [PATCH] Makefile: Add NEEDS_CRYPTO_WITH_SSL","fromName":"Brian Gernhardt","fromEmail":"brian@gernhardtsoftware.com","sentAt":"2009-08-24T14:22:26Z","receivedAt":"2009-08-24T14:22:26Z","isPatch":true,"sender":{"key":"brian@gernhardtsoftware.com","avatar":"https://avatars.githubusercontent.com/u/133455?v=4"},"body":"\nOn Aug 24, 2009, at 5:45 AM, Alex Riesen wrote:\n\n> As imap-send is the only one which uses the symbols, why not just add\n> LIB_4_CRYPTO\n> to its linking command? Like in the broken GMail-patch below:\n\nI didn't do this because I didn't know if all platforms needed  \nlibcrypto to compile imap-send.  If it is, then this is obviously the  \nsimpler solution.\n\n> diff --git a/Makefile b/Makefile\n> index 02ff867..33971f3 100644\n> --- a/Makefile\n> +++ b/Makefile\n> @@ -1503,7 +1503,7 @@ git-%$X: %.o $(GITLIBS)\n>\n> git-imap-send$X: imap-send.o $(GITLIBS)\n> \t$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o, \n> $^) \\\n> -\t\t$(LIBS) $(OPENSSL_LINK) $(OPENSSL_LIBSSL)\n> +\t\t$(LIBS) $(OPENSSL_LINK) $(OPENSSL_LIBSSL) $(LIB_4_CRYPTO)\n>\n> http.o http-walker.o http-push.o: http.h\n"}]}