Skip to content

Commit 54cf3b9

Browse files
author
Andy Polyakov
committed
Configure: base compiler-specific decisions on pre-defines.
The commit subject is a bit misleading in sense that decisions affect only gcc and gcc-alikes, like clang, recent icc... Reviewed-by: Richard Levitte <[email protected]> Reviewed-by: Ben Kaduk <[email protected]> (Merged from openssl#4281)
1 parent e295d04 commit 54cf3b9

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

Configure

+24-24
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,12 @@ my $usage="Usage: Configure [no-<cipher> ...] [enable-<cipher> ...] [-Dxxx] [-lx
117117
# but 'long long' type.
118118

119119
my $gcc_devteam_warn = "-DDEBUG_UNUSED"
120-
. " -Wswitch"
121120
. " -DPEDANTIC -pedantic -Wno-long-long"
122121
. " -Wall"
123122
. " -Wextra"
124123
. " -Wno-unused-parameter"
125124
. " -Wno-missing-field-initializers"
125+
. " -Wswitch"
126126
. " -Wsign-compare"
127127
. " -Wmissing-prototypes"
128128
. " -Wshadow"
@@ -1257,29 +1257,29 @@ unless ($disabled{asm}) {
12571257
}
12581258
}
12591259

1260-
my $ecc = $target{cc};
1261-
if ($^O ne "VMS" && !$disabled{makedepend}) {
1262-
# Is the compiler gcc or clang? $ecc is used below to see if
1263-
# error-checking can be turned on.
1264-
my $ccpcc = "$config{cross_compile_prefix}$target{cc}";
1265-
open(PIPE, "$ccpcc --version 2>&1 |");
1266-
my $lines = 2;
1267-
while ( <PIPE> ) {
1268-
# Find the version number and save the major.
1269-
m|(?:.*)\b(\d+)\.\d+\.\d+\b(?:.*)|;
1270-
my $compiler_major = $1;
1271-
# We know that GNU C version 3 and up as well as all clang
1272-
# versions support dependency generation
1273-
$config{makedepprog} = $ccpcc
1274-
if (/clang/ || (/gcc/ && $compiler_major >= 3));
1275-
$ecc = "clang" if /clang/;
1276-
$ecc = "gcc" if /gcc/;
1277-
last if ($config{makedepprog} || !$lines--);
1260+
my %predefined;
1261+
1262+
if ($^O ne "VMS") {
1263+
my $cc = "$config{cross_compile_prefix}$target{cc}";
1264+
1265+
# collect compiler pre-defines from gcc or gcc-alike...
1266+
open(PIPE, "$cc -dM -E -x c /dev/null 2>&1 |");
1267+
while (<PIPE>) {
1268+
m/^#define\s+(\w+(?:\(\w+\))?)(?:\s+(.+))?/ or last;
1269+
$predefined{$1} = $2 // "";
12781270
}
12791271
close(PIPE);
12801272

1281-
$config{makedepprog} = which('makedepend') unless $config{makedepprog};
1282-
$disabled{makedepend} = "unavailable" unless $config{makedepprog};
1273+
if (!$disabled{makedepend}) {
1274+
# We know that GNU C version 3 and up as well as all clang
1275+
# versions support dependency generation
1276+
if ($predefined{__GNUC__} >= 3) {
1277+
$config{makedepprog} = $cc;
1278+
} else {
1279+
$config{makedepprog} = which('makedepend');
1280+
$disabled{makedepend} = "unavailable" unless $config{makedepprog};
1281+
}
1282+
}
12831283
}
12841284

12851285

@@ -1324,13 +1324,13 @@ if (defined($config{api})) {
13241324
if ($strict_warnings)
13251325
{
13261326
my $wopt;
1327-
die "ERROR --strict-warnings requires gcc or clang"
1328-
unless $ecc eq 'gcc' || $ecc eq 'clang';
1327+
die "ERROR --strict-warnings requires gcc or gcc-alike"
1328+
unless defined($predefined{__GNUC__});
13291329
foreach $wopt (split /\s+/, $gcc_devteam_warn)
13301330
{
13311331
$config{cflags} .= " $wopt" unless ($config{cflags} =~ /(?:^|\s)$wopt(?:\s|$)/)
13321332
}
1333-
if ($ecc eq "clang")
1333+
if (defined($predefined{__clang__}))
13341334
{
13351335
foreach $wopt (split /\s+/, $clang_devteam_warn)
13361336
{

0 commit comments

Comments
 (0)