diff -ur openssl-head.orig\apps\s_client.c openssl-head\apps\s_client.c
--- openssl-head.orig\apps\s_client.c	Sun Jun 29 18:20:54 2008
+++ openssl-head\apps\s_client.c	Sun Jun 29 18:40:58 2008
@@ -405,8 +405,9 @@
 #ifndef OPENSSL_NO_ENGINE
 	char *engine_id=NULL;
 	char *ssl_client_engine_id=NULL;
-	ENGINE *e=NULL, *ssl_client_engine=NULL;
+	ENGINE *ssl_client_engine=NULL;
 #endif
+	ENGINE *e=NULL;
 #if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_NETWARE) || defined(OPENSSL_SYS_BEOS_R5)
 	struct timeval tv;
 #if defined(OPENSSL_SYS_BEOS_R5)
diff -ur openssl-head.orig\apps\s_server.c openssl-head\apps\s_server.c
--- openssl-head.orig\apps\s_server.c	Sun Jun 29 18:20:54 2008
+++ openssl-head\apps\s_server.c	Sun Jun 29 18:41:17 2008
@@ -840,9 +840,7 @@
 	int state=0;
 	const SSL_METHOD *meth=NULL;
 	int socket_type=SOCK_STREAM;
-#ifndef OPENSSL_NO_ENGINE
 	ENGINE *e=NULL;
-#endif
 	char *inrand=NULL;
 	int s_cert_format = FORMAT_PEM, s_key_format = FORMAT_PEM;
 	char *passarg = NULL, *pass = NULL;
diff -ur openssl-head.orig\engines\e_4758cca.c openssl-head\engines\e_4758cca.c
--- openssl-head.orig\engines\e_4758cca.c	Sun Jun 29 18:21:13 2008
+++ openssl-head\engines\e_4758cca.c	Sun Jun 29 18:41:42 2008
@@ -53,6 +53,9 @@
  *
  */
 
+#ifndef OPENSSL_NO_HW
+#ifndef OPENSSL_NO_HW_4758_CCA
+
 #include <stdio.h>
 #include <string.h>
 #include <openssl/crypto.h>
@@ -65,9 +68,6 @@
 #include <openssl/rsa.h>
 #endif
 #include <openssl/bn.h>
-
-#ifndef OPENSSL_NO_HW
-#ifndef OPENSSL_NO_HW_4758_CCA
 
 #ifdef FLAT_INC
 #include "hw_4758_cca.h"
diff -ur openssl-head.orig\engines\e_aep.c openssl-head\engines\e_aep.c
--- openssl-head.orig\engines\e_aep.c	Sun Jun 29 18:21:13 2008
+++ openssl-head\engines\e_aep.c	Sun Jun 29 18:41:58 2008
@@ -52,6 +52,9 @@
  *
  */
 
+#ifndef OPENSSL_NO_HW
+#ifndef OPENSSL_NO_HW_AEP
+
 #include <stdio.h>
 #include <openssl/bn.h>
 #include <string.h>
@@ -85,8 +88,6 @@
 #endif
 #include <openssl/bn.h>
 
-#ifndef OPENSSL_NO_HW
-#ifndef OPENSSL_NO_HW_AEP
 #ifdef FLAT_INC
 #include "aep.h"
 #else
diff -ur openssl-head.orig\engines\e_atalla.c openssl-head\engines\e_atalla.c
--- openssl-head.orig\engines\e_atalla.c	Sun Jun 29 18:21:13 2008
+++ openssl-head\engines\e_atalla.c	Sun Jun 29 18:42:11 2008
@@ -56,6 +56,9 @@
  *
  */
 
+#ifndef OPENSSL_NO_HW
+#ifndef OPENSSL_NO_HW_ATALLA
+
 #include <stdio.h>
 #include <string.h>
 #include <openssl/crypto.h>
@@ -72,9 +75,6 @@
 #include <openssl/dh.h>
 #endif
 #include <openssl/bn.h>
-
-#ifndef OPENSSL_NO_HW
-#ifndef OPENSSL_NO_HW_ATALLA
 
 #ifdef FLAT_INC
 #include "atalla.h"
diff -ur openssl-head.orig\engines\e_capi.c openssl-head\engines\e_capi.c
--- openssl-head.orig\engines\e_capi.c	Sun Jun 29 18:21:13 2008
+++ openssl-head\engines\e_capi.c	Sun Jun 29 18:42:28 2008
@@ -51,6 +51,7 @@
  * ====================================================================
  */
 
+#ifndef OPENSSL_NO_CAPIENG
 
 #include <stdio.h>
 #include <string.h>
@@ -60,8 +61,6 @@
 #include <openssl/bn.h>
 
 #ifdef OPENSSL_SYS_WIN32
-#ifndef OPENSSL_NO_CAPIENG
-
 
 #include <windows.h>
 
diff -ur openssl-head.orig\engines\e_chil.c openssl-head\engines\e_chil.c
--- openssl-head.orig\engines\e_chil.c	Sun Jun 29 18:21:13 2008
+++ openssl-head\engines\e_chil.c	Sun Jun 29 18:42:41 2008
@@ -57,6 +57,9 @@
  *
  */
 
+#ifndef OPENSSL_NO_HW
+#ifndef OPENSSL_NO_HW_CHIL
+
 #include <stdio.h>
 #include <string.h>
 #include <openssl/crypto.h>
@@ -72,9 +75,6 @@
 #include <openssl/dh.h>
 #endif
 #include <openssl/bn.h>
-
-#ifndef OPENSSL_NO_HW
-#ifndef OPENSSL_NO_HW_CHIL
 
 /* Attribution notice: nCipher have said several times that it's OK for
  * us to implement a general interface to their boxes, and recently declared
diff -ur openssl-head.orig\engines\e_cswift.c openssl-head\engines\e_cswift.c
--- openssl-head.orig\engines\e_cswift.c	Sun Jun 29 18:21:13 2008
+++ openssl-head\engines\e_cswift.c	Sun Jun 29 18:42:54 2008
@@ -56,6 +56,9 @@
  *
  */
 
+#ifndef OPENSSL_NO_HW
+#ifndef OPENSSL_NO_HW_CSWIFT
+
 #include <stdio.h>
 #include <string.h>
 #include <openssl/crypto.h>
@@ -73,9 +76,6 @@
 #endif
 #include <openssl/rand.h>
 #include <openssl/bn.h>
-
-#ifndef OPENSSL_NO_HW
-#ifndef OPENSSL_NO_HW_CSWIFT
 
 /* Attribution notice: Rainbow have generously allowed me to reproduce
  * the necessary definitions here from their API. This means the support
diff -ur openssl-head.orig\engines\e_gmp.c openssl-head\engines\e_gmp.c
--- openssl-head.orig\engines\e_gmp.c	Sun Jun 29 18:21:13 2008
+++ openssl-head\engines\e_gmp.c	Sun Jun 29 18:43:07 2008
@@ -80,6 +80,9 @@
  * chipsets might be a good deal more favourable to the GMP version (eg. PPC).
  * Feedback welcome. */
 
+#ifndef OPENSSL_NO_HW
+#ifndef OPENSSL_NO_GMP
+
 #include <stdio.h>
 #include <string.h>
 #include <openssl/crypto.h>
@@ -87,9 +90,6 @@
 #include <openssl/engine.h>
 #include <openssl/rsa.h>
 #include <openssl/bn.h>
-
-#ifndef OPENSSL_NO_HW
-#ifndef OPENSSL_NO_GMP
 
 #include <gmp.h>
 
diff -ur openssl-head.orig\engines\e_nuron.c openssl-head\engines\e_nuron.c
--- openssl-head.orig\engines\e_nuron.c	Sun Jun 29 18:21:13 2008
+++ openssl-head\engines\e_nuron.c	Sun Jun 29 18:43:27 2008
@@ -56,6 +56,9 @@
  *
  */
 
+#ifndef OPENSSL_NO_HW
+#ifndef OPENSSL_NO_HW_NURON
+
 #include <stdio.h>
 #include <string.h>
 #include <openssl/crypto.h>
@@ -72,9 +75,6 @@
 #include <openssl/dh.h>
 #endif
 #include <openssl/bn.h>
-
-#ifndef OPENSSL_NO_HW
-#ifndef OPENSSL_NO_HW_NURON
 
 #define NURON_LIB_NAME "nuron engine"
 #include "e_nuron_err.c"
diff -ur openssl-head.orig\engines\e_padlock.c openssl-head\engines\e_padlock.c
--- openssl-head.orig\engines\e_padlock.c	Sun Jun 29 18:21:14 2008
+++ openssl-head\engines\e_padlock.c	Sun Jun 29 18:43:45 2008
@@ -62,6 +62,8 @@
  *
  */
 
+#ifndef OPENSSL_NO_HW
+#ifndef OPENSSL_NO_HW_PADLOCK
 
 #include <stdio.h>
 #include <string.h>
@@ -76,9 +78,6 @@
 #endif
 #include <openssl/rand.h>
 #include <openssl/err.h>
-
-#ifndef OPENSSL_NO_HW
-#ifndef OPENSSL_NO_HW_PADLOCK
 
 /* Attempt to have a single source for both 0.9.7 and 0.9.8 :-) */
 #if (OPENSSL_VERSION_NUMBER >= 0x00908000L)
diff -ur openssl-head.orig\engines\e_sureware.c openssl-head\engines\e_sureware.c
--- openssl-head.orig\engines\e_sureware.c	Sun Jun 29 18:21:14 2008
+++ openssl-head\engines\e_sureware.c	Sun Jun 29 18:44:02 2008
@@ -50,6 +50,9 @@
 *		SUCH DAMAGE.																			*
 ====================================================================*/
 
+#ifndef OPENSSL_NO_HW
+#ifndef OPENSSL_NO_HW_SUREWARE
+
 #include <stdio.h>
 #include <string.h>
 #include <openssl/crypto.h>
@@ -67,9 +70,6 @@
 #include <openssl/dh.h>
 #endif
 #include <openssl/bn.h>
-
-#ifndef OPENSSL_NO_HW
-#ifndef OPENSSL_NO_HW_SUREWARE
 
 #ifdef FLAT_INC
 #include "sureware.h"
diff -ur openssl-head.orig\engines\e_ubsec.c openssl-head\engines\e_ubsec.c
--- openssl-head.orig\engines\e_ubsec.c	Sun Jun 29 18:21:14 2008
+++ openssl-head\engines\e_ubsec.c	Sun Jun 29 18:44:20 2008
@@ -58,6 +58,9 @@
  *
  */
 
+#ifndef OPENSSL_NO_HW
+#ifndef OPENSSL_NO_HW_UBSEC
+
 #include <stdio.h>
 #include <string.h>
 #include <openssl/crypto.h>
@@ -74,9 +77,6 @@
 #include <openssl/dh.h>
 #endif
 #include <openssl/bn.h>
-
-#ifndef OPENSSL_NO_HW
-#ifndef OPENSSL_NO_HW_UBSEC
 
 #ifdef FLAT_INC
 #include "hw_ubsec.h"
diff -ur openssl-head.orig\util\mk1mf.pl openssl-head\util\mk1mf.pl
--- openssl-head.orig\util\mk1mf.pl	Sun Jun 29 18:21:17 2008
+++ openssl-head\util\mk1mf.pl	Sun Jun 29 18:46:51 2008
@@ -98,6 +98,8 @@
 	no-bf no-cast no-aes no-camellia no-seed
 	no-rsa no-dsa no-dh			- Skip this public key cipher
 	no-ssl2 no-ssl3				- Skip this version of SSL
+	enable-gmp enable-montasm
+	enable-rfc3779			- Enable elements disabled by default
 	just-ssl				- remove all non-ssl keys/digest
 	no-asm 					- No x86 asm
 	no-krb5					- No KRB5
@@ -114,7 +116,7 @@
 	no-err					- No error strings
 	dll/shlib				- Build shared libraries (MS)
 	debug					- Debug build
-        profile                                 - Profiling build
+	profile					- Profiling build
 	gcc					- Use Gcc (unix)
 
 Values that can be set
@@ -266,6 +268,9 @@
 $cflags.=" -DOPENSSL_NO_ECDH" if $no_ecdh;
 $cflags.=" -DOPENSSL_NO_ENGINE"   if $no_engine;
 $cflags.=" -DOPENSSL_NO_HW"   if $no_hw;
+$cflags.=" -DOPENSSL_NO_GMP"   if !$enable_gmp;
+$cflags.=" -DOPENSSL_NO_RFC3779"  if !$enable_rfc3779;
+$cflags.=" -DOPENSSL_BN_ASM_MONT" if $enable_montasm;
 
 $cflags.= " -DZLIB" if $zlib_opt;
 $cflags.= " -DZLIB_SHARED" if $zlib_opt == 2;
@@ -1056,9 +1061,12 @@
 		"shlib" => \$shlib,
 		"dll" => \$shlib,
 		"shared" => 0,
-		"no-gmp" => 0,
-		"no-rfc3779" => 0,
-		"no-montasm" => 0,
+		"no-gmp" => 1,
+		"enable-gmp" => \$enable_gmp,
+		"no-rfc3779" => 1,
+		"enable-rfc3779" => \$enable_rfc3779,
+		"no-montasm" => 1,
+		"enable-montasm" => \$enable_montasm,
 		"no-shared" => 0,
 		"no-zlib" => 0,
 		"no-zlib-dynamic" => 0,
