From ff73264e38b1a2f09264915c9d4aec1bafa01b3d Mon Sep 17 00:00:00 2001
From: Marc Hoersken <info@marc-hoersken.de>
Date: Thu, 14 Jun 2012 16:13:29 +0200
Subject: [PATCH] winbuild: Allow SSPI build with or without Schannel

The changes introduced by Yang in commit 2bfa57bc32 are not enough
to make it actually possible to use the USE_WINSSL option.
Makefile.vc was not updated and the configuration name which is
used in the build path did not match between both build files.

This patch fixes those issues and introduces the following changes:

- Replaced the -schannel name with -winssl in order to be consistent
with the other options
- Added ENABLE_WINSSL option to winbuild/Makefile.vc (default yes)
- Changed winbuild/MakefileBuild.vc to set USE_WINSSL to true if
USE_SSL is false and USE_WINSSL was not specified as a parameter
- Separated WINSSL handling from SSPI handling to be consistent with
the other options and their corresponding code path

Since the makefiles are currently switching between ENABLE_, WITH_
and USE_ prefix I would like to propose the following strategy for
Windows makefiles:
- WITH_ prefix: External define with custom path or mode support
- ENABLE_ prefix: External define with yes or no values
- USE_ prefix: Internal define with true or false value
USE_ should also probably be the only define passed around from
winbuild/Makefile.vc to winbuild/MakefileBuild.vc
---
 winbuild/Makefile.vc      |   14 ++++++++++++++
 winbuild/MakefileBuild.vc |   20 ++++++++++++++++----
 2 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/winbuild/Makefile.vc b/winbuild/Makefile.vc
index a45e4ee..59e29d6 100644
--- a/winbuild/Makefile.vc
+++ b/winbuild/Makefile.vc
@@ -27,6 +27,7 @@ CFGSET=true
 !MESSAGE   ENABLE_IPV6=<yes or no>      - Enable IPV6, default to yes
 !MESSAGE   ENABLE_IDN=<yes or no>       - Wheter or not to use IDN Windows APIs. Requires Windows Vista or later.
 !MESSAGE                                  or to install http://www.microsoft.com/downloads/details.aspx?FamilyID=AD6158D7-DDBA-416A-9109-07607425A815
+!MESSAGE   ENABLE_WINSSL=<yes or no>    - Enable native Windows SSL support, default to yes
 !MESSAGE   GEN_PDB=<yes or no>          - Generate Program Database (debug symbols release build)
 !MESSAGE   DEBUG=<yes or no>            - Debug builds
 !ERROR please choose a valid mode
@@ -65,6 +66,14 @@ USE_IDN = true
 USE_IDN = false
 !ENDIF
 
+!IFNDEF ENABLE_WINSSL
+USE_WINSSL = true
+!ELSEIF "$(ENABLE_WINSSL)"=="yes"
+USE_WINSSL = true
+!ELSEIF "$(ENABLE_WINSSL)"=="no"
+USE_WINSSL = false
+!ENDIF
+
 CONFIG_NAME_LIB = libcurl
 
 !IF "$(WITH_SSL)"=="dll"
@@ -123,6 +132,10 @@ CONFIG_NAME_LIB = $(CONFIG_NAME_LIB)-ipv6
 CONFIG_NAME_LIB = $(CONFIG_NAME_LIB)-sspi
 !ENDIF
 
+!IF "$(USE_WINSSL)"=="true"
+CONFIG_NAME_LIB = $(CONFIG_NAME_LIB)-winssl
+!ENDIF
+
 !MESSAGE configuration name: $(CONFIG_NAME_LIB)
 
 BUILD_DIR=../builds/$(CONFIG_NAME_LIB)
@@ -141,6 +154,7 @@ $(MODE):
 	@gen_resp_file.bat $(CURL_OBJS)
 	@SET USE_IPV6=$(USE_IPV6)
 	@SET USE_IDN=$(USE_IDN)
+	@SET USE_WINSSL=$(USE_WINSSL)
 	@$(MAKE) /NOLOGO /F MakefileBuild.vc
 
 copy_from_lib:
diff --git a/winbuild/MakefileBuild.vc b/winbuild/MakefileBuild.vc
index 6ac9a75..513c344 100644
--- a/winbuild/MakefileBuild.vc
+++ b/winbuild/MakefileBuild.vc
@@ -143,12 +143,23 @@ SSH2_CFLAGS = $(SSH2_CFLAGS) /I$(WITH_DEVEL)/include/libssh2
 !ENDIF
 
 
-!IFDEF USE_WINSSL
+!IFNDEF USE_WINSSL
+!IF "$(USE_SSL)"=="true"
+USE_WINSSL  = false
+!ELSE
+USE_WINSSL  = true
+!ENDIF
+!ELSEIF "$(USE_WINSSL)"=="yes"
+USE_WINSSL  = true
+!ENDIF
+
+!IF "$(USE_WINSSL)"=="true"
 CFLAGS_SSPI  = /DUSE_SCHANNEL
 USE_SCHANNEL = true
 USE_SSPI     = yes
 !ENDIF
 
+
 !IFNDEF USE_SSPI
 USE_SSPI = yes
 !ENDIF
@@ -298,11 +309,11 @@ CONFIG_NAME_LIB = $(CONFIG_NAME_LIB)-ipv6
 
 !IF "$(USE_SSPI)"=="true"
 CFLAGS = $(CFLAGS) $(CFLAGS_SSPI)
-!IF "$(USE_SCHANNEL)"=="true"
-CONFIG_NAME_LIB = $(CONFIG_NAME_LIB)-sspi-schannel
-!ELSE
 CONFIG_NAME_LIB = $(CONFIG_NAME_LIB)-sspi
 !ENDIF
+
+!IF "$(USE_WINSSL)"=="true"
+CONFIG_NAME_LIB = $(CONFIG_NAME_LIB)-winssl
 !ENDIF
 
 !IF "$(GEN_PDB)"=="true"
@@ -362,6 +373,7 @@ $(TARGET): $(LIB_OBJS) $(LIB_DIROBJ) $(DISTDIR)
 	@echo Using SSPI: $(USE_SSPI)
 	@echo Using IPv6: $(USE_IPV6)
 	@echo Using IDN:  $(USE_IDN)
+	@echo Using WinSSL: $(USE_WINSSL)
 	@echo CFLAGS:     $(CFLAGS)
 	@echo LFLAGS:     $(LFLAGS)
 	@echo GenPDB:     $(GEN_PDB)
-- 
1.7.10.msysgit.1

