Unified - extract settings from util/pl/VC-32.pl and make the config settings
[openssl.git] / Configurations / 10-main.conf
index 121815ff8162a48df94c5064198709d6e22bc97b..fa9af88e421b8223246f6b4aa5188e3c77a8c3ae 100644 (file)
@@ -7,6 +7,89 @@ sub picker {
                      $opts{$config{build_type}} || ())->(); }
 }
 
+sub threads {
+    my @flags = @_;
+    return sub { add($disabled{threads} ? () : @flags)->(); }
+}
+
+sub combine {
+    my @stuff = @_;
+    return sub { add(@stuff)->(); }
+}
+
+# Helper functions for the Windows configs
+my $vc_win64a_info = {};
+sub vc_win64a_info {
+    unless (%$vc_win64a_info) {
+        if (`nasm -v 2>NUL` =~ /NASM version ([0-9]+\.[0-9]+)/ && $1 >= 2.0) {
+            $vc_win64a_info = { as        => "nasm",
+                                asflags   => "-f win64 -DNEAR -Ox -g",
+                                asoutflag => "-o" };
+        } else {
+            $vc_win64a_info = { as        => "ml64",
+                                asflags   => "/c /Cp /Cx /Zi",
+                                asoutflag => "/Fo" };
+        }
+    }
+    return $vc_win64a_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'}));
+
+        #
+        # 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 $wceplatf =  $ENV{'PLATFORM'};
+        my $wceplatf =~ tr/a-z0-9 /A-Z0-9_/d;
+        my $wcecdefs .= " -DWCE_PLATFORM_$wceplatf";
+
+        my $wcetgt = $ENV{'TARGETCPU'};                     # just shorter name...
+      SWITCH: for($wcetgt) {
+          /^X86/        && do { $wcecdefs.=" -Dx86 -D_X86_ -D_i386_ -Di_386_";
+                                $wcelflag.=" /machine:X86";     last; };
+          /^ARMV4[IT]/  && do { $wcecdefs.=" -DARM -D_ARM_ -D$wcetgt";
+                                $wcecdefs.=" -DTHUMB -D_THUMB_" if($wcetgt=~/T$/);
+                                $wcecdefs.=" -QRarch4T -QRinterwork-return";
+                                $wcelflag.=" /machine:THUMB";   last; };
+          /^ARM/        && do { $wcecdefs.=" -DARM -D_ARM_ -D$wcetgt";
+                                $wcelflag.=" /machine:ARM";     last; };
+          /^MIPSIV/     && do { $wcecdefs.=" -DMIPS -D_MIPS_ -DR4000 -D$wcetgt";
+                                $wcecdefs.=" -D_MIPS64 -QMmips4 -QMn32";
+                                $wcelflag.=" /machine:MIPSFPU"; last; };
+          /^MIPS16/     && do { $wcecdefs.=" -DMIPS -D_MIPS_ -DR4000 -D$wcetgt";
+                                $wcecdefs.=" -DMIPSII -QMmips16";
+                                $wcelflag.=" /machine:MIPS16";  last; };
+          /^MIPSII/     && do { $wcecdefs.=" -DMIPS -D_MIPS_ -DR4000 -D$wcetgt";
+                                $wcecdefs.=" -QMmips2";
+                                $wcelflag.=" /machine:MIPS";    last; };
+          /^R4[0-9]{3}/ && do { $wcecdefs.=" -DMIPS -D_MIPS_ -DR4000";
+                                $wcelflag.=" /machine:MIPS";    last; };
+          /^SH[0-9]/    && do { $wcecdefs.=" -D$wcetgt -D_${wcetgt}_ -DSHx";
+                                $wcecdefs.=" -Qsh4" if ($wcetgt =~ /^SH4/);
+                                $wcelflag.=" /machine:$wcetgt"; last; };
+          { $wcecdefs.=" -D$wcetgt -D_${wcetgt}_";
+            $wcelflag.=" /machine:$wcetgt";                     last; };
+      }
+
+        $vc_wince_info = { cflags => $wcecdefs,
+                           lflags => $wcelflag };
+    }
+    return $vc_wince_info;
+}
+
+
 %targets = (
 
 #### Basic configs that should work on any 32-bit box
@@ -14,13 +97,13 @@ sub picker {
         cc               => "gcc",
         cflags           => picker(debug   => "-O0 -g",
                                    release => "-O3"),
-        thread_cflag     => "(unknown)",
+        thread_scheme    => "(unknown)",
         bn_ops           => "BN_LLONG",
     },
     "cc" => {
         cc               => "cc",
         cflags           => "-O",
-        thread_cflag     => "(unknown)",
+        thread_scheme    => "(unknown)",
     },
 
 #### VOS Configurations
@@ -30,7 +113,7 @@ sub picker {
         cflags           => picker(default => "-Wall -DOPENSSL_SYS_VOS -D_POSIX_C_SOURCE=200112L -D_BSD -D_VOS_EXTENDED_NAMES -DB_ENDIAN",
                                    debug   => "-O0 -g -DBN_DEBUG -DREF_DEBUG -DCONF_DEBUG",
                                    release => "-O3"),
-        thread_cflag     => "(unknown)",
+        thread_scheme    => "(unknown)",
         sys_id           => "VOS",
         lflags           => "-Wl,-map",
         bn_ops           => "BN_LLONG",
@@ -44,6 +127,7 @@ sub picker {
         cflags           => "-DFILIO_H",
         ex_libs          => add("-lresolv -lsocket -lnsl -ldl"),
         dso_scheme       => "dlfcn",
+        thread_scheme    => "pthreads",
         shared_target    => "solaris-shared",
         shared_extension => ".so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
     },
@@ -58,8 +142,8 @@ sub picker {
         cc               => "gcc",
         cflags           => add_before(picker(default => "-Wall -DL_ENDIAN -DOPENSSL_NO_INLINE_ASM",
                                               debug   => "-O0 -g",
-                                              release => "-O3 -fomit-frame-pointer")),
-        thread_cflag     => "-pthread",
+                                              release => "-O3 -fomit-frame-pointer"),
+                                       threads("-pthread")),
         bn_ops           => "BN_LLONG",
         shared_cflag     => "-fPIC",
         shared_ldflag    => "-shared",
@@ -77,8 +161,8 @@ sub picker {
         cc               => "gcc",
         cflags           => add_before(picker(default => "-m64 -Wall -DL_ENDIAN",
                                               debug   => "-O0 -g",
-                                              release => "-O3")),
-        thread_cflag     => "-pthread",
+                                              release => "-O3"),
+                                       threads("-pthread")),
         bn_ops           => "SIXTY_FOUR_BIT_LONG",
         perlasm_scheme   => "elf",
         shared_cflag     => "-fPIC",
@@ -92,10 +176,10 @@ sub picker {
         cc               => "cc",
         cflags           => add_before(picker(default => "-xarch=generic -xstrconst -Xa -DL_ENDIAN",
                                               debug   => "-g",
-                                              release => "-xO5 -xregs=frameptr -xdepend -xbuiltin")),
-        thread_cflag     => "-D_REENTRANT",
-        lflags           => add("-mt"),
-        ex_libs          => add("-lpthread"),
+                                              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",
@@ -105,10 +189,11 @@ sub picker {
         cc               => "cc",
         cflags           => add_before(picker(default => "-xarch=generic64 -xstrconst -Xa -DL_ENDIAN",
                                               debug   => "-g",
-                                              release => "-xO5 -xdepend -xbuiltin")),
-        thread_cflag     => "-D_REENTRANT",
-        lflags           => add("-mt"),
-        ex_libs          => add("-lpthread"),
+                                              release => "-xO5 -xdepend -xbuiltin"),
+                                       threads("-D_REENTRANT")),
+        thread_scheme    => "pthreads",
+        lflags           => add(threads("-mt")),
+        ex_libs          => add(threads("-lpthread")),
         bn_ops           => "SIXTY_FOUR_BIT_LONG",
         perlasm_scheme   => "elf",
         shared_cflag     => "-KPIC",
@@ -122,8 +207,8 @@ sub picker {
         cc               => "gcc",
         cflags           => add_before(picker(default => "-Wall -DB_ENDIAN -DBN_DIV2W",
                                               debug   => "-O0 -g",
-                                              release => "-O3")),
-        thread_cflag     => "-pthread",
+                                              release => "-O3"),
+                                       threads("-pthread")),
         bn_ops           => "BN_LLONG RC4_CHAR",
         shared_cflag     => "-fPIC",
         shared_ldflag    => "-shared",
@@ -156,10 +241,10 @@ sub picker {
         cc               => "cc",
         cflags           => add_before(picker(default => "-xstrconst -Xa -DB_ENDIAN -DBN_DIV2W",
                                               debug   => "-g -DBN_DEBUG -DREF_DEBUG -DCONF_DEBUG -DBN_CTX_DEBUG",
-                                              release => "-xO5 -xdepend")),
-        thread_cflag     => "-D_REENTRANT",
-        lflags           => add("-mt"),
-        ex_libs          => add("-lpthread"),
+                                              release => "-xO5 -xdepend"),
+                                       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",
@@ -189,8 +274,8 @@ sub picker {
         cflags           => picker(default => "-DB_ENDIAN",
                                    debug   => "-g -O0",
                                    release => "-O3"),
-        thread_cflag     => "(unknown)",
         bn_ops           => "BN_LLONG RC4_CHAR",
+        thread_scheme    => "(unknown)",
         perlasm_scheme   => "o32",
         dso_scheme       => "dlfcn",
         shared_target    => "irix-shared",
@@ -202,8 +287,8 @@ sub picker {
         cflags           => picker(default => "-use_readonly_const -DB_ENDIAN",
                                    debug   => "-g -O0",
                                    release => "-O2"),
-        thread_cflag     => "(unknown)",
         bn_ops           => "BN_LLONG RC4_CHAR",
+        thread_scheme    => "(unknown)",
         perlasm_scheme   => "o32",
         dso_scheme       => "dlfcn",
         shared_target    => "irix-shared",
@@ -215,11 +300,12 @@ sub picker {
     "irix-mips3-gcc" => {
         inherit_from     => [ "BASE_unix", asm("mips64_asm") ],
         cc               => "gcc",
-        cflags           => picker(default => "-mabi=n32 -DB_ENDIAN -DBN_DIV3W",
-                                   debug   => "-g -O0",
-                                   release => "-O3"),
-        thread_cflag     => "-D_SGI_MP_SOURCE -pthread",
+        cflags           => combine(picker(default => "-mabi=n32 -DB_ENDIAN -DBN_DIV3W",
+                                           debug   => "-g -O0",
+                                           release => "-O3"),
+                                    threads("-D_SGI_MP_SOURCE -pthread")),
         bn_ops           => "RC4_CHAR SIXTY_FOUR_BIT",
+        thread_scheme    => "pthreads",
         perlasm_scheme   => "n32",
         dso_scheme       => "dlfcn",
         shared_target    => "irix-shared",
@@ -230,12 +316,13 @@ sub picker {
     "irix-mips3-cc" => {
         inherit_from     => [ "BASE_unix", asm("mips64_asm") ],
         cc               => "cc",
-        cflags           => picker(default => "-n32 -mips3 -use_readonly_const -G0 -rdata_shared -DB_ENDIAN -DBN_DIV3W",
-                                   debug   => "-g -O0",
-                                   release => "-O2"),
-        thread_cflag     => "-D_SGI_MP_SOURCE",
-        ex_libs          => add("-lpthread"),
+        cflags           => combine(picker(default => "-n32 -mips3 -use_readonly_const -G0 -rdata_shared -DB_ENDIAN -DBN_DIV3W",
+                                           debug   => "-g -O0",
+                                           release => "-O2"),
+                                    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",
@@ -247,11 +334,12 @@ sub picker {
     "irix64-mips4-gcc" => {
         inherit_from     => [ "BASE_unix", asm("mips64_asm") ],
         cc               => "gcc",
-        cflags           => picker(default => "-mabi=64 -mips4 -DB_ENDIAN -DBN_DIV3W",
-                                   debug   => "-g -O0",
-                                   release => "-O3"),
-        thread_cflag     => "-D_SGI_MP_SOURCE",
+        cflags           => combine(picker(default => "-mabi=64 -mips4 -DB_ENDIAN -DBN_DIV3W",
+                                           debug   => "-g -O0",
+                                           release => "-O3"),
+                                    threads("-D_SGI_MP_SOURCE")),
         bn_ops           => "RC4_CHAR SIXTY_FOUR_BIT_LONG",
+        thread_scheme    => "pthreads",
         perlasm_scheme   => "64",
         dso_scheme       => "dlfcn",
         shared_target    => "irix-shared",
@@ -262,12 +350,13 @@ sub picker {
     "irix64-mips4-cc" => {
         inherit_from     => [ "BASE_unix", asm("mips64_asm") ],
         cc               => "cc",
-        cflags           => picker(default => "-64 -mips4 -use_readonly_const -G0 -rdata_shared -DB_ENDIAN -DBN_DIV3W",
-                                   debug   => "-g -O0",
-                                   release => "-O2"),
-        thread_cflag     => "-D_SGI_MP_SOURCE",
-        ex_libs          => add("-lpthread"),
+        cflags           => combine(picker(default => "-64 -mips4 -use_readonly_const -G0 -rdata_shared -DB_ENDIAN -DBN_DIV3W",
+                                           debug   => "-g -O0",
+                                           release => "-O2"),
+                                    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",
@@ -307,12 +396,13 @@ sub picker {
     "hpux-parisc-gcc" => {
         inherit_from     => [ "BASE_unix" ],
         cc               => "gcc",
-        cflags           => picker(default => "-DB_ENDIAN -DBN_DIV2W",
-                                   debug   => "-O0 -g",
-                                   release => "-O3"),
-        thread_cflag     => "-pthread",
+        cflags           => combine(picker(default => "-DB_ENDIAN -DBN_DIV2W",
+                                           debug   => "-O0 -g",
+                                           release => "-O3"),
+                                    threads("-pthread")),
         ex_libs          => add("-Wl,+s -ldld"),
         bn_ops           => "BN_LLONG",
+        thread_scheme    => "pthreads",
         dso_scheme       => "dl",
         shared_target    => "hpux-shared",
         shared_cflag     => "-fPIC",
@@ -326,12 +416,13 @@ sub picker {
     "hpux64-parisc2-gcc" => {
         inherit_from     => [ "BASE_unix", asm("parisc20_64_asm") ],
         cc               => "gcc",
-        cflags           => picker(default => "-DB_ENDIAN",
-                                   debug   => "-O0 -g",
-                                   release => "-O3"),
-        thread_cflag     => "-D_REENTRANT",
+        cflags           => combine(picker(default => "-DB_ENDIAN",
+                                           debug   => "-O0 -g",
+                                           release => "-O3"),
+                                    threads("-D_REENTRANT")),
         ex_libs          => add("-ldl"),
         bn_ops           => "SIXTY_FOUR_BIT_LONG RC4_CHAR",
+        thread_scheme    => "pthreads",
         dso_scheme       => "dlfcn",
         shared_target    => "hpux-shared",
         shared_cflag     => "-fpic",
@@ -347,12 +438,13 @@ sub picker {
     "hpux-parisc-cc" => {
         inherit_from     => [ "BASE_unix" ],
         cc               => "cc",
-        cflags           => picker(default => "+Optrs_strongly_typed -Ae +ESlit -DB_ENDIAN -DBN_DIV2W -DMD32_XARRAY",
-                                   debug   => "+O0 +d -g",
-                                   release => "+O3"),
-        thread_cflag     => "-D_REENTRANT",
-        ex_libs          => add("-Wl,+s -ldld -lpthread"),
+        cflags           => combine(picker(default => "+Optrs_strongly_typed -Ae +ESlit -DB_ENDIAN -DBN_DIV2W -DMD32_XARRAY",
+                                           debug   => "+O0 +d -g",
+                                           release => "+O3"),
+                                    threads("-D_REENTRANT")),
+        ex_libs          => add("-Wl,+s -ldld",threads("-lpthread")),
         bn_ops           => "RC4_CHAR",
+        thread_scheme    => "pthreads",
         dso_scheme       => "dl",
         shared_target    => "hpux-shared",
         shared_cflag     => "+Z",
@@ -367,12 +459,13 @@ sub picker {
     "hpux64-parisc2-cc" => {
         inherit_from     => [ "BASE_unix", asm("parisc20_64_asm") ],
         cc               => "cc",
-        cflags           => picker(default => "+DD64 +Optrs_strongly_typed -Ae +ESlit -DB_ENDIAN -DMD32_XARRAY",
-                                   debug   => "+O0 +d -g",
-                                   release => "+O3"),
-        thread_cflag     => "-D_REENTRANT",
-        ex_libs          => add("-ldl -lpthread"),
+        cflags           => combine(picker(default => "+DD64 +Optrs_strongly_typed -Ae +ESlit -DB_ENDIAN -DMD32_XARRAY",
+                                           debug   => "+O0 +d -g",
+                                           release => "+O3"),
+                                    threads("-D_REENTRANT")),
+        ex_libs          => add("-ldl",threads("-lpthread")),
         bn_ops           => "SIXTY_FOUR_BIT_LONG RC4_CHAR",
+        thread_scheme    => "pthreads",
         dso_scheme       => "dlfcn",
         shared_target    => "hpux-shared",
         shared_cflag     => "+Z",
@@ -385,12 +478,13 @@ sub picker {
     "hpux-ia64-cc" => {
         inherit_from     => [ "BASE_unix", asm("ia64_asm") ],
         cc               => "cc",
-        cflags           => picker(default => "-Ae +DD32 +Olit=all -z -DB_ENDIAN",
-                                   debug   => "+O0 +d -g",
-                                   release => "+O2"),
-        thread_cflag     => "-D_REENTRANT",
-        ex_libs          => add("-ldl -lpthread"),
+        cflags           => combine(picker(default => "-Ae +DD32 +Olit=all -z -DB_ENDIAN",
+                                           debug   => "+O0 +d -g",
+                                           release => "+O2"),
+                                    threads("-D_REENTRANT")),
+        ex_libs          => add("-ldl",threads("-lpthread")),
         bn_ops           => "SIXTY_FOUR_BIT",
+        thread_scheme    => "pthreads",
         dso_scheme       => "dlfcn",
         shared_target    => "hpux-shared",
         shared_cflag     => "+Z",
@@ -403,12 +497,13 @@ sub picker {
     "hpux64-ia64-cc" => {
         inherit_from     => [ "BASE_unix", asm("ia64_asm") ],
         cc               => "cc",
-        cflags           => picker(default => "-Ae +DD64 +Olit=all -z -DB_ENDIAN",
-                                   debug   => "+O0 +d -g",
-                                   release => "+O3"),
-        thread_cflag     => "-D_REENTRANT",
-        ex_libs          => add("-ldl -lpthread"),
+        cflags           => combine(picker(default => "-Ae +DD64 +Olit=all -z -DB_ENDIAN",
+                                           debug   => "+O0 +d -g",
+                                           release => "+O3"),
+                                    threads("-D_REENTRANT")),
+        ex_libs          => add("-ldl", threads("-lpthread")),
         bn_ops           => "SIXTY_FOUR_BIT_LONG",
+        thread_scheme    => "pthreads",
         dso_scheme       => "dlfcn",
         shared_target    => "hpux-shared",
         shared_cflag     => "+Z",
@@ -420,12 +515,13 @@ sub picker {
     "hpux-ia64-gcc" => {
         inherit_from     => [ "BASE_unix", asm("ia64_asm") ],
         cc               => "gcc",
-        cflags           => picker(default => "-DB_ENDIAN",
-                                   debug   => "-O0 -g",
-                                   release => "-O3"),
-        thread_cflag     => "-pthread",
+        cflags           => combine(picker(default => "-DB_ENDIAN",
+                                           debug   => "-O0 -g",
+                                           release => "-O3"),
+                                    threads("-pthread")),
         ex_libs          => add("-ldl"),
         bn_ops           => "SIXTY_FOUR_BIT",
+        thread_scheme    => "pthreads",
         dso_scheme       => "dlfcn",
         shared_target    => "hpux-shared",
         shared_cflag     => "-fpic",
@@ -438,10 +534,11 @@ sub picker {
         cc               => "gcc",
         cflags           => picker(default => "-mlp64 -DB_ENDIAN",
                                    debug   => "-O0 -g",
-                                   release => "-O3"),
-        thread_cflag     => "-pthread",
+                                   release => "-O3",
+                                   threads("-pthread")),
         ex_libs          => add("-ldl"),
         bn_ops           => "SIXTY_FOUR_BIT_LONG",
+        thread_scheme    => "pthreads",
         dso_scheme       => "dlfcn",
         shared_target    => "hpux-shared",
         shared_cflag     => "-fpic",
@@ -455,9 +552,9 @@ sub picker {
         inherit_from     => [ "BASE_unix" ],
         cc               => "gcc",
         cflags           => "-D_ENDIAN -DBN_DIV2W -O3 -D_POSIX_SOURCE -D_SOCKET_SOURCE -I/SYSLOG/PUB",
-        thread_cflag     => "(unknown)",
         sys_id           => "MPE",
         ex_libs          => add("-L/SYSLOG/PUB -lsyslog -lsocket -lcurses"),
+        thread_scheme    => "(unknown)",
         bn_ops           => "BN_LLONG",
     },
 
@@ -466,8 +563,8 @@ sub picker {
         inherit_from     => [ "BASE_unix", asm("alpha_asm") ],
         cc               => "gcc",
         cflags           => "-O3",
-        thread_cflag     => "(unknown)",
         bn_ops           => "SIXTY_FOUR_BIT_LONG",
+        thread_scheme    => "(unknown)",
         dso_scheme       => "dlfcn",
         shared_target    => "alpha-osf1-shared",
         shared_extension => ".so",
@@ -476,8 +573,8 @@ sub picker {
         inherit_from     => [ "BASE_unix", asm("alpha_asm") ],
         cc               => "cc",
         cflags           => "-std1 -tune host -O4 -readonly_strings",
-        thread_cflag     => "(unknown)",
         bn_ops           => "SIXTY_FOUR_BIT_LONG",
+        thread_scheme    => "(unknown)",
         dso_scheme       => "dlfcn",
         shared_target    => "alpha-osf1-shared",
         shared_extension => ".so",
@@ -485,9 +582,10 @@ sub picker {
     "tru64-alpha-cc" => {
         inherit_from     => [ "BASE_unix", asm("alpha_asm") ],
         cc               => "cc",
-        cflags           => "-std1 -tune host -fast -readonly_strings",
-        thread_cflag     => "-pthread",
+        cflags           => combine("-std1 -tune host -fast -readonly_strings",
+                                    threads("-pthread")),
         bn_ops           => "SIXTY_FOUR_BIT_LONG",
+        thread_scheme    => "pthreads",
         dso_scheme       => "dlfcn",
         shared_target    => "alpha-osf1-shared",
         shared_ldflag    => "-msym",
@@ -502,12 +600,13 @@ sub picker {
     "linux-generic32" => {
         inherit_from     => [ "BASE_unix" ],
         cc               => "gcc",
-        cflags           => picker(default => "-Wall",
-                                   debug   => "-O0 -g -DBN_DEBUG -DREF_DEBUG -DCONF_DEBUG",
-                                   release => "-O3"),
-        thread_cflag     => "-pthread",
+        cflags           => combine(picker(default => "-Wall",
+                                           debug   => "-O0 -g -DBN_DEBUG -DREF_DEBUG -DCONF_DEBUG",
+                                           release => "-O3"),
+                                    threads("-pthread")),
         ex_libs          => add("-ldl"),
         bn_ops           => "BN_LLONG RC4_CHAR",
+        thread_scheme    => "pthreads",
         dso_scheme       => "dlfcn",
         shared_target    => "linux-shared",
         shared_cflag     => "-fPIC",
@@ -623,8 +722,8 @@ sub picker {
         cflags           => add(picker(default => "-DL_ENDIAN -Wall",
                                        debug   => "-O0 -g",
                                        release => "-O3 -fomit-frame-pointer")),
-        thread_cflag     => "(unknown)",
         bn_ops           => "BN_LLONG",
+        thread_scheme    => "(unknown)",
         perlasm_scheme   => "a.out",
     },
 
@@ -719,8 +818,8 @@ sub picker {
         inherit_from     => [ "BASE_unix" ],
         # TI_CGT_C6000_7.3.x is a requirement
         cc               => "cl6x",
-        cflags           => "--linux -ea=.s -eo=.o -mv6400+ -o2 -ox -ms -pden -DOPENSSL_SMALL_FOOTPRINT",
-        thread_cflag     => "-D_REENTRANT",
+        cflags           => combine("--linux -ea=.s -eo=.o -mv6400+ -o2 -ox -ms -pden -DOPENSSL_SMALL_FOOTPRINT",
+                                    threads("-D_REENTRANT")),
         bn_ops           => "BN_LLONG",
         cpuid_asm_src    => "c64xpluscpuid.s",
         bn_asm_src       => "asm/bn-c64xplus.asm c64xplus-gf2m.s",
@@ -730,6 +829,7 @@ sub picker {
         modes_asm_src    => "ghash-c64xplus.s",
         chacha_asm_src   => "chacha-c64xplus.s",
         poly1305_asm_src => "poly1305-c64xplus.s",
+        thread_scheme    => "pthreads",
         perlasm_scheme   => "void",
         dso_scheme       => "dlfcn",
         shared_target    => "linux-shared",
@@ -821,7 +921,7 @@ sub picker {
 
 #### *BSD
     "BSD-generic32" => {
-        # As for thread_cflag. Idea is to maintain "collective" set of
+        # As for thread cflag. Idea is to maintain "collective" set of
         # flags, which would cover all BSD flavors. -pthread applies
         # to them all, but is treated differently. OpenBSD expands is
         # as -D_POSIX_THREAD -lc_r, which is sufficient. FreeBSD 4.x
@@ -830,11 +930,12 @@ sub picker {
         # expands it as -lc_r, which seems to be sufficient?
         inherit_from     => [ "BASE_unix" ],
         cc               => "cc",
-        cflags           => picker(default => "-Wall",
-                                   debug   => "-O0 -g",
-                                   release => "-O3"),
-        thread_cflag     => "-pthread -D_THREAD_SAFE -D_REENTRANT",
+        cflags           => combine(picker(default => "-Wall",
+                                           debug   => "-O0 -g",
+                                           release => "-O3"),
+                                    threads("-pthread -D_THREAD_SAFE -D_REENTRANT")),
         bn_ops           => "BN_LLONG",
+        thread_scheme    => "pthreads",
         dso_scheme       => "dlfcn",
         shared_target    => "bsd-gcc-shared",
         shared_cflag     => "-fPIC",
@@ -888,9 +989,9 @@ sub picker {
         inherit_from     => [ "BASE_unix", asm("x86_elf_asm") ],
         cc               => "gcc",
         cflags           => "-DPERL5 -DL_ENDIAN -fomit-frame-pointer -O3 -Wall",
-        thread_cflag     => "(unknown)",
         ex_libs          => add("-ldl"),
         bn_ops           => "BN_LLONG",
+        thread_scheme    => "(unknown)",
         dso_scheme       => "dlfcn",
         shared_target    => "bsd-gcc-shared",
         shared_cflag     => "-fPIC",
@@ -902,16 +1003,16 @@ sub picker {
         cc               => "cc",
         cflags           => "-O -Wall",
         unistd           => "<libc.h>",
-        thread_cflag     => "(unknown)",
         bn_ops           => "BN_LLONG",
+        thread_scheme    => "(unknown)",
     },
     "nextstep3.3" => {
         inherit_from     => [ "BASE_unix" ],
         cc               => "cc",
         cflags           => "-O3 -Wall",
         unistd           => "<libc.h>",
-        thread_cflag     => "(unknown)",
         bn_ops           => "BN_LLONG",
+        thread_scheme    => "(unknown)",
     },
 
 # QNX
@@ -919,7 +1020,7 @@ sub picker {
         inherit_from     => [ "BASE_unix" ],
         cc               => "cc",
         cflags           => "-DL_ENDIAN -DTERMIO",
-        thread_cflag     => "(unknown)",
+        thread_scheme    => "(unknown)",
     },
     "QNX6" => {
         inherit_from     => [ "BASE_unix" ],
@@ -956,23 +1057,26 @@ sub picker {
     "unixware-2.0" => {
         inherit_from     => [ "BASE_unix" ],
         cc               => "cc",
-        cflags           => "-DFILIO_H -DNO_STRINGS_H",
-        thread_cflag     => "-Kthread",
+        cflags           => combine("-DFILIO_H -DNO_STRINGS_H",
+                                    threads("-Kthread")),
         ex_libs          => add("-lsocket -lnsl -lresolv -lx"),
+        thread_scheme    => "uithreads",
     },
     "unixware-2.1" => {
         inherit_from     => [ "BASE_unix" ],
         cc               => "cc",
-        cflags           => "-O -DFILIO_H",
-        thread_cflag     => "-Kthread",
+        cflags           => combine("-O -DFILIO_H",
+                                    threads("-Kthread")),
         ex_libs          => add("-lsocket -lnsl -lresolv -lx"),
+        thread_scheme    => "uithreads",
     },
     "unixware-7" => {
         inherit_from     => [ "BASE_unix", asm("x86_elf_asm") ],
         cc               => "cc",
-        cflags           => "-O -DFILIO_H -Kalloca",
-        thread_cflag     => "-Kthread",
+        cflags           => combine("-O -DFILIO_H -Kalloca",
+                                    threads("-Kthread")),
         ex_libs          => add("-lsocket -lnsl"),
+        thread_scheme    => "uithreads",
         bn_ops           => "BN_LLONG",
         perlasm_scheme   => "elf-1",
         dso_scheme       => "dlfcn",
@@ -983,10 +1087,11 @@ sub picker {
     "unixware-7-gcc" => {
         inherit_from     => [ "BASE_unix", asm("x86_elf_asm") ],
         cc               => "gcc",
-        cflags           => "-DL_ENDIAN -DFILIO_H -O3 -fomit-frame-pointer -Wall",
-        thread_cflag     => "-D_REENTRANT",
+        cflags           => combine("-DL_ENDIAN -DFILIO_H -O3 -fomit-frame-pointer -Wall",
+                                    threads("-D_REENTRANT")),
         ex_libs          => add("-lsocket -lnsl"),
         bn_ops           => "BN_LLONG",
+        thread_scheme    => "pthreads",
         perlasm_scheme   => "elf-1",
         dso_scheme       => "dlfcn",
         shared_target    => "gnu-shared",
@@ -998,8 +1103,8 @@ sub picker {
         inherit_from     => [ "BASE_unix", asm("x86_elf_asm") ],
         cc               => "cc",
         cflags           => "-belf",
-        thread_cflag     => "(unknown)",
         ex_libs          => add("-lsocket -lnsl"),
+        thread_scheme    => "(unknown)",
         perlasm_scheme   => "elf-1",
         dso_scheme       => "dlfcn",
         shared_target    => "svr3-shared",
@@ -1010,9 +1115,9 @@ sub picker {
         inherit_from     => [ "BASE_unix", asm("x86_elf_asm") ],
         cc               => "gcc",
         cflags           => "-O3 -fomit-frame-pointer",
-        thread_cflag     => "(unknown)",
         ex_libs          => add("-lsocket -lnsl"),
         bn_ops           => "BN_LLONG",
+        thread_scheme    => "(unknown)",
         perlasm_scheme   => "elf-1",
         dso_scheme       => "dlfcn",
         shared_target    => "svr3-shared",
@@ -1024,12 +1129,13 @@ sub picker {
     "aix-gcc" => {
         inherit_from     => [ "BASE_unix", asm("ppc32_asm") ],
         cc               => "gcc",
-        cflags           => picker(default => "-DB_ENDIAN",
-                                   debug   => "-O0 -g",
-                                   release => "-O"),
-        thread_cflag     => "-pthread",
+        cflags           => combine(picker(default => "-DB_ENDIAN",
+                                           debug   => "-O0 -g",
+                                           release => "-O"),
+                                    threads("-pthread")),
         sys_id           => "AIX",
         bn_ops           => "BN_LLONG RC4_CHAR",
+        thread_scheme    => "pthreads",
         perlasm_scheme   => "aix32",
         dso_scheme       => "dlfcn",
         shared_target    => "aix-shared",
@@ -1040,12 +1146,13 @@ sub picker {
     "aix64-gcc" => {
         inherit_from     => [ "BASE_unix", asm("ppc64_asm") ],
         cc               => "gcc",
-        cflags           => picker(default => "-maix64 -DB_ENDIAN",
-                                   debug   => "-O0 -g",
-                                   release => "-O"),
-        thread_cflag     => "-pthread",
+        cflags           => combine(picker(default => "-maix64 -DB_ENDIAN",
+                                           debug   => "-O0 -g",
+                                           release => "-O"),
+                                    threads("-pthread")),
         sys_id           => "AIX",
         bn_ops           => "SIXTY_FOUR_BIT_LONG RC4_CHAR",
+        thread_scheme    => "pthreads",
         perlasm_scheme   => "aix64",
         dso_scheme       => "dlfcn",
         shared_target    => "aix-shared",
@@ -1059,12 +1166,13 @@ sub picker {
     "aix-cc" => {
         inherit_from     => [ "BASE_unix", asm("ppc32_asm") ],
         cc               => "cc",
-        cflags           => picker(default => "-q32 -DB_ENDIAN -qmaxmem=16384 -qro -qroconst",
-                                   debug   => "-O0 -g",
-                                   release => "-O"),
-        thread_cflag     => "-qthreaded -D_THREAD_SAFE",
+        cflags           => combine(picker(default => "-q32 -DB_ENDIAN -qmaxmem=16384 -qro -qroconst",
+                                           debug   => "-O0 -g",
+                                           release => "-O"),
+                                    threads("-qthreaded -D_THREAD_SAFE")),
         sys_id           => "AIX",
         bn_ops           => "BN_LLONG RC4_CHAR",
+        thread_scheme    => "pthreads",
         perlasm_scheme   => "aix32",
         dso_scheme       => "dlfcn",
         shared_target    => "aix-shared",
@@ -1075,12 +1183,13 @@ sub picker {
     "aix64-cc" => {
         inherit_from     => [ "BASE_unix", asm("ppc64_asm") ],
         cc               => "cc",
-        cflags           => picker(default => "-q64 -DB_ENDIAN -qmaxmem=16384 -qro -qroconst",
-                                   debug   => "-O0 -g",
-                                   release => "-O"),
-        thread_cflag     => "-qthreaded -D_THREAD_SAFE",
+        cflags           => combine(picker(default => "-q64 -DB_ENDIAN -qmaxmem=16384 -qro -qroconst",
+                                           debug   => "-O0 -g",
+                                           release => "-O"),
+                                    threads("-qthreaded -D_THREAD_SAFE")),
         sys_id           => "AIX",
         bn_ops           => "SIXTY_FOUR_BIT_LONG RC4_CHAR",
+        thread_scheme    => "pthreads",
         perlasm_scheme   => "aix64",
         dso_scheme       => "dlfcn",
         shared_target    => "aix-shared",
@@ -1094,9 +1203,9 @@ sub picker {
         inherit_from     => [ "BASE_unix" ],
         cc               => "c89",
         cflags           => "-O -XLLML -XLLMK -XL -DB_ENDIAN -DCHARSET_EBCDIC",
-        thread_cflag     => "(unknown)",
         ex_libs          => add("-lsocket -lnsl"),
         bn_ops           => "THIRTY_TWO_BIT RC4_CHAR",
+        thread_scheme    => "(unknown)",
     },
 
 # OS/390 Unix an EBCDIC-based Unix system on IBM mainframe
@@ -1107,8 +1216,8 @@ sub picker {
         inherit_from     => [ "BASE_unix" ],
         cc               => "c89.sh",
         cflags           => "-O -DB_ENDIAN -DCHARSET_EBCDIC -DNO_SYS_PARAM_H  -D_ALL_SOURCE",
-        thread_cflag     => "(unknown)",
         bn_ops           => "THIRTY_TWO_BIT RC4_CHAR",
+        thread_scheme    => "(unknown)",
     },
 
 #### Visual C targets
@@ -1119,73 +1228,167 @@ sub picker {
 # positives in some situations. Disabling it altogether masks both
 # legitimate and false cases, but as we compile on multiple platforms,
 # we rely on other compilers to catch legitimate cases.
+#
+# Also note that we force threads no matter what.  Configuring "no-threads"
+# is ignored.
     "VC-common" => {
         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",
+        coutflag         => "/Fo",
+        lib_cflags       => "/Zl /Zi /Fdlib",
+        dso_cflags       => "/Zi",
+        bin_cflags       => "/Zi /Fdapp",
+        lflags           => add("/debug"),
+        shared_cflag     => "-D_WINDLL",
+        shared_ldflag    => "/dll",
         shared_target    => "win-shared", # meaningless except it gives Configure a hint
+        thread_scheme    => "winthreads",
         dso_scheme       => "win32",
     },
+    "VC-noCE-common" => {
+        inherit_from     => [ "VC-common", "uplink_common" ],
+        cflags           => add(picker(default => "-DUNICODE -D_UNICODE",
+                                       debug   =>
+                                       sub {
+                                           ($disabled{shared} ? "/MT" : "/MD")
+                                               ."d /Od -DDEBUG -D_DEBUG";
+                                       },
+                                       release =>
+                                       sub {
+                                           ($disabled{shared} ? "/MT" : "/MD")
+                                               ." /Ox /O2 /Ob2";
+                                       })),
+        bin_lflags       => add("/subsystem:console /opt:ref"),
+        ex_libs          => 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 {
+            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 }),
+    },
     "VC-WIN64I" => {
-        inherit_from     => [ "VC-common", asm("ia64_asm") ],
-        cflags           => add("-DUNICODE -D_UNICODE"),
+        inherit_from     => [ "VC-WIN64-common", asm("ia64_asm") ],
+        as               => "ias",
+        asflags          => "-d debug",
+        asoutflag        => "-o",
         sys_id           => "WIN64I",
-        bn_ops           => "SIXTY_FOUR_BIT EXPORT_VAR_AS_FN",
-        bn_obj           => sub { my $r=join(" ",@_); $r=~s/bn\-//; $r; },
-        rc4_obj          => "",
+        rc4_asm_src      => "",
         perlasm_scheme   => "ias",
-        build_scheme     => add("VC-W64", { separator => undef }),
     },
     "VC-WIN64A" => {
-        inherit_from     => [ "VC-common", asm("x86_64_asm") ],
-        cflags           => add("-DUNICODE -D_UNICODE"),
+        inherit_from     => [ "VC-WIN64-common", asm("x86_64_asm") ],
+        as               => sub { vc_win64a_info()->{as} },
+        asflags          => sub { vc_win64a_info()->{asflags} },
+        asoutflag        => sub { vc_win64a_info()->{asoutflag} },
         sys_id           => "WIN64A",
-        bn_ops           => "SIXTY_FOUR_BIT EXPORT_VAR_AS_FN",
-        bn_obj           => sub { my $r=join(" ",@_); $r=~s/x86_64\-gcc/bn_asm/; $r; },
+        bn_asm_src       => sub { return undef unless @_;
+                                  my $r=join(" ",@_); $r=~s|asm/x86_64-gcc|bn_asm|; $r; },
         perlasm_scheme   => "auto",
-        build_scheme     => add("VC-W64", { separator => undef }),
     },
     "VC-WIN32" => {
         # x86 Win32 target defaults to ANSI API, if you want UNICODE,
         # configure with 'perl Configure VC-WIN32 -DUNICODE -D_UNICODE'
-        inherit_from     => [ "VC-common", asm("x86_asm") ],
+        inherit_from     => [ "VC-noCE-common", asm("x86_asm") ],
+        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 {
+            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",
         build_scheme     => add("VC-W32", { separator => undef }),
     },
     "VC-CE" => {
-        inherit_from     => [ "BASE_Windows" ],
+        inherit_from     => [ "VC-common" ],
+        as               => "ml",
+        asflags          => "/nologo /Cp /coff /c /Cx /Zi",
+        asoutflag        => "/Fo",
         cc               => "cl",
+        cflags           =>
+            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'})
+                                     ? '-I$(WCECOMPAT)/include' : (); },
+                           sub { defined($ENV{'PORTSDK_LIBPATH'})
+                                     ? '-I$(PORTSDK_LIBPATH)/../../include' : (); },
+                           sub { `cl 2>&1` =~ /Version ([0-9]+)\./ && $1>=14
+                                     ? ($disabled{shared} ? " /MT" : " /MD")
+                                     : " /MC"; }),
+                   debug   => "/Od -DDEBUG -D_DEBUG",
+                   release => "/O1i"),
+        lflags           => combine("/nologo /opt:ref",
+                                    sub { vc_wince_info()->{lflags}; },
+                                    sub { defined($ENV{PORTSDK_LIBPATH})
+                                              ? "/entry:mainCRTstartup" : (); }),
         sys_id           => "WINCE",
         bn_ops           => "BN_LLONG EXPORT_VAR_AS_FN",
-        dso_scheme       => "win32",
+        ex_libs          => sub {
+            my @ex_libs = ();
+            push @ex_libs, 'ws2.lib' unless $disabled{sock};
+            push @ex_libs, 'crypt32.lib';
+            if (defined($ENV{WCECOMPAT})) {
+                my $x = '$(WCECOMPAT)/lib';
+                if (-f "$x/$ENV{TARGETCPU}/wcecompatex.lib") {
+                    $x .= '/$(TARGETCPU)/wcecompatex.lib';
+                } else {
+                    $x .= '/wcecompatex.lib';
+                }
+                push @ex_libs, $x;
+            }
+            push @ex_libs, '$(PORTSDK_LIBPATH)/portlib.lib'
+                if (defined($ENV{'PORTSDK_LIBPATH'}));
+            push @ex_libs, ' /nodefaultlib coredll.lib corelibc.lib'
+                if ($ENV{'TARGETCPU'} eq "X86");
+            return @ex_libs;
+        },
         build_scheme     => add("VC-WCE", { separator => undef }),
     },
 
-#### Borland C++ 4.5
-    "BC-32" => {
-        inherit_from     => [ "BASE_Windows" ],
-        cc               => "bcc32",
-        sys_id           => "WIN32",
-        bn_ops           => "BN_LLONG EXPORT_VAR_AS_FN",
-        dso_scheme       => "win32",
-        build_scheme     => add("BC", { separator => undef }),
-    },
+###### Borland C++ 4.5
+##    "BC-32" => {
+##        inherit_from     => [ "BASE_Windows" ],
+##        cc               => "bcc32",
+##        sys_id           => "WIN32",
+##        bn_ops           => "BN_LLONG EXPORT_VAR_AS_FN",
+##        dso_scheme       => "win32",
+##        build_scheme     => add("BC", { separator => undef }),
+##    },
 
 #### MinGW
     "mingw" => {
         inherit_from     => [ "BASE_unix", asm("x86_asm"),
                               sub { $disabled{shared} ? () : "x86_uplink" } ],
         cc               => "gcc",
-        cflags           => picker(default => "-DL_ENDIAN -DWIN32_LEAN_AND_MEAN -DUNICODE -D_UNICODE -m32 -Wall",
-                                   debug   => "-g -O0",
-                                   release => "-O3 -fomit-frame-pointer"),
-        thread_cflag     => "-D_MT",
+        cflags           => combine(picker(default => "-DL_ENDIAN -DWIN32_LEAN_AND_MEAN -DUNICODE -D_UNICODE -m32 -Wall",
+                                           debug   => "-g -O0",
+                                           release => "-O3 -fomit-frame-pointer"),
+                                    threads("-D_MT")),
         sys_id           => "MINGW32",
         ex_libs          => add("-lws2_32 -lgdi32 -lcrypt32"),
         bn_ops           => "BN_LLONG EXPORT_VAR_AS_FN",
+        thread_scheme    => "winthreads",
         perlasm_scheme   => "coff",
         dso_scheme       => "win32",
         shared_target    => "mingw-shared",
@@ -1206,13 +1409,14 @@ sub picker {
         # Applink is never engaged and can as well be omitted.
         inherit_from     => [ "BASE_unix", asm("x86_64_asm") ],
         cc               => "gcc",
-        cflags           => picker(default => "-DL_ENDIAN -DWIN32_LEAN_AND_MEAN -DUNICODE -D_UNICODE -m64 -Wall",
-                                   debug   => "-g -O0",
-                                   release => "-O3"),
-        thread_cflag     => "-D_MT",
+        cflags           => combine(picker(default => "-DL_ENDIAN -DWIN32_LEAN_AND_MEAN -DUNICODE -D_UNICODE -m64 -Wall",
+                                           debug   => "-g -O0",
+                                           release => "-O3"),
+                                    threads("-D_MT")),
         sys_id           => "MINGW64",
         ex_libs          => add("-lws2_32 -lgdi32 -lcrypt32"),
         bn_ops           => "SIXTY_FOUR_BIT EXPORT_VAR_AS_FN",
+        thread_scheme    => "winthreads",
         perlasm_scheme   => "mingw64",
         dso_scheme       => "win32",
         shared_target    => "mingw-shared",
@@ -1357,14 +1561,14 @@ sub picker {
         inherit_from     => [ "BASE_unix" ],
         cc               => "cc",
         cflags           => "-std1 -O -Olimit 2500 -DL_ENDIAN",
-        thread_cflag     => "(unknown)",
+        thread_scheme    => "(unknown)",
     },
     "ultrix-gcc" => {
         inherit_from     => [ "BASE_unix" ],
         cc               => "gcc",
         cflags           => "-O3 -DL_ENDIAN",
-        thread_cflag     => "(unknown)",
         bn_ops           => "BN_LLONG",
+        thread_scheme    => "(unknown)",
     },
 # K&R C is no longer supported; you need gcc on old Ultrix installations
 ##"ultrix","cc:-O2 -DNOPROTO -DNOCONST -DL_ENDIAN::(unknown):::::::",
@@ -1374,17 +1578,19 @@ sub picker {
         inherit_from     => [ "BASE_unix" ],
         template         => 1,
         cc               => "cc",
-        cflags           => picker(default => "",
-                                   debug   => "-g -O0",
-                                   release => "-O3"),
-        thread_cflag     => "-D_REENTRANT",
+        cflags           => combine(picker(default => "",
+                                           debug   => "-g -O0",
+                                           release => "-O3"),
+                                   threads("-D_REENTRANT")),
         sys_id           => "MACOSX",
         plib_lflags      => "-Wl,-search_paths_first",
         bn_ops           => "BN_LLONG RC4_CHAR",
+        thread_scheme    => "pthreads",
         perlasm_scheme   => "osx32",
         dso_scheme       => "dlfcn",
+        ranlib           => "ranlib -c",
         shared_target    => "darwin-shared",
-        shared_cflag     => "-fPIC -fno-common",
+        shared_cflag     => "-fPIC",
         shared_ldflag    => "-dynamiclib",
         shared_extension => ".\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
     },
@@ -1459,10 +1665,11 @@ sub picker {
         inherit_from     => [ "BASE_unix" ],
         inherit_from     => [ asm("x86_elf_asm") ],
         cc               => "gcc",
-        cflags           => "-DL_ENDIAN -O3 -fomit-frame-pointer -Wall",
-        thread_cflag     => "-pthread",
+        cflags           => combine("-DL_ENDIAN -O3 -fomit-frame-pointer -Wall",
+                                    threads("-pthread")),
         ex_libs          => add("-ldl"),
         bn_ops           => "BN_LLONG",
+        thread_scheme    => "pthreads",
         dso_scheme       => "dlfcn",
         shared_target    => "linux-shared",
         shared_cflag     => "-fPIC",
@@ -1528,10 +1735,11 @@ sub picker {
     "vxworks-mips" => {
         inherit_from     => [ "BASE_unix", asm("mips32_asm") ],
         cc               => "ccmips",
-        cflags           => "-mrtp -mips2 -O -G 0 -B\$(WIND_BASE)/host/\$(WIND_HOST_TYPE)/lib/gcc-lib/ -D_VSB_CONFIG_FILE=\"\$(WIND_BASE)/target/lib/h/config/vsbConfig.h\" -DCPU=MIPS32 -msoft-float -mno-branch-likely -DTOOL_FAMILY=gnu -DTOOL=gnu -fno-builtin -fno-defer-pop -DNO_STRINGS_H -I\$(WIND_BASE)/target/usr/h -I\$(WIND_BASE)/target/h/wrn/coreip",
-        thread_cflag     => "-D_REENTRANT",
+        cflags           => combine("-mrtp -mips2 -O -G 0 -B\$(WIND_BASE)/host/\$(WIND_HOST_TYPE)/lib/gcc-lib/ -D_VSB_CONFIG_FILE=\"\$(WIND_BASE)/target/lib/h/config/vsbConfig.h\" -DCPU=MIPS32 -msoft-float -mno-branch-likely -DTOOL_FAMILY=gnu -DTOOL=gnu -fno-builtin -fno-defer-pop -DNO_STRINGS_H -I\$(WIND_BASE)/target/usr/h -I\$(WIND_BASE)/target/h/wrn/coreip",
+                                    threads("-D_REENTRANT")),
         sys_id           => "VXWORKS",
         ex_libs          => add("-Wl,--defsym,__wrs_rtp_base=0xe0000000 -L \$(WIND_BASE)/target/usr/lib/mips/MIPSI32/sfcommon"),
+        thread_scheme    => "pthreads",
         perlasm_scheme   => "o32",
         ranlib           => "ranlibmips",
     },
@@ -1540,11 +1748,12 @@ sub picker {
     "uClinux-dist" => {
         inherit_from     => [ "BASE_unix" ],
         cc               => "$ENV{'CC'}",
-        cflags           => "\$(CFLAGS)",
-        thread_cflag     => "-D_REENTRANT",
+        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'}",
         shared_target    => "linux-shared",
         shared_cflag     => "-fPIC",
@@ -1555,11 +1764,12 @@ sub picker {
     "uClinux-dist64" => {
         inherit_from     => [ "BASE_unix" ],
         cc               => "$ENV{'CC'}",
-        cflags           => "\$(CFLAGS)",
-        thread_cflag     => "-D_REENTRANT",
+        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'}",
         shared_target    => "linux-shared",
         shared_cflag     => "-fPIC",
@@ -1580,6 +1790,7 @@ sub picker {
                                    debug   => "/DEBUG/TRACEBACK",
                                    release => "/NODEBUG/NOTRACEBACK"),
         shared_target    => "vms-shared",
+        thread_scheme    => "pthreads",
 
         apps_aux_src     => "vms_decc_init.c",
     },