Configure - neater looking add() and add_before()
authorRichard Levitte <levitte@openssl.org>
Wed, 24 Feb 2016 23:17:59 +0000 (00:17 +0100)
committerRichard Levitte <levitte@openssl.org>
Fri, 26 Feb 2016 08:00:25 +0000 (09:00 +0100)
They now default to " " as separator, but that can be overridden by
having a hash with parameters as last argument.  The only currently
recognised parameter is `separator'.

The special separator `undef' will force the result to become a list
rather than a concatenated string.

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

index 791634f..7a20867 100644 (file)
 
     uplink_common => {
        template        => 1,
-       apps_aux_src    => add(" ","../ms/applink.c"),
-       cpuid_asm_src   => add(" ","../ms/uplink.c"),
-       shared_defines  => add(undef, "OPENSSL_USE_APPLINK"),
+       apps_aux_src    => add("../ms/applink.c"),
+       cpuid_asm_src   => add("../ms/uplink.c"),
+       shared_defines  => add("OPENSSL_USE_APPLINK", { separator => undef }),
     },
     x86_uplink => {
        inherit_from    => [ "uplink_common" ],
        template        => 1,
-       cpuid_asm_src   => add(" ","uplink-x86.s"),
+       cpuid_asm_src   => add("uplink-x86.s"),
     },
     x86_64_uplink => {
        inherit_from    => [ "uplink_common" ],
        template        => 1,
-       cpuid_asm_src   => add(" ","uplink-x86_64.s"),
+       cpuid_asm_src   => add("uplink-x86_64.s"),
     },
     ia64_uplink => {
        inherit_from    => [ "uplink_common" ],
        template        => 1,
-       cpuid_asm_src   => add(" ","uplink-ia64.s"),
+       cpuid_asm_src   => add("uplink-ia64.s"),
     },
 
     x86_asm => {
     mips64_asm => {
        inherit_from    => [ "mips32_asm" ],
        template        => 1,
-       sha1_asm_src    => add(" ", "sha512-mips.S")
+       sha1_asm_src    => add("sha512-mips.S")
     },
     s390x_asm => {
        template        => 1,
index 930bef4..41d71b5 100644 (file)
@@ -53,7 +53,7 @@
         # 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"),
+        cflags           => add_before("-Wall -DL_ENDIAN -DOPENSSL_NO_INLINE_ASM"),
         debug_cflags     => "-O0 -g",
         release_cflags   => "-O3 -fomit-frame-pointer",
         thread_cflag     => "-pthread",
@@ -72,7 +72,7 @@
         #                                      <appro@fy.chalmers.se>
         inherit_from     => [ "solaris-common", asm("x86_64_asm") ],
         cc               => "gcc",
-        cflags           => add_before(" ", "-m64 -Wall -DL_ENDIAN"),
+        cflags           => add_before("-m64 -Wall -DL_ENDIAN"),
         debug_cflags     => "-O0 -g",
         release_cflags   => "-O3",
         thread_cflag     => "-pthread",
     "solaris-x86-cc" => {
         inherit_from     => [ "solaris-common" ],
         cc               => "cc",
-        cflags           => add_before(" ", "-xarch=generic -xstrconst -Xa -DL_ENDIAN"),
+        cflags           => add_before("-xarch=generic -xstrconst -Xa -DL_ENDIAN"),
         debug_cflags     => "-g",
         release_cflags   => "-xO5 -xregs=frameptr -xdepend -xbuiltin",
         thread_cflag     => "-D_REENTRANT",
-        lflags           => add(" ", "-mt"),
-        ex_libs          => add(" ", "-lpthread"),
+        lflags           => add("-mt"),
+        ex_libs          => add("-lpthread"),
         bn_ops           => "BN_LLONG RC4_CHAR",
         shared_cflag     => "-KPIC",
         shared_ldflag    => "-G -dy -z text",
     "solaris64-x86_64-cc" => {
         inherit_from     => [ "solaris-common", asm("x86_64_asm") ],
         cc               => "cc",
-        cflags           => add_before(" ", "-xarch=generic64 -xstrconst -Xa -DL_ENDIAN"),
+        cflags           => add_before("-xarch=generic64 -xstrconst -Xa -DL_ENDIAN"),
         debug_cflags     => "-g",
         release_cflags   => "-xO5 -xdepend -xbuiltin",
         thread_cflag     => "-D_REENTRANT",
-        lflags           => add(" ", "-mt"),
-        ex_libs          => add(" ", "-lpthread"),
+        lflags           => add("-mt"),
+        ex_libs          => add("-lpthread"),
         bn_ops           => "SIXTY_FOUR_BIT_LONG",
         perlasm_scheme   => "elf",
         shared_cflag     => "-KPIC",
     "solaris-sparcv7-gcc" => {
         inherit_from     => [ "solaris-common" ],
         cc               => "gcc",
-        cflags           => add_before(" ", "-Wall -DB_ENDIAN -DBN_DIV2W"),
+        cflags           => add_before("-Wall -DB_ENDIAN -DBN_DIV2W"),
         debug_cflags     => "-O0 -g",
         release_cflags   => "-O3",
         thread_cflag     => "-pthread",
     },
     "solaris-sparcv8-gcc" => {
         inherit_from     => [ "solaris-sparcv7-gcc", asm("sparcv8_asm") ],
-        cflags           => add_before(" ", "-mcpu=v8"),
+        cflags           => add_before("-mcpu=v8"),
     },
     "solaris-sparcv9-gcc" => {
         # -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"),
+        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__",
     },
     "solaris64-sparcv9-gcc" => {
     "solaris-sparcv7-cc" => {
         inherit_from     => [ "solaris-common" ],
         cc               => "cc",
-        cflags           => add_before(" ", "-xstrconst -Xa -DB_ENDIAN -DBN_DIV2W"),
+        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",
         thread_cflag     => "-D_REENTRANT",
-        lflags           => add(" ", "-mt"),
-        ex_libs          => add(" ", "-lpthread"),
+        lflags           => add("-mt"),
+        ex_libs          => add("-lpthread"),
         bn_ops           => "BN_LLONG RC4_CHAR",
         shared_cflag     => "-KPIC",
         shared_ldflag    => "-G -dy -z text",
 ####
     "solaris-sparcv8-cc" => {
         inherit_from     => [ "solaris-sparcv7-cc", asm("sparcv8_asm") ],
-        cflags           => add_before(" ", "-xarch=v8"),
+        cflags           => add_before("-xarch=v8"),
     },
     "solaris-sparcv9-cc" => {
         inherit_from     => [ "solaris-sparcv7-cc", asm("sparcv9_asm") ],
-        cflags           => add_before(" ", "-xarch=v8plus -xtarget=ultra"),
+        cflags           => add_before("-xarch=v8plus -xtarget=ultra"),
     },
     "solaris64-sparcv9-cc" => {
         inherit_from     => [ "solaris-sparcv7-cc", asm("sparcv9_asm") ],
-        cflags           => add_before(" ", "-xarch=v9 -xtarget=ultra"),
+        cflags           => add_before("-xarch=v9 -xtarget=ultra"),
         bn_ops           => "BN_LLONG RC4_CHAR",
         shared_ldflag    => "-xarch=v9 -G -dy -z text",
         multilib         => "/64",
     },
     "hpux-parisc1_1-cc" => {
         inherit_from     => [ "hpux-parisc-cc", asm("parisc11_asm") ],
-        cflags           => add_before(" ", "+DA1.1"),
+        cflags           => add_before("+DA1.1"),
         multilib         => "/pa1.1",
     },
     "hpux64-parisc2-cc" => {
     },
     "VC-WIN64I" => {
         inherit_from     => [ "VC-common", asm("ia64_asm") ],
-        cflags           => add(" ", "-DUNICODE -D_UNICODE"),
+        cflags           => add("-DUNICODE -D_UNICODE"),
         sys_id           => "WIN64I",
         bn_ops           => "SIXTY_FOUR_BIT EXPORT_VAR_AS_FN",
         bn_obj           => sub { my $r=join(" ",@_); $r=~s/bn\-//; $r; },
     },
     "VC-WIN64A" => {
         inherit_from     => [ "VC-common", asm("x86_64_asm") ],
-        cflags           => add(" ", "-DUNICODE -D_UNICODE"),
+        cflags           => add("-DUNICODE -D_UNICODE"),
         sys_id           => "WIN64A",
         bn_ops           => "SIXTY_FOUR_BIT EXPORT_VAR_AS_FN",
         bn_obj           => sub { my $r=join(" ",@_); $r=~s/x86_64\-gcc/bn_asm/; $r; },
         perlasm_scheme   => "coff",
         dso_scheme       => "win32",
         shared_target    => "mingw-shared",
-        shared_cflag     => add(" ", "-D_WINDLL"),
+        shared_cflag     => add("-D_WINDLL"),
         shared_ldflag    => "-static-libgcc",
         shared_rcflag    => "--target=pe-i386",
         shared_extension => ".dll",
         perlasm_scheme   => "mingw64",
         dso_scheme       => "win32",
         shared_target    => "mingw-shared",
-        shared_cflag     => add(" ", "-D_WINDLL"),
+        shared_cflag     => add("-D_WINDLL"),
         shared_ldflag    => "-static-libgcc",
         shared_rcflag    => "--target=pe-x86-64",
         shared_extension => ".dll",
     },
     "vms-alpha-P32" => {
        inherit_from     => [ "vms-alpha" ],
-       cflags           => add(" ", "/POINTER_SIZE=32"),
+       cflags           => add("/POINTER_SIZE=32"),
     },
     "vms-alpha-P64" => {
        inherit_from     => [ "vms-alpha" ],
-       cflags           => add(" ", "/POINTER_SIZE=64"),
+       cflags           => add("/POINTER_SIZE=64"),
     },
     "vms-ia64" => {
         inherit_from     => [ "vms-generic" ],
     },
     "vms-ia64-P32" => {
        inherit_from     => [ "vms-ia64" ],
-       cflags           => add(" ", "/POINTER_SIZE=32"),
+       cflags           => add("/POINTER_SIZE=32"),
     },
     "vms-ia64-P64" => {
        inherit_from     => [ "vms-ia64" ],
-       cflags           => add(" ", "/POINTER_SIZE=64"),
+       cflags           => add("/POINTER_SIZE=64"),
     },
 
 );
index a1b92d0..d13f167 100644 (file)
@@ -8,15 +8,15 @@
 %targets = (
     "levitte-linux-elf" => {
         inherit_from     => [ "linux-elf" ],
-        debug_cflags     => add(" ", "-ggdb -g3"),
-        debug_defines    => add(undef, "LEVITTE_DEBUG"),
+        debug_cflags     => add("-ggdb -g3"),
+        debug_defines    => add("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(undef, "LEVITTE_DEBUG"),
+        debug_cflags     => add("-ggdb -g3"),
+        debug_defines    => add("LEVITTE_DEBUG", { separator => undef }),
         build_scheme     => [ "unified", "unix" ],
         build_file       => "Makefile",
     },
index b6c8d8c..ad20bf6 100755 (executable)
--- a/Configure
+++ b/Configure
@@ -1970,12 +1970,20 @@ sub _add {
     }
 }
 sub add_before {
-    my $separator = shift;
+    my $separator = " ";
+    if (ref($_[$#_]) eq "HASH") {
+        my $opts = pop;
+        $separator = $opts->{separator};
+    }
     my @x = @_;
     sub { _add($separator, @x, @_) };
 }
 sub add {
-    my $separator = shift;
+    my $separator = " ";
+    if (ref($_[$#_]) eq "HASH") {
+        my $opts = pop;
+        $separator = $opts->{separator};
+    }
     my @x = @_;
     sub { _add($separator, @_, @x) };
 }