Configure - Get rid of the special thread_cflag, replace with thread_scheme
authorRichard Levitte <levitte@openssl.org>
Sat, 27 Feb 2016 15:51:34 +0000 (16:51 +0100)
committerRichard Levitte <levitte@openssl.org>
Wed, 2 Mar 2016 18:15:42 +0000 (19:15 +0100)
The thread_cflag setting filled a double role, as kinda sorta an
indicator of thread scheme, and as cflags.  Some configs also added
lflags and ex_libs for multithreading regardless of if threading would
be enabled or not.

Instead of this, add threading cflags among in the cflag setting,
threading lflags in the lflag setting and so on if and only if threads
are enabled (which they are by default).

Also, for configs where there are no special cflags for threading (the
VMS configs are of that kind), this makes it possible to still clearly
mention what thread scheme is used.

The exact value of thread scheme is currently ignored except when it's
"(unknown)", and thereby only serves as a flag to tell if we know how
to build for multi-threading in a particular config.  Yet, the
currently used values are "(unknown)", "pthreads", "uithreads" (a.k.a
solaris threads) and "winthreads".

Reviewed-by: Andy Polyakov <appro@openssl.org>
Configurations/00-base-templates.conf
Configurations/10-main.conf
Configurations/90-team.conf
Configurations/99-personal-ben.conf
Configurations/99-personal-bodo.conf
Configurations/99-personal-geoff.conf
Configurations/99-personal-rse.conf
Configurations/99-personal-steve.conf
Configure

index 161eb39ae235214278a305d384e806feca038e50..cf50785ceb00d929be5ba60f372f887cc0ccdd3b 100644 (file)
@@ -5,7 +5,7 @@
 
        cflags          => "",
        defines         => [],
-       thread_cflags   => "",
+       thread_scheme   => "(unknown)", # Assume we don't know
        thread_defines  => [],
 
        apps_aux_src    => "",
index 121815ff8162a48df94c5064198709d6e22bc97b..6fade9811c168d3de1d5150f69984ae12eb66dad 100644 (file)
@@ -7,6 +7,16 @@ sub picker {
                      $opts{$config{build_type}} || ())->(); }
 }
 
+sub threads {
+    my @flags = @_;
+    return sub { add($disabled{threads} ? () : @flags)->(); }
+}
+
+sub combine {
+    my @stuff = @_;
+    return sub { add(@stuff)->(); }
+}
+
 %targets = (
 
 #### Basic configs that should work on any 32-bit box
@@ -14,13 +24,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 +40,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 +54,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 +69,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 +88,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 +103,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 +116,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 +134,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 +168,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 +201,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 +214,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 +227,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 +243,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 +261,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 +277,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 +323,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 +343,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 +365,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 +386,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 +405,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 +424,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 +442,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 +461,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 +479,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 +490,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 +500,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 +509,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 +527,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 +649,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 +745,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 +756,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 +848,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 +857,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 +916,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 +930,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 +947,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 +984,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 +1014,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 +1030,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 +1042,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 +1056,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 +1073,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 +1093,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 +1110,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 +1130,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 +1143,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
@@ -1179,13 +1215,14 @@ sub picker {
         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 +1243,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 +1395,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,13 +1412,14 @@ 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",
         shared_target    => "darwin-shared",
@@ -1459,10 +1498,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 +1568,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 +1581,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 +1597,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 +1623,7 @@ sub picker {
                                    debug   => "/DEBUG/TRACEBACK",
                                    release => "/NODEBUG/NOTRACEBACK"),
         shared_target    => "vms-shared",
+        thread_scheme    => "pthreads",
 
         apps_aux_src     => "vms_decc_init.c",
     },
index 52175049b1cebcafeca37d0911f01cb1d67402f2..c7f287fb239630d623f8353d772d08dc9a19ff2c 100644 (file)
@@ -1,26 +1,37 @@
 ## -*- mode: perl; -*-
 ## Build configuration targets for openssl-team members
 
+sub threads {
+    my @flags = @_;
+    return sub { add($disabled{threads} ? () : @flags)->(); }
+}
+
+sub combine {
+    my @stuff = @_;
+    return sub { add(@stuff)->(); }
+}
+
 %targets = (
     "purify" => {
         cc               => "purify gcc",
         cflags           => "-g -Wall",
-        thread_cflag     => "(unknown)",
+        thread_scheme    => "(unknown)",
         ex_libs          => add(" ","-lsocket -lnsl"),
     },
     "debug" => {
         cc               => "gcc",
         cflags           => "-DBN_DEBUG -DREF_DEBUG -DCONF_DEBUG -DBN_CTX_DEBUG -DOPENSSL_NO_ASM -ggdb -g2 -Wformat -Wshadow -Wmissing-prototypes -Wmissing-declarations -Werror",
-        thread_cflag     => "(unknown)",
+        thread_scheme    => "(unknown)",
         ex_libs          => add(" ","-lefence"),
     },
     "debug-erbridge" => {
         inherit_from     => [ "x86_64_asm" ],
         cc               => "gcc",
-        cflags           => "$gcc_devteam_warn -DBN_DEBUG -DCONF_DEBUG -m64 -DL_ENDIAN -DTERMIO -g",
-        thread_cflag     => "-D_REENTRANT",
+        cflags           => combine("$gcc_devteam_warn -DBN_DEBUG -DCONF_DEBUG -m64 -DL_ENDIAN -DTERMIO -g",
+                                    threads("-D_REENTRANT")),
         ex_libs          => add(" ","-ldl"),
         bn_ops           => "SIXTY_FOUR_BIT_LONG",
+        thread_scheme    => "pthreads",
         perlasm_scheme   => "elf",
         dso_scheme       => "dlfcn",
         shared_target    => "linux-shared",
     "debug-linux-pentium" => {
         inherit_from     => [ "x86_elf_asm" ],
         cc               => "gcc",
-        cflags           => "-DBN_DEBUG -DREF_DEBUG -DCONF_DEBUG -DBN_CTX_DEBUG -DL_ENDIAN -g -mcpu=pentium -Wall",
-        thread_cflag     => "-D_REENTRANT",
+        cflags           => combine("-DBN_DEBUG -DREF_DEBUG -DCONF_DEBUG -DBN_CTX_DEBUG -DL_ENDIAN -g -mcpu=pentium -Wall",
+                                    threads("-D_REENTRANT")),
         ex_libs          => add(" ","-ldl"),
         bn_ops           => "BN_LLONG",
+        thread_scheme    => "pthreads",
         dso_scheme       => "dlfcn",
     },
     "debug-linux-ppro" => {
         inherit_from     => [ "x86_elf_asm" ],
         cc               => "gcc",
-        cflags           => "-DBN_DEBUG -DREF_DEBUG -DCONF_DEBUG -DBN_CTX_DEBUG -DL_ENDIAN -g -mcpu=pentiumpro -Wall",
-        thread_cflag     => "-D_REENTRANT",
+        cflags           => combine("-DBN_DEBUG -DREF_DEBUG -DCONF_DEBUG -DBN_CTX_DEBUG -DL_ENDIAN -g -mcpu=pentiumpro -Wall",
+                                    threads("-D_REENTRANT")),
         ex_libs          => add(" ","-ldl"),
         bn_ops           => "BN_LLONG",
+        thread_scheme    => "pthreads",
         dso_scheme       => "dlfcn",
     },
     "debug-linux-elf-noefence" => {
         inherit_from     => [ "x86_elf_asm" ],
         cc               => "gcc",
-        cflags           => "-DBN_DEBUG -DREF_DEBUG -DCONF_DEBUG -DBN_CTX_DEBUG -DL_ENDIAN -g -Wall",
-        thread_cflag     => "-D_REENTRANT",
+        cflags           => combine("-DBN_DEBUG -DREF_DEBUG -DCONF_DEBUG -DBN_CTX_DEBUG -DL_ENDIAN -g -Wall",
+                                    threads("-D_REENTRANT")),
         ex_libs          => add(" ","-ldl"),
         bn_ops           => "BN_LLONG",
+        thread_scheme    => "pthreads",
         dso_scheme       => "dlfcn",
         shared_target    => "linux-shared",
         shared_cflag     => "-fPIC",
@@ -61,8 +75,8 @@
     },
     "debug-linux-ia32-aes" => {
         cc               => "gcc",
-        cflags           => "-DL_ENDIAN -O3 -fomit-frame-pointer -Wall",
-        thread_cflag     => "-D_REENTRANT",
+        cflags           => combine("-DL_ENDIAN -O3 -fomit-frame-pointer -Wall",
+                                    threads("-D_REENTRANT")),
         ex_libs          => add(" ","-ldl"),
         bn_ops           => "BN_LLONG",
         cpuid_asm_src    => "x86cpuid.s",
@@ -79,6 +93,7 @@
         wp_asm_src       => "wp_block.s wp-mmx.s",
         modes_asm_src    => "ghash-x86.s",
         padlock_asm_src  => "e_padlock-x86.s",
+        thread_scheme    => "pthreads",
         perlasm_scheme   => "elf",
         dso_scheme       => "dlfcn",
         shared_target    => "linux-shared",
     "dist" => {
         cc               => "cc",
         cflags           => "-O",
-        thread_cflag     => "(unknown)",
+        thread_scheme    => "(unknown)",
     },
     "debug-test-64-clang" => {
         inherit_from     => [ "x86_64_asm" ],
         cc               => "clang",
-        cflags           => "$gcc_devteam_warn -Wno-error=overlength-strings -Wno-error=extended-offsetof -Wno-error=language-extension-token -Wno-error=unused-const-variable -Wstrict-overflow -Qunused-arguments -DBN_DEBUG -DCONF_DEBUG -DDEBUG_SAFESTACK -DDEBUG_UNUSED -g3 -O3 -pipe",
-        thread_cflag     => "${BSDthreads}",
+        cflags           => combine("$gcc_devteam_warn -Wno-error=overlength-strings -Wno-error=extended-offsetof -Wno-error=language-extension-token -Wno-error=unused-const-variable -Wstrict-overflow -Qunused-arguments -DBN_DEBUG -DCONF_DEBUG -DDEBUG_SAFESTACK -DDEBUG_UNUSED -g3 -O3 -pipe",
+                                    threads("${BSDthreads}")),
         bn_ops           => "SIXTY_FOUR_BIT_LONG",
+        thread_scheme    => "pthreads",
         perlasm_scheme   => "elf",
         dso_scheme       => "dlfcn",
         shared_target    => "bsd-gcc-shared",
     "darwin64-debug-test-64-clang" => {
         inherit_from     => [ "x86_64_asm" ],
         cc               => "clang",
-        cflags           => "-arch x86_64 -DL_ENDIAN $gcc_devteam_warn -Wno-error=overlength-strings -Wno-error=extended-offsetof -Wno-error=language-extension-token -Wno-error=unused-const-variable -Wstrict-overflow -Qunused-arguments -DBN_DEBUG -DCONF_DEBUG -DDEBUG_SAFESTACK -DDEBUG_UNUSED -g3 -O3 -pipe",
-        thread_cflag     => "${BSDthreads}",
+        cflags           => combine("-arch x86_64 -DL_ENDIAN $gcc_devteam_warn -Wno-error=overlength-strings -Wno-error=extended-offsetof -Wno-error=language-extension-token -Wno-error=unused-const-variable -Wstrict-overflow -Qunused-arguments -DBN_DEBUG -DCONF_DEBUG -DDEBUG_SAFESTACK -DDEBUG_UNUSED -g3 -O3 -pipe",
+                                    threads("${BSDthreads}")),
         sys_id           => "MACOSX",
         bn_ops           => "SIXTY_FOUR_BIT_LONG",
+        thread_scheme    => "pthreads",
         perlasm_scheme   => "macosx",
         dso_scheme       => "dlfcn",
         shared_target    => "darwin-shared",
index 611e3dedd0fe18a395b9563043802ae48b997236..50b9315cf39ea652b3b49480757c7992166a21a0 100644 (file)
@@ -5,29 +5,30 @@
     "debug-ben" => {
         cc               => "gcc",
         cflags           => "$gcc_devteam_warn -DBN_DEBUG -DREF_DEBUG -DCONF_DEBUG -DBN_CTX_DEBUG -DDEBUG_SAFESTACK -O2 -pipe",
-        thread_cflag     => "(unknown)",
+        thread_scheme    => "(unknown)",
     },
     "debug-ben-openbsd" => {
         cc               => "gcc",
         cflags           => "-DBN_DEBUG -DREF_DEBUG -DCONF_DEBUG -DBN_CTX_DEBUG -DPEDANTIC -DDEBUG_SAFESTACK -DOPENSSL_OPENBSD_DEV_CRYPTO -DOPENSSL_NO_ASM -O2 -pedantic -Wall -Wshadow -Werror -pipe",
-        thread_cflag     => "(unknown)",
+        thread_scheme    => "(unknown)",
     },
     "debug-ben-openbsd-debug" => {
         cc               => "gcc",
         cflags           => "-DBN_DEBUG -DREF_DEBUG -DCONF_DEBUG -DBN_CTX_DEBUG -DPEDANTIC -DDEBUG_SAFESTACK -DOPENSSL_OPENBSD_DEV_CRYPTO -DOPENSSL_NO_ASM -g3 -O2 -pedantic -Wall -Wshadow -Werror -pipe",
-        thread_cflag     => "(unknown)",
+        thread_scheme    => "(unknown)",
     },
     "debug-ben-debug" => {
         cc               => "gcc",
         cflags           => "$gcc_devteam_warn -DBN_DEBUG -DCONF_DEBUG -DDEBUG_SAFESTACK -DOPENSSL_NO_HW_PADLOCK -g3 -O2 -pipe",
-        thread_cflag     => "(unknown)",
+        thread_scheme    => "(unknown)",
     },
     "debug-ben-debug-64" => {
         inherit_from     => [ "x86_64_asm" ],
         cc               => "gcc",
-        cflags           => "$gcc_devteam_warn -Wno-error=overlength-strings -DBN_DEBUG -DCONF_DEBUG -DDEBUG_SAFESTACK -DDEBUG_UNUSED -g3 -O3 -pipe",
-        thread_cflag     => "${BSDthreads}",
+        cflags           => combine("$gcc_devteam_warn -Wno-error=overlength-strings -DBN_DEBUG -DCONF_DEBUG -DDEBUG_SAFESTACK -DDEBUG_UNUSED -g3 -O3 -pipe",
+                                    threads("${BSDthreads}")),
         bn_ops           => "SIXTY_FOUR_BIT_LONG",
+        thread_scheme    => "pthreads",
         perlasm_scheme   => "elf",
         dso_scheme       => "dlfcn",
         shared_target    => "bsd-gcc-shared",
     "debug-ben-debug-64-clang" => {
         inherit_from     => [ "x86_64_asm" ],
         cc               => "clang",
-        cflags           => "$gcc_devteam_warn -Wno-error=overlength-strings -Wno-error=extended-offsetof -Wno-error=language-extension-token -Wstrict-overflow -Qunused-arguments -DBN_DEBUG -DCONF_DEBUG -DDEBUG_SAFESTACK -DDEBUG_UNUSED -g3 -O3 -pipe",
-        thread_cflag     => "${BSDthreads}",
+        cflags           => combine("$gcc_devteam_warn -Wno-error=overlength-strings -Wno-error=extended-offsetof -Wno-error=language-extension-token -Wstrict-overflow -Qunused-arguments -DBN_DEBUG -DCONF_DEBUG -DDEBUG_SAFESTACK -DDEBUG_UNUSED -g3 -O3 -pipe",
+                                    threads("${BSDthreads}")),
         bn_ops           => "SIXTY_FOUR_BIT_LONG",
+        thread_scheme    => "pthreads",
         perlasm_scheme   => "elf",
         dso_scheme       => "dlfcn",
         shared_target    => "bsd-gcc-shared",
     "debug-ben-debug-64-noopt" => {
         inherit_from     => [ "x86_64_asm" ],
         cc               => "gcc",
-        cflags           => "$gcc_devteam_warn -Wno-error=overlength-strings -DBN_DEBUG -DCONF_DEBUG -DDEBUG_SAFESTACK -DDEBUG_UNUSED -g3 -pipe",
-        thread_cflag     => "${BSDthreads}",
+        cflags           => combine("$gcc_devteam_warn -Wno-error=overlength-strings -DBN_DEBUG -DCONF_DEBUG -DDEBUG_SAFESTACK -DDEBUG_UNUSED -g3 -pipe",
+                                    threads("${BSDthreads}")),
         bn_ops           => "SIXTY_FOUR_BIT_LONG",
+        thread_scheme    => "pthreads",
         perlasm_scheme   => "elf",
         dso_scheme       => "dlfcn",
         shared_target    => "bsd-gcc-shared",
     "debug-ben-macos" => {
         cc               => "cc",
         cflags           => "$gcc_devteam_warn -DOPENSSL_NO_ASM -DBN_DEBUG -DCONF_DEBUG -DDEBUG_SAFESTACK -DDEBUG_UNUSED -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -arch i386 -O3 -DL_ENDIAN -g3 -pipe",
-        thread_cflag     => "(unknown)",
+        thread_scheme    => "(unknown)",
     },
     "debug-ben-no-opt" => {
         cc               => "gcc",
         cflags           => " -Wall -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations -DDEBUG_SAFESTACK -Werror -DL_ENDIAN -Wall -g3",
-        thread_cflag     => "(unknown)",
+        thread_scheme    => "(unknown)",
     },
     "debug-ben-strict" => {
         cc               => "gcc",
         cflags           => "-DBN_DEBUG -DREF_DEBUG -DCONF_DEBUG -DBN_CTX_DEBUG -DCONST_STRICT -O2 -Wall -Wshadow -Werror -Wpointer-arith -Wcast-qual -Wwrite-strings -pipe",
-        thread_cflag     => "(unknown)",
+        thread_scheme    => "(unknown)",
     },
     "debug-ben-darwin64" => {
         inherit_from     => [ "x86_64_asm" ],
         cc               => "cc",
-        cflags           => "$gcc_devteam_warn -Wno-language-extension-token -Wno-extended-offsetof -arch x86_64 -O3 -DL_ENDIAN -DMD32_REG_T=int -Wall",
-        thread_cflag     => "-D_REENTRANT",
+        cflags           => combine("$gcc_devteam_warn -Wno-language-extension-token -Wno-extended-offsetof -arch x86_64 -O3 -DL_ENDIAN -DMD32_REG_T=int -Wall",
+                                    threads("-D_REENTRANT")),
         sys_id           => "MACOSX",
         plib_lflags      => "-Wl,-search_paths_first",
         bn_ops           => "SIXTY_FOUR_BIT_LONG",
+        thread_scheme    => "pthreads",
         perlasm_scheme   => "macosx",
         dso_scheme       => "dlfcn",
         shared_target    => "darwin-shared",
index c59333a2d1ce27d8973716df16022be38eaada05..df9b49ce92e6a198a8e663ec4481abc95f26d233 100644 (file)
@@ -5,10 +5,11 @@
     "debug-bodo" => {
         inherit_from     => [ "x86_64_asm" ],
         cc               => "gcc",
-        cflags           => "$gcc_devteam_warn -Wno-error=overlength-strings -DBN_DEBUG -DBN_DEBUG_RAND -DCONF_DEBUG -m64 -DL_ENDIAN -DTERMIO -g -DMD32_REG_T=int",
-        thread_cflag     => "-D_REENTRANT",
+        cflags           => combine("$gcc_devteam_warn -Wno-error=overlength-strings -DBN_DEBUG -DBN_DEBUG_RAND -DCONF_DEBUG -m64 -DL_ENDIAN -DTERMIO -g -DMD32_REG_T=int",
+                                    threads("-D_REENTRANT")),
         ex_libs          => add(" ","-ldl"),
         bn_ops           => "SIXTY_FOUR_BIT_LONG",
+        thread_scheme    => "pthreads",
         perlasm_scheme   => "elf",
         dso_scheme       => "dlfcn",
         shared_target    => "linux-shared",
index 0e393f9656efc79eb6275040f8f27703eaa117cb..5bddfaef8349b83d4ed79dffeef6e3cf237551cd 100644 (file)
@@ -4,10 +4,11 @@
 %targets = (
     "debug-geoff32" => {
         cc               => "gcc",
-        cflags           => "-DBN_DEBUG -DBN_DEBUG_RAND -DBN_STRICT -DOPENSSL_NO_DEPRECATED -DOPENSSL_NO_ASM -DOPENSSL_NO_INLINE_ASM -DL_ENDIAN -DTERMIO -DPEDANTIC -O1 -ggdb2 -Wall -Werror -Wundef -pedantic -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-align -Wsign-compare -Wmissing-prototypes -Wmissing-declarations -Wno-long-long",
-        thread_cflag     => "-D_REENTRANT",
+        cflags           => combine("-DBN_DEBUG -DBN_DEBUG_RAND -DBN_STRICT -DOPENSSL_NO_DEPRECATED -DOPENSSL_NO_ASM -DOPENSSL_NO_INLINE_ASM -DL_ENDIAN -DTERMIO -DPEDANTIC -O1 -ggdb2 -Wall -Werror -Wundef -pedantic -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-align -Wsign-compare -Wmissing-prototypes -Wmissing-declarations -Wno-long-long",
+                                    threads("-D_REENTRANT")),
         ex_libs          => add(" ","-ldl"),
         bn_ops           => "BN_LLONG",
+        thread_scheme    => "pthreads",
         dso_scheme       => "dlfcn",
         shared_target    => "linux-shared",
         shared_cflag     => "-fPIC",
     },
     "debug-geoff64" => {
         cc               => "gcc",
-        cflags           => "-DBN_DEBUG -DBN_DEBUG_RAND -DBN_STRICT -DOPENSSL_NO_DEPRECATED -DOPENSSL_NO_ASM -DOPENSSL_NO_INLINE_ASM -DL_ENDIAN -DTERMIO -DPEDANTIC -O1 -ggdb2 -Wall -Werror -Wundef -pedantic -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-align -Wsign-compare -Wmissing-prototypes -Wmissing-declarations -Wno-long-long",
-        thread_cflag     => "-D_REENTRANT",
+        cflags           => combine("-DBN_DEBUG -DBN_DEBUG_RAND -DBN_STRICT -DOPENSSL_NO_DEPRECATED -DOPENSSL_NO_ASM -DOPENSSL_NO_INLINE_ASM -DL_ENDIAN -DTERMIO -DPEDANTIC -O1 -ggdb2 -Wall -Werror -Wundef -pedantic -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-align -Wsign-compare -Wmissing-prototypes -Wmissing-declarations -Wno-long-long",
+                                    threads("-D_REENTRANT")),
         ex_libs          => add(" ","-ldl"),
         bn_ops           => "SIXTY_FOUR_BIT_LONG RC4_CHAR",
+        thread_scheme    => "pthreads",
         dso_scheme       => "dlfcn",
         shared_target    => "linux-shared",
         shared_cflag     => "-fPIC",
index ecb47420867c141e57ec52035f64c1e3e3e7d83a..9999fcd3cf603d6fd9da4ccc3dba121df54c293e 100644 (file)
@@ -6,7 +6,7 @@
         inherit_from     => [ "x86_elf_asm" ],
         cc               => "cc",
         cflags           => "-DL_ENDIAN -pipe -O -g -ggdb3 -Wall",
-        thread_cflag     => "(unknown)",
+        thread_scheme    => "(unknown)",
         bn_ops           => "BN_LLONG",
     },
 );
index 9aadf4b16f40af7889c12d2db61e3e0fb4f12ba7..473fd240d4f9d06028a97de597184ce9289a8f13 100644 (file)
@@ -5,10 +5,11 @@
     "debug-steve64" => {
         inherit_from     => [ "x86_64_asm" ],
         cc               => "gcc",
-        cflags           => "$gcc_devteam_warn -pthread -m64 -DL_ENDIAN -DTERMIO -DCONF_DEBUG -g",
-        thread_cflag     => "-D_REENTRANT",
+        cflags           => combine("$gcc_devteam_warn -pthread -m64 -DL_ENDIAN -DTERMIO -DCONF_DEBUG -g",
+                                    threads("-D_REENTRANT")),
         ex_libs          => add(" ","-ldl"),
         bn_ops           => "SIXTY_FOUR_BIT_LONG",
+        thread_scheme    => "pthreads",
         perlasm_scheme   => "elf",
         dso_scheme       => "dlfcn",
         shared_target    => "linux-shared",
     "debug-steve32" => {
         inherit_from     => [ "x86_elf_asm" ],
         cc               => "gcc",
-        cflags           => "$gcc_devteam_warn -pthread -m32 -DL_ENDIAN -DCONF_DEBUG -g",
-        thread_cflag     => "-D_REENTRANT",
+        cflags           => combine("$gcc_devteam_warn -pthread -m32 -DL_ENDIAN -DCONF_DEBUG -g",
+                                    threads("-D_REENTRANT")),
         lflags           => "-rdynamic",
         ex_libs          => add(" ","-ldl"),
         bn_ops           => "BN_LLONG",
+        thread_scheme    => "pthreads",
         dso_scheme       => "dlfcn",
         shared_target    => "linux-shared",
         shared_cflag     => "-fPIC",
     "debug-steve-opt" => {
         inherit_from     => [ "x86_64_asm" ],
         cc               => "gcc",
-        cflags           => "$gcc_devteam_warn -pthread -m64 -O3 -DL_ENDIAN -DTERMIO -DCONF_DEBUG -g",
-        thread_cflag     => "-D_REENTRANT",
+        cflags           => combine("$gcc_devteam_warn -pthread -m64 -O3 -DL_ENDIAN -DTERMIO -DCONF_DEBUG -g",
+                                    threads("-D_REENTRANT")),
         ex_libs          => add(" ","-ldl"),
         bn_ops           => "SIXTY_FOUR_BIT_LONG",
+        thread_scheme    => "pthreads",
         perlasm_scheme   => "elf",
         dso_scheme       => "dlfcn",
         shared_target    => "linux-shared",
index eab3c661d279bd434eda85bc6355ed32c5b81ed2..c1a3f8a26ef536fe5d04d22a5e0de30ea799725d 100755 (executable)
--- a/Configure
+++ b/Configure
@@ -124,7 +124,7 @@ my $strict_warnings = 0;
 # which has to be accompanied by explicit -D_THREAD_SAFE and
 # sometimes -D_REENTRANT. FreeBSD 5.x expands it as -lc_r, which
 # seems to be sufficient?
-my $BSDthreads="-pthread -D_THREAD_SAFE -D_REENTRANT";
+our $BSDthreads="-pthread -D_THREAD_SAFE -D_REENTRANT";
 
 #
 # API compability name to version number mapping.
@@ -208,7 +208,7 @@ $config{cross_compile_prefix}="";
 $config{fipslibdir}="/usr/local/ssl/fips-2.0/lib/";
 my $nofipscanistercheck=0;
 $config{baseaddr}="0xFB00000";
-my $threads=0;
+my $auto_threads=1;    # enable threads automatically? true by default
 my $default_ranlib;
 $config{fips}=0;
 
@@ -569,6 +569,8 @@ foreach (@argvcopy)
                         {
                         $disabled{$1} = "option";
                         }
+               # No longer an automatic choice
+               $auto_threads = 0 if ($1 eq "threads");
                }
        elsif (/^enable-(.+)$/)
                {
@@ -583,7 +585,8 @@ foreach (@argvcopy)
                my $algo = $1;
                delete $disabled{$algo};
 
-               $threads = 1 if ($algo eq "threads");
+               # No longer an automatic choice
+               $auto_threads = 0 if ($1 eq "threads");
                }
        elsif (/^--strict-warnings$/)
                {
@@ -928,32 +931,6 @@ if (!$disabled{dso} && $target{dso_scheme} ne "")
                }
        }
 
-my $thread_cflags = "";
-my @thread_defines;
-if ($target{thread_cflag} ne "(unknown)" && !$disabled{threads})
-       {
-       # If we know how to do it, support threads by default.
-       $threads = 1;
-       }
-if ($target{thread_cflag} eq "(unknown)" && $threads)
-       {
-       # If the user asked for "threads", [s]he is also expected to
-       # provide any system-dependent compiler options that are
-       # necessary.
-       if ($no_user_cflags && $no_user_defines)
-               {
-               print "You asked for multi-threading support, but didn't\n";
-               print "provide any system-specific compiler options\n";
-               exit(1);
-               }
-       push @thread_defines, "OPENSSL_THREADS";
-       }
-else
-       {
-       $thread_cflags=" $target{thread_cflag}";
-       push @thread_defines, @{$target{thread_defines}}, "OPENSSL_THREADS";
-       }
-
 $config{ex_libs}="$libs$config{ex_libs}" if ($libs ne "");
 
 if ($disabled{asm})
@@ -962,12 +939,37 @@ if ($disabled{asm})
            if ($config{fips});
        }
 
-if ($threads)
-       {
-       $config{cflags} = "$thread_cflags $config{cflags}" if $thread_cflags;
-       push @{$config{defines}}, @thread_defines;
-       push @{$config{openssl_thread_defines}}, @thread_defines;
-       }
+# If threads aren't disabled, check how possible they are
+unless ($disabled{threads}) {
+    if ($auto_threads) {
+        # Enabled by default, disable it forcibly if unavailable
+        if ($target{thread_scheme} eq "(unknown)") {
+            $disabled{threads} = "unavailable";
+        }
+    } else {
+        # The user chose to enable threads explicitely, let's see
+        # if there's a chance that's possible
+        if ($target{thread_scheme} eq "(unknown)") {
+            # If the user asked for "threads" and we don't have internal
+            # knowledge how to do it, [s]he is expected to provide any
+            # system-dependent compiler options that are necessary.  We
+            # can't truly check that the given options are correct, but
+            # we expect the user to know what [s]He is doing.
+            if ($no_user_cflags && $no_user_defines) {
+                die "You asked for multi-threading support, but didn't\n"
+                    ,"provide any system-specific compiler options\n";
+            }
+        }
+    }
+}
+
+# If threads still aren't disabled, add a C macro to ensure the source
+# code knows about it.  Any other flag is taken care of by the configs.
+unless($disabled{threads}) {
+    foreach (("defines", "openssl_thread_defines")) {
+        push @{$config{$_}}, "OPENSSL_THREADS";
+    }
+}
 
 # With "deprecated" disable all deprecated features.
 if (defined($disabled{"deprecated"})) {
@@ -1833,7 +1835,7 @@ print <<"EOF";
 Configured for $target.
 EOF
 
-print <<"EOF" if (!$disabled{threads} && !$threads);
+print <<"EOF" if ($disabled{threads} eq "unavailable");
 
 The library could not be configured for supporting multi-threaded
 applications as the compiler options required on this system are not known.
@@ -1903,6 +1905,7 @@ sub asm {
     }
 }
 
+our $add_called = 0;
 # Helper function to implement adding values to already existing configuration
 # values.  It handles elements that are ARRAYs, CODEs and scalars
 sub _add {
@@ -1931,6 +1934,8 @@ sub _add {
            }
     } (@_);
 
+    $add_called = 1;
+
     if ($found_array) {
        [ @values ];
     } else {
@@ -1999,6 +2004,8 @@ sub resolve_config {
     my $target = shift;
     my @breadcrumbs = @_;
 
+    my $extra_checks = defined($ENV{CONFIGURE_EXTRA_CHECKS});
+
     if (grep { $_ eq $target } @breadcrumbs) {
        die "inherit_from loop!  target backtrace:\n  "
            ,$target,"\n  ",join("\n  ", @breadcrumbs),"\n";
@@ -2061,6 +2068,8 @@ sub resolve_config {
        my $target    = shift;
        my $entry     = shift;
 
+        $add_called = 0;
+
         while(ref($object) eq "CODE") {
             $object = $object->(@$inherited);
         }
@@ -2068,6 +2077,7 @@ sub resolve_config {
             return ();
         }
         elsif (ref($object) eq "ARRAY") {
+            local $add_called;  # To make sure recursive calls don't affect it
             return [ map { process_values($_, $inherited, $target, $entry) }
                      @$object ];
         } elsif (ref($object) eq "") {
@@ -2079,6 +2089,7 @@ sub resolve_config {
     }
 
     foreach (sort keys %all_keys) {
+        my $previous = $combined_inheritance{$_};
 
        # Current target doesn't have a value for the current key?
        # Assign it the default combiner, the rest of this loop body
@@ -2093,6 +2104,10 @@ sub resolve_config {
         unless(defined($table{$target}->{$_})) {
             delete $table{$target}->{$_};
         }
+        if ($extra_checks &&
+            $previous && !($add_called ||  $previous ~~ $table{$target}->{$_})) {
+            warn "$_ got replaced in $target\n";
+        }
     }
 
     # Finally done, return the result.
@@ -2167,7 +2182,6 @@ sub print_table_entry
        "cc",
        "cflags",
        "defines",
-       "thread_cflag",
        "unistd",
        "ld",
        "lflags",
@@ -2190,6 +2204,7 @@ sub print_table_entry
        "cmll_obj",
        "modes_obj",
        "padlock_obj",
+       "thread_scheme",
        "perlasm_scheme",
        "dso_scheme",
        "shared_target",