To secure Win64 API I'm throwing in this minimalistic Win64 support.
[openssl.git] / util / pl / VC-32.pl
index 334a53f70b5155df52edd940cd67b3fcfd8cd7f8..d39715cdad62db25d27bc0afad681adff0e44d75 100644 (file)
@@ -11,8 +11,27 @@ $rm='del';
 
 # C compiler stuff
 $cc='cl';
-$cflags=' /MD /W3 /WX /G5 /Ox /O2 /Ob2 /Gs0 /GF /Gy /nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DDSO_WIN32';
-$lflags="/nologo /subsystem:console /machine:I386 /opt:ref";
+if ($FLAVOR =~ /WIN64/)
+    {
+    # Note that we currently don't have /WX on Win64! There is a lot of
+    # warnings, but only of two types:
+    #
+    # C4344: conversion from '__int64' to 'int/long', possible loss of data
+    # C4267: conversion from 'size_t' to 'int/long', possible loss of data
+    #
+    # Amount of latter type is minimized by aliasing strlen to function of
+    # own desing and limiting its return value to 2GB-1 (see e_os.h). As
+    # per 0.9.8 release remaining warnings were explicitly examines and
+    # considered safe to ignore.
+    # 
+    $cflags=' /MD /W3 /Ox /Gs0 /GF /Gy /nologo -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DDSO_WIN32 -DOPENSSL_SYSNAME_WIN32 -DOPENSSL_SYSNAME_WINNT -DUNICODE -D_UNICODE';
+    $lflags="/nologo /subsystem:console /opt:ref";
+    }
+else
+    {
+    $cflags=' /MD /W3 /WX /G5 /Ox /O2 /Ob2 /Gs0 /GF /Gy /nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DDSO_WIN32';
+    $lflags="/nologo /subsystem:console /machine:I386 /opt:ref";
+    }
 $mlflags='';
 
 $out_def="out32";
@@ -38,6 +57,7 @@ $exep='.exe';
 if ($no_sock)
        { $ex_libs=""; }
 else   { $ex_libs="wsock32.lib user32.lib gdi32.lib"; }
+$ex_libs="$ex_libs bufferoverflowu.lib" if ($FLAVOR =~ /WIN64/);
 
 # static library stuff
 $mklib='lib';
@@ -92,9 +112,33 @@ if ($shlib)
        {
        $mlflags.=" $lflags /dll";
 #      $cflags =~ s| /MD| /MT|;
-       $lib_cflag=" -D_WINDLL -D_DLL";
+       $lib_cflag=" -D_WINDLL";
        $out_def="out32dll";
        $tmp_def="tmp32dll";
+       #
+       # Engage Applink...
+       #
+       $app_ex_obj.=" \$(OBJ_D)\\applink.obj /implib:\$(TMP_D)\\junk.lib";
+       $cflags.=" -DOPENSSL_USE_APPLINK -I.";
+       # I'm open for better suggestions than overriding $banner...
+       $banner=<<'___';
+       @echo Building OpenSSL
+
+$(OBJ_D)\applink.obj:  ms\applink.c
+       $(CC) /Fo$(OBJ_D)\applink.obj $(APP_CFLAGS) -c ms\applink.c
+$(OBJ_D)\uplink.obj:   ms\uplink.c ms\applink.c
+       $(CC) /Fo$(OBJ_D)\uplink.obj $(SHLIB_CFLAGS) -c ms\uplink.c
+$(INCO_D)\applink.c:   ms\applink.c
+       $(CP) ms\applink.c $(INCO_D)\applink.c
+
+EXHEADER= $(EXHEADER) $(INCO_D)\applink.c
+
+LIBS_DEP=$(LIBS_DEP) $(OBJ_D)\applink.obj
+CRYPTOOBJ=$(OBJ_D)\uplink.obj $(CRYPTOOBJ)
+___
+       $banner.=<<'___' if ($FLAVOR =~ /WIN64/);
+CRYPTOOBJ=ms\uptable.obj $(CRYPTOOBJ)
+___
        }
 
 $cflags.=" /Fd$out_def";
@@ -118,7 +162,8 @@ sub do_lib_rule
        else
                {
                local($ex)=($target =~ /O_SSL/)?' $(L_CRYPTO)':'';
-               $ex.=' wsock32.lib gdi32.lib advapi32.lib';
+               $ex.=' wsock32.lib gdi32.lib advapi32.lib user32.lib';
+               $ex.=' bufferoverflowu.lib' if ($FLAVOR =~ /WIN64/);
                $ret.="\t\$(LINK) \$(MLFLAGS) $efile$target /def:ms/${Name}.def @<<\n  \$(SHLIB_EX_OBJ) $objs $ex\n<<\n";
                }
        $ret.="\n";