X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=blobdiff_plain;f=Configure;h=a5d5c84e024451c91a5033550862fc48a982b711;hp=26904930163c9b4bc2bef5deeebb791a94f6920a;hb=793077d0beccfa20c9962546393128b92a7e68e4;hpb=99aeeecb9f59ab6d6cdb13ed07a30c11e89a32e7 diff --git a/Configure b/Configure index 2690493016..a5d5c84e02 100755 --- a/Configure +++ b/Configure @@ -879,9 +879,48 @@ my %target = resolve_config($target); &usage if (!%target || $target{template}); +%target = ( %{$table{DEFAULTS}}, %target ); + +# Make the flags to build DSOs the same as for shared libraries unless they +# are already defined +$target{dso_cflags} = $target{shared_cflag} unless defined $target{dso_cflags}; +$target{dso_cxxflags} = $target{shared_cxxflag} unless defined $target{dso_cxxflags}; +$target{dso_lflags} = $target{shared_ldflag} unless defined $target{dso_lflags}; +{ + my $shared_info_pl = + catfile(dirname($0), "Configurations", "shared-info.pl"); + my %shared_info = read_eval_file($shared_info_pl); + push @{$target{_conf_fname_int}}, $shared_info_pl; + my $si = $target{shared_target}; + while (ref $si ne "HASH") { + last if ! defined $si; + if (ref $si eq "CODE") { + $si = $si->(); + } else { + $si = $shared_info{$si}; + } + } + + # Some of the 'shared_target' values don't have any entried in + # %shared_info. That's perfectly fine, AS LONG AS the build file + # template knows how to handle this. That is currently the case for + # Windows and VMS. + if (defined $si) { + # Just as above, copy certain shared_* attributes to the corresponding + # dso_ attribute unless the latter is already defined + $si->{dso_cflags} = $si->{shared_cflag} unless defined $si->{dso_cflags}; + $si->{dso_cxxflags} = $si->{shared_cxxflag} unless defined $si->{dso_cxxflags}; + $si->{dso_lflags} = $si->{shared_ldflag} unless defined $si->{dso_lflags}; + foreach (sort keys %$si) { + $target{$_} = defined $target{$_} + ? add($si->{$_})->($target{$_}) + : $si->{$_}; + } + } +} + my %conf_files = map { $_ => 1 } (@{$target{_conf_fname_int}}); $config{conf_files} = [ sort keys %conf_files ]; -%target = ( %{$table{DEFAULTS}}, %target ); foreach my $feature (@{$target{disable}}) { if (exists $deprecated_disablables{$feature}) { @@ -1163,8 +1202,11 @@ unless ($disabled{"fuzz-libfuzzer"} && $disabled{"fuzz-afl"} # This saves the build files from having to check if ($disabled{pic}) { - $target{shared_cflag} = $target{shared_ldflag} = - $target{shared_rcflag} = ""; + foreach (qw(shared_cflag shared_cxxflag shared_ldflag + dso_cflags dso_cxxflags dso_lflags)) + { + $target{$_} = ""; + } } else { @@ -1235,33 +1277,20 @@ unless ($disabled{asm}) { } } -my %predefined; - -if ($^O ne "VMS") { - my $cc = "$config{cross_compile_prefix}$target{cc}"; - - # collect compiler pre-defines from gcc or gcc-alike... - open(PIPE, "$cc -dM -E -x c /dev/null 2>&1 |"); - while () { - m/^#define\s+(\w+(?:\(\w+\))?)(?:\s+(.+))?/ or last; - $predefined{$1} = $2 // ""; - } - close(PIPE); +my %predefined = compiler_predefined($target{cc}); - if (!$disabled{makedepend}) { - # We know that GNU C version 3 and up as well as all clang - # versions support dependency generation - if ($predefined{__GNUC__} >= 3) { - $config{makedepprog} = $cc; - } else { - $config{makedepprog} = which('makedepend'); - $disabled{makedepend} = "unavailable" unless $config{makedepprog}; - } +if (!$disabled{makedepend}) { + # We know that GNU C version 3 and up as well as all clang + # versions support dependency generation + if ($predefined{__GNUC__} >= 3) { + $config{makedepprog} = "\$(CROSS_COMPILE)$target{cc}"; + } else { + $config{makedepprog} = which('makedepend'); + $disabled{makedepend} = "unavailable" unless $config{makedepprog}; } } - # Deal with bn_ops ################################################### $config{bn_ll} =0; @@ -2305,25 +2334,38 @@ sub add { sub { _add($separator, @_, @x) }; } +sub read_eval_file { + my $fname = shift; + my $content; + my @result; + + open F, "< $fname" or die "Can't open '$fname': $!\n"; + { + undef local $/; + $content = ; + } + close F; + { + local $@; + + @result = ( eval $content ); + warn $@ if $@; + } + return wantarray ? @result : $result[0]; +} + # configuration reader, evaluates the input file as a perl script and expects # it to fill %targets with target configurations. Those are then added to # %table. sub read_config { my $fname = shift; - open(CONFFILE, "< $fname") - or die "Can't open configuration file '$fname'!\n"; - my $x = $/; - undef $/; - my $content = ; - $/ = $x; - close(CONFFILE); - my %targets = (); + my %targets; + { # Protect certain tables from tampering - local %table = %::table; + local %table = (); - eval $content; - warn $@ if $@; + %targets = read_eval_file($fname); } # For each target, check that it's configured with a hash table. @@ -2514,6 +2556,32 @@ sub run_dofile rename("$out.new", $out) || die "Can't rename $out.new, $!"; } +sub compiler_predefined { + state %predefined; + my $default_compiler = shift; + + return () if $^O eq 'VMS'; + + die 'compiler_predefines called without a default compiler' + unless $default_compiler; + + if (! $predefined{$default_compiler}) { + my $cc = "$config{cross_compile_prefix}$default_compiler"; + + $predefined{$default_compiler} = {}; + + # collect compiler pre-defines from gcc or gcc-alike... + open(PIPE, "$cc -dM -E -x c /dev/null 2>&1 |"); + while (my $l = ) { + $l =~ m/^#define\s+(\w+(?:\(\w+\))?)(?:\s+(.+))?/ or last; + $predefined{$default_compiler}->{$1} = $2 // ''; + } + close(PIPE); + } + + return %{$predefined{$default_compiler}}; +} + sub which { my ($name)=@_;