From 2952b9b8115bdd852fb226e918f8b6d6a4a0bea2 Mon Sep 17 00:00:00 2001 From: Richard Levitte Date: Wed, 2 Mar 2016 10:57:05 +0100 Subject: [PATCH] Don't copy from %target to %config so much, see %config as a complement We copied $target{cflags}, $target{defines} and a few more to %config, just to add to the entries. Avoid doing so, and let the build templates deal with combining the two. There are a few cases where we still fiddle with %target, but that's acceptable. Reviewed-by: Andy Polyakov --- Configurations/descrip.mms.tmpl | 4 ++-- Configurations/unix-Makefile.tmpl | 6 +++--- Configure | 32 ++++++++++++++++--------------- Makefile.in | 6 +++--- 4 files changed, 25 insertions(+), 23 deletions(-) diff --git a/Configurations/descrip.mms.tmpl b/Configurations/descrip.mms.tmpl index a35e3ced61..ef59d425e4 100644 --- a/Configurations/descrip.mms.tmpl +++ b/Configurations/descrip.mms.tmpl @@ -126,10 +126,10 @@ OPENSSLDIR={- catdir($config{openssldir}) || ENGINESDIR={- $osslprefix -}ENGINES: CC= {- $target{cc} -} -CFLAGS= /DEFINE=({- join(",", @{$config{defines}},"OPENSSLDIR=\"\"\"\$(OPENSSLDIR)\"\"\"","ENGINESDIR=\"\"\"\$(ENGINESDIR)\"\"\"") -}) {- $config{cflags} -} +CFLAGS= /DEFINE=({- join(",", @{$target{defines}}, @{$config{defines}},"OPENSSLDIR=\"\"\"\$(OPENSSLDIR)\"\"\"","ENGINESDIR=\"\"\"\$(ENGINESDIR)\"\"\"") -}) {- $target{cflags} -} {- $config{cflags} -} DEPFLAG= /DEFINE=({- join(",", @{$config{depdefines}}) -}) LDFLAGS= {- $target{lflags} -} -EX_LIBS= {- $config{ex_libs} ? ",".$config{ex_libs} : "" -} +EX_LIBS= {- $target{ex_libs} ? ",".$target{ex_libs} : "" -}{- $config{ex_libs} ? ",".$config{ex_libs} : "" -} PERL={- $config{perl} -} diff --git a/Configurations/unix-Makefile.tmpl b/Configurations/unix-Makefile.tmpl index 7deafd655a..8ccadbb215 100644 --- a/Configurations/unix-Makefile.tmpl +++ b/Configurations/unix-Makefile.tmpl @@ -144,13 +144,13 @@ HTMLSUFFIX=html CROSS_COMPILE= {- $config{cross_compile_prefix} -} CC= $(CROSS_COMPILE){- $target{cc} -} -CFLAGS={- our $cflags2 = join(" ",(map { "-D".$_} @{$config{defines}}),"-DOPENSSLDIR=\"\\\"\$(OPENSSLDIR)\\\"\"","-DENGINESDIR=\"\\\"\$(ENGINESDIR)\\\"\"") -} {- $config{cflags} -} +CFLAGS={- our $cflags2 = join(" ",(map { "-D".$_} @{$target{defines}}, @{$config{defines}}),"-DOPENSSLDIR=\"\\\"\$(OPENSSLDIR)\\\"\"","-DENGINESDIR=\"\\\"\$(ENGINESDIR)\\\"\"") -} {- $target{cflags} -} {- $config{cflags} -} CFLAGS_Q={- $cflags2 =~ s|([\\"])|\\$1|g; $cflags2 -} {- $config{cflags} -} LDFLAGS= {- $target{lflags} -} PLIB_LDFLAGS= {- $target{plib_lflags} -} -EX_LIBS= {- $config{ex_libs} -} +EX_LIBS= {- $target{ex_libs} -} {- $config{ex_libs} -} SHARED_CFLAGS={- $target{shared_cflag} || "" -} -SHARED_LDFLAGS={- $target{shared_ldflag} +SHARED_LDFLAGS={- $target{shared_ldflag}." ".$config{shared_ldflag} # Unlike other OSes (like Solaris, Linux, Tru64, # IRIX) BSD run-time linkers (tested OpenBSD, NetBSD # and FreeBSD) "demand" RPATH set on .so objects. diff --git a/Configure b/Configure index c1a3f8a26e..28339f1dae 100755 --- a/Configure +++ b/Configure @@ -869,9 +869,10 @@ $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} || []; -$config{cflags} = $target{cflags} || ""; -$config{ex_libs} = $target{ex_libs} || ""; +$config{defines} = []; +$config{cflags} = ""; +$config{ex_libs} = ""; +$config{shared_ldflag} = ""; # Make sure build_scheme is consistent. $target{build_scheme} = [ $target{build_scheme} ] @@ -893,7 +894,7 @@ my ($builder, $builder_platform, @builder_opts) = if ($target =~ /^mingw/ && `$target{cc} --target-help 2>&1` =~ m/-mno-cygwin/m) { $config{cflags} .= " -mno-cygwin"; - $target{shared_ldflag} .= " -mno-cygwin"; + $config{shared_ldflag} .= " -mno-cygwin"; } if ($target =~ /linux.*-mips/ && !$disabled{asm} && $user_cflags !~ /-m(ips|arch=)/) { @@ -917,17 +918,15 @@ if (!$disabled{dso} && $target{dso_scheme} ne "") $target{dso_scheme} =~ tr/[a-z]/[A-Z]/; if ($target{dso_scheme} eq "DLFCN") { - $config{defines} = [ "DSO_DLFCN", "HAVE_DLFCN_H", - @{$config{defines}} ] + unshift @{$config{defines}}, "DSO_DLFCN", "HAVE_DLFCN_H"; } elsif ($target{dso_scheme} eq "DLFCN_NO_H") { - $config{defines} = [ "DSO_DLFCN", @{$config{defines}} ] + unshift @{$config{defines}}, "DSO_DLFCN"; } else { - $config{defines} = [ "DSO_$target{dso_scheme}", - @{$config{defines}} ] + unshift @{$config{defines}}, "DSO_$target{dso_scheme}"; } } @@ -935,8 +934,11 @@ $config{ex_libs}="$libs$config{ex_libs}" if ($libs ne ""); if ($disabled{asm}) { - @{$config{defines}} = grep !/^[BL]_ENDIAN$/, @{$config{defines}} - if ($config{fips}); + if ($config{fips}) + { + @{$config{defines}} = grep !/^[BL]_ENDIAN$/, @{$config{defines}}; + @{$target{defines}} = grep !/^[BL]_ENDIAN$/, @{$target{defines}}; + } } # If threads aren't disabled, check how possible they are @@ -1057,7 +1059,7 @@ unless ($disabled{asm}) { if ($config{processor} eq "386") { $target{wp_asm_src}=$table{DEFAULTS}->{wp_asm_src}; } elsif (!$disabled{"whirlpool"}) { - $config{cflags}.=" -DWHIRLPOOL_ASM"; + push @{$config{defines}}, "WHIRLPOOL_ASM"; } } if ($target{modes_asm_src} =~ /ghash-/) { @@ -1671,11 +1673,11 @@ close(OUT); print "IsMK1MF =", ($builder eq "mk1mf" ? "yes" : "no"), "\n"; print "CC =$target{cc}\n"; -print "CFLAG =$config{cflags}\n"; -print "DEFINES =",join(" ", @{$config{defines}}),"\n"; +print "CFLAG =$target{cflags} $config{cflags}\n"; +print "DEFINES =",join(" ", @{$target{defines}}, @{$config{defines}}),"\n"; print "LFLAG =$target{lflags}\n"; print "PLIB_LFLAG =$target{plib_lflags}\n"; -print "EX_LIBS =$config{ex_libs}\n"; +print "EX_LIBS =$target{ex_libs} $config{ex_libs}\n"; print "APPS_OBJ =$target{apps_obj}\n"; print "CPUID_OBJ =$target{cpuid_obj}\n"; print "UPLINK_OBJ =$target{uplink_obj}\n"; diff --git a/Makefile.in b/Makefile.in index bddbfdbce8..4286eb9dbc 100644 --- a/Makefile.in +++ b/Makefile.in @@ -93,11 +93,11 @@ ENGINESDIR={- use File::Spec::Functions; CROSS_COMPILE= {- $config{cross_compile_prefix} -} CC= $(CROSS_COMPILE){- $target{cc} -} -CFLAG={- our $cflags2 = join(" ",(map { "-D".$_} @{$config{defines}},"OPENSSLDIR=\"\\\"\$(OPENSSLDIR)\\\"\"","ENGINESDIR=\"\\\"\$(ENGINESDIR)\\\"\"")) -} {- $config{cflags} -} +CFLAG={- our $cflags2 = join(" ",(map { "-D".$_} @{$target{defines}}, @{$config{defines}}),"-DOPENSSLDIR=\"\\\"\$(OPENSSLDIR)\\\"\"","-DENGINESDIR=\"\\\"\$(ENGINESDIR)\\\"\"") -} {- $target{cflags} -} {- $config{cflags} -} CFLAG_Q={- $cflags2 =~ s|([\\"])|\\$1|g; $cflags2 -} {- $config{cflags} -} LDFLAG= {- $config{lflags} -} PLIB_LDFLAG= {- $config{plib_lflags} -} -EX_LIBS= {- $config{ex_libs} -} +EX_LIBS= {- $target{ex_libs} -} {- $config{ex_libs} -} EXE_EXT= {- $target{exe_extension} -} ARFLAGS= {- $target{arflags} -} AR=$(CROSS_COMPILE){- $target{ar} -} $(ARFLAGS) r @@ -196,7 +196,7 @@ SHARED_CRYPTO=libcrypto$(SHLIB_EXT) SHARED_SSL=libssl$(SHLIB_EXT) SHARED_LIBS={- $disabled{shared} ? '' : '$(SHARED_CRYPTO) $(SHARED_SSL)' -} SHARED_CFLAG={- $target{shared_cflag} -} -SHARED_LDFLAG={- $target{shared_ldflag} +SHARED_LDFLAG={- $target{shared_ldflag}." ".$config{shared_ldflag} # Unlike other OSes (like Solaris, Linux, Tru64, # IRIX) BSD run-time linkers (tested OpenBSD, NetBSD # and FreeBSD) "demand" RPATH set on .so objects. -- 2.25.1