Hello everyone, another set of patches inspired by Bob Kast's reports. These patches allow the compilation of libssh2 with WinCNG using the generated Visual Studio project files. This patch adds WinCNG support to parts of the existing Win32 build infrastructure, until new build systems, like pre-defined VS project files or CMake files may be added.
The patches probably raise one main question: How to handle build systems, like VS project files, that need to include all source files regardless of the desired target, including all supported crypto backends? For now I added a check for LIBSSH2_OPENSSL to openssl.c and hardcoded the supported crypto backends within Makefile.am. Best regards, Marc
>From 93f69ae580641da9c28caecdeb9d355f578a0682 Mon Sep 17 00:00:00 2001 From: Marc Hoersken <[email protected]> Date: Sat, 22 Mar 2014 23:33:56 +0100 Subject: [PATCH 1/2] openssl: Check for LIBSSH2_OPENSSL in order to compile with openssl --- src/openssl.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/openssl.c b/src/openssl.c index b26842b..056b0b7 100644 --- a/src/openssl.c +++ b/src/openssl.c @@ -40,6 +40,8 @@ #include "libssh2_priv.h" +#ifdef LIBSSH2_OPENSSL /* compile only if we build with openssl */ + #include <string.h> #ifndef EVP_MAX_BLOCK_LENGTH @@ -814,3 +816,5 @@ _libssh2_pub_priv_keyfile(LIBSSH2_SESSION *session, EVP_PKEY_free(pk); return st; } + +#endif /* LIBSSH2_OPENSSL */ -- 1.8.1.msysgit.1
From 3ed83def3e73520886839ded729a09a713d8a467 Mon Sep 17 00:00:00 2001 From: Marc Hoersken <[email protected]> Date: Sat, 22 Mar 2014 23:34:55 +0100 Subject: [PATCH 2/2] win32: Added WinCNG targets to generated Visual Studio project --- Makefile.am | 5 +- win32/libssh2_config.h | 1 + win32/msvcproj.head | 138 ++++++++++++++++++++++++++++++++++++++++++++----- 3 files changed, 128 insertions(+), 16 deletions(-) diff --git a/Makefile.am b/Makefile.am index e0a74c7..1489be3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -75,8 +75,9 @@ gen-coverage: coverage: init-coverage build-coverage gen-coverage # DSP/VCPROJ generation adapted from libcurl -# only OpenSSL is supported with this build system -include Makefile.OpenSSL.inc +# only OpenSSL and WinCNG are supported with this build system +CRYPTO_CSOURCES = openssl.c wincng.c +CRYPTO_HHEADERS = openssl.h wincng.h # Makefile.inc provides the CSOURCES and HHEADERS defines include Makefile.inc diff --git a/win32/libssh2_config.h b/win32/libssh2_config.h index 4e2ae29..56646da 100644 --- a/win32/libssh2_config.h +++ b/win32/libssh2_config.h @@ -18,6 +18,7 @@ #define HAVE_GETTIMEOFDAY #endif +#define HAVE_LIBCRYPT32 #define HAVE_WINSOCK2_H #define HAVE_IOCTLSOCKET #define HAVE_SELECT diff --git a/win32/msvcproj.head b/win32/msvcproj.head index 6b39740..eb82020 100644 --- a/win32/msvcproj.head +++ b/win32/msvcproj.head @@ -1,12 +1,12 @@ # Microsoft Developer Studio Project File - Name="libssh2" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** -# only OpenSSL is supported with this build system +# only OpenSSL and WinCNG are supported with this build system # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 # TARGTYPE "Win32 (x86) Static Library" 0x0104 -CFG=libssh2 - Win32 Debug +CFG=libssh2 - Win32 OpenSSL Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE @@ -19,10 +19,14 @@ CFG=libssh2 - Win32 Debug !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE -!MESSAGE "libssh2 - Win32 DLL Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "libssh2 - Win32 DLL Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "libssh2 - Win32 LIB Release" (based on "Win32 (x86) Static Library") -!MESSAGE "libssh2 - Win32 LIB Debug" (based on "Win32 (x86) Static Library") +!MESSAGE "libssh2 - Win32 OpenSSL DLL Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "libssh2 - Win32 OpenSSL DLL Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "libssh2 - Win32 OpenSSL LIB Release" (based on "Win32 (x86) Static Library") +!MESSAGE "libssh2 - Win32 OpenSSL LIB Debug" (based on "Win32 (x86) Static Library") +!MESSAGE "libssh2 - Win32 WinCNG DLL Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "libssh2 - Win32 WinCNG DLL Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "libssh2 - Win32 WinCNG LIB Release" (based on "Win32 (x86) Static Library") +!MESSAGE "libssh2 - Win32 WinCNG LIB Debug" (based on "Win32 (x86) Static Library") !MESSAGE # Begin Project @@ -33,7 +37,7 @@ CPP=cl.exe MTL=midl.exe RSC=rc.exe -!IF "$(CFG)" == "libssh2 - Win32 DLL Release" +!IF "$(CFG)" == "libssh2 - Win32 OpenSSL DLL Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 @@ -60,7 +64,7 @@ LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 # ADD LINK32 gdi32.lib advapi32.lib user32.lib kernel32.lib ws2_32.lib libeay32.lib zlib.lib /nologo /dll /map /debug /machine:I386 -!ELSEIF "$(CFG)" == "libssh2 - Win32 DLL Debug" +!ELSEIF "$(CFG)" == "libssh2 - Win32 OpenSSL DLL Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 @@ -88,7 +92,7 @@ LINK32=link.exe # ADD LINK32 gdi32.lib advapi32.lib user32.lib kernel32.lib ws2_32.lib libeay32.lib zlib.lib /nologo /dll /incremental:no /map /debug /machine:I386 /pdbtype:sept # SUBTRACT LINK32 /nodefaultlib -!ELSEIF "$(CFG)" == "libssh2 - Win32 LIB Release" +!ELSEIF "$(CFG)" == "libssh2 - Win32 OpenSSL LIB Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 @@ -112,7 +116,7 @@ LIB32=link.exe -lib # ADD LIB32 /nologo # ADD LIB32 /nologo /out:"Release_lib\libssh2.lib" -!ELSEIF "$(CFG)" == "libssh2 - Win32 LIB Debug" +!ELSEIF "$(CFG)" == "libssh2 - Win32 OpenSSL LIB Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 @@ -135,12 +139,118 @@ LIB32=link.exe -lib # ADD BASE LIB32 /nologo # ADD LIB32 /nologo /out:"Debug_lib\libssh2d.lib" +!ELSEIF "$(CFG)" == "libssh2 - Win32 WinCNG LIB Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release_dll" +# PROP BASE Intermediate_Dir "Release_dll" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release_dll" +# PROP Intermediate_Dir "Release_dll" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "LIBSSH2_WIN32" /D "LIBSSH2_WINCNG" /D "_MBCS" /D "_LIB" /YX /FD /c +# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\win32" /I "..\include" /D "WIN32" /D "NDEBUG" /D "LIBSSH2_WIN32" /D "LIBSSH2_WINCNG" /D "_MBCS" /D "_LIB" /YX /FD /c +# SUBTRACT CPP /YX +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 +# ADD LINK32 gdi32.lib advapi32.lib user32.lib kernel32.lib ws2_32.lib crypt32.lib bcrypt.lib /nologo /dll /map /debug /machine:I386 + +!ELSEIF "$(CFG)" == "libssh2 - Win32 WinCNG DLL Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug_dll" +# PROP BASE Intermediate_Dir "Debug_dll" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug_dll" +# PROP Intermediate_Dir "Debug_dll" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "LIBSSH2_WIN32" /D "LIBSSH2_WINCNG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c +# ADD CPP /nologo /MD /W3 /Gm /GX /ZI /Od /I "..\win32" /I "..\include" /D "WIN32" /D "_DEBUG" /D "LIBSSH2_WIN32" /D "LIBSSH2_WINCNG" /D "_MBCS" /D "_LIB" /D "LIBSSH2DEBUG" /YX /FD /GZ /c +# SUBTRACT CPP /WX /YX +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept +# ADD LINK32 gdi32.lib advapi32.lib user32.lib kernel32.lib ws2_32.lib crypt32.lib bcrypt.lib /nologo /dll /incremental:no /map /debug /machine:I386 /pdbtype:sept +# SUBTRACT LINK32 /nodefaultlib + +!ELSEIF "$(CFG)" == "libssh2 - Win32 WinCNG LIB Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release_lib" +# PROP BASE Intermediate_Dir "Release_lib" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release_lib" +# PROP Intermediate_Dir "Release_lib" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "LIBSSH2_WIN32" /D "LIBSSH2_WINCNG" /D "_MBCS" /D "_LIB" /YX /FD /c +# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\win32" /I "..\include" /D "WIN32" /D "NDEBUG" /D "LIBSSH2_WIN32" /D "LIBSSH2_WINCNG" /D "_MBCS" /D "_LIB" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo +# ADD LIB32 /nologo /out:"Release_lib\libssh2.lib" + +!ELSEIF "$(CFG)" == "libssh2 - Win32 WinCNG LIB Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug_lib" +# PROP BASE Intermediate_Dir "Debug_lib" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug_lib" +# PROP Intermediate_Dir "Debug_lib" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "LIBSSH2_WIN32" /D "LIBSSH2_WINCNG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c +# ADD CPP /nologo /MD /W3 /Gm /GX /ZI /Od /I "..\win32" /I "..\include" /D "WIN32" /D "_DEBUG" /D "LIBSSH2_WIN32" /D "LIBSSH2_WINCNG" /D "_MBCS" /D "_LIB" /D "LIBSSH2DEBUG" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo /out:"Debug_lib\libssh2d.lib" + !ENDIF # Begin Target -# Name "libssh2 - Win32 DLL Release" -# Name "libssh2 - Win32 DLL Debug" -# Name "libssh2 - Win32 LIB Release" -# Name "libssh2 - Win32 LIB Debug" +# Name "libssh2 - Win32 OpenSSL DLL Release" +# Name "libssh2 - Win32 OpenSSL DLL Debug" +# Name "libssh2 - Win32 OpenSSL LIB Release" +# Name "libssh2 - Win32 OpenSSL LIB Debug" +# Name "libssh2 - Win32 WinCNG DLL Release" +# Name "libssh2 - Win32 WinCNG DLL Debug" +# Name "libssh2 - Win32 WinCNG LIB Release" +# Name "libssh2 - Win32 WinCNG LIB Debug" -- 1.8.1.msysgit.1
_______________________________________________ libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
