summaryrefslogtreecommitdiffstats
path: root/Configure
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2017-11-06 17:11:03 +0100
committerRichard Levitte <levitte@openssl.org>2017-12-11 15:51:02 +0100
commit6d75a83c076f569289e63541ebb8473c37bd1ac6 (patch)
tree729790dd7ecceaf2a0b456f14763652c68e41c3b /Configure
parentcac19d19e7d6f252ff9aea60d85e0c0fd71a117f (diff)
Configure: move the processing of predefined macros to a function
Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/4899)
Diffstat (limited to 'Configure')
-rwxr-xr-xConfigure57
1 files changed, 35 insertions, 22 deletions
diff --git a/Configure b/Configure
index 2690493016..db191213ad 100755
--- a/Configure
+++ b/Configure
@@ -1235,33 +1235,20 @@ unless ($disabled{asm}) {
}
}
-my %predefined;
+my %predefined = compiler_predefined($target{cc});
-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 (<PIPE>) {
- m/^#define\s+(\w+(?:\(\w+\))?)(?:\s+(.+))?/ or last;
- $predefined{$1} = $2 // "";
- }
- close(PIPE);
-
- 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;
@@ -2514,6 +2501,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 = <PIPE>) {
+ $l =~ m/^#define\s+(\w+(?:\(\w+\))?)(?:\s+(.+))?/ or last;
+ $predefined{$default_compiler}->{$1} = $2 // '';
+ }
+ close(PIPE);
+ }
+
+ return %{$predefined{$default_compiler}};
+}
+
sub which
{
my ($name)=@_;