155714Skris:
255714Skriseval 'exec perl -S $0 ${1+"$@"}'
355714Skris    if $running_under_some_shell;
455714Skris##
555714Skris##  Configure -- OpenSSL source tree configuration script
655714Skris##
755714Skris
855714Skrisrequire 5.000;
9238405Sjkimuse strict;
10312826Sjkimuse File::Compare;
1155714Skris
1255714Skris# see INSTALL for instructions.
1355714Skris
14238405Sjkimmy $usage="Usage: Configure [no-<cipher> ...] [enable-<cipher> ...] [experimental-<cipher> ...] [-Dxxx] [-lxxx] [-Lxxx] [-fxxx] [-Kxxx] [no-hw-xxx|no-hw] [[no-]threads] [[no-]shared] [[no-]zlib|zlib-dynamic] [no-asm] [no-dso] [no-krb5] [sctp] [386] [--prefix=DIR] [--openssldir=OPENSSLDIR] [--with-xxx[=vvv]] [--test-sanity] os/compiler[:flags]\n";
1555714Skris
1655714Skris# Options:
1755714Skris#
1855714Skris# --openssldir  install OpenSSL in OPENSSLDIR (Default: DIR/ssl if the
1955714Skris#               --prefix option is given; /usr/local/ssl otherwise)
2055714Skris# --prefix      prefix for the OpenSSL include, lib and bin directories
2155714Skris#               (Default: the OPENSSLDIR directory)
2255714Skris#
2355714Skris# --install_prefix  Additional prefix for package builders (empty by
2455714Skris#               default).  This needn't be set in advance, you can
2555714Skris#               just as well use "make INSTALL_PREFIX=/whatever install".
2655714Skris#
27109998Smarkm# --with-krb5-dir  Declare where Kerberos 5 lives.  The libraries are expected
28109998Smarkm#		to live in the subdirectory lib/ and the header files in
29109998Smarkm#		include/.  A value is required.
30109998Smarkm# --with-krb5-lib  Declare where the Kerberos 5 libraries live.  A value is
31109998Smarkm#		required.
32109998Smarkm#		(Default: KRB5_DIR/lib)
33109998Smarkm# --with-krb5-include  Declare where the Kerberos 5 header files live.  A
34109998Smarkm#		value is required.
35109998Smarkm#		(Default: KRB5_DIR/include)
36109998Smarkm# --with-krb5-flavor  Declare what flavor of Kerberos 5 is used.  Currently
37109998Smarkm#		supported values are "MIT" and "Heimdal".  A value is required.
38109998Smarkm#
39100928Snectar# --test-sanity Make a number of sanity checks on the data in this file.
40100928Snectar#               This is a debugging tool for OpenSSL developers.
41100928Snectar#
42238405Sjkim# --cross-compile-prefix Add specified prefix to binutils components.
43238405Sjkim#
44109998Smarkm# no-hw-xxx     do not compile support for specific crypto hardware.
45109998Smarkm#               Generic OpenSSL-style methods relating to this support
46109998Smarkm#               are always compiled but return NULL if the hardware
47109998Smarkm#               support isn't compiled.
48109998Smarkm# no-hw         do not compile support for any crypto hardware.
4955714Skris# [no-]threads  [don't] try to create a library that is suitable for
5055714Skris#               multithreaded applications (default is "threads" if we
5155714Skris#               know how to do it)
5268651Skris# [no-]shared	[don't] try to create shared libraries when supported.
5355714Skris# no-asm        do not use assembler
5468651Skris# no-dso        do not compile in any native shared-library methods. This
5568651Skris#               will ensure that all methods just return NULL.
56109998Smarkm# no-krb5       do not compile in any KRB5 library or code.
57109998Smarkm# [no-]zlib     [don't] compile support for zlib compression.
58109998Smarkm# zlib-dynamic	Like "zlib", but the zlib library is expected to be a shared
59109998Smarkm#		library and will be loaded in run-time by the OpenSSL library.
60238405Sjkim# sctp          include SCTP support
61296279Sjkim# enable-weak-ssl-ciphers
62296279Sjkim#		Enable EXPORT and LOW SSLv3 ciphers that are disabled by
63296279Sjkim#		default.  Note, weak SSLv2 ciphers are unconditionally
64296279Sjkim#		disabled.
65312826Sjkim# 386		generate 80386 code in assembly modules
66312826Sjkim# no-sse2	disables IA-32 SSE2 code in assembly modules, the above
67312826Sjkim#		mentioned '386' option implies this one
6855714Skris# no-<cipher>   build without specified algorithm (rsa, idea, rc5, ...)
6955714Skris# -<xxx> +<xxx> compiler options are passed through 
7068651Skris#
7168651Skris# DEBUG_SAFESTACK use type-safe stacks to enforce type-safety on stack items
7268651Skris#		provided to stack calls. Generates unique stack functions for
7368651Skris#		each possible stack type.
7455714Skris# DES_PTR	use pointer lookup vs arrays in the DES in crypto/des/des_locl.h
7555714Skris# DES_RISC1	use different DES_ENCRYPT macro that helps reduce register
7655714Skris#		dependancies but needs to more registers, good for RISC CPU's
7755714Skris# DES_RISC2	A different RISC variant.
7855714Skris# DES_UNROLL	unroll the inner DES loop, sometimes helps, somtimes hinders.
7955714Skris# DES_INT	use 'int' instead of 'long' for DES_LONG in crypto/des/des.h
8055714Skris#		This is used on the DEC Alpha where long is 8 bytes
8155714Skris#		and int is 4
8255714Skris# BN_LLONG	use the type 'long long' in crypto/bn/bn.h
8355714Skris# MD2_CHAR	use 'char' instead of 'int' for MD2_INT in crypto/md2/md2.h
8455714Skris# MD2_LONG	use 'long' instead of 'int' for MD2_INT in crypto/md2/md2.h
8555714Skris# IDEA_SHORT	use 'short' instead of 'int' for IDEA_INT in crypto/idea/idea.h
8655714Skris# IDEA_LONG	use 'long' instead of 'int' for IDEA_INT in crypto/idea/idea.h
8755714Skris# RC2_SHORT	use 'short' instead of 'int' for RC2_INT in crypto/rc2/rc2.h
8855714Skris# RC2_LONG	use 'long' instead of 'int' for RC2_INT in crypto/rc2/rc2.h
8955714Skris# RC4_CHAR	use 'char' instead of 'int' for RC4_INT in crypto/rc4/rc4.h
9055714Skris# RC4_LONG	use 'long' instead of 'int' for RC4_INT in crypto/rc4/rc4.h
9155714Skris# RC4_INDEX	define RC4_INDEX in crypto/rc4/rc4_locl.h.  This turns on
9255714Skris#		array lookups instead of pointer use.
9359191Skris# RC4_CHUNK	enables code that handles data aligned at long (natural CPU
9459191Skris#		word) boundary.
9559191Skris# RC4_CHUNK_LL	enables code that handles data aligned at long long boundary
9659191Skris#		(intended for 64-bit CPUs running 32-bit OS).
9755714Skris# BF_PTR	use 'pointer arithmatic' for Blowfish (unsafe on Alpha).
9855714Skris# BF_PTR2	intel specific version (generic version is more efficient).
99160814Ssimon#
100160814Ssimon# Following are set automatically by this script
101160814Ssimon#
10255714Skris# MD5_ASM	use some extra md5 assember,
10355714Skris# SHA1_ASM	use some extra sha1 assember, must define L_ENDIAN for x86
10455714Skris# RMD160_ASM	use some extra ripemd160 assember,
105160814Ssimon# SHA256_ASM	sha256_block is implemented in assembler
106160814Ssimon# SHA512_ASM	sha512_block is implemented in assembler
107160814Ssimon# AES_ASM	ASE_[en|de]crypt is implemented in assembler
10855714Skris
109194206Ssimon# Minimum warning options... any contributions to OpenSSL should at least get
110194206Ssimon# past these. 
111194206Ssimon
112325335Sjkimmy $gcc_devteam_warn = "-Wall -pedantic -DPEDANTIC -Wno-long-long -Wsign-compare -Wmissing-prototypes -Wshadow -Wformat -Wundef -Werror -DCRYPTO_MDEBUG_ALL -DCRYPTO_MDEBUG_ABORT -DREF_CHECK -DOPENSSL_NO_DEPRECATED";
113194206Ssimon
114290207Sjkim# TODO(openssl-team): fix problems and investigate if (at least) the following
115290207Sjkim# warnings can also be enabled:
116290207Sjkim# -Wconditional-uninitialized, -Wswitch-enum, -Wunused-macros,
117290207Sjkim# -Wmissing-field-initializers, -Wmissing-variable-declarations,
118290207Sjkim# -Wincompatible-pointer-types-discards-qualifiers, -Wcast-align,
119290207Sjkim# -Wunreachable-code -Wunused-parameter -Wlanguage-extension-token
120290207Sjkim# -Wextended-offsetof
121352193Sjkimmy $clang_disabled_warnings = "-Wno-unknown-warning-option -Wno-unused-parameter -Wno-missing-field-initializers -Wno-language-extension-token  -Wno-extended-offsetof";
122290207Sjkim
123290207Sjkim# These are used in addition to $gcc_devteam_warn when the compiler is clang.
124290207Sjkim# TODO(openssl-team): fix problems and investigate if (at least) the
125290207Sjkim# following warnings can also be enabled: -Wconditional-uninitialized,
126290207Sjkim# -Wswitch-enum, -Wunused-macros, -Wmissing-field-initializers,
127290207Sjkim# -Wmissing-variable-declarations,
128290207Sjkim# -Wincompatible-pointer-types-discards-qualifiers, -Wcast-align,
129290207Sjkim# -Wunreachable-code -Wunused-parameter -Wlanguage-extension-token
130290207Sjkim# -Wextended-offsetof
131352193Sjkimmy $clang_devteam_warn = "-Wno-unknown-warning-option -Wno-unused-parameter -Wno-missing-field-initializers -Wno-language-extension-token -Wno-extended-offsetof -Qunused-arguments";
132290207Sjkim
133295009Sjkim# Warn that "make depend" should be run?
134295009Sjkimmy $warn_make_depend = 0;
135295009Sjkim
136205128Ssimonmy $strict_warnings = 0;
137205128Ssimon
13855714Skrismy $x86_gcc_des="DES_PTR DES_RISC1 DES_UNROLL";
13955714Skris
14055714Skris# MD2_CHAR slags pentium pros
14155714Skrismy $x86_gcc_opts="RC4_INDEX MD2_INT";
14255714Skris
14355714Skris# MODIFY THESE PARAMETERS IF YOU ARE GOING TO USE THE 'util/speed.sh SCRIPT
14455714Skris# Don't worry about these normally
14555714Skris
14655714Skrismy $tcc="cc";
14755714Skrismy $tflags="-fast -Xa";
14855714Skrismy $tbn_mul="";
14955714Skrismy $tlib="-lnsl -lsocket";
15055714Skris#$bits1="SIXTEEN_BIT ";
15155714Skris#$bits2="THIRTY_TWO_BIT ";
15255714Skrismy $bits1="THIRTY_TWO_BIT ";
15355714Skrismy $bits2="SIXTY_FOUR_BIT ";
15455714Skris
155290207Sjkimmy $x86_asm="x86cpuid.o:bn-586.o co-586.o x86-mont.o x86-gf2m.o::des-586.o crypt586.o:aes-586.o vpaes-x86.o aesni-x86.o:bf-586.o:md5-586.o:sha1-586.o sha256-586.o sha512-586.o:cast-586.o:rc4-586.o:rmd-586.o:rc5-586.o:wp_block.o wp-mmx.o:cmll-x86.o:ghash-x86.o:";
15655714Skris
157238405Sjkimmy $x86_elf_asm="$x86_asm:elf";
15876866Skris
159290207Sjkimmy $x86_64_asm="x86_64cpuid.o:x86_64-gcc.o x86_64-mont.o x86_64-mont5.o x86_64-gf2m.o rsaz_exp.o rsaz-x86_64.o rsaz-avx2.o:ecp_nistz256.o ecp_nistz256-x86_64.o::aes-x86_64.o vpaes-x86_64.o bsaes-x86_64.o aesni-x86_64.o aesni-sha1-x86_64.o aesni-sha256-x86_64.o aesni-mb-x86_64.o::md5-x86_64.o:sha1-x86_64.o sha256-x86_64.o sha512-x86_64.o sha1-mb-x86_64.o sha256-mb-x86_64.o::rc4-x86_64.o rc4-md5-x86_64.o:::wp-x86_64.o:cmll-x86_64.o cmll_misc.o:ghash-x86_64.o aesni-gcm-x86_64.o:";
160290207Sjkimmy $ia64_asm="ia64cpuid.o:bn-ia64.o ia64-mont.o:::aes_core.o aes_cbc.o aes-ia64.o::md5-ia64.o:sha1-ia64.o sha256-ia64.o sha512-ia64.o::rc4-ia64.o rc4_skey.o:::::ghash-ia64.o::void";
161290207Sjkimmy $sparcv9_asm="sparcv9cap.o sparccpuid.o:bn-sparcv9.o sparcv9-mont.o sparcv9a-mont.o vis3-mont.o sparct4-mont.o sparcv9-gf2m.o::des_enc-sparc.o fcrypt_b.o dest4-sparcv9.o:aes_core.o aes_cbc.o aes-sparcv9.o aest4-sparcv9.o::md5-sparcv9.o:sha1-sparcv9.o sha256-sparcv9.o sha512-sparcv9.o::::::camellia.o cmll_misc.o cmll_cbc.o cmllt4-sparcv9.o:ghash-sparcv9.o::void";
162290207Sjkimmy $sparcv8_asm=":sparcv8.o::des_enc-sparc.o fcrypt_b.o:::::::::::::void";
163290207Sjkimmy $alpha_asm="alphacpuid.o:bn_asm.o alpha-mont.o::::::sha1-alpha.o:::::::ghash-alpha.o::void";
164290207Sjkimmy $mips64_asm=":bn-mips.o mips-mont.o:::aes_cbc.o aes-mips.o:::sha1-mips.o sha256-mips.o sha512-mips.o::::::::";
165290207Sjkimmy $mips32_asm=$mips64_asm; $mips32_asm =~ s/\s*sha512\-mips\.o//;
166290207Sjkimmy $s390x_asm="s390xcap.o s390xcpuid.o:bn-s390x.o s390x-mont.o s390x-gf2m.o:::aes-s390x.o aes-ctr.o aes-xts.o:::sha1-s390x.o sha256-s390x.o sha512-s390x.o::rc4-s390x.o:::::ghash-s390x.o:";
167290207Sjkimmy $armv4_asm="armcap.o armv4cpuid.o:bn_asm.o armv4-mont.o armv4-gf2m.o:::aes_cbc.o aes-armv4.o bsaes-armv7.o aesv8-armx.o:::sha1-armv4-large.o sha256-armv4.o sha512-armv4.o:::::::ghash-armv4.o ghashv8-armx.o::void";
168290207Sjkimmy $aarch64_asm="armcap.o arm64cpuid.o mem_clr.o::::aes_core.o aes_cbc.o aesv8-armx.o:::sha1-armv8.o sha256-armv8.o sha512-armv8.o:::::::ghashv8-armx.o:";
169290207Sjkimmy $parisc11_asm="pariscid.o:bn_asm.o parisc-mont.o:::aes_core.o aes_cbc.o aes-parisc.o:::sha1-parisc.o sha256-parisc.o sha512-parisc.o::rc4-parisc.o:::::ghash-parisc.o::32";
170290207Sjkimmy $parisc20_asm="pariscid.o:pa-risc2W.o parisc-mont.o:::aes_core.o aes_cbc.o aes-parisc.o:::sha1-parisc.o sha256-parisc.o sha512-parisc.o::rc4-parisc.o:::::ghash-parisc.o::64";
171290207Sjkimmy $ppc64_asm="ppccpuid.o ppccap.o:bn-ppc.o ppc-mont.o ppc64-mont.o:::aes_core.o aes_cbc.o aes-ppc.o vpaes-ppc.o aesp8-ppc.o:::sha1-ppc.o sha256-ppc.o sha512-ppc.o sha256p8-ppc.o sha512p8-ppc.o:::::::ghashp8-ppc.o:";
172290207Sjkimmy $ppc32_asm=$ppc64_asm;
173290207Sjkimmy $no_asm="::::::::::::::::void";
17455714Skris
175160814Ssimon# As for $BSDthreads. Idea is to maintain "collective" set of flags,
176160814Ssimon# which would cover all BSD flavors. -pthread applies to them all, 
177160814Ssimon# but is treated differently. OpenBSD expands is as -D_POSIX_THREAD
178160814Ssimon# -lc_r, which is sufficient. FreeBSD 4.x expands it as -lc_r,
179160814Ssimon# which has to be accompanied by explicit -D_THREAD_SAFE and
180160814Ssimon# sometimes -D_REENTRANT. FreeBSD 5.x expands it as -lc_r, which
181160814Ssimon# seems to be sufficient?
182160814Ssimonmy $BSDthreads="-pthread -D_THREAD_SAFE -D_REENTRANT";
18359191Skris
184290207Sjkim#config-string	$cc : $cflags : $unistd : $thread_cflag : $sys_id : $lflags : $bn_ops : $cpuid_obj : $bn_obj : $ec_obj : $des_obj : $aes_obj : $bf_obj : $md5_obj : $sha1_obj : $cast_obj : $rc4_obj : $rmd160_obj : $rc5_obj : $wp_obj : $cmll_obj : $modes_obj : $engines_obj : $dso_scheme : $shared_target : $shared_cflag : $shared_ldflag : $shared_extension : $ranlib : $arflags : $multilib
185160814Ssimon
18655714Skrismy %table=(
18768651Skris# File 'TABLE' (created by 'make TABLE') contains the data from this list,
18868651Skris# formatted for better readability.
18968651Skris
19068651Skris
19159191Skris#"b",		"${tcc}:${tflags}::${tlib}:${bits1}:${tbn_mul}::",
19259191Skris#"bl-4c-2c",	"${tcc}:${tflags}::${tlib}:${bits1}BN_LLONG RC4_CHAR MD2_CHAR:${tbn_mul}::",
19359191Skris#"bl-4c-ri",	"${tcc}:${tflags}::${tlib}:${bits1}BN_LLONG RC4_CHAR RC4_INDEX:${tbn_mul}::",
19459191Skris#"b2-is-ri-dp",	"${tcc}:${tflags}::${tlib}:${bits2}IDEA_SHORT RC4_INDEX DES_PTR:${tbn_mul}::",
19555714Skris
19655714Skris# Our development configs
197109998Smarkm"purify",	"purify gcc:-g -DPURIFY -Wall::(unknown)::-lsocket -lnsl::::",
198109998Smarkm"debug",	"gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DOPENSSL_NO_ASM -ggdb -g2 -Wformat -Wshadow -Wmissing-prototypes -Wmissing-declarations -Werror::(unknown)::-lefence::::",
199238405Sjkim"debug-ben",	"gcc:$gcc_devteam_warn -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DDEBUG_SAFESTACK -O2 -pipe::(unknown):::::",
200109998Smarkm"debug-ben-openbsd","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DPEDANTIC -DDEBUG_SAFESTACK -DOPENSSL_OPENBSD_DEV_CRYPTO -DOPENSSL_NO_ASM -O2 -pedantic -Wall -Wshadow -Werror -pipe::(unknown)::::",
201109998Smarkm"debug-ben-openbsd-debug","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DPEDANTIC -DDEBUG_SAFESTACK -DOPENSSL_OPENBSD_DEV_CRYPTO -DOPENSSL_NO_ASM -g3 -O2 -pedantic -Wall -Wshadow -Werror -pipe::(unknown)::::",
202238405Sjkim"debug-ben-debug",	"gcc44:$gcc_devteam_warn -DBN_DEBUG -DCONF_DEBUG -DDEBUG_SAFESTACK -DDEBUG_UNUSED -g3 -O2 -pipe::(unknown)::::::",
203246772Sjkim"debug-ben-debug-64",	"gcc:$gcc_devteam_warn -Wno-error=overlength-strings -DBN_DEBUG -DCONF_DEBUG -DDEBUG_SAFESTACK -DDEBUG_UNUSED -g3 -O3 -pipe::${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)",
204238405Sjkim"debug-ben-macos",	"cc:$gcc_devteam_warn -arch i386 -DBN_DEBUG -DCONF_DEBUG -DDEBUG_SAFESTACK -DDEBUG_UNUSED -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -O3 -DL_ENDIAN -g3 -pipe::(unknown)::-Wl,-search_paths_first::::",
205238405Sjkim"debug-ben-macos-gcc46",	"gcc-mp-4.6:$gcc_devteam_warn -Wconversion -DBN_DEBUG -DCONF_DEBUG -DDEBUG_SAFESTACK -DDEBUG_UNUSED -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -O3 -DL_ENDIAN -g3 -pipe::(unknown)::::::",
206290207Sjkim"debug-ben-darwin64","cc:$gcc_devteam_warn -g -Wno-language-extension-token -Wno-extended-offsetof -arch x86_64 -O3 -DL_ENDIAN -Wall::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL:".eval{my $asm=$x86_64_asm;$asm=~s/rc4\-[^:]+//;$asm}.":macosx:dlfcn:darwin-shared:-fPIC -fno-common:-arch x86_64 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
207290207Sjkim"debug-ben-debug-64-clang",	"clang:$gcc_devteam_warn -Wno-error=overlength-strings -Wno-error=extended-offsetof -Qunused-arguments -DBN_DEBUG -DCONF_DEBUG -DDEBUG_SAFESTACK -DDEBUG_UNUSED -g3 -O3 -pipe::${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)",
208238405Sjkim"debug-ben-no-opt",	"gcc: -Wall -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations -DDEBUG_SAFESTACK -DCRYPTO_MDEBUG -Werror -DL_ENDIAN -DTERMIOS -Wall -g3::(unknown)::::::",
209109998Smarkm"debug-ben-strict",	"gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DCONST_STRICT -O2 -Wall -Wshadow -Werror -Wpointer-arith -Wcast-qual -Wwrite-strings -pipe::(unknown)::::::",
210109998Smarkm"debug-rse","cc:-DTERMIOS -DL_ENDIAN -pipe -O -g -ggdb3 -Wall::(unknown):::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}",
211261037Sjkim"debug-bodo",	"gcc:$gcc_devteam_warn -Wno-error=overlength-strings -DBN_DEBUG -DBN_DEBUG_RAND -DCONF_DEBUG -DBIO_PAIR_DEBUG -m64 -DL_ENDIAN -DTERMIO -g -DMD32_REG_T=int::-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",
212246772Sjkim"debug-steve64", "gcc:$gcc_devteam_warn -m64 -DL_ENDIAN -DTERMIO -DCONF_DEBUG -DDEBUG_SAFESTACK -Wno-overlength-strings -g::-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)",
213290207Sjkim"debug-steve32", "gcc:$gcc_devteam_warn -m32 -DL_ENDIAN -DCONF_DEBUG -DDEBUG_SAFESTACK -Wno-overlength-strings -g -pipe::-D_REENTRANT::-rdynamic -ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared:-fPIC:-m32:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
214238405Sjkim"debug-steve-opt", "gcc:$gcc_devteam_warn -m64 -O3 -DL_ENDIAN -DTERMIO -DCONF_DEBUG -DDEBUG_SAFESTACK -g::-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)",
215246772Sjkim"debug-levitte-linux-elf","gcc:-DLEVITTE_DEBUG -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DCRYPTO_MDEBUG -DL_ENDIAN -ggdb -g3 -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
216246772Sjkim"debug-levitte-linux-noasm","gcc:-DLEVITTE_DEBUG -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DCRYPTO_MDEBUG -DOPENSSL_NO_ASM -DL_ENDIAN -ggdb -g3 -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
217280297Sjkim"debug-levitte-linux-elf-extreme","gcc:-DLEVITTE_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_DEBUG -DBN_DEBUG_RAND -DCRYPTO_MDEBUG -DENGINE_CONF_DEBUG -DL_ENDIAN -DPEDANTIC -ggdb -g3 -pedantic -ansi -Wall -W -Wundef -Wshadow -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wno-long-long -Wundef -Wconversion -pipe::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
218280297Sjkim"debug-levitte-linux-noasm-extreme","gcc:-DLEVITTE_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_DEBUG -DBN_DEBUG_RAND -DCRYPTO_MDEBUG -DENGINE_CONF_DEBUG -DOPENSSL_NO_ASM -DL_ENDIAN -DPEDANTIC -ggdb -g3 -pedantic -ansi -Wall -W -Wundef -Wshadow -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wno-long-long -Wundef -Wconversion -pipe::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
219238405Sjkim"debug-geoff32","gcc:-DBN_DEBUG -DBN_DEBUG_RAND -DBN_STRICT -DPURIFY -DOPENSSL_NO_DEPRECATED -DOPENSSL_NO_ASM -DOPENSSL_NO_INLINE_ASM -DL_ENDIAN -DTERMIO -DPEDANTIC -O1 -ggdb2 -Wall -Werror -Wundef -pedantic -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-align -Wsign-compare -Wmissing-prototypes -Wmissing-declarations -Wno-long-long::-D_REENTRANT::-ldl:BN_LLONG:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
220238405Sjkim"debug-geoff64","gcc:-DBN_DEBUG -DBN_DEBUG_RAND -DBN_STRICT -DPURIFY -DOPENSSL_NO_DEPRECATED -DOPENSSL_NO_ASM -DOPENSSL_NO_INLINE_ASM -DL_ENDIAN -DTERMIO -DPEDANTIC -O1 -ggdb2 -Wall -Werror -Wundef -pedantic -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-align -Wsign-compare -Wmissing-prototypes -Wmissing-declarations -Wno-long-long::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
221280297Sjkim"debug-linux-pentium","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DL_ENDIAN -g -mcpu=pentium -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn",
222280297Sjkim"debug-linux-ppro","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DL_ENDIAN -g -mcpu=pentiumpro -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn",
223280297Sjkim"debug-linux-elf","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DL_ENDIAN -g -march=i486 -Wall::-D_REENTRANT::-lefence -ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
224280297Sjkim"debug-linux-elf-noefence","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DL_ENDIAN -g -march=i486 -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
225290207Sjkim"debug-linux-ia32-aes", "gcc:-DAES_EXPERIMENTAL -DL_ENDIAN -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:x86cpuid.o:bn-586.o co-586.o x86-mont.o::des-586.o crypt586.o:aes_x86core.o aes_cbc.o aesni-x86.o:bf-586.o:md5-586.o:sha1-586.o sha256-586.o sha512-586.o:cast-586.o:rc4-586.o:rmd-586.o:rc5-586.o:wp_block.o wp-mmx.o::ghash-x86.o::elf:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
226280297Sjkim"debug-linux-generic32","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DCRYPTO_MDEBUG -g -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
227290207Sjkim"debug-linux-generic64","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DCRYPTO_MDEBUG -DTERMIO -g -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
228280297Sjkim"debug-linux-x86_64","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DCRYPTO_MDEBUG -m64 -DL_ENDIAN -g -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",
229109998Smarkm"dist",		"cc:-O::(unknown)::::::",
23055714Skris
23159191Skris# Basic configs that should work on any (32 and less bit) box
232109998Smarkm"gcc",		"gcc:-O3::(unknown):::BN_LLONG:::",
233109998Smarkm"cc",		"cc:-O::(unknown)::::::",
23455714Skris
235142425Snectar####VOS Configurations
236238405Sjkim"vos-gcc","gcc:-O3 -Wall -DOPENSSL_SYSNAME_VOS -D_POSIX_C_SOURCE=200112L -D_BSD -D_VOS_EXTENDED_NAMES -DB_ENDIAN::(unknown):VOS:-Wl,-map:BN_LLONG:${no_asm}:::::.so:",
237238405Sjkim"debug-vos-gcc","gcc:-O0 -g -Wall -DOPENSSL_SYSNAME_VOS -D_POSIX_C_SOURCE=200112L -D_BSD -D_VOS_EXTENDED_NAMES -DB_ENDIAN -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DCRYPTO_MDEBUG::(unknown):VOS:-Wl,-map:BN_LLONG:${no_asm}:::::.so:",
238142425Snectar
239109998Smarkm#### Solaris x86 with GNU C setups
240109998Smarkm# -DOPENSSL_NO_INLINE_ASM switches off inline assembler. We have to do it
24159191Skris# here because whenever GNU C instantiates an assembler template it
24259191Skris# surrounds it with #APP #NO_APP comment pair which (at least Solaris
24359191Skris# 7_x86) /usr/ccs/bin/as fails to assemble with "Illegal mnemonic"
24459191Skris# error message.
245160814Ssimon"solaris-x86-gcc","gcc:-O3 -fomit-frame-pointer -march=pentium -Wall -DL_ENDIAN -DOPENSSL_NO_INLINE_ASM::-D_REENTRANT::-lsocket -lnsl -ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:solaris-shared:-fPIC:-shared:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
246160814Ssimon# -shared -static-libgcc might appear controversial, but modules taken
247160814Ssimon# from static libgcc do not have relocations and linking them into our
248160814Ssimon# shared objects doesn't have any negative side-effects. On the contrary,
249160814Ssimon# doing so makes it possible to use gcc shared build with Sun C. Given
250160814Ssimon# that gcc generates faster code [thanks to inline assembler], I would
251160814Ssimon# actually recommend to consider using gcc shared build even with vendor
252160814Ssimon# compiler:-)
253160814Ssimon#						<appro@fy.chalmers.se>
254238405Sjkim"solaris64-x86_64-gcc","gcc:-m64 -O3 -Wall -DL_ENDIAN::-D_REENTRANT::-lsocket -lnsl -ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:solaris-shared:-fPIC:-m64 -shared -static-libgcc:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::/64",
255160814Ssimon 
25679998Skris#### Solaris x86 with Sun C setups
257290207Sjkim"solaris-x86-cc","cc:-fast -xarch=generic -O -Xa::-D_REENTRANT::-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_PTR DES_UNROLL BF_PTR:${no_asm}:dlfcn:solaris-shared:-KPIC:-G -dy -z text:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
258238405Sjkim"solaris64-x86_64-cc","cc:-fast -xarch=amd64 -xstrconst -Xa -DL_ENDIAN::-D_REENTRANT::-lsocket -lnsl -ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:solaris-shared:-KPIC:-xarch=amd64 -G -dy -z text:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::/64",
25979998Skris
26055714Skris#### SPARC Solaris with GNU C setups
261160814Ssimon"solaris-sparcv7-gcc","gcc:-O3 -fomit-frame-pointer -Wall -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT::-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${no_asm}:dlfcn:solaris-shared:-fPIC:-shared:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
262284283Sjkim"solaris-sparcv8-gcc","gcc:-mcpu=v8 -O3 -fomit-frame-pointer -Wall -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT::-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${sparcv8_asm}:dlfcn:solaris-shared:-fPIC:-shared:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
263109998Smarkm# -m32 should be safe to add as long as driver recognizes -mcpu=ultrasparc
264238405Sjkim"solaris-sparcv9-gcc","gcc:-m32 -mcpu=ultrasparc -O3 -fomit-frame-pointer -Wall -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT:ULTRASPARC:-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${sparcv9_asm}:dlfcn:solaris-shared:-fPIC:-shared:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
265238405Sjkim"solaris64-sparcv9-gcc","gcc:-m64 -mcpu=ultrasparc -O3 -Wall -DB_ENDIAN::-D_REENTRANT:ULTRASPARC:-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_PTR DES_RISC1 DES_UNROLL BF_PTR:${sparcv9_asm}:dlfcn:solaris-shared:-fPIC:-m64 -shared:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::/64",
26655714Skris####
267284283Sjkim"debug-solaris-sparcv8-gcc","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG_ALL -O -g -mcpu=v8 -Wall -DB_ENDIAN::-D_REENTRANT::-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${sparcv8_asm}:dlfcn:solaris-shared:-fPIC:-shared:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
268238405Sjkim"debug-solaris-sparcv9-gcc","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG_ALL -DPEDANTIC -O -g -mcpu=ultrasparc -pedantic -ansi -Wall -Wshadow -Wno-long-long -D__EXTENSIONS__ -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT:ULTRASPARC:-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${sparcv9_asm}:dlfcn:solaris-shared:-fPIC:-shared:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
26955714Skris
27055714Skris#### SPARC Solaris with Sun C setups
27155714Skris# SC4.0 doesn't pass 'make test', upgrade to SC5.0 or SC4.2.
27255714Skris# SC4.2 is ok, better than gcc even on bn as long as you tell it -xarch=v8
27355714Skris# SC5.0 note: Compiler common patch 107357-01 or later is required!
274160814Ssimon"solaris-sparcv7-cc","cc:-xO5 -xstrconst -xdepend -Xa -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT::-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_PTR DES_RISC1 DES_UNROLL BF_PTR:${no_asm}:dlfcn:solaris-shared:-KPIC:-G -dy -z text:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
275238405Sjkim"solaris-sparcv8-cc","cc:-xarch=v8 -xO5 -xstrconst -xdepend -Xa -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT::-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_PTR DES_RISC1 DES_UNROLL BF_PTR:${sparcv8_asm}:dlfcn:solaris-shared:-KPIC:-G -dy -z text:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
276238405Sjkim"solaris-sparcv9-cc","cc:-xtarget=ultra -xarch=v8plus -xO5 -xstrconst -xdepend -Xa -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT:ULTRASPARC:-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK_LL DES_PTR DES_RISC1 DES_UNROLL BF_PTR:${sparcv9_asm}:dlfcn:solaris-shared:-KPIC:-G -dy -z text:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
277246772Sjkim"solaris64-sparcv9-cc","cc:-xtarget=ultra -xarch=v9 -xO5 -xstrconst -xdepend -Xa -DB_ENDIAN::-D_REENTRANT:ULTRASPARC:-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_PTR DES_RISC1 DES_UNROLL BF_PTR:${sparcv9_asm}:dlfcn:solaris-shared:-KPIC:-xarch=v9 -G -dy -z text:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::/64",
27859191Skris####
279238405Sjkim"debug-solaris-sparcv8-cc","cc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG_ALL -xarch=v8 -g -O -xstrconst -Xa -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT::-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_PTR DES_RISC1 DES_UNROLL BF_PTR:${sparcv8_asm}:dlfcn:solaris-shared:-KPIC:-G -dy -z text:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
280238405Sjkim"debug-solaris-sparcv9-cc","cc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG_ALL -xtarget=ultra -xarch=v8plus -g -O -xstrconst -Xa -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT:ULTRASPARC:-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK_LL DES_PTR DES_RISC1 DES_UNROLL BF_PTR:${sparcv9_asm}:dlfcn:solaris-shared:-KPIC:-G -dy -z text:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 
28155714Skris
282160814Ssimon#### SunOS configs, assuming sparc for the gcc one.
283160814Ssimon#"sunos-cc", "cc:-O4 -DNOPROTO -DNOCONST::(unknown):SUNOS::DES_UNROLL:${no_asm}::",
284284283Sjkim"sunos-gcc","gcc:-O3 -mcpu=v8 -Dssize_t=int::(unknown):SUNOS::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL DES_PTR DES_RISC1:${no_asm}::",
28555714Skris
28655714Skris#### IRIX 5.x configs
28755714Skris# -mips2 flag is added by ./config when appropriate.
288280297Sjkim"irix-gcc","gcc:-O3 -DB_ENDIAN::(unknown):::BN_LLONG MD2_CHAR RC4_INDEX RC4_CHAR RC4_CHUNK DES_UNROLL DES_RISC2 DES_PTR BF_PTR:${mips32_asm}:o32:dlfcn:irix-shared:::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
289280297Sjkim"irix-cc", "cc:-O2 -use_readonly_const -DB_ENDIAN::(unknown):::BN_LLONG RC4_CHAR RC4_CHUNK DES_PTR DES_RISC2 DES_UNROLL BF_PTR:${mips32_asm}:o32:dlfcn:irix-shared:::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
29055714Skris#### IRIX 6.x configs
29155714Skris# Only N32 and N64 ABIs are supported. If you need O32 ABI build, invoke
292127128Snectar# './Configure irix-cc -o32' manually.
293280297Sjkim"irix-mips3-gcc","gcc:-mabi=n32 -O3 -DB_ENDIAN -DBN_DIV3W::-D_SGI_MP_SOURCE:::MD2_CHAR RC4_INDEX RC4_CHAR RC4_CHUNK_LL DES_UNROLL DES_RISC2 DES_PTR BF_PTR SIXTY_FOUR_BIT:${mips64_asm}:n32:dlfcn:irix-shared::-mabi=n32:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::32",
294280297Sjkim"irix-mips3-cc", "cc:-n32 -mips3 -O2 -use_readonly_const -G0 -rdata_shared -DB_ENDIAN -DBN_DIV3W::-D_SGI_MP_SOURCE:::DES_PTR RC4_CHAR RC4_CHUNK_LL DES_RISC2 DES_UNROLL BF_PTR SIXTY_FOUR_BIT:${mips64_asm}:n32:dlfcn:irix-shared::-n32:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::32",
29555714Skris# N64 ABI builds.
296280297Sjkim"irix64-mips4-gcc","gcc:-mabi=64 -mips4 -O3 -DB_ENDIAN -DBN_DIV3W::-D_SGI_MP_SOURCE:::RC4_CHAR RC4_CHUNK DES_RISC2 DES_UNROLL SIXTY_FOUR_BIT_LONG:${mips64_asm}:64:dlfcn:irix-shared::-mabi=64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::64",
297280297Sjkim"irix64-mips4-cc", "cc:-64 -mips4 -O2 -use_readonly_const -G0 -rdata_shared -DB_ENDIAN -DBN_DIV3W::-D_SGI_MP_SOURCE:::RC4_CHAR RC4_CHUNK DES_RISC2 DES_UNROLL SIXTY_FOUR_BIT_LONG:${mips64_asm}:64:dlfcn:irix-shared::-64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::64",
29855714Skris
29959191Skris#### Unified HP-UX ANSI C configs.
30059191Skris# Special notes:
30159191Skris# - Originally we were optimizing at +O4 level. It should be noted
30259191Skris#   that the only difference between +O3 and +O4 is global inter-
30359191Skris#   procedural analysis. As it has to be performed during the link
30459191Skris#   stage the compiler leaves behind certain pseudo-code in lib*.a
30559191Skris#   which might be release or even patch level specific. Generating
30659191Skris#   the machine code for and analyzing the *whole* program appears
30759191Skris#   to be *extremely* memory demanding while the performance gain is
30859191Skris#   actually questionable. The situation is intensified by the default
30959191Skris#   HP-UX data set size limit (infamous 'maxdsiz' tunable) of 64MB
31059191Skris#   which is way too low for +O4. In other words, doesn't +O3 make
31159191Skris#   more sense?
31259191Skris# - Keep in mind that the HP compiler by default generates code
31359191Skris#   suitable for execution on the host you're currently compiling at.
31459191Skris#   If the toolkit is ment to be used on various PA-RISC processors
315109998Smarkm#   consider './config +DAportable'.
316160814Ssimon# - +DD64 is chosen in favour of +DA2.0W because it's meant to be
31759191Skris#   compatible with *future* releases.
31859191Skris# - If you run ./Configure hpux-parisc-[g]cc manually don't forget to
31959191Skris#   pass -D_REENTRANT on HP-UX 10 and later.
32059191Skris# - -DMD32_XARRAY triggers workaround for compiler bug we ran into in
32159191Skris#   32-bit message digests. (For the moment of this writing) HP C
32259191Skris#   doesn't seem to "digest" too many local variables (they make "him"
32359191Skris#   chew forever:-). For more details look-up MD32_XARRAY comment in
32459191Skris#   crypto/sha/sha_lcl.h.
32559191Skris#					<appro@fy.chalmers.se>
32659191Skris#
32759191Skris# Since there is mention of this in shlib/hpux10-cc.sh
328160814Ssimon"hpux-parisc-cc-o4","cc:-Ae +O4 +ESlit -z -DB_ENDIAN -DBN_DIV2W -DMD32_XARRAY::-D_REENTRANT::-ldld:BN_LLONG DES_PTR DES_UNROLL DES_RISC1:${no_asm}:dl:hpux-shared:+Z:-b:.sl.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
329160814Ssimon"hpux-parisc-gcc","gcc:-O3 -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT::-Wl,+s -ldld:BN_LLONG DES_PTR DES_UNROLL DES_RISC1:${no_asm}:dl:hpux-shared:-fPIC:-shared:.sl.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
330238405Sjkim"hpux-parisc1_1-gcc","gcc:-O3 -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT::-Wl,+s -ldld:BN_LLONG DES_PTR DES_UNROLL DES_RISC1:${parisc11_asm}:dl:hpux-shared:-fPIC:-shared:.sl.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::/pa1.1",
331238405Sjkim"hpux-parisc2-gcc","gcc:-march=2.0 -O3 -DB_ENDIAN -D_REENTRANT::::-Wl,+s -ldld:SIXTY_FOUR_BIT RC4_CHAR RC4_CHUNK DES_PTR DES_UNROLL DES_RISC1:".eval{my $asm=$parisc20_asm;$asm=~s/2W\./2\./;$asm=~s/:64/:32/;$asm}.":dl:hpux-shared:-fPIC:-shared:.sl.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::/pa20_32",
332290207Sjkim"hpux64-parisc2-gcc","gcc:-O3 -DB_ENDIAN -D_REENTRANT::::-ldl:SIXTY_FOUR_BIT_LONG MD2_CHAR RC4_INDEX RC4_CHAR DES_UNROLL DES_RISC1 DES_INT::pa-risc2W.o:::::::::::::::void:dlfcn:hpux-shared:-fpic:-shared:.sl.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::/pa20_64",
33359191Skris
33468651Skris# More attempts at unified 10.X and 11.X targets for HP C compiler.
33568651Skris#
33668651Skris# Chris Ruemmler <ruemmler@cup.hp.com>
33768651Skris# Kevin Steves <ks@hp.se>
338160814Ssimon"hpux-parisc-cc","cc:+O3 +Optrs_strongly_typed -Ae +ESlit -DB_ENDIAN -DBN_DIV2W -DMD32_XARRAY::-D_REENTRANT::-Wl,+s -ldld:MD2_CHAR RC4_INDEX RC4_CHAR DES_UNROLL DES_RISC1 DES_INT:${no_asm}:dl:hpux-shared:+Z:-b:.sl.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
339238405Sjkim"hpux-parisc1_1-cc","cc:+DA1.1 +O3 +Optrs_strongly_typed -Ae +ESlit -DB_ENDIAN -DMD32_XARRAY::-D_REENTRANT::-Wl,+s -ldld:MD2_CHAR RC4_INDEX RC4_CHAR DES_UNROLL DES_RISC1 DES_INT:${parisc11_asm}:dl:hpux-shared:+Z:-b:.sl.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::/pa1.1",
340238405Sjkim"hpux-parisc2-cc","cc:+DA2.0 +DS2.0 +O3 +Optrs_strongly_typed -Ae +ESlit -DB_ENDIAN -DMD32_XARRAY -D_REENTRANT::::-Wl,+s -ldld:SIXTY_FOUR_BIT MD2_CHAR RC4_INDEX RC4_CHAR DES_UNROLL DES_RISC1 DES_INT:".eval{my $asm=$parisc20_asm;$asm=~s/2W\./2\./;$asm=~s/:64/:32/;$asm}.":dl:hpux-shared:+Z:-b:.sl.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::/pa20_32",
341238405Sjkim"hpux64-parisc2-cc","cc:+DD64 +O3 +Optrs_strongly_typed -Ae +ESlit -DB_ENDIAN -DMD32_XARRAY -D_REENTRANT::::-ldl:SIXTY_FOUR_BIT_LONG MD2_CHAR RC4_INDEX RC4_CHAR DES_UNROLL DES_RISC1 DES_INT:${parisc20_asm}:dlfcn:hpux-shared:+Z:+DD64 -b:.sl.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::/pa20_64",
34268651Skris
343160814Ssimon# HP/UX IA-64 targets
344238405Sjkim"hpux-ia64-cc","cc:-Ae +DD32 +O2 +Olit=all -z -DB_ENDIAN -D_REENTRANT::::-ldl:SIXTY_FOUR_BIT MD2_CHAR RC4_INDEX DES_UNROLL DES_RISC1 DES_INT:${ia64_asm}:dlfcn:hpux-shared:+Z:+DD32 -b:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::/hpux32",
345160814Ssimon# Frank Geurts <frank.geurts@nl.abnamro.com> has patiently assisted with
346160814Ssimon# with debugging of the following config.
347238405Sjkim"hpux64-ia64-cc","cc:-Ae +DD64 +O3 +Olit=all -z -DB_ENDIAN -D_REENTRANT::::-ldl:SIXTY_FOUR_BIT_LONG MD2_CHAR RC4_INDEX DES_UNROLL DES_RISC1 DES_INT:${ia64_asm}:dlfcn:hpux-shared:+Z:+DD64 -b:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::/hpux64",
348160814Ssimon# GCC builds...
349238405Sjkim"hpux-ia64-gcc","gcc:-O3 -DB_ENDIAN -D_REENTRANT::::-ldl:SIXTY_FOUR_BIT MD2_CHAR RC4_INDEX DES_UNROLL DES_RISC1 DES_INT:${ia64_asm}:dlfcn:hpux-shared:-fpic:-shared:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::/hpux32",
350238405Sjkim"hpux64-ia64-gcc","gcc:-mlp64 -O3 -DB_ENDIAN -D_REENTRANT::::-ldl:SIXTY_FOUR_BIT_LONG MD2_CHAR RC4_INDEX DES_UNROLL DES_RISC1 DES_INT:${ia64_asm}:dlfcn:hpux-shared:-fpic:-mlp64 -shared:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::/hpux64", 
35155714Skris
352160814Ssimon# Legacy HPUX 9.X configs...
353160814Ssimon"hpux-cc",	"cc:-DB_ENDIAN -DBN_DIV2W -DMD32_XARRAY -Ae +ESlit +O2 -z::(unknown)::-Wl,+s -ldld:DES_PTR DES_UNROLL DES_RISC1:${no_asm}:dl:hpux-shared:+Z:-b:.sl.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
354160814Ssimon"hpux-gcc",	"gcc:-DB_ENDIAN -DBN_DIV2W -O3::(unknown)::-Wl,+s -ldld:DES_PTR DES_UNROLL DES_RISC1:${no_asm}:dl:hpux-shared:-fPIC:-shared:.sl.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
35555714Skris
35668651Skris#### HP MPE/iX http://jazz.external.hp.com/src/openssl/
357331638Sjkim"MPE/iX-gcc",	"gcc:-DBN_DIV2W -O3 -D_POSIX_SOURCE -D_SOCKET_SOURCE -I/SYSLOG/PUB::(unknown):MPE:-L/SYSLOG/PUB -lsyslog -lsocket -lcurses:BN_LLONG DES_PTR DES_UNROLL DES_RISC1:::",
35868651Skris
359160814Ssimon# DEC Alpha OSF/1/Tru64 targets.
36089837Skris#
36189837Skris#	"What's in a name? That which we call a rose
36289837Skris#	 By any other word would smell as sweet."
36389837Skris#
36489837Skris# - William Shakespeare, "Romeo & Juliet", Act II, scene II.
36589837Skris#
36655714Skris# For gcc, the following gave a %50 speedup on a 164 over the 'DES_INT' version
36789837Skris#
368238405Sjkim"osf1-alpha-gcc", "gcc:-O3::(unknown):::SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_UNROLL DES_RISC1:${alpha_asm}:dlfcn:alpha-osf1-shared:::.so",
369238405Sjkim"osf1-alpha-cc",  "cc:-std1 -tune host -O4 -readonly_strings::(unknown):::SIXTY_FOUR_BIT_LONG RC4_CHUNK:${alpha_asm}:dlfcn:alpha-osf1-shared:::.so",
370238405Sjkim"tru64-alpha-cc", "cc:-std1 -tune host -fast -readonly_strings::-pthread:::SIXTY_FOUR_BIT_LONG RC4_CHUNK:${alpha_asm}:dlfcn:alpha-osf1-shared::-msym:.so",
37155714Skris
372160814Ssimon####
373160814Ssimon#### Variety of LINUX:-)
374160814Ssimon####
375160814Ssimon# *-generic* is endian-neutral target, but ./config is free to
376160814Ssimon# throw in -D[BL]_ENDIAN, whichever appropriate...
377280297Sjkim"linux-generic32","gcc:-O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
378280297Sjkim"linux-ppc",	"gcc:-DB_ENDIAN -O3 -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_RISC1 DES_UNROLL:${ppc32_asm}:linux32:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
379290207Sjkim
380290207Sjkim#######################################################################
381290207Sjkim# Note that -march is not among compiler options in below linux-armv4
382290207Sjkim# target line. Not specifying one is intentional to give you choice to:
383290207Sjkim#
384290207Sjkim# a) rely on your compiler default by not specifying one;
385290207Sjkim# b) specify your target platform explicitly for optimal performance,
386290207Sjkim#    e.g. -march=armv6 or -march=armv7-a;
387290207Sjkim# c) build "universal" binary that targets *range* of platforms by
388290207Sjkim#    specifying minimum and maximum supported architecture;
389290207Sjkim#
390290207Sjkim# As for c) option. It actually makes no sense to specify maximum to be
391290207Sjkim# less than ARMv7, because it's the least requirement for run-time
392290207Sjkim# switch between platform-specific code paths. And without run-time
393290207Sjkim# switch performance would be equivalent to one for minimum. Secondly,
394290207Sjkim# there are some natural limitations that you'd have to accept and
395290207Sjkim# respect. Most notably you can *not* build "universal" binary for
396290207Sjkim# big-endian platform. This is because ARMv7 processor always picks
397290207Sjkim# instructions in little-endian order. Another similar limitation is
398290207Sjkim# that -mthumb can't "cross" -march=armv6t2 boundary, because that's
399290207Sjkim# where it became Thumb-2. Well, this limitation is a bit artificial,
400290207Sjkim# because it's not really impossible, but it's deemed too tricky to
401290207Sjkim# support. And of course you have to be sure that your binutils are
402290207Sjkim# actually up to the task of handling maximum target platform. With all
403290207Sjkim# this in mind here is an example of how to configure "universal" build:
404290207Sjkim#
405290207Sjkim#       ./Configure linux-armv4 -march=armv6 -D__ARM_MAX_ARCH__=8
406290207Sjkim#
407290207Sjkim"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)",
408290207Sjkim"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)",
409290207Sjkim# Configure script adds minimally required -march for assembly support,
410290207Sjkim# if no -march was specified at command line. mips32 and mips64 below
411290207Sjkim# refer to contemporary MIPS Architecture specifications, MIPS32 and
412290207Sjkim# MIPS64, rather than to kernel bitness.
413290207Sjkim"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)",
414290207Sjkim"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",
415290207Sjkim"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",
416160814Ssimon#### IA-32 targets...
417290207Sjkim"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)",
418280297Sjkim"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)",
419280297Sjkim"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",
420160814Ssimon####
421280297Sjkim"linux-generic64","gcc:-O3 -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
422280297Sjkim"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",
423290207Sjkim"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):::",
424290207Sjkim"linux-ia64",	"gcc:-DL_ENDIAN -DTERMIO -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)",
425290207Sjkim"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)",
426280297Sjkim"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",
427290207Sjkim"linux-x86_64-clang",	"clang: -m64 -DL_ENDIAN -O3 -Wall -Wextra $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",
428291719Sjkim"debug-linux-x86_64-clang",	"clang: -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DCRYPTO_MDEBUG -m64 -DL_ENDIAN -g -Wall -Wextra $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",
429290207Sjkim"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",
430290207Sjkim"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",
431280297Sjkim"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",
432238405Sjkim#### So called "highgprs" target for z/Architecture CPUs
433238405Sjkim# "Highgprs" is kernel feature first implemented in Linux 2.6.32, see
434238405Sjkim# /proc/cpuinfo. The idea is to preserve most significant bits of
435238405Sjkim# general purpose registers not only upon 32-bit process context
436238405Sjkim# switch, but even on asynchronous signal delivery to such process.
437238405Sjkim# This makes it possible to deploy 64-bit instructions even in legacy
438238405Sjkim# application context and achieve better [or should we say adequate]
439238405Sjkim# performance. The build is binary compatible with linux-generic32,
440238405Sjkim# and the idea is to be able to install the resulting libcrypto.so
441238405Sjkim# alongside generic one, e.g. as /lib/highgprs/libcrypto.so.x.y, for
442238405Sjkim# ldconfig and run-time linker to autodiscover. Unfortunately it
443238405Sjkim# doesn't work just yet, because of couple of bugs in glibc
444238405Sjkim# sysdeps/s390/dl-procinfo.c affecting ldconfig and ld.so.1...
445280297Sjkim"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",
446160814Ssimon#### SPARC Linux setups
447160814Ssimon# Ray Miller <ray.miller@computing-services.oxford.ac.uk> has patiently
448160814Ssimon# assisted with debugging of following two configs.
449284283Sjkim"linux-sparcv8","gcc:-mcpu=v8 -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)",
450160814Ssimon# it's a real mess with -mcpu=ultrasparc option under Linux, but
451160814Ssimon# -Wa,-Av8plus should do the trick no matter what.
452280297Sjkim"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)",
453160814Ssimon# GCC 3.1 is a requirement
454280297Sjkim"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",
45559191Skris#### Alpha Linux with GNU C and Compaq C setups
45659191Skris# Special notes:
45759191Skris# - linux-alpha+bwx-gcc is ment to be used from ./config only. If you
45859191Skris#   ought to run './Configure linux-alpha+bwx-gcc' manually, do
45959191Skris#   complement the command line with -mcpu=ev56, -mcpu=ev6 or whatever
46059191Skris#   which is appropriate.
46159191Skris# - If you use ccc keep in mind that -fast implies -arch host and the
46259191Skris#   compiler is free to issue instructions which gonna make elder CPU
46359191Skris#   choke. If you wish to build "blended" toolkit, add -arch generic
46459191Skris#   *after* -fast and invoke './Configure linux-alpha-ccc' manually.
46559191Skris#
46659191Skris#					<appro@fy.chalmers.se>
46759191Skris#
468280297Sjkim"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)",
469280297Sjkim"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)",
470280297Sjkim"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}",
471280297Sjkim"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}",
47259191Skris
473280297Sjkim# Android: linux-* but without pointers to headers and libs.
474237657Sjkim"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}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
475238405Sjkim"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)",
476238405Sjkim"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)",
477290207Sjkim"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)",
478348343Sjkim"android64-aarch64","gcc:-mandroid -fPIC -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -Wall::-D_REENTRANT::-pie%-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${aarch64_asm}:linux64:dlfcn:linux-shared:::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
479237657Sjkim
480160814Ssimon#### *BSD [do see comment about ${BSDthreads} above!]
481280297Sjkim"BSD-generic32","gcc:-O3 -fomit-frame-pointer -Wall::${BSDthreads}:::BN_LLONG RC2_CHAR RC4_INDEX DES_INT DES_UNROLL:${no_asm}:dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
482280297Sjkim"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)",
483280297Sjkim"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)",
484280297Sjkim"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)",
485284283Sjkim"BSD-sparcv8",	"gcc:-DB_ENDIAN -O3 -mcpu=v8 -Wall::${BSDthreads}:::BN_LLONG RC2_CHAR RC4_INDEX DES_INT DES_UNROLL:${sparcv8_asm}:dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
48655714Skris
487280297Sjkim"BSD-generic64","gcc:-O3 -Wall::${BSDthreads}:::SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${no_asm}:dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
488160814Ssimon# -DMD32_REG_T=int doesn't actually belong in sparc64 target, it
489160814Ssimon# simply *happens* to work around a compiler bug in gcc 3.3.3,
490160814Ssimon# triggered by RIPEMD160 code.
491280297Sjkim"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)",
492280297Sjkim"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)",
493290207Sjkim"BSD-x86_64",	"cc:-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)",
494160814Ssimon
495160814Ssimon"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)",
496160814Ssimon
497109998Smarkm"nextstep",	"cc:-O -Wall:<libc.h>:(unknown):::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:::",
498109998Smarkm"nextstep3.3",	"cc:-O3 -Wall:<libc.h>:(unknown):::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:::",
499109998Smarkm
50055714Skris# NCR MP-RAS UNIX ver 02.03.01
501111147Snectar"ncr-scde","cc:-O6 -Xa -Hoff=BEHAVED -686 -Hwide -Hiw::(unknown)::-lsocket -lnsl -lc89:${x86_gcc_des} ${x86_gcc_opts}:::",
50255714Skris
503160814Ssimon# QNX
504109998Smarkm"qnx4",	"cc:-DL_ENDIAN -DTERMIO::(unknown):::${x86_gcc_des} ${x86_gcc_opts}:",
505280297Sjkim"QNX6",       "gcc:::::-lsocket::${no_asm}:dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
506280297Sjkim"QNX6-i386",  "gcc:-DL_ENDIAN -O2 -Wall::::-lsocket:${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
50789837Skris
508238405Sjkim# BeOS
509238405Sjkim"beos-x86-r5",   "gcc:-DL_ENDIAN -DTERMIOS -O3 -fomit-frame-pointer -mcpu=pentium -Wall::-D_REENTRANT:BEOS:-lbe -lnet:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:beos:beos-shared:-fPIC -DPIC:-shared:.so",
510238405Sjkim"beos-x86-bone", "gcc:-DL_ENDIAN -DTERMIOS -O3 -fomit-frame-pointer -mcpu=pentium -Wall::-D_REENTRANT:BEOS:-lbe -lbind -lsocket:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:beos:beos-shared:-fPIC:-shared:.so",
511238405Sjkim
512160814Ssimon#### SCO/Caldera targets.
513111147Snectar#
514111147Snectar# Originally we had like unixware-*, unixware-*-pentium, unixware-*-p6, etc.
515111147Snectar# Now we only have blended unixware-* as it's the only one used by ./config.
516111147Snectar# If you want to optimize for particular microarchitecture, bypass ./config
517111147Snectar# and './Configure unixware-7 -Kpentium_pro' or whatever appropriate.
518111147Snectar# Note that not all targets include assembler support. Mostly because of
519111147Snectar# lack of motivation to support out-of-date platforms with out-of-date
520111147Snectar# compiler drivers and assemblers. Tim Rice <tim@multitalents.net> has
521111147Snectar# patiently assisted to debug most of it.
522111147Snectar#
523160814Ssimon# UnixWare 2.0x fails destest with -O.
524109998Smarkm"unixware-2.0","cc:-DFILIO_H -DNO_STRINGS_H::-Kthread::-lsocket -lnsl -lresolv -lx:${x86_gcc_des} ${x86_gcc_opts}:::",
525109998Smarkm"unixware-2.1","cc:-O -DFILIO_H::-Kthread::-lsocket -lnsl -lresolv -lx:${x86_gcc_des} ${x86_gcc_opts}:::",
526290207Sjkim"unixware-7","cc:-O -DFILIO_H -Kalloca::-Kthread::-lsocket -lnsl:BN_LLONG MD2_CHAR RC4_INDEX ${x86_gcc_des}:${x86_elf_asm}-1:dlfcn:svr5-shared:-Kpic::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
527290207Sjkim"unixware-7-gcc","gcc:-DL_ENDIAN -DFILIO_H -O3 -fomit-frame-pointer -march=pentium -Wall::-D_REENTRANT::-lsocket -lnsl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}-1:dlfcn:gnu-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
528111147Snectar# SCO 5 - Ben Laurie <ben@algroup.co.uk> says the -O breaks the SCO cc.
529290207Sjkim"sco5-cc",  "cc:-belf::(unknown)::-lsocket -lnsl:${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}-1:dlfcn:svr3-shared:-Kpic::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
530290207Sjkim"sco5-gcc",  "gcc:-O3 -fomit-frame-pointer::(unknown)::-lsocket -lnsl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}-1:dlfcn:svr3-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
53176866Skris
532160814Ssimon#### IBM's AIX.
533160814Ssimon"aix3-cc",  "cc:-O -DB_ENDIAN -qmaxmem=16384::(unknown):AIX::BN_LLONG RC4_CHAR:::",
534238405Sjkim"aix-gcc",  "gcc:-O -DB_ENDIAN::-pthread:AIX::BN_LLONG RC4_CHAR:${ppc32_asm}:aix32:dlfcn:aix-shared::-shared -Wl,-G:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)::-X32",
535238405Sjkim"aix64-gcc","gcc:-maix64 -O -DB_ENDIAN::-pthread:AIX::SIXTY_FOUR_BIT_LONG RC4_CHAR:${ppc64_asm}:aix64:dlfcn:aix-shared::-maix64 -shared -Wl,-G:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)::-X64",
536160814Ssimon# Below targets assume AIX 5. Idea is to effectively disregard $OBJECT_MODE
537160814Ssimon# at build time. $OBJECT_MODE is respected at ./config stage!
538246772Sjkim"aix-cc",   "cc:-q32 -O -DB_ENDIAN -qmaxmem=16384 -qro -qroconst::-qthreaded -D_THREAD_SAFE:AIX::BN_LLONG RC4_CHAR:${ppc32_asm}:aix32:dlfcn:aix-shared::-q32 -G:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)::-X 32",
539246772Sjkim"aix64-cc", "cc:-q64 -O -DB_ENDIAN -qmaxmem=16384 -qro -qroconst::-qthreaded -D_THREAD_SAFE:AIX::SIXTY_FOUR_BIT_LONG RC4_CHAR:${ppc64_asm}:aix64:dlfcn:aix-shared::-q64 -G:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)::-X 64",
54059191Skris
54155714Skris#
542100928Snectar# Cray T90 and similar (SDSC)
54355714Skris# It's Big-endian, but the algorithms work properly when B_ENDIAN is NOT
54455714Skris# defined.  The T90 ints and longs are 8 bytes long, and apparently the
54555714Skris# B_ENDIAN code assumes 4 byte ints.  Fortunately, the non-B_ENDIAN and
54655714Skris# non L_ENDIAN code aligns the bytes in each word correctly.
54755714Skris#
54855714Skris# The BIT_FIELD_LIMITS define is to avoid two fatal compiler errors:
54955714Skris#'Taking the address of a bit field is not allowed. '
55055714Skris#'An expression with bit field exists as the operand of "sizeof" '
55155714Skris# (written by Wayne Schroeder <schroede@SDSC.EDU>)
552100928Snectar#
553100928Snectar# j90 is considered the base machine type for unicos machines,
554100928Snectar# so this configuration is now called "cray-j90" ...
555109998Smarkm"cray-j90", "cc: -DBIT_FIELD_LIMITS -DTERMIOS::(unknown):CRAY::SIXTY_FOUR_BIT_LONG DES_INT:::",
55655714Skris
55755714Skris#
55855714Skris# Cray T3E (Research Center Juelich, beckman@acl.lanl.gov)
55955714Skris#
56055714Skris# The BIT_FIELD_LIMITS define was written for the C90 (it seems).  I added
56155714Skris# another use.  Basically, the problem is that the T3E uses some bit fields
56255714Skris# for some st_addr stuff, and then sizeof and address-of fails
56355714Skris# I could not use the ams/alpha.o option because the Cray assembler, 'cam'
56455714Skris# did not like it.
565109998Smarkm"cray-t3e", "cc: -DBIT_FIELD_LIMITS -DTERMIOS::(unknown):CRAY::SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT:::",
56655714Skris
56755714Skris# DGUX, 88100.
568109998Smarkm"dgux-R3-gcc",	"gcc:-O3 -fomit-frame-pointer::(unknown):::RC4_INDEX DES_UNROLL:::",
569109998Smarkm"dgux-R4-gcc",	"gcc:-O3 -fomit-frame-pointer::(unknown)::-lnsl -lsocket:RC4_INDEX DES_UNROLL:::",
570109998Smarkm"dgux-R4-x86-gcc",	"gcc:-O3 -fomit-frame-pointer -DL_ENDIAN::(unknown)::-lnsl -lsocket:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}",
57155714Skris
57255714Skris# Sinix/ReliantUNIX RM400
57355714Skris# NOTE: The CDS++ Compiler up to V2.0Bsomething has the IRIX_CC_BUG optimizer problem. Better use -g  */
574160814Ssimon"ReliantUNIX","cc:-KPIC -g -DTERMIOS -DB_ENDIAN::-Kthread:SNI:-lsocket -lnsl -lc -L/usr/ucblib -lucb:BN_LLONG DES_PTR DES_RISC2 DES_UNROLL BF_PTR:${no_asm}:dlfcn:reliantunix-shared:::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
575109998Smarkm"SINIX","cc:-O::(unknown):SNI:-lsocket -lnsl -lc -L/usr/ucblib -lucb:RC4_INDEX RC4_CHAR:::",
576109998Smarkm"SINIX-N","/usr/ucb/cc:-O2 -misaligned::(unknown)::-lucb:RC4_INDEX RC4_CHAR:::",
57755714Skris
57855714Skris# SIEMENS BS2000/OSD: an EBCDIC-based mainframe
579280297Sjkim"BS2000-OSD","c89:-O -XLLML -XLLMK -XL -DB_ENDIAN -DCHARSET_EBCDIC::(unknown)::-lsocket -lnsl:THIRTY_TWO_BIT DES_PTR DES_UNROLL MD2_CHAR RC4_INDEX RC4_CHAR BF_PTR:::",
58055714Skris
58189837Skris# OS/390 Unix an EBCDIC-based Unix system on IBM mainframe
58289837Skris# You need to compile using the c89.sh wrapper in the tools directory, because the
58389837Skris# IBM compiler does not like the -L switch after any object modules.
58489837Skris#
585109998Smarkm"OS390-Unix","c89.sh:-O -DB_ENDIAN -DCHARSET_EBCDIC -DNO_SYS_PARAM_H  -D_ALL_SOURCE::(unknown):::THIRTY_TWO_BIT DES_PTR DES_UNROLL MD2_CHAR RC4_INDEX RC4_CHAR BF_PTR:::",
58689837Skris
587238405Sjkim# Visual C targets
588238405Sjkim#
589160814Ssimon# Win64 targets, WIN64I denotes IA-64 and WIN64A - AMD64
590290207Sjkim"VC-WIN64I","cl:-W3 -Gs0 -Gy -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DUNICODE -D_UNICODE -D_CRT_SECURE_NO_DEPRECATE:::WIN64I::SIXTY_FOUR_BIT RC4_CHUNK_LL DES_INT EXPORT_VAR_AS_FN:ia64cpuid.o:ia64.o ia64-mont.o:::aes_core.o aes_cbc.o aes-ia64.o::md5-ia64.o:sha1-ia64.o sha256-ia64.o sha512-ia64.o:::::::ghash-ia64.o::ias:win32",
591238405Sjkim"VC-WIN64A","cl:-W3 -Gs0 -Gy -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DUNICODE -D_UNICODE -D_CRT_SECURE_NO_DEPRECATE:::WIN64A::SIXTY_FOUR_BIT RC4_CHUNK_LL DES_INT EXPORT_VAR_AS_FN:".eval{my $asm=$x86_64_asm;$asm=~s/x86_64-gcc\.o/bn_asm.o/;$asm}.":auto:win32",
592290207Sjkim"debug-VC-WIN64I","cl:-W3 -Gs0 -Gy -Zi -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DUNICODE -D_UNICODE -D_CRT_SECURE_NO_DEPRECATE:::WIN64I::SIXTY_FOUR_BIT RC4_CHUNK_LL DES_INT EXPORT_VAR_AS_FN:ia64cpuid.o:ia64.o:::aes_core.o aes_cbc.o aes-ia64.o::md5-ia64.o:sha1-ia64.o sha256-ia64.o sha512-ia64.o:::::::ghash-ia64.o::ias:win32",
593238405Sjkim"debug-VC-WIN64A","cl:-W3 -Gs0 -Gy -Zi -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DUNICODE -D_UNICODE -D_CRT_SECURE_NO_DEPRECATE:::WIN64A::SIXTY_FOUR_BIT RC4_CHUNK_LL DES_INT EXPORT_VAR_AS_FN:".eval{my $asm=$x86_64_asm;$asm=~s/x86_64-gcc\.o/bn_asm.o/;$asm}.":auto:win32",
594238405Sjkim# x86 Win32 target defaults to ANSI API, if you want UNICODE, complement
595238405Sjkim# 'perl Configure VC-WIN32' with '-DUNICODE -D_UNICODE'
596326663Sjkim"VC-WIN32","cl:-W3 -WX -Gs0 -GF -Gy -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -D_CRT_SECURE_NO_DEPRECATE -D_WINSOCK_DEPRECATED_NO_WARNINGS:::WIN32::BN_LLONG RC4_INDEX EXPORT_VAR_AS_FN ${x86_gcc_opts}:${x86_asm}:win32n:win32",
597238405Sjkim# Unified CE target
598326663Sjkim"debug-VC-WIN32","cl:-W3 -WX -Gs0 -GF -Gy -Zi -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -D_CRT_SECURE_NO_DEPRECATE -D_WINSOCK_DEPRECATED_NO_WARNINGS:::WIN32::BN_LLONG RC4_INDEX EXPORT_VAR_AS_FN ${x86_gcc_opts}:${x86_asm}:win32n:win32",
599160814Ssimon"VC-CE","cl::::WINCE::BN_LLONG RC4_INDEX EXPORT_VAR_AS_FN ${x86_gcc_opts}:${no_asm}:win32",
60055714Skris
60155714Skris# Borland C++ 4.5
602160814Ssimon"BC-32","bcc32::::WIN32::BN_LLONG DES_PTR RC4_INDEX EXPORT_VAR_AS_FN:${no_asm}:win32",
60355714Skris
604120631Snectar# MinGW
605238405Sjkim"mingw", "gcc:-mno-cygwin -DL_ENDIAN -DWIN32_LEAN_AND_MEAN -fomit-frame-pointer -O3 -march=i486 -Wall::-D_MT:MINGW32:-lws2_32 -lgdi32 -lcrypt32:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts} EXPORT_VAR_AS_FN:${x86_asm}:coff:win32:cygwin-shared:-D_WINDLL -DOPENSSL_USE_APPLINK:-mno-cygwin:.dll.a",
606238405Sjkim# As for OPENSSL_USE_APPLINK. Applink makes it possible to use .dll
607238405Sjkim# compiled with one compiler with application compiled with another
608238405Sjkim# compiler. It's possible to engage Applink support in mingw64 build,
609238405Sjkim# but it's not done, because till mingw64 supports structured exception
610238405Sjkim# handling, one can't seriously consider its binaries for using with
611238405Sjkim# non-mingw64 run-time environment. And as mingw64 is always consistent
612238405Sjkim# with itself, Applink is never engaged and can as well be omitted.
613238405Sjkim"mingw64", "gcc:-mno-cygwin -DL_ENDIAN -O3 -Wall -DWIN32_LEAN_AND_MEAN -DUNICODE -D_UNICODE::-D_MT:MINGW64:-lws2_32 -lgdi32 -lcrypt32:SIXTY_FOUR_BIT RC4_CHUNK_LL DES_INT EXPORT_VAR_AS_FN:${x86_64_asm}:mingw64:win32:cygwin-shared:-D_WINDLL:-mno-cygwin:.dll.a",
61455714Skris
615100936Snectar# UWIN 
616160814Ssimon"UWIN", "cc:-DTERMIOS -DL_ENDIAN -O -Wall:::UWIN::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${no_asm}:win32",
617100936Snectar
618100928Snectar# Cygwin
619290207Sjkim"Cygwin", "gcc:-DTERMIOS -DL_ENDIAN -fomit-frame-pointer -O3 -march=i486 -Wall:::CYGWIN::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_asm}:coff:dlfcn:cygwin-shared:-D_WINDLL:-shared:.dll.a",
620290207Sjkim"Cygwin-x86_64", "gcc:-DTERMIOS -DL_ENDIAN -O3 -Wall:::CYGWIN::SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:mingw64:dlfcn:cygwin-shared:-D_WINDLL:-shared:.dll.a",
62168651Skris
622194206Ssimon# NetWare from David Ward (dsward@novell.com)
623194206Ssimon# requires either MetroWerks NLM development tools, or gcc / nlmconv
624194206Ssimon# NetWare defaults socket bio to WinSock sockets. However,
625194206Ssimon# the builds can be configured to use BSD sockets instead.
626160814Ssimon# netware-clib => legacy CLib c-runtime support
627194206Ssimon"netware-clib", "mwccnlm::::::${x86_gcc_opts}::",
628194206Ssimon"netware-clib-bsdsock", "mwccnlm::::::${x86_gcc_opts}::",
629194206Ssimon"netware-clib-gcc", "i586-netware-gcc:-nostdinc -I/ndk/nwsdk/include/nlm -I/ndk/ws295sdk/include -DL_ENDIAN -DNETWARE_CLIB -DOPENSSL_SYSNAME_NETWARE -O2 -Wall:::::${x86_gcc_opts}::",
630194206Ssimon"netware-clib-bsdsock-gcc", "i586-netware-gcc:-nostdinc -I/ndk/nwsdk/include/nlm -DNETWARE_BSDSOCK -DNETDB_USE_INTERNET -DL_ENDIAN -DNETWARE_CLIB -DOPENSSL_SYSNAME_NETWARE -O2 -Wall:::::${x86_gcc_opts}::",
631160814Ssimon# netware-libc => LibC/NKS support
632160814Ssimon"netware-libc", "mwccnlm::::::BN_LLONG ${x86_gcc_opts}::",
633160814Ssimon"netware-libc-bsdsock", "mwccnlm::::::BN_LLONG ${x86_gcc_opts}::",
634160814Ssimon"netware-libc-gcc", "i586-netware-gcc:-nostdinc -I/ndk/libc/include -I/ndk/libc/include/winsock -DL_ENDIAN -DNETWARE_LIBC -DOPENSSL_SYSNAME_NETWARE -DTERMIO -O2 -Wall:::::BN_LLONG ${x86_gcc_opts}::",
635194206Ssimon"netware-libc-bsdsock-gcc", "i586-netware-gcc:-nostdinc -I/ndk/libc/include -DNETWARE_BSDSOCK -DL_ENDIAN -DNETWARE_LIBC -DOPENSSL_SYSNAME_NETWARE -DTERMIO -O2 -Wall:::::BN_LLONG ${x86_gcc_opts}::",
636160814Ssimon
637109998Smarkm# DJGPP
638280297Sjkim"DJGPP", "gcc:-I/dev/env/WATT_ROOT/inc -DTERMIO -DL_ENDIAN -fomit-frame-pointer -O2 -Wall:::MSDOS:-L/dev/env/WATT_ROOT/lib -lwatt:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_asm}:a.out:",
639109998Smarkm
64055714Skris# Ultrix from Bernhard Simon <simon@zid.tuwien.ac.at>
641109998Smarkm"ultrix-cc","cc:-std1 -O -Olimit 2500 -DL_ENDIAN::(unknown):::::::",
642160814Ssimon"ultrix-gcc","gcc:-O3 -DL_ENDIAN::(unknown):::BN_LLONG::::",
64355714Skris# K&R C is no longer supported; you need gcc on old Ultrix installations
644109998Smarkm##"ultrix","cc:-O2 -DNOPROTO -DNOCONST -DL_ENDIAN::(unknown):::::::",
64555714Skris
64689837Skris##### MacOS X (a.k.a. Rhapsody or Darwin) setup
647160814Ssimon"rhapsody-ppc-cc","cc:-O3 -DB_ENDIAN::(unknown):MACOSX_RHAPSODY::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${no_asm}::",
648238405Sjkim"darwin-ppc-cc","cc:-arch ppc -O3 -DB_ENDIAN -Wa,-force_cpusubtype_ALL::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${ppc32_asm}:osx32:dlfcn:darwin-shared:-fPIC -fno-common:-arch ppc -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
649238405Sjkim"darwin64-ppc-cc","cc:-arch ppc64 -O3 -DB_ENDIAN::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${ppc64_asm}:osx64:dlfcn:darwin-shared:-fPIC -fno-common:-arch ppc64 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
650238405Sjkim"darwin-i386-cc","cc:-arch i386 -O3 -fomit-frame-pointer -DL_ENDIAN::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:BN_LLONG RC4_INT RC4_CHUNK DES_UNROLL BF_PTR:".eval{my $asm=$x86_asm;$asm=~s/cast\-586\.o//;$asm}.":macosx:dlfcn:darwin-shared:-fPIC -fno-common:-arch i386 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
651238405Sjkim"debug-darwin-i386-cc","cc:-arch i386 -g3 -DL_ENDIAN::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:BN_LLONG RC4_INT RC4_CHUNK DES_UNROLL BF_PTR:${x86_asm}:macosx:dlfcn:darwin-shared:-fPIC -fno-common:-arch i386 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
652290207Sjkim"darwin64-x86_64-cc","cc:-arch x86_64 -O3 -DL_ENDIAN -Wall::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:".eval{my $asm=$x86_64_asm;$asm=~s/rc4\-[^:]+//;$asm}.":macosx:dlfcn:darwin-shared:-fPIC -fno-common:-arch x86_64 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
653290207Sjkim"debug-darwin64-x86_64-cc","cc:-arch x86_64 -ggdb -g2 -O0 -DL_ENDIAN -Wall::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:".eval{my $asm=$x86_64_asm;$asm=~s/rc4\-[^:]+//;$asm}.":macosx:dlfcn:darwin-shared:-fPIC -fno-common:-arch x86_64 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
654238405Sjkim"debug-darwin-ppc-cc","cc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DCRYPTO_MDEBUG -DB_ENDIAN -g -Wall -O::-D_REENTRANT:MACOSX::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${ppc32_asm}:osx32:dlfcn:darwin-shared:-fPIC:-dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
655238405Sjkim# iPhoneOS/iOS
656238405Sjkim"iphoneos-cross","llvm-gcc:-O3 -isysroot \$(CROSS_TOP)/SDKs/\$(CROSS_SDK) -fomit-frame-pointer -fno-common::-D_REENTRANT:iOS:-Wl,-search_paths_first%:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${no_asm}:dlfcn:darwin-shared:-fPIC -fno-common:-dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
65759191Skris
658109998Smarkm##### A/UX
659109998Smarkm"aux3-gcc","gcc:-O2 -DTERMIO::(unknown):AUX:-lbsd:RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:::",
660109998Smarkm
66168651Skris##### Sony NEWS-OS 4.x
662109998Smarkm"newsos4-gcc","gcc:-O -DB_ENDIAN::(unknown):NEWS4:-lmld -liberty:BN_LLONG RC4_CHAR RC4_CHUNK DES_PTR DES_RISC1 DES_UNROLL BF_PTR::::",
66368651Skris
664109998Smarkm##### GNU Hurd
665280297Sjkim"hurd-x86",  "gcc:-DL_ENDIAN -O3 -fomit-frame-pointer -march=i486 -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared:-fPIC",
666109998Smarkm
667109998Smarkm##### OS/2 EMX
668109998Smarkm"OS2-EMX", "gcc::::::::",
669109998Smarkm
670100928Snectar##### VxWorks for various targets
671238405Sjkim"vxworks-ppc60x","ccppc:-D_REENTRANT -mrtp -mhard-float -mstrict-align -fno-implicit-fp -DPPC32_fp60x -O2 -fstrength-reduce -fno-builtin -fno-strict-aliasing -Wall -DCPU=PPC32 -DTOOL_FAMILY=gnu -DTOOL=gnu -I\$(WIND_BASE)/target/usr/h -I\$(WIND_BASE)/target/usr/h/wrn/coreip:::VXWORKS:-Wl,--defsym,__wrs_rtp_base=0xe0000000 -L \$(WIND_BASE)/target/usr/lib/ppc/PPC32/common:::::",
672238405Sjkim"vxworks-ppcgen","ccppc:-D_REENTRANT -mrtp -msoft-float -mstrict-align -O1 -fno-builtin -fno-strict-aliasing -Wall -DCPU=PPC32 -DTOOL_FAMILY=gnu -DTOOL=gnu -I\$(WIND_BASE)/target/usr/h -I\$(WIND_BASE)/target/usr/h/wrn/coreip:::VXWORKS:-Wl,--defsym,__wrs_rtp_base=0xe0000000 -L \$(WIND_BASE)/target/usr/lib/ppc/PPC32/sfcommon:::::",
673109998Smarkm"vxworks-ppc405","ccppc:-g -msoft-float -mlongcall -DCPU=PPC405 -I\$(WIND_BASE)/target/h:::VXWORKS:-r:::::",
674109998Smarkm"vxworks-ppc750","ccppc:-ansi -nostdinc -DPPC750 -D_REENTRANT -fvolatile -fno-builtin -fno-for-scope -fsigned-char -Wall -msoft-float -mlongcall -DCPU=PPC604 -I\$(WIND_BASE)/target/h \$(DEBUG_FLAG):::VXWORKS:-r:::::",
675238405Sjkim"vxworks-ppc750-debug","ccppc:-ansi -nostdinc -DPPC750 -D_REENTRANT -fvolatile -fno-builtin -fno-for-scope -fsigned-char -Wall -msoft-float -mlongcall -DCPU=PPC604 -I\$(WIND_BASE)/target/h -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DPEDANTIC -DDEBUG_SAFESTACK -DDEBUG -g:::VXWORKS:-r:::::",
676120631Snectar"vxworks-ppc860","ccppc:-nostdinc -msoft-float -DCPU=PPC860 -DNO_STRINGS_H -I\$(WIND_BASE)/target/h:::VXWORKS:-r:::::",
677238405Sjkim"vxworks-simlinux","ccpentium:-B\$(WIND_BASE)/host/\$(WIND_HOST_TYPE)/lib/gcc-lib/ -D_VSB_CONFIG_FILE=\"\$(WIND_BASE)/target/lib/h/config/vsbConfig.h\" -DL_ENDIAN -DCPU=SIMLINUX -DTOOL_FAMILY=gnu -DTOOL=gnu -fno-builtin -fno-defer-pop -DNO_STRINGS_H -I\$(WIND_BASE)/target/h -I\$(WIND_BASE)/target/h/wrn/coreip -DOPENSSL_NO_HW_PADLOCK:::VXWORKS:-r::${no_asm}::::::ranlibpentium:",
678238405Sjkim"vxworks-mips","ccmips:-mrtp -mips2 -O -G 0 -B\$(WIND_BASE)/host/\$(WIND_HOST_TYPE)/lib/gcc-lib/ -D_VSB_CONFIG_FILE=\"\$(WIND_BASE)/target/lib/h/config/vsbConfig.h\" -DCPU=MIPS32 -msoft-float -mno-branch-likely -DTOOL_FAMILY=gnu -DTOOL=gnu -fno-builtin -fno-defer-pop -DNO_STRINGS_H -I\$(WIND_BASE)/target/usr/h -I\$(WIND_BASE)/target/h/wrn/coreip::-D_REENTRANT:VXWORKS:-Wl,--defsym,__wrs_rtp_base=0xe0000000 -L \$(WIND_BASE)/target/usr/lib/mips/MIPSI32/sfcommon::${mips32_asm}:o32::::::ranlibmips:",
679100928Snectar
680109998Smarkm##### Compaq Non-Stop Kernel (Tandem)
681109998Smarkm"tandem-c89","c89:-Ww -D__TANDEM -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED=1 -D_TANDEM_SOURCE -DB_ENDIAN::(unknown):::THIRTY_TWO_BIT:::",
682109998Smarkm
683238405Sjkim# uClinux
684238405Sjkim"uClinux-dist","$ENV{'CC'}:\$(CFLAGS)::-D_REENTRANT::\$(LDFLAGS) \$(LDLIBS):BN_LLONG:${no_asm}:$ENV{'LIBSSL_dlfcn'}:linux-shared:-fPIC:-shared:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):$ENV{'RANLIB'}::",
685238405Sjkim"uClinux-dist64","$ENV{'CC'}:\$(CFLAGS)::-D_REENTRANT::\$(LDFLAGS) \$(LDLIBS):SIXTY_FOUR_BIT_LONG:${no_asm}:$ENV{'LIBSSL_dlfcn'}:linux-shared:-fPIC:-shared:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):$ENV{'RANLIB'}::",
686238405Sjkim
68755714Skris);
68855714Skris
689160814Ssimonmy @MK1MF_Builds=qw(VC-WIN64I VC-WIN64A
690238405Sjkim		    debug-VC-WIN64I debug-VC-WIN64A
691238405Sjkim		    VC-NT VC-CE VC-WIN32 debug-VC-WIN32
692238405Sjkim		    BC-32 
693194206Ssimon		    netware-clib netware-clib-bsdsock
694194206Ssimon		    netware-libc netware-libc-bsdsock);
69555714Skris
696100928Snectarmy $idx = 0;
697100928Snectarmy $idx_cc = $idx++;
698100928Snectarmy $idx_cflags = $idx++;
699100928Snectarmy $idx_unistd = $idx++;
700100928Snectarmy $idx_thread_cflag = $idx++;
701109998Smarkmmy $idx_sys_id = $idx++;
702100928Snectarmy $idx_lflags = $idx++;
703100928Snectarmy $idx_bn_ops = $idx++;
704160814Ssimonmy $idx_cpuid_obj = $idx++;
705100928Snectarmy $idx_bn_obj = $idx++;
706290207Sjkimmy $idx_ec_obj = $idx++;
707100928Snectarmy $idx_des_obj = $idx++;
708160814Ssimonmy $idx_aes_obj = $idx++;
709100928Snectarmy $idx_bf_obj = $idx++;
710100928Snectarmy $idx_md5_obj = $idx++;
711100928Snectarmy $idx_sha1_obj = $idx++;
712100928Snectarmy $idx_cast_obj = $idx++;
713100928Snectarmy $idx_rc4_obj = $idx++;
714100928Snectarmy $idx_rmd160_obj = $idx++;
715100928Snectarmy $idx_rc5_obj = $idx++;
716238405Sjkimmy $idx_wp_obj = $idx++;
717238405Sjkimmy $idx_cmll_obj = $idx++;
718238405Sjkimmy $idx_modes_obj = $idx++;
719238405Sjkimmy $idx_engines_obj = $idx++;
720238405Sjkimmy $idx_perlasm_scheme = $idx++;
721100928Snectarmy $idx_dso_scheme = $idx++;
722100928Snectarmy $idx_shared_target = $idx++;
723100928Snectarmy $idx_shared_cflag = $idx++;
724100928Snectarmy $idx_shared_ldflag = $idx++;
725100928Snectarmy $idx_shared_extension = $idx++;
726100928Snectarmy $idx_ranlib = $idx++;
727109998Smarkmmy $idx_arflags = $idx++;
728238405Sjkimmy $idx_multilib = $idx++;
729100928Snectar
73055714Skrismy $prefix="";
731205128Ssimonmy $libdir="";
73255714Skrismy $openssldir="";
73376866Skrismy $exe_ext="";
734205128Ssimonmy $install_prefix= "$ENV{'INSTALL_PREFIX'}";
735205128Ssimonmy $cross_compile_prefix="";
736238405Sjkimmy $fipsdir="/usr/local/ssl/fips-2.0";
737238405Sjkimmy $fipslibdir="";
738194206Ssimonmy $baseaddr="0xFB00000";
73955714Skrismy $no_threads=0;
74055714Skrismy $threads=0;
741160814Ssimonmy $no_shared=0; # but "no-shared" is default
742160814Ssimonmy $zlib=1;      # but "no-zlib" is default
743160814Ssimonmy $no_krb5=0;   # but "no-krb5" is implied unless "--with-krb5-..." is used
744167612Ssimonmy $no_rfc3779=1; # but "no-rfc3779" is default
74555714Skrismy $no_asm=0;
74668651Skrismy $no_dso=0;
747160814Ssimonmy $no_gmp=0;
74855714Skrismy @skip=();
749142425Snectarmy $Makefile="Makefile";
75055714Skrismy $des_locl="crypto/des/des_locl.h";
75155714Skrismy $des	="crypto/des/des.h";
75255714Skrismy $bn	="crypto/bn/bn.h";
75355714Skrismy $md2	="crypto/md2/md2.h";
75455714Skrismy $rc4	="crypto/rc4/rc4.h";
75555714Skrismy $rc4_locl="crypto/rc4/rc4_locl.h";
75655714Skrismy $idea	="crypto/idea/idea.h";
75755714Skrismy $rc2	="crypto/rc2/rc2.h";
75855714Skrismy $bf	="crypto/bf/bf_locl.h";
75955714Skrismy $bn_asm	="bn_asm.o";
76055714Skrismy $des_enc="des_enc.o fcrypt_b.o";
761160814Ssimonmy $aes_enc="aes_core.o aes_cbc.o";
76255714Skrismy $bf_enc	="bf_enc.o";
76355714Skrismy $cast_enc="c_enc.o";
764194206Ssimonmy $rc4_enc="rc4_enc.o rc4_skey.o";
76555714Skrismy $rc5_enc="rc5_enc.o";
76655714Skrismy $md5_obj="";
76755714Skrismy $sha1_obj="";
76855714Skrismy $rmd160_obj="";
769238405Sjkimmy $cmll_enc="camellia.o cmll_misc.o cmll_cbc.o";
77055714Skrismy $processor="";
77176866Skrismy $default_ranlib;
77255714Skrismy $perl;
773194206Ssimonmy $fips=0;
77455714Skris
775238405Sjkimif (exists $ENV{FIPSDIR})
776238405Sjkim	{
777238405Sjkim	$fipsdir = $ENV{FIPSDIR};
778238405Sjkim	$fipsdir =~ s/\/$//;
779238405Sjkim	}
780109998Smarkm
781160814Ssimon# All of the following is disabled by default (RC5 was enabled before 0.9.8):
782160814Ssimon
783194206Ssimonmy %disabled = ( # "what"         => "comment" [or special keyword "experimental"]
784238405Sjkim		 "ec_nistp_64_gcc_128" => "default",
785238405Sjkim		 "gmp"		  => "default",
786238405Sjkim		 "jpake"          => "experimental",
787290207Sjkim		 "libunbound"     => "experimental",
788238405Sjkim		 "md2"            => "default",
789238405Sjkim		 "rc5"            => "default",
790238405Sjkim		 "rfc3779"	  => "default",
791296279Sjkim		 "sctp"           => "default",
792238405Sjkim		 "shared"         => "default",
793290207Sjkim		 "ssl-trace"	  => "default",
794296279Sjkim		 "ssl2"           => "default",
795238405Sjkim		 "store"	  => "experimental",
796269682Sjkim		 "unit-test"	  => "default",
797296279Sjkim		 "weak-ssl-ciphers" => "default",
798238405Sjkim		 "zlib"           => "default",
799238405Sjkim		 "zlib-dynamic"   => "default"
800238405Sjkim	       );
801194206Ssimonmy @experimental = ();
802160814Ssimon
803194206Ssimon# This is what $depflags will look like with the above defaults
804194206Ssimon# (we need this to see if we should advise the user to run "make depend"):
805306195Sjkimmy $default_depflags = " -DOPENSSL_NO_EC_NISTP_64_GCC_128 -DOPENSSL_NO_GMP -DOPENSSL_NO_JPAKE -DOPENSSL_NO_LIBUNBOUND -DOPENSSL_NO_MD2 -DOPENSSL_NO_RC5 -DOPENSSL_NO_RFC3779 -DOPENSSL_NO_SCTP -DOPENSSL_NO_SSL_TRACE -DOPENSSL_NO_SSL2 -DOPENSSL_NO_STORE -DOPENSSL_NO_UNIT_TEST -DOPENSSL_NO_WEAK_SSL_CIPHERS";
806160814Ssimon
807194206Ssimon# Explicit "no-..." options will be collected in %disabled along with the defaults.
808194206Ssimon# To remove something from %disabled, use "enable-foo" (unless it's experimental).
809194206Ssimon# For symmetry, "disable-foo" is a synonym for "no-foo".
810160814Ssimon
811194206Ssimon# For features called "experimental" here, a more explicit "experimental-foo" is needed to enable.
812194206Ssimon# We will collect such requests in @experimental.
813194206Ssimon# To avoid accidental use of experimental features, applications will have to use -DOPENSSL_EXPERIMENTAL_FOO.
814194206Ssimon
815194206Ssimon
816160814Ssimonmy $no_sse2=0;
817160814Ssimon
81855714Skris&usage if ($#ARGV < 0);
81955714Skris
82068651Skrismy $flags;
82168651Skrismy $depflags;
822194206Ssimonmy $openssl_experimental_defines;
82368651Skrismy $openssl_algorithm_defines;
82468651Skrismy $openssl_thread_defines;
825109998Smarkmmy $openssl_sys_defines="";
82668651Skrismy $openssl_other_defines;
82768651Skrismy $libs;
828111147Snectarmy $libkrb5="";
82968651Skrismy $target;
83068651Skrismy $options;
83168651Skrismy $symlink;
832109998Smarkmmy $make_depend=0;
833109998Smarkmmy %withargs=();
83468651Skris
83568651Skrismy @argvcopy=@ARGV;
83668651Skrismy $argvstring="";
83768651Skrismy $argv_unprocessed=1;
83868651Skris
83968651Skriswhile($argv_unprocessed)
84055714Skris	{
84168651Skris	$flags="";
84268651Skris	$depflags="";
843194206Ssimon	$openssl_experimental_defines="";
84468651Skris	$openssl_algorithm_defines="";
84568651Skris	$openssl_thread_defines="";
846109998Smarkm	$openssl_sys_defines="";
84768651Skris	$openssl_other_defines="";
84868651Skris	$libs="";
84968651Skris	$target="";
85068651Skris	$options="";
85168651Skris	$symlink=1;
85268651Skris
85368651Skris	$argv_unprocessed=0;
85468651Skris	$argvstring=join(' ',@argvcopy);
85568651Skris
85668651SkrisPROCESS_ARGS:
85768651Skris	foreach (@argvcopy)
85855714Skris		{
85968651Skris		s /^-no-/no-/; # some people just can't read the instructions
860160814Ssimon
861160814Ssimon		# rewrite some options in "enable-..." form
862160814Ssimon		s /^-?-?shared$/enable-shared/;
863238405Sjkim		s /^sctp$/enable-sctp/;
864160814Ssimon		s /^threads$/enable-threads/;
865160814Ssimon		s /^zlib$/enable-zlib/;
866160814Ssimon		s /^zlib-dynamic$/enable-zlib-dynamic/;
867160814Ssimon
868160814Ssimon		if (/^no-(.+)$/ || /^disable-(.+)$/)
869100928Snectar			{
870194206Ssimon			if (!($disabled{$1} eq "experimental"))
871109998Smarkm				{
872194206Ssimon				if ($1 eq "ssl")
873194206Ssimon					{
874194206Ssimon					$disabled{"ssl2"} = "option(ssl)";
875194206Ssimon					$disabled{"ssl3"} = "option(ssl)";
876194206Ssimon					}
877194206Ssimon				elsif ($1 eq "tls")
878194206Ssimon					{
879194206Ssimon					$disabled{"tls1"} = "option(tls)"
880194206Ssimon					}
881276861Sjkim				elsif ($1 eq "ssl3-method")
882276861Sjkim					{
883276861Sjkim					$disabled{"ssl3-method"} = "option(ssl)";
884276861Sjkim					$disabled{"ssl3"} = "option(ssl)";
885276861Sjkim					}
886194206Ssimon				else
887194206Ssimon					{
888194206Ssimon					$disabled{$1} = "option";
889194206Ssimon					}
890238405Sjkim				}			
891238405Sjkim			}
892194206Ssimon		elsif (/^enable-(.+)$/ || /^experimental-(.+)$/)
893194206Ssimon			{
894194206Ssimon			my $algo = $1;
895194206Ssimon			if ($disabled{$algo} eq "experimental")
89668651Skris				{
897194206Ssimon				die "You are requesting an experimental feature; please say 'experimental-$algo' if you are sure\n"
898194206Ssimon					unless (/^experimental-/);
899194206Ssimon				push @experimental, $algo;
90068651Skris				}
901194206Ssimon			delete $disabled{$algo};
902160814Ssimon
903194206Ssimon			$threads = 1 if ($algo eq "threads");
90455714Skris			}
905160814Ssimon		elsif (/^--test-sanity$/)
906160814Ssimon			{
907160814Ssimon			exit(&test_sanity());
908160814Ssimon			}
909205128Ssimon		elsif (/^--strict-warnings/)
910205128Ssimon			{
911205128Ssimon			$strict_warnings = 1;
912205128Ssimon			}
91368651Skris		elsif (/^reconfigure/ || /^reconf/)
91455714Skris			{
91568651Skris			if (open(IN,"<$Makefile"))
91668651Skris				{
91768651Skris				while (<IN>)
91868651Skris					{
919160814Ssimon					chomp;
92068651Skris					if (/^CONFIGURE_ARGS=(.*)/)
92168651Skris						{
92268651Skris						$argvstring=$1;
92368651Skris						@argvcopy=split(' ',$argvstring);
92468651Skris						die "Incorrect data to reconfigure, please do a normal configuration\n"
92568651Skris							if (grep(/^reconf/,@argvcopy));
92668651Skris						print "Reconfiguring with: $argvstring\n";
92768651Skris						$argv_unprocessed=1;
92868651Skris						close(IN);
92968651Skris						last PROCESS_ARGS;
93068651Skris						}
93168651Skris					}
93268651Skris				close(IN);
93368651Skris				}
93468651Skris			die "Insufficient data to reconfigure, please do a normal configuration\n";
93555714Skris			}
93668651Skris		elsif (/^386$/)
93768651Skris			{ $processor=386; }
938194206Ssimon		elsif (/^fips$/)
939194206Ssimon			{
940194206Ssimon			$fips=1;
941238405Sjkim			}
94268651Skris		elsif (/^rsaref$/)
94355714Skris			{
944109998Smarkm			# No RSAref support any more since it's not needed.
945109998Smarkm			# The check for the option is there so scripts aren't
946109998Smarkm			# broken
94755714Skris			}
94868651Skris		elsif (/^[-+]/)
94955714Skris			{
950290207Sjkim			if (/^--prefix=(.*)$/)
95168651Skris				{
95268651Skris				$prefix=$1;
95368651Skris				}
954205128Ssimon			elsif (/^--libdir=(.*)$/)
955205128Ssimon				{
956205128Ssimon				$libdir=$1;
957205128Ssimon				}
95868651Skris			elsif (/^--openssldir=(.*)$/)
95968651Skris				{
96068651Skris				$openssldir=$1;
96168651Skris				}
96268651Skris			elsif (/^--install.prefix=(.*)$/)
96368651Skris				{
96468651Skris				$install_prefix=$1;
96568651Skris				}
966109998Smarkm			elsif (/^--with-krb5-(dir|lib|include|flavor)=(.*)$/)
967109998Smarkm				{
968109998Smarkm				$withargs{"krb5-".$1}=$2;
969109998Smarkm				}
970160814Ssimon			elsif (/^--with-zlib-lib=(.*)$/)
971160814Ssimon				{
972160814Ssimon				$withargs{"zlib-lib"}=$1;
973160814Ssimon				}
974160814Ssimon			elsif (/^--with-zlib-include=(.*)$/)
975160814Ssimon				{
976160814Ssimon				$withargs{"zlib-include"}="-I$1";
977160814Ssimon				}
978238405Sjkim			elsif (/^--with-fipsdir=(.*)$/)
979238405Sjkim				{
980238405Sjkim				$fipsdir="$1";
981238405Sjkim				}
982194206Ssimon			elsif (/^--with-fipslibdir=(.*)$/)
983194206Ssimon				{
984238405Sjkim				$fipslibdir="$1";
985194206Ssimon				}
986194206Ssimon			elsif (/^--with-baseaddr=(.*)$/)
987194206Ssimon				{
988194206Ssimon				$baseaddr="$1";
989194206Ssimon				}
990238405Sjkim			elsif (/^--cross-compile-prefix=(.*)$/)
991238405Sjkim				{
992238405Sjkim				$cross_compile_prefix=$1;
993238405Sjkim				}
994290207Sjkim			elsif (/^-[lL](.*)$/ or /^-Wl,/)
99568651Skris				{
996290207Sjkim				$libs.=$_." ";
99768651Skris				}
998290207Sjkim			else	# common if (/^[-+]/), just pass down...
999290207Sjkim				{
1000290207Sjkim				$_ =~ s/%([0-9a-f]{1,2})/chr(hex($1))/gei;
1001290207Sjkim				$flags.=$_." ";
1002290207Sjkim				}
100355714Skris			}
100468651Skris		elsif ($_ =~ /^([^:]+):(.+)$/)
100555714Skris			{
100668651Skris			eval "\$table{\$1} = \"$2\""; # allow $xxx constructs in the string
100768651Skris			$target=$1;
100855714Skris			}
100955714Skris		else
101055714Skris			{
1011160814Ssimon			die "target already defined - $target (offending arg: $_)\n" if ($target ne "");
101268651Skris			$target=$_;
101355714Skris			}
1014160814Ssimon
1015160814Ssimon		unless ($_ eq $target || /^no-/ || /^disable-/)
1016160814Ssimon			{
1017160814Ssimon			# "no-..." follows later after implied disactivations
1018160814Ssimon			# have been derived.  (Don't take this too seroiusly,
1019160814Ssimon			# we really only write OPTIONS to the Makefile out of
1020160814Ssimon			# nostalgia.)
1021160814Ssimon
1022160814Ssimon			if ($options eq "")
1023160814Ssimon				{ $options = $_; }
1024160814Ssimon			else
1025160814Ssimon				{ $options .= " ".$_; }
102668651Skris			}
102755714Skris		}
102855714Skris	}
102955714Skris
1030109998Smarkm
1031109998Smarkm
1032160814Ssimonif ($processor eq "386")
1033160814Ssimon	{
1034160814Ssimon	$disabled{"sse2"} = "forced";
1035160814Ssimon	}
1036109998Smarkm
1037160814Ssimonif (!defined($withargs{"krb5-flavor"}) || $withargs{"krb5-flavor"} eq "")
1038109998Smarkm	{
1039160814Ssimon	$disabled{"krb5"} = "krb5-flavor not specified";
1040109998Smarkm	}
1041109998Smarkm
1042160814Ssimonif (!defined($disabled{"zlib-dynamic"}))
1043109998Smarkm	{
1044160814Ssimon	# "zlib-dynamic" was specifically enabled, so enable "zlib"
1045160814Ssimon	delete $disabled{"zlib"};
1046109998Smarkm	}
1047109998Smarkm
1048160814Ssimonif (defined($disabled{"rijndael"}))
1049109998Smarkm	{
1050160814Ssimon	$disabled{"aes"} = "forced";
1051109998Smarkm	}
1052160814Ssimonif (defined($disabled{"des"}))
1053160814Ssimon	{
1054160814Ssimon	$disabled{"mdc2"} = "forced";
1055160814Ssimon	}
1056160814Ssimonif (defined($disabled{"ec"}))
1057160814Ssimon	{
1058160814Ssimon	$disabled{"ecdsa"} = "forced";
1059160814Ssimon	$disabled{"ecdh"} = "forced";
1060160814Ssimon	}
1061109998Smarkm
1062160814Ssimon# SSL 2.0 requires MD5 and RSA
1063160814Ssimonif (defined($disabled{"md5"}) || defined($disabled{"rsa"}))
1064160814Ssimon	{
1065160814Ssimon	$disabled{"ssl2"} = "forced";
1066160814Ssimon	}
1067160814Ssimon
1068238405Sjkimif ($fips && $fipslibdir eq "")
1069238405Sjkim	{
1070238405Sjkim	$fipslibdir = $fipsdir . "/lib/";
1071238405Sjkim	}
1072238405Sjkim
1073238405Sjkim# RSAX ENGINE sets default non-FIPS RSA method.
1074238405Sjkimif ($fips)
1075238405Sjkim	{
1076238405Sjkim	$disabled{"rsax"} = "forced";
1077238405Sjkim	}
1078238405Sjkim
1079160814Ssimon# SSL 3.0 and TLS requires MD5 and SHA and either RSA or DSA+DH
1080160814Ssimonif (defined($disabled{"md5"}) || defined($disabled{"sha"})
1081160814Ssimon    || (defined($disabled{"rsa"})
1082160814Ssimon        && (defined($disabled{"dsa"}) || defined($disabled{"dh"}))))
1083160814Ssimon	{
1084160814Ssimon	$disabled{"ssl3"} = "forced";
1085160814Ssimon	$disabled{"tls1"} = "forced";
1086160814Ssimon	}
1087160814Ssimon
1088238405Sjkimif (defined($disabled{"ec"}) || defined($disabled{"dsa"})
1089238405Sjkim    || defined($disabled{"dh"}))
1090238405Sjkim	{
1091238405Sjkim	$disabled{"gost"} = "forced";
1092238405Sjkim	}
1093238405Sjkim
1094238405Sjkim# SRP and HEARTBEATS require TLSEXT
1095238405Sjkimif (defined($disabled{"tlsext"}))
1096238405Sjkim	{
1097238405Sjkim	$disabled{"srp"} = "forced";
1098238405Sjkim	$disabled{"heartbeats"} = "forced";
1099238405Sjkim	}
1100238405Sjkim
110155714Skrisif ($target eq "TABLE") {
110255714Skris	foreach $target (sort keys %table) {
110355714Skris		print_table_entry($target);
110455714Skris	}
110555714Skris	exit 0;
110655714Skris}
110755714Skris
110859191Skrisif ($target eq "LIST") {
110959191Skris	foreach (sort keys %table) {
111059191Skris		print;
111159191Skris		print "\n";
111259191Skris	}
111359191Skris	exit 0;
111459191Skris}
111559191Skris
1116100928Snectarif ($target =~ m/^CygWin32(-.*)$/) {
1117100928Snectar	$target = "Cygwin".$1;
1118100928Snectar}
1119100928Snectar
112068651Skrisprint "Configuring for $target\n";
112168651Skris
112255714Skris&usage if (!defined($table{$target}));
112355714Skris
112455714Skris
1125160814Ssimonforeach (sort (keys %disabled))
1126160814Ssimon	{
1127160814Ssimon	$options .= " no-$_";
1128160814Ssimon
1129160814Ssimon	printf "    no-%-12s %-10s", $_, "[$disabled{$_}]";
1130160814Ssimon
1131160814Ssimon	if (/^dso$/)
1132160814Ssimon		{ $no_dso = 1; }
1133160814Ssimon	elsif (/^threads$/)
1134160814Ssimon		{ $no_threads = 1; }
1135160814Ssimon	elsif (/^shared$/)
1136160814Ssimon		{ $no_shared = 1; }
1137160814Ssimon	elsif (/^zlib$/)
1138160814Ssimon		{ $zlib = 0; }
1139160814Ssimon	elsif (/^static-engine$/)
1140160814Ssimon		{ }
1141160814Ssimon	elsif (/^zlib-dynamic$/)
1142160814Ssimon		{ }
1143160814Ssimon	elsif (/^symlinks$/)
1144160814Ssimon		{ $symlink = 0; }
1145160814Ssimon	elsif (/^sse2$/)
1146160814Ssimon		{ $no_sse2 = 1; }
1147160814Ssimon	else
1148160814Ssimon		{
1149160814Ssimon		my ($ALGO, $algo);
1150238405Sjkim		($ALGO = $algo = $_) =~ tr/[\-a-z]/[_A-Z]/;
1151160814Ssimon
1152160814Ssimon		if (/^asm$/ || /^err$/ || /^hw$/ || /^hw-/)
1153160814Ssimon			{
1154160814Ssimon			$openssl_other_defines .= "#define OPENSSL_NO_$ALGO\n";
1155160814Ssimon			print " OPENSSL_NO_$ALGO";
1156160814Ssimon		
1157160814Ssimon			if (/^err$/)	{ $flags .= "-DOPENSSL_NO_ERR "; }
1158160814Ssimon			elsif (/^asm$/)	{ $no_asm = 1; }
1159160814Ssimon			}
1160160814Ssimon		else
1161160814Ssimon			{
1162160814Ssimon			$openssl_algorithm_defines .= "#define OPENSSL_NO_$ALGO\n";
1163160814Ssimon			print " OPENSSL_NO_$ALGO";
1164160814Ssimon
1165160814Ssimon			if (/^krb5$/)
1166160814Ssimon				{ $no_krb5 = 1; }
1167160814Ssimon			else
1168160814Ssimon				{
1169160814Ssimon				push @skip, $algo;
1170238405Sjkim				# fix-up crypto/directory name(s)
1171238405Sjkim				@skip[$#skip]="whrlpool" if $algo eq "whirlpool";
1172160814Ssimon				print " (skip dir)";
1173160814Ssimon
1174194206Ssimon				$depflags .= " -DOPENSSL_NO_$ALGO";
1175160814Ssimon				}
1176160814Ssimon			}
1177337982Sjkim                        if (/^comp$/)	{ $zlib = 0; }
1178160814Ssimon		}
1179160814Ssimon
1180160814Ssimon	print "\n";
1181160814Ssimon	}
1182160814Ssimon
1183238405Sjkimmy $exp_cflags = "";
1184238405Sjkimforeach (sort @experimental)
1185238405Sjkim	{
1186238405Sjkim	my $ALGO;
1187238405Sjkim	($ALGO = $_) =~ tr/[a-z]/[A-Z]/;
1188160814Ssimon
1189238405Sjkim	# opensslconf.h will set OPENSSL_NO_... unless OPENSSL_EXPERIMENTAL_... is defined
1190238405Sjkim	$openssl_experimental_defines .= "#define OPENSSL_NO_$ALGO\n";
1191238405Sjkim	$exp_cflags .= " -DOPENSSL_EXPERIMENTAL_$ALGO";
1192238405Sjkim	}
1193160814Ssimon
1194238405Sjkimmy $IsMK1MF=scalar grep /^$target$/,@MK1MF_Builds;
1195194206Ssimon
1196238405Sjkim$exe_ext=".exe" if ($target eq "Cygwin" || $target eq "DJGPP" || $target =~ /^mingw/);
1197194206Ssimon$exe_ext=".nlm" if ($target =~ /netware/);
1198160814Ssimon$exe_ext=".pm"  if ($target =~ /vos/);
1199238405Sjkim$openssldir="/usr/local/ssl" if ($openssldir eq "" and $prefix eq "");
120055714Skris$prefix=$openssldir if $prefix eq "";
120155714Skris
1202142425Snectar$default_ranlib= &which("ranlib") or $default_ranlib="true";
1203142425Snectar$perl=$ENV{'PERL'} or $perl=&which("perl5") or $perl=&which("perl")
1204142425Snectar  or $perl="perl";
1205205128Ssimonmy $make = $ENV{'MAKE'} || "make";
1206142425Snectar
1207205128Ssimon$cross_compile_prefix=$ENV{'CROSS_COMPILE'} if $cross_compile_prefix eq "";
1208205128Ssimon
120955714Skrischop $openssldir if $openssldir =~ /\/$/;
1210194206Ssimonchop $prefix if $prefix =~ /.\/$/;
121155714Skris
121255714Skris$openssldir=$prefix . "/ssl" if $openssldir eq "";
1213109998Smarkm$openssldir=$prefix . "/" . $openssldir if $openssldir !~ /(^\/|^[a-zA-Z]:[\\\/])/;
121455714Skris
121555714Skris
1216160814Ssimonprint "IsMK1MF=$IsMK1MF\n";
121755714Skris
1218238405Sjkimmy @fields = split(/\s*:\s*/,$table{$target} . ":" x 30 , -1);
1219238405Sjkimmy $cc = $fields[$idx_cc];
1220238405Sjkim# Allow environment CC to override compiler...
1221238405Sjkimif($ENV{CC}) {
1222238405Sjkim    $cc = $ENV{CC};
1223238405Sjkim}
1224290207Sjkim
1225238405Sjkimmy $cflags = $fields[$idx_cflags];
1226238405Sjkimmy $unistd = $fields[$idx_unistd];
1227238405Sjkimmy $thread_cflag = $fields[$idx_thread_cflag];
1228238405Sjkimmy $sys_id = $fields[$idx_sys_id];
1229238405Sjkimmy $lflags = $fields[$idx_lflags];
1230238405Sjkimmy $bn_ops = $fields[$idx_bn_ops];
1231238405Sjkimmy $cpuid_obj = $fields[$idx_cpuid_obj];
1232238405Sjkimmy $bn_obj = $fields[$idx_bn_obj];
1233290207Sjkimmy $ec_obj = $fields[$idx_ec_obj];
1234238405Sjkimmy $des_obj = $fields[$idx_des_obj];
1235238405Sjkimmy $aes_obj = $fields[$idx_aes_obj];
1236238405Sjkimmy $bf_obj = $fields[$idx_bf_obj];
1237238405Sjkimmy $md5_obj = $fields[$idx_md5_obj];
1238238405Sjkimmy $sha1_obj = $fields[$idx_sha1_obj];
1239238405Sjkimmy $cast_obj = $fields[$idx_cast_obj];
1240238405Sjkimmy $rc4_obj = $fields[$idx_rc4_obj];
1241238405Sjkimmy $rmd160_obj = $fields[$idx_rmd160_obj];
1242238405Sjkimmy $rc5_obj = $fields[$idx_rc5_obj];
1243238405Sjkimmy $wp_obj = $fields[$idx_wp_obj];
1244238405Sjkimmy $cmll_obj = $fields[$idx_cmll_obj];
1245238405Sjkimmy $modes_obj = $fields[$idx_modes_obj];
1246238405Sjkimmy $engines_obj = $fields[$idx_engines_obj];
1247238405Sjkimmy $perlasm_scheme = $fields[$idx_perlasm_scheme];
1248238405Sjkimmy $dso_scheme = $fields[$idx_dso_scheme];
1249238405Sjkimmy $shared_target = $fields[$idx_shared_target];
1250238405Sjkimmy $shared_cflag = $fields[$idx_shared_cflag];
1251238405Sjkimmy $shared_ldflag = $fields[$idx_shared_ldflag];
1252238405Sjkimmy $shared_extension = $fields[$idx_shared_extension];
1253238405Sjkimmy $ranlib = $ENV{'RANLIB'} || $fields[$idx_ranlib];
1254238405Sjkimmy $ar = $ENV{'AR'} || "ar";
1255238405Sjkimmy $arflags = $fields[$idx_arflags];
1256306195Sjkimmy $windres = $ENV{'RC'} || $ENV{'WINDRES'} || "windres";
1257238405Sjkimmy $multilib = $fields[$idx_multilib];
1258238405Sjkim
1259238405Sjkim# if $prefix/lib$multilib is not an existing directory, then
1260238405Sjkim# assume that it's not searched by linker automatically, in
1261238405Sjkim# which case adding $multilib suffix causes more grief than
1262238405Sjkim# we're ready to tolerate, so don't...
1263238405Sjkim$multilib="" if !-d "$prefix/lib$multilib";
1264238405Sjkim
1265238405Sjkim$libdir="lib$multilib" if $libdir eq "";
1266238405Sjkim
1267238405Sjkim$cflags = "$cflags$exp_cflags";
1268238405Sjkim
1269194206Ssimon# '%' in $lflags is used to split flags to "pre-" and post-flags
1270194206Ssimonmy ($prelflags,$postlflags)=split('%',$lflags);
1271238405Sjkimif (defined($postlflags))	{ $lflags=$postlflags;	}
1272238405Sjkimelse				{ $lflags=$prelflags; undef $prelflags;	}
1273100928Snectar
1274331638Sjkimif ($target =~ /^mingw/ && `$cross_compile_prefix$cc --target-help 2>&1` !~ m/\-mno\-cygwin/m)
1275238405Sjkim	{
1276238405Sjkim	$cflags =~ s/\-mno\-cygwin\s*//;
1277238405Sjkim	$shared_ldflag =~ s/\-mno\-cygwin\s*//;
1278238405Sjkim	}
1279238405Sjkim
1280290207Sjkimif ($target =~ /linux.*\-mips/ && !$no_asm && $flags !~ /\-m(ips|arch=)/) {
1281290207Sjkim	# minimally required architecture flags for assembly modules
1282290207Sjkim	$cflags="-mips2 $cflags" if ($target =~ /mips32/);
1283290207Sjkim	$cflags="-mips3 $cflags" if ($target =~ /mips64/);
1284290207Sjkim}
1285290207Sjkim
1286111147Snectarmy $no_shared_warn=0;
1287160814Ssimonmy $no_user_cflags=0;
1288111147Snectar
1289160814Ssimonif ($flags ne "")	{ $cflags="$flags$cflags"; }
1290160814Ssimonelse			{ $no_user_cflags=1;       }
129155714Skris
1292109998Smarkm# Kerberos settings.  The flavor must be provided from outside, either through
1293109998Smarkm# the script "config" or manually.
1294160814Ssimonif (!$no_krb5)
1295109998Smarkm	{
1296109998Smarkm	my ($lresolv, $lpath, $lext);
1297109998Smarkm	if ($withargs{"krb5-flavor"} =~ /^[Hh]eimdal$/)
1298109998Smarkm		{
1299109998Smarkm		die "Sorry, Heimdal is currently not supported\n";
1300109998Smarkm		}
1301109998Smarkm	##### HACK to force use of Heimdal.
1302109998Smarkm	##### WARNING: Since we don't really have adequate support for Heimdal,
1303109998Smarkm	#####          using this will break the build.  You'll have to make
1304109998Smarkm	#####          changes to the source, and if you do, please send
1305109998Smarkm	#####          patches to openssl-dev@openssl.org
1306109998Smarkm	if ($withargs{"krb5-flavor"} =~ /^force-[Hh]eimdal$/)
1307109998Smarkm		{
1308109998Smarkm		warn "Heimdal isn't really supported.  Your build WILL break\n";
1309109998Smarkm		warn "If you fix the problems, please send a patch to openssl-dev\@openssl.org\n";
1310109998Smarkm		$withargs{"krb5-dir"} = "/usr/heimdal"
1311109998Smarkm			if $withargs{"krb5-dir"} eq "";
1312109998Smarkm		$withargs{"krb5-lib"} = "-L".$withargs{"krb5-dir"}.
1313109998Smarkm			"/lib -lgssapi -lkrb5 -lcom_err"
1314160814Ssimon			if $withargs{"krb5-lib"} eq "" && !$IsMK1MF;
1315109998Smarkm		$cflags="-DKRB5_HEIMDAL $cflags";
1316109998Smarkm		}
1317109998Smarkm	if ($withargs{"krb5-flavor"} =~ /^[Mm][Ii][Tt]/)
1318109998Smarkm		{
1319109998Smarkm		$withargs{"krb5-dir"} = "/usr/kerberos"
1320109998Smarkm			if $withargs{"krb5-dir"} eq "";
1321109998Smarkm		$withargs{"krb5-lib"} = "-L".$withargs{"krb5-dir"}.
1322109998Smarkm			"/lib -lgssapi_krb5 -lkrb5 -lcom_err -lk5crypto"
1323160814Ssimon			if $withargs{"krb5-lib"} eq "" && !$IsMK1MF;
1324109998Smarkm		$cflags="-DKRB5_MIT $cflags";
1325109998Smarkm		$withargs{"krb5-flavor"} =~ s/^[Mm][Ii][Tt][._-]*//;
1326109998Smarkm		if ($withargs{"krb5-flavor"} =~ /^1[._-]*[01]/)
1327109998Smarkm			{
1328109998Smarkm			$cflags="-DKRB5_MIT_OLD11 $cflags";
1329109998Smarkm			}
1330109998Smarkm		}
1331109998Smarkm	LRESOLV:
1332109998Smarkm	foreach $lpath ("/lib", "/usr/lib")
1333109998Smarkm		{
1334109998Smarkm		foreach $lext ("a", "so")
1335109998Smarkm			{
1336109998Smarkm			$lresolv = "$lpath/libresolv.$lext";
1337109998Smarkm			last LRESOLV	if (-r "$lresolv");
1338109998Smarkm			$lresolv = "";
1339109998Smarkm			}
1340109998Smarkm		}
1341109998Smarkm	$withargs{"krb5-lib"} .= " -lresolv"
1342109998Smarkm		if ("$lresolv" ne "");
1343109998Smarkm	$withargs{"krb5-include"} = "-I".$withargs{"krb5-dir"}."/include"
1344109998Smarkm		if $withargs{"krb5-include"} eq "" &&
1345109998Smarkm		   $withargs{"krb5-dir"} ne "";
1346109998Smarkm	}
1347109998Smarkm
134868651Skris# The DSO code currently always implements all functions so that no
134968651Skris# applications will have to worry about that from a compilation point
135068651Skris# of view. However, the "method"s may return zero unless that platform
135168651Skris# has support compiled in for them. Currently each method is enabled
135268651Skris# by a define "DSO_<name>" ... we translate the "dso_scheme" config
135368651Skris# string entry into using the following logic;
135468651Skrismy $dso_cflags;
135568651Skrisif (!$no_dso && $dso_scheme ne "")
135668651Skris	{
135768651Skris	$dso_scheme =~ tr/[a-z]/[A-Z]/;
135868651Skris	if ($dso_scheme eq "DLFCN")
135968651Skris		{
136068651Skris		$dso_cflags = "-DDSO_DLFCN -DHAVE_DLFCN_H";
136168651Skris		}
136268651Skris	elsif ($dso_scheme eq "DLFCN_NO_H")
136368651Skris		{
136468651Skris		$dso_cflags = "-DDSO_DLFCN";
136568651Skris		}
136668651Skris	else
136768651Skris		{
136868651Skris		$dso_cflags = "-DDSO_$dso_scheme";
136968651Skris		}
137068651Skris	$cflags = "$dso_cflags $cflags";
137168651Skris	}
137268651Skris
137355714Skrismy $thread_cflags;
137459191Skrismy $thread_defines;
137555714Skrisif ($thread_cflag ne "(unknown)" && !$no_threads)
137655714Skris	{
137755714Skris	# If we know how to do it, support threads by default.
137855714Skris	$threads = 1;
137955714Skris	}
1380160814Ssimonif ($thread_cflag eq "(unknown)" && $threads)
138155714Skris	{
1382160814Ssimon	# If the user asked for "threads", [s]he is also expected to
1383160814Ssimon	# provide any system-dependent compiler options that are
1384160814Ssimon	# necessary.
1385160814Ssimon	if ($no_user_cflags)
1386160814Ssimon		{
1387160814Ssimon		print "You asked for multi-threading support, but didn't\n";
1388160814Ssimon		print "provide any system-specific compiler options\n";
1389160814Ssimon		exit(1);
1390160814Ssimon		}
1391109998Smarkm	$thread_cflags="-DOPENSSL_THREADS $cflags" ;
1392109998Smarkm	$thread_defines .= "#define OPENSSL_THREADS\n";
139355714Skris	}
139455714Skriselse
139555714Skris	{
1396109998Smarkm	$thread_cflags="-DOPENSSL_THREADS $thread_cflag $cflags";
1397109998Smarkm	$thread_defines .= "#define OPENSSL_THREADS\n";
139859191Skris#	my $def;
139959191Skris#	foreach $def (split ' ',$thread_cflag)
140059191Skris#		{
140159191Skris#		if ($def =~ s/^-D// && $def !~ /^_/)
140259191Skris#			{
140359191Skris#			$thread_defines .= "#define $def\n";
140459191Skris#			}
140559191Skris#		}
140655714Skris	}	
140755714Skris
1408109998Smarkm$lflags="$libs$lflags" if ($libs ne "");
140955714Skris
141055714Skrisif ($no_asm)
141155714Skris	{
1412290207Sjkim	$cpuid_obj=$bn_obj=$ec_obj=
1413238405Sjkim	$des_obj=$aes_obj=$bf_obj=$cast_obj=$rc4_obj=$rc5_obj=$cmll_obj=
1414238405Sjkim	$modes_obj=$sha1_obj=$md5_obj=$rmd160_obj=$wp_obj=$engines_obj="";
141555714Skris	}
141655714Skris
1417109998Smarkmif (!$no_shared)
1418109998Smarkm	{
1419109998Smarkm	$cast_obj="";	# CAST assembler is not PIC
1420109998Smarkm	}
1421109998Smarkm
142255714Skrisif ($threads)
142355714Skris	{
1424109998Smarkm	$cflags=$thread_cflags;
1425109998Smarkm	$openssl_thread_defines .= $thread_defines;
142655714Skris	}
142755714Skris
1428109998Smarkmif ($zlib)
1429109998Smarkm	{
1430109998Smarkm	$cflags = "-DZLIB $cflags";
1431160814Ssimon	if (defined($disabled{"zlib-dynamic"}))
1432160814Ssimon		{
1433238405Sjkim		if (defined($withargs{"zlib-lib"}))
1434238405Sjkim			{
1435238405Sjkim			$lflags = "$lflags -L" . $withargs{"zlib-lib"} . " -lz";
1436238405Sjkim			}
1437238405Sjkim		else
1438238405Sjkim			{
1439238405Sjkim			$lflags = "$lflags -lz";
1440238405Sjkim			}
1441160814Ssimon		}
1442160814Ssimon	else
1443160814Ssimon		{
1444160814Ssimon		$cflags = "-DZLIB_SHARED $cflags";
1445160814Ssimon		}
1446109998Smarkm	}
1447109998Smarkm
144868651Skris# You will find shlib_mark1 and shlib_mark2 explained in Makefile.org
144976866Skrismy $shared_mark = "";
1450109998Smarkmif ($shared_target eq "")
145168651Skris	{
1452238405Sjkim	$no_shared_warn = 1 if !$no_shared;
1453109998Smarkm	$no_shared = 1;
1454109998Smarkm	}
1455109998Smarkmif (!$no_shared)
1456109998Smarkm	{
145776866Skris	if ($shared_cflag ne "")
145876866Skris		{
1459160814Ssimon		$cflags = "$shared_cflag -DOPENSSL_PIC $cflags";
146076866Skris		}
146168651Skris	}
1462109998Smarkm
1463160814Ssimonif (!$IsMK1MF)
1464160814Ssimon	{
1465238405Sjkim	# add {no-}static-engine to options to allow mkdef.pl to work without extra arguments
1466160814Ssimon	if ($no_shared)
1467160814Ssimon		{
1468160814Ssimon		$openssl_other_defines.="#define OPENSSL_NO_DYNAMIC_ENGINE\n";
1469238405Sjkim		$options.=" static-engine";
1470160814Ssimon		}
1471160814Ssimon	else
1472160814Ssimon		{
1473160814Ssimon		$openssl_other_defines.="#define OPENSSL_NO_STATIC_ENGINE\n";
1474238405Sjkim		$options.=" no-static-engine";
1475160814Ssimon		}
1476160814Ssimon	}
1477160814Ssimon
1478238405Sjkim$cpuid_obj.=" uplink.o uplink-x86.o" if ($cflags =~ /\-DOPENSSL_USE_APPLINK/);
1479194206Ssimon
1480194206Ssimon#
1481194206Ssimon# Platform fix-ups
1482194206Ssimon#
1483194206Ssimonif ($target =~ /\-icc$/)	# Intel C compiler
1484160814Ssimon	{
1485194206Ssimon	my $iccver=0;
1486194206Ssimon	if (open(FD,"$cc -V 2>&1 |"))
1487194206Ssimon		{
1488194206Ssimon		while(<FD>) { $iccver=$1 if (/Version ([0-9]+)\./); }
1489194206Ssimon		close(FD);
1490194206Ssimon		}
1491160814Ssimon	if ($iccver>=8)
1492160814Ssimon		{
1493290207Sjkim		$cflags=~s/\-KPIC/-fPIC/;
1494160814Ssimon		# Eliminate unnecessary dependency from libirc.a. This is
1495160814Ssimon		# essential for shared library support, as otherwise
1496160814Ssimon		# apps/openssl can end up in endless loop upon startup...
1497160814Ssimon		$cflags.=" -Dmemcpy=__builtin_memcpy -Dmemset=__builtin_memset";
1498160814Ssimon		}
1499194206Ssimon	if ($iccver>=9)
1500194206Ssimon		{
1501290207Sjkim		$lflags.=" -i-static";
1502290207Sjkim		$lflags=~s/\-no_cpprt/-no-cpprt/;
1503194206Ssimon		}
1504194206Ssimon	if ($iccver>=10)
1505194206Ssimon		{
1506290207Sjkim		$lflags=~s/\-i\-static/-static-intel/;
1507194206Ssimon		}
1508290207Sjkim	if ($iccver>=11)
1509290207Sjkim		{
1510290207Sjkim		$cflags.=" -no-intel-extensions";	# disable Cilk
1511290207Sjkim		$lflags=~s/\-no\-cpprt/-no-cxxlib/;
1512290207Sjkim		}
1513160814Ssimon	}
1514160814Ssimon
1515194206Ssimon# Unlike other OSes (like Solaris, Linux, Tru64, IRIX) BSD run-time
1516194206Ssimon# linkers (tested OpenBSD, NetBSD and FreeBSD) "demand" RPATH set on
1517194206Ssimon# .so objects. Apparently application RPATH is not global and does
1518194206Ssimon# not apply to .so linked with other .so. Problem manifests itself
1519194206Ssimon# when libssl.so fails to load libcrypto.so. One can argue that we
1520194206Ssimon# should engrave this into Makefile.shared rules or into BSD-* config
1521194206Ssimon# lines above. Meanwhile let's try to be cautious and pass -rpath to
1522194206Ssimon# linker only when --prefix is not /usr.
1523194206Ssimonif ($target =~ /^BSD\-/)
1524194206Ssimon	{
1525295009Sjkim	$shared_ldflag.=" -Wl,-rpath,\$\$(LIBRPATH)" if ($prefix !~ m|^/usr[/]*$|);
1526194206Ssimon	}
1527194206Ssimon
1528109998Smarkmif ($sys_id ne "")
152972613Skris	{
1530160814Ssimon	#$cflags="-DOPENSSL_SYSNAME_$sys_id $cflags";
1531109998Smarkm	$openssl_sys_defines="#define OPENSSL_SYSNAME_$sys_id\n";
153272613Skris	}
153368651Skris
153476866Skrisif ($ranlib eq "")
153576866Skris	{
153676866Skris	$ranlib = $default_ranlib;
153776866Skris	}
153876866Skris
153955714Skris#my ($bn1)=split(/\s+/,$bn_obj);
154055714Skris#$bn1 = "" unless defined $bn1;
154155714Skris#$bn1=$bn_asm unless ($bn1 =~ /\.o$/);
154255714Skris#$bn_obj="$bn1";
154355714Skris
1544160814Ssimon$cpuid_obj="" if ($processor eq "386");
1545160814Ssimon
154655714Skris$bn_obj = $bn_asm unless $bn_obj ne "";
1547238405Sjkim# bn-586 is the only one implementing bn_*_part_words
1548238405Sjkim$cflags.=" -DOPENSSL_BN_ASM_PART_WORDS" if ($bn_obj =~ /bn-586/);
1549238405Sjkim$cflags.=" -DOPENSSL_IA32_SSE2" if (!$no_sse2 && $bn_obj =~ /86/);
155055714Skris
1551238405Sjkim$cflags.=" -DOPENSSL_BN_ASM_MONT" if ($bn_obj =~ /-mont/);
1552238405Sjkim$cflags.=" -DOPENSSL_BN_ASM_MONT5" if ($bn_obj =~ /-mont5/);
1553238405Sjkim$cflags.=" -DOPENSSL_BN_ASM_GF2m" if ($bn_obj =~ /-gf2m/);
1554194206Ssimon
1555194206Ssimonif ($fips)
1556194206Ssimon	{
1557194206Ssimon	$openssl_other_defines.="#define OPENSSL_FIPS\n";
1558238405Sjkim	$cflags .= " -I\$(FIPSDIR)/include";
1559194206Ssimon	}
1560194206Ssimon
1561238405Sjkim$cpuid_obj="mem_clr.o"	unless ($cpuid_obj =~ /\.o$/);
1562160814Ssimon$des_obj=$des_enc	unless ($des_obj =~ /\.o$/);
156355714Skris$bf_obj=$bf_enc		unless ($bf_obj =~ /\.o$/);
156455714Skris$cast_obj=$cast_enc	unless ($cast_obj =~ /\.o$/);
156555714Skris$rc5_obj=$rc5_enc	unless ($rc5_obj =~ /\.o$/);
1566306195Sjkimif ($rc4_obj =~ /\.o$/)
1567306195Sjkim	{
1568306195Sjkim	$cflags.=" -DRC4_ASM";
1569306195Sjkim	}
1570306195Sjkimelse
1571306195Sjkim	{
1572306195Sjkim	$rc4_obj=$rc4_enc;
1573306195Sjkim	}
1574160814Ssimonif ($sha1_obj =~ /\.o$/)
157555714Skris	{
157655714Skris#	$sha1_obj=$sha1_enc;
1577160814Ssimon	$cflags.=" -DSHA1_ASM"   if ($sha1_obj =~ /sx86/ || $sha1_obj =~ /sha1/);
1578160814Ssimon	$cflags.=" -DSHA256_ASM" if ($sha1_obj =~ /sha256/);
1579160814Ssimon	$cflags.=" -DSHA512_ASM" if ($sha1_obj =~ /sha512/);
1580194206Ssimon	if ($sha1_obj =~ /sse2/)
1581160814Ssimon	    {	if ($no_sse2)
1582160814Ssimon		{   $sha1_obj =~ s/\S*sse2\S+//;        }
1583160814Ssimon		elsif ($cflags !~ /OPENSSL_IA32_SSE2/)
1584160814Ssimon		{   $cflags.=" -DOPENSSL_IA32_SSE2";    }
1585160814Ssimon	    }
158655714Skris	}
158755714Skrisif ($md5_obj =~ /\.o$/)
158855714Skris	{
158955714Skris#	$md5_obj=$md5_enc;
159055714Skris	$cflags.=" -DMD5_ASM";
159155714Skris	}
159255714Skrisif ($rmd160_obj =~ /\.o$/)
159355714Skris	{
159455714Skris#	$rmd160_obj=$rmd160_enc;
159555714Skris	$cflags.=" -DRMD160_ASM";
159655714Skris	}
1597160814Ssimonif ($aes_obj =~ /\.o$/)
1598142425Snectar	{
1599290207Sjkim	$cflags.=" -DAES_ASM" if ($aes_obj =~ m/\baes\-/);;
1600238405Sjkim	# aes-ctr.o is not a real file, only indication that assembler
1601238405Sjkim	# module implements AES_ctr32_encrypt...
1602238405Sjkim	$cflags.=" -DAES_CTR_ASM" if ($aes_obj =~ s/\s*aes\-ctr\.o//);
1603238405Sjkim	# aes-xts.o indicates presense of AES_xts_[en|de]crypt...
1604238405Sjkim	$cflags.=" -DAES_XTS_ASM" if ($aes_obj =~ s/\s*aes\-xts\.o//);
1605238405Sjkim	$aes_obj =~ s/\s*(vpaes|aesni)\-x86\.o//g if ($no_sse2);
1606238405Sjkim	$cflags.=" -DVPAES_ASM" if ($aes_obj =~ m/vpaes/);
1607238405Sjkim	$cflags.=" -DBSAES_ASM" if ($aes_obj =~ m/bsaes/);
1608142425Snectar	}
1609160814Ssimonelse	{
1610160814Ssimon	$aes_obj=$aes_enc;
1611160814Ssimon	}
1612238405Sjkim$wp_obj="" if ($wp_obj =~ /mmx/ && $processor eq "386");
1613238405Sjkimif ($wp_obj =~ /\.o$/ && !$disabled{"whirlpool"})
1614238405Sjkim	{
1615238405Sjkim	$cflags.=" -DWHIRLPOOL_ASM";
1616238405Sjkim	}
1617238405Sjkimelse	{
1618238405Sjkim	$wp_obj="wp_block.o";
1619238405Sjkim	}
1620238405Sjkim$cmll_obj=$cmll_enc	unless ($cmll_obj =~ /.o$/);
1621290207Sjkimif ($modes_obj =~ /ghash\-/)
1622238405Sjkim	{
1623238405Sjkim	$cflags.=" -DGHASH_ASM";
1624238405Sjkim	}
1625290207Sjkimif ($ec_obj =~ /ecp_nistz256/)
1626290207Sjkim	{
1627290207Sjkim	$cflags.=" -DECP_NISTZ256_ASM";
1628290207Sjkim	}
1629142425Snectar
1630100936Snectar# "Stringify" the C flags string.  This permits it to be made part of a string
1631100936Snectar# and works as well on command lines.
1632100936Snectar$cflags =~ s/([\\\"])/\\\1/g;
1633100936Snectar
163455714Skrismy $version = "unknown";
1635160814Ssimonmy $version_num = "unknown";
163655714Skrismy $major = "unknown";
163755714Skrismy $minor = "unknown";
163868651Skrismy $shlib_version_number = "unknown";
163968651Skrismy $shlib_version_history = "unknown";
164068651Skrismy $shlib_major = "unknown";
164168651Skrismy $shlib_minor = "unknown";
164255714Skris
164355714Skrisopen(IN,'<crypto/opensslv.h') || die "unable to read opensslv.h:$!\n";
164455714Skriswhile (<IN>)
164555714Skris	{
164655714Skris	$version=$1 if /OPENSSL.VERSION.TEXT.*OpenSSL (\S+) /;
1647160814Ssimon	$version_num=$1 if /OPENSSL.VERSION.NUMBER.*0x(\S+)/;
164868651Skris	$shlib_version_number=$1 if /SHLIB_VERSION_NUMBER *"([^"]+)"/;
164968651Skris	$shlib_version_history=$1 if /SHLIB_VERSION_HISTORY *"([^"]*)"/;
165055714Skris	}
165155714Skrisclose(IN);
165268651Skrisif ($shlib_version_history ne "") { $shlib_version_history .= ":"; }
165355714Skris
165455714Skrisif ($version =~ /(^[0-9]*)\.([0-9\.]*)/)
165555714Skris	{
165655714Skris	$major=$1;
165755714Skris	$minor=$2;
165855714Skris	}
165955714Skris
166068651Skrisif ($shlib_version_number =~ /(^[0-9]*)\.([0-9\.]*)/)
166168651Skris	{
166268651Skris	$shlib_major=$1;
166368651Skris	$shlib_minor=$2;
166468651Skris	}
166568651Skris
1666331638Sjkimmy %predefined;
1667291719Sjkim
1668331638Sjkim# collect compiler pre-defines from gcc or gcc-alike...
1669331638Sjkimopen(PIPE, "$cross_compile_prefix$cc -dM -E -x c /dev/null 2>&1 |");
1670331638Sjkimwhile (<PIPE>) {
1671331638Sjkim  m/^#define\s+(\w+(?:\(\w+\))?)(?:\s+(.+))?/ or last;
1672331638Sjkim  $predefined{$1} = defined($2) ? $2 : "";
1673331638Sjkim}
1674331638Sjkimclose(PIPE);
1675331638Sjkim
1676337982Sjkim# Xcode did not handle $cc -M before clang support
1677337982Sjkimmy $cc_as_makedepend = 0;
1678337982Sjkimif ($predefined{__GNUC__} >= 3 && !(defined($predefined{__APPLE_CC__})
1679337982Sjkim                                    && !defined($predefined{__clang__}))) {
1680337982Sjkim  $cc_as_makedepend = 1;
1681337982Sjkim}
1682337982Sjkim
1683205128Ssimonif ($strict_warnings)
1684205128Ssimon	{
1685205128Ssimon	my $wopt;
1686331638Sjkim	die "ERROR --strict-warnings requires gcc or clang" unless defined($predefined{__GNUC__});
1687205128Ssimon	foreach $wopt (split /\s+/, $gcc_devteam_warn)
1688205128Ssimon		{
1689291719Sjkim		$cflags .= " $wopt" unless ($cflags =~ /(^|\s)$wopt(\s|$)/)
1690205128Ssimon		}
1691331638Sjkim	if (defined($predefined{__clang__}))
1692290207Sjkim		{
1693290207Sjkim		foreach $wopt (split /\s+/, $clang_devteam_warn)
1694290207Sjkim			{
1695291719Sjkim			$cflags .= " $wopt" unless ($cflags =~ /(^|\s)$wopt(\s|$)/)
1696290207Sjkim			}
1697290207Sjkim		}
1698205128Ssimon	}
1699205128Ssimon
170055714Skrisopen(IN,'<Makefile.org') || die "unable to read Makefile.org:$!\n";
1701109998Smarkmunlink("$Makefile.new") || die "unable to remove old $Makefile.new:$!\n" if -e "$Makefile.new";
1702109998Smarkmopen(OUT,">$Makefile.new") || die "unable to create $Makefile.new:$!\n";
170359191Skrisprint OUT "### Generated automatically from Makefile.org by Configure.\n\n";
170455714Skrismy $sdirs=0;
170555714Skriswhile (<IN>)
170655714Skris	{
1707160814Ssimon	chomp;
170855714Skris	$sdirs = 1 if /^SDIRS=/;
170955714Skris	if ($sdirs) {
171055714Skris		my $dir;
171155714Skris		foreach $dir (@skip) {
1712238405Sjkim			s/(\s)$dir /$1/;
1713194206Ssimon			s/\s$dir$//;
171455714Skris			}
171555714Skris		}
171655714Skris	$sdirs = 0 unless /\\$/;
1717194206Ssimon        s/engines // if (/^DIRS=/ && $disabled{"engine"});
1718238405Sjkim	s/ccgost// if (/^ENGDIRS=/ && $disabled{"gost"});
171955714Skris	s/^VERSION=.*/VERSION=$version/;
172055714Skris	s/^MAJOR=.*/MAJOR=$major/;
172155714Skris	s/^MINOR=.*/MINOR=$minor/;
172268651Skris	s/^SHLIB_VERSION_NUMBER=.*/SHLIB_VERSION_NUMBER=$shlib_version_number/;
172368651Skris	s/^SHLIB_VERSION_HISTORY=.*/SHLIB_VERSION_HISTORY=$shlib_version_history/;
172468651Skris	s/^SHLIB_MAJOR=.*/SHLIB_MAJOR=$shlib_major/;
172568651Skris	s/^SHLIB_MINOR=.*/SHLIB_MINOR=$shlib_minor/;
172676866Skris	s/^SHLIB_EXT=.*/SHLIB_EXT=$shared_extension/;
172755714Skris	s/^INSTALLTOP=.*$/INSTALLTOP=$prefix/;
1728238405Sjkim	s/^MULTILIB=.*$/MULTILIB=$multilib/;
172955714Skris	s/^OPENSSLDIR=.*$/OPENSSLDIR=$openssldir/;
1730205128Ssimon	s/^LIBDIR=.*$/LIBDIR=$libdir/;
173155714Skris	s/^INSTALL_PREFIX=.*$/INSTALL_PREFIX=$install_prefix/;
173255714Skris	s/^PLATFORM=.*$/PLATFORM=$target/;
173355714Skris	s/^OPTIONS=.*$/OPTIONS=$options/;
173468651Skris	s/^CONFIGURE_ARGS=.*$/CONFIGURE_ARGS=$argvstring/;
1735205128Ssimon	if ($cross_compile_prefix)
1736205128Ssimon		{
1737205128Ssimon		s/^CC=.*$/CROSS_COMPILE= $cross_compile_prefix\nCC= \$\(CROSS_COMPILE\)$cc/;
1738205128Ssimon		s/^AR=\s*/AR= \$\(CROSS_COMPILE\)/;
1739238405Sjkim		s/^NM=\s*/NM= \$\(CROSS_COMPILE\)/;
1740205128Ssimon		s/^RANLIB=\s*/RANLIB= \$\(CROSS_COMPILE\)/;
1741306195Sjkim		s/^RC=\s*/RC= \$\(CROSS_COMPILE\)/;
1742337982Sjkim		s/^MAKEDEPPROG=.*$/MAKEDEPPROG= \$\(CROSS_COMPILE\)$cc/ if $cc_as_makedepend;
1743205128Ssimon		}
1744205128Ssimon	else	{
1745205128Ssimon		s/^CC=.*$/CC= $cc/;
1746205128Ssimon		s/^AR=\s*ar/AR= $ar/;
1747205128Ssimon		s/^RANLIB=.*/RANLIB= $ranlib/;
1748306195Sjkim		s/^RC=.*/RC= $windres/;
1749337982Sjkim		s/^MAKEDEPPROG=.*$/MAKEDEPPROG= $cc/ if $cc_as_makedepend;
1750205128Ssimon		}
175155714Skris	s/^CFLAG=.*$/CFLAG= $cflags/;
1752194206Ssimon	s/^DEPFLAG=.*$/DEPFLAG=$depflags/;
1753194206Ssimon	s/^PEX_LIBS=.*$/PEX_LIBS= $prelflags/;
175455714Skris	s/^EX_LIBS=.*$/EX_LIBS= $lflags/;
175576866Skris	s/^EXE_EXT=.*$/EXE_EXT= $exe_ext/;
1756160814Ssimon	s/^CPUID_OBJ=.*$/CPUID_OBJ= $cpuid_obj/;
175755714Skris	s/^BN_ASM=.*$/BN_ASM= $bn_obj/;
1758290207Sjkim	s/^EC_ASM=.*$/EC_ASM= $ec_obj/;
175955714Skris	s/^DES_ENC=.*$/DES_ENC= $des_obj/;
1760238405Sjkim	s/^AES_ENC=.*$/AES_ENC= $aes_obj/;
176155714Skris	s/^BF_ENC=.*$/BF_ENC= $bf_obj/;
176255714Skris	s/^CAST_ENC=.*$/CAST_ENC= $cast_obj/;
176355714Skris	s/^RC4_ENC=.*$/RC4_ENC= $rc4_obj/;
176455714Skris	s/^RC5_ENC=.*$/RC5_ENC= $rc5_obj/;
176555714Skris	s/^MD5_ASM_OBJ=.*$/MD5_ASM_OBJ= $md5_obj/;
176655714Skris	s/^SHA1_ASM_OBJ=.*$/SHA1_ASM_OBJ= $sha1_obj/;
176755714Skris	s/^RMD160_ASM_OBJ=.*$/RMD160_ASM_OBJ= $rmd160_obj/;
1768238405Sjkim	s/^WP_ASM_OBJ=.*$/WP_ASM_OBJ= $wp_obj/;
1769238405Sjkim	s/^CMLL_ENC=.*$/CMLL_ENC= $cmll_obj/;
1770238405Sjkim	s/^MODES_ASM_OBJ.=*$/MODES_ASM_OBJ= $modes_obj/;
1771238405Sjkim	s/^ENGINES_ASM_OBJ.=*$/ENGINES_ASM_OBJ= $engines_obj/;
1772238405Sjkim	s/^PERLASM_SCHEME=.*$/PERLASM_SCHEME= $perlasm_scheme/;
177355714Skris	s/^PROCESSOR=.*/PROCESSOR= $processor/;
1774109998Smarkm	s/^ARFLAGS=.*/ARFLAGS= $arflags/;
177555714Skris	s/^PERL=.*/PERL= $perl/;
1776109998Smarkm	s/^KRB5_INCLUDES=.*/KRB5_INCLUDES=$withargs{"krb5-include"}/;
1777111147Snectar	s/^LIBKRB5=.*/LIBKRB5=$withargs{"krb5-lib"}/;
1778160814Ssimon	s/^LIBZLIB=.*/LIBZLIB=$withargs{"zlib-lib"}/;
1779160814Ssimon	s/^ZLIB_INCLUDE=.*/ZLIB_INCLUDE=$withargs{"zlib-include"}/;
1780238405Sjkim
1781238405Sjkim	s/^FIPSDIR=.*/FIPSDIR=$fipsdir/;
1782194206Ssimon	s/^FIPSLIBDIR=.*/FIPSLIBDIR=$fipslibdir/;
1783238405Sjkim	s/^FIPSCANLIB=.*/FIPSCANLIB=libcrypto/ if $fips;
1784194206Ssimon	s/^BASEADDR=.*/BASEADDR=$baseaddr/;
1785238405Sjkim
178668651Skris	s/^SHLIB_TARGET=.*/SHLIB_TARGET=$shared_target/;
178776866Skris	s/^SHLIB_MARK=.*/SHLIB_MARK=$shared_mark/;
1788238405Sjkim	s/^SHARED_LIBS=.*/SHARED_LIBS=\$(SHARED_CRYPTO) \$(SHARED_SSL)/ if (!$no_shared);
178989837Skris	if ($shared_extension ne "" && $shared_extension =~ /^\.s([ol])\.[^\.]*$/)
179089837Skris		{
179189837Skris		my $sotmp = $1;
1792100936Snectar		s/^SHARED_LIBS_LINK_EXTS=.*/SHARED_LIBS_LINK_EXTS=.s$sotmp/;
179389837Skris		}
1794100936Snectar	elsif ($shared_extension ne "" && $shared_extension =~ /^\.[^\.]*\.dylib$/)
1795100936Snectar		{
1796100936Snectar		s/^SHARED_LIBS_LINK_EXTS=.*/SHARED_LIBS_LINK_EXTS=.dylib/;
1797100936Snectar		}
179889837Skris	elsif ($shared_extension ne "" && $shared_extension =~ /^\.s([ol])\.[^\.]*\.[^\.]*$/)
179989837Skris		{
180089837Skris		my $sotmp = $1;
180189837Skris		s/^SHARED_LIBS_LINK_EXTS=.*/SHARED_LIBS_LINK_EXTS=.s$sotmp.\$(SHLIB_MAJOR) .s$sotmp/;
180289837Skris		}
1803100936Snectar	elsif ($shared_extension ne "" && $shared_extension =~ /^\.[^\.]*\.[^\.]*\.dylib$/)
1804100936Snectar		{
1805100936Snectar		s/^SHARED_LIBS_LINK_EXTS=.*/SHARED_LIBS_LINK_EXTS=.\$(SHLIB_MAJOR).dylib .dylib/;
1806100936Snectar		}
1807100928Snectar	s/^SHARED_LDFLAGS=.*/SHARED_LDFLAGS=$shared_ldflag/;
180855714Skris	print OUT $_."\n";
180955714Skris	}
181055714Skrisclose(IN);
181155714Skrisclose(OUT);
1812312826Sjkimif ((compare($Makefile, "$Makefile.new"))
1813312826Sjkim	or file_newer('Configure', $Makefile)
1814312826Sjkim	or file_newer('config', $Makefile)
1815312826Sjkim	or file_newer('Makefile.org', $Makefile))
1816312826Sjkim	{
1817312826Sjkim	rename($Makefile,"$Makefile.bak") || die "unable to rename $Makefile\n" if -e $Makefile;
1818312826Sjkim	rename("$Makefile.new",$Makefile) || die "unable to rename $Makefile.new\n";
1819312826Sjkim	}
1820312826Sjkimelse
1821312826Sjkim	{ unlink("$Makefile.new"); }
182255714Skris
182355714Skrisprint "CC            =$cc\n";
182455714Skrisprint "CFLAG         =$cflags\n";
182555714Skrisprint "EX_LIBS       =$lflags\n";
1826160814Ssimonprint "CPUID_OBJ     =$cpuid_obj\n";
182755714Skrisprint "BN_ASM        =$bn_obj\n";
1828290207Sjkimprint "EC_ASM        =$ec_obj\n";
182955714Skrisprint "DES_ENC       =$des_obj\n";
1830238405Sjkimprint "AES_ENC       =$aes_obj\n";
183155714Skrisprint "BF_ENC        =$bf_obj\n";
183255714Skrisprint "CAST_ENC      =$cast_obj\n";
183355714Skrisprint "RC4_ENC       =$rc4_obj\n";
183455714Skrisprint "RC5_ENC       =$rc5_obj\n";
183555714Skrisprint "MD5_OBJ_ASM   =$md5_obj\n";
183655714Skrisprint "SHA1_OBJ_ASM  =$sha1_obj\n";
183755714Skrisprint "RMD160_OBJ_ASM=$rmd160_obj\n";
1838238405Sjkimprint "CMLL_ENC      =$cmll_obj\n";
1839238405Sjkimprint "MODES_OBJ     =$modes_obj\n";
1840238405Sjkimprint "ENGINES_OBJ   =$engines_obj\n";
184155714Skrisprint "PROCESSOR     =$processor\n";
184255714Skrisprint "RANLIB        =$ranlib\n";
1843109998Smarkmprint "ARFLAGS       =$arflags\n";
184455714Skrisprint "PERL          =$perl\n";
1845109998Smarkmprint "KRB5_INCLUDES =",$withargs{"krb5-include"},"\n"
1846109998Smarkm	if $withargs{"krb5-include"} ne "";
184755714Skris
184855714Skrismy $des_ptr=0;
184955714Skrismy $des_risc1=0;
185055714Skrismy $des_risc2=0;
185155714Skrismy $des_unroll=0;
185255714Skrismy $bn_ll=0;
185355714Skrismy $def_int=2;
185455714Skrismy $rc4_int=$def_int;
185555714Skrismy $md2_int=$def_int;
185655714Skrismy $idea_int=$def_int;
185755714Skrismy $rc2_int=$def_int;
185855714Skrismy $rc4_idx=0;
185959191Skrismy $rc4_chunk=0;
186055714Skrismy $bf_ptr=0;
186155714Skrismy @type=("char","short","int","long");
186255714Skrismy ($b64l,$b64,$b32,$b16,$b8)=(0,0,1,0,0);
1863109998Smarkmmy $export_var_as_fn=0;
186455714Skris
186555714Skrismy $des_int;
186655714Skris
186755714Skrisforeach (sort split(/\s+/,$bn_ops))
186855714Skris	{
186955714Skris	$des_ptr=1 if /DES_PTR/;
187055714Skris	$des_risc1=1 if /DES_RISC1/;
187155714Skris	$des_risc2=1 if /DES_RISC2/;
187255714Skris	$des_unroll=1 if /DES_UNROLL/;
187355714Skris	$des_int=1 if /DES_INT/;
187455714Skris	$bn_ll=1 if /BN_LLONG/;
187555714Skris	$rc4_int=0 if /RC4_CHAR/;
187655714Skris	$rc4_int=3 if /RC4_LONG/;
187755714Skris	$rc4_idx=1 if /RC4_INDEX/;
187859191Skris	$rc4_chunk=1 if /RC4_CHUNK/;
187959191Skris	$rc4_chunk=2 if /RC4_CHUNK_LL/;
188055714Skris	$md2_int=0 if /MD2_CHAR/;
188155714Skris	$md2_int=3 if /MD2_LONG/;
188255714Skris	$idea_int=1 if /IDEA_SHORT/;
188355714Skris	$idea_int=3 if /IDEA_LONG/;
188455714Skris	$rc2_int=1 if /RC2_SHORT/;
188555714Skris	$rc2_int=3 if /RC2_LONG/;
188655714Skris	$bf_ptr=1 if $_ eq "BF_PTR";
188755714Skris	$bf_ptr=2 if $_ eq "BF_PTR2";
188855714Skris	($b64l,$b64,$b32,$b16,$b8)=(0,1,0,0,0) if /SIXTY_FOUR_BIT/;
188955714Skris	($b64l,$b64,$b32,$b16,$b8)=(1,0,0,0,0) if /SIXTY_FOUR_BIT_LONG/;
189055714Skris	($b64l,$b64,$b32,$b16,$b8)=(0,0,1,0,0) if /THIRTY_TWO_BIT/;
189155714Skris	($b64l,$b64,$b32,$b16,$b8)=(0,0,0,1,0) if /SIXTEEN_BIT/;
189255714Skris	($b64l,$b64,$b32,$b16,$b8)=(0,0,0,0,1) if /EIGHT_BIT/;
1893109998Smarkm	$export_var_as_fn=1 if /EXPORT_VAR_AS_FN/;
189455714Skris	}
189555714Skris
189655714Skrisopen(IN,'<crypto/opensslconf.h.in') || die "unable to read crypto/opensslconf.h.in:$!\n";
1897109998Smarkmunlink("crypto/opensslconf.h.new") || die "unable to remove old crypto/opensslconf.h.new:$!\n" if -e "crypto/opensslconf.h.new";
1898109998Smarkmopen(OUT,'>crypto/opensslconf.h.new') || die "unable to create crypto/opensslconf.h.new:$!\n";
189959191Skrisprint OUT "/* opensslconf.h */\n";
190059191Skrisprint OUT "/* WARNING: Generated automatically from opensslconf.h.in by Configure. */\n\n";
190159191Skris
1902273144Sjkimprint OUT "#ifdef  __cplusplus\n";
1903273144Sjkimprint OUT "extern \"C\" {\n";
1904273144Sjkimprint OUT "#endif\n";
190559191Skrisprint OUT "/* OpenSSL was configured with the following options: */\n";
1906109998Smarkmmy $openssl_algorithm_defines_trans = $openssl_algorithm_defines;
1907194206Ssimon$openssl_experimental_defines =~ s/^\s*#\s*define\s+OPENSSL_NO_(.*)/#ifndef OPENSSL_EXPERIMENTAL_$1\n# ifndef OPENSSL_NO_$1\n#  define OPENSSL_NO_$1\n# endif\n#endif/mg;
1908109998Smarkm$openssl_algorithm_defines_trans =~ s/^\s*#\s*define\s+OPENSSL_(.*)/# if defined(OPENSSL_$1) \&\& !defined($1)\n#  define $1\n# endif/mg;
1909109998Smarkm$openssl_algorithm_defines =~ s/^\s*#\s*define\s+(.*)/#ifndef $1\n# define $1\n#endif/mg;
191059191Skris$openssl_algorithm_defines = "   /* no ciphers excluded */\n" if $openssl_algorithm_defines eq "";
1911109998Smarkm$openssl_thread_defines =~ s/^\s*#\s*define\s+(.*)/#ifndef $1\n# define $1\n#endif/mg;
1912109998Smarkm$openssl_sys_defines =~ s/^\s*#\s*define\s+(.*)/#ifndef $1\n# define $1\n#endif/mg;
1913109998Smarkm$openssl_other_defines =~ s/^\s*#\s*define\s+(.*)/#ifndef $1\n# define $1\n#endif/mg;
1914109998Smarkmprint OUT $openssl_sys_defines;
1915109998Smarkmprint OUT "#ifndef OPENSSL_DOING_MAKEDEPEND\n\n";
1916194206Ssimonprint OUT $openssl_experimental_defines;
1917194206Ssimonprint OUT "\n";
1918109998Smarkmprint OUT $openssl_algorithm_defines;
1919194206Ssimonprint OUT "\n#endif /* OPENSSL_DOING_MAKEDEPEND */\n\n";
1920109998Smarkmprint OUT $openssl_thread_defines;
1921109998Smarkmprint OUT $openssl_other_defines,"\n";
192259191Skris
1923109998Smarkmprint OUT "/* The OPENSSL_NO_* macros are also defined as NO_* if the application\n";
1924109998Smarkmprint OUT "   asks for it.  This is a transient feature that is provided for those\n";
1925109998Smarkmprint OUT "   who haven't had the time to do the appropriate changes in their\n";
1926109998Smarkmprint OUT "   applications.  */\n";
1927109998Smarkmprint OUT "#ifdef OPENSSL_ALGORITHM_DEFINES\n";
1928109998Smarkmprint OUT $openssl_algorithm_defines_trans;
1929109998Smarkmprint OUT "#endif\n\n";
1930109998Smarkm
1931238405Sjkimprint OUT "#define OPENSSL_CPUID_OBJ\n\n" if ($cpuid_obj ne "mem_clr.o");
1932160814Ssimon
193355714Skriswhile (<IN>)
193455714Skris	{
193555714Skris	if	(/^#define\s+OPENSSLDIR/)
1936205128Ssimon		{
1937205128Ssimon		my $foo = $openssldir;
1938205128Ssimon		$foo =~ s/\\/\\\\/g;
1939205128Ssimon		print OUT "#define OPENSSLDIR \"$foo\"\n";
1940205128Ssimon		}
1941160814Ssimon	elsif	(/^#define\s+ENGINESDIR/)
1942205128Ssimon		{
1943238405Sjkim		my $foo = "$prefix/$libdir/engines";
1944205128Ssimon		$foo =~ s/\\/\\\\/g;
1945205128Ssimon		print OUT "#define ENGINESDIR \"$foo\"\n";
1946205128Ssimon		}
1947109998Smarkm	elsif	(/^#((define)|(undef))\s+OPENSSL_EXPORT_VAR_AS_FUNCTION/)
1948109998Smarkm		{ printf OUT "#undef OPENSSL_EXPORT_VAR_AS_FUNCTION\n"
1949109998Smarkm			if $export_var_as_fn;
1950109998Smarkm		  printf OUT "#%s OPENSSL_EXPORT_VAR_AS_FUNCTION\n",
1951109998Smarkm			($export_var_as_fn)?"define":"undef"; }
195255714Skris	elsif	(/^#define\s+OPENSSL_UNISTD/)
195355714Skris		{
195455714Skris		$unistd = "<unistd.h>" if $unistd eq "";
195555714Skris		print OUT "#define OPENSSL_UNISTD $unistd\n";
195655714Skris		}
195755714Skris	elsif	(/^#((define)|(undef))\s+SIXTY_FOUR_BIT_LONG/)
195855714Skris		{ printf OUT "#%s SIXTY_FOUR_BIT_LONG\n",($b64l)?"define":"undef"; }
195955714Skris	elsif	(/^#((define)|(undef))\s+SIXTY_FOUR_BIT/)
196055714Skris		{ printf OUT "#%s SIXTY_FOUR_BIT\n",($b64)?"define":"undef"; }
196155714Skris	elsif	(/^#((define)|(undef))\s+THIRTY_TWO_BIT/)
196255714Skris		{ printf OUT "#%s THIRTY_TWO_BIT\n",($b32)?"define":"undef"; }
196355714Skris	elsif	(/^#((define)|(undef))\s+SIXTEEN_BIT/)
196455714Skris		{ printf OUT "#%s SIXTEEN_BIT\n",($b16)?"define":"undef"; }
196555714Skris	elsif	(/^#((define)|(undef))\s+EIGHT_BIT/)
196655714Skris		{ printf OUT "#%s EIGHT_BIT\n",($b8)?"define":"undef"; }
196755714Skris	elsif	(/^#((define)|(undef))\s+BN_LLONG\s*$/)
196855714Skris		{ printf OUT "#%s BN_LLONG\n",($bn_ll)?"define":"undef"; }
196955714Skris	elsif	(/^\#define\s+DES_LONG\s+.*/)
197055714Skris		{ printf OUT "#define DES_LONG unsigned %s\n",
197155714Skris			($des_int)?'int':'long'; }
197255714Skris	elsif	(/^\#(define|undef)\s+DES_PTR/)
197355714Skris		{ printf OUT "#%s DES_PTR\n",($des_ptr)?'define':'undef'; }
197455714Skris	elsif	(/^\#(define|undef)\s+DES_RISC1/)
197555714Skris		{ printf OUT "#%s DES_RISC1\n",($des_risc1)?'define':'undef'; }
197655714Skris	elsif	(/^\#(define|undef)\s+DES_RISC2/)
197755714Skris		{ printf OUT "#%s DES_RISC2\n",($des_risc2)?'define':'undef'; }
197855714Skris	elsif	(/^\#(define|undef)\s+DES_UNROLL/)
197955714Skris		{ printf OUT "#%s DES_UNROLL\n",($des_unroll)?'define':'undef'; }
198055714Skris	elsif	(/^#define\s+RC4_INT\s/)
198155714Skris		{ printf OUT "#define RC4_INT unsigned %s\n",$type[$rc4_int]; }
198259191Skris	elsif	(/^#undef\s+RC4_CHUNK/)
198359191Skris		{
198459191Skris		printf OUT "#undef RC4_CHUNK\n" if $rc4_chunk==0;
198559191Skris		printf OUT "#define RC4_CHUNK unsigned long\n" if $rc4_chunk==1;
198659191Skris		printf OUT "#define RC4_CHUNK unsigned long long\n" if $rc4_chunk==2;
198759191Skris		}
198855714Skris	elsif	(/^#((define)|(undef))\s+RC4_INDEX/)
198955714Skris		{ printf OUT "#%s RC4_INDEX\n",($rc4_idx)?"define":"undef"; }
199055714Skris	elsif (/^#(define|undef)\s+I386_ONLY/)
1991160814Ssimon		{ printf OUT "#%s I386_ONLY\n", ($processor eq "386")?
199255714Skris			"define":"undef"; }
199355714Skris	elsif	(/^#define\s+MD2_INT\s/)
199455714Skris		{ printf OUT "#define MD2_INT unsigned %s\n",$type[$md2_int]; }
199555714Skris	elsif	(/^#define\s+IDEA_INT\s/)
199655714Skris		{printf OUT "#define IDEA_INT unsigned %s\n",$type[$idea_int];}
199755714Skris	elsif	(/^#define\s+RC2_INT\s/)
199855714Skris		{printf OUT "#define RC2_INT unsigned %s\n",$type[$rc2_int];}
199955714Skris	elsif (/^#(define|undef)\s+BF_PTR/)
200055714Skris		{
200155714Skris		printf OUT "#undef BF_PTR\n" if $bf_ptr == 0;
200255714Skris		printf OUT "#define BF_PTR\n" if $bf_ptr == 1;
200355714Skris		printf OUT "#define BF_PTR2\n" if $bf_ptr == 2;
200455714Skris	        }
200555714Skris	else
200655714Skris		{ print OUT $_; }
200755714Skris	}
200855714Skrisclose(IN);
2009273144Sjkimprint OUT "#ifdef  __cplusplus\n";
2010273144Sjkimprint OUT "}\n";
2011273144Sjkimprint OUT "#endif\n";
201255714Skrisclose(OUT);
2013312826Sjkimif (compare("crypto/opensslconf.h.new","crypto/opensslconf.h"))
2014312826Sjkim	{
2015312826Sjkim	rename("crypto/opensslconf.h","crypto/opensslconf.h.bak") || die "unable to rename crypto/opensslconf.h\n" if -e "crypto/opensslconf.h";
2016312826Sjkim	rename("crypto/opensslconf.h.new","crypto/opensslconf.h") || die "unable to rename crypto/opensslconf.h.new\n";
2017312826Sjkim	}
2018312826Sjkimelse
2019312826Sjkim	{ unlink("crypto/opensslconf.h.new"); }
202055714Skris
202155714Skris# Fix the date
202255714Skris
202355714Skrisprint "SIXTY_FOUR_BIT_LONG mode\n" if $b64l;
202455714Skrisprint "SIXTY_FOUR_BIT mode\n" if $b64;
202555714Skrisprint "THIRTY_TWO_BIT mode\n" if $b32;
202655714Skrisprint "SIXTEEN_BIT mode\n" if $b16;
202755714Skrisprint "EIGHT_BIT mode\n" if $b8;
202855714Skrisprint "DES_PTR used\n" if $des_ptr;
202955714Skrisprint "DES_RISC1 used\n" if $des_risc1;
203055714Skrisprint "DES_RISC2 used\n" if $des_risc2;
203155714Skrisprint "DES_UNROLL used\n" if $des_unroll;
203255714Skrisprint "DES_INT used\n" if $des_int;
203355714Skrisprint "BN_LLONG mode\n" if $bn_ll;
203455714Skrisprint "RC4 uses u$type[$rc4_int]\n" if $rc4_int != $def_int;
203555714Skrisprint "RC4_INDEX mode\n" if $rc4_idx;
203659191Skrisprint "RC4_CHUNK is undefined\n" if $rc4_chunk==0;
203759191Skrisprint "RC4_CHUNK is unsigned long\n" if $rc4_chunk==1;
203859191Skrisprint "RC4_CHUNK is unsigned long long\n" if $rc4_chunk==2;
203955714Skrisprint "MD2 uses u$type[$md2_int]\n" if $md2_int != $def_int;
204055714Skrisprint "IDEA uses u$type[$idea_int]\n" if $idea_int != $def_int;
204155714Skrisprint "RC2 uses u$type[$rc2_int]\n" if $rc2_int != $def_int;
204255714Skrisprint "BF_PTR used\n" if $bf_ptr == 1; 
204355714Skrisprint "BF_PTR2 used\n" if $bf_ptr == 2; 
204455714Skris
2045160814Ssimonif($IsMK1MF) {
204655714Skris	open (OUT,">crypto/buildinf.h") || die "Can't open buildinf.h";
204755714Skris	printf OUT <<EOF;
204855714Skris#ifndef MK1MF_BUILD
204955714Skris  /* auto-generated by Configure for crypto/cversion.c:
2050160814Ssimon   * for Unix builds, crypto/Makefile.ssl generates functional definitions;
205155714Skris   * Windows builds (and other mk1mf builds) compile cversion.c with
205255714Skris   * -DMK1MF_BUILD and use definitions added to this file by util/mk1mf.pl. */
205355714Skris  #error "Windows builds (PLATFORM=$target) use mk1mf.pl-created Makefiles"
205455714Skris#endif
205555714SkrisEOF
205655714Skris	close(OUT);
205755714Skris} else {
2058205128Ssimon	my $make_command = "$make PERL=\'$perl\'";
2059325335Sjkim	my @make_targets = ();
2060325335Sjkim	push @make_targets, "links" if $symlink;
2061325335Sjkim	push @make_targets, "depend" if $depflags ne $default_depflags && $make_depend;
2062325335Sjkim	push @make_targets, "gentests" if $symlink;
2063325335Sjkim	foreach my $make_target (@make_targets) {
2064325335Sjkim	    (system "$make_command $make_target") == 0 or exit $?;
2065325335Sjkim	}
206655714Skris	if ( $perl =~ m@^/@) {
2067215697Ssimon	    &dofile("tools/c_rehash",$perl,'^#!/', '#!%s','^my \$dir;$', 'my $dir = "' . $openssldir . '";', '^my \$prefix;$', 'my $prefix = "' . $prefix . '";');
206859191Skris	    &dofile("apps/CA.pl",$perl,'^#!/', '#!%s');
206955714Skris	} else {
207055714Skris	    # No path for Perl known ...
2071215697Ssimon	    &dofile("tools/c_rehash",'/usr/local/bin/perl','^#!/', '#!%s','^my \$dir;$', 'my $dir = "' . $openssldir . '";',  '^my \$prefix;$', 'my $prefix = "' . $prefix . '";');
207259191Skris	    &dofile("apps/CA.pl",'/usr/local/bin/perl','^#!/', '#!%s');
2073109998Smarkm	}
2074160814Ssimon	if ($depflags ne $default_depflags && !$make_depend) {
2075325335Sjkim	    $warn_make_depend++;
2076325335Sjkim	}
207755714Skris}
207855714Skris
2079160814Ssimon# create the ms/version32.rc file if needed
2080194206Ssimonif ($IsMK1MF && ($target !~ /^netware/)) {
2081160814Ssimon	my ($v1, $v2, $v3, $v4);
2082160814Ssimon	if ($version_num =~ /(^[0-9a-f]{1})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})/i) {
2083160814Ssimon		$v1=hex $1;
2084160814Ssimon		$v2=hex $2;
2085160814Ssimon		$v3=hex $3;
2086160814Ssimon		$v4=hex $4;
2087160814Ssimon	}
2088160814Ssimon	open (OUT,">ms/version32.rc") || die "Can't open ms/version32.rc";
2089160814Ssimon	print OUT <<EOF;
2090160814Ssimon#include <winver.h>
2091160814Ssimon
2092160814SsimonLANGUAGE 0x09,0x01
2093160814Ssimon
2094160814Ssimon1 VERSIONINFO
2095160814Ssimon  FILEVERSION $v1,$v2,$v3,$v4
2096160814Ssimon  PRODUCTVERSION $v1,$v2,$v3,$v4
2097160814Ssimon  FILEFLAGSMASK 0x3fL
2098160814Ssimon#ifdef _DEBUG
2099160814Ssimon  FILEFLAGS 0x01L
2100160814Ssimon#else
2101160814Ssimon  FILEFLAGS 0x00L
2102160814Ssimon#endif
2103160814Ssimon  FILEOS VOS__WINDOWS32
2104160814Ssimon  FILETYPE VFT_DLL
2105160814Ssimon  FILESUBTYPE 0x0L
2106160814SsimonBEGIN
2107160814Ssimon    BLOCK "StringFileInfo"
2108160814Ssimon    BEGIN
2109160814Ssimon	BLOCK "040904b0"
2110160814Ssimon	BEGIN
2111160814Ssimon	    // Required:	    
2112160814Ssimon	    VALUE "CompanyName", "The OpenSSL Project, http://www.openssl.org/\\0"
2113160814Ssimon	    VALUE "FileDescription", "OpenSSL Shared Library\\0"
2114160814Ssimon	    VALUE "FileVersion", "$version\\0"
2115160814Ssimon#if defined(CRYPTO)
2116160814Ssimon	    VALUE "InternalName", "libeay32\\0"
2117160814Ssimon	    VALUE "OriginalFilename", "libeay32.dll\\0"
2118160814Ssimon#elif defined(SSL)
2119160814Ssimon	    VALUE "InternalName", "ssleay32\\0"
2120160814Ssimon	    VALUE "OriginalFilename", "ssleay32.dll\\0"
2121160814Ssimon#endif
2122160814Ssimon	    VALUE "ProductName", "The OpenSSL Toolkit\\0"
2123160814Ssimon	    VALUE "ProductVersion", "$version\\0"
2124160814Ssimon	    // Optional:
2125160814Ssimon	    //VALUE "Comments", "\\0"
2126290207Sjkim	    VALUE "LegalCopyright", "Copyright  � 1998-2005 The OpenSSL Project. Copyright � 1995-1998 Eric A. Young, Tim J. Hudson. All rights reserved.\\0"
2127160814Ssimon	    //VALUE "LegalTrademarks", "\\0"
2128160814Ssimon	    //VALUE "PrivateBuild", "\\0"
2129160814Ssimon	    //VALUE "SpecialBuild", "\\0"
2130160814Ssimon	END
2131160814Ssimon    END
2132160814Ssimon    BLOCK "VarFileInfo"
2133160814Ssimon    BEGIN
2134160814Ssimon        VALUE "Translation", 0x409, 0x4b0
2135160814Ssimon    END
2136160814SsimonEND
2137160814SsimonEOF
2138160814Ssimon	close(OUT);
2139160814Ssimon  }
2140160814Ssimon  
214155714Skrisprint <<EOF;
214255714Skris
214359191SkrisConfigured for $target.
214455714SkrisEOF
214555714Skris
214655714Skrisprint <<\EOF if (!$no_threads && !$threads);
214755714Skris
214855714SkrisThe library could not be configured for supporting multi-threaded
214955714Skrisapplications as the compiler options required on this system are not known.
215055714SkrisSee file INSTALL for details if you need multi-threading.
215155714SkrisEOF
215255714Skris
2153111147Snectarprint <<\EOF if ($no_shared_warn);
2154111147Snectar
2155295009SjkimYou gave the option 'shared', which is not supported on this platform, so
2156295009Sjkimwe will pretend you gave the option 'no-shared'.  If you know how to implement
2157295009Sjkimshared libraries, please let us know (but please first make sure you have
2158295009Sjkimtried with a current version of OpenSSL).
2159111147SnectarEOF
2160111147Snectar
2161295009Sjkimprint <<EOF if ($warn_make_depend);
2162295009Sjkim
2163295009Sjkim*** Because of configuration changes, you MUST do the following before
2164295009Sjkim*** building:
2165295009Sjkim
2166295009Sjkim	make depend
2167295009SjkimEOF
2168295009Sjkim
216955714Skrisexit(0);
217055714Skris
217155714Skrissub usage
217255714Skris	{
217355714Skris	print STDERR $usage;
217459191Skris	print STDERR "\npick os/compiler from:\n";
217555714Skris	my $j=0;
217655714Skris	my $i;
217759191Skris        my $k=0;
217855714Skris	foreach $i (sort keys %table)
217955714Skris		{
218055714Skris		next if $i =~ /^debug/;
218159191Skris		$k += length($i) + 1;
218259191Skris		if ($k > 78)
218359191Skris			{
218459191Skris			print STDERR "\n";
218559191Skris			$k=length($i);
218659191Skris			}
218759191Skris		print STDERR $i . " ";
218855714Skris		}
218955714Skris	foreach $i (sort keys %table)
219055714Skris		{
219155714Skris		next if $i !~ /^debug/;
219259191Skris		$k += length($i) + 1;
219359191Skris		if ($k > 78)
219459191Skris			{
219559191Skris			print STDERR "\n";
219659191Skris			$k=length($i);
219759191Skris			}
219859191Skris		print STDERR $i . " ";
219955714Skris		}
220059191Skris	print STDERR "\n\nNOTE: If in doubt, on Unix-ish systems use './config'.\n";
220155714Skris	exit(1);
220255714Skris	}
220355714Skris
220455714Skrissub which
220555714Skris	{
220655714Skris	my($name)=@_;
220755714Skris	my $path;
220855714Skris	foreach $path (split /:/, $ENV{PATH})
220955714Skris		{
2210142425Snectar		if (-f "$path/$name$exe_ext" and -x _)
221155714Skris			{
2212142425Snectar			return "$path/$name$exe_ext" unless ($name eq "perl" and
2213142425Snectar			 system("$path/$name$exe_ext -e " . '\'exit($]<5.0);\''));
221455714Skris			}
221555714Skris		}
221655714Skris	}
221755714Skris
221855714Skrissub dofile
221955714Skris	{
222055714Skris	my $f; my $p; my %m; my @a; my $k; my $ff;
222155714Skris	($f,$p,%m)=@_;
222255714Skris
222355714Skris	open(IN,"<$f.in") || open(IN,"<$f") || die "unable to open $f:$!\n";
222455714Skris	@a=<IN>;
222555714Skris	close(IN);
222655714Skris	foreach $k (keys %m)
222755714Skris		{
222855714Skris		grep(/$k/ && ($_=sprintf($m{$k}."\n",$p)),@a);
222955714Skris		}
223059191Skris	open(OUT,">$f.new") || die "unable to open $f.new:$!\n";
223155714Skris	print OUT @a;
223255714Skris	close(OUT);
223359191Skris	rename($f,"$f.bak") || die "unable to rename $f\n" if -e $f;
223459191Skris	rename("$f.new",$f) || die "unable to rename $f.new\n";
223555714Skris	}
223655714Skris
223755714Skrissub print_table_entry
223855714Skris	{
223955714Skris	my $target = shift;
224055714Skris
2241290207Sjkim	my ($cc, $cflags, $unistd, $thread_cflag, $sys_id, $lflags,
2242290207Sjkim	    $bn_ops, $cpuid_obj, $bn_obj, $ec_obj, $des_obj, $aes_obj, $bf_obj,
2243290207Sjkim	    $md5_obj, $sha1_obj, $cast_obj, $rc4_obj, $rmd160_obj,
2244290207Sjkim	    $rc5_obj, $wp_obj, $cmll_obj, $modes_obj, $engines_obj,
2245290207Sjkim	    $perlasm_scheme, $dso_scheme, $shared_target, $shared_cflag,
2246290207Sjkim	    $shared_ldflag, $shared_extension, $ranlib, $arflags, $multilib)=
224776866Skris	split(/\s*:\s*/,$table{$target} . ":" x 30 , -1);
224855714Skris			
224955714Skris	print <<EOF
225055714Skris
225155714Skris*** $target
225255714Skris\$cc           = $cc
225355714Skris\$cflags       = $cflags
225455714Skris\$unistd       = $unistd
225555714Skris\$thread_cflag = $thread_cflag
2256109998Smarkm\$sys_id       = $sys_id
225755714Skris\$lflags       = $lflags
225855714Skris\$bn_ops       = $bn_ops
2259160814Ssimon\$cpuid_obj    = $cpuid_obj
226055714Skris\$bn_obj       = $bn_obj
2261290207Sjkim\$ec_obj       = $ec_obj
226255714Skris\$des_obj      = $des_obj
2263160814Ssimon\$aes_obj      = $aes_obj
226455714Skris\$bf_obj       = $bf_obj
226555714Skris\$md5_obj      = $md5_obj
226655714Skris\$sha1_obj     = $sha1_obj
226755714Skris\$cast_obj     = $cast_obj
226855714Skris\$rc4_obj      = $rc4_obj
226955714Skris\$rmd160_obj   = $rmd160_obj
227055714Skris\$rc5_obj      = $rc5_obj
2271238405Sjkim\$wp_obj       = $wp_obj
2272238405Sjkim\$cmll_obj     = $cmll_obj
2273238405Sjkim\$modes_obj    = $modes_obj
2274238405Sjkim\$engines_obj  = $engines_obj
2275238405Sjkim\$perlasm_scheme = $perlasm_scheme
227668651Skris\$dso_scheme   = $dso_scheme
227768651Skris\$shared_target= $shared_target
227868651Skris\$shared_cflag = $shared_cflag
2279100928Snectar\$shared_ldflag = $shared_ldflag
228076866Skris\$shared_extension = $shared_extension
228176866Skris\$ranlib       = $ranlib
2282109998Smarkm\$arflags      = $arflags
2283238405Sjkim\$multilib     = $multilib
228455714SkrisEOF
228555714Skris	}
2286100928Snectar
2287100928Snectarsub test_sanity
2288100928Snectar	{
2289100928Snectar	my $errorcnt = 0;
2290100928Snectar
2291100928Snectar	print STDERR "=" x 70, "\n";
2292100928Snectar	print STDERR "=== SANITY TESTING!\n";
2293100928Snectar	print STDERR "=== No configuration will be done, all other arguments will be ignored!\n";
2294100928Snectar	print STDERR "=" x 70, "\n";
2295100928Snectar
2296100928Snectar	foreach $target (sort keys %table)
2297100928Snectar		{
2298100928Snectar		@fields = split(/\s*:\s*/,$table{$target} . ":" x 30 , -1);
2299100928Snectar
2300238405Sjkim		if ($fields[$idx_dso_scheme-1] =~ /^(beos|dl|dlfcn|win32|vms)$/)
2301100928Snectar			{
2302100928Snectar			$errorcnt++;
2303100928Snectar			print STDERR "SANITY ERROR: '$target' has the dso_scheme [$idx_dso_scheme] values\n";
2304100928Snectar			print STDERR "              in the previous field\n";
2305100928Snectar			}
2306238405Sjkim		elsif ($fields[$idx_dso_scheme+1] =~ /^(beos|dl|dlfcn|win32|vms)$/)
2307100928Snectar			{
2308100928Snectar			$errorcnt++;
2309100928Snectar			print STDERR "SANITY ERROR: '$target' has the dso_scheme [$idx_dso_scheme] values\n";
2310100928Snectar			print STDERR "              in the following field\n";
2311100928Snectar			}
2312238405Sjkim		elsif ($fields[$idx_dso_scheme] !~ /^(beos|dl|dlfcn|win32|vms|)$/)
2313100928Snectar			{
2314100928Snectar			$errorcnt++;
2315100928Snectar			print STDERR "SANITY ERROR: '$target' has the dso_scheme [$idx_dso_scheme] field = ",$fields[$idx_dso_scheme],"\n";
2316238405Sjkim			print STDERR "              valid values are 'beos', 'dl', 'dlfcn', 'win32' and 'vms'\n";
2317100928Snectar			}
2318100928Snectar		}
2319100928Snectar	print STDERR "No sanity errors detected!\n" if $errorcnt == 0;
2320100928Snectar	return $errorcnt;
2321100928Snectar	}
2322312826Sjkim
2323312826Sjkimsub file_newer
2324312826Sjkim	{
2325312826Sjkim	my ($file1, $file2) = @_;
2326312826Sjkim	return (stat($file1))[9] > (stat($file2))[9]
2327312826Sjkim	}
2328