summaryrefslogtreecommitdiff
path: root/util/perl
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2020-03-03 00:01:35 +0100
committerRichard Levitte <levitte@openssl.org>2020-06-28 18:34:35 +0200
commite39795af0a871a0bd560838ce54610a34c92fb49 (patch)
tree47b23986b305c2d61e040b75f84871fa385d2e8f /util/perl
parent081436bf732c0889b2649426df4e1c23c671d6d7 (diff)
downloadopenssl-new-e39795af0a871a0bd560838ce54610a34c92fb49.tar.gz
util/perl/OpenSSL/config.pm: refactor map_guess()
map_guess() is now table driven, just like get_system(). Additionally, it now takes a config hash table and returns one of its own. This way, 'Configure' can pass whatever it has already found to OpenSSL::config::get_platform(), and easily merge the returned hash table into its %config. This also gets rid of variables that we no longer need. That includes $PERL and all the $__CNF_ environment variables. Reviewed-by: Tim Hudson <tjh@openssl.org> (Merged from https://github.com/openssl/openssl/pull/11230)
Diffstat (limited to 'util/perl')
-rwxr-xr-xutil/perl/OpenSSL/config.pm782
1 files changed, 400 insertions, 382 deletions
diff --git a/util/perl/OpenSSL/config.pm b/util/perl/OpenSSL/config.pm
index 5e0372ac2e..53a77b3424 100755
--- a/util/perl/OpenSSL/config.pm
+++ b/util/perl/OpenSSL/config.pm
@@ -36,11 +36,9 @@ my $GCC_BITS;
my $GCC_ARCH;
# Some environment variables; they will affect Configure
-my $PERL = $ENV{PERL} // $^X // 'perl';
my $CONFIG_OPTIONS = $ENV{CONFIG_OPTIONS} // '';
-my $CC = $ENV{CC} // '';
-my $CROSS_COMPILE = $ENV{CROSS_COMPILE} // "";
-my $KERNEL_BITS = $ENV{KERNEL_BITS} // '';
+my $CC;
+my $CROSS_COMPILE;
# For determine_compiler_settings, the list of known compilers
my @c_compilers = qw(clang gcc cc);
@@ -67,15 +65,6 @@ my @cc_version =
# This is what we will set as the target for calling Configure.
my $options = '';
-# Environment that will be passed to Configure
-my $__CNF_CPPDEFINES = '';
-my $__CNF_CPPINCLUDES = '';
-my $__CNF_CPPFLAGS = '';
-my $__CNF_CFLAGS = '';
-my $__CNF_CXXFLAGS = '';
-my $__CNF_LDFLAGS = '';
-my $__CNF_LDLIBS = '';
-
# Pattern matches against "${SYSTEM}:${RELEASE}:${VERSION}:${MACHINE}"
my $simple_guess_patterns = [
[ 'A\/UX:', 'm68k-apple-aux3' ],
@@ -450,392 +439,451 @@ EOF
}
}
-# Map GUESSOS into OpenSSL terminology. Also sets some of variables
-# like $options, $__CNX_xxx. And uses some, like the KERNEL flags
-# and MACHINE.
-# It would be nice to fix this so that this weren't necessary. :( XXX
-sub map_guess {
- my $GUESSOS = shift;
- my $OUT;
- return 'uClinux-dist64' if $GUESSOS =~ 'uClinux.*64.*';
- return 'uClinux-dist' if $GUESSOS =~ 'uClinux.*';
- return "irix-mips3-$CC" if $GUESSOS =~ 'mips3-sgi-irix';
- if ( $GUESSOS =~ 'mips4-sgi-irix64' ) {
- print <<EOF;
+my $map_patterns =
+ [ [ 'uClinux.*64.*', { target => 'uClinux-dist64' } ],
+ [ 'uClinux.*', { target => 'uClinux-dist' } ],
+ [ 'mips3-sgi-irix', { target => 'irix-mips3' } ],
+ [ 'mips4-sgi-irix64',
+ sub {
+ print <<EOF;
WARNING! To build 64-bit package, do this:
$WHERE/Configure irix64-mips4-$CC
EOF
- maybe_abort();
- return "irix-mips3-$CC";
- }
- return "rhapsody-ppc-cc" if $GUESSOS =~ 'ppc-apple-rhapsody';
- if ( $GUESSOS =~ 'ppc-apple-darwin' ) {
- my $ISA64 = `sysctl -n hw.optional.64bitops 2>/dev/null`;
- if ( $ISA64 == 1 && $KERNEL_BITS eq '' ) {
- print <<EOF;
+ maybe_abort();
+ return { target => "irix-mips3" };
+ }
+ ],
+ [ 'ppc-apple-rhapsody', { target => "rhapsody-ppc" } ],
+ [ 'ppc-apple-darwin.*',
+ sub {
+ my $KERNEL_BITS = $ENV{KERNEL_BITS};
+ my $ISA64 = `sysctl -n hw.optional.64bitops 2>/dev/null`;
+ if ( $ISA64 == 1 && $KERNEL_BITS eq '' ) {
+ print <<EOF;
WARNING! To build 64-bit package, do this:
$WHERE/Configure darwin64-ppc-cc
EOF
- maybe_abort();
+ maybe_abort();
+ }
+ return { target => "darwin64-ppc" }
+ if $ISA64 == 1 && $KERNEL_BITS eq '64';
+ return { target => "darwin-ppc" };
}
- return "darwin64-ppc-cc" if $ISA64 == 1 && $KERNEL_BITS eq '64';
- return "darwin-ppc-cc";
- }
- if ( $GUESSOS =~ 'i.86-apple-darwin' ) {
- my $ISA64 = `sysctl -n hw.optional.x86_64 2>/dev/null`;
- if ( $ISA64 == 1 && $KERNEL_BITS eq '' ) {
- print <<EOF;
+ ],
+ [ 'i.86-apple-darwin.*',
+ sub {
+ my $KERNEL_BITS = $ENV{KERNEL_BITS};
+ my $ISA64 = `sysctl -n hw.optional.x86_64 2>/dev/null`;
+ if ( $ISA64 == 1 && $KERNEL_BITS eq '' ) {
+ print <<EOF;
WARNING! To build 64-bit package, do this:
- KERNEL_BITS=64 $WHERE/config $options
+ KERNEL_BITS=64 $WHERE/Configure \[\[ options \]\]
EOF
- maybe_abort();
+ maybe_abort();
+ }
+ return { target => "darwin64-x86_64" }
+ if $ISA64 == 1 && $KERNEL_BITS eq '64';
+ return { target => "darwin-i386" };
}
- return "darwin64-x86_64-cc" if $ISA64 == 1 && $KERNEL_BITS eq '64';
- return "darwin-i386-cc";
- }
- if ( $GUESSOS =~ 'x86_64-apple-darwin' ) {
- return "darwin-i386-cc" if $KERNEL_BITS eq '32';
+ ],
+ [ 'x86_64-apple-darwin.*',
+ sub {
+ my $KERNEL_BITS = $ENV{KERNEL_BITS};
+ return { target => "darwin-i386" } if $KERNEL_BITS eq '32';
- print <<EOF;
+ print <<EOF;
WARNING! To build 32-bit package, do this:
- KERNEL_BITS=32 $WHERE/config $options
+ KERNEL_BITS=32 $WHERE/Configure \[\[ options \]\]
EOF
- maybe_abort();
- return "darwin64-x86_64-cc"
- }
- if ( $GUESSOS =~ 'armv6+7-.*-iphoneos' ) {
- $__CNF_CFLAGS .= " -arch armv6 -arch armv7";
- $__CNF_CXXFLAGS .= " -arch armv6 -arch armv7";
- return "iphoneos-cross";
- }
- if ( $GUESSOS =~ '.*-.*-iphoneos' ) {
- $__CNF_CFLAGS .= " -arch ${MACHINE}";
- $__CNF_CXXFLAGS .= " -arch ${MACHINE}";
- return "iphoneos-cross";
- }
- return "ios64-cross" if $GUESSOS =~ 'arm64-.*-iphoneos|.*-.*-ios64';
- if ( $GUESSOS =~ 'alpha-.*-linux2' ) {
- my $ISA = `awk '/cpu model/{print \$4;exit(0);}' /proc/cpuinfo`;
- $ISA //= 'generic';
- if ( $CCVENDOR eq "gnu" ) {
- if ( $ISA =~ 'EV5|EV45' ) {
- $__CNF_CFLAGS .= " -mcpu=ev5";
- $__CNF_CFLAGS .= " -mcpu=ev5";
- } elsif ( $ISA =~ 'EV56|PCA56' ) {
- $__CNF_CFLAGS .= " -mcpu=ev56";
- $__CNF_CXXFLAGS .= " -mcpu=ev56";
- } else {
- $__CNF_CFLAGS .= "-mcpu=ev6";
- $__CNF_CXXFLAGS .= "-mcpu=ev6";
+ maybe_abort();
+ return { target => "darwin64-x86_64" };
+ }
+ ],
+ [ 'armv6\+7-.*-iphoneos',
+ { target => "iphoneos-cross",
+ cflags => [ qw(-arch armv6 -arch armv7) ],
+ cxxflags => [ qw(-arch armv6 -arch armv7) ] }
+ ],
+ [ 'arm64-.*-iphoneos|.*-.*-ios64',
+ { target => "ios64-cross" }
+ ],
+ [ '.*-.*-iphoneos',
+ sub { return { target => "iphoneos-cross",
+ cflags => [ "-arch ${MACHINE}" ],
+ cxxflags => [ "-arch ${MACHINE}" ] }; }
+ ],
+ [ 'alpha-.*-linux2.*',
+ sub {
+ my $ISA = `awk '/cpu model/{print \$4;exit(0);}' /proc/cpuinfo`;
+ $ISA //= 'generic';
+ my %config = ();
+ if ( $CCVENDOR eq "gnu" ) {
+ if ( $ISA =~ 'EV5|EV45' ) {
+ %config = ( cflags => [ '-mcpu=ev5' ],
+ cxxflags => [ '-mcpu=ev5' ] );
+ } elsif ( $ISA =~ 'EV56|PCA56' ) {
+ %config = ( cflags => [ '-mcpu=ev56' ],
+ cxxflags => [ '-mcpu=ev56' ] );
+ } else {
+ %config = ( cflags => [ '-mcpu=ev6' ],
+ cxxflags => [ '-mcpu=ev6' ] );
+ }
}
+ return { target => "linux-alpha",
+ %config };
}
- return "linux-alpha-$CC";
- }
- if ( $GUESSOS =~ 'ppc64-.*-linux2' ) {
- if ( $KERNEL_BITS eq '' ) {
- print <<EOF;
+ ],
+ [ 'ppc64-.*-linux2',
+ sub {
+ my $KERNEL_BITS = $ENV{KERNEL_BITS};
+ if ( $KERNEL_BITS eq '' ) {
+ print <<EOF;
WARNING! To build 64-bit package, do this:
$WHERE/Configure linux-ppc64
EOF
- maybe_abort();
- }
- return "linux-ppc64" if $KERNEL_BITS eq '64';
- if (!okrun('echo __LP64__',
- 'gcc -E -x c - 2>/dev/null',
- 'grep "^__LP64__" 2>&1 >/dev/null') ) {
- $__CNF_CFLAGS .= " -m32";
- $__CNF_CXXFLAGS .= " -m32";
+ maybe_abort();
+ }
+ return { target => "linux-ppc64" } if $KERNEL_BITS eq '64';
+
+ my %config = ();
+ if (!okrun('echo __LP64__',
+ 'gcc -E -x c - 2>/dev/null',
+ 'grep "^__LP64__" 2>&1 >/dev/null') ) {
+ %config = ( cflags => [ '-m32' ],
+ cxxflags => [ '-m32' ] );
+ }
+ return { target => "linux-ppc",
+ %config };
}
- return "linux-ppc";
- }
- return "linux-ppc64le" if $GUESSOS =~ 'ppc64le-.*-linux2';
- return "linux-ppc" if $GUESSOS =~ 'ppc-.*-linux2';
- if ( $GUESSOS =~ 'mips64.*-*-linux2' ) {
- print <<EOF;
+ ],
+ [ 'ppc64le-.*-linux2', { target => "linux-ppc64le" } ],
+ [ 'ppc-.*-linux2', { target => "linux-ppc" } ],
+ [ 'mips64.*-*-linux2',
+ sub {
+ print <<EOF;
WARNING! To build 64-bit package, do this:
$WHERE/Configure linux64-mips64
EOF
- maybe_abort();
- return "linux-mips64";
- }
- return "linux-mips32" if $GUESSOS =~ 'mips.*-.*-linux2';
- return "vxworks-ppc60x" if $GUESSOS =~ 'ppc60x-.*-vxworks*';
- return "vxworks-ppcgen" if $GUESSOS =~ 'ppcgen-.*-vxworks*';
- return "vxworks-pentium" if $GUESSOS =~ 'pentium-.*-vxworks*';
- return "vxworks-simlinux" if $GUESSOS =~ 'simlinux-.*-vxworks*';
- return "vxworks-mips" if $GUESSOS =~ 'mips-.*-vxworks*';
- return "linux-generic64 -DL_ENDIAN" if $GUESSOS =~ 'e2k-.*-linux*';
- return "linux-ia64" if $GUESSOS =~ 'ia64-.*-linux.';
- if ( $GUESSOS =~ 'sparc64-.*-linux2' ) {
- print <<EOF;
+ maybe_abort();
+ return { target => "linux-mips64" };
+ }
+ ],
+ [ 'mips.*-.*-linux2', { target => "linux-mips32" } ],
+ [ 'ppc60x-.*-vxworks.*', { target => "vxworks-ppc60x" } ],
+ [ 'ppcgen-.*-vxworks.*', { target => "vxworks-ppcgen" } ],
+ [ 'pentium-.*-vxworks.*', { target => "vxworks-pentium" } ],
+ [ 'simlinux-.*-vxworks.*', { target => "vxworks-simlinux" } ],
+ [ 'mips-.*-vxworks.*', { target => "vxworks-mips" } ],
+ [ 'e2k-.*-linux.*', { target => "linux-generic64",
+ defines => [ 'L_ENDIAN' ] } ],
+ [ 'ia64-.*-linux.', { target => "linux-ia64" } ],
+ [ 'sparc64-.*-linux2',
+ sub {
+ print <<EOF;
WARNING! If you *know* that your GNU C supports 64-bit/V9 ABI and you
want to build 64-bit library, do this:
$WHERE/Configure linux64-sparcv9
EOF
- maybe_abort();
- return "linux-sparcv9";
- }
- if ( $GUESSOS =~ 'sparc-.*-linux2' ) {
- my $KARCH = `awk '/^type/{print \$3;exit(0);}' /proc/cpuinfo`;
- $KARCH //= "sun4";
- return "linux-sparcv9" if $KARCH =~ 'sun4u*';
- return "linux-sparcv8" if $KARCH =~ 'sun4[md]';
- $__CNF_CPPFLAGS .= " -DB_ENDIAN";
- return "linux-generic32";
- }
- if ( $GUESSOS =~ 'parisc.*-.*-linux2' ) {
- # 64-bit builds under parisc64 linux are not supported and
- # compiler is expected to generate 32-bit objects...
- my $CPUARCH =
- `awk '/cpu family/{print substr(\$5,1,3); exit(0);}' /proc/cpuinfo`;
- my $CPUSCHEDULE =
- `awk '/^cpu.[ ]*: PA/{print substr(\$3,3); exit(0);}' /proc/cpuinfo`;
- # TODO XXX Model transformations
- # 0. CPU Architecture for the 1.1 processor has letter suffixes. We
- # strip that off assuming no further arch. identification will ever
- # be used by GCC.
- # 1. I'm most concerned about whether is a 7300LC is closer to a 7100
- # versus a 7100LC.
- # 2. The variant 64-bit processors cause concern should GCC support
- # explicit schedulers for these chips in the future.
- # PA7300LC -> 7100LC (1.1)
- # PA8200 -> 8000 (2.0)
- # PA8500 -> 8000 (2.0)
- # PA8600 -> 8000 (2.0)
- $CPUSCHEDULE =~ s/7300LC/7100LC/;
- $CPUSCHEDULE =~ s/8.00/8000/;
- # Finish Model transformations
- $__CNF_CPPFLAGS .= " -DB_ENDIAN";
- $__CNF_CFLAGS .= " -mschedule=$CPUSCHEDULE -march=$CPUARCH";
- $__CNF_CXXFLAGS .= " -mschedule=$CPUSCHEDULE -march=$CPUARCH";
- return "linux-generic32";
- }
- return "linux-generic32" if $GUESSOS =~ 'armv[1-3].*-.*-linux2';
- if ( $GUESSOS =~ 'armv[7-9].*-.*-linux2' ) {
- $__CNF_CFLAGS .= " -march=armv7-a";
- $__CNF_CXXFLAGS .= " -march=armv7-a";
- return "linux-armv4";
- }
- return "linux-armv4" if $GUESSOS =~ 'arm.*-.*-linux2';
- return "linux-aarch64" if $GUESSOS =~ 'aarch64-.*-linux2';
- if ( $GUESSOS =~ 'sh.*b-.*-linux2' ) {
- $__CNF_CPPFLAGS .= " -DB_ENDIAN";
- return "linux-generic32";
- }
- if ( $GUESSOS =~ 'sh.*-.*-linux2' ) {
- $__CNF_CPPFLAGS .= " -DL_ENDIAN";
- return "linux-generic32";
- }
- if ( $GUESSOS =~ 'm68k.*-.*-linux2' || $GUESSOS =~ 's390-.*-linux2' ) {
- $__CNF_CPPFLAGS .= " -DB_ENDIAN";
- return "linux-generic32";
- }
- if ( $GUESSOS =~ 's390x-.*-linux2' ) {
- # Disabled until a glibc bug is fixed; see Configure.
- if (0 || okrun(
- 'egrep -e \'^features.* highgprs\' /proc/cpuinfo >/dev/null') )
- {
- print <<EOF;
+ maybe_abort();
+ return { target => "linux-sparcv9" };
+ }
+ ],
+ [ 'sparc-.*-linux2',
+ sub {
+ my $KARCH = `awk '/^type/{print \$3;exit(0);}' /proc/cpuinfo`;
+ $KARCH //= "sun4";
+ return { target => "linux-sparcv9" } if $KARCH =~ 'sun4u.*';
+ return { target => "linux-sparcv8" } if $KARCH =~ 'sun4[md]';
+ return { target => "linux-generic32",
+ defines => [ 'L_ENDIAN' ] };
+ }
+ ],
+ [ 'parisc.*-.*-linux2',
+ sub {
+ # 64-bit builds under parisc64 linux are not supported and
+ # compiler is expected to generate 32-bit objects...
+ my $CPUARCH =
+ `awk '/cpu family/{print substr(\$5,1,3); exit(0);}' /proc/cpuinfo`;
+ my $CPUSCHEDULE =
+ `awk '/^cpu.[ ]*: PA/{print substr(\$3,3); exit(0);}' /proc/cpuinfo`;
+ # TODO XXX Model transformations
+ # 0. CPU Architecture for the 1.1 processor has letter suffixes.
+ # We strip that off assuming no further arch. identification
+ # will ever be used by GCC.
+ # 1. I'm most concerned about whether is a 7300LC is closer to a
+ # 7100 versus a 7100LC.
+ # 2. The variant 64-bit processors cause concern should GCC support
+ # explicit schedulers for these chips in the future.
+ # PA7300LC -> 7100LC (1.1)
+ # PA8200 -> 8000 (2.0)
+ # PA8500 -> 8000 (2.0)
+ # PA8600 -> 8000 (2.0)
+ $CPUSCHEDULE =~ s/7300LC/7100LC/;
+ $CPUSCHEDULE =~ s/8.00/8000/;
+ return
+ { target => "linux-generic32",
+ defines => [ 'B_ENDIAN' ],
+ cflags => [ "-mschedule=$CPUSCHEDULE", "-march=$CPUARCH" ],
+ cxxflags => [ "-mschedule=$CPUSCHEDULE", "-march=$CPUARCH" ]
+ };
+ }
+ ],
+ [ 'armv[1-3].*-.*-linux2', { target => "linux-generic32" } ],
+ [ 'armv[7-9].*-.*-linux2', { target => "linux-armv4",
+ defines => [ 'B_ENDIAN' ],
+ cflags => [ '-march=armv7-a' ],
+ cxxflags => [ '-march=armv7-a' ] } ],
+ [ 'arm.*-.*-linux2', { target => "linux-armv4" } ],
+ [ 'aarch64-.*-linux2', { target => "linux-aarch64" } ],
+ [ 'sh.*b-.*-linux2', { target => "linux-generic32",
+ defines => [ 'B_ENDIAN' ] } ],
+ [ 'sh.*-.*-linux2', { target => "linux-generic32",
+ defines => [ 'L_ENDIAN' ] } ],
+ [ 'm68k.*-.*-linux2', { target => "linux-generic32",
+ defines => [ 'B_ENDIAN' ] } ],
+ [ 's390-.*-linux2', { target => "linux-generic32",
+ defines => [ 'B_ENDIAN' ] } ],
+ [ 's390x-.*-linux2',
+ sub {
+ # Disabled until a glibc bug is fixed; see Configure.
+ if (0
+ || okrun('egrep -e \'^features.* highgprs\' /proc/cpuinfo >/dev/null') )
+ {
+ print <<EOF;
WARNING! To build "highgprs" 32-bit package, do this:
$WHERE/Configure linux32-s390x
EOF
- maybe_abort();
+ maybe_abort();
+ }
+ return { target => "linux64-s390x" };
}
- return "linux64-s390x";
- }
- if ( $GUESSOS =~ 'x86_64-.*-linux.' ) {
- return "linux-x32"
- if okrun("$CC -dM -E -x c /dev/null 2>&1",
- 'grep -q ILP32 >/dev/null');
- return "linux-x86_64";
- }
- if ( $GUESSOS =~ '.*86-.*-linux2' ) {
- # On machines where the compiler understands -m32, prefer a
- # config target that uses it
- return "linux-x86"
- if okrun("$CC -m32 -E -x c /dev/null >/dev/null 2>&1");
- return "linux-elf"
- }
- return "linux-aout" if $GUESSOS =~ '.*86-.*-linux1';
- return "linux-generic32" if $GUESSOS =~ '.*-.*-linux.';
- if ( $GUESSOS =~ 'sun4[uv].*-.*-solaris2' ) {
- my $ISA64 = `isainfo 2>/dev/null | grep sparcv9`;
- if ( $ISA64 ne "" && $KERNEL_BITS eq '' ) {
- if ( $CCVENDOR eq "sun" && $CCVER >= 500 ) {
- print <<EOF;
+ ],
+ [ 'x86_64-.*-linux.',
+ sub {
+ return { target => "linux-x32" }
+ if okrun("$CC -dM -E -x c /dev/null 2>&1",
+ 'grep -q ILP32 >/dev/null');
+ return { target => "linux-x86_64" };
+ }
+ ],
+ [ '.*86-.*-linux2',
+ sub {
+ # On machines where the compiler understands -m32, prefer a
+ # config target that uses it
+ return { target => "linux-x86" }
+ if okrun("$CC -m32 -E -x c /dev/null >/dev/null 2>&1");
+ return { target => "linux-elf" };
+ }
+ ],
+ [ '.*86-.*-linux1', { target => "linux-aout" } ],
+ [ '.*-.*-linux.', { target => "linux-generic32" } ],
+ [ 'sun4[uv].*-.*-solaris2',
+ sub {
+ my $KERNEL_BITS = $ENV{KERNEL_BITS};
+ my $ISA64 = `isainfo 2>/dev/null | grep sparcv9`;
+ if ( $ISA64 ne "" && $KERNEL_BITS eq '' ) {
+ if ( $CCVENDOR eq "sun" && $CCVER >= 500 ) {
+ print <<EOF;
WARNING! To build 64-bit package, do this:
$WHERE/Configure solaris64-sparcv9-cc
EOF
- maybe_abort();
- } elsif ( $CCVENDOR eq "gnu" && $GCC_ARCH eq "-m64" ) {
- # $GCC_ARCH denotes default ABI chosen by compiler driver
- # (first one found on the $PATH). I assume that user
- # expects certain consistency with the rest of his builds
- # and therefore switch over to 64-bit. <appro>
- print <<EOF;
+ maybe_abort();
+ } elsif ( $CCVENDOR eq "gnu" && $GCC_ARCH eq "-m64" ) {
+ # $GCC_ARCH denotes default ABI chosen by compiler driver
+ # (first one found on the $PATH). I assume that user
+ # expects certain consistency with the rest of his builds
+ # and therefore switch over to 64-bit. <appro>
+ print <<EOF;
WARNING! To build 32-bit package, do this:
$WHERE/Configure solaris-sparcv9-gcc
EOF
- maybe_abort();
- return "solaris64-sparcv9-gcc";
- } elsif ( $GCC_ARCH eq "-m32" ) {
- print <<EOF;
+ maybe_abort();
+ return { target => "solaris64-sparcv9" };
+ } elsif ( $GCC_ARCH eq "-m32" ) {
+ print <<EOF;
NOTICE! If you *know* that your GNU C supports 64-bit/V9 ABI and you wish
to build 64-bit library, do this:
$WHERE/Configure solaris64-sparcv9-gcc
EOF
- maybe_abort();
+ maybe_abort();
+ }
}
+ return { target => "solaris64-sparcv9" }
+ if $ISA64 ne "" && $KERNEL_BITS eq '64';
+ return { target => "solaris-sparcv9" };
}
- return "solaris64-sparcv9-$CC" if $ISA64 ne "" && $KERNEL_BITS eq '64';
- return "solaris-sparcv9-$CC";
- }
- return "solaris-sparcv8-$CC" if $GUESSOS =~ 'sun4m-.*-solaris2';
- return "solaris-sparcv8-$CC" if $GUESSOS =~ 'sun4d-.*-solaris2';
- return "solaris-sparcv7-$CC" if $GUESSOS =~ 'sun4.*-.*-solaris2';
- if ( $GUESSOS =~ '.*86.*-.*-solaris2' ) {
- my $ISA64 = `isainfo 2>/dev/null | grep amd64`;
- my $KB = $KERNEL_BITS // '64';
- return "solaris64-x86_64-$CC" if $ISA64 ne "" && $KB eq '64';
- my $REL = uname('-r');
- $REL =~ s/5\.//;
- $options .= " no-sse2" if int($REL) < 10;
- return "solaris-x86-$CC";
- }
- return "sunos-$CC" if $GUESSOS =~ '.*-.*-sunos4';
- if ( $GUESSOS =~ '.*86.*-.*-bsdi4' ) {
- $options .= " no-sse2";
- $__CNF_LDFLAGS .= " -ldl";
- return "BSD-x86-elf";
- }
- if ( $GUESSOS =~ 'alpha.*-.*-.*bsd.*' ) {
- $__CNF_CPPFLAGS .= " -DL_ENDIAN";
- return "BSD-generic64";
- }
- if ( $GUESSOS =~ 'powerpc64-.*-.*bsd.*' ) {
- $__CNF_CPPFLAGS .= " -DB_ENDIAN";
- return "BSD-generic64";
- }
- return "BSD-sparc64" if $GUESSOS =~ 'sparc64-.*-.*bsd.*';
- return "BSD-ia64" if $GUESSOS =~ 'ia64-.*-.*bsd.*';
- return "BSD-x86_64" if $GUESSOS =~ 'x86_64-.*-dragonfly.*';
- return "BSD-x86_64" if $GUESSOS =~ 'amd64-.*-.*bsd.*';
- if ( $GUESSOS =~ '.*86.*-.*-.*bsd.*' ) {
- # mimic ld behaviour when it's looking for libc...
- my $libc;
- if ( -l "/usr/lib/libc.so" ) {
- $libc = "/usr/lib/libc.so";
- } else {
- # ld searches for highest libc.so.* and so do we
- $libc =
- `(ls /usr/lib/libc.so.* /lib/libc.so.* | tail -1) 2>/dev/null`;
+ ],
+ [ 'sun4m-.*-solaris2', { target => "solaris-sparcv8" } ],
+ [ 'sun4d-.*-solaris2', { target => "solaris-sparcv8" } ],
+ [ 'sun4.*-.*-solaris2', { target => "solaris-sparcv7" } ],
+ [ '.*86.*-.*-solaris2',
+ sub {
+ my $KERNEL_BITS = $ENV{KERNEL_BITS};
+ my $ISA64 = `isainfo 2>/dev/null | grep amd64`;
+ my $KB = $KERNEL_BITS // '64';
+ return { target => "solaris64-x86_64" }
+ if $ISA64 ne "" && $KB eq '64';
+ my $REL = uname('-r');
+ $REL =~ s/5\.//;
+ my @tmp_disable = ();
+ push @tmp_disable, 'sse2' if int($REL) < 10;
+ return { target => "solaris-x86",
+ disable => [ @tmp_disable ] };
}
- my $what = `file -L $libc 2>/dev/null`;
- return "BSD-x86-elf" if $what =~ /ELF/;
- $options .= " no-sse2";
- return "BSD-x86";
- }
- return "BSD-generic32" if $GUESSOS =~ '.*-.*-.*bsd.*';
- return "haiku-x86_64" if $GUESSOS =~ 'x86_64-.*-haiku';
- return "haiku-x86" if $GUESSOS =~ '.*-.*-haiku';
- return "osf1-alpha-cc" if $GUESSOS =~ '.*-.*-osf';
- return "tru64-alpha-cc" if $GUESSOS =~ '.*-.*-tru64';
- if ( $GUESSOS =~ '.*-.*-[Uu]nix[Ww]are7' ) {
- $options .= "no-sse2";
- return "unixware-7-gcc" if $CCVENDOR eq "gnu";
- $__CNF_CPPFLAGS .= " -D__i386__";
- return "unixware-7";
- }
- if ( $GUESSOS =~ '.*-.*-[Uu]nix[Ww]are20*' ) {
- $options .= " no-sse2 no-sha512";
- return "unixware-2.0";
- }
- if ( $GUESSOS =~ '.*-.*-[Uu]nix[Ww]are21*' ) {
- $options .= " no-sse2 no-sha512";
- return "unixware-2.1";
- }
- if ( $GUESSOS =~ '.*-.*-vos' ) {
- $options .= " no-threads no-shared no-asm no-dso";
- return "vos-$CC";
- }
- return "BS2000-OSD" if $GUESSOS =~ 'BS2000-siemens-sysv4';
- return "Cygwin-x86" if $GUESSOS =~ 'i[3456]86-.*-cygwin';
- return "Cygwin-${MACHINE}" if $GUESSOS =~ '.*-.*-cygwin';
- return "android-x86" if $GUESSOS =~ 'x86-.*-android|i.86-.*-android';
- if ( $GUESSOS =~ 'armv[7-9].*-.*-android' ) {
- $__CNF_CFLAGS .= " -march=armv7-a";
- $__CNF_CXXFLAGS .= " -march=armv7-a";
- return "android-armeabi";
- }
- return "android-armeabi" if $GUESSOS =~ 'arm.*-.*-android';
- if ( $GUESSOS =~ '.*-hpux1.*' ) {
- $OUT = "hpux64-parisc2-gcc" if $CCVENDOR eq "gnu" && $GCC_BITS eq '64';
- $KERNEL_BITS //= `getconf KERNEL_BITS 2>/dev/null` // '32';
- # See <sys/unistd.h> for further info on CPU_VERSION.
- my $CPU_VERSION = `getconf CPU_VERSION 2>/dev/null` // 0;
- $__CNF_CPPFLAGS .= " -D_REENTRANT";
- if ( $CPU_VERSION >= 768 ) {
- # IA-64 CPU
- return "hpux64-ia64-cc" if $KERNEL_BITS eq '64' && ! $CCVENDOR;
- return "hpux-ia64-cc"
+ ],
+ # We don't have any sunos target in Configurations/*.conf, so why here?
+ [ '.*-.*-sunos4', { target => "sunos" } ],
+ [ '.*86.*-.*-bsdi4', { target => "BSD-x86-elf",
+ lflags => [ '-ldl' ],
+ disable => [ 'sse2' ] } ],
+ [ 'alpha.*-.*-.*bsd.*', { target => "BSD-generic64",
+ defines => [ 'L_ENDIAN' ] } ],
+ [ 'powerpc64-.*-.*bsd.*', { target => "BSD-generic64",
+ defines => [ 'B_ENDIAN' ] } ],
+ [ 'sparc64-.*-.*bsd.*', { target => "BSD-sparc64" } ],
+ [ 'ia64-.*-.*bsd.*', { target => "BSD-ia64" } ],
+ [ 'x86_64-.*-dragonfly.*', { target => "BSD-x86_64" } ],
+ [ 'amd64-.*-.*bsd.*', { target => "BSD-x86_64" } ],
+ [ '.*86.*-.*-.*bsd.*',
+ sub {
+ # mimic ld behaviour when it's looking for libc...
+ my $libc;
+ if ( -l "/usr/lib/libc.so" ) {
+ $libc = "/usr/lib/libc.so";
+ } else {
+ # ld searches for highest libc.so.* and so do we
+ $libc =
+ `(ls /usr/lib/libc.so.* /lib/libc.so.* | tail -1) 2>/dev/null`;
+ }
+ my $what = `file -L $libc 2>/dev/null`;
+ return { target => "BSD-x86-elf" } if $what =~ /ELF/;
+ return { target => "BSD-x86",
+ disable => [ 'sse2' ] };
}
- if ( $CPU_VERSION >= 532 ) {
- # PA-RISC 2.x CPU
- # PA-RISC 2.0 is no longer supported as separate 32-bit
- # target. This is compensated for by run-time detection
- # in most critical assembly modules and taking advantage
- # of 2.0 architecture in PA-RISC 1.1 build.
- $OUT //= "hpux-parisc1_1-${CC}";
- if ( $KERNEL_BITS eq '64' && ! $CCVENDOR ) {
- print <<EOF;
+ ],
+ [ '.*-.*-.*bsd.*', { target => "BSD-generic32" } ],
+ [ 'x86_64-.*-haiku', { target => "haiku-x86_64" } ],
+ [ '.*-.*-haiku', { target => "haiku-x86" } ],
+ [ '.*-.*-osf', { target => "osf1-alpha" } ],
+ [ '.*-.*-tru64', { target => "tru64-alpha" } ],
+ [ '.*-.*-[Uu]nix[Ww]are7',
+ sub {
+ return { target => "unixware-7",
+ disable => [ 'sse2' ] } if $CCVENDOR eq "gnu";
+ return { target => "unixware-7",
+ defines => [ '__i386__' ] };
+ }
+ ],
+ [ '.*-.*-[Uu]nix[Ww]are20.*', { target => "unixware-2.0",
+ disable => [ 'sse2', 'sha512' ] } ],
+ [ '.*-.*-[Uu]nix[Ww]are21.*', { target => "unixware-2.1",
+ disable => [ 'sse2', 'sha512' ] } ],
+ [ '.*-.*-vos', { target => "vos",
+ disable => [ 'threads', 'shared', 'asm',
+ 'dso' ] } ],
+ [ 'BS2000-siemens-sysv4', { target => "BS2000-OSD" } ],
+ [ 'i[3456]86-.*-cygwin', { target => "Cygwin-x86" } ],
+ [ '.*-.*-cygwin',
+ sub { return { target => "Cygwin-${MACHINE}" } } ],
+ [ 'x86-.*-android|i.86-.*-android', { target => "android-x86" } ],
+ [ 'armv[7-9].*-.*-android', { target => "android-armeabi",
+ cflags => [ '-march=armv7-a' ],
+ cxxflags => [ '-march=armv7-a' ] } ],
+ [ 'arm.*-.*-android', { target => "android-armeabi" } ],
+ [ '.*-hpux1.*',
+ sub {
+ my $KERNEL_BITS = $ENV{KERNEL_BITS};
+ my %common_return = ( defines => [ '_REENTRANT' ] );
+ $KERNEL_BITS ||= `getconf KERNEL_BITS 2>/dev/null` // '32';
+ # See <sys/unistd.h> for further info on CPU_VERSION.
+ my $CPU_VERSION = `getconf CPU_VERSION 2>/dev/null` // 0;
+ if ( $CPU_VERSION >= 768 ) {
+ # IA-64 CPU
+ return { target => "hpux64-ia64",
+ %common_return }
+ if $KERNEL_BITS eq '64' && ! $CCVENDOR;
+ return { target => "hpux-ia64",
+ %common_return };
+ }
+ if ( $CPU_VERSION >= 532 ) {
+ # PA-RISC 2.x CPU
+ # PA-RISC 2.0 is no longer supported as separate 32-bit
+ # target. This is compensated for by run-time detection
+ # in most critical assembly modules and taking advantage
+ # of 2.0 architecture in PA-RISC 1.1 build.
+ my $target = ($CCVENDOR eq "gnu" && $GCC_BITS eq '64')
+ ? "hpux64-parisc2"
+ : "hpux-parisc1_1";
+ if ( $KERNEL_BITS eq '64' && ! $CCVENDOR ) {
+ print <<EOF;
WARNING! To build 64-bit package, do this:
$WHERE/Configure hpux64-parisc2-cc
EOF
- maybe_abort();
+ maybe_abort();
+ }
+ return { target => $target,
+ %common_return };
}
- return $OUT;
+ # PA-RISC 1.1+ CPU?
+ return { target => "hpux-parisc1_1",
+ %common_return } if $CPU_VERSION >= 528;
+ # PA-RISC 1.0 CPU
+ return { target => "hpux-parisc",
+ %common_return } if $CPU_VERSION >= 523;
+ # Motorola(?) CPU
+ return { target => "hpux",
+ %common_return };
}
- # PA-RISC 1.1+ CPU?
- return "hpux-parisc1_1-${CC}" if $CPU_VERSION >= 528;
- # PA-RISC 1.0 CPU
- return "hpux-parisc-${CC}" if $CPU_VERSION >= 523;
- # Motorola(?) CPU
- return "hpux-$CC";
- return $OUT;
- }
- return "hpux-parisc-$CC" if $GUESSOS =~ '.*-hpux';
- if ( $GUESSOS =~ '.*-aix' ) {
- $KERNEL_BITS //= `getconf KERNEL_BITMODE 2>/dev/null`;
- $KERNEL_BITS //= '32';
- my $OBJECT_MODE //= 32;
- if ( $CCVENDOR eq "gcc" ) {
- $OUT = "aix-gcc";
+ ],
+ [ '.*-hpux', { target => "hpux-parisc" } ],
+ [ '.*-aix',
+ sub {
+ my %config = ();
+ my $KERNEL_BITS = $ENV{KERNEL_BITS};
+ $KERNEL_BITS ||= `getconf KERNEL_BITMODE 2>/dev/null`;
+ $KERNEL_BITS ||= '32';
+ my $OBJECT_MODE = $ENV{OBJECT_MODE};
+ $OBJECT_MODE ||= 32;
+ $config{target} = "aix";
if ( $OBJECT_MODE == 64 ) {
print 'Your $OBJECT_MODE was found to be set to 64';
- $OUT = "aix64-gcc"
- }
- } elsif ( $OBJECT_MODE == 64 ) {
- print 'Your $OBJECT_MODE was found to be set to 64';
- $OUT = "aix64-cc";
- } else {
- $OUT = "aix-cc";
- if ( $KERNEL_BITS eq '64' ) {
- print <<EOF;
+ $config{target} = "aix64";
+ } else {
+ if ( $CCVENDOR ne 'gnu' && $KERNEL_BITS eq '64' ) {
+ print <<EOF;
WARNING! To build 64-bit package, do this:
$WHERE/Configure aix64-cc
EOF
- maybe_abort();
+ maybe_abort();
+ }
}
+ if ( okrun(
+ "lsattr -E -O -l `lsdev -c processor|awk '{print \$1;exit}'`",
+ 'grep -i powerpc) >/dev/null 2>&1') ) {
+ # this applies even to Power3 and later, as they return
+ # PowerPC_POWER[345]
+ } else {
+ $config{disable} = [ 'asm' ];
+ }
+ return %config;
}
- if ( okrun(
- "lsattr -E -O -l `lsdev -c processor|awk '{print \$1;exit}'`",
- 'grep -i powerpc) >/dev/null 2>&1') ) {
- # this applies even to Power3 and later, as they return
- # PowerPC_POWER[345]
- } else {
- $config{disable} = [ 'asm' ];
- }
- return %config;
+ ],
+ ];
+
+# Map GUESSOS into OpenSSL terminology.
+# Returns a hash table with diverse entries, most importantly 'target',
+# but also other entries that are fitting for Configure's %config
+# and MACHINE.
+# It would be nice to fix this so that this weren't necessary. :( XXX
+sub map_guess {
+ my $GUESSOS = shift;
+
+ foreach my $tuple ( @$map_patterns ) {
+ my $pat = @$tuple[0];
+ next if $GUESSOS !~ /^${pat}$/;
+ my $result = @$tuple[1];
+ $result = $result->() if ref $result eq 'CODE';
+ return %$result;
}
# Last case, return "z" from x-y-z
@@ -871,50 +919,20 @@ EOF
### MAIN PROCESSING
###
-# Common part, does all the real work.
-sub common {
- my $showguess = shift;
-
- get_machine_etc();
- my $GUESSOS = guess_system();
- print "Operating system: $GUESSOS\n" if $VERBOSE || $showguess;
- $options .= " 386" if $GUESSOS =~ /i386-/;
- remove_removed_crypto_directories();
- determine_compiler_settings();
- my $TARGET = map_guess($GUESSOS) // $CC;
- $TARGET = check_solaris_sparc8($TARGET);
- $TARGET = check_target_exists($TARGET);
- $options .= " $CONFIG_OPTIONS" if $CONFIG_OPTIONS ne '';
- return $TARGET;
-}
-
-## If called from Configure
sub get_platform {
- my $ref = shift;
- my %options = %{$ref};
+ my %options = @_;
+
$VERBOSE = 1 if defined $options{verbose};
- $options .= " --debug" if defined $options{debug};
$WAIT = 0 if defined $options{nowait};
+ $CC = $options{CC};
+ $CROSS_COMPILE = $options{CROSS_COMPILE} // '';
- my $TARGET = common(0);
-
- # Populate the environment settings.
- my %env;
- $env{__CNF_CPPDEFINES} = $__CNF_CPPDEFINES;
- $env{__CNF_CPPINCLUDES} = $__CNF_CPPINCLUDES;
- $env{__CNF_CPPFLAGS} = $__CNF_CPPFLAGS;
- $env{__CNF_CFLAGS} = $__CNF_CFLAGS;
- $env{__CNF_CXXFLAGS} = $__CNF_CXXFLAGS;
-
- # Prepare results and return them
- my %ret = {
- 'target' => $TARGET,
- 'options' => $options,
- 'envvars' => %env,
- };
- return %ret;
-}
+ my $GUESSOS = guess_system();
+ determine_compiler_settings();
+ my %ret = map_guess($GUESSOS);
+ $ret{target} = check_solaris_sparc8($ret{target});
+ return %ret;
}
1;