Configure - get rid of the special debug_ and release_ settings
authorRichard Levitte <levitte@openssl.org>
Wed, 2 Mar 2016 18:13:26 +0000 (19:13 +0100)
committerRichard Levitte <levitte@openssl.org>
Wed, 2 Mar 2016 18:15:42 +0000 (19:15 +0100)
Instead, make the build type ("debug" or "release") available through
$config{build_type} and let the configs themselves figure out what the
usual settings (such as "cflags", "lflags" and so on) should be
accordingly.

The benefit with this is that we can now have debug and release
variants of any setting, not just those Configure supports, and may
also involve other factors (the MSVC flags /MD[d] and /MT[d] involve
both build type and whether threading is enabled or not)

Reviewed-by: Andy Polyakov <appro@openssl.org>
Configurations/00-base-templates.conf
Configurations/10-main.conf
Configurations/99-personal-levitte.conf
Configure

index 60cd90e..161eb39 100644 (file)
@@ -5,10 +5,6 @@
 
        cflags          => "",
        defines         => [],
-       debug_cflags    => "",
-       debug_defines   => [],
-       release_cflags  => "",
-       release_defines => [],
        thread_cflags   => "",
        thread_defines  => [],
 
index 3b90403..121815f 100644 (file)
@@ -1,14 +1,19 @@
 ## -*- mode: perl; -*-
 ## Standard openssl configuration targets.
 
+sub picker {
+    my %opts = @_;
+    return sub { add($opts{default} || (),
+                     $opts{$config{build_type}} || ())->(); }
+}
+
 %targets = (
 
 #### Basic configs that should work on any 32-bit box
     "gcc" => {
         cc               => "gcc",
-        cflags           => "",
-        debug_cflags     => "-O0 -g",
-        release_cflags   => "-O3",
+        cflags           => picker(debug   => "-O0 -g",
+                                   release => "-O3"),
         thread_cflag     => "(unknown)",
         bn_ops           => "BN_LLONG",
     },
@@ -22,9 +27,9 @@
     "vos-gcc" => {
         inherit_from     => [ "BASE_unix" ],
         cc               => "gcc",
-        cflags           => "-Wall -DOPENSSL_SYS_VOS -D_POSIX_C_SOURCE=200112L -D_BSD -D_VOS_EXTENDED_NAMES -DB_ENDIAN",
-        debug_cflags     => "-O0 -g -DBN_DEBUG -DREF_DEBUG -DCONF_DEBUG",
-        release_cflags   => "-O3",
+        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)",
         sys_id           => "VOS",
         lflags           => "-Wl,-map",
@@ -51,9 +56,9 @@
         # with "Illegal mnemonic" error message.
         inherit_from     => [ "solaris-common", asm("x86_elf_asm") ],
         cc               => "gcc",
-        cflags           => add_before("-Wall -DL_ENDIAN -DOPENSSL_NO_INLINE_ASM"),
-        debug_cflags     => "-O0 -g",
-        release_cflags   => "-O3 -fomit-frame-pointer",
+        cflags           => add_before(picker(default => "-Wall -DL_ENDIAN -DOPENSSL_NO_INLINE_ASM",
+                                              debug   => "-O0 -g",
+                                              release => "-O3 -fomit-frame-pointer")),
         thread_cflag     => "-pthread",
         bn_ops           => "BN_LLONG",
         shared_cflag     => "-fPIC",
@@ -70,9 +75,9 @@
         #                                      <appro@fy.chalmers.se>
         inherit_from     => [ "solaris-common", asm("x86_64_asm") ],
         cc               => "gcc",
-        cflags           => add_before("-m64 -Wall -DL_ENDIAN"),
-        debug_cflags     => "-O0 -g",
-        release_cflags   => "-O3",
+        cflags           => add_before(picker(default => "-m64 -Wall -DL_ENDIAN",
+                                              debug   => "-O0 -g",
+                                              release => "-O3")),
         thread_cflag     => "-pthread",
         bn_ops           => "SIXTY_FOUR_BIT_LONG",
         perlasm_scheme   => "elf",
@@ -85,9 +90,9 @@
     "solaris-x86-cc" => {
         inherit_from     => [ "solaris-common" ],
         cc               => "cc",
-        cflags           => add_before("-xarch=generic -xstrconst -Xa -DL_ENDIAN"),
-        debug_cflags     => "-g",
-        release_cflags   => "-xO5 -xregs=frameptr -xdepend -xbuiltin",
+        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"),
     "solaris64-x86_64-cc" => {
         inherit_from     => [ "solaris-common", asm("x86_64_asm") ],
         cc               => "cc",
-        cflags           => add_before("-xarch=generic64 -xstrconst -Xa -DL_ENDIAN"),
-        debug_cflags     => "-g",
-        release_cflags   => "-xO5 -xdepend -xbuiltin",
+        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"),
     "solaris-sparcv7-gcc" => {
         inherit_from     => [ "solaris-common" ],
         cc               => "gcc",
-        cflags           => add_before("-Wall -DB_ENDIAN -DBN_DIV2W"),
-        debug_cflags     => "-O0 -g",
-        release_cflags   => "-O3",
+        cflags           => add_before(picker(default => "-Wall -DB_ENDIAN -DBN_DIV2W",
+                                              debug   => "-O0 -g",
+                                              release => "-O3")),
         thread_cflag     => "-pthread",
         bn_ops           => "BN_LLONG RC4_CHAR",
         shared_cflag     => "-fPIC",
         # -m32 should be safe to add as long as driver recognizes
         # -mcpu=ultrasparc
         inherit_from     => [ "solaris-sparcv7-gcc", asm("sparcv9_asm") ],
-        cflags           => add_before("-m32 -mcpu=ultrasparc"),
-        debug_cflags     => "-DBN_DEBUG -DREF_DEBUG -DCONF_DEBUG -DBN_CTX_DEBUG -DPEDANTIC -O -g -pedantic -ansi -Wshadow -Wno-long-long -D__EXTENSIONS__",
+        cflags           => add_before(picker(default => "-m32 -mcpu=ultrasparc",
+                                              debug   => "-DBN_DEBUG -DREF_DEBUG -DCONF_DEBUG -DBN_CTX_DEBUG -DPEDANTIC -O -g -pedantic -ansi -Wshadow -Wno-long-long -D__EXTENSIONS__")),
     },
     "solaris64-sparcv9-gcc" => {
         inherit_from     => [ "solaris-sparcv9-gcc" ],
     "solaris-sparcv7-cc" => {
         inherit_from     => [ "solaris-common" ],
         cc               => "cc",
-        cflags           => add_before("-xstrconst -Xa -DB_ENDIAN -DBN_DIV2W"),
-        debug_cflags     => "-g -DBN_DEBUG -DREF_DEBUG -DCONF_DEBUG -DBN_CTX_DEBUG",
-        release_cflags   => "-xO5 -xdepend",
+        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"),
     "irix-gcc" => {
         inherit_from     => [ "BASE_unix", asm("mips32_asm") ],
         cc               => "gcc",
-        cflags           => "-DB_ENDIAN",
-        debug_cflags     => "-g -O0",
-        release_cflags   => "-O3",
+        cflags           => picker(default => "-DB_ENDIAN",
+                                   debug   => "-g -O0",
+                                   release => "-O3"),
         thread_cflag     => "(unknown)",
         bn_ops           => "BN_LLONG RC4_CHAR",
         perlasm_scheme   => "o32",
     "irix-cc" => {
         inherit_from     => [ "BASE_unix", asm("mips32_asm") ],
         cc               => "cc",
-        cflags           => "-use_readonly_const -DB_ENDIAN",
-        debug_cflags     => "-g -O0",
-        release_cflags   => "-O2",
+        cflags           => picker(default => "-use_readonly_const -DB_ENDIAN",
+                                   debug   => "-g -O0",
+                                   release => "-O2"),
         thread_cflag     => "(unknown)",
         bn_ops           => "BN_LLONG RC4_CHAR",
         perlasm_scheme   => "o32",
     "irix-mips3-gcc" => {
         inherit_from     => [ "BASE_unix", asm("mips64_asm") ],
         cc               => "gcc",
-        cflags           => "-mabi=n32 -DB_ENDIAN -DBN_DIV3W",
-        debug_cflags     => "-g -O0",
-        release_cflags   => "-O3",
+        cflags           => picker(default => "-mabi=n32 -DB_ENDIAN -DBN_DIV3W",
+                                   debug   => "-g -O0",
+                                   release => "-O3"),
         thread_cflag     => "-D_SGI_MP_SOURCE -pthread",
         bn_ops           => "RC4_CHAR SIXTY_FOUR_BIT",
         perlasm_scheme   => "n32",
     "irix-mips3-cc" => {
         inherit_from     => [ "BASE_unix", asm("mips64_asm") ],
         cc               => "cc",
-        cflags           => "-n32 -mips3 -use_readonly_const -G0 -rdata_shared -DB_ENDIAN -DBN_DIV3W",
-        debug_cflags     => "-g -O0",
-        release_cflags   => "-O2",
+        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"),
         bn_ops           => "RC4_CHAR SIXTY_FOUR_BIT",
     "irix64-mips4-gcc" => {
         inherit_from     => [ "BASE_unix", asm("mips64_asm") ],
         cc               => "gcc",
-        cflags           => "-mabi=64 -mips4 -DB_ENDIAN -DBN_DIV3W",
-        debug_cflags     => "-g -O0",
-        release_cflags   => "-O3",
+        cflags           => picker(default => "-mabi=64 -mips4 -DB_ENDIAN -DBN_DIV3W",
+                                   debug   => "-g -O0",
+                                   release => "-O3"),
         thread_cflag     => "-D_SGI_MP_SOURCE",
         bn_ops           => "RC4_CHAR SIXTY_FOUR_BIT_LONG",
         perlasm_scheme   => "64",
     "irix64-mips4-cc" => {
         inherit_from     => [ "BASE_unix", asm("mips64_asm") ],
         cc               => "cc",
-        cflags           => "-64 -mips4 -use_readonly_const -G0 -rdata_shared -DB_ENDIAN -DBN_DIV3W",
-        debug_cflags     => "-g -O0",
-        release_cflags   => "-O2",
+        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"),
         bn_ops           => "RC4_CHAR SIXTY_FOUR_BIT_LONG",
     "hpux-parisc-gcc" => {
         inherit_from     => [ "BASE_unix" ],
         cc               => "gcc",
-        cflags           => "-DB_ENDIAN -DBN_DIV2W",
-        debug_cflags     => "-O0 -g",
-        release_cflags   => "-O3",
+        cflags           => picker(default => "-DB_ENDIAN -DBN_DIV2W",
+                                   debug   => "-O0 -g",
+                                   release => "-O3"),
         thread_cflag     => "-pthread",
         ex_libs          => add("-Wl,+s -ldld"),
         bn_ops           => "BN_LLONG",
     "hpux64-parisc2-gcc" => {
         inherit_from     => [ "BASE_unix", asm("parisc20_64_asm") ],
         cc               => "gcc",
-        cflags           => "-DB_ENDIAN",
-        debug_cflags     => "-O0 -g",
-        release_cflags   => "-O3",
+        cflags           => picker(default => "-DB_ENDIAN",
+                                   debug   => "-O0 -g",
+                                   release => "-O3"),
         thread_cflag     => "-D_REENTRANT",
         ex_libs          => add("-ldl"),
         bn_ops           => "SIXTY_FOUR_BIT_LONG RC4_CHAR",
     "hpux-parisc-cc" => {
         inherit_from     => [ "BASE_unix" ],
         cc               => "cc",
-        cflags           => "+Optrs_strongly_typed -Ae +ESlit -DB_ENDIAN -DBN_DIV2W -DMD32_XARRAY",
-        debug_cflags      => "+O0 +d -g",
-        release_cflags   => "+O3",
+        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"),
         bn_ops           => "RC4_CHAR",
     "hpux64-parisc2-cc" => {
         inherit_from     => [ "BASE_unix", asm("parisc20_64_asm") ],
         cc               => "cc",
-        cflags           => "+DD64 +Optrs_strongly_typed -Ae +ESlit -DB_ENDIAN -DMD32_XARRAY",
-        debug_cflags      => "+O0 +d -g",
-        release_cflags   => "+O3",
+        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"),
         bn_ops           => "SIXTY_FOUR_BIT_LONG RC4_CHAR",
     "hpux-ia64-cc" => {
         inherit_from     => [ "BASE_unix", asm("ia64_asm") ],
         cc               => "cc",
-        cflags           => "-Ae +DD32 +Olit=all -z -DB_ENDIAN",
-        debug_cflags     => "+O0 +d -g",
-        release_cflags   => "+O2",
+        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"),
         bn_ops           => "SIXTY_FOUR_BIT",
     "hpux64-ia64-cc" => {
         inherit_from     => [ "BASE_unix", asm("ia64_asm") ],
         cc               => "cc",
-        cflags           => "-Ae +DD64 +Olit=all -z -DB_ENDIAN",
-        debug_cflags     => "+O0 +d -g",
-        release_cflags   => "+O3",
+        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"),
         bn_ops           => "SIXTY_FOUR_BIT_LONG",
     "hpux-ia64-gcc" => {
         inherit_from     => [ "BASE_unix", asm("ia64_asm") ],
         cc               => "gcc",
-        cflags           => "-DB_ENDIAN",
-        debug_cflags     => "-O0 -g",
-        release_cflags   => "-O3",
+        cflags           => picker(default => "-DB_ENDIAN",
+                                   debug   => "-O0 -g",
+                                   release => "-O3"),
         thread_cflag     => "-pthread",
         ex_libs          => add("-ldl"),
         bn_ops           => "SIXTY_FOUR_BIT",
     "hpux64-ia64-gcc" => {
         inherit_from     => [ "BASE_unix", asm("ia64_asm") ],
         cc               => "gcc",
-        cflags           => "-mlp64 -DB_ENDIAN",
-        debug_cflags     => "-O0 -g",
-        release_cflags   => "-O3",
+        cflags           => picker(default => "-mlp64 -DB_ENDIAN",
+                                   debug   => "-O0 -g",
+                                   release => "-O3"),
         thread_cflag     => "-pthread",
         ex_libs          => add("-ldl"),
         bn_ops           => "SIXTY_FOUR_BIT_LONG",
     "linux-generic32" => {
         inherit_from     => [ "BASE_unix" ],
         cc               => "gcc",
-        cflags           => "-Wall",
-        debug_cflags     => "-O0 -g -DBN_DEBUG -DREF_DEBUG -DCONF_DEBUG",
-        release_cflags   => "-O3",
+        cflags           => picker(default => "-Wall",
+                                   debug   => "-O0 -g -DBN_DEBUG -DREF_DEBUG -DCONF_DEBUG",
+                                   release => "-O3"),
         thread_cflag     => "-pthread",
         ex_libs          => add("-ldl"),
         bn_ops           => "BN_LLONG RC4_CHAR",
     },
     "linux-ppc64" => {
         inherit_from     => [ "linux-generic64", asm("ppc64_asm") ],
-        cflags           => "-m64 -Wall -DB_ENDIAN",
+        cflags           => add("-m64 -DB_ENDIAN"),
         perlasm_scheme   => "linux64",
         shared_ldflag    => "-m64",
         multilib         => "64",
     },
     "linux-ppc64le" => {
         inherit_from     => [ "linux-generic64", asm("ppc64_asm") ],
-        cflags           => "-m64 -Wall -DL_ENDIAN",
+        cflags           => add("-m64 -DL_ENDIAN"),
         perlasm_scheme   => "linux64le",
         shared_ldflag    => "-m64",
     },
     },
     "linux-arm64ilp32" => {  # https://wiki.linaro.org/Platform/arm64-ilp32
         inherit_from     => [ "linux-generic32", asm("aarch64_asm") ],
-        cflags           => "-mabi=ilp32 -Wall",
+        cflags           => add("-mabi=ilp32"),
         bn_ops           => "SIXTY_FOUR_BIT RC4_CHAR",
         perlasm_scheme   => "linux64",
         shared_ldflag    => "-mabi=ilp32",
         # Configure script adds minimally required -march for assembly
         # support, if no -march was specified at command line.
         inherit_from     => [ "linux-generic32", asm("mips32_asm") ],
-        cflags           => "-mabi=32 -Wall -DBN_DIV3W",
+        cflags           => add("-mabi=32 -DBN_DIV3W"),
         perlasm_scheme   => "o32",
         shared_ldflag    => "-mabi=32",
     },
     # specifications, MIPS32 and MIPS64, rather than to kernel bitness.
     "linux-mips64" => {
         inherit_from     => [ "linux-generic32", asm("mips64_asm") ],
-        cflags           => "-mabi=n32 -Wall -DBN_DIV3W",
+        cflags           => add("-mabi=n32 -DBN_DIV3W"),
         bn_ops           => "SIXTY_FOUR_BIT RC4_CHAR",
         perlasm_scheme   => "n32",
         shared_ldflag    => "-mabi=n32",
     },
     "linux64-mips64" => {
         inherit_from     => [ "linux-generic64", asm("mips64_asm") ],
-        cflags           => "-mabi=64 -O3 -Wall -DBN_DIV3W",
+        cflags           => add("-mabi=64 -DBN_DIV3W"),
         perlasm_scheme   => "64",
         shared_ldflag    => "-mabi=64",
         multilib         => "64",
     #### IA-32 targets...
     "linux-elf" => {
         inherit_from     => [ "linux-generic32", asm("x86_elf_asm") ],
-        cc               => "gcc",
-        cflags           => "-DL_ENDIAN -Wall",
-        debug_cflags     => "-O0 -g -DBN_DEBUG -DREF_DEBUG -DCONF_DEBUG -DBN_CTX_DEBUG",
-        release_cflags   => "-O3 -fomit-frame-pointer",
-        debug_ex_libs    => "-lefence",
+        cflags           => add(picker(default => "-DL_ENDIAN",
+                                       release => "-fomit-frame-pointer")),
+        ex_libs          => add(picker(debug => "-lefence")),
         bn_ops           => "BN_LLONG",
     },
     "linux-aout" => {
         inherit_from     => [ "BASE_unix", asm("x86_asm") ],
         cc               => "gcc",
-        cflags           => "-DL_ENDIAN -Wall",
-        debug_cflags     => "-O0 -g",
-        release_cflags   => "-O3 -fomit-frame-pointer",
+        cflags           => add(picker(default => "-DL_ENDIAN -Wall",
+                                       debug   => "-O0 -g",
+                                       release => "-O3 -fomit-frame-pointer")),
         thread_cflag     => "(unknown)",
         bn_ops           => "BN_LLONG",
         perlasm_scheme   => "a.out",
 
     "linux-x86_64" => {
         inherit_from     => [ "linux-generic64", asm("x86_64_asm") ],
-        cflags           => "-m64 -DL_ENDIAN -Wall",
+        cflags           => add("-m64 -DL_ENDIAN"),
         bn_ops           => "SIXTY_FOUR_BIT_LONG",
         perlasm_scheme   => "elf",
         shared_ldflag    => "-m64",
     "linux-x86_64-clang" => {
         inherit_from     => [ "linux-x86_64" ],
         cc               => "clang",
-        cflags           => "-m64 -DL_ENDIAN -Wall -Wextra -Qunused-arguments",
+        cflags           => add("-Wextra -Qunused-arguments"),
     },
     "linux-x32" => {
         inherit_from     => [ "linux-generic32", asm("x86_64_asm") ],
-        cflags           => "-mx32 -DL_ENDIAN -Wall",
+        cflags           => add("-mx32 -DL_ENDIAN"),
         bn_ops           => "SIXTY_FOUR_BIT",
         perlasm_scheme   => "elf",
         shared_ldflag    => "-mx32",
 
     "linux64-s390x" => {
         inherit_from     => [ "linux-generic64", asm("s390x_asm") ],
-        cflags           => "-m64 -Wall -DB_ENDIAN",
+        cflags           => add("-m64 -DB_ENDIAN"),
         perlasm_scheme   => "64",
         shared_ldflag    => "-m64",
         multilib         => "64",
         # sysdeps/s390/dl-procinfo.c affecting ldconfig and ld.so.1...
         #
         inherit_from     => [ "linux-generic32", asm("s390x_asm") ],
-        cflags           => "-m31 -Wall -Wa,-mzarch -DB_ENDIAN",
+        cflags           => add("-m31 -Wa,-mzarch -DB_ENDIAN"),
         bn_obj           => sub { my $r=join(" ",@_); $r=~s/bn\-s390x/bn_asm/; $r; },
         perlasm_scheme   => "31",
         shared_ldflag    => "-m31",
     # patiently assisted with debugging of following two configs.
     "linux-sparcv8" => {
         inherit_from     => [ "linux-generic32", asm("sparcv8_asm") ],
-        cflags           => "-mcpu=v8 -Wall -DB_ENDIAN -DBN_DIV2W",
+        cflags           => add("-mcpu=v8 -DB_ENDIAN -DBN_DIV2W"),
     },
     "linux-sparcv9" => {
         # it's a real mess with -mcpu=ultrasparc option under Linux,
         # but -Wa,-Av8plus should do the trick no matter what.
         inherit_from     => [ "linux-generic32", asm("sparcv9_asm") ],
-        cflags           => "-m32 -mcpu=ultrasparc -Wall -Wa,-Av8plus -DB_ENDIAN -DBN_DIV2W",
+        cflags           => add("-m32 -mcpu=ultrasparc -Wa,-Av8plus -DB_ENDIAN -DBN_DIV2W"),
         shared_ldflag    => "-m32",
     },
     "linux64-sparcv9" => {
         # GCC 3.1 is a requirement
         inherit_from     => [ "linux-generic64", asm("sparcv9_asm") ],
-        cflags           => "-m64 -mcpu=ultrasparc -Wall -DB_ENDIAN",
+        cflags           => add("-m64 -mcpu=ultrasparc -DB_ENDIAN"),
         bn_ops           => "BN_LLONG RC4_CHAR",
         shared_ldflag    => "-m64",
         multilib         => "64",
 
     "linux-alpha-gcc" => {
         inherit_from     => [ "linux-generic64", asm("alpha_asm") ],
-        cflags           => "-DL_ENDIAN",
+        cflags           => add("-DL_ENDIAN"),
         bn_ops           => "SIXTY_FOUR_BIT_LONG",
     },
     "linux-c64xplus" => {
         # systems are perfectly capable of executing binaries targeting
         # Froyo. Keep in mind that in the nutshell Android builds are
         # about JNI, i.e. shared libraries, not applications.
-        cflags           => "-mandroid -fPIC --sysroot=\$(CROSS_SYSROOT) -Wa,--noexecstack -Wall",
-        debug_cflags     => "-O0 -g",
+        cflags           => picker(default => "-mandroid -fPIC --sysroot=\$(CROSS_SYSROOT) -Wa,--noexecstack -Wall",
+                                   debug   => "-O0 -g",
+                                   release => "-O3"),
         lflags           => "-pie",
         shared_cflag     => "",
     },
     "android-x86" => {
         inherit_from     => [ "android", asm("x86_asm") ],
-        release_cflags   => "-O3 -fomit-frame-pointer",
+        cflags           => add(picker(release => "-fomit-frame-pointer")),
         bn_ops           => "BN_LLONG",
         perlasm_scheme   => "android",
     },
 
     "android64" => {
         inherit_from     => [ "linux-generic64" ],
-        cflags           => "-mandroid -fPIC --sysroot=\$(CROSS_SYSROOT) -Wa,--noexecstack -Wall",
-        debug_cflags     => "-O0 -g",
+        cflags           => picker(default => "-mandroid -fPIC --sysroot=\$(CROSS_SYSROOT) -Wa,--noexecstack -Wall",
+                                   debug   => "-O0 -g",
+                                   release => "-O3"),
         lflags           => "-pie",
         shared_cflag     => "",
     },
         # expands it as -lc_r, which seems to be sufficient?
         inherit_from     => [ "BASE_unix" ],
         cc               => "cc",
-        cflags           => "-Wall",
-        debug_cflags     => "-O0 -g",
-        release_cflags   => "-O3",
+        cflags           => picker(default => "-Wall",
+                                   debug   => "-O0 -g",
+                                   release => "-O3"),
         thread_cflag     => "-pthread -D_THREAD_SAFE -D_REENTRANT",
         bn_ops           => "BN_LLONG",
         dso_scheme       => "dlfcn",
 
     "BSD-x86" => {
         inherit_from     => [ "BSD-generic32", asm("x86_asm") ],
-        cflags           => "-DL_ENDIAN -Wall",
-        release_cflags   => "-O3 -fomit-frame-pointer",
+        cflags           => add(picker(default => "-DL_ENDIAN",
+                                       release => "-fomit-frame-pointer")),
         bn_ops           => "BN_LLONG",
         shared_target    => "bsd-shared",
         perlasm_scheme   => "a.out",
 
     "BSD-sparcv8" => {
         inherit_from     => [ "BSD-generic32", asm("sparcv8_asm") ],
-        cflags           => "-mcpu=v8 -Wall -DB_ENDIAN",
+        cflags           => add("-mcpu=v8 -DB_ENDIAN"),
     },
     "BSD-sparc64" => {
         # -DMD32_REG_T=int doesn't actually belong in sparc64 target, it
         # simply *happens* to work around a compiler bug in gcc 3.3.3,
         # triggered by RIPEMD160 code.
         inherit_from     => [ "BSD-generic64", asm("sparcv9_asm") ],
-        cflags           => "-DB_ENDIAN -DMD32_REG_T=int -Wall",
+        cflags           => add("-DB_ENDIAN -DMD32_REG_T=int"),
         bn_ops           => "BN_LLONG",
     },
 
     "BSD-ia64" => {
         inherit_from     => [ "BSD-generic64", asm("ia64_asm") ],
-        cflags           => "-DL_ENDIAN -Wall",
+        cflags           => add_before("-DL_ENDIAN"),
         bn_ops           => "SIXTY_FOUR_BIT_LONG",
     },
 
     "BSD-x86_64" => {
         inherit_from     => [ "BSD-generic64", asm("x86_64_asm") ],
-        cflags           => "-DL_ENDIAN -Wall",
+        cflags           => add_before("-DL_ENDIAN"),
         bn_ops           => "SIXTY_FOUR_BIT_LONG",
         perlasm_scheme   => "elf",
     },
     "aix-gcc" => {
         inherit_from     => [ "BASE_unix", asm("ppc32_asm") ],
         cc               => "gcc",
-        cflags           => "-DB_ENDIAN",
-        debug_cflags     => "-O0 -g",
-        release_cflags   => "-O",
+        cflags           => picker(default => "-DB_ENDIAN",
+                                   debug   => "-O0 -g",
+                                   release => "-O"),
         thread_cflag     => "-pthread",
         sys_id           => "AIX",
         bn_ops           => "BN_LLONG RC4_CHAR",
     "aix64-gcc" => {
         inherit_from     => [ "BASE_unix", asm("ppc64_asm") ],
         cc               => "gcc",
-        cflags           => "-maix64 -DB_ENDIAN",
-        debug_cflags     => "-O0 -g",
-        release_cflags   => "-O",
+        cflags           => picker(default => "-maix64 -DB_ENDIAN",
+                                   debug   => "-O0 -g",
+                                   release => "-O"),
         thread_cflag     => "-pthread",
         sys_id           => "AIX",
         bn_ops           => "SIXTY_FOUR_BIT_LONG RC4_CHAR",
     "aix-cc" => {
         inherit_from     => [ "BASE_unix", asm("ppc32_asm") ],
         cc               => "cc",
-        cflags           => "-q32 -DB_ENDIAN -qmaxmem=16384 -qro -qroconst",
-        debug_cflags     => "",
-        release_cflags   => "-O",
+        cflags           => picker(default => "-q32 -DB_ENDIAN -qmaxmem=16384 -qro -qroconst",
+                                   debug   => "-O0 -g",
+                                   release => "-O"),
         thread_cflag     => "-qthreaded -D_THREAD_SAFE",
         sys_id           => "AIX",
         bn_ops           => "BN_LLONG RC4_CHAR",
     "aix64-cc" => {
         inherit_from     => [ "BASE_unix", asm("ppc64_asm") ],
         cc               => "cc",
-        cflags           => "-q64 -DB_ENDIAN -qmaxmem=16384 -qro -qroconst",
-        debug_cflags     => "",
-        release_cflags   => "-O",
+        cflags           => picker(default => "-q64 -DB_ENDIAN -qmaxmem=16384 -qro -qroconst",
+                                   debug   => "-O0 -g",
+                                   release => "-O"),
         thread_cflag     => "-qthreaded -D_THREAD_SAFE",
         sys_id           => "AIX",
         bn_ops           => "SIXTY_FOUR_BIT_LONG RC4_CHAR",
         inherit_from     => [ "BASE_unix", asm("x86_asm"),
                               sub { $disabled{shared} ? () : "x86_uplink" } ],
         cc               => "gcc",
-        cflags           => "-DL_ENDIAN -DWIN32_LEAN_AND_MEAN -DUNICODE -D_UNICODE -m32 -Wall",
-        debug_cflags     => "-g -O0",
-        release_cflags   => "-O3 -fomit-frame-pointer",
+        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",
         sys_id           => "MINGW32",
         ex_libs          => add("-lws2_32 -lgdi32 -lcrypt32"),
         # Applink is never engaged and can as well be omitted.
         inherit_from     => [ "BASE_unix", asm("x86_64_asm") ],
         cc               => "gcc",
-        cflags           => "-DL_ENDIAN -DWIN32_LEAN_AND_MEAN -DUNICODE -D_UNICODE -m64 -Wall",
-        debug_cflags     => "-g -O0",
-        release_cflags   => "-O3",
+        cflags           => picker(default => "-DL_ENDIAN -DWIN32_LEAN_AND_MEAN -DUNICODE -D_UNICODE -m64 -Wall",
+                                   debug   => "-g -O0",
+                                   release => "-O3"),
         thread_cflag     => "-D_MT",
         sys_id           => "MINGW64",
         ex_libs          => add("-lws2_32 -lgdi32 -lcrypt32"),
     "Cygwin-x86" => {
         inherit_from     => [ "BASE_unix", asm("x86_asm") ],
         cc               => "gcc",
-        cflags           => "-DTERMIOS -DL_ENDIAN -Wall",
-        debug_cflags     => "-g -O0",
-        release_cflags   => "-O3 -fomit-frame-pointer",
+        cflags           => picker(default => "-DTERMIOS -DL_ENDIAN -Wall",
+                                   debug   => "-g -O0",
+                                   release => "-O3 -fomit-frame-pointer"),
         sys_id           => "CYGWIN",
         bn_ops           => "BN_LLONG",
         perlasm_scheme   => "coff",
     "Cygwin-x86_64" => {
         inherit_from     => [ "BASE_unix", asm("x86_64_asm") ],
         cc               => "gcc",
-        cflags           => "-DTERMIOS -DL_ENDIAN -Wall",
-        debug_cflags     => "-g -O0",
-        release_cflags   => "-O3",
+        cflags           => picker(default => "-DTERMIOS -DL_ENDIAN -Wall",
+                                   debug   => "-g -O0",
+                                   release => "-O3"),
         sys_id           => "CYGWIN",
         bn_ops           => "SIXTY_FOUR_BIT_LONG",
         perlasm_scheme   => "mingw64",
         inherit_from     => [ "BASE_unix" ],
         template         => 1,
         cc               => "cc",
-        cflags           => "",
-        debug_cflags     => "-g -O0",
-        release_cflags   => "-O3",
+        cflags           => picker(default => "",
+                                   debug   => "-g -O0",
+                                   release => "-O3"),
         thread_cflag     => "-D_REENTRANT",
         sys_id           => "MACOSX",
         plib_lflags      => "-Wl,-search_paths_first",
     },
     "darwin-ppc-cc" => {
         inherit_from     => [ "darwin-common", asm("ppc32_asm") ],
-        cflags           => "-arch ppc -DB_ENDIAN -Wa,-force_cpusubtype_ALL",
+        cflags           => add("-arch ppc -DB_ENDIAN -Wa,-force_cpusubtype_ALL"),
         perlasm_scheme   => "osx32",
         shared_ldflag    => "-arch ppc -dynamiclib",
     },
     "darwin64-ppc-cc" => {
         inherit_from     => [ "darwin-common", asm("ppc64_asm") ],
-        cflags           => "-arch ppc64 -DB_ENDIAN",
+        cflags           => add("-arch ppc64 -DB_ENDIAN"),
         bn_ops           => "SIXTY_FOUR_BIT_LONG RC4_CHAR",
         perlasm_scheme   => "osx64",
         shared_ldflag    => "-arch ppc64 -dynamiclib",
     },
     "darwin-i386-cc" => {
         inherit_from     => [ "darwin-common", asm("x86_asm") ],
-        cflags           => "-arch i386 -DL_ENDIAN",
-        release_cflags   => "-O3 -fomit-frame-pointer",
+        cflags           => add(picker(default => "-arch i386 -DL_ENDIAN",
+                                       release => "-fomit-frame-pointer")),
         bn_ops           => "BN_LLONG RC4_INT",
         perlasm_scheme   => "macosx",
         shared_ldflag    => "-arch i386 -dynamiclib",
     },
     "darwin64-x86_64-cc" => {
         inherit_from     => [ "darwin-common", asm("x86_64_asm") ],
-        cflags           => "-arch x86_64 -DL_ENDIAN -Wall",
+        cflags           => add("-arch x86_64 -DL_ENDIAN -Wall"),
         bn_ops           => "SIXTY_FOUR_BIT_LONG",
         perlasm_scheme   => "macosx",
         shared_ldflag    => "-arch x86_64 -dynamiclib",
 #
     "iphoneos-cross" => {
         inherit_from     => [ "darwin-common" ],
-        cflags           => "-isysroot \$(CROSS_TOP)/SDKs/\$(CROSS_SDK) -fno-common",
+        cflags           => add("-isysroot \$(CROSS_TOP)/SDKs/\$(CROSS_SDK) -fno-common"),
         sys_id           => "iOS",
     },
     "ios-cross" => {
         # It should be possible to go below iOS 6 and even add -arch armv6,
         # thus targeting iPhone pre-3GS, but it's assumed to be irrelevant
         # at this point.
-        cflags           => "-arch armv7 -mios-version-min=6.0.0 -isysroot \$(CROSS_TOP)/SDKs/\$(CROSS_SDK) -fno-common",
+        cflags           => add("-arch armv7 -mios-version-min=6.0.0 -isysroot \$(CROSS_TOP)/SDKs/\$(CROSS_SDK) -fno-common"),
         sys_id           => "iOS",
         perlasm_scheme   => "ios32",
     },
     "ios64-cross" => {
         inherit_from     => [ "darwin-common", asm("aarch64_asm") ],
-        cflags           => "-arch arm64 -mios-version-min=7.0.0 -isysroot \$(CROSS_TOP)/SDKs/\$(CROSS_SDK) -fno-common",
+        cflags           => add("-arch arm64 -mios-version-min=7.0.0 -isysroot \$(CROSS_TOP)/SDKs/\$(CROSS_SDK) -fno-common"),
         sys_id           => "iOS",
         bn_ops           => "SIXTY_FOUR_BIT_LONG RC4_CHAR",
         perlasm_scheme   => "ios64",
         inherit_from     => [ "BASE_VMS" ],
         template         => 1,
         cc               => "CC/DECC",
-        cflags           => "/STANDARD=RELAXED/NOLIST/PREFIX=ALL/NAMES=(AS_IS,SHORTENED)",
-        debug_cflags     => "/NOOPTIMIZE/DEBUG",
-        release_cflags   => "/OPTIMIZE/NODEBUG",
-        lflags           => "/MAP",
-        debug_lflags     => "/DEBUG/TRACEBACK",
-        release_lflags   => "/NODEBUG/NOTRACEBACK",
+        cflags           => picker(default => "/STANDARD=RELAXED/NOLIST/PREFIX=ALL/NAMES=(AS_IS,SHORTENED)",
+                                   debug   => "/NOOPTIMIZE/DEBUG",
+                                   release => "/OPTIMIZE/NODEBUG"),
+        lflags           => picker(default => "/MAP",
+                                   debug   => "/DEBUG/TRACEBACK",
+                                   release => "/NODEBUG/NOTRACEBACK"),
         shared_target    => "vms-shared",
 
         apps_aux_src     => "vms_decc_init.c",
index 9db343e..d1ddf2e 100644 (file)
@@ -1,18 +1,26 @@
 ## -*- mode: perl; -*-
 ## Personal configuration targets
 
+sub picker {
+    my %opts = @_;
+    return sub { add($opts{default} || (),
+                     $opts{$config{build_type}} || ())->(); }
+}
+
 %targets = (
     "levitte-linux-elf" => {
         inherit_from     => [ "linux-elf" ],
-        debug_cflags     => add("-ggdb -g3"),
-        debug_defines    => add("LEVITTE_DEBUG", { separator => undef }),
+        cflags           => add(picker(debug => "-ggdb -g3")),
+        defines          => add(picker(debug => "LEVITTE_DEBUG"),
+                                { separator => undef }),
         build_scheme     => [ "unified", "unix" ],
         build_file       => "Makefile",
     },
     "levitte-linux-x86_64" => {
         inherit_from     => [ "linux-x86_64" ],
-        debug_cflags     => add("-ggdb -g3"),
-        debug_defines    => add("LEVITTE_DEBUG", { separator => undef }),
+        cflags           => add(picker(debug => "-ggdb -g3")),
+        defines          => add(picker(debug => "LEVITTE_DEBUG"),
+                                { separator => undef }),
         build_scheme     => [ "unified", "unix" ],
         build_file       => "Makefile",
     },
index 15b763c..eab3c66 100755 (executable)
--- a/Configure
+++ b/Configure
@@ -438,7 +438,7 @@ $config{openssl_other_defines}=[];
 my $libs="";
 my $target="";
 $config{options}="";
-my $build_prefix = "release_";
+$config{build_type} = "release";
 
 my @argvcopy=@ARGV;
 
@@ -591,11 +591,11 @@ foreach (@argvcopy)
                }
        elsif (/^--debug$/)
                {
-               $build_prefix = "debug_";
+               $config{build_type} = "debug";
                }
        elsif (/^--release$/)
                {
-               $build_prefix = "release_";
+               $config{build_type} = "release";
                }
        elsif (/^386$/)
                { $config{processor}=386; }
@@ -826,7 +826,7 @@ print "Configuring for $target\n";
 # Support for legacy targets having a name starting with 'debug-'
 my ($d, $t) = $target =~ m/^(debug-)?(.*)$/;
 if ($d) {
-    $build_prefix = "debug_";
+    $config{build_type} = "debug";
 
     # If we do not find debug-foo in the table, the target is set to foo.
     if (!$table{$target}) {
@@ -866,14 +866,9 @@ $target{nm} =      $ENV{'NM'}      || $target{nm}      || "nm";
 # For cflags, lflags, plib_lflags, ex_libs and defines, add the debug_
 # or release_ attributes.
 # Do it in such a way that no spurious space is appended (hence the grep).
-$config{defines} = [ @{$target{defines}},
-                     @{$target{$build_prefix."defines"}} ];
-$config{cflags} = join(" ",
-                      grep { $_ ne "" } ($target{cflags},
-                                         $target{$build_prefix."cflags"}));
-$config{ex_libs} = join(" ",
-                       grep { $_  ne "" } ($target{ex_libs},
-                                           $target{$build_prefix."ex_libs"}));
+$config{defines} = $target{defines} || [];
+$config{cflags} = $target{cflags} || "";
+$config{ex_libs} = $target{ex_libs} || "";
 
 # Make sure build_scheme is consistent.
 $target{build_scheme} = [ $target{build_scheme} ]
@@ -2172,22 +2167,12 @@ sub print_table_entry
        "cc",
        "cflags",
        "defines",
-       "debug_cflags",
-       "debug_defines",
-       "release_cflags",
-       "release_defines",
        "thread_cflag",
        "unistd",
        "ld",
        "lflags",
        "plib_lflags",
        "ex_libs",
-       "debug_lflags",
-       "debug_plib_lflags",
-       "debug_ex_libs",
-       "release_lflags",
-       "release_plib_lflags",
-       "release_ex_libs",
        "bn_ops",
        "cpuid_obj",
        "bn_obj",