{"thread":{"id":"20878","subject":"[PATCH] Makefile: Add NEEDS_CRYPTO_WITH_SSL","startedAt":"2009-09-08T13:54:38Z","lastAt":"2009-09-09T00:40:34Z","messageCount":3,"participants":["Brian Gernhardt","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"122702","messageId":"1252418078-68650-1-git-send-email-brian@gernhardtsoftware.com","threadId":"20878","inReplyTo":null,"subject":"[PATCH] Makefile: Add NEEDS_CRYPTO_WITH_SSL","fromName":"Brian Gernhardt","fromEmail":"brian@gernhardtsoftware.com","sentAt":"2009-09-08T13:54:38Z","receivedAt":"2009-09-08T13:54:38Z","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\nSigned-off-by: Brian Gernhardt <brian@gernhardtsoftware.com>\n---\n\n Compilation using BLK_SHA1 on OS X 10.5 and 10.6 (at least) is still\n broken without this patch.\n\n Alex Riesen <raa.lkml@gmail.com> pointed out that just adding LIB_4_CRYPTO\n to git-imap-send is simpler, but judging from the fact that nobody else\n has complained about this issue, I'm guessing that the need for -lcrypto\n when using -lssl is not widespread.  (Or BLK_SHA1 isn't getting used much\n or those who do don't compile git-imap-send with SSL.)\n\n Makefile |    8 +++++++-\n 1 files changed, 7 insertions(+), 1 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex ce882d0..121be04 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -91,7 +91,9 @@ all::\n # Define PPC_SHA1 environment variable when running make to make use of\n # a bundled SHA1 routine optimized for PowerPC.\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@@ -707,6 +709,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@@ -1009,6 +1012,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 \tBLK_SHA1 = 1\n-- \n1.6.4.2.420.g30ecf\n"},{"id":"122724","messageId":"7vhbvdyysq.fsf@alter.siamese.dyndns.org","threadId":"20878","inReplyTo":"1252418078-68650-1-git-send-email-brian@gernhardtsoftware.com","subject":"Re: [PATCH] Makefile: Add NEEDS_CRYPTO_WITH_SSL","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-09-08T20:19:33Z","receivedAt":"2009-09-08T20:19:33Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Brian Gernhardt <brian@gernhardtsoftware.com> writes:\n\n> The Makefile comment for NEEDS_SSL_WITH_CRYPTO says to define it \"if\n> you need -lcrypto with -lssl (Darwin).\"  However, what it actually\n> does is add -lssl when you use -lcrypto and not the other way around.\n\nCorrect.  That is worth fixing.\n\n> However, libcrypto contains a majority of the ERR_* functions from\n> OpenSSL (at least on OS X) so we need it both ways.\n\nI see.  We need to be able to see ERR_err_string(), whose caller happens\nto be only imap-send.c for now, and that function is in -lcrypto together\nwith other ERR_* functions.\n\n>  Compilation using BLK_SHA1 on OS X 10.5 and 10.6 (at least) is still\n>  broken without this patch.\n>\n>  Alex Riesen <raa.lkml@gmail.com> pointed out that just adding LIB_4_CRYPTO\n>  to git-imap-send is simpler, but judging from the fact that nobody else\n>  has complained about this issue, I'm guessing that the need for -lcrypto\n>  when using -lssl is not widespread.  (Or BLK_SHA1 isn't getting used much\n>  or those who do don't compile git-imap-send with SSL.)\n\nBLK_SHA1 is fairly new on 'master', so lack of breakage report is\nexpected.\n\nThe patch makes sense to me, but as the result, depending on platforms\nand configuration, we would use three variations when linking imap-send\nwith no NO_OPENSSL defined:\n\n * Both -lcrypto -lssl\n * Only -lssl\n * Only -lcrypto\n\nI wonder if we can simplify this in some way (not a 1.6.5 topic).\n\nI am suspecting that the reason we do not say \"always both\" is because\ndepending on the vintage of OpenSSL one or the other is missing?\n"},{"id":"122746","messageId":"2DD80FE2-385E-4488-811F-A80450AACA23@gernhardtsoftware.com","threadId":"20878","inReplyTo":"7vhbvdyysq.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] Makefile: Add NEEDS_CRYPTO_WITH_SSL","fromName":"Brian Gernhardt","fromEmail":"brian@gernhardtsoftware.com","sentAt":"2009-09-09T00:40:34Z","receivedAt":"2009-09-09T00:40:34Z","isPatch":true,"sender":{"key":"brian@gernhardtsoftware.com","avatar":"https://avatars.githubusercontent.com/u/133455?v=4"},"body":"\nOn Sep 8, 2009, at 4:19 PM, Junio C Hamano wrote:\n\n> The patch makes sense to me, but as the result, depending on platforms\n> and configuration, we would use three variations when linking imap- \n> send\n> with no NO_OPENSSL defined:\n>\n> * Both -lcrypto -lssl\n> * Only -lssl\n> * Only -lcrypto\n>\n> I wonder if we can simplify this in some way (not a 1.6.5 topic).\n>\n> I am suspecting that the reason we do not say \"always both\" is because\n> depending on the vintage of OpenSSL one or the other is missing?\n\nIt just occurred to me that I have a Debian machine to test this on.   \nI generally don't use my web server for testing, but testing a compile  \nshould be safe enough.\n\nSure enough, it compiles without this patch.  It may be a difference  \nbetween the linkers.  It appears that ERR_error_string() is in  \nlibcrypto for both OS X and Debian and that libssl.{so,dylib} both  \nhave load commands for libcrypto.{so,dylib}, but OS X ld is pickier  \nthan Debian ld.  Odd.\n\nI don't see a scenario where only -lcrypto would be used for imap- \nsend, actually.  That would imply that we're using OpenSSL's SHA-1  \nalgorithm but not using it for IMAPS access.  SSL_WITH_CRYPTO is about  \nneeding -lssl when using -lcrypto for SHA-1 while CRYPTO_WITH_SSL is  \nabout needing -lcrypto when using -lssl for SSL.\n\nThe only simplification I can think of is to make  \nNEEDS_CRYPTO_WITH_SSL and NEEDS_SSL_WITH_CRYPTO be the same, so that  \nit will include both any time it includes either one.   \nNEEDS_SSL_WITH_CRYPTO is set for UnixWare, SCO_SV, and OS X.  I only  \nhave the latter to test with so I don't know if the symmetry is true  \nfor the other two.\n\n~~ Brian\n"}]}