diff options
Diffstat (limited to 'util')
-rwxr-xr-x | util/perl/OpenSSL/config.pm | 208 |
1 files changed, 103 insertions, 105 deletions
diff --git a/util/perl/OpenSSL/config.pm b/util/perl/OpenSSL/config.pm index 3536f12d2b..46dad98d08 100755 --- a/util/perl/OpenSSL/config.pm +++ b/util/perl/OpenSSL/config.pm @@ -66,109 +66,115 @@ my @cc_version = my $options = ''; # Pattern matches against "${SYSTEM}:${RELEASE}:${VERSION}:${MACHINE}" -my $simple_guess_patterns = [ - [ 'A\/UX:', 'm68k-apple-aux3' ], - [ 'AIX:[3-9]:4:', '${MACHINE}-ibm-aix' ], - [ 'AIX:.*:[5-9]:', '${MACHINE}-ibm-aix' ], - [ 'AIX:', '${MACHINE}-ibm-aix3' ], - [ 'HI-UX:', '${MACHINE}-hi-hiux' ], - [ 'IRIX:6.', 'mips3-sgi-irix' ], - [ 'IRIX64:', 'mips4-sgi-irix64' ], - [ 'Linux:[2-9]', '${MACHINE}-whatever-linux2' ], - [ 'Linux:1', '${MACHINE}-whatever-linux1' ], - [ 'GNU', 'hurd-x86' ], - [ 'LynxOS:', '${MACHINE}-lynx-lynxos' ], +# The patterns are assumed to be wrapped like this: /^(${pattern})$/ +my $guess_patterns = [ + [ 'A\/UX:.*', 'm68k-apple-aux3' ], + [ 'AIX:[3-9]:4:.*', '${MACHINE}-ibm-aix' ], + [ 'AIX:.*?:[5-9]:.*', '${MACHINE}-ibm-aix' ], + [ 'AIX:.*', '${MACHINE}-ibm-aix3' ], + [ 'HI-UX:.*', '${MACHINE}-hi-hiux' ], + [ 'HP-UX:.*', + sub { + my $HPUXVER = $RELEASE; + $HPUXVER = s/[^.]*.[0B]*//; + # HPUX 10 and 11 targets are unified + return "${MACHINE}-hp-hpux1x" if $HPUXVER =~ m@1[0-9]@; + return "${MACHINE}-hp-hpux"; + } + ], + [ 'IRIX:6\..*', 'mips3-sgi-irix' ], + [ 'IRIX64:.*', 'mips4-sgi-irix64' ], + [ 'Linux:[2-9]\..*', '${MACHINE}-whatever-linux2' ], + [ 'Linux:1\..*', '${MACHINE}-whatever-linux1' ], + [ 'GNU.*', 'hurd-x86' ], + [ 'LynxOS:.*', '${MACHINE}-lynx-lynxos' ], # BSD/OS always says 386 - [ 'BSD\/OS:4.*', 'i486-whatever-bsdi4' ], - [ 'BSD\/386:.*|BSD\/OS:', '${MACHINE}-whatever-bsdi' ], - [ 'DragonFly:', '${MACHINE}-whatever-dragonfly' ], - [ 'FreeBSD:', '${MACHINE}-whatever-freebsd' ], - [ 'Haiku:', '${MACHINE}-whatever-haiku' ], - [ 'NetBSD:', '${MACHINE}-whatever-netbsd' ], - [ 'OpenBSD:', '${MACHINE}-whatever-openbsd' ], - [ 'OpenUNIX:', '${MACHINE}-unknown-OpenUNIX${VERSION}' ], - [ 'Paragon.*:', 'i860-intel-osf1' ], - [ 'Rhapsody:', 'ppc-apple-rhapsody' ], - [ 'SunOS:5.', '${MACHINE}-whatever-solaris2' ], - [ 'SunOS:', '${MACHINE}-sun-sunos4' ], - [ 'UNIX_System_V:4.*:', '${MACHINE}-whatever-sysv4' ], - [ 'VOS:.*:.*:i786', 'i386-stratus-vos' ], - [ 'VOS:.*:.*:', 'hppa1.1-stratus-vos' ], - [ '.*:4.*:R4.*:m88k', '${MACHINE}-whatever-sysv4' ], - [ 'DYNIX\/ptx:4.*:', '${MACHINE}-whatever-sysv4' ], - [ ':4.0:3.0:3[34]', 'i486-ncr-sysv4' ], - [ 'ULTRIX:', '${MACHINE}-unknown-ultrix' ], - [ 'POSIX-BC', 'BS2000-siemens-sysv4' ], - [ 'machten:', '${MACHINE}-tenon-${SYSTEM}' ], - [ 'library:', '${MACHINE}-ncr-sysv4' ], - [ 'ConvexOS:.*:11.0:', '${MACHINE}-v11-${SYSTEM}' ], - [ 'MINGW64.*:.*x86_64', '${MACHINE}-whatever-mingw64' ], - [ 'MINGW', '${MACHINE}-whatever-mingw' ], - [ 'CYGWIN', '${MACHINE}-pc-cygwin' ], - [ 'vxworks', '${MACHINE}-whatever-vxworks' ], - [ 'Darwin:.*Power', 'ppc-apple-darwin' ], - [ 'Darwin:.*x86_64', 'x86_64-apple-darwin' ], - [ 'Darwin:', 'i686-apple-darwin' ], + [ 'BSD\/OS:4\..*', 'i486-whatever-bsdi4' ], + # Order is important, this has to appear before 'BSD\/386:' + [ 'BSD/386:.*?:.*?:.*486.*|BSD/OS:.*?:.*?:.*?:.*486.*', + sub { + my $BSDVAR = `/sbin/sysctl -n hw.model`; + return "i586-whatever-bsdi" if $BSDVAR =~ m@Pentium@; + return "i386-whatever-bsdi"; + } + ], + [ 'BSD\/386:.*|BSD\/OS:.*', '${MACHINE}-whatever-bsdi' ], + # Order is important, this has to appear before 'FreeBSD:' + [ 'FreeBSD:.*?:.*?:.*386.*', + sub { + my $VERS = $RELEASE; + $VERS =~ s/[-(].*//; + my $MACH = `sysctl -n hw.model`; + $MACH = "i386" if $MACH =~ m@386@; + $MACH = "i486" if $MACH =~ m@486@; + $MACH = "i686" if $MACH =~ m@Pentium II@; + $MACH = "i586" if $MACH =~ m@Pentium@; + $MACH = "$MACHINE" if $MACH !~ /i.86/; + my $ARCH = 'whatever'; + $ARCH = "pc" if $MACH =~ m@i[0-9]86@; + return "${MACH}-${ARCH}-freebsd${VERS}"; + } + ], + [ 'DragonFly:.*', '${MACHINE}-whatever-dragonfly' ], + [ 'FreeBSD:.*', '${MACHINE}-whatever-freebsd' ], + [ 'Haiku:.*', '${MACHINE}-whatever-haiku' ], + # Order is important, this has to appear before 'NetBSD:.*' + [ 'NetBSD:.*?:.*?:.*386.*', + sub { + my $hw = `/usr/sbin/sysctl -n hw.model || /sbin/sysctl -n hw.model`; + $hw =~ s@.*(.)86-class.*@i${1}86@; + return "${hw}-whatever-netbsd"; + } + ], + [ 'NetBSD:.*', '${MACHINE}-whatever-netbsd' ], + [ 'OpenBSD:.*', '${MACHINE}-whatever-openbsd' ], + [ 'OpenUNIX:.*', '${MACHINE}-unknown-OpenUNIX${VERSION}' ], + [ 'OSF1:.*?:.*?:.*alpha.*', + sub { + my $OSFMAJOR = $RELEASE; + $OSFMAJOR =~ 's/^V([0-9]*)\..*$/\1/'; + return "${MACHINE}-dec-tru64" if $OSFMAJOR =~ m@[45]@; + return "${MACHINE}-dec-osf"; + } + ], + [ 'Paragon.*?:.*', 'i860-intel-osf1' ], + [ 'Rhapsody:.*', 'ppc-apple-rhapsody' ], + [ 'Darwin:.*?:.*?:Power.*', 'ppc-apple-darwin' ], + [ 'Darwin:.*?:.*?:x86_64', 'x86_64-apple-darwin' ], + [ 'Darwin:.*', 'i686-apple-darwin' ], + [ 'SunOS:5\..*', '${MACHINE}-whatever-solaris2' ], + [ 'SunOS:.*', '${MACHINE}-sun-sunos4' ], + [ 'UNIX_System_V:4\..*?:.*', '${MACHINE}-whatever-sysv4' ], + [ 'VOS:.*?:.*?:i786', 'i386-stratus-vos' ], + [ 'VOS:.*?:.*?:.*', 'hppa1.1-stratus-vos' ], + [ '.*?:4.*?:R4.*?:m88k', '${MACHINE}-whatever-sysv4' ], + [ 'DYNIX\/ptx:4.*?:.*', '${MACHINE}-whatever-sysv4' ], + [ '.*?:4\.0:3\.0:3[34]..(,.*)?', 'i486-ncr-sysv4' ], + [ 'ULTRIX:.*', '${MACHINE}-unknown-ultrix' ], + [ 'POSIX-BC.*', 'BS2000-siemens-sysv4' ], + [ 'machten:.*', '${MACHINE}-tenon-${SYSTEM}' ], + [ 'library:.*', '${MACHINE}-ncr-sysv4' ], + [ 'ConvexOS:.*?:11\.0:.*', '${MACHINE}-v11-${SYSTEM}' ], + [ 'MINGW64.*?:.*?:.*?:x86_64', '${MACHINE}-whatever-mingw64' ], + [ 'MINGW.*', '${MACHINE}-whatever-mingw' ], + [ 'CYGWIN.*', '${MACHINE}-pc-cygwin' ], + [ 'vxworks.*', '${MACHINE}-whatever-vxworks' ], # Windows values found by looking at Perl 5's win32/win32.c - [ 'Windows NT:.*:amd64', 'VC-WIN64A' ], - [ 'Windows NT:.*:ia64', 'VC-WIN64I' ], - [ 'Windows NT:.*:x86', 'VC-WIN32' ], + [ 'Windows NT:.*:amd64', 'VC-WIN64A' ], + [ 'Windows NT:.*:ia64', 'VC-WIN64I' ], + [ 'Windows NT:.*:x86', 'VC-WIN32' ], # VMS values found by observation on existing machinery. Unfortunately, # the machine part is a bit... overdone. It seems, though, that 'Alpha' # exists in that part, making it distinguishable from Itanium. It will # be interesting to see what we'll get in the upcoming x86_64 port... - [ 'OpenVMS:.*:.*:.*:.*Alpha*', 'vms-alpha' ], - [ 'OpenVMS:', 'vms-ia64' ], + [ 'OpenVMS:.*?:.*?:.*?:.*Alpha.*', 'vms-alpha' ], + [ 'OpenVMS:.*', 'vms-ia64' ], + [ sub { -d '/usr/apollo' }, 'whatever-apollo-whatever' ], ]; -# More complex cases that require run-time code. -my $complex_sys_list = [ - [ 'HP-UX:', sub { - my $HPUXVER = $RELEASE; - $HPUXVER = s/[^.]*.[0B]*//; - # HPUX 10 and 11 targets are unified - return "${MACHINE}-hp-hpux1x" if $HPUXVER =~ m@1[0-9]@; - return "${MACHINE}-hp-hpux"; - } ], - - [ 'BSD/386:.*:.*:.*486.*|BSD/OS:.*:.*:.*:.*486', sub { - my $BSDVAR = `/sbin/sysctl -n hw.model`; - return "i586-whatever-bsdi" if $BSDVAR =~ m@Pentium@; - return "i386-whatever-bsdi"; - } ], - - [ 'FreeBSD:.*:.*:.*386', sub { - my $VERS = $RELEASE; - $VERS =~ s/[-(].*//; - my $MACH = `sysctl -n hw.model`; - $MACH = "i386" if $MACH =~ m@386@; - $MACH = "i486" if $MACH =~ m@486@; - $MACH = "i686" if $MACH =~ m@Pentium II@; - $MACH = "i586" if $MACH =~ m@Pentium@; - $MACH = "$MACHINE" if $MACH !~ /i.86/; - my $ARCH = 'whatever'; - $ARCH = "pc" if $MACH =~ m@i[0-9]86@; - return "${MACH}-${ARCH}-freebsd${VERS}"; - } ], - - [ 'NetBSD:.*:.*:.*386', sub { - my $hw = `/usr/sbin/sysctl -n hw.model || /sbin/sysctl -n hw.model`; - $hw =~ s@.*(.)86-class.*@i${1}86@; - return "${hw}-whatever-netbsd"; - } ], - - [ 'OSF1:.*:.*:.*alpha', sub { - my $OSFMAJOR = $RELEASE; - $OSFMAJOR =~ 's/^V([0-9]*)\..*$/\1/'; - return "${MACHINE}-dec-tru64" if $OSFMAJOR =~ m@[45]@; - return "${MACHINE}-dec-osf"; - } ], -]; - - # Run a command, return true if exit zero else false. # Multiple args are glued together into a pipeline. # Name comes from OpenSSL tests, often written as "ok(run(...." @@ -247,21 +253,13 @@ sub guess_system { # Now pattern-match # Simple cases - foreach my $tuple ( @$simple_guess_patterns ) { + foreach my $tuple ( @$guess_patterns ) { my $pat = @$tuple[0]; - # Trailing $ omitted on purpose. - next if $sys !~ /^$pat/; - my $result = @$tuple[1]; - return eval "\"$result\""; - } + my $check = ref $pat eq 'CODE' ? $pat->($sys) : $sys =~ /^(${pat})$/; + next unless $check; - # Complex cases. - foreach my $tuple ( @$complex_sys_list ) { - my $pat = @$tuple[0]; - # Trailing $ omitted on purpose. - next if $sys !~ /^$pat/; - my $ref = @$tuple[1]; - my $result = &$ref; + my $result = @$tuple[1]; + $result = $result->() if ref $result eq 'CODE'; return eval "\"$result\""; } |