-#######################################################################
-# Note that -march is not among compiler options in below linux-armv4
-# target line. Not specifying one is intentional to give you choice to:
-#
-# a) rely on your compiler default by not specifying one;
-# b) specify your target platform explicitly for optimal performance,
-# e.g. -march=armv6 or -march=armv7-a;
-# c) build "universal" binary that targets *range* of platforms by
-# specifying minimum and maximum supported architecture;
-#
-# As for c) option. It actually makes no sense to specify maximum to be
-# less than ARMv7, because it's the least requirement for run-time
-# switch between platform-specific code paths. And without run-time
-# switch performance would be equivalent to one for minimum. Secondly,
-# there are some natural limitations that you'd have to accept and
-# respect. Most notably you can *not* build "universal" binary for
-# big-endian platform. This is because ARMv7 processor always picks
-# instructions in little-endian order. Another similar limitation is
-# that -mthumb can't "cross" -march=armv6t2 boundary, because that's
-# where it became Thumb-2. Well, this limitation is a bit artificial,
-# because it's not really impossible, but it's deemed too tricky to
-# support. And of course you have to be sure that your binutils are
-# actually up to the task of handling maximum target platform. With all
-# this in mind here is an example of how to configure "universal" build:
-#
-# ./Configure linux-armv4 -march=armv6 -D__ARM_MAX_ARCH__=8
-#
-"linux-armv4", "gcc:-O3 -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${armv4_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
-"linux-aarch64","gcc:-O3 -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${aarch64_asm}:linux64:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
-# Configure script adds minimally required -march for assembly support,
-# if no -march was specified at command line. mips32 and mips64 below
-# refer to contemporary MIPS Architecture specifications, MIPS32 and
-# MIPS64, rather than to kernel bitness.
-"linux-mips32", "gcc:-mabi=32 -O3 -Wall -DBN_DIV3W::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${mips32_asm}:o32:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
-"linux-mips64", "gcc:-mabi=n32 -O3 -Wall -DBN_DIV3W::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${mips64_asm}:n32:dlfcn:linux-shared:-fPIC:-mabi=n32:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::32",
-"linux64-mips64", "gcc:-mabi=64 -O3 -Wall -DBN_DIV3W::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${mips64_asm}:64:dlfcn:linux-shared:-fPIC:-mabi=64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::64",
-#### IA-32 targets...
-"linux-ia32-icc", "icc:-DL_ENDIAN -O2::-D_REENTRANT::-ldl -no_cpprt:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared:-KPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
-"linux-elf", "gcc:-DL_ENDIAN -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
-"linux-aout", "gcc:-DL_ENDIAN -O3 -fomit-frame-pointer -march=i486 -Wall::(unknown):::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_asm}:a.out",
-####
-"linux-generic64","gcc:-O3 -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${no_asm_filler}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
-"linux-ppc64", "gcc:-m64 -DB_ENDIAN -O3 -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_RISC1 DES_UNROLL:${ppc64_asm}:linux64:dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::64",
-"linux-ppc64le","gcc:-m64 -DL_ENDIAN -O3 -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_RISC1 DES_UNROLL:$ppc64_asm:linux64le:dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::",
-"linux-ia64", "gcc:-DL_ENDIAN -O3 -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_UNROLL DES_INT:${ia64_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
-"linux-ia64-icc","icc:-DL_ENDIAN -O2 -Wall::-D_REENTRANT::-ldl -no_cpprt:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_RISC1 DES_INT:${ia64_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
-"linux-x86_64", "gcc:-m64 -DL_ENDIAN -O3 -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::64",
-"linux-x86_64-clang", "clang:-m64 -DL_ENDIAN -O3 -Weverything $clang_disabled_warnings -Qunused-arguments::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::64",
-"linux-x86_64-icc", "icc:-DL_ENDIAN -O2::-D_REENTRANT::-ldl -no_cpprt:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::64",
-"linux-x32", "gcc:-mx32 -DL_ENDIAN -O3 -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT RC4_CHUNK_LL DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:linux-shared:-fPIC:-mx32:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::x32:",
-"linux64-s390x", "gcc:-m64 -DB_ENDIAN -O3 -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL:${s390x_asm}:64:dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::64",
-#### So called "highgprs" target for z/Architecture CPUs
-# "Highgprs" is kernel feature first implemented in Linux 2.6.32, see
-# /proc/cpuinfo. The idea is to preserve most significant bits of
-# general purpose registers not only upon 32-bit process context
-# switch, but even on asynchronous signal delivery to such process.
-# This makes it possible to deploy 64-bit instructions even in legacy
-# application context and achieve better [or should we say adequate]
-# performance. The build is binary compatible with linux-generic32,
-# and the idea is to be able to install the resulting libcrypto.so
-# alongside generic one, e.g. as /lib/highgprs/libcrypto.so.x.y, for
-# ldconfig and run-time linker to autodiscover. Unfortunately it
-# doesn't work just yet, because of couple of bugs in glibc
-# sysdeps/s390/dl-procinfo.c affecting ldconfig and ld.so.1...
-"linux32-s390x", "gcc:-m31 -Wa,-mzarch -DB_ENDIAN -O3 -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL:".eval{my $asm=$s390x_asm;$asm=~s/bn\-s390x\.o/bn_asm.o/;$asm}.":31:dlfcn:linux-shared:-fPIC:-m31:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::/highgprs",
-#### SPARC Linux setups
-# Ray Miller <ray.miller@computing-services.oxford.ac.uk> has patiently
-# assisted with debugging of following two configs.
-"linux-sparcv8","gcc:-mv8 -DB_ENDIAN -O3 -fomit-frame-pointer -Wall -DBN_DIV2W::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${sparcv8_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
-# it's a real mess with -mcpu=ultrasparc option under Linux, but
-# -Wa,-Av8plus should do the trick no matter what.
-"linux-sparcv9","gcc:-m32 -mcpu=ultrasparc -DB_ENDIAN -O3 -fomit-frame-pointer -Wall -Wa,-Av8plus -DBN_DIV2W::-D_REENTRANT:ULTRASPARC:-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${sparcv9_asm}:dlfcn:linux-shared:-fPIC:-m32:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
-# GCC 3.1 is a requirement
-"linux64-sparcv9","gcc:-m64 -mcpu=ultrasparc -DB_ENDIAN -O3 -fomit-frame-pointer -Wall::-D_REENTRANT:ULTRASPARC:-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_PTR DES_RISC1 DES_UNROLL BF_PTR:${sparcv9_asm}:dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::64",
-#### Alpha Linux with GNU C and Compaq C setups
-# Special notes:
-# - linux-alpha+bwx-gcc is ment to be used from ./config only. If you
-# ought to run './Configure linux-alpha+bwx-gcc' manually, do
-# complement the command line with -mcpu=ev56, -mcpu=ev6 or whatever
-# which is appropriate.
-# - If you use ccc keep in mind that -fast implies -arch host and the
-# compiler is free to issue instructions which gonna make elder CPU
-# choke. If you wish to build "blended" toolkit, add -arch generic
-# *after* -fast and invoke './Configure linux-alpha-ccc' manually.
-"linux-alpha-gcc","gcc:-O3 -DL_ENDIAN::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_RISC1 DES_UNROLL:${alpha_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
-"linux-alpha+bwx-gcc","gcc:-O3 -DL_ENDIAN::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_RISC1 DES_UNROLL:${alpha_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
-"linux-alpha-ccc","ccc:-fast -readonly_strings -DL_ENDIAN::-D_REENTRANT:::SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_PTR DES_RISC1 DES_UNROLL:${alpha_asm}",
-"linux-alpha+bwx-ccc","ccc:-fast -readonly_strings -DL_ENDIAN::-D_REENTRANT:::SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_PTR DES_RISC1 DES_UNROLL:${alpha_asm}",
-#
-# TI_CGT_C6000_7.3.x is a requirement
-"linux-c64xplus","cl6x:--linux -ea=.s -eo=.o -mv6400+ -o2 -ox -ms -pden -DOPENSSL_SMALL_FOOTPRINT::-D_REENTRANT:::BN_LLONG:c64xpluscpuid.o:bn-c64xplus.o c64xplus-gf2m.o:::aes-c64xplus.o aes_cbc.o aes_ctr.o:::sha1-c64xplus.o sha256-c64xplus.o sha512-c64xplus.o::rc4-c64xplus.o:::::ghash-c64xplus.o::void:dlfcn:linux-shared:--pic:-z --sysv --shared:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):true",
-
-# Android: linux-* but without pointers to headers and libs.
-"android","gcc:-mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${no_asm_filler}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
-"android-x86","gcc:-mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:".eval{my $asm=${x86_elf_asm};$asm=~s/:elf/:android/;$asm}.":dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
-"android-armv7","gcc:-march=armv7-a -mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${armv4_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
-"android-mips","gcc:-mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${mips32_asm}:o32:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
-
-#### *BSD [do see comment about ${BSDthreads} in Configure!]
-"BSD-generic32","gcc:-O3 -fomit-frame-pointer -Wall::${BSDthreads}:::BN_LLONG RC2_CHAR RC4_INDEX DES_INT DES_UNROLL:${no_asm_filler}:dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
-"BSD-x86", "gcc:-DL_ENDIAN -O3 -fomit-frame-pointer -Wall::${BSDthreads}:::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_asm}:a.out:dlfcn:bsd-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
-"BSD-x86-elf", "gcc:-DL_ENDIAN -O3 -fomit-frame-pointer -Wall::${BSDthreads}:::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:bsd-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
-"debug-BSD-x86-elf", "gcc:-DL_ENDIAN -O3 -Wall -g::${BSDthreads}:::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:bsd-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
-"BSD-sparcv8", "gcc:-DB_ENDIAN -O3 -mv8 -Wall::${BSDthreads}:::BN_LLONG RC2_CHAR RC4_INDEX DES_INT DES_UNROLL:${sparcv8_asm}:dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
-
-"BSD-generic64","gcc:-O3 -Wall::${BSDthreads}:::SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${no_asm_filler}:dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
-# -DMD32_REG_T=int doesn't actually belong in sparc64 target, it
-# simply *happens* to work around a compiler bug in gcc 3.3.3,
-# triggered by RIPEMD160 code.
-"BSD-sparc64", "gcc:-DB_ENDIAN -O3 -DMD32_REG_T=int -Wall::${BSDthreads}:::BN_LLONG RC2_CHAR RC4_CHUNK DES_INT DES_PTR DES_RISC2 BF_PTR:${sparcv9_asm}:dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
-"BSD-ia64", "gcc:-DL_ENDIAN -O3 -Wall::${BSDthreads}:::SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_UNROLL DES_INT:${ia64_asm}:dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
-"BSD-x86_64", "gcc:-DL_ENDIAN -O3 -Wall::${BSDthreads}:::SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
-
-"bsdi-elf-gcc", "gcc:-DPERL5 -DL_ENDIAN -fomit-frame-pointer -O3 -march=i486 -Wall::(unknown)::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
-
-"nextstep", "cc:-O -Wall:<libc.h>:(unknown):::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:::",
-"nextstep3.3", "cc:-O3 -Wall:<libc.h>:(unknown):::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:::",
+ "linux-ppc" => {
+ inherit_from => [ "linux-generic32", asm("ppc32_asm") ],
+ perlasm_scheme => "linux32",
+ },
+ "linux-ppc64" => {
+ inherit_from => [ "linux-generic64", asm("ppc64_asm") ],
+ cflags => "-m64 -Wall -DB_ENDIAN",
+ perlasm_scheme => "linux64",
+ shared_ldflag => "-m64",
+ multilib => "64",
+ },
+ "linux-ppc64le" => {
+ inherit_from => [ "linux-generic64", asm("ppc64_asm") ],
+ cflags => "-m64 -Wall -DL_ENDIAN",
+ perlasm_scheme => "linux64le",
+ shared_ldflag => "-m64",
+ },
+
+ "linux-armv4" => {
+ ################################################################
+ # Note that -march is not among compiler options in linux-armv4
+ # target description. Not specifying one is intentional to give
+ # you choice to:
+ #
+ # a) rely on your compiler default by not specifying one;
+ # b) specify your target platform explicitly for optimal
+ # performance, e.g. -march=armv6 or -march=armv7-a;
+ # c) build "universal" binary that targets *range* of platforms
+ # by specifying minimum and maximum supported architecture;
+ #
+ # As for c) option. It actually makes no sense to specify
+ # maximum to be less than ARMv7, because it's the least
+ # requirement for run-time switch between platform-specific
+ # code paths. And without run-time switch performance would be
+ # equivalent to one for minimum. Secondly, there are some
+ # natural limitations that you'd have to accept and respect.
+ # Most notably you can *not* build "universal" binary for
+ # big-endian platform. This is because ARMv7 processor always
+ # picks instructions in little-endian order. Another similar
+ # limitation is that -mthumb can't "cross" -march=armv6t2
+ # boundary, because that's where it became Thumb-2. Well, this
+ # limitation is a bit artificial, because it's not really
+ # impossible, but it's deemed too tricky to support. And of
+ # course you have to be sure that your binutils are actually
+ # up to the task of handling maximum target platform. With all
+ # this in mind here is an example of how to configure
+ # "universal" build:
+ #
+ # ./Configure linux-armv4 -march=armv6 -D__ARM_MAX_ARCH__=8
+ #
+ inherit_from => [ "linux-generic32", asm("armv4_asm") ],
+ perlasm_scheme => "linux32",
+ },
+ "linux-aarch64" => {
+ inherit_from => [ "linux-generic64", asm("aarch64_asm") ],
+ perlasm_scheme => "linux64",
+ },
+ "linux-arm64ilp32" => { # https://wiki.linaro.org/Platform/arm64-ilp32
+ inherit_from => [ "linux-generic32", asm("aarch64_asm") ],
+ cflags => "-mabi=ilp32 -Wall"
+ bn_ops => "SIXTY_FOUR_BIT RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR",
+ perlasm_scheme => "linux64",
+ shared_ldflag => "-mabi=ilp32",
+ },
+
+ "linux-mips32" => {
+ # Configure script adds minimally required -march for assembly
+ # support, if no -march was specified at command line.
+ inherit_from => [ "linux-generic32", asm("mips32_asm") ],
+ cflags => "-mabi=32 -Wall -DBN_DIV3W",
+ perlasm_scheme => "o32",
+ shared_ldflag => "-mabi=32",
+ },
+ # mips32 and mips64 below refer to contemporary MIPS Architecture
+ # specifications, MIPS32 and MIPS64, rather than to kernel bitness.
+ "linux-mips64" => {
+ inherit_from => [ "linux-generic32", asm("mips64_asm") ],
+ cflags => "-mabi=n32 -Wall -DBN_DIV3W",
+ bn_ops => "SIXTY_FOUR_BIT RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR",
+ perlasm_scheme => "n32",
+ shared_ldflag => "-mabi=n32",
+ multilib => "32",
+ },
+ "linux64-mips64" => {
+ inherit_from => [ "linux-generic64", asm("mips64_asm") ],
+ cflags => "-mabi=64 -O3 -Wall -DBN_DIV3W",
+ perlasm_scheme => "64",
+ shared_ldflag => "-mabi=64",
+ multilib => "64",
+ },
+
+ #### IA-32 targets...
+ "linux-elf" => {
+ inherit_from => [ "linux-generic32", asm("x86_elf_asm") ],
+ cc => "gcc",
+ cflags => "-march=i486 -DL_ENDIAN -Wall",
+ debug_cflags => "-O0 -g -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG",
+ release_cflags => "-O3 -fomit-frame-pointer",
+ debug_lflags => "-lefence",
+ bn_ops => "BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}",
+ },
+ "linux-aout" => {
+ inherit_from => [ asm("x86_asm") ],
+ cc => "gcc",
+ cflags => "-DL_ENDIAN -march=i486 -Wall",
+ debug_cflags => "-O0 -g",
+ release_cflags => "-O3 -fomit-frame-pointer",
+ thread_cflag => "(unknown)",
+ bn_ops => "BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}",
+ perlasm_scheme => "a.out",
+ },
+
+ "linux-x86_64" => {
+ inherit_from => [ "linux-generic64", asm("x86_64_asm") ],
+ cflags => "-m64 -DL_ENDIAN -Wall",
+ bn_ops => "SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL",
+ perlasm_scheme => "elf",
+ shared_ldflag => "-m64",
+ multilib => "64",
+ },
+ "linux-x86_64-clang" => {
+ inherit_from => [ "linux-x86_64" ],
+ cc => "clang",
+ cflags => "-m64 -DL_ENDIAN -Wall -Wextra -Qunused-arguments",
+ },
+ "linux-x32" => {
+ inherit_from => [ "linux-generic32", asm("x86_64_asm") ],
+ cflags => "-mx32 -DL_ENDIAN -Wall",
+ bn_ops => "SIXTY_FOUR_BIT RC4_CHUNK_LL DES_INT DES_UNROLL",
+ perlasm_scheme => "elf",
+ shared_ldflag => "-mx32",
+ multilib => "x32",
+ },
+
+ "linux-ia64" => {
+ inherit_from => [ "linux-generic64", asm("ia64_asm") ],
+ bn_ops => "SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_UNROLL DES_INT",
+ },
+
+ "linux64-s390x" => {
+ inherit_from => [ "linux-generic64", asm("s390x_asm") ],
+ cflags => "-m64 -Wall -DB_ENDIAN",
+ thread_cflag => "-D_REENTRANT",
+ perlasm_scheme => "64",
+ shared_ldflag => "-m64",
+ multilib => "64",
+ },
+ "linux32-s390x" => {
+ #### So called "highgprs" target for z/Architecture CPUs
+ # "Highgprs" is kernel feature first implemented in Linux
+ # 2.6.32, see /proc/cpuinfo. The idea is to preserve most
+ # significant bits of general purpose registers not only
+ # upon 32-bit process context switch, but even on
+ # asynchronous signal delivery to such process. This makes
+ # it possible to deploy 64-bit instructions even in legacy
+ # application context and achieve better [or should we say
+ # adequate] performance. The build is binary compatible with
+ # linux-generic32, and the idea is to be able to install the
+ # resulting libcrypto.so alongside generic one, e.g. as
+ # /lib/highgprs/libcrypto.so.x.y, for ldconfig and run-time
+ # linker to autodiscover. Unfortunately it doesn't work just
+ # yet, because of couple of bugs in glibc
+ # sysdeps/s390/dl-procinfo.c affecting ldconfig and ld.so.1...
+ #
+ inherit_from => [ "linux-generic32", asm("s390x_asm") ],
+ cflags => "-m31 -Wall -Wa,-mzarch -DB_ENDIAN",
+ bn_obj => sub { my $r=join(" ",@_); $r=~s/bn\-s390x/bn_asm/; $r; },
+ perlasm_scheme => "31",
+ shared_ldflag => "-m31",
+ multilib => "/highgprs",
+ },
+
+ #### SPARC Linux setups
+ # Ray Miller <ray.miller@computing-services.oxford.ac.uk> has
+ # patiently assisted with debugging of following two configs.
+ "linux-sparcv8" => {
+ inherit_from => [ "linux-generic32", asm("sparcv8_asm") ],
+ cflags => "-mcpu=v8 -Wall -DB_ENDIAN -DBN_DIV2W",
+ },
+ "linux-sparcv9" => {
+ # it's a real mess with -mcpu=ultrasparc option under Linux,
+ # but -Wa,-Av8plus should do the trick no matter what.
+ inherit_from => [ "linux-generic32", asm("sparcv9_asm") ],
+ cflags => "-m32 -mcpu=ultrasparc -Wall -Wa,-Av8plus -DB_ENDIAN -DBN_DIV2W",
+ shared_ldflag => "-m32",
+ },
+ "linux64-sparcv9" => {
+ # GCC 3.1 is a requirement
+ inherit_from => [ "linux-generic64", asm("sparcv9_asm") ],
+ cflags => "-m64 -mcpu=ultrasparc -Wall -DB_ENDIAN",
+ bn_ops => "BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR",
+ shared_ldflag => "-m64",
+ multilib => "64",
+ },
+
+ "linux-alpha-gcc" => {
+ inherit_from => [ "linux-generic64", asm("alpha_asm") ],
+ cflags => "-DL_ENDIAN",
+ bn_ops => "SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_RISC1 DES_UNROLL",
+ },
+ "linux-c64xplus" => {
+ # TI_CGT_C6000_7.3.x is a requirement
+ cc => "cl6x",
+ cflags => "--linux -ea=.s -eo=.o -mv6400+ -o2 -ox -ms -pden -DOPENSSL_SMALL_FOOTPRINT",
+ thread_cflag => "-D_REENTRANT",
+ bn_ops => "BN_LLONG",
+ cpuid_obj => "c64xpluscpuid.o",
+ bn_obj => "bn-c64xplus.o c64xplus-gf2m.o",
+ aes_obj => "aes-c64xplus.o aes_cbc.o aes_ctr.o",
+ sha1_obj => "sha1-c64xplus.o sha256-c64xplus.o sha512-c64xplus.o",
+ rc4_obj => "rc4-c64xplus.o",
+ modes_obj => "ghash-c64xplus.o",
+ perlasm_scheme => "void",
+ dso_scheme => "dlfcn",
+ shared_target => "linux-shared",
+ shared_cflag => "--pic",
+ shared_ldflag => "-z --sysv --shared",
+ shared_extension => ".so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
+ ranlib => "true",
+ },
+
+#### Android: linux-* but without pointers to headers and libs.
+ #
+ # It takes pair of prior-set environment variables to make it work:
+ #
+ # CROSS_SYSROOT=/some/where/android-ndk-<ver>/platforms/android-<apiver>/arch-<
+ # CROSS_COMPILE=<prefix>
+ #
+ # As well as PATH adjusted to cover ${CROSS_COMPILE}gcc and company.
+ # For example to compile for ICS and ARM with NDK 10d, you'd:
+ #
+ # ANDROID_NDK=/some/where/android-ndk-10d
+ # CROSS_SYSROOT=$ANDROID_NDK/platforms/android-14/arch-arm
+ # CROSS_COMPILE=arm-linux-adroideabi-
+ # PATH=$ANDROID_NDK/toolchains/arm-linux-androideabi-4.8/prebuild/linux-x86_64/
+ #
+ "android" => {
+ inherit_from => [ "linux-generic32" ],
+ # Special note about unconditional -fPIC and -pie. The underlying
+ # reason is that Lollipop refuses to run non-PIE. But what about
+ # older systems and NDKs? -fPIC was never problem, so the only
+ # concern if -pie. Older toolchains, e.g. r4, appear to handle it
+ # and binaries turn mostly functional. "Mostly" means that oldest
+ # Androids, such as Froyo, fail to handle executable, but newer
+ # systems are perfectly capable of executing binaries targeting
+ # Froyo. Keep in mind that in the nutshell Android builds are
+ # about JNI, i.e. shared libraries, not applications.
+ cflags => "-mandroid -fPIC --sysroot=\$(CROSS_SYSROOT) -Wa,--noexecstack -Wall",
+ debug_cflags => "-O0 -g",
+ lflags => "-pie%-ldl",
+ shared_cflag => "",
+ },
+ "android-x86" => {
+ inherit_from => [ "android", asm("x86_asm") ],
+ release_cflags => "-O3 -fomit-frame-pointer",
+ bn_ops => "BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}",
+ perlasm_scheme => "android",
+ },
+ ################################################################
+ # Contemporary Android applications can provide multiple JNI
+ # providers in .apk, targeting multiple architectures. Among
+ # them there is "place" for two ARM flavours: generic eabi and
+ # armv7-a/hard-float. However, it should be noted that OpenSSL's
+ # ability to engage NEON is not constrained by ABI choice, nor
+ # is your ability to call OpenSSL from your application code
+ # compiled with floating-point ABI other than default 'soft'.
+ # [Latter thanks to __attribute__((pcs("aapcs"))) declaration.]
+ # This means that choice of ARM libraries you provide in .apk
+ # is driven by application needs. For example if application
+ # itself benefits from NEON or is floating-point intensive, then
+ # it might be appropriate to provide both libraries. Otherwise
+ # just generic eabi would do. But in latter case it would be
+ # appropriate to
+ #
+ # ./Configure android-armeabi -D__ARM_MAX_ARCH__=8
+ #
+ # in order to build "universal" binary and allow OpenSSL take
+ # advantage of NEON when it's available.
+ #
+ "android-armeabi" => {
+ inherit_from => [ "android", asm("armv4_asm") ],
+ },
+ "android-armv7" => {
+ inherit_from => [ "android-armeabi" ],
+ cflags => sub { join (" ","-march=armv7-a",@_); },
+ },
+ "android-mips" => {
+ inherit_from => [ "android", asm("mips32_asm") ],
+ perlasm_scheme => "o32",
+ },
+
+ "android64" => {
+ inherit_from => [ "linux-generic64" ],
+ cflags => "-mandroid -fPIC --sysroot=\$(CROSS_SYSROOT) -Wa,--noexecstack -Wall",
+ debug_cflags => "-O0 -g",
+ lflags => "-pie%-ldl",
+ shared_cflag => "",
+ },
+ "android64-aarch64" => {
+ inherit_from => [ "android64", asm("aarch64_asm") ],
+ perlasm_scheme => "linux64",
+ },
+
+#### *BSD
+ "BSD-generic32" => {
+ # As for thread_cflag. Idea is to maintain "collective" set of
+ # flags, which would cover all BSD flavors. -pthread applies
+ # to them all, but is treated differently. OpenBSD expands is
+ # as -D_POSIX_THREAD -lc_r, which is sufficient. FreeBSD 4.x
+ # expands it as -lc_r, which has to be accompanied by explicit
+ # -D_THREAD_SAFE and sometimes -D_REENTRANT. FreeBSD 5.x
+ # expands it as -lc_r, which seems to be sufficient?
+ cc => "cc",
+ cflags => "-Wall",
+ debug_cflags => "-O0 -g",
+ release_cflags => "-O3",
+ thread_cflag => "-pthread -D_THREAD_SAFE -D_REENTRANT",
+ bn_ops => "BN_LLONG RC2_CHAR RC4_INDEX DES_INT DES_UNROLL",
+ dso_scheme => "dlfcn",
+ shared_target => "bsd-gcc-shared",
+ shared_cflag => "-fPIC",
+ shared_extension => ".so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
+ },
+ "BSD-generic64" => {
+ inherit_from => [ "BSD-generic32" ],
+ bn_ops => "SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL",
+ },
+
+ "BSD-x86" => {
+ inherit_from => [ "BSD-generic32", asm("x86_asm") ],
+ cflags => "-DL_ENDIAN -Wall",
+ release_cflags => "-O3 -fomit-frame-pointer",
+ bn_ops => "BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}",
+ shared_target => "bsd-shared",
+ perlasm_scheme => "a.out",
+ },
+ "BSD-x86-elf" => {
+ inherit_from => [ "BSD-x86" ],
+ perlasm_scheme => "elf",
+ },
+
+ "BSD-sparcv8" => {
+ inherit_from => [ "BSD-generic32", asm("sparcv8_asm") ],
+ cflags => "-mcpu=v8 -Wall -DB_ENDIAN",
+ },
+ "BSD-sparc64" => {
+ # -DMD32_REG_T=int doesn't actually belong in sparc64 target, it
+ # simply *happens* to work around a compiler bug in gcc 3.3.3,
+ # triggered by RIPEMD160 code.
+ inherit_from => [ "BSD-generic64", asm("sparcv9_asm") ],
+ cflags => "-DB_ENDIAN -DMD32_REG_T=int -Wall",
+ bn_ops => "BN_LLONG RC2_CHAR RC4_CHUNK DES_INT DES_PTR DES_RISC2 BF_PTR",
+ },
+
+ "BSD-ia64" => {
+ inherit_from => [ "BSD-generic64", asm("ia64_asm") ],
+ cflags => "-DL_ENDIAN -Wall",
+ bn_ops => "SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_UNROLL DES_INT",
+ },
+
+ "BSD-x86_64" => {
+ inherit_from => [ "BSD-generic64", asm("x86_64_asm") ],
+ cflags => "-DL_ENDIAN -Wall",
+ bn_ops => "SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL",
+ perlasm_scheme => "elf",
+ },
+
+ "bsdi-elf-gcc" => {
+ inherit_from => [ asm("x86_elf_asm") ],
+ cc => "gcc",
+ cflags => "-DPERL5 -DL_ENDIAN -fomit-frame-pointer -O3 -march=i486 -Wall",
+ thread_cflag => "(unknown)",
+ lflags => "-ldl",
+ bn_ops => "BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}",
+ dso_scheme => "dlfcn",
+ shared_target => "bsd-gcc-shared",
+ shared_cflag => "-fPIC",
+ shared_extension => ".so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
+ },
+
+ "nextstep" => {
+ cc => "cc",
+ cflags => "-O -Wall",
+ unistd => "<libc.h>",
+ thread_cflag => "(unknown)",
+ bn_ops => "BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}",
+ },
+ "nextstep3.3" => {
+ cc => "cc",
+ cflags => "-O3 -Wall",
+ unistd => "<libc.h>",
+ thread_cflag => "(unknown)",
+ bn_ops => "BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}",
+ },