From: Andy Polyakov Date: Sun, 24 Jul 2005 21:48:04 +0000 (+0000) Subject: Unify VC-32.pl and VC-CE.pl scripts and update INSTALL.W32. X-Git-Tag: OpenSSL_0_9_8k^2~1905 X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=commitdiff_plain;h=b3836ed3cbeb9a5d735597e8a79ffea5894cb470 Unify VC-32.pl and VC-CE.pl scripts and update INSTALL.W32. --- diff --git a/INSTALL.W32 b/INSTALL.W32 index f18f249677..a4b6700e2e 100644 --- a/INSTALL.W32 +++ b/INSTALL.W32 @@ -287,3 +287,21 @@ (e.g. fopen()), and OpenSSL cannot change these; so in general you cannot rely on CRYPTO_malloc_init() solving your problem, and you should consistently use the multithreaded library. + + Linking your application + ------------------------ + + If you link with static OpenSSL libraries [those built with ms/nt.mak], + then you're expected to additionally link your application with + WSOCK32.LIB, ADVAPI32.LIB, GDI32.LIB and USER32.LIB. Those developing + non-interactive service applications might feel concerned about linking + with latter two, as they are justly associated with interactive desktop, + which is not available to service processes. The toolkit is designed + to detect in which context it's currently executed, GUI, console app + or service, and act accordingly, namely whether or not to actually make + GUI calls. + + If you link with OpenSSL .DLLs, then you're expected to include into + your application code small "shim" snippet, which provides glue between + OpenSSL BIO layer and your compiler run-time. Look up OPENSSL_Applink + reference page for further details. diff --git a/util/mk1mf.pl b/util/mk1mf.pl index 6090a2b5a6..ca130b5d06 100755 --- a/util/mk1mf.pl +++ b/util/mk1mf.pl @@ -128,10 +128,6 @@ if (($platform =~ /VC-(.+)/)) $NT = 1 if $1 eq "NT"; require 'VC-32.pl'; } -elsif ($platform eq "VC-CE") - { - require 'VC-CE.pl'; - } elsif ($platform eq "Mingw32") { require 'Mingw32.pl'; diff --git a/util/pl/VC-32.pl b/util/pl/VC-32.pl index d39715cdad..d2ec04eac1 100644 --- a/util/pl/VC-32.pl +++ b/util/pl/VC-32.pl @@ -1,5 +1,6 @@ #!/usr/local/bin/perl -# VCw32lib.pl - the file for Visual C++ 4.[01] for windows NT, static libraries +# VC-32.pl - unified script for Microsoft Visual C++, covering Win32, +# Win64 and WinCE [follow $FLAVOR variable to trace the differences]. # $ssl= "ssleay32"; @@ -21,30 +22,44 @@ if ($FLAVOR =~ /WIN64/) # # 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 + # per 0.9.8 release remaining warnings were explicitly examined 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'; + $base_cflags=' /W3 /Gs0 /GF /Gy /nologo -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DDSO_WIN32 -DOPENSSL_SYSNAME_WIN32 -DOPENSSL_SYSNAME_WINNT -DUNICODE -D_UNICODE'; + $opt_cflags=' /MD /Ox'; + $dbg_cflags=' /MDd /Od -DDEBUG -D_DEBUG'; $lflags="/nologo /subsystem:console /opt:ref"; } -else +elsif ($FLAVOR =~ /CE/) + { + $base_cflags=' /W3 /WX /Gs0 /GF /Gy /nologo $(WCETARGETDEFS) -DUNICODE -D_UNICODE -DOPENSSL_SYSNAME_WINCE -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DDSO_WIN32 -DNO_CHMOD -I$(WCECOMPAT)/include'; + $opt_cflags=' /MD /Ox /O2 /Ob2'; + $dbg_clfags=' /MDd /Od -DDEBUG -D_DEBUG'; + $lflags='/nologo /subsystem:windowsce,$(WCELDVERSION) /machine:$(WCELDMACHINE) /opt:ref'; + } +else # Win32 { - $cflags=' /MD /W3 /WX /G5 /Ox /O2 /Ob2 /Gs0 /GF /Gy /nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DDSO_WIN32'; + $base_cflags=' /W3 /WX /Gs0 /GF /Gy /nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DDSO_WIN32'; + $opt_cflags=' /MD /Ox /O2 /Ob2'; + $dbg_cflags=' /MDd /Od -DDEBUG -D_DEBUG'; $lflags="/nologo /subsystem:console /machine:I386 /opt:ref"; } $mlflags=''; -$out_def="out32"; -$tmp_def="tmp32"; +$out_def="out32"; $out_def.='_$(TARGETCPU)' if ($FLAVOR =~ /CE/); +$tmp_def="tmp32"; $tmp_def.='_$(TARGETCPU)' if ($FLAVOR =~ /CE/); $inc_def="inc32"; if ($debug) { - $cflags=" /MDd /W3 /WX /Zi /Yd /Od /nologo -DOPENSSL_SYSNAME_WIN32 -D_DEBUG -DL_ENDIAN -DWIN32_LEAN_AND_MEAN -DDEBUG -DDSO_WIN32"; + $cflags=$dbg_cflags.$base_cflags; $lflags.=" /debug"; $mlflags.=' /debug'; } -$cflags .= " -DOPENSSL_SYSNAME_WINNT" if $NT == 1; +else + { + $cflags=$opt_cflags.$base_cflags; + } $obj='.obj'; $ofile="/Fo"; @@ -54,10 +69,25 @@ $link="link"; $rsc="rc"; $efile="/out:"; $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/); +if ($no_sock) { $ex_libs=''; } +elsif ($FLAVOR =~ /CE/) { $ex_libs='winsock.lib'; } +else { $ex_libs='wsock32.lib'; } + +if ($FLAVOR =~ /CE/) + { $ex_libs.=' $(WCECOMPAT)/lib/wcecompatex.lib $(WCELDFLAGS)'; } +else + { + $ex_libs.=' gdi32.lib advapi32.lib user32.lib'; + $ex_libs.=' bufferoverflowu.lib' if ($FLAVOR =~ /WIN64/); + } + +# As native NT API is pure UNICODE, our WIN-NT build defaults to UNICODE, +# but gets linked with unicows.lib to ensure backward compatibility. +if ($FLAVOR =~ /NT/) + { + $cflags.=" -DOPENSSL_SYSNAME_WINNT -DUNICODE -D_UNICODE"; + $ex_libs="unicows.lib $ex_libs"; + } # static library stuff $mklib='lib'; @@ -68,7 +98,7 @@ $shlibp=($shlib)?".dll":".lib"; $lfile='/out:'; $shlib_ex_obj=""; -$app_ex_obj="setargv.obj"; +$app_ex_obj="setargv.obj" if ($FLAVOR !~ /CE/); if ($nasm) { $asm='nasmw -f win32'; $afile='-o '; @@ -108,7 +138,7 @@ if (!$no_asm) $cflags.=" -DBN_ASM -DMD5_ASM -DSHA1_ASM -DRMD160_ASM"; } -if ($shlib) +if ($shlib && $FLAVOR !~ /CE/) { $mlflags.=" $lflags /dll"; # $cflags =~ s| /MD| /MT|; @@ -140,6 +170,13 @@ ___ CRYPTOOBJ=ms\uptable.obj $(CRYPTOOBJ) ___ } +elsif ($shlib && $FLAVOR =~ /CE/) + { + $mlflags.=" $lflags /dll"; + $lib_cflag=" -D_WINDLL -D_DLL"; + $out_def='out32dll_$(TARGETCPU)'; + $tmp_def='tmp32dll_$(TARGETCPU)'; + } $cflags.=" /Fd$out_def"; @@ -156,14 +193,22 @@ sub do_lib_rule if (!$shlib) { # $ret.="\t\$(RM) \$(O_$Name)\n"; - $ex =' advapi32.lib'; + $ex =' '; $ret.="\t\$(MKLIB) $lfile$target @<<\n $objs $ex\n<<\n"; } else { local($ex)=($target =~ /O_SSL/)?' $(L_CRYPTO)':''; - $ex.=' wsock32.lib gdi32.lib advapi32.lib user32.lib'; - $ex.=' bufferoverflowu.lib' if ($FLAVOR =~ /WIN64/); + if ($FLAVOR =~ /CE/) + { + $ex.=' winsock.lib $(WCECOMPAT)/lib/wcecompatex.lib'; + } + else + { + $ex.=' unicows.lib' if ($FLAVOR =~ /NT/); + $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"; diff --git a/util/pl/VC-CE.pl b/util/pl/VC-CE.pl deleted file mode 100644 index 547383720a..0000000000 --- a/util/pl/VC-CE.pl +++ /dev/null @@ -1,111 +0,0 @@ -#!/usr/local/bin/perl -# VC-CE.pl - the file for eMbedded Visual C++ 3.0 for windows CE, static libraries -# - -$ssl= "ssleay32"; -$crypto="libeay32"; -$RSAref="RSAref32"; - -$o='\\'; -$cp='copy nul+'; # Timestamps get stuffed otherwise -$rm='del'; - -# C compiler stuff -$cc='$(CC)'; -$cflags=' /W3 /WX /Ox /O2 /Ob2 /Gs0 /GF /Gy /nologo $(WCETARGETDEFS) -DUNICODE -D_UNICODE -DOPENSSL_SYSNAME_WINCE -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DDSO_WIN32 -DNO_CHMOD -I$(WCECOMPAT)/include'; -$lflags='/nologo /subsystem:windowsce,$(WCELDVERSION) /machine:$(WCELDMACHINE) /opt:ref'; -$mlflags=''; - -$out_def='out32_$(TARGETCPU)'; -$tmp_def='tmp32_$(TARGETCPU)'; -$inc_def="inc32"; - -if ($debug) - { - $cflags=" /MDd /W3 /WX /Zi /Yd /Od /nologo -DUNICODE -D_UNICODE -DOPENSSL_SYSNAME_WINCE -D_DEBUG -DL_ENDIAN -DWIN32_LEAN_AND_MEAN -DDEBUG -DDSO_WIN32"; - $lflags.=" /debug"; - $mlflags.=' /debug'; - } - -$obj='.obj'; -$ofile="/Fo"; - -# EXE linking stuff -$link="link"; -$efile="/out:"; -$exep='.exe'; -if ($no_sock) - { $ex_libs=""; } -else { $ex_libs='winsock.lib $(WCECOMPAT)/lib/wcecompatex.lib $(WCELDFLAGS)'; } - -# static library stuff -$mklib='lib'; -$ranlib=''; -$plib=""; -$libp=".lib"; -$shlibp=($shlib)?".dll":".lib"; -$lfile='/out:'; - -$shlib_ex_obj=""; -#$app_ex_obj="setargv.obj"; -$app_ex_obj=""; - -$bn_asm_obj=''; -$bn_asm_src=''; -$des_enc_obj=''; -$des_enc_src=''; -$bf_enc_obj=''; -$bf_enc_src=''; - -if ($shlib) - { - $mlflags.=" $lflags /dll"; -# $cflags =~ s| /MD| /MT|; - $lib_cflag=" -D_WINDLL -D_DLL"; - $out_def='out32dll_$(TARGETCPU)'; - $tmp_def='tmp32dll_$(TARGETCPU)'; - } - -$cflags.=" /Fd$out_def"; - -sub do_lib_rule - { - local($objs,$target,$name,$shlib)=@_; - local($ret,$Name); - - $taget =~ s/\//$o/g if $o ne '/'; - ($Name=$name) =~ tr/a-z/A-Z/; - -# $target="\$(LIB_D)$o$target"; - $ret.="$target: $objs\n"; - if (!$shlib) - { -# $ret.="\t\$(RM) \$(O_$Name)\n"; - $ex =' '; - $ret.="\t\$(MKLIB) $lfile$target @<<\n $objs $ex\n<<\n"; - } - else - { - local($ex)=($target =~ /O_SSL/)?' $(L_CRYPTO)':''; -# $ex.=' winsock.lib coredll.lib $(WCECOMPAT)/lib/wcecompatex.lib'; - $ex.=' winsock.lib $(WCECOMPAT)/lib/wcecompatex.lib'; - $ret.="\t\$(LINK) \$(MLFLAGS) $efile$target /def:ms/${Name}.def @<<\n \$(SHLIB_EX_OBJ) $objs $ex\n<<\n"; - } - $ret.="\n"; - return($ret); - } - -sub do_link_rule - { - local($target,$files,$dep_libs,$libs)=@_; - local($ret,$_); - - $file =~ s/\//$o/g if $o ne '/'; - $n=&bname($targer); - $ret.="$target: $files $dep_libs\n"; - $ret.=" \$(LINK) \$(LFLAGS) $efile$target @<<\n"; - $ret.=" \$(APP_EX_OBJ) $files $libs\n<<\n\n"; - return($ret); - } - -1;