Configure et al: cleanups
[openssl.git] / Configurations / 10-main.conf
index 8c6ee7f..1bdb723 100644 (file)
@@ -9,38 +9,77 @@ sub vc_win64a_info {
             $vc_win64a_info = { as        => "nasm",
                                 asflags   => "-f win64 -DNEAR -Ox -g",
                                 asoutflag => "-o" };
-        } else {
+        } elsif ($disabled{asm}) {
             $vc_win64a_info = { as        => "ml64",
                                 asflags   => "/c /Cp /Cx /Zi",
                                 asoutflag => "/Fo" };
+        } else {
+            $die->("NASM not found - please read INSTALL and NOTES.WIN for further details\n");
+            $vc_win64a_info = { as        => "{unknown}",
+                                asflags   => "",
+                                asoutflag => "" };
         }
     }
     return $vc_win64a_info;
 }
 
+my $vc_win32_info = {};
+sub vc_win32_info {
+    unless (%$vc_win32_info) {
+        my $ver=`nasm -v 2>NUL`;
+        my $vew=`nasmw -v 2>NUL`;
+        if ($ver ne "" || $vew ne "") {
+            $vc_win32_info = { as        => $ver ge $vew ? "nasm" : "nasmw",
+                               asflags   => "-f win32",
+                               asoutflag => "-o",
+                               perlasm_scheme => "win32n" };
+        } elsif ($disabled{asm}) {
+            $vc_win32_info = { as        => "ml",
+                               asflags   => "/nologo /Cp /coff /c /Cx /Zi",
+                               asoutflag => "/Fo",
+                               perlasm_scheme => "win32" };
+        } else {
+            $die->("NASM not found - please read INSTALL and NOTES.WIN for further details\n");
+            $vc_win32_info = { as        => "{unknown}",
+                               asflags   => "",
+                               asoutflag => "",
+                               perlasm_scheme => "win32" };
+        }
+    }
+    return $vc_win32_info;
+}
+
 my $vc_wince_info = {};
 sub vc_wince_info {
     unless (%$vc_wince_info) {
         # sanity check
-        die '%OSVERSION% is not defined' if (!defined($ENV{'OSVERSION'}));
-        die '%PLATFORM% is not defined'  if (!defined($ENV{'PLATFORM'}));
-        die '%TARGETCPU% is not defined' if (!defined($ENV{'TARGETCPU'}));
+        $die->('%OSVERSION% is not defined') if (!defined(env('OSVERSION')));
+        $die->('%PLATFORM% is not defined')  if (!defined(env('PLATFORM')));
+        $die->('%TARGETCPU% is not defined') if (!defined(env('TARGETCPU')));
 
         #
         # Idea behind this is to mimic flags set by eVC++ IDE...
         #
-        my $wcevers = $ENV{'OSVERSION'};                    # WCENNN
-        die '%OSVERSION% value is insane'
-            if ($wcevers !~ /^WCE([1-9])([0-9]{2})$/);
-        my $wcecdefs = "-D_WIN32_WCE=$1$2 -DUNDER_CE=$1$2"; # -D_WIN32_WCE=NNN
-        my $wcelflag = "/subsystem:windowsce,$1.$2";        # ...,N.NN
+        my $wcevers = env('OSVERSION');                     # WCENNN
+       my $wcevernum;
+       my $wceverdotnum;
+       if ($wcevers =~ /^WCE([1-9])([0-9]{2})$/) {
+           $wcevernum = "$1$2";
+           $wceverdotnum = "$1.$2";
+       } else {
+           $die->('%OSVERSION% value is insane');
+           $wcevernum = "{unknown}";
+           $wceverdotnum = "{unknown}";
+       }
+        my $wcecdefs = "-D_WIN32_WCE=$wcevernum -DUNDER_CE=$wcevernum"; # -D_WIN32_WCE=NNN
+        my $wcelflag = "/subsystem:windowsce,$wceverdotnum";        # ...,N.NN
 
-        my $wceplatf =  $ENV{'PLATFORM'};
+        my $wceplatf =  env('PLATFORM');
 
         $wceplatf =~ tr/a-z0-9 /A-Z0-9_/;
         $wcecdefs .= " -DWCE_PLATFORM_$wceplatf";
 
-        my $wcetgt = $ENV{'TARGETCPU'};                     # just shorter name...
+        my $wcetgt = env('TARGETCPU');                      # just shorter name...
       SWITCH: for($wcetgt) {
           /^X86/        && do { $wcecdefs.=" -Dx86 -D_X86_ -D_i386_ -Di_386_";
                                 $wcelflag.=" /machine:X86";     last; };
@@ -82,6 +121,7 @@ sub vms_info {
         my $pointer_size_str = $pointer_size == 0 ? "" : "$pointer_size";
 
         $vms_info->{disable_warns} = [ ];
+        $vms_info->{pointer_size} = $pointer_size_str;
         if ($pointer_size == 64) {
             `PIPE CC /NOCROSS_REFERENCE /NOLIST /NOOBJECT /WARNINGS = DISABLE = ( MAYLOSEDATA3, EMPTYFILE ) NL: 2> NL:`;
             if ($? == 0) {
@@ -104,7 +144,7 @@ sub vms_info {
     return $vms_info;
 }
 
-%targets = (
+my %targets = (
 
 #### Basic configs that should work on any 32-bit box
     "gcc" => {
@@ -139,28 +179,26 @@ sub vms_info {
         inherit_from     => [ "BASE_unix" ],
         template         => 1,
         cflags           => "-DFILIO_H",
-        ex_libs          => add("-lresolv -lsocket -lnsl -ldl"),
+        ex_libs          => add("-lsocket -lnsl -ldl"),
         dso_scheme       => "dlfcn",
         thread_scheme    => "pthreads",
         shared_target    => "solaris-shared",
-        shared_extension => ".so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
+        shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
     },
 #### Solaris x86 with GNU C setups
     "solaris-x86-gcc" => {
-        # -DOPENSSL_NO_INLINE_ASM switches off inline assembler. We have
-        # to do it here because whenever GNU C instantiates an assembler
-        # template it surrounds it with #APP #NO_APP comment pair which
-        # (at least Solaris 7_x86) /usr/ccs/bin/as fails to assemble
-        # with "Illegal mnemonic" error message.
+        # NB. GNU C has to be configured to use GNU assembler, and not
+        # /usr/ccs/bin/as. Failure to comply will result in compile
+        # failures [at least] in 32-bit build.
         inherit_from     => [ "solaris-common", asm("x86_elf_asm") ],
         cc               => "gcc",
-        cflags           => add_before(picker(default => "-Wall -DL_ENDIAN -DOPENSSL_NO_INLINE_ASM",
+        cflags           => add_before(picker(default => "-Wall -DL_ENDIAN",
                                               debug   => "-O0 -g",
                                               release => "-O3 -fomit-frame-pointer"),
                                        threads("-pthread")),
         bn_ops           => "BN_LLONG",
         shared_cflag     => "-fPIC",
-        shared_ldflag    => "-shared",
+        shared_ldflag    => "-shared -static-libgcc",
     },
     "solaris64-x86_64-gcc" => {
         # -shared -static-libgcc might appear controversial, but modules
@@ -170,7 +208,7 @@ sub vms_info {
         # gcc shared build with Sun C. Given that gcc generates faster
         # code [thanks to inline assembler], I would actually recommend
         # to consider using gcc shared build even with vendor compiler:-)
-        #                                      <appro@fy.chalmers.se>
+        #                        -- <appro@openssl.org>
         inherit_from     => [ "solaris-common", asm("x86_64_asm") ],
         cc               => "gcc",
         cflags           => add_before(picker(default => "-m64 -Wall -DL_ENDIAN",
@@ -180,24 +218,23 @@ sub vms_info {
         bn_ops           => "SIXTY_FOUR_BIT_LONG",
         perlasm_scheme   => "elf",
         shared_cflag     => "-fPIC",
-        shared_ldflag    => "-m64 -shared -static-libgcc",
+        shared_ldflag    => "-shared -static-libgcc",
         multilib         => "/64",
     },
 
 #### Solaris x86 with Sun C setups
-    "solaris-x86-cc" => {
-        inherit_from     => [ "solaris-common" ],
-        cc               => "cc",
-        cflags           => add_before(picker(default => "-xarch=generic -xstrconst -Xa -DL_ENDIAN",
-                                              debug   => "-g",
-                                              release => "-xO5 -xregs=frameptr -xdepend -xbuiltin"),
-                                       threads("-D_REENTRANT")),
-        lflags           => add(threads("-mt")),
-        ex_libs          => add(threads("-lpthread")),
-        bn_ops           => "BN_LLONG RC4_CHAR",
-        shared_cflag     => "-KPIC",
-        shared_ldflag    => "-G -dy -z text",
-    },
+    # There used to be solaris-x86-cc target, but it was removed,
+    # primarily because vendor assembler can't assemble our modules
+    # with -KPIC flag. As result it, assembly support, was not even
+    # available as option. But its lack means lack of side-channel
+    # resistant code, which is incompatible with security by todays
+    # standards. Fortunately gcc is readily available prepackaged
+    # option, which we can firmly point at...
+    #
+    # On related note, solaris64-x86_64-cc target won't compile code
+    # paths utilizing AVX and post-Haswell instruction extensions.
+    # Consider switching to solaris64-x86_64-gcc even here...
+    #
     "solaris64-x86_64-cc" => {
         inherit_from     => [ "solaris-common", asm("x86_64_asm") ],
         cc               => "cc",
@@ -211,7 +248,7 @@ sub vms_info {
         bn_ops           => "SIXTY_FOUR_BIT_LONG",
         perlasm_scheme   => "elf",
         shared_cflag     => "-KPIC",
-        shared_ldflag    => "-xarch=generic64 -G -dy -z text",
+        shared_ldflag    => "-G -dy -z text",
         multilib         => "/64",
     },
 
@@ -241,7 +278,6 @@ sub vms_info {
         inherit_from     => [ "solaris-sparcv9-gcc" ],
         cflags           => sub { my $f=join(" ",@_); $f =~ s/\-m32/-m64/; $f; },
         bn_ops           => "BN_LLONG RC4_CHAR",
-        shared_ldflag    => "-m64 -shared",
         multilib         => "/64",
     },
 
@@ -269,61 +305,31 @@ sub vms_info {
     },
     "solaris-sparcv9-cc" => {
         inherit_from     => [ "solaris-sparcv7-cc", asm("sparcv9_asm") ],
-        cflags           => add_before("-xarch=v8plus -xtarget=ultra"),
+        cflags           => add_before("-xarch=v8plus"),
     },
     "solaris64-sparcv9-cc" => {
         inherit_from     => [ "solaris-sparcv7-cc", asm("sparcv9_asm") ],
-        cflags           => add_before("-xarch=v9 -xtarget=ultra"),
+        cflags           => add_before("-xarch=v9"),
         bn_ops           => "BN_LLONG RC4_CHAR",
-        shared_ldflag    => "-xarch=v9 -G -dy -z text",
         multilib         => "/64",
     },
 
-#### IRIX 5.x configs
-# -mips2 flag is added by ./config when appropriate.
-    "irix-gcc" => {
-        inherit_from     => [ "BASE_unix", asm("mips32_asm") ],
-        cc               => "gcc",
-        cflags           => picker(default => "-DB_ENDIAN",
-                                   debug   => "-g -O0",
-                                   release => "-O3"),
-        bn_ops           => "BN_LLONG RC4_CHAR",
-        thread_scheme    => "(unknown)",
-        perlasm_scheme   => "o32",
-        dso_scheme       => "dlfcn",
-        shared_target    => "irix-shared",
-        shared_extension => ".so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
-    },
-    "irix-cc" => {
-        inherit_from     => [ "BASE_unix", asm("mips32_asm") ],
-        cc               => "cc",
-        cflags           => picker(default => "-use_readonly_const -DB_ENDIAN",
-                                   debug   => "-g -O0",
-                                   release => "-O2"),
-        bn_ops           => "BN_LLONG RC4_CHAR",
-        thread_scheme    => "(unknown)",
-        perlasm_scheme   => "o32",
-        dso_scheme       => "dlfcn",
-        shared_target    => "irix-shared",
-        shared_extension => ".so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
-    },
 #### IRIX 6.x configs
-# Only N32 and N64 ABIs are supported. If you need O32 ABI build, invoke
-# './Configure irix-cc -o32' manually.
+# Only N32 and N64 ABIs are supported.
     "irix-mips3-gcc" => {
         inherit_from     => [ "BASE_unix", asm("mips64_asm") ],
         cc               => "gcc",
         cflags           => combine(picker(default => "-mabi=n32 -DB_ENDIAN -DBN_DIV3W",
                                            debug   => "-g -O0",
                                            release => "-O3"),
-                                    threads("-D_SGI_MP_SOURCE -pthread")),
+                                    threads("-D_SGI_MP_SOURCE")),
+        ex_libs          => add(threads("-lpthread")),
         bn_ops           => "RC4_CHAR SIXTY_FOUR_BIT",
         thread_scheme    => "pthreads",
         perlasm_scheme   => "n32",
         dso_scheme       => "dlfcn",
         shared_target    => "irix-shared",
-        shared_ldflag    => "-mabi=n32",
-        shared_extension => ".so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
+        shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
         multilib         => "32",
     },
     "irix-mips3-cc" => {
@@ -339,8 +345,7 @@ sub vms_info {
         perlasm_scheme   => "n32",
         dso_scheme       => "dlfcn",
         shared_target    => "irix-shared",
-        shared_ldflag    => "-n32",
-        shared_extension => ".so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
+        shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
         multilib         => "32",
     },
     # N64 ABI builds.
@@ -351,13 +356,13 @@ sub vms_info {
                                            debug   => "-g -O0",
                                            release => "-O3"),
                                     threads("-D_SGI_MP_SOURCE")),
+        ex_libs          => add(threads("-lpthread")),
         bn_ops           => "RC4_CHAR SIXTY_FOUR_BIT_LONG",
         thread_scheme    => "pthreads",
         perlasm_scheme   => "64",
         dso_scheme       => "dlfcn",
         shared_target    => "irix-shared",
-        shared_ldflag    => "-mabi=64",
-        shared_extension => ".so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
+        shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
         multilib         => "64",
     },
     "irix64-mips4-cc" => {
@@ -373,8 +378,7 @@ sub vms_info {
         perlasm_scheme   => "64",
         dso_scheme       => "dlfcn",
         shared_target    => "irix-shared",
-        shared_ldflag    => "-64",
-        shared_extension => ".so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
+        shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
         multilib         => "64",
     },
 
@@ -402,10 +406,9 @@ sub vms_info {
 #   crypto/sha/sha_lcl.h.
 # - originally there were 32-bit hpux-parisc2-* targets. They were
 #   scrapped, because a) they were not interchangeable with other 32-bit
-#   targets; a) when critical 32-bit assembly modules detect if they
-#   are executed on PA-RISC 2.0 and thus adequate performance is
-#   provided. 
-#                                      <appro@fy.chalmers.se>
+#   targets; b) performance-critical 32-bit assembly modules implement
+#   even PA-RISC 2.0-specific code paths, which are chosen at run-time,
+#   thus adequate performance is provided even with PA-RISC 1.1 build.
     "hpux-parisc-gcc" => {
         inherit_from     => [ "BASE_unix" ],
         cc               => "gcc",
@@ -420,7 +423,7 @@ sub vms_info {
         shared_target    => "hpux-shared",
         shared_cflag     => "-fPIC",
         shared_ldflag    => "-shared",
-        shared_extension => ".sl.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
+        shared_extension => ".sl.\$(SHLIB_VERSION_NUMBER)",
     },
     "hpux-parisc1_1-gcc" => {
         inherit_from     => [ "hpux-parisc-gcc", asm("parisc11_asm") ],
@@ -440,14 +443,11 @@ sub vms_info {
         shared_target    => "hpux-shared",
         shared_cflag     => "-fpic",
         shared_ldflag    => "-shared",
-        shared_extension => ".sl.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
+        shared_extension => ".sl.\$(SHLIB_VERSION_NUMBER)",
         multilib         => "/pa20_64",
     },
 
     # More attempts at unified 10.X and 11.X targets for HP C compiler.
-    #
-    # Chris Ruemmler <ruemmler@cup.hp.com>
-    # Kevin Steves <ks@hp.se>
     "hpux-parisc-cc" => {
         inherit_from     => [ "BASE_unix" ],
         cc               => "cc",
@@ -462,7 +462,7 @@ sub vms_info {
         shared_target    => "hpux-shared",
         shared_cflag     => "+Z",
         shared_ldflag    => "-b",
-        shared_extension => ".sl.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
+        shared_extension => ".sl.\$(SHLIB_VERSION_NUMBER)",
     },
     "hpux-parisc1_1-cc" => {
         inherit_from     => [ "hpux-parisc-cc", asm("parisc11_asm") ],
@@ -482,8 +482,8 @@ sub vms_info {
         dso_scheme       => "dlfcn",
         shared_target    => "hpux-shared",
         shared_cflag     => "+Z",
-        shared_ldflag    => "+DD64 -b",
-        shared_extension => ".sl.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
+        shared_ldflag    => "-b",
+        shared_extension => ".sl.\$(SHLIB_VERSION_NUMBER)",
         multilib         => "/pa20_64",
     },
 
@@ -501,12 +501,10 @@ sub vms_info {
         dso_scheme       => "dlfcn",
         shared_target    => "hpux-shared",
         shared_cflag     => "+Z",
-        shared_ldflag    => "+DD32 -b",
-        shared_extension => ".so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
+        shared_ldflag    => "-b",
+        shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
         multilib         => "/hpux32",
     },
-    # Frank Geurts <frank.geurts@nl.abnamro.com> has patiently assisted
-    # with debugging of the following config.
     "hpux64-ia64-cc" => {
         inherit_from     => [ "BASE_unix", asm("ia64_asm") ],
         cc               => "cc",
@@ -520,8 +518,8 @@ sub vms_info {
         dso_scheme       => "dlfcn",
         shared_target    => "hpux-shared",
         shared_cflag     => "+Z",
-        shared_ldflag    => "+DD64 -b",
-        shared_extension => ".so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
+        shared_ldflag    => "-b",
+        shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
         multilib         => "/hpux64",
     },
     # GCC builds...
@@ -539,7 +537,7 @@ sub vms_info {
         shared_target    => "hpux-shared",
         shared_cflag     => "-fpic",
         shared_ldflag    => "-shared",
-        shared_extension => ".so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
+        shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
         multilib         => "/hpux32",
     },
     "hpux64-ia64-gcc" => {
@@ -555,8 +553,8 @@ sub vms_info {
         dso_scheme       => "dlfcn",
         shared_target    => "hpux-shared",
         shared_cflag     => "-fpic",
-        shared_ldflag    => "-mlp64 -shared",
-        shared_extension => ".so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
+        shared_ldflag    => "-shared",
+        shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
         multilib         => "/hpux64",
     },
 
@@ -571,23 +569,18 @@ sub vms_info {
         bn_ops           => "BN_LLONG",
     },
 
-#### DEC Alpha OSF/1/Tru64 targets.
-    "osf1-alpha-gcc" => {
+#### DEC Alpha Tru64 targets. Tru64 is marketing name for OSF/1 version 4
+#### and forward. In reality 'uname -s' still returns "OSF1". Originally
+#### there were even osf1-* configs targeting prior versions provided,
+#### but not anymore...
+    "tru64-alpha-gcc" => {
         inherit_from     => [ "BASE_unix", asm("alpha_asm") ],
         cc               => "gcc",
-        cflags           => "-O3",
-        bn_ops           => "SIXTY_FOUR_BIT_LONG",
-        thread_scheme    => "(unknown)",
-        dso_scheme       => "dlfcn",
-        shared_target    => "alpha-osf1-shared",
-        shared_extension => ".so",
-    },
-    "osf1-alpha-cc" => {
-        inherit_from     => [ "BASE_unix", asm("alpha_asm") ],
-        cc               => "cc",
-        cflags           => "-std1 -tune host -O4 -readonly_strings",
+        cflags           => combine("-std=c9x -D_XOPEN_SOURCE=500 -D_OSF_SOURCE -O3",
+                                    threads("-pthread")),
+        ex_libs          => "-lrt",    # for mlock(2)
         bn_ops           => "SIXTY_FOUR_BIT_LONG",
-        thread_scheme    => "(unknown)",
+        thread_scheme    => "pthreads",
         dso_scheme       => "dlfcn",
         shared_target    => "alpha-osf1-shared",
         shared_extension => ".so",
@@ -595,8 +588,9 @@ sub vms_info {
     "tru64-alpha-cc" => {
         inherit_from     => [ "BASE_unix", asm("alpha_asm") ],
         cc               => "cc",
-        cflags           => combine("-std1 -tune host -fast -readonly_strings",
+        cflags           => combine("-std1 -D_XOPEN_SOURCE=500 -D_OSF_SOURCE -tune host -fast -readonly_strings",
                                     threads("-pthread")),
+        ex_libs          => "-lrt",    # for mlock(2)
         bn_ops           => "SIXTY_FOUR_BIT_LONG",
         thread_scheme    => "pthreads",
         dso_scheme       => "dlfcn",
@@ -613,6 +607,7 @@ sub vms_info {
     "linux-generic32" => {
         inherit_from     => [ "BASE_unix" ],
         cc               => "gcc",
+        cxx              => "g++",
         cflags           => combine(picker(default => "-Wall",
                                            debug   => "-O0 -g",
                                            release => "-O3"),
@@ -622,8 +617,9 @@ sub vms_info {
         thread_scheme    => "pthreads",
         dso_scheme       => "dlfcn",
         shared_target    => "linux-shared",
-        shared_cflag     => "-fPIC",
-        shared_extension => ".so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
+        shared_cflag     => "-fPIC -DOPENSSL_USE_NODELETE",
+        shared_ldflag    => "-Wl,-znodelete",
+        shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
     },
     "linux-generic64" => {
         inherit_from     => [ "linux-generic32" ],
@@ -638,14 +634,12 @@ sub vms_info {
         inherit_from     => [ "linux-generic64", asm("ppc64_asm") ],
         cflags           => add("-m64 -DB_ENDIAN"),
         perlasm_scheme   => "linux64",
-        shared_ldflag    => "-m64",
         multilib         => "64",
     },
     "linux-ppc64le" => {
         inherit_from     => [ "linux-generic64", asm("ppc64_asm") ],
         cflags           => add("-m64 -DL_ENDIAN"),
         perlasm_scheme   => "linux64le",
-        shared_ldflag    => "-m64",
     },
 
     "linux-armv4" => {
@@ -692,7 +686,6 @@ sub vms_info {
         cflags           => add("-mabi=ilp32"),
         bn_ops           => "SIXTY_FOUR_BIT RC4_CHAR",
         perlasm_scheme   => "linux64",
-        shared_ldflag    => "-mabi=ilp32",
     },
 
     "linux-mips32" => {
@@ -701,7 +694,6 @@ sub vms_info {
         inherit_from     => [ "linux-generic32", asm("mips32_asm") ],
         cflags           => add("-mabi=32 -DBN_DIV3W"),
         perlasm_scheme   => "o32",
-        shared_ldflag    => "-mabi=32",
     },
     # mips32 and mips64 below refer to contemporary MIPS Architecture
     # specifications, MIPS32 and MIPS64, rather than to kernel bitness.
@@ -710,23 +702,22 @@ sub vms_info {
         cflags           => add("-mabi=n32 -DBN_DIV3W"),
         bn_ops           => "SIXTY_FOUR_BIT RC4_CHAR",
         perlasm_scheme   => "n32",
-        shared_ldflag    => "-mabi=n32",
         multilib         => "32",
     },
     "linux64-mips64" => {
         inherit_from     => [ "linux-generic64", asm("mips64_asm") ],
         cflags           => add("-mabi=64 -DBN_DIV3W"),
         perlasm_scheme   => "64",
-        shared_ldflag    => "-mabi=64",
         multilib         => "64",
     },
 
     #### IA-32 targets...
+    #### These two targets are a bit aged and are to be used on older Linux
+    #### machines where gcc doesn't understand -m32 and -m64
     "linux-elf" => {
         inherit_from     => [ "linux-generic32", asm("x86_elf_asm") ],
         cflags           => add(picker(default => "-DL_ENDIAN",
                                        release => "-fomit-frame-pointer")),
-        ex_libs          => add(picker(debug => "-lefence")),
         bn_ops           => "BN_LLONG",
     },
     "linux-aout" => {
@@ -740,25 +731,38 @@ sub vms_info {
         perlasm_scheme   => "a.out",
     },
 
+    #### X86 / X86_64 targets
+    "linux-x86" => {
+        inherit_from     => [ "linux-generic32", asm("x86_asm") ],
+        cflags           => add(picker(default => "-m32 -DL_ENDIAN",
+                                       release => "-fomit-frame-pointer")),
+        bn_ops           => "BN_LLONG",
+        perlasm_scheme   => "elf",
+    },
+    "linux-x86-clang" => {
+        inherit_from     => [ "linux-x86" ],
+        cc               => "clang",
+        cxx              => "clang++",
+        cflags           => add("-Wextra"),
+    },
     "linux-x86_64" => {
         inherit_from     => [ "linux-generic64", asm("x86_64_asm") ],
         cflags           => add("-m64 -DL_ENDIAN"),
         bn_ops           => "SIXTY_FOUR_BIT_LONG",
         perlasm_scheme   => "elf",
-        shared_ldflag    => "-m64",
         multilib         => "64",
     },
     "linux-x86_64-clang" => {
         inherit_from     => [ "linux-x86_64" ],
         cc               => "clang",
-        cflags           => add("-Wextra -Qunused-arguments"),
+        cxx              => "clang++",
+        cflags           => add("-Wextra"),
     },
     "linux-x32" => {
         inherit_from     => [ "linux-generic32", asm("x86_64_asm") ],
         cflags           => add("-mx32 -DL_ENDIAN"),
         bn_ops           => "SIXTY_FOUR_BIT",
         perlasm_scheme   => "elf32",
-        shared_ldflag    => "-mx32",
         multilib         => "x32",
     },
 
@@ -771,7 +775,6 @@ sub vms_info {
         inherit_from     => [ "linux-generic64", asm("s390x_asm") ],
         cflags           => add("-m64 -DB_ENDIAN"),
         perlasm_scheme   => "64",
-        shared_ldflag    => "-m64",
         multilib         => "64",
     },
     "linux32-s390x" => {
@@ -795,13 +798,10 @@ sub vms_info {
         cflags           => add("-m31 -Wa,-mzarch -DB_ENDIAN"),
         bn_asm_src       => sub { my $r=join(" ",@_); $r=~s|asm/s390x\.S|bn_asm.c|; $r; },
         perlasm_scheme   => "31",
-        shared_ldflag    => "-m31",
         multilib         => "/highgprs",
     },
 
     #### SPARC Linux setups
-    # Ray Miller <ray.miller@computing-services.oxford.ac.uk> has
-    # patiently assisted with debugging of following two configs.
     "linux-sparcv8" => {
         inherit_from     => [ "linux-generic32", asm("sparcv8_asm") ],
         cflags           => add("-mcpu=v8 -DB_ENDIAN -DBN_DIV2W"),
@@ -811,14 +811,12 @@ sub vms_info {
         # but -Wa,-Av8plus should do the trick no matter what.
         inherit_from     => [ "linux-generic32", asm("sparcv9_asm") ],
         cflags           => add("-m32 -mcpu=ultrasparc -Wa,-Av8plus -DB_ENDIAN -DBN_DIV2W"),
-        shared_ldflag    => "-m32",
     },
     "linux64-sparcv9" => {
         # GCC 3.1 is a requirement
         inherit_from     => [ "linux-generic64", asm("sparcv9_asm") ],
         cflags           => add("-m64 -mcpu=ultrasparc -DB_ENDIAN"),
         bn_ops           => "BN_LLONG RC4_CHAR",
-        shared_ldflag    => "-m64",
         multilib         => "64",
     },
 
@@ -847,8 +845,8 @@ sub vms_info {
         dso_scheme       => "dlfcn",
         shared_target    => "linux-shared",
         shared_cflag     => "--pic",
-        shared_ldflag    => "-z --sysv --shared",
-        shared_extension => ".so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
+        shared_ldflag    => add("-z --sysv --shared"),
+        shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
         ranlib           => "true",
     },
 
@@ -856,7 +854,7 @@ sub vms_info {
     #
     # It takes pair of prior-set environment variables to make it work:
     #
-    # CROSS_SYSROOT=/some/where/android-ndk-<ver>/platforms/android-<apiver>/arch-<
+    # CROSS_SYSROOT=/some/where/android-ndk-<ver>/platforms/android-<apiver>/arch-<arch>
     # CROSS_COMPILE=<prefix>
     #
     # As well as PATH adjusted to cover ${CROSS_COMPILE}gcc and company.
@@ -865,24 +863,21 @@ sub vms_info {
     # ANDROID_NDK=/some/where/android-ndk-10d
     # CROSS_SYSROOT=$ANDROID_NDK/platforms/android-14/arch-arm
     # CROSS_COMPILE=arm-linux-adroideabi-
-    # PATH=$ANDROID_NDK/toolchains/arm-linux-androideabi-4.8/prebuild/linux-x86_64/
+    # PATH=$ANDROID_NDK/toolchains/arm-linux-androideabi-4.8/prebuild/linux-x86_64/bin
     #
     "android" => {
         inherit_from     => [ "linux-generic32" ],
         # Special note about unconditional -fPIC and -pie. The underlying
         # reason is that Lollipop refuses to run non-PIE. But what about
         # older systems and NDKs? -fPIC was never problem, so the only
-        # concern if -pie. Older toolchains, e.g. r4, appear to handle it
+        # concern is -pie. Older toolchains, e.g. r4, appear to handle it
         # and binaries turn mostly functional. "Mostly" means that oldest
         # Androids, such as Froyo, fail to handle executable, but newer
         # systems are perfectly capable of executing binaries targeting
         # Froyo. Keep in mind that in the nutshell Android builds are
         # about JNI, i.e. shared libraries, not applications.
-        cflags           => picker(default => "-mandroid -fPIC --sysroot=\$(CROSS_SYSROOT) -Wa,--noexecstack -Wall",
-                                   debug   => "-O0 -g",
-                                   release => "-O3"),
-        lflags           => "-pie",
-        shared_cflag     => "",
+        cflags           => add(picker(default => "-mandroid -fPIC --sysroot=\$(CROSS_SYSROOT) -Wa,--noexecstack")),
+        bin_cflags       => "-pie",
     },
     "android-x86" => {
         inherit_from     => [ "android", asm("x86_asm") ],
@@ -921,16 +916,30 @@ sub vms_info {
 
     "android64" => {
         inherit_from     => [ "linux-generic64" ],
-        cflags           => picker(default => "-mandroid -fPIC --sysroot=\$(CROSS_SYSROOT) -Wa,--noexecstack -Wall",
-                                   debug   => "-O0 -g",
-                                   release => "-O3"),
-        lflags           => "-pie",
-        shared_cflag     => "",
+        cflags           => add(picker(default => "-mandroid -fPIC --sysroot=\$(CROSS_SYSROOT) -Wa,--noexecstack")),
+        bin_cflags       => "-pie",
     },
     "android64-aarch64" => {
         inherit_from     => [ "android64", asm("aarch64_asm") ],
         perlasm_scheme   => "linux64",
     },
+    "android64-x86_64" => {
+        inherit_from     => [ "android64", asm("x86_64_asm") ],
+        perlasm_scheme   => "elf",
+    },
+    "android64-mips64" => {
+        ############################################################
+        # You are more than likely have to specify target processor
+        # on ./Configure command line. Trouble is that toolchain's
+        # default is MIPS64r6 (at least in r10d), but there are no
+        # such processors around (or they are too rare to spot one).
+        # Actual problem is that MIPS64r6 is binary incompatible
+        # with previous MIPS ISA versions, in sense that unlike
+        # prior versions original MIPS binary code will fail.
+        #
+        inherit_from     => [ "android64", asm("mips64_asm") ],
+        perlasm_scheme   => "64",
+    },
 
 #### *BSD
     "BSD-generic32" => {
@@ -947,12 +956,13 @@ sub vms_info {
                                            debug   => "-O0 -g",
                                            release => "-O3"),
                                     threads("-pthread -D_THREAD_SAFE -D_REENTRANT")),
+        enable           => add("devcryptoeng"),
         bn_ops           => "BN_LLONG",
         thread_scheme    => "pthreads",
         dso_scheme       => "dlfcn",
         shared_target    => "bsd-gcc-shared",
         shared_cflag     => "-fPIC",
-        shared_extension => ".so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
+        shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
     },
     "BSD-generic64" => {
         inherit_from     => [ "BSD-generic32" ],
@@ -1008,7 +1018,7 @@ sub vms_info {
         dso_scheme       => "dlfcn",
         shared_target    => "bsd-gcc-shared",
         shared_cflag     => "-fPIC",
-        shared_extension => ".so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
+        shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
     },
 
     "nextstep" => {
@@ -1042,7 +1052,7 @@ sub vms_info {
         dso_scheme       => "dlfcn",
         shared_target    => "bsd-gcc-shared",
         shared_cflag     => "-fPIC",
-        shared_extension => ".so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
+        shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
     },
     "QNX6-i386" => {
         inherit_from     => [ "BASE_unix", asm("x86_elf_asm") ],
@@ -1052,7 +1062,7 @@ sub vms_info {
         dso_scheme       => "dlfcn",
         shared_target    => "bsd-gcc-shared",
         shared_cflag     => "-fPIC",
-        shared_extension => ".so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
+        shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
     },
 
 #### SCO/Caldera targets.
@@ -1063,8 +1073,7 @@ sub vms_info {
 # and './Configure unixware-7 -Kpentium_pro' or whatever appropriate.
 # Note that not all targets include assembler support. Mostly because of
 # lack of motivation to support out-of-date platforms with out-of-date
-# compiler drivers and assemblers. Tim Rice <tim@multitalents.net> has
-# patiently assisted to debug most of it.
+# compiler drivers and assemblers.
 #
 # UnixWare 2.0x fails destest with -O.
     "unixware-2.0" => {
@@ -1095,7 +1104,7 @@ sub vms_info {
         dso_scheme       => "dlfcn",
         shared_target    => "svr5-shared",
         shared_cflag     => "-Kpic",
-        shared_extension => ".so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
+        shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
     },
     "unixware-7-gcc" => {
         inherit_from     => [ "BASE_unix", asm("x86_elf_asm") ],
@@ -1109,9 +1118,9 @@ sub vms_info {
         dso_scheme       => "dlfcn",
         shared_target    => "gnu-shared",
         shared_cflag     => "-fPIC",
-        shared_extension => ".so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
+        shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
     },
-# SCO 5 - Ben Laurie <ben@algroup.co.uk> says the -O breaks the SCO cc.
+# SCO 5 - Ben Laurie says the -O breaks the SCO cc.
     "sco5-cc" => {
         inherit_from     => [ "BASE_unix", asm("x86_elf_asm") ],
         cc               => "cc",
@@ -1122,7 +1131,7 @@ sub vms_info {
         dso_scheme       => "dlfcn",
         shared_target    => "svr3-shared",
         shared_cflag     => "-Kpic",
-        shared_extension => ".so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
+        shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
     },
     "sco5-gcc" => {
         inherit_from     => [ "BASE_unix", asm("x86_elf_asm") ],
@@ -1135,10 +1144,15 @@ sub vms_info {
         dso_scheme       => "dlfcn",
         shared_target    => "svr3-shared",
         shared_cflag     => "-fPIC",
-        shared_extension => ".so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
+        shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
     },
 
 #### IBM's AIX.
+    # Below targets assume AIX >=5. Caveat lector. If you are accustomed
+    # to control compilation "bitness" by setting $OBJECT_MODE environment
+    # variable, then you should know that in OpenSSL case it's considered
+    # only in ./config. Once configured, build procedure remains "deaf" to
+    # current value of $OBJECT_MODE.
     "aix-gcc" => {
         inherit_from     => [ "BASE_unix", asm("ppc32_asm") ],
         cc               => "gcc",
@@ -1152,8 +1166,8 @@ sub vms_info {
         perlasm_scheme   => "aix32",
         dso_scheme       => "dlfcn",
         shared_target    => "aix-shared",
-        shared_ldflag    => "-shared -Wl,-G",
-        shared_extension => ".so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
+        shared_ldflag    => "-shared -static-libgcc -Wl,-G",
+        shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
         arflags          => "-X32",
     },
     "aix64-gcc" => {
@@ -1169,13 +1183,10 @@ sub vms_info {
         perlasm_scheme   => "aix64",
         dso_scheme       => "dlfcn",
         shared_target    => "aix-shared",
-        shared_ldflag    => "-maix64 -shared -Wl,-G",
-        shared_extension => ".so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
+        shared_ldflag    => "-shared -static-libgcc -Wl,-G",
+        shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
         arflags          => "-X64",
     },
-    # Below targets assume AIX 5. Idea is to effectively disregard
-    # $OBJECT_MODE at build time. $OBJECT_MODE is respected at
-    # ./config stage!
     "aix-cc" => {
         inherit_from     => [ "BASE_unix", asm("ppc32_asm") ],
         cc               => "cc",
@@ -1186,11 +1197,12 @@ sub vms_info {
         sys_id           => "AIX",
         bn_ops           => "BN_LLONG RC4_CHAR",
         thread_scheme    => "pthreads",
+        ex_libs          => threads("-lpthreads"),
         perlasm_scheme   => "aix32",
         dso_scheme       => "dlfcn",
         shared_target    => "aix-shared",
-        shared_ldflag    => "-q32 -G",
-        shared_extension => ".so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
+        shared_ldflag    => "-G",
+        shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
         arflags          => "-X 32",
     },
     "aix64-cc" => {
@@ -1203,11 +1215,12 @@ sub vms_info {
         sys_id           => "AIX",
         bn_ops           => "SIXTY_FOUR_BIT_LONG RC4_CHAR",
         thread_scheme    => "pthreads",
+        ex_libs          => threads("-lpthreads"),
         perlasm_scheme   => "aix64",
         dso_scheme       => "dlfcn",
         shared_target    => "aix-shared",
-        shared_ldflag    => "-q64 -G",
-        shared_extension => ".so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
+        shared_ldflag    => "-G",
+        shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
         arflags          => "-X 64",
     },
 
@@ -1248,21 +1261,31 @@ sub vms_info {
         inherit_from     => [ "BASE_Windows" ],
         template         => 1,
         cc               => "cl",
-        cflags           => "-W3 -wd4090 -Gs0 -GF -Gy -nologo -DOPENSSL_SYS_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -D_CRT_SECURE_NO_DEPRECATE",
+        cflags           => "-W3 -wd4090 -Gs0 -GF -Gy -nologo -DOPENSSL_SYS_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -D_CRT_SECURE_NO_DEPRECATE -D_WINSOCK_DEPRECATED_NO_WARNINGS",
+        defines          => add(sub { my @defs = ();
+                                      unless ($disabled{"zlib-dynamic"}) {
+                                          my $zlib =
+                                              $withargs{zlib_lib} // "ZLIB1";
+                                          push @defs,
+                                              quotify("perl",
+                                                      'LIBZ="' . $zlib . '"');
+                                      }
+                                      return [ @defs ];
+                                    }),
         coutflag         => "/Fo",
-        rc               => "rc",
-        rcoutflag        => "/fo",
-        lib_cflags       => add("/Zi /Fdlib"),
-        dso_cflags       => "/Zi",
+        lib_cflags       => add("/Zi /Fdossl_static"),
+        dso_cflags       => "/Zi /Fddso",
         bin_cflags       => "/Zi /Fdapp",
         lflags           => add("/debug"),
         shared_ldflag    => "/dll",
         shared_target    => "win-shared", # meaningless except it gives Configure a hint
         thread_scheme    => "winthreads",
         dso_scheme       => "win32",
+        apps_aux_src     => add("win32_init.c"),
     },
     "VC-noCE-common" => {
         inherit_from     => [ "VC-common" ],
+        template         => 1,
         cflags           => add(picker(default => "-DUNICODE -D_UNICODE",
                                        debug   =>
                                        sub {
@@ -1272,7 +1295,7 @@ sub vms_info {
                                        release =>
                                        sub {
                                            ($disabled{shared} ? "" : "/MD")
-                                               ." /Ox /O2 /Ob2";
+                                               ." /O2";
                                        })),
         lib_cflags       => add(sub { $disabled{shared} ? "/MT /Zl" : () }),
         # Following might/should appears controversial, i.e. defining
@@ -1290,20 +1313,21 @@ sub vms_info {
                                        release => sub { $disabled{shared} ? "/MT" : () },
                                       )),
         bin_lflags       => add("/subsystem:console /opt:ref"),
-        ex_libs          => sub {
+        ex_libs          => add(sub {
             my @ex_libs = ();
             push @ex_libs, 'ws2_32.lib' unless $disabled{sock};
             push @ex_libs, 'gdi32.lib advapi32.lib crypt32.lib user32.lib';
             return join(" ", @ex_libs);
-        },
+        }),
     },
     "VC-WIN64-common" => {
         inherit_from     => [ "VC-noCE-common" ],
-        ex_libs          => sub {
+        template         => 1,
+        ex_libs          => add(sub {
             my @ex_libs = ();
             push @ex_libs, 'bufferoverflowu.lib' if (`cl 2>&1` =~ /14\.00\.4[0-9]{4}\./);
             return join(" ", @_, @ex_libs);
-        },
+        }),
         bn_ops           => "SIXTY_FOUR_BIT EXPORT_VAR_AS_FN",
         build_scheme     => add("VC-W64", { separator => undef }),
     },
@@ -1336,22 +1360,21 @@ sub vms_info {
         # configure with 'perl Configure VC-WIN32 -DUNICODE -D_UNICODE'
         inherit_from     => [ "VC-noCE-common", asm("x86_asm"),
                               sub { $disabled{shared} ? () : "uplink_common" } ],
-        as               => sub { my $ver=`nasm -v 2>NUL`;
-                                  my $vew=`nasmw -v 2>NUL`;
-                                  return $ver ge $vew ? "nasm" : "nasmw" },
-        asflags          => "-f win32",
-        asoutflag        => "-o",
-        ex_libs          => sub {
+        cflags           => add("-WX"),
+        as               => sub { vc_win32_info()->{as} },
+        asflags          => sub { vc_win32_info()->{asflags} },
+        asoutflag        => sub { vc_win32_info()->{asoutflag} },
+        ex_libs          => add(sub {
             my @ex_libs = ();
             # WIN32 UNICODE build gets linked with unicows.lib for
             # backward compatibility with Win9x.
             push @ex_libs, 'unicows.lib'
                 if (grep { $_ eq "UNICODE" } @user_defines);
             return join(" ", @ex_libs, @_);
-        },
+        }),
         sys_id           => "WIN32",
         bn_ops           => "BN_LLONG EXPORT_VAR_AS_FN",
-        perlasm_scheme   => "win32n",
+        perlasm_scheme   => sub { vc_win32_info()->{perlasm_scheme} },
         build_scheme     => add("VC-W32", { separator => undef }),
     },
     "VC-CE" => {
@@ -1364,9 +1387,9 @@ sub vms_info {
             picker(default =>
                    combine('/W3 /WX /GF /Gy /nologo -DUNICODE -D_UNICODE -DOPENSSL_SYS_WINCE -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DDSO_WIN32 -DNO_CHMOD -DOPENSSL_SMALL_FOOTPRINT',
                            sub { vc_wince_info()->{cflags}; },
-                           sub { defined($ENV{'WCECOMPAT'})
+                           sub { defined(env('WCECOMPAT'))
                                      ? '-I$(WCECOMPAT)/include' : (); },
-                           sub { defined($ENV{'PORTSDK_LIBPATH'})
+                           sub { defined(env('PORTSDK_LIBPATH'))
                                      ? '-I$(PORTSDK_LIBPATH)/../../include' : (); },
                            sub { `cl 2>&1` =~ /Version ([0-9]+)\./ && $1>=14
                                      ? ($disabled{shared} ? " /MT" : " /MD")
@@ -1375,17 +1398,17 @@ sub vms_info {
                    release => "/O1i"),
         lflags           => combine("/nologo /opt:ref",
                                     sub { vc_wince_info()->{lflags}; },
-                                    sub { defined($ENV{PORTSDK_LIBPATH})
+                                    sub { defined(env('PORTSDK_LIBPATH'))
                                               ? "/entry:mainCRTstartup" : (); }),
         sys_id           => "WINCE",
         bn_ops           => "BN_LLONG EXPORT_VAR_AS_FN",
-        ex_libs          => sub {
+        ex_libs          => add(sub {
             my @ex_libs = ();
             push @ex_libs, 'ws2.lib' unless $disabled{sock};
             push @ex_libs, 'crypt32.lib';
-            if (defined($ENV{WCECOMPAT})) {
+            if (defined(env('WCECOMPAT'))) {
                 my $x = '$(WCECOMPAT)/lib';
-                if (-f "$x/$ENV{TARGETCPU}/wcecompatex.lib") {
+                if (-f "$x/env('TARGETCPU')/wcecompatex.lib") {
                     $x .= '/$(TARGETCPU)/wcecompatex.lib';
                 } else {
                     $x .= '/wcecompatex.lib';
@@ -1393,11 +1416,11 @@ sub vms_info {
                 push @ex_libs, $x;
             }
             push @ex_libs, '$(PORTSDK_LIBPATH)/portlib.lib'
-                if (defined($ENV{'PORTSDK_LIBPATH'}));
+                if (defined(env('PORTSDK_LIBPATH')));
             push @ex_libs, ' /nodefaultlib coredll.lib corelibc.lib'
-                if ($ENV{'TARGETCPU'} eq "X86");
+                if (env('TARGETCPU') eq "X86");
             return @ex_libs;
-        },
+        }),
         build_scheme     => add("VC-WCE", { separator => undef }),
     },
 
@@ -1422,6 +1445,7 @@ sub vms_info {
         shared_rcflag    => "--target=pe-i386",
         shared_extension => ".dll",
         multilib         => "",
+        apps_aux_src     => add("win32_init.c"),
     },
     "mingw64" => {
         # As for OPENSSL_USE_APPLINK. Applink makes it possible to use
@@ -1450,6 +1474,7 @@ sub vms_info {
         shared_rcflag    => "--target=pe-x86-64",
         shared_extension => ".dll",
         multilib         => "64",
+        apps_aux_src     => add("win32_init.c"),
     },
 
 #### UEFI
@@ -1484,7 +1509,6 @@ sub vms_info {
         dso_scheme       => "dlfcn",
         shared_target    => "cygwin-shared",
         shared_cflag     => "-D_WINDLL",
-        shared_ldflag    => "-shared",
         shared_extension => ".dll",
     },
     "Cygwin-x86_64" => {
@@ -1500,7 +1524,6 @@ sub vms_info {
         dso_scheme       => "dlfcn",
         shared_target    => "cygwin-shared",
         shared_cflag     => "-D_WINDLL",
-        shared_ldflag    => "-shared",
         shared_extension => ".dll",
     },
     # Backward compatibility for those using this target
@@ -1521,17 +1544,6 @@ sub vms_info {
        inherit_from     => [ "Cygwin-x86" ]
     },
 
-#### DJGPP
-    "DJGPP" => {
-        inherit_from     => [ asm("x86_asm") ],
-        cc               => "gcc",
-        cflags           => "-I/dev/env/WATT_ROOT/inc -DTERMIO -DL_ENDIAN -fomit-frame-pointer -O2 -Wall",
-        sys_id           => "MSDOS",
-        ex_libs          => add("-L/dev/env/WATT_ROOT/lib -lwatt"),
-        bn_ops           => "BN_LLONG",
-        perlasm_scheme   => "a.out",
-    },
-
 ##### MacOS X (a.k.a. Darwin) setup
     "darwin-common" => {
         inherit_from     => [ "BASE_unix" ],
@@ -1550,8 +1562,7 @@ sub vms_info {
         ranlib           => "ranlib -c",
         shared_target    => "darwin-shared",
         shared_cflag     => "-fPIC",
-        shared_ldflag    => "-dynamiclib",
-        shared_extension => ".\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
+        shared_extension => ".\$(SHLIB_VERSION_NUMBER).dylib",
     },
     # Option "freeze" such as -std=gnu9x can't negatively interfere
     # with future defaults for below two targets, because MacOS X
@@ -1560,14 +1571,12 @@ sub vms_info {
         inherit_from     => [ "darwin-common", asm("ppc32_asm") ],
         cflags           => add("-arch ppc -std=gnu9x -DB_ENDIAN -Wa,-force_cpusubtype_ALL"),
         perlasm_scheme   => "osx32",
-        shared_ldflag    => "-arch ppc -dynamiclib",
     },
     "darwin64-ppc-cc" => {
         inherit_from     => [ "darwin-common", asm("ppc64_asm") ],
         cflags           => add("-arch ppc64 -std=gnu9x -DB_ENDIAN"),
         bn_ops           => "SIXTY_FOUR_BIT_LONG RC4_CHAR",
         perlasm_scheme   => "osx64",
-        shared_ldflag    => "-arch ppc64 -dynamiclib",
     },
     "darwin-i386-cc" => {
         inherit_from     => [ "darwin-common", asm("x86_asm") ],
@@ -1575,14 +1584,12 @@ sub vms_info {
                                        release => "-fomit-frame-pointer")),
         bn_ops           => "BN_LLONG RC4_INT",
         perlasm_scheme   => "macosx",
-        shared_ldflag    => "-arch i386 -dynamiclib",
     },
     "darwin64-x86_64-cc" => {
         inherit_from     => [ "darwin-common", asm("x86_64_asm") ],
         cflags           => add("-arch x86_64 -DL_ENDIAN -Wall"),
         bn_ops           => "SIXTY_FOUR_BIT_LONG",
         perlasm_scheme   => "macosx",
-        shared_ldflag    => "-arch x86_64 -dynamiclib",
     },
 
 #### iPhoneOS/iOS
@@ -1635,6 +1642,7 @@ sub vms_info {
         dso_scheme       => "dlfcn",
         shared_target    => "linux-shared",
         shared_cflag     => "-fPIC",
+        shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
     },
 
 ##### VxWorks for various targets
@@ -1703,35 +1711,33 @@ sub vms_info {
 #### uClinux
     "uClinux-dist" => {
         inherit_from     => [ "BASE_unix" ],
-        cc               => "$ENV{'CC'}",
+        cc               => sub { env('CC') },
         cflags           => combine("\$(CFLAGS)",
                                     threads("-D_REENTRANT")),
         plib_lflags      => "\$(LDFLAGS)",
         ex_libs          => add("\$(LDLIBS)"),
         bn_ops           => "BN_LLONG",
         thread_scheme    => "pthreads",
-        dso_scheme       => "$ENV{'LIBSSL_dlfcn'}",
+        dso_scheme       => sub { env('LIBSSL_dlfcn') },
         shared_target    => "linux-shared",
         shared_cflag     => "-fPIC",
-        shared_ldflag    => "-shared",
-        shared_extension => ".so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
-        ranlib           => "$ENV{'RANLIB'}",
+        shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
+        ranlib           => sub { env('RANLIB') },
     },
     "uClinux-dist64" => {
         inherit_from     => [ "BASE_unix" ],
-        cc               => "$ENV{'CC'}",
+        cc               => sub { env('CC') },
         cflags           => combine("\$(CFLAGS)",
                                     threads("-D_REENTRANT")),
         plib_lflags      => "\$(LDFLAGS)",
         ex_libs          => add("\$(LDLIBS)"),
         bn_ops           => "SIXTY_FOUR_BIT_LONG",
         thread_scheme    => "pthreads",
-        dso_scheme       => "$ENV{'LIBSSL_dlfcn'}",
+        dso_scheme       => sub { env('LIBSSL_dlfcn') },
         shared_target    => "linux-shared",
         shared_cflag     => "-fPIC",
-        shared_ldflag    => "-shared",
-        shared_extension => ".so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
-        ranlib           => "$ENV{'RANLIB'}",
+        shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
+        ranlib           => sub { env('RANLIB') },
     },
 
     ##### VMS
@@ -1739,31 +1745,24 @@ sub vms_info {
         inherit_from     => [ "BASE_VMS" ],
         template         => 1,
         cc               => "CC/DECC",
-        cflags           => picker(default => "/STANDARD=RELAXED/NOLIST/PREFIX=ALL/NAMES=(AS_IS,SHORTENED)",
+        cflags           => picker(default => "/STANDARD=(ISOC94,RELAXED)/NOLIST/PREFIX=ALL",
                                    debug   => "/NOOPTIMIZE/DEBUG",
                                    release => "/OPTIMIZE/NODEBUG"),
-        lflags           => picker(default => "/MAP",
+        defines          => add("OPENSSL_USE_NODELETE"),
+        lflags           => picker(default => "/MAP='F\$PARSE(\".MAP\",\"\$\@\")'",
                                    debug   => "/DEBUG/TRACEBACK",
                                    release => "/NODEBUG/NOTRACEBACK"),
+        lib_cflags       => add("/NAMES=(AS_IS,SHORTENED)/EXTERN_MODEL=STRICT_REFDEF"),
+        # no_inst_lib_cflags is used instead of lib_cflags by descrip.mms.tmpl
+        # for object files belonging to selected internal libraries
+        no_inst_lib_cflags => "",
         shared_target    => "vms-shared",
         dso_scheme       => "vms",
         thread_scheme    => "pthreads",
 
-        apps_aux_src     => "vms_decc_init.c",
+        apps_aux_src     => "vms_decc_init.c vms_term_sock.c",
     },
 
-    # VMS on VAX is *unsupported*
-    #"vms-asm" => {
-    #   template          => 1,
-    #   bn_obj            => "[.asm]vms.obj vms-helper.obj"
-    #},
-    #"vms-vax" => {
-    #   inherit_from      => [ "vms-generic", asm("vms-asm") ],
-    #   as                => "MACRO",
-    #   debug_aflags      => "/NOOPTIMIZE/DEBUG",
-    #   release_aflags    => "/OPTIMIZE/NODEBUG",
-    #   bn_opts           => "THIRTY_TWO_BIT RC4_CHAR RC4_CHUNK DES_PTR BF_PTR",
-    #},
     "vms-alpha" => {
         inherit_from     => [ "vms-generic" ],
         cflags           => add(sub { my @warnings =
@@ -1776,10 +1775,11 @@ sub vms_info {
                                 ? "LIBZ=\"\"\"".vms_info(0)->{def_zlib}."\"\"\"" : ();
                             }),
         ex_libs          => add(sub { return vms_info(0)->{zlib} || (); }),
+        pointer_size     => sub { return vms_info(0)->{pointer_size} },
         #as               => "???",
         #debug_aflags     => "/NOOPTIMIZE/DEBUG",
         #release_aflags   => "/OPTIMIZE/NODEBUG",
-        bn_opts          => "SIXTY_FOUR_BIT RC4_INT RC4_CHUNK_LL DES_PTR BF_PTR",
+        bn_opts          => "SIXTY_FOUR_BIT RC4_INT",
     },
     "vms-alpha-p32" => {
         inherit_from     => [ "vms-generic" ],
@@ -1796,6 +1796,7 @@ sub vms_info {
                                 ? "LIBZ=\"\"\"".vms_info(32)->{def_zlib}."\"\"\"" : ();
                             }),
         ex_libs          => add(sub { return vms_info(32)->{zlib} || (); }),
+        pointer_size     => sub { return vms_info(32)->{pointer_size} },
     },
     "vms-alpha-p64" => {
         inherit_from     => [ "vms-generic" ],
@@ -1812,6 +1813,7 @@ sub vms_info {
                                 ? "LIBZ=\"\"\"".vms_info(64)->{def_zlib}."\"\"\"" : ();
                             }),
         ex_libs          => add(sub { return vms_info(64)->{zlib} || (); }),
+        pointer_size     => sub { return vms_info(64)->{pointer_size} },
     },
     "vms-ia64" => {
         inherit_from     => [ "vms-generic" ],
@@ -1825,10 +1827,11 @@ sub vms_info {
                                 ? "LIBZ=\"\"\"".vms_info(0)->{def_zlib}."\"\"\"" : ();
                             }),
         ex_libs          => add(sub { return vms_info(0)->{zlib} || (); }),
+        pointer_size     => sub { return vms_info(0)->{pointer_size} },
         #as               => "I4S",
         #debug_aflags     => "/NOOPTIMIZE/DEBUG",
         #release_aflags   => "/OPTIMIZE/NODEBUG",
-        bn_opts          => "SIXTY_FOUR_BIT RC4_INT RC4_CHUNK_LL DES_PTR BF_PTR",
+        bn_opts          => "SIXTY_FOUR_BIT RC4_INT",
     },
     "vms-ia64-p32" => {
         inherit_from     => [ "vms-generic" ],
@@ -1845,6 +1848,7 @@ sub vms_info {
                                 ? "LIBZ=\"\"\"".vms_info(32)->{def_zlib}."\"\"\"" : ();
                             }),
         ex_libs          => add(sub { return vms_info(32)->{zlib} || (); }),
+        pointer_size     => sub { return vms_info(32)->{pointer_size} },
     },
     "vms-ia64-p64" => {
         inherit_from     => [ "vms-generic" ],
@@ -1861,6 +1865,7 @@ sub vms_info {
                                 ? "LIBZ=\"\"\"".vms_info(64)->{def_zlib}."\"\"\"" : ();
                             }),
         ex_libs          => add(sub { return vms_info(64)->{zlib} || (); }),
+        pointer_size     => sub { return vms_info(64)->{pointer_size} },
     },
 
 );