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