From bdcd83e1272c84f3de576f793ba03fdc2c21a557 Mon Sep 17 00:00:00 2001 From: Richard Levitte Date: Thu, 25 Feb 2016 00:17:59 +0100 Subject: [PATCH] Configure - neater looking add() and add_before() 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 --- Configurations/00-base-templates.conf | 14 +++---- Configurations/10-main.conf | 52 ++++++++++++------------- Configurations/99-personal-levitte.conf | 8 ++-- Configure | 12 +++++- 4 files changed, 47 insertions(+), 39 deletions(-) diff --git a/Configurations/00-base-templates.conf b/Configurations/00-base-templates.conf index 791634f352..7a208676ea 100644 --- a/Configurations/00-base-templates.conf +++ b/Configurations/00-base-templates.conf @@ -44,24 +44,24 @@ 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 => { @@ -155,7 +155,7 @@ 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, diff --git a/Configurations/10-main.conf b/Configurations/10-main.conf index 930bef4c2e..41d71b57f0 100644 --- a/Configurations/10-main.conf +++ b/Configurations/10-main.conf @@ -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 @@ # 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", @@ -87,12 +87,12 @@ "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", @@ -100,12 +100,12 @@ "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", @@ -117,7 +117,7 @@ "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", @@ -127,13 +127,13 @@ }, "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" => { @@ -151,12 +151,12 @@ "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", @@ -164,15 +164,15 @@ #### "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", @@ -356,7 +356,7 @@ }, "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" => { @@ -1113,7 +1113,7 @@ }, "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; }, @@ -1123,7 +1123,7 @@ }, "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; }, @@ -1171,7 +1171,7 @@ 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", @@ -1198,7 +1198,7 @@ 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", @@ -1564,11 +1564,11 @@ }, "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" ], @@ -1579,11 +1579,11 @@ }, "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"), }, ); diff --git a/Configurations/99-personal-levitte.conf b/Configurations/99-personal-levitte.conf index a1b92d0729..d13f167234 100644 --- a/Configurations/99-personal-levitte.conf +++ b/Configurations/99-personal-levitte.conf @@ -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", }, diff --git a/Configure b/Configure index b6c8d8ce6c..ad20bf6288 100755 --- 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) }; }