]> git.ipfire.org Git - thirdparty/openssl.git/blame - util/perl/OpenSSL/config.pm
speed: make hmac(sha256) the default hmac
[thirdparty/openssl.git] / util / perl / OpenSSL / config.pm
CommitLineData
4901b570 1#! /usr/bin/env perl
da1c088f 2# Copyright 1998-2023 The OpenSSL Project Authors. All Rights Reserved.
4901b570
RS
3#
4# Licensed under the Apache License 2.0 (the "License"). You may not use
5# this file except in compliance with the License. You can obtain a copy
6# in the file LICENSE in the source distribution or at
7# https://www.openssl.org/source/license.html
8
9# Determine the operating system and run ./Configure. Far descendant from
10# Apache's minarch and GuessOS.
11
12package OpenSSL::config;
13
14use strict;
15use warnings;
16use Getopt::Std;
17use File::Basename;
2ba5bffa 18use File::Spec;
a3310b18 19use IPC::Cmd;
69aa579e 20use POSIX;
e63f5fdc 21use Config;
a3310b18 22use Carp;
4901b570
RS
23
24# These control our behavior.
25my $DRYRUN;
26my $VERBOSE;
4901b570 27my $WHERE = dirname($0);
ecb09baf 28my $WAIT = 1;
4901b570
RS
29
30# Machine type, etc., used to determine the platform
31my $MACHINE;
32my $RELEASE;
33my $SYSTEM;
34my $VERSION;
a3310b18 35my $CCVENDOR;
4901b570 36my $CCVER;
0747f94b 37my $CL_ARCH;
4901b570
RS
38my $GCC_BITS;
39my $GCC_ARCH;
40
41# Some environment variables; they will affect Configure
4901b570 42my $CONFIG_OPTIONS = $ENV{CONFIG_OPTIONS} // '';
e39795af
RL
43my $CC;
44my $CROSS_COMPILE;
4901b570 45
a3310b18
RL
46# For determine_compiler_settings, the list of known compilers
47my @c_compilers = qw(clang gcc cc);
48# Methods to determine compiler version. The expected output is one of
49# MAJOR or MAJOR.MINOR or MAJOR.MINOR.PATCH... or false if the compiler
50# isn't of the given brand.
51# This is a list to ensure that gnu comes last, as we've made it a fallback
52my @cc_version =
53 (
54 clang => sub {
2ba5bffa 55 return undef unless IPC::Cmd::can_run("$CROSS_COMPILE$CC");
a3310b18 56 my $v = `$CROSS_COMPILE$CC -v 2>&1`;
cd84d883 57 $v =~ m/(?:(?:clang|LLVM) version|.*based on LLVM)\s+([0-9]+\.[0-9]+)/;
a3310b18
RL
58 return $1;
59 },
60 gnu => sub {
2ba5bffa
RL
61 return undef unless IPC::Cmd::can_run("$CROSS_COMPILE$CC");
62 my $nul = File::Spec->devnull();
63 my $v = `$CROSS_COMPILE$CC -dumpversion 2> $nul`;
a3310b18
RL
64 # Strip off whatever prefix egcs prepends the number with.
65 # Hopefully, this will work for any future prefixes as well.
66 $v =~ s/^[a-zA-Z]*\-//;
67 return $v;
68 },
69 );
70
4901b570
RS
71# This is what we will set as the target for calling Configure.
72my $options = '';
73
4901b570 74# Pattern matches against "${SYSTEM}:${RELEASE}:${VERSION}:${MACHINE}"
bfa68462
RL
75# The patterns are assumed to be wrapped like this: /^(${pattern})$/
76my $guess_patterns = [
77 [ 'A\/UX:.*', 'm68k-apple-aux3' ],
78 [ 'AIX:[3-9]:4:.*', '${MACHINE}-ibm-aix' ],
79 [ 'AIX:.*?:[5-9]:.*', '${MACHINE}-ibm-aix' ],
80 [ 'AIX:.*', '${MACHINE}-ibm-aix3' ],
81 [ 'HI-UX:.*', '${MACHINE}-hi-hiux' ],
82 [ 'HP-UX:.*',
83 sub {
84 my $HPUXVER = $RELEASE;
85 $HPUXVER = s/[^.]*.[0B]*//;
86 # HPUX 10 and 11 targets are unified
87 return "${MACHINE}-hp-hpux1x" if $HPUXVER =~ m@1[0-9]@;
88 return "${MACHINE}-hp-hpux";
89 }
90 ],
91 [ 'IRIX:6\..*', 'mips3-sgi-irix' ],
92 [ 'IRIX64:.*', 'mips4-sgi-irix64' ],
93 [ 'Linux:[2-9]\..*', '${MACHINE}-whatever-linux2' ],
94 [ 'Linux:1\..*', '${MACHINE}-whatever-linux1' ],
7c729851
ST
95 [ 'GNU:.*86-AT386', 'hurd-x86' ],
96 [ 'GNU:.*86_64-AT386', 'hurd-x86_64' ],
bfa68462 97 [ 'LynxOS:.*', '${MACHINE}-lynx-lynxos' ],
4901b570 98 # BSD/OS always says 386
bfa68462
RL
99 [ 'BSD\/OS:4\..*', 'i486-whatever-bsdi4' ],
100 # Order is important, this has to appear before 'BSD\/386:'
101 [ 'BSD/386:.*?:.*?:.*486.*|BSD/OS:.*?:.*?:.*?:.*486.*',
102 sub {
103 my $BSDVAR = `/sbin/sysctl -n hw.model`;
104 return "i586-whatever-bsdi" if $BSDVAR =~ m@Pentium@;
105 return "i386-whatever-bsdi";
106 }
107 ],
108 [ 'BSD\/386:.*|BSD\/OS:.*', '${MACHINE}-whatever-bsdi' ],
109 # Order is important, this has to appear before 'FreeBSD:'
110 [ 'FreeBSD:.*?:.*?:.*386.*',
111 sub {
112 my $VERS = $RELEASE;
113 $VERS =~ s/[-(].*//;
114 my $MACH = `sysctl -n hw.model`;
115 $MACH = "i386" if $MACH =~ m@386@;
116 $MACH = "i486" if $MACH =~ m@486@;
117 $MACH = "i686" if $MACH =~ m@Pentium II@;
118 $MACH = "i586" if $MACH =~ m@Pentium@;
119 $MACH = "$MACHINE" if $MACH !~ /i.86/;
120 my $ARCH = 'whatever';
121 $ARCH = "pc" if $MACH =~ m@i[0-9]86@;
122 return "${MACH}-${ARCH}-freebsd${VERS}";
123 }
124 ],
125 [ 'DragonFly:.*', '${MACHINE}-whatever-dragonfly' ],
126 [ 'FreeBSD:.*', '${MACHINE}-whatever-freebsd' ],
127 [ 'Haiku:.*', '${MACHINE}-whatever-haiku' ],
128 # Order is important, this has to appear before 'NetBSD:.*'
129 [ 'NetBSD:.*?:.*?:.*386.*',
130 sub {
131 my $hw = `/usr/sbin/sysctl -n hw.model || /sbin/sysctl -n hw.model`;
132 $hw =~ s@.*(.)86-class.*@i${1}86@;
133 return "${hw}-whatever-netbsd";
134 }
135 ],
136 [ 'NetBSD:.*', '${MACHINE}-whatever-netbsd' ],
137 [ 'OpenBSD:.*', '${MACHINE}-whatever-openbsd' ],
138 [ 'OpenUNIX:.*', '${MACHINE}-unknown-OpenUNIX${VERSION}' ],
139 [ 'OSF1:.*?:.*?:.*alpha.*',
140 sub {
141 my $OSFMAJOR = $RELEASE;
142 $OSFMAJOR =~ 's/^V([0-9]*)\..*$/\1/';
143 return "${MACHINE}-dec-tru64" if $OSFMAJOR =~ m@[45]@;
144 return "${MACHINE}-dec-osf";
145 }
146 ],
147 [ 'Paragon.*?:.*', 'i860-intel-osf1' ],
148 [ 'Rhapsody:.*', 'ppc-apple-rhapsody' ],
149 [ 'Darwin:.*?:.*?:Power.*', 'ppc-apple-darwin' ],
8758f4e6 150 [ 'Darwin:.*', '${MACHINE}-apple-darwin' ],
bfa68462
RL
151 [ 'SunOS:5\..*', '${MACHINE}-whatever-solaris2' ],
152 [ 'SunOS:.*', '${MACHINE}-sun-sunos4' ],
153 [ 'UNIX_System_V:4\..*?:.*', '${MACHINE}-whatever-sysv4' ],
154 [ 'VOS:.*?:.*?:i786', 'i386-stratus-vos' ],
155 [ 'VOS:.*?:.*?:.*', 'hppa1.1-stratus-vos' ],
156 [ '.*?:4.*?:R4.*?:m88k', '${MACHINE}-whatever-sysv4' ],
157 [ 'DYNIX\/ptx:4.*?:.*', '${MACHINE}-whatever-sysv4' ],
158 [ '.*?:4\.0:3\.0:3[34]..(,.*)?', 'i486-ncr-sysv4' ],
159 [ 'ULTRIX:.*', '${MACHINE}-unknown-ultrix' ],
160 [ 'POSIX-BC.*', 'BS2000-siemens-sysv4' ],
161 [ 'machten:.*', '${MACHINE}-tenon-${SYSTEM}' ],
162 [ 'library:.*', '${MACHINE}-ncr-sysv4' ],
163 [ 'ConvexOS:.*?:11\.0:.*', '${MACHINE}-v11-${SYSTEM}' ],
164 [ 'MINGW64.*?:.*?:.*?:x86_64', '${MACHINE}-whatever-mingw64' ],
165 [ 'MINGW.*', '${MACHINE}-whatever-mingw' ],
166 [ 'CYGWIN.*', '${MACHINE}-pc-cygwin' ],
167 [ 'vxworks.*', '${MACHINE}-whatever-vxworks' ],
69aa579e 168
e63f5fdc
RL
169 # The MACHINE part of the array POSIX::uname() returns on VMS isn't
170 # worth the bits wasted on it. It's better, then, to rely on perl's
171 # %Config, which has a trustworthy item 'archname', especially since
172 # VMS installation aren't multiarch (yet)
173 [ 'OpenVMS:.*', "$Config{archname}-whatever-OpenVMS" ],
174
4232a9e5
RL
175 # Note: there's also NEO and NSR, but they are old and unsupported
176 [ 'NONSTOP_KERNEL:.*:NSE-.*?', 'nse-tandem-nsk${RELEASE}' ],
177 [ 'NONSTOP_KERNEL:.*:NSV-.*?', 'nsv-tandem-nsk${RELEASE}' ],
178 [ 'NONSTOP_KERNEL:.*:NSX-.*?', 'nsx-tandem-nsk${RELEASE}' ],
179
bfa68462 180 [ sub { -d '/usr/apollo' }, 'whatever-apollo-whatever' ],
4901b570
RS
181];
182
4901b570
RS
183# Run a command, return true if exit zero else false.
184# Multiple args are glued together into a pipeline.
185# Name comes from OpenSSL tests, often written as "ok(run(...."
186sub okrun {
187 my $command = join(' | ', @_);
188 my $status = system($command) >> 8;
189 return $status == 0;
190}
191
192# Give user a chance to abort/interrupt if interactive if interactive.
193sub maybe_abort {
194 if ( $WAIT && -t 1 ) {
195 eval {
196 local $SIG{ALRM} = sub { die "Timeout"; };
197 local $| = 1;
198 alarm(5);
199 print "You have about five seconds to abort: ";
200 my $ignored = <STDIN>;
201 alarm(0);
202 };
203 print "\n" if $@ =~ /Timeout/;
204 }
205}
206
4901b570
RS
207# Look for ISC/SCO with its unique uname program
208sub is_sco_uname {
9e1094ad
RL
209 return undef unless IPC::Cmd::can_run('uname');
210
4901b570
RS
211 open UNAME, "uname -X 2>/dev/null|" or return '';
212 my $line = "";
8d67621d 213 my $os = "";
4901b570
RS
214 while ( <UNAME> ) {
215 chop;
216 $line = $_ if m@^Release@;
8d67621d 217 $os = $_ if m@^System@;
4901b570
RS
218 }
219 close UNAME;
9e1094ad 220
8d67621d 221 return undef if $line eq '' or $os eq 'System = SunOS';
9e1094ad 222
3eb84c62 223 my @fields = split(/\s+/, $line);
9e1094ad 224 return $fields[2];
4901b570
RS
225}
226
227sub get_sco_type {
228 my $REL = shift;
229
230 if ( -f "/etc/kconfig" ) {
231 return "${MACHINE}-whatever-isc4" if $REL eq '4.0' || $REL eq '4.1';
232 } else {
233 return "whatever-whatever-sco3" if $REL eq '3.2v4.2';
234 return "whatever-whatever-sco5" if $REL =~ m@3\.2v5\.0.*@;
235 if ( $REL eq "4.2MP" ) {
236 return "whatever-whatever-unixware20" if $VERSION =~ m@2\.0.*@;
237 return "whatever-whatever-unixware21" if $VERSION =~ m@2\.1.*@;
238 return "whatever-whatever-unixware2" if $VERSION =~ m@2.*@;
239 }
240 return "whatever-whatever-unixware1" if $REL eq "4.2";
241 if ( $REL =~ m@5.*@ ) {
242 # We hardcode i586 in place of ${MACHINE} for the following
243 # reason: even though Pentium is minimum requirement for
244 # platforms in question, ${MACHINE} gets always assigned to
245 # i386. This means i386 gets passed to Configure, which will
246 # cause bad assembler code to be generated.
247 return "i586-sco-unixware7" if $VERSION =~ m@[678].*@;
248 }
249 }
250}
251
252# Return the cputype-vendor-osversion
253sub guess_system {
69aa579e
RL
254 ($SYSTEM, undef, $RELEASE, $VERSION, $MACHINE) = POSIX::uname();
255 my $sys = "${SYSTEM}:${RELEASE}:${VERSION}:${MACHINE}";
8d67621d 256
4901b570
RS
257 # Special-cases for ISC, SCO, Unixware
258 my $REL = is_sco_uname();
9e1094ad 259 if ( defined $REL ) {
4901b570 260 my $result = get_sco_type($REL);
019e3a0b 261 return eval "\"$result\"" if $result ne '';
4901b570
RS
262 }
263
264 # Now pattern-match
4901b570
RS
265
266 # Simple cases
bfa68462 267 foreach my $tuple ( @$guess_patterns ) {
4901b570 268 my $pat = @$tuple[0];
bfa68462
RL
269 my $check = ref $pat eq 'CODE' ? $pat->($sys) : $sys =~ /^(${pat})$/;
270 next unless $check;
4901b570 271
bfa68462
RL
272 my $result = @$tuple[1];
273 $result = $result->() if ref $result eq 'CODE';
019e3a0b 274 return eval "\"$result\"";
4901b570
RS
275 }
276
277 # Oh well.
278 return "${MACHINE}-whatever-${SYSTEM}";
279}
280
a3310b18
RL
281# We would use List::Util::pair() for this... unfortunately, that function
282# only appeared in perl v5.19.3, and we claim to support perl v5.10 and on.
283# Therefore, we implement a quick cheap variant of our own.
284sub _pairs (@) {
285 croak "Odd number of arguments" if @_ & 1;
286
287 my @pairlist = ();
288
289 while (@_) {
290 my $x = [ shift, shift ];
291 push @pairlist, $x;
292 }
293 return @pairlist;
294}
295
4901b570
RS
296# Figure out CC, GCCVAR, etc.
297sub determine_compiler_settings {
9e1094ad
RL
298 # Make a copy and don't touch it. That helps determine if we're finding
299 # the compiler here (false), or if it was set by the user (true.
a3310b18
RL
300 my $cc = $CC;
301
302 # Set certain default
303 $CCVER = 0; # Unknown
304 $CCVENDOR = ''; # Dunno, don't care (unless found later)
305
306 # Find a compiler if we don't already have one
307 if ( ! $cc ) {
308 foreach (@c_compilers) {
309 next unless IPC::Cmd::can_run("$CROSS_COMPILE$_");
310 $CC = $_;
311 last;
312 }
313 }
314
9e1094ad
RL
315 if ( $CC ) {
316 # Find the compiler vendor and version number for certain compilers
317 foreach my $pair (_pairs @cc_version) {
318 # Try to get the version number.
319 # Failure gets us undef or an empty string
320 my ( $k, $v ) = @$pair;
321 $v = $v->();
322
323 # If we got a version number, process it
324 if ($v) {
325 $CCVENDOR = $k;
326
327 # The returned version is expected to be one of
328 #
329 # MAJOR
330 # MAJOR.MINOR
331 # MAJOR.MINOR.{whatever}
332 #
333 # We don't care what comes after MAJOR.MINOR. All we need is
334 # to have them calculated into a single number, using this
335 # formula:
336 #
337 # MAJOR * 100 + MINOR
338 # Here are a few examples of what we should get:
339 #
340 # 2.95.1 => 295
341 # 3.1 => 301
342 # 9 => 900
343 my @numbers = split /\./, $v;
344 my @factors = (100, 1);
345 while (@numbers && @factors) {
346 $CCVER += shift(@numbers) * shift(@factors)
347 }
348 last;
a3310b18 349 }
a3310b18
RL
350 }
351 }
352
9e1094ad 353 # Vendor specific overrides, only if we didn't determine the compiler here
a3310b18 354 if ( ! $cc ) {
f627561c
RL
355 if ( $SYSTEM eq 'OpenVMS' ) {
356 my $v = `CC/VERSION NLA0:`;
357 if ($? == 0) {
d6175dcc
RL
358 # The normal releases have a version number prefixed with a V.
359 # However, other letters have been seen as well (for example X),
360 # and it's documented that HP (now VSI) reserve the letter W, X,
361 # Y and Z for their own uses.
f627561c 362 my ($vendor, $version) =
d6175dcc 363 ( $v =~ m/^([A-Z]+) C [VWXYZ]([0-9\.-]+)(:? +\(.*?\))? on / );
f627561c
RL
364 my ($major, $minor, $patch) =
365 ( $version =~ m/^([0-9]+)\.([0-9]+)-0*?(0|[1-9][0-9]*)$/ );
366 $CC = 'CC';
367 $CCVENDOR = $vendor;
368 $CCVER = ( $major * 100 + $minor ) * 100 + $patch;
369 }
370 }
371
a3310b18
RL
372 if ( ${SYSTEM} eq 'AIX' ) {
373 # favor vendor cc over gcc
374 if (IPC::Cmd::can_run('cc')) {
375 $CC = 'cc';
376 $CCVENDOR = ''; # Determine later
377 $CCVER = 0;
378 }
379 }
380
381 if ( $SYSTEM eq "SunOS" ) {
8d67621d 382 # check for Oracle Developer Studio, expected output is "cc: blah-blah C x.x blah-blah"
a3310b18 383 my $v = `(cc -V 2>&1) 2>/dev/null | egrep -e '^cc: .* C [0-9]\.[0-9]'`;
8d67621d
JL
384 my @numbers =
385 ( $v =~ m/^.* C ([0-9]+)\.([0-9]+) .*/ );
a3310b18
RL
386 my @factors = (100, 1);
387 $v = 0;
388 while (@numbers && @factors) {
389 $v += shift(@numbers) * shift(@factors)
390 }
391
8d67621d 392 if ($v > 500) {
a3310b18 393 $CC = 'cc';
8d67621d 394 $CCVENDOR = 'sun';
a3310b18 395 $CCVER = $v;
a3310b18 396 }
4901b570 397 }
0747f94b
RL
398
399 # 'Windows NT' is the system name according to POSIX::uname()!
400 if ( $SYSTEM eq "Windows NT" ) {
401 # favor vendor cl over gcc
402 if (IPC::Cmd::can_run('cl')) {
403 $CC = 'cl';
404 $CCVENDOR = ''; # Determine later
405 $CCVER = 0;
406
407 my $v = `cl 2>&1`;
408 if ( $v =~ /Microsoft .* Version ([0-9\.]+) for (x86|x64|ARM|ia64)/ ) {
409 $CCVER = $1;
410 $CL_ARCH = $2;
411 }
412 }
413 }
4901b570
RS
414 }
415
9e1094ad
RL
416 # If no C compiler has been determined at this point, we die. Hard.
417 die <<_____
418ERROR!
419No C compiler found, please specify one with the environment variable CC,
420or configure with an explicit configuration target.
421_____
422 unless $CC;
423
a3310b18 424 # On some systems, we assume a cc vendor if it's not already determined
4901b570 425
a3310b18
RL
426 if ( ! $CCVENDOR ) {
427 $CCVENDOR = 'aix' if $SYSTEM eq 'AIX';
428 $CCVENDOR = 'sun' if $SYSTEM eq 'SunOS';
429 }
430
431 # Some systems need to know extra details
432
433 if ( $SYSTEM eq "HP-UX" && $CCVENDOR eq 'gnu' ) {
4901b570
RS
434 # By default gcc is a ILP32 compiler (with long long == 64).
435 $GCC_BITS = "32";
a3310b18 436 if ( $CCVER >= 300 ) {
4901b570
RS
437 # PA64 support only came in with gcc 3.0.x.
438 # We check if the preprocessor symbol __LP64__ is defined.
439 if ( okrun('echo __LP64__',
a3310b18
RL
440 "$CC -v -E -x c - 2>/dev/null",
441 'grep "^__LP64__" 2>&1 >/dev/null') ) {
4901b570
RS
442 # __LP64__ has slipped through, it therefore is not defined
443 } else {
444 $GCC_BITS = '64';
445 }
446 }
4901b570
RS
447 }
448
a3310b18
RL
449 if ( $SYSTEM eq "SunOS" && $CCVENDOR eq 'gnu' ) {
450 if ( $CCVER >= 300 ) {
4901b570
RS
451 # 64-bit ABI isn't officially supported in gcc 3.0, but seems
452 # to be working; at the very least 'make test' passes.
a3310b18
RL
453 if ( okrun("$CC -v -E -x c /dev/null 2>&1",
454 'grep __arch64__ >/dev/null') ) {
4901b570
RS
455 $GCC_ARCH = "-m64"
456 } else {
457 $GCC_ARCH = "-m32"
458 }
459 }
a3310b18
RL
460 }
461
462 if ($VERBOSE) {
463 my $vendor = $CCVENDOR ? $CCVENDOR : "(undetermined)";
464 my $version = $CCVER ? $CCVER : "(undetermined)";
465 print "C compiler: $CC\n";
466 print "C compiler vendor: $vendor\n";
467 print "C compiler version: $version\n";
4901b570
RS
468 }
469}
470
e39795af
RL
471my $map_patterns =
472 [ [ 'uClinux.*64.*', { target => 'uClinux-dist64' } ],
473 [ 'uClinux.*', { target => 'uClinux-dist' } ],
474 [ 'mips3-sgi-irix', { target => 'irix-mips3' } ],
475 [ 'mips4-sgi-irix64',
476 sub {
477 print <<EOF;
4901b570
RS
478WARNING! To build 64-bit package, do this:
479 $WHERE/Configure irix64-mips4-$CC
480EOF
e39795af
RL
481 maybe_abort();
482 return { target => "irix-mips3" };
483 }
484 ],
485 [ 'ppc-apple-rhapsody', { target => "rhapsody-ppc" } ],
486 [ 'ppc-apple-darwin.*',
487 sub {
21488844 488 my $KERNEL_BITS = $ENV{KERNEL_BITS} // '';
e39795af
RL
489 my $ISA64 = `sysctl -n hw.optional.64bitops 2>/dev/null`;
490 if ( $ISA64 == 1 && $KERNEL_BITS eq '' ) {
491 print <<EOF;
4901b570
RS
492WARNING! To build 64-bit package, do this:
493 $WHERE/Configure darwin64-ppc-cc
494EOF
e39795af
RL
495 maybe_abort();
496 }
497 return { target => "darwin64-ppc" }
498 if $ISA64 == 1 && $KERNEL_BITS eq '64';
499 return { target => "darwin-ppc" };
4901b570 500 }
e39795af
RL
501 ],
502 [ 'i.86-apple-darwin.*',
503 sub {
21488844 504 my $KERNEL_BITS = $ENV{KERNEL_BITS} // '';
e39795af
RL
505 my $ISA64 = `sysctl -n hw.optional.x86_64 2>/dev/null`;
506 if ( $ISA64 == 1 && $KERNEL_BITS eq '' ) {
507 print <<EOF;
4901b570 508WARNING! To build 64-bit package, do this:
a4ffb33e 509 KERNEL_BITS=64 $WHERE/Configure [options...]
4901b570 510EOF
e39795af
RL
511 maybe_abort();
512 }
513 return { target => "darwin64-x86_64" }
514 if $ISA64 == 1 && $KERNEL_BITS eq '64';
515 return { target => "darwin-i386" };
4901b570 516 }
e39795af
RL
517 ],
518 [ 'x86_64-apple-darwin.*',
519 sub {
21488844 520 my $KERNEL_BITS = $ENV{KERNEL_BITS} // '';
b926548b
TS
521 # macOS >= 10.15 is 64-bit only
522 my $SW_VERS = `sw_vers -productVersion 2>/dev/null`;
523 if ($SW_VERS =~ /^(\d+)\.(\d+)\.(\d+)$/) {
524 if ($1 > 10 || ($1 == 10 && $2 >= 15)) {
525 die "32-bit applications not supported on macOS 10.15 or later\n" if $KERNEL_BITS eq '32';
526 return { target => "darwin64-x86_64" };
527 }
528 }
e39795af 529 return { target => "darwin-i386" } if $KERNEL_BITS eq '32';
4901b570 530
e39795af 531 print <<EOF;
4901b570 532WARNING! To build 32-bit package, do this:
a4ffb33e 533 KERNEL_BITS=32 $WHERE/Configure [options...]
4901b570 534EOF
e39795af
RL
535 maybe_abort();
536 return { target => "darwin64-x86_64" };
537 }
538 ],
8758f4e6 539 [ 'arm64-apple-darwin.*', { target => "darwin64-arm64" } ],
e39795af
RL
540 [ 'armv6\+7-.*-iphoneos',
541 { target => "iphoneos-cross",
542 cflags => [ qw(-arch armv6 -arch armv7) ],
543 cxxflags => [ qw(-arch armv6 -arch armv7) ] }
544 ],
545 [ 'arm64-.*-iphoneos|.*-.*-ios64',
546 { target => "ios64-cross" }
547 ],
548 [ '.*-.*-iphoneos',
549 sub { return { target => "iphoneos-cross",
550 cflags => [ "-arch ${MACHINE}" ],
551 cxxflags => [ "-arch ${MACHINE}" ] }; }
552 ],
553 [ 'alpha-.*-linux2.*',
554 sub {
555 my $ISA = `awk '/cpu model/{print \$4;exit(0);}' /proc/cpuinfo`;
556 $ISA //= 'generic';
557 my %config = ();
558 if ( $CCVENDOR eq "gnu" ) {
559 if ( $ISA =~ 'EV5|EV45' ) {
560 %config = ( cflags => [ '-mcpu=ev5' ],
561 cxxflags => [ '-mcpu=ev5' ] );
562 } elsif ( $ISA =~ 'EV56|PCA56' ) {
563 %config = ( cflags => [ '-mcpu=ev56' ],
564 cxxflags => [ '-mcpu=ev56' ] );
565 } else {
566 %config = ( cflags => [ '-mcpu=ev6' ],
567 cxxflags => [ '-mcpu=ev6' ] );
568 }
4901b570 569 }
e39795af
RL
570 return { target => "linux-alpha",
571 %config };
4901b570 572 }
e39795af
RL
573 ],
574 [ 'ppc64-.*-linux2',
575 sub {
21488844 576 my $KERNEL_BITS = $ENV{KERNEL_BITS} // '';
e39795af
RL
577 if ( $KERNEL_BITS eq '' ) {
578 print <<EOF;
4901b570
RS
579WARNING! To build 64-bit package, do this:
580 $WHERE/Configure linux-ppc64
581EOF
e39795af
RL
582 maybe_abort();
583 }
584 return { target => "linux-ppc64" } if $KERNEL_BITS eq '64';
585
586 my %config = ();
587 if (!okrun('echo __LP64__',
588 'gcc -E -x c - 2>/dev/null',
589 'grep "^__LP64__" 2>&1 >/dev/null') ) {
590 %config = ( cflags => [ '-m32' ],
591 cxxflags => [ '-m32' ] );
592 }
593 return { target => "linux-ppc",
594 %config };
4901b570 595 }
e39795af
RL
596 ],
597 [ 'ppc64le-.*-linux2', { target => "linux-ppc64le" } ],
598 [ 'ppc-.*-linux2', { target => "linux-ppc" } ],
599 [ 'mips64.*-*-linux2',
600 sub {
601 print <<EOF;
4901b570
RS
602WARNING! To build 64-bit package, do this:
603 $WHERE/Configure linux64-mips64
604EOF
e39795af
RL
605 maybe_abort();
606 return { target => "linux-mips64" };
607 }
608 ],
609 [ 'mips.*-.*-linux2', { target => "linux-mips32" } ],
610 [ 'ppc60x-.*-vxworks.*', { target => "vxworks-ppc60x" } ],
611 [ 'ppcgen-.*-vxworks.*', { target => "vxworks-ppcgen" } ],
612 [ 'pentium-.*-vxworks.*', { target => "vxworks-pentium" } ],
613 [ 'simlinux-.*-vxworks.*', { target => "vxworks-simlinux" } ],
614 [ 'mips-.*-vxworks.*', { target => "vxworks-mips" } ],
615 [ 'e2k-.*-linux.*', { target => "linux-generic64",
616 defines => [ 'L_ENDIAN' ] } ],
617 [ 'ia64-.*-linux.', { target => "linux-ia64" } ],
618 [ 'sparc64-.*-linux2',
619 sub {
620 print <<EOF;
4901b570
RS
621WARNING! If you *know* that your GNU C supports 64-bit/V9 ABI and you
622 want to build 64-bit library, do this:
623 $WHERE/Configure linux64-sparcv9
624EOF
e39795af
RL
625 maybe_abort();
626 return { target => "linux-sparcv9" };
627 }
628 ],
629 [ 'sparc-.*-linux2',
630 sub {
631 my $KARCH = `awk '/^type/{print \$3;exit(0);}' /proc/cpuinfo`;
632 $KARCH //= "sun4";
633 return { target => "linux-sparcv9" } if $KARCH =~ 'sun4u.*';
634 return { target => "linux-sparcv8" } if $KARCH =~ 'sun4[md]';
635 return { target => "linux-generic32",
636 defines => [ 'L_ENDIAN' ] };
637 }
638 ],
639 [ 'parisc.*-.*-linux2',
640 sub {
641 # 64-bit builds under parisc64 linux are not supported and
642 # compiler is expected to generate 32-bit objects...
643 my $CPUARCH =
644 `awk '/cpu family/{print substr(\$5,1,3); exit(0);}' /proc/cpuinfo`;
645 my $CPUSCHEDULE =
646 `awk '/^cpu.[ ]*: PA/{print substr(\$3,3); exit(0);}' /proc/cpuinfo`;
647 # TODO XXX Model transformations
648 # 0. CPU Architecture for the 1.1 processor has letter suffixes.
649 # We strip that off assuming no further arch. identification
650 # will ever be used by GCC.
651 # 1. I'm most concerned about whether is a 7300LC is closer to a
652 # 7100 versus a 7100LC.
653 # 2. The variant 64-bit processors cause concern should GCC support
654 # explicit schedulers for these chips in the future.
655 # PA7300LC -> 7100LC (1.1)
656 # PA8200 -> 8000 (2.0)
657 # PA8500 -> 8000 (2.0)
658 # PA8600 -> 8000 (2.0)
659 $CPUSCHEDULE =~ s/7300LC/7100LC/;
660 $CPUSCHEDULE =~ s/8.00/8000/;
661 return
662 { target => "linux-generic32",
663 defines => [ 'B_ENDIAN' ],
664 cflags => [ "-mschedule=$CPUSCHEDULE", "-march=$CPUARCH" ],
665 cxxflags => [ "-mschedule=$CPUSCHEDULE", "-march=$CPUARCH" ]
666 };
667 }
668 ],
669 [ 'armv[1-3].*-.*-linux2', { target => "linux-generic32" } ],
670 [ 'armv[7-9].*-.*-linux2', { target => "linux-armv4",
e39795af
RL
671 cflags => [ '-march=armv7-a' ],
672 cxxflags => [ '-march=armv7-a' ] } ],
673 [ 'arm.*-.*-linux2', { target => "linux-armv4" } ],
674 [ 'aarch64-.*-linux2', { target => "linux-aarch64" } ],
675 [ 'sh.*b-.*-linux2', { target => "linux-generic32",
676 defines => [ 'B_ENDIAN' ] } ],
677 [ 'sh.*-.*-linux2', { target => "linux-generic32",
678 defines => [ 'L_ENDIAN' ] } ],
160f4894
XR
679 [ 'loongarch64-.*-linux2',
680 sub {
681 my $disable = [ 'asm' ];
682 if ( okrun('echo xvadd.w \$xr0,\$xr0,\$xr0',
683 "$CC -c -x assembler - -o /dev/null 2>/dev/null") ) {
684 $disable = [];
685 }
686 return { target => "linux64-loongarch64",
687 defines => [ 'L_ENDIAN' ],
688 disable => $disable, };
689 }
690 ],
e39795af
RL
691 [ 'm68k.*-.*-linux2', { target => "linux-generic32",
692 defines => [ 'B_ENDIAN' ] } ],
693 [ 's390-.*-linux2', { target => "linux-generic32",
694 defines => [ 'B_ENDIAN' ] } ],
695 [ 's390x-.*-linux2',
696 sub {
697 # Disabled until a glibc bug is fixed; see Configure.
698 if (0
699 || okrun('egrep -e \'^features.* highgprs\' /proc/cpuinfo >/dev/null') )
700 {
701 print <<EOF;
4901b570
RS
702WARNING! To build "highgprs" 32-bit package, do this:
703 $WHERE/Configure linux32-s390x
704EOF
e39795af
RL
705 maybe_abort();
706 }
707 return { target => "linux64-s390x" };
4901b570 708 }
e39795af
RL
709 ],
710 [ 'x86_64-.*-linux.',
711 sub {
712 return { target => "linux-x32" }
713 if okrun("$CC -dM -E -x c /dev/null 2>&1",
714 'grep -q ILP32 >/dev/null');
715 return { target => "linux-x86_64" };
716 }
717 ],
718 [ '.*86-.*-linux2',
719 sub {
720 # On machines where the compiler understands -m32, prefer a
721 # config target that uses it
722 return { target => "linux-x86" }
723 if okrun("$CC -m32 -E -x c /dev/null >/dev/null 2>&1");
724 return { target => "linux-elf" };
725 }
726 ],
727 [ '.*86-.*-linux1', { target => "linux-aout" } ],
e6760e3e 728 [ 'riscv64-.*-linux.', { target => "linux64-riscv64" } ],
e39795af
RL
729 [ '.*-.*-linux.', { target => "linux-generic32" } ],
730 [ 'sun4[uv].*-.*-solaris2',
731 sub {
732 my $KERNEL_BITS = $ENV{KERNEL_BITS};
733 my $ISA64 = `isainfo 2>/dev/null | grep sparcv9`;
8d67621d
JL
734 my $KB = $KERNEL_BITS // '64';
735 if ( $ISA64 ne "" && $KB eq '64' ) {
e39795af
RL
736 if ( $CCVENDOR eq "sun" && $CCVER >= 500 ) {
737 print <<EOF;
8d67621d
JL
738WARNING! To build 32-bit package, do this:
739 $WHERE/Configure solaris-sparcv9-cc
4901b570 740EOF
e39795af
RL
741 maybe_abort();
742 } elsif ( $CCVENDOR eq "gnu" && $GCC_ARCH eq "-m64" ) {
743 # $GCC_ARCH denotes default ABI chosen by compiler driver
744 # (first one found on the $PATH). I assume that user
745 # expects certain consistency with the rest of his builds
746 # and therefore switch over to 64-bit. <appro>
747 print <<EOF;
4901b570
RS
748WARNING! To build 32-bit package, do this:
749 $WHERE/Configure solaris-sparcv9-gcc
750EOF
e39795af 751 maybe_abort();
8d67621d 752 return { target => "solaris64-sparcv9-gcc" };
e39795af
RL
753 } elsif ( $GCC_ARCH eq "-m32" ) {
754 print <<EOF;
4901b570
RS
755NOTICE! If you *know* that your GNU C supports 64-bit/V9 ABI and you wish
756 to build 64-bit library, do this:
757 $WHERE/Configure solaris64-sparcv9-gcc
758EOF
e39795af
RL
759 maybe_abort();
760 }
4901b570 761 }
8d67621d
JL
762 return { target => "solaris64-sparcv9-cc" }
763 if $ISA64 ne "" && $KB eq '64';
764 return { target => "solaris-sparcv9-cc" };
4901b570 765 }
e39795af
RL
766 ],
767 [ 'sun4m-.*-solaris2', { target => "solaris-sparcv8" } ],
768 [ 'sun4d-.*-solaris2', { target => "solaris-sparcv8" } ],
769 [ 'sun4.*-.*-solaris2', { target => "solaris-sparcv7" } ],
770 [ '.*86.*-.*-solaris2',
771 sub {
772 my $KERNEL_BITS = $ENV{KERNEL_BITS};
773 my $ISA64 = `isainfo 2>/dev/null | grep amd64`;
774 my $KB = $KERNEL_BITS // '64';
5800d041
MC
775 if ($ISA64 ne "" && $KB eq '64') {
776 return { target => "solaris64-x86_64-gcc" } if $CCVENDOR eq "gnu";
777 return { target => "solaris64-x86_64-cc" };
778 }
e39795af
RL
779 my $REL = uname('-r');
780 $REL =~ s/5\.//;
781 my @tmp_disable = ();
782 push @tmp_disable, 'sse2' if int($REL) < 10;
5800d041
MC
783 #There is no solaris-x86-cc target
784 return { target => "solaris-x86-gcc",
e39795af 785 disable => [ @tmp_disable ] };
4901b570 786 }
e39795af
RL
787 ],
788 # We don't have any sunos target in Configurations/*.conf, so why here?
789 [ '.*-.*-sunos4', { target => "sunos" } ],
790 [ '.*86.*-.*-bsdi4', { target => "BSD-x86-elf",
791 lflags => [ '-ldl' ],
792 disable => [ 'sse2' ] } ],
793 [ 'alpha.*-.*-.*bsd.*', { target => "BSD-generic64",
794 defines => [ 'L_ENDIAN' ] } ],
f5485b97 795 [ 'powerpc-.*-.*bsd.*', { target => "BSD-ppc" } ],
796 [ 'powerpc64-.*-.*bsd.*', { target => "BSD-ppc64" } ],
797 [ 'powerpc64le-.*-.*bsd.*', { target => "BSD-ppc64le" } ],
c2d1ad0e 798 [ 'riscv64-.*-.*bsd.*', { target => "BSD-riscv64" } ],
e39795af 799 [ 'sparc64-.*-.*bsd.*', { target => "BSD-sparc64" } ],
c3bd630d 800 [ 'ia64-.*-openbsd.*', { target => "BSD-nodef-ia64" } ],
e39795af
RL
801 [ 'ia64-.*-.*bsd.*', { target => "BSD-ia64" } ],
802 [ 'x86_64-.*-dragonfly.*', { target => "BSD-x86_64" } ],
c3bd630d 803 [ 'amd64-.*-openbsd.*', { target => "BSD-nodef-x86_64" } ],
e39795af 804 [ 'amd64-.*-.*bsd.*', { target => "BSD-x86_64" } ],
8e22f9d6 805 [ 'arm64-.*-.*bsd.*', { target => "BSD-aarch64" } ],
a9389c0b
PK
806 [ 'armv6-.*-.*bsd.*', { target => "BSD-armv4" } ],
807 [ 'armv7-.*-.*bsd.*', { target => "BSD-armv4" } ],
e39795af
RL
808 [ '.*86.*-.*-.*bsd.*',
809 sub {
810 # mimic ld behaviour when it's looking for libc...
811 my $libc;
812 if ( -l "/usr/lib/libc.so" ) {
813 $libc = "/usr/lib/libc.so";
814 } else {
815 # ld searches for highest libc.so.* and so do we
816 $libc =
817 `(ls /usr/lib/libc.so.* /lib/libc.so.* | tail -1) 2>/dev/null`;
818 }
819 my $what = `file -L $libc 2>/dev/null`;
820 return { target => "BSD-x86-elf" } if $what =~ /ELF/;
821 return { target => "BSD-x86",
822 disable => [ 'sse2' ] };
4901b570 823 }
e39795af 824 ],
c3bd630d 825 [ '.*-.*-openbsd.*', { target => "BSD-nodef-generic32" } ],
e39795af
RL
826 [ '.*-.*-.*bsd.*', { target => "BSD-generic32" } ],
827 [ 'x86_64-.*-haiku', { target => "haiku-x86_64" } ],
828 [ '.*-.*-haiku', { target => "haiku-x86" } ],
829 [ '.*-.*-osf', { target => "osf1-alpha" } ],
830 [ '.*-.*-tru64', { target => "tru64-alpha" } ],
831 [ '.*-.*-[Uu]nix[Ww]are7',
832 sub {
833 return { target => "unixware-7",
834 disable => [ 'sse2' ] } if $CCVENDOR eq "gnu";
835 return { target => "unixware-7",
836 defines => [ '__i386__' ] };
837 }
838 ],
839 [ '.*-.*-[Uu]nix[Ww]are20.*', { target => "unixware-2.0",
840 disable => [ 'sse2', 'sha512' ] } ],
841 [ '.*-.*-[Uu]nix[Ww]are21.*', { target => "unixware-2.1",
842 disable => [ 'sse2', 'sha512' ] } ],
843 [ '.*-.*-vos', { target => "vos",
844 disable => [ 'threads', 'shared', 'asm',
845 'dso' ] } ],
846 [ 'BS2000-siemens-sysv4', { target => "BS2000-OSD" } ],
847 [ 'i[3456]86-.*-cygwin', { target => "Cygwin-x86" } ],
848 [ '.*-.*-cygwin',
849 sub { return { target => "Cygwin-${MACHINE}" } } ],
850 [ 'x86-.*-android|i.86-.*-android', { target => "android-x86" } ],
851 [ 'armv[7-9].*-.*-android', { target => "android-armeabi",
852 cflags => [ '-march=armv7-a' ],
853 cxxflags => [ '-march=armv7-a' ] } ],
854 [ 'arm.*-.*-android', { target => "android-armeabi" } ],
855 [ '.*-hpux1.*',
856 sub {
857 my $KERNEL_BITS = $ENV{KERNEL_BITS};
858 my %common_return = ( defines => [ '_REENTRANT' ] );
859 $KERNEL_BITS ||= `getconf KERNEL_BITS 2>/dev/null` // '32';
860 # See <sys/unistd.h> for further info on CPU_VERSION.
861 my $CPU_VERSION = `getconf CPU_VERSION 2>/dev/null` // 0;
862 if ( $CPU_VERSION >= 768 ) {
863 # IA-64 CPU
864 return { target => "hpux64-ia64",
865 %common_return }
866 if $KERNEL_BITS eq '64' && ! $CCVENDOR;
867 return { target => "hpux-ia64",
868 %common_return };
869 }
870 if ( $CPU_VERSION >= 532 ) {
871 # PA-RISC 2.x CPU
872 # PA-RISC 2.0 is no longer supported as separate 32-bit
873 # target. This is compensated for by run-time detection
874 # in most critical assembly modules and taking advantage
875 # of 2.0 architecture in PA-RISC 1.1 build.
876 my $target = ($CCVENDOR eq "gnu" && $GCC_BITS eq '64')
877 ? "hpux64-parisc2"
878 : "hpux-parisc1_1";
879 if ( $KERNEL_BITS eq '64' && ! $CCVENDOR ) {
880 print <<EOF;
4901b570
RS
881WARNING! To build 64-bit package, do this:
882 $WHERE/Configure hpux64-parisc2-cc
883EOF
e39795af
RL
884 maybe_abort();
885 }
886 return { target => $target,
887 %common_return };
4901b570 888 }
e39795af
RL
889 # PA-RISC 1.1+ CPU?
890 return { target => "hpux-parisc1_1",
891 %common_return } if $CPU_VERSION >= 528;
892 # PA-RISC 1.0 CPU
893 return { target => "hpux-parisc",
894 %common_return } if $CPU_VERSION >= 523;
895 # Motorola(?) CPU
896 return { target => "hpux",
897 %common_return };
4901b570 898 }
e39795af
RL
899 ],
900 [ '.*-hpux', { target => "hpux-parisc" } ],
901 [ '.*-aix',
902 sub {
903 my %config = ();
904 my $KERNEL_BITS = $ENV{KERNEL_BITS};
905 $KERNEL_BITS ||= `getconf KERNEL_BITMODE 2>/dev/null`;
906 $KERNEL_BITS ||= '32';
907 my $OBJECT_MODE = $ENV{OBJECT_MODE};
908 $OBJECT_MODE ||= 32;
909 $config{target} = "aix";
4901b570
RS
910 if ( $OBJECT_MODE == 64 ) {
911 print 'Your $OBJECT_MODE was found to be set to 64';
e39795af
RL
912 $config{target} = "aix64";
913 } else {
914 if ( $CCVENDOR ne 'gnu' && $KERNEL_BITS eq '64' ) {
915 print <<EOF;
4901b570
RS
916WARNING! To build 64-bit package, do this:
917 $WHERE/Configure aix64-cc
918EOF
e39795af
RL
919 maybe_abort();
920 }
4901b570 921 }
e39795af 922 if ( okrun(
52f5407d 923 "(lsattr -E -O -l `lsdev -c processor|awk '{print \$1;exit}'`",
e39795af
RL
924 'grep -i powerpc) >/dev/null 2>&1') ) {
925 # this applies even to Power3 and later, as they return
926 # PowerPC_POWER[345]
927 } else {
928 $config{disable} = [ 'asm' ];
929 }
2ba5bffa 930 return { %config };
4901b570 931 }
e39795af 932 ],
b2bed3c6
RL
933
934 # Windows values found by looking at Perl 5's win32/win32.c
0747f94b
RL
935 [ '(amd64|ia64|x86|ARM)-.*?-Windows NT',
936 sub {
937 # If we determined the arch by asking cl, take that value,
938 # otherwise the SYSTEM we got from from POSIX::uname().
939 my $arch = $CL_ARCH // $1;
940 my $config;
941
942 if ($arch) {
943 $config = { 'amd64' => { target => 'VC-WIN64A' },
944 'ia64' => { target => 'VC-WIN64I' },
945 'x86' => { target => 'VC-WIN32' },
946 'x64' => { target => 'VC-WIN64A' },
947 'ARM' => { target => 'VC-WIN64-ARM' },
948 } -> {$arch};
949 die <<_____ unless defined $config;
950ERROR
951I do not know how to handle ${arch}.
952_____
953 }
954 die <<_____ unless defined $config;
955ERROR
956Could not figure out the architecture.
957_____
958
959 return $config;
960 }
961 ],
b2bed3c6
RL
962
963 # VMS values found by observation on existing machinery.
e63f5fdc
RL
964 [ 'VMS_AXP-.*?-OpenVMS', { target => 'vms-alpha' } ],
965 [ 'VMS_IA64-.*?-OpenVMS', { target => 'vms-ia64' } ],
966 [ 'VMS_x86_64-.*?-OpenVMS', { target => 'vms-x86_64' } ],
b2bed3c6 967
4232a9e5
RL
968 # TODO: There are a few more choices among OpenSSL config targets, but
969 # reaching them involves a bit more than just a host tripet. Select
970 # environment variables could do the job to cover for more granular
971 # build options such as data model (ILP32 or LP64), thread support
972 # model (PUT, SPT or nothing), target execution environment (OSS or
973 # GUARDIAN). And still, there must be some kind of default when
974 # nothing else is said.
975 #
976 # nsv is a virtual x86 environment, equivalent to nsx, so we enforce
977 # the latter.
978 [ 'nse-tandem-nsk.*', { target => 'nonstop-nse' } ],
979 [ 'nsv-tandem-nsk.*', { target => 'nonstop-nsx' } ],
980 [ 'nsx-tandem-nsk.*', { target => 'nonstop-nsx' } ],
981
e39795af
RL
982 ];
983
984# Map GUESSOS into OpenSSL terminology.
985# Returns a hash table with diverse entries, most importantly 'target',
986# but also other entries that are fitting for Configure's %config
987# and MACHINE.
988# It would be nice to fix this so that this weren't necessary. :( XXX
989sub map_guess {
990 my $GUESSOS = shift;
991
992 foreach my $tuple ( @$map_patterns ) {
993 my $pat = @$tuple[0];
994 next if $GUESSOS !~ /^${pat}$/;
995 my $result = @$tuple[1];
996 $result = $result->() if ref $result eq 'CODE';
997 return %$result;
4901b570
RS
998 }
999
1000 # Last case, return "z" from x-y-z
1001 my @fields = split(/-/, $GUESSOS);
a3310b18 1002 return ( target => $fields[2] );
4901b570
RS
1003}
1004
1005# gcc < 2.8 does not support -march=ultrasparc
1006sub check_solaris_sparc8 {
1007 my $OUT = shift;
a3310b18
RL
1008 if ( $CCVENDOR eq 'gnu' && $CCVER < 208 ) {
1009 if ( $OUT eq 'solaris-sparcv9-gcc' ) {
1010 print <<EOF;
4901b570
RS
1011WARNING! Downgrading to solaris-sparcv8-gcc
1012 Upgrade to gcc-2.8 or later.
1013EOF
a3310b18
RL
1014 maybe_abort();
1015 return 'solaris-sparcv8-gcc';
1016 }
1017 if ( $OUT eq "linux-sparcv9" ) {
1018 print <<EOF;
4901b570
RS
1019WARNING! Downgrading to linux-sparcv8
1020 Upgrade to gcc-2.8 or later.
1021EOF
a3310b18
RL
1022 maybe_abort();
1023 return 'linux-sparcv8';
1024 }
4901b570
RS
1025 }
1026 return $OUT;
1027}
1028
4901b570
RS
1029###
1030### MAIN PROCESSING
1031###
1032
4901b570 1033sub get_platform {
e39795af
RL
1034 my %options = @_;
1035
4901b570 1036 $VERBOSE = 1 if defined $options{verbose};
4901b570 1037 $WAIT = 0 if defined $options{nowait};
e39795af
RL
1038 $CC = $options{CC};
1039 $CROSS_COMPILE = $options{CROSS_COMPILE} // '';
4901b570 1040
e39795af
RL
1041 my $GUESSOS = guess_system();
1042 determine_compiler_settings();
4901b570 1043
e39795af
RL
1044 my %ret = map_guess($GUESSOS);
1045 $ret{target} = check_solaris_sparc8($ret{target});
1046 return %ret;
4901b570
RS
1047}
1048
10491;