From: Nicolas Pitre Date: Tue, 30 Sep 2008 20:22:45 GMT Subject: [PATCH, resent] fix openssl headers conflicting with custom SHA1 implementations Message-ID: On ARM I have the following compilation errors: CC fast-import.o In file included from cache.h:8, from builtin.h:6, from fast-import.c:142: arm/sha1.h:14: error: conflicting types for 'SHA_CTX' /usr/include/openssl/sha.h:105: error: previous declaration of 'SHA_CTX' was here arm/sha1.h:16: error: conflicting types for 'SHA1_Init' /usr/include/openssl/sha.h:115: error: previous declaration of 'SHA1_Init' was here arm/sha1.h:17: error: conflicting types for 'SHA1_Update' /usr/include/openssl/sha.h:116: error: previous declaration of 'SHA1_Update' was here arm/sha1.h:18: error: conflicting types for 'SHA1_Final' /usr/include/openssl/sha.h:117: error: previous declaration of 'SHA1_Final' was here make: *** [fast-import.o] Error 1 This is because openssl header files are always included in git-compat-util.h since commit 684ec6c63c whenever NO_OPENSSL is not set, which somehow brings in clashing with the custom ARM version. Compilation of git is probably broken on PPC too for the same reason. Turns out that the only file requiring openssl/ssl.h and openssl/err.h is imap-send.c. But only moving those problematic includes there doesn't solve the issue as it also includes cache.h which brings in the conflicting header. So also conditionally including SHA1_HEADER allows for not including it when compiling imap-send.c. Signed-off-by: Nicolas Pitre --- This is a bit ugly but given the rat nest of system includes we have I don't know how to solve this any better. diff --git a/Makefile b/Makefile index 3c0664a..a0f86dd 100644 --- a/Makefile +++ b/Makefile @@ -1242,6 +1242,9 @@ endif git-%$X: %.o $(GITLIBS) $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS) +imap-send.o: imap-send.c GIT-CFLAGS + $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -USHA1_HEADER $< + git-imap-send$X: imap-send.o $(GITLIBS) $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \ $(LIBS) $(OPENSSL_LINK) $(OPENSSL_LIBSSL) diff --git a/cache.h b/cache.h index de8c2b6..d93e086 100644 --- a/cache.h +++ b/cache.h @@ -5,7 +5,10 @@ #include "strbuf.h" #include "hash.h" +#ifdef SHA1_HEADER #include SHA1_HEADER +#endif + #include #if defined(NO_DEFLATE_BOUND) || ZLIB_VERNUM < 0x1200 diff --git a/git-compat-util.h b/git-compat-util.h index db2836f..044f62b 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -99,11 +99,6 @@ #include #endif -#ifndef NO_OPENSSL -#include -#include -#endif - /* On most systems would have given us this, but * not on some systems (e.g. GNU/Hurd). */ diff --git a/imap-send.c b/imap-send.c index af7e08c..01f1c9a 100644 --- a/imap-send.c +++ b/imap-send.c @@ -22,11 +22,15 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "cache.h" #ifdef NO_OPENSSL typedef void *SSL; +#else +#include +#include #endif +#include "cache.h" + struct store_conf { char *name; const char *path; /* should this be here? its interpretation is driver-specific */ Nicolas