2 # Copyright 1998-2021 The OpenSSL Project Authors. All Rights Reserved.
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
9 # Determine the operating system and run ./Configure. Far descendant from
10 # Apache's minarch and GuessOS.
12 package OpenSSL
::config
;
22 # These control our behavior.
25 my $WHERE = dirname
($0);
28 # Machine type, etc., used to determine the platform
38 # Some environment variables; they will affect Configure
39 my $CONFIG_OPTIONS = $ENV{CONFIG_OPTIONS
} // '';
43 # For determine_compiler_settings, the list of known compilers
44 my @c_compilers = qw(clang gcc cc);
45 # Methods to determine compiler version. The expected output is one of
46 # MAJOR or MAJOR.MINOR or MAJOR.MINOR.PATCH... or false if the compiler
47 # isn't of the given brand.
48 # This is a list to ensure that gnu comes last, as we've made it a fallback
52 my $v = `$CROSS_COMPILE$CC -v 2>&1`;
53 $v =~ m/(?:(?:clang|LLVM) version|.*based on LLVM)\s+([0-9]+\.[0-9]+)/;
57 my $v = `$CROSS_COMPILE$CC -dumpversion 2>/dev/null`;
58 # Strip off whatever prefix egcs prepends the number with.
59 # Hopefully, this will work for any future prefixes as well.
60 $v =~ s/^[a-zA-Z]*\-//;
65 # This is what we will set as the target for calling Configure.
68 # Pattern matches against "${SYSTEM}:${RELEASE}:${VERSION}:${MACHINE}"
69 # The patterns are assumed to be wrapped like this: /^(${pattern})$/
70 my $guess_patterns = [
71 [ 'A\/UX:.*', 'm68k-apple-aux3' ],
72 [ 'AIX:[3-9]:4:.*', '${MACHINE}-ibm-aix' ],
73 [ 'AIX:.*?:[5-9]:.*', '${MACHINE}-ibm-aix' ],
74 [ 'AIX:.*', '${MACHINE}-ibm-aix3' ],
75 [ 'HI-UX:.*', '${MACHINE}-hi-hiux' ],
78 my $HPUXVER = $RELEASE;
79 $HPUXVER = s/[^.]*.[0B]*//;
80 # HPUX 10 and 11 targets are unified
81 return "${MACHINE}-hp-hpux1x" if $HPUXVER =~ m
@1[0-9]@
;
82 return "${MACHINE}-hp-hpux";
85 [ 'IRIX:6\..*', 'mips3-sgi-irix' ],
86 [ 'IRIX64:.*', 'mips4-sgi-irix64' ],
87 [ 'Linux:[2-9]\..*', '${MACHINE}-whatever-linux2' ],
88 [ 'Linux:1\..*', '${MACHINE}-whatever-linux1' ],
89 [ 'GNU.*', 'hurd-x86' ],
90 [ 'LynxOS:.*', '${MACHINE}-lynx-lynxos' ],
91 # BSD/OS always says 386
92 [ 'BSD\/OS:4\..*', 'i486-whatever-bsdi4' ],
93 # Order is important, this has to appear before 'BSD\/386:'
94 [ 'BSD/386:.*?:.*?:.*486.*|BSD/OS:.*?:.*?:.*?:.*486.*',
96 my $BSDVAR = `/sbin/sysctl -n hw.model`;
97 return "i586-whatever-bsdi" if $BSDVAR =~ m
@Pentium@
;
98 return "i386-whatever-bsdi";
101 [ 'BSD\/386:.*|BSD\/OS:.*', '${MACHINE}-whatever-bsdi' ],
102 # Order is important, this has to appear before 'FreeBSD:'
103 [ 'FreeBSD:.*?:.*?:.*386.*',
107 my $MACH = `sysctl -n hw.model`;
108 $MACH = "i386" if $MACH =~ m
@386@
;
109 $MACH = "i486" if $MACH =~ m
@486@
;
110 $MACH = "i686" if $MACH =~ m
@Pentium II@
;
111 $MACH = "i586" if $MACH =~ m
@Pentium@
;
112 $MACH = "$MACHINE" if $MACH !~ /i.86/;
113 my $ARCH = 'whatever';
114 $ARCH = "pc" if $MACH =~ m
@i[0-9]86@
;
115 return "${MACH}-${ARCH}-freebsd${VERS}";
118 [ 'DragonFly:.*', '${MACHINE}-whatever-dragonfly' ],
119 [ 'FreeBSD:.*', '${MACHINE}-whatever-freebsd' ],
120 [ 'Haiku:.*', '${MACHINE}-whatever-haiku' ],
121 # Order is important, this has to appear before 'NetBSD:.*'
122 [ 'NetBSD:.*?:.*?:.*386.*',
124 my $hw = `/usr/sbin/sysctl -n hw.model || /sbin/sysctl -n hw.model`;
125 $hw =~ s@
.*(.)86-class.*@i${1}86@
;
126 return "${hw}-whatever-netbsd";
129 [ 'NetBSD:.*', '${MACHINE}-whatever-netbsd' ],
130 [ 'OpenBSD:.*', '${MACHINE}-whatever-openbsd' ],
131 [ 'OpenUNIX:.*', '${MACHINE}-unknown-OpenUNIX${VERSION}' ],
132 [ 'OSF1:.*?:.*?:.*alpha.*',
134 my $OSFMAJOR = $RELEASE;
135 $OSFMAJOR =~ 's/^V([0-9]*)\..*$/\1/';
136 return "${MACHINE}-dec-tru64" if $OSFMAJOR =~ m@
[45]@
;
137 return "${MACHINE}-dec-osf";
140 [ 'Paragon.*?:.*', 'i860-intel-osf1' ],
141 [ 'Rhapsody:.*', 'ppc-apple-rhapsody' ],
142 [ 'Darwin:.*?:.*?:Power.*', 'ppc-apple-darwin' ],
143 [ 'Darwin:.*', '${MACHINE}-apple-darwin' ],
144 [ 'SunOS:5\..*', '${MACHINE}-whatever-solaris2' ],
145 [ 'SunOS:.*', '${MACHINE}-sun-sunos4' ],
146 [ 'UNIX_System_V:4\..*?:.*', '${MACHINE}-whatever-sysv4' ],
147 [ 'VOS:.*?:.*?:i786', 'i386-stratus-vos' ],
148 [ 'VOS:.*?:.*?:.*', 'hppa1.1-stratus-vos' ],
149 [ '.*?:4.*?:R4.*?:m88k', '${MACHINE}-whatever-sysv4' ],
150 [ 'DYNIX\/ptx:4.*?:.*', '${MACHINE}-whatever-sysv4' ],
151 [ '.*?:4\.0:3\.0:3[34]..(,.*)?', 'i486-ncr-sysv4' ],
152 [ 'ULTRIX:.*', '${MACHINE}-unknown-ultrix' ],
153 [ 'POSIX-BC.*', 'BS2000-siemens-sysv4' ],
154 [ 'machten:.*', '${MACHINE}-tenon-${SYSTEM}' ],
155 [ 'library:.*', '${MACHINE}-ncr-sysv4' ],
156 [ 'ConvexOS:.*?:11\.0:.*', '${MACHINE}-v11-${SYSTEM}' ],
157 [ 'MINGW64.*?:.*?:.*?:x86_64', '${MACHINE}-whatever-mingw64' ],
158 [ 'MINGW.*', '${MACHINE}-whatever-mingw' ],
159 [ 'CYGWIN.*', '${MACHINE}-pc-cygwin' ],
160 [ 'vxworks.*', '${MACHINE}-whatever-vxworks' ],
162 # Note: there's also NEO and NSR, but they are old and unsupported
163 [ 'NONSTOP_KERNEL:.*:NSE-.*?', 'nse-tandem-nsk${RELEASE}' ],
164 [ 'NONSTOP_KERNEL:.*:NSV-.*?', 'nsv-tandem-nsk${RELEASE}' ],
165 [ 'NONSTOP_KERNEL:.*:NSX-.*?', 'nsx-tandem-nsk${RELEASE}' ],
167 [ sub { -d
'/usr/apollo' }, 'whatever-apollo-whatever' ],
170 # Run a command, return true if exit zero else false.
171 # Multiple args are glued together into a pipeline.
172 # Name comes from OpenSSL tests, often written as "ok(run(...."
174 my $command = join(' | ', @_);
175 my $status = system($command) >> 8;
179 # Give user a chance to abort/interrupt if interactive if interactive.
181 if ( $WAIT && -t
1 ) {
183 local $SIG{ALRM
} = sub { die "Timeout"; };
186 print "You have about five seconds to abort: ";
187 my $ignored = <STDIN
>;
190 print "\n" if $@
=~ /Timeout/;
194 # Look for ISC/SCO with its unique uname program
196 return undef unless IPC
::Cmd
::can_run
('uname');
198 open UNAME
, "uname -X 2>/dev/null|" or return '';
203 $line = $_ if m@
^Release@
;
204 $os = $_ if m@
^System@
;
208 return undef if $line eq '' or $os eq 'System = SunOS';
210 my @fields = split(/\s+/, $line);
217 if ( -f
"/etc/kconfig" ) {
218 return "${MACHINE}-whatever-isc4" if $REL eq '4.0' || $REL eq '4.1';
220 return "whatever-whatever-sco3" if $REL eq '3.2v4.2';
221 return "whatever-whatever-sco5" if $REL =~ m
@3\
.2v5\
.0.*@
;
222 if ( $REL eq "4.2MP" ) {
223 return "whatever-whatever-unixware20" if $VERSION =~ m
@2\
.0.*@
;
224 return "whatever-whatever-unixware21" if $VERSION =~ m
@2\
.1.*@
;
225 return "whatever-whatever-unixware2" if $VERSION =~ m
@2.*@
;
227 return "whatever-whatever-unixware1" if $REL eq "4.2";
228 if ( $REL =~ m
@5.*@
) {
229 # We hardcode i586 in place of ${MACHINE} for the following
230 # reason: even though Pentium is minimum requirement for
231 # platforms in question, ${MACHINE} gets always assigned to
232 # i386. This means i386 gets passed to Configure, which will
233 # cause bad assembler code to be generated.
234 return "i586-sco-unixware7" if $VERSION =~ m@
[678].*@
;
239 # Return the cputype-vendor-osversion
241 ($SYSTEM, undef, $RELEASE, $VERSION, $MACHINE) = POSIX
::uname
();
242 my $sys = "${SYSTEM}:${RELEASE}:${VERSION}:${MACHINE}";
244 # Special-cases for ISC, SCO, Unixware
245 my $REL = is_sco_uname
();
246 if ( defined $REL ) {
247 my $result = get_sco_type
($REL);
248 return eval "\"$result\"" if $result ne '';
254 foreach my $tuple ( @
$guess_patterns ) {
255 my $pat = @
$tuple[0];
256 my $check = ref $pat eq 'CODE' ?
$pat->($sys) : $sys =~ /^(${pat})$/;
259 my $result = @
$tuple[1];
260 $result = $result->() if ref $result eq 'CODE';
261 return eval "\"$result\"";
265 return "${MACHINE}-whatever-${SYSTEM}";
268 # We would use List::Util::pair() for this... unfortunately, that function
269 # only appeared in perl v5.19.3, and we claim to support perl v5.10 and on.
270 # Therefore, we implement a quick cheap variant of our own.
272 croak
"Odd number of arguments" if @_ & 1;
277 my $x = [ shift, shift ];
283 # Figure out CC, GCCVAR, etc.
284 sub determine_compiler_settings
{
285 # Make a copy and don't touch it. That helps determine if we're finding
286 # the compiler here (false), or if it was set by the user (true.
289 # Set certain default
290 $CCVER = 0; # Unknown
291 $CCVENDOR = ''; # Dunno, don't care (unless found later)
293 # Find a compiler if we don't already have one
295 foreach (@c_compilers) {
296 next unless IPC
::Cmd
::can_run
("$CROSS_COMPILE$_");
303 # Find the compiler vendor and version number for certain compilers
304 foreach my $pair (_pairs
@cc_version) {
305 # Try to get the version number.
306 # Failure gets us undef or an empty string
307 my ( $k, $v ) = @
$pair;
310 # If we got a version number, process it
314 # The returned version is expected to be one of
318 # MAJOR.MINOR.{whatever}
320 # We don't care what comes after MAJOR.MINOR. All we need is
321 # to have them calculated into a single number, using this
324 # MAJOR * 100 + MINOR
325 # Here are a few examples of what we should get:
330 my @numbers = split /\./, $v;
331 my @factors = (100, 1);
332 while (@numbers && @factors) {
333 $CCVER += shift(@numbers) * shift(@factors)
340 # Vendor specific overrides, only if we didn't determine the compiler here
342 if ( $SYSTEM eq 'OpenVMS' ) {
343 my $v = `CC/VERSION NLA0:`;
345 my ($vendor, $version) =
346 ( $v =~ m/^([A-Z]+) C V([0-9\.-]+) on / );
347 my ($major, $minor, $patch) =
348 ( $version =~ m/^([0-9]+)\.([0-9]+)-0*?(0|[1-9][0-9]*)$/ );
351 $CCVER = ( $major * 100 + $minor ) * 100 + $patch;
355 if ( ${SYSTEM
} eq 'AIX' ) {
356 # favor vendor cc over gcc
357 if (IPC
::Cmd
::can_run
('cc')) {
359 $CCVENDOR = ''; # Determine later
364 if ( $SYSTEM eq "SunOS" ) {
365 # check for Oracle Developer Studio, expected output is "cc: blah-blah C x.x blah-blah"
366 my $v = `(cc -V 2>&1) 2>/dev/null | egrep -e '^cc: .* C [0-9]\.[0-9]'`;
368 ( $v =~ m/^.* C ([0-9]+)\.([0-9]+) .*/ );
369 my @factors = (100, 1);
371 while (@numbers && @factors) {
372 $v += shift(@numbers) * shift(@factors)
383 # If no C compiler has been determined at this point, we die. Hard.
386 No C compiler found
, please specify one with the environment variable CC
,
387 or configure with an explicit configuration target
.
391 # On some systems, we assume a cc vendor if it's not already determined
394 $CCVENDOR = 'aix' if $SYSTEM eq 'AIX';
395 $CCVENDOR = 'sun' if $SYSTEM eq 'SunOS';
398 # Some systems need to know extra details
400 if ( $SYSTEM eq "HP-UX" && $CCVENDOR eq 'gnu' ) {
401 # By default gcc is a ILP32 compiler (with long long == 64).
403 if ( $CCVER >= 300 ) {
404 # PA64 support only came in with gcc 3.0.x.
405 # We check if the preprocessor symbol __LP64__ is defined.
406 if ( okrun
('echo __LP64__',
407 "$CC -v -E -x c - 2>/dev/null",
408 'grep "^__LP64__" 2>&1 >/dev/null') ) {
409 # __LP64__ has slipped through, it therefore is not defined
416 if ( $SYSTEM eq "SunOS" && $CCVENDOR eq 'gnu' ) {
417 if ( $CCVER >= 300 ) {
418 # 64-bit ABI isn't officially supported in gcc 3.0, but seems
419 # to be working; at the very least 'make test' passes.
420 if ( okrun
("$CC -v -E -x c /dev/null 2>&1",
421 'grep __arch64__ >/dev/null') ) {
430 my $vendor = $CCVENDOR ?
$CCVENDOR : "(undetermined)";
431 my $version = $CCVER ?
$CCVER : "(undetermined)";
432 print "C compiler: $CC\n";
433 print "C compiler vendor: $vendor\n";
434 print "C compiler version: $version\n";
439 [ [ 'uClinux.*64.*', { target
=> 'uClinux-dist64' } ],
440 [ 'uClinux.*', { target
=> 'uClinux-dist' } ],
441 [ 'mips3-sgi-irix', { target
=> 'irix-mips3' } ],
442 [ 'mips4-sgi-irix64',
445 WARNING! To build 64-bit package, do this:
446 $WHERE/Configure irix64-mips4-$CC
449 return { target
=> "irix-mips3" };
452 [ 'ppc-apple-rhapsody', { target
=> "rhapsody-ppc" } ],
453 [ 'ppc-apple-darwin.*',
455 my $KERNEL_BITS = $ENV{KERNEL_BITS
} // '';
456 my $ISA64 = `sysctl -n hw.optional.64bitops 2>/dev/null`;
457 if ( $ISA64 == 1 && $KERNEL_BITS eq '' ) {
459 WARNING! To build 64-bit package, do this:
460 $WHERE/Configure darwin64-ppc-cc
464 return { target
=> "darwin64-ppc" }
465 if $ISA64 == 1 && $KERNEL_BITS eq '64';
466 return { target
=> "darwin-ppc" };
469 [ 'i.86-apple-darwin.*',
471 my $KERNEL_BITS = $ENV{KERNEL_BITS
} // '';
472 my $ISA64 = `sysctl -n hw.optional.x86_64 2>/dev/null`;
473 if ( $ISA64 == 1 && $KERNEL_BITS eq '' ) {
475 WARNING! To build 64-bit package, do this:
476 KERNEL_BITS=64 $WHERE/Configure [options...]
480 return { target
=> "darwin64-x86_64" }
481 if $ISA64 == 1 && $KERNEL_BITS eq '64';
482 return { target
=> "darwin-i386" };
485 [ 'x86_64-apple-darwin.*',
487 my $KERNEL_BITS = $ENV{KERNEL_BITS
} // '';
488 return { target
=> "darwin-i386" } if $KERNEL_BITS eq '32';
491 WARNING! To build 32-bit package, do this:
492 KERNEL_BITS=32 $WHERE/Configure [options...]
495 return { target
=> "darwin64-x86_64" };
498 [ 'arm64-apple-darwin.*', { target
=> "darwin64-arm64" } ],
499 [ 'armv6\+7-.*-iphoneos',
500 { target
=> "iphoneos-cross",
501 cflags
=> [ qw(-arch armv6 -arch armv7) ],
502 cxxflags
=> [ qw(-arch armv6 -arch armv7) ] }
504 [ 'arm64-.*-iphoneos|.*-.*-ios64',
505 { target
=> "ios64-cross" }
508 sub { return { target
=> "iphoneos-cross",
509 cflags
=> [ "-arch ${MACHINE}" ],
510 cxxflags
=> [ "-arch ${MACHINE}" ] }; }
512 [ 'alpha-.*-linux2.*',
514 my $ISA = `awk '/cpu model/{print \$4;exit(0);}' /proc/cpuinfo`;
517 if ( $CCVENDOR eq "gnu" ) {
518 if ( $ISA =~ 'EV5|EV45' ) {
519 %config = ( cflags
=> [ '-mcpu=ev5' ],
520 cxxflags
=> [ '-mcpu=ev5' ] );
521 } elsif ( $ISA =~ 'EV56|PCA56' ) {
522 %config = ( cflags
=> [ '-mcpu=ev56' ],
523 cxxflags
=> [ '-mcpu=ev56' ] );
525 %config = ( cflags
=> [ '-mcpu=ev6' ],
526 cxxflags
=> [ '-mcpu=ev6' ] );
529 return { target
=> "linux-alpha",
535 my $KERNEL_BITS = $ENV{KERNEL_BITS
} // '';
536 if ( $KERNEL_BITS eq '' ) {
538 WARNING! To build 64-bit package, do this:
539 $WHERE/Configure linux-ppc64
543 return { target
=> "linux-ppc64" } if $KERNEL_BITS eq '64';
546 if (!okrun
('echo __LP64__',
547 'gcc -E -x c - 2>/dev/null',
548 'grep "^__LP64__" 2>&1 >/dev/null') ) {
549 %config = ( cflags
=> [ '-m32' ],
550 cxxflags
=> [ '-m32' ] );
552 return { target
=> "linux-ppc",
556 [ 'ppc64le-.*-linux2', { target
=> "linux-ppc64le" } ],
557 [ 'ppc-.*-linux2', { target
=> "linux-ppc" } ],
558 [ 'mips64.*-*-linux2',
561 WARNING! To build 64-bit package, do this:
562 $WHERE/Configure linux64-mips64
565 return { target
=> "linux-mips64" };
568 [ 'mips.*-.*-linux2', { target
=> "linux-mips32" } ],
569 [ 'ppc60x-.*-vxworks.*', { target
=> "vxworks-ppc60x" } ],
570 [ 'ppcgen-.*-vxworks.*', { target
=> "vxworks-ppcgen" } ],
571 [ 'pentium-.*-vxworks.*', { target
=> "vxworks-pentium" } ],
572 [ 'simlinux-.*-vxworks.*', { target
=> "vxworks-simlinux" } ],
573 [ 'mips-.*-vxworks.*', { target
=> "vxworks-mips" } ],
574 [ 'e2k-.*-linux.*', { target
=> "linux-generic64",
575 defines
=> [ 'L_ENDIAN' ] } ],
576 [ 'ia64-.*-linux.', { target
=> "linux-ia64" } ],
577 [ 'sparc64-.*-linux2',
580 WARNING! If you *know* that your GNU C supports 64-bit/V9 ABI and you
581 want to build 64-bit library, do this:
582 $WHERE/Configure linux64-sparcv9
585 return { target
=> "linux-sparcv9" };
590 my $KARCH = `awk '/^type/{print \$3;exit(0);}' /proc/cpuinfo`;
592 return { target
=> "linux-sparcv9" } if $KARCH =~ 'sun4u.*';
593 return { target
=> "linux-sparcv8" } if $KARCH =~ 'sun4[md]';
594 return { target
=> "linux-generic32",
595 defines
=> [ 'L_ENDIAN' ] };
598 [ 'parisc.*-.*-linux2',
600 # 64-bit builds under parisc64 linux are not supported and
601 # compiler is expected to generate 32-bit objects...
603 `awk '/cpu family/{print substr(\$5,1,3); exit(0);}' /proc/cpuinfo`;
605 `awk '/^cpu.[ ]*: PA/{print substr(\$3,3); exit(0);}' /proc/cpuinfo`;
606 # TODO XXX Model transformations
607 # 0. CPU Architecture for the 1.1 processor has letter suffixes.
608 # We strip that off assuming no further arch. identification
609 # will ever be used by GCC.
610 # 1. I'm most concerned about whether is a 7300LC is closer to a
611 # 7100 versus a 7100LC.
612 # 2. The variant 64-bit processors cause concern should GCC support
613 # explicit schedulers for these chips in the future.
614 # PA7300LC -> 7100LC (1.1)
615 # PA8200 -> 8000 (2.0)
616 # PA8500 -> 8000 (2.0)
617 # PA8600 -> 8000 (2.0)
618 $CPUSCHEDULE =~ s/7300LC/7100LC/;
619 $CPUSCHEDULE =~ s/8.00/8000/;
621 { target
=> "linux-generic32",
622 defines
=> [ 'B_ENDIAN' ],
623 cflags
=> [ "-mschedule=$CPUSCHEDULE", "-march=$CPUARCH" ],
624 cxxflags
=> [ "-mschedule=$CPUSCHEDULE", "-march=$CPUARCH" ]
628 [ 'armv[1-3].*-.*-linux2', { target
=> "linux-generic32" } ],
629 [ 'armv[7-9].*-.*-linux2', { target
=> "linux-armv4",
630 cflags
=> [ '-march=armv7-a' ],
631 cxxflags
=> [ '-march=armv7-a' ] } ],
632 [ 'arm.*-.*-linux2', { target
=> "linux-armv4" } ],
633 [ 'aarch64-.*-linux2', { target
=> "linux-aarch64" } ],
634 [ 'sh.*b-.*-linux2', { target
=> "linux-generic32",
635 defines
=> [ 'B_ENDIAN' ] } ],
636 [ 'sh.*-.*-linux2', { target
=> "linux-generic32",
637 defines
=> [ 'L_ENDIAN' ] } ],
638 [ 'm68k.*-.*-linux2', { target
=> "linux-generic32",
639 defines
=> [ 'B_ENDIAN' ] } ],
640 [ 's390-.*-linux2', { target
=> "linux-generic32",
641 defines
=> [ 'B_ENDIAN' ] } ],
644 # Disabled until a glibc bug is fixed; see Configure.
646 || okrun
('egrep -e \'^features.* highgprs\' /proc/cpuinfo >/dev/null') )
649 WARNING! To build "highgprs" 32-bit package, do this:
650 $WHERE/Configure linux32-s390x
654 return { target
=> "linux64-s390x" };
657 [ 'x86_64-.*-linux.',
659 return { target
=> "linux-x32" }
660 if okrun
("$CC -dM -E -x c /dev/null 2>&1",
661 'grep -q ILP32 >/dev/null');
662 return { target
=> "linux-x86_64" };
667 # On machines where the compiler understands -m32, prefer a
668 # config target that uses it
669 return { target
=> "linux-x86" }
670 if okrun
("$CC -m32 -E -x c /dev/null >/dev/null 2>&1");
671 return { target
=> "linux-elf" };
674 [ '.*86-.*-linux1', { target
=> "linux-aout" } ],
675 [ 'riscv64-.*-linux.', { target
=> "linux64-riscv64" } ],
676 [ '.*-.*-linux.', { target
=> "linux-generic32" } ],
677 [ 'sun4[uv].*-.*-solaris2',
679 my $KERNEL_BITS = $ENV{KERNEL_BITS
};
680 my $ISA64 = `isainfo 2>/dev/null | grep sparcv9`;
681 my $KB = $KERNEL_BITS // '64';
682 if ( $ISA64 ne "" && $KB eq '64' ) {
683 if ( $CCVENDOR eq "sun" && $CCVER >= 500 ) {
685 WARNING! To build 32-bit package, do this:
686 $WHERE/Configure solaris-sparcv9-cc
689 } elsif ( $CCVENDOR eq "gnu" && $GCC_ARCH eq "-m64" ) {
690 # $GCC_ARCH denotes default ABI chosen by compiler driver
691 # (first one found on the $PATH). I assume that user
692 # expects certain consistency with the rest of his builds
693 # and therefore switch over to 64-bit. <appro>
695 WARNING! To build 32-bit package, do this:
696 $WHERE/Configure solaris-sparcv9-gcc
699 return { target
=> "solaris64-sparcv9-gcc" };
700 } elsif ( $GCC_ARCH eq "-m32" ) {
702 NOTICE! If you *know* that your GNU C supports 64-bit/V9 ABI and you wish
703 to build 64-bit library, do this:
704 $WHERE/Configure solaris64-sparcv9-gcc
709 return { target
=> "solaris64-sparcv9-cc" }
710 if $ISA64 ne "" && $KB eq '64';
711 return { target
=> "solaris-sparcv9-cc" };
714 [ 'sun4m-.*-solaris2', { target
=> "solaris-sparcv8" } ],
715 [ 'sun4d-.*-solaris2', { target
=> "solaris-sparcv8" } ],
716 [ 'sun4.*-.*-solaris2', { target
=> "solaris-sparcv7" } ],
717 [ '.*86.*-.*-solaris2',
719 my $KERNEL_BITS = $ENV{KERNEL_BITS
};
720 my $ISA64 = `isainfo 2>/dev/null | grep amd64`;
721 my $KB = $KERNEL_BITS // '64';
722 if ($ISA64 ne "" && $KB eq '64') {
723 return { target
=> "solaris64-x86_64-gcc" } if $CCVENDOR eq "gnu";
724 return { target
=> "solaris64-x86_64-cc" };
726 my $REL = uname
('-r');
728 my @tmp_disable = ();
729 push @tmp_disable, 'sse2' if int($REL) < 10;
730 #There is no solaris-x86-cc target
731 return { target
=> "solaris-x86-gcc",
732 disable
=> [ @tmp_disable ] };
735 # We don't have any sunos target in Configurations/*.conf, so why here?
736 [ '.*-.*-sunos4', { target
=> "sunos" } ],
737 [ '.*86.*-.*-bsdi4', { target
=> "BSD-x86-elf",
738 lflags
=> [ '-ldl' ],
739 disable
=> [ 'sse2' ] } ],
740 [ 'alpha.*-.*-.*bsd.*', { target
=> "BSD-generic64",
741 defines
=> [ 'L_ENDIAN' ] } ],
742 [ 'powerpc-.*-.*bsd.*', { target
=> "BSD-ppc" } ],
743 [ 'powerpc64-.*-.*bsd.*', { target
=> "BSD-ppc64" } ],
744 [ 'powerpc64le-.*-.*bsd.*', { target
=> "BSD-ppc64le" } ],
745 [ 'riscv64-.*-.*bsd.*', { target
=> "BSD-riscv64" } ],
746 [ 'sparc64-.*-.*bsd.*', { target
=> "BSD-sparc64" } ],
747 [ 'ia64-.*-.*bsd.*', { target
=> "BSD-ia64" } ],
748 [ 'x86_64-.*-dragonfly.*', { target
=> "BSD-x86_64" } ],
749 [ 'amd64-.*-.*bsd.*', { target
=> "BSD-x86_64" } ],
750 [ 'arm64-.*-.*bsd.*', { target
=> "BSD-aarch64" } ],
751 [ '.*86.*-.*-.*bsd.*',
753 # mimic ld behaviour when it's looking for libc...
755 if ( -l
"/usr/lib/libc.so" ) {
756 $libc = "/usr/lib/libc.so";
758 # ld searches for highest libc.so.* and so do we
760 `(ls /usr/lib/libc.so.* /lib/libc.so.* | tail -1) 2>/dev/null`;
762 my $what = `file -L $libc 2>/dev/null`;
763 return { target
=> "BSD-x86-elf" } if $what =~ /ELF/;
764 return { target
=> "BSD-x86",
765 disable
=> [ 'sse2' ] };
768 [ '.*-.*-.*bsd.*', { target
=> "BSD-generic32" } ],
769 [ 'x86_64-.*-haiku', { target
=> "haiku-x86_64" } ],
770 [ '.*-.*-haiku', { target
=> "haiku-x86" } ],
771 [ '.*-.*-osf', { target
=> "osf1-alpha" } ],
772 [ '.*-.*-tru64', { target
=> "tru64-alpha" } ],
773 [ '.*-.*-[Uu]nix[Ww]are7',
775 return { target
=> "unixware-7",
776 disable
=> [ 'sse2' ] } if $CCVENDOR eq "gnu";
777 return { target
=> "unixware-7",
778 defines
=> [ '__i386__' ] };
781 [ '.*-.*-[Uu]nix[Ww]are20.*', { target
=> "unixware-2.0",
782 disable
=> [ 'sse2', 'sha512' ] } ],
783 [ '.*-.*-[Uu]nix[Ww]are21.*', { target
=> "unixware-2.1",
784 disable
=> [ 'sse2', 'sha512' ] } ],
785 [ '.*-.*-vos', { target
=> "vos",
786 disable
=> [ 'threads', 'shared', 'asm',
788 [ 'BS2000-siemens-sysv4', { target
=> "BS2000-OSD" } ],
789 [ 'i[3456]86-.*-cygwin', { target
=> "Cygwin-x86" } ],
791 sub { return { target
=> "Cygwin-${MACHINE}" } } ],
792 [ 'x86-.*-android|i.86-.*-android', { target
=> "android-x86" } ],
793 [ 'armv[7-9].*-.*-android', { target
=> "android-armeabi",
794 cflags
=> [ '-march=armv7-a' ],
795 cxxflags
=> [ '-march=armv7-a' ] } ],
796 [ 'arm.*-.*-android', { target
=> "android-armeabi" } ],
799 my $KERNEL_BITS = $ENV{KERNEL_BITS
};
800 my %common_return = ( defines
=> [ '_REENTRANT' ] );
801 $KERNEL_BITS ||= `getconf KERNEL_BITS 2>/dev/null` // '32';
802 # See <sys/unistd.h> for further info on CPU_VERSION.
803 my $CPU_VERSION = `getconf CPU_VERSION 2>/dev/null` // 0;
804 if ( $CPU_VERSION >= 768 ) {
806 return { target
=> "hpux64-ia64",
808 if $KERNEL_BITS eq '64' && ! $CCVENDOR;
809 return { target
=> "hpux-ia64",
812 if ( $CPU_VERSION >= 532 ) {
814 # PA-RISC 2.0 is no longer supported as separate 32-bit
815 # target. This is compensated for by run-time detection
816 # in most critical assembly modules and taking advantage
817 # of 2.0 architecture in PA-RISC 1.1 build.
818 my $target = ($CCVENDOR eq "gnu" && $GCC_BITS eq '64')
821 if ( $KERNEL_BITS eq '64' && ! $CCVENDOR ) {
823 WARNING! To build 64-bit package, do this:
824 $WHERE/Configure hpux64-parisc2-cc
828 return { target
=> $target,
832 return { target
=> "hpux-parisc1_1",
833 %common_return } if $CPU_VERSION >= 528;
835 return { target
=> "hpux-parisc",
836 %common_return } if $CPU_VERSION >= 523;
838 return { target
=> "hpux",
842 [ '.*-hpux', { target
=> "hpux-parisc" } ],
846 my $KERNEL_BITS = $ENV{KERNEL_BITS
};
847 $KERNEL_BITS ||= `getconf KERNEL_BITMODE 2>/dev/null`;
848 $KERNEL_BITS ||= '32';
849 my $OBJECT_MODE = $ENV{OBJECT_MODE
};
851 $config{target
} = "aix";
852 if ( $OBJECT_MODE == 64 ) {
853 print 'Your $OBJECT_MODE was found to be set to 64';
854 $config{target
} = "aix64";
856 if ( $CCVENDOR ne 'gnu' && $KERNEL_BITS eq '64' ) {
858 WARNING! To build 64-bit package, do this:
859 $WHERE/Configure aix64-cc
865 "(lsattr -E -O -l `lsdev -c processor|awk '{print \$1;exit}'`",
866 'grep -i powerpc) >/dev/null 2>&1') ) {
867 # this applies even to Power3 and later, as they return
870 $config{disable
} = [ 'asm' ];
876 # Windows values found by looking at Perl 5's win32/win32.c
877 [ 'amd64-.*?-Windows NT', { target
=> 'VC-WIN64A' } ],
878 [ 'ia64-.*?-Windows NT', { target
=> 'VC-WIN64I' } ],
879 [ 'x86-.*?-Windows NT', { target
=> 'VC-WIN32' } ],
881 # VMS values found by observation on existing machinery.
882 # Unfortunately, the machine part is a bit... overdone. It seems,
883 # though, that 'Alpha' exists in that part for Alphas, making it
884 # distinguishable from Itanium. It will be interesting to see what
885 # we'll get in the upcoming x86_64 port...
886 [ '.*Alpha.*?-.*?-OpenVMS', { target
=> 'vms-alpha' } ],
887 [ '.*?-.*?-OpenVMS', { target
=> 'vms-ia64' } ],
889 # TODO: There are a few more choices among OpenSSL config targets, but
890 # reaching them involves a bit more than just a host tripet. Select
891 # environment variables could do the job to cover for more granular
892 # build options such as data model (ILP32 or LP64), thread support
893 # model (PUT, SPT or nothing), target execution environment (OSS or
894 # GUARDIAN). And still, there must be some kind of default when
895 # nothing else is said.
897 # nsv is a virtual x86 environment, equivalent to nsx, so we enforce
899 [ 'nse-tandem-nsk.*', { target
=> 'nonstop-nse' } ],
900 [ 'nsv-tandem-nsk.*', { target
=> 'nonstop-nsx' } ],
901 [ 'nsx-tandem-nsk.*', { target
=> 'nonstop-nsx' } ],
905 # Map GUESSOS into OpenSSL terminology.
906 # Returns a hash table with diverse entries, most importantly 'target',
907 # but also other entries that are fitting for Configure's %config
909 # It would be nice to fix this so that this weren't necessary. :( XXX
913 foreach my $tuple ( @
$map_patterns ) {
914 my $pat = @
$tuple[0];
915 next if $GUESSOS !~ /^${pat}$/;
916 my $result = @
$tuple[1];
917 $result = $result->() if ref $result eq 'CODE';
921 # Last case, return "z" from x-y-z
922 my @fields = split(/-/, $GUESSOS);
923 return ( target
=> $fields[2] );
926 # gcc < 2.8 does not support -march=ultrasparc
927 sub check_solaris_sparc8
{
929 if ( $CCVENDOR eq 'gnu' && $CCVER < 208 ) {
930 if ( $OUT eq 'solaris-sparcv9-gcc' ) {
932 WARNING! Downgrading to solaris-sparcv8-gcc
933 Upgrade to gcc-2.8 or later.
936 return 'solaris-sparcv8-gcc';
938 if ( $OUT eq "linux-sparcv9" ) {
940 WARNING! Downgrading to linux-sparcv8
941 Upgrade to gcc-2.8 or later.
944 return 'linux-sparcv8';
957 $VERBOSE = 1 if defined $options{verbose
};
958 $WAIT = 0 if defined $options{nowait
};
960 $CROSS_COMPILE = $options{CROSS_COMPILE
} // '';
962 my $GUESSOS = guess_system
();
963 determine_compiler_settings
();
965 my %ret = map_guess
($GUESSOS);
966 $ret{target
} = check_solaris_sparc8
($ret{target
});