Configure 71 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423
  1. #! /usr/bin/env perl
  2. # -*- mode: perl; -*-
  3. ##
  4. ## Configure -- OpenSSL source tree configuration script
  5. ## If editing this file, run this command before committing
  6. ## make -f Makefile.org TABLE
  7. ##
  8. require 5.000;
  9. use strict;
  10. use File::Basename;
  11. use File::Spec::Functions;
  12. # see INSTALL for instructions.
  13. my $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] [sctp] [386] [--prefix=DIR] [--openssldir=OPENSSLDIR] [--with-xxx[=vvv]] [--test-sanity] [--config=FILE] os/compiler[:flags]\n";
  14. # Options:
  15. #
  16. # --config add the given configuration file, which will be read after
  17. # any "Configurations*" files that are found in the same
  18. # directory as this script.
  19. # --openssldir install OpenSSL in OPENSSLDIR (Default: DIR/ssl if the
  20. # --prefix option is given; /usr/local/ssl otherwise)
  21. # --prefix prefix for the OpenSSL include, lib and bin directories
  22. # (Default: the OPENSSLDIR directory)
  23. #
  24. # --install_prefix Additional prefix for package builders (empty by
  25. # default). This needn't be set in advance, you can
  26. # just as well use "make INSTALL_PREFIX=/whatever install".
  27. #
  28. # --test-sanity Make a number of sanity checks on the data in this file.
  29. # This is a debugging tool for OpenSSL developers.
  30. #
  31. # --cross-compile-prefix Add specified prefix to binutils components.
  32. #
  33. # no-hw-xxx do not compile support for specific crypto hardware.
  34. # Generic OpenSSL-style methods relating to this support
  35. # are always compiled but return NULL if the hardware
  36. # support isn't compiled.
  37. # no-hw do not compile support for any crypto hardware.
  38. # [no-]threads [don't] try to create a library that is suitable for
  39. # multithreaded applications (default is "threads" if we
  40. # know how to do it)
  41. # [no-]shared [don't] try to create shared libraries when supported.
  42. # no-asm do not use assembler
  43. # no-dso do not compile in any native shared-library methods. This
  44. # will ensure that all methods just return NULL.
  45. # [no-]zlib [don't] compile support for zlib compression.
  46. # zlib-dynamic Like "zlib", but the zlib library is expected to be a shared
  47. # library and will be loaded in run-time by the OpenSSL library.
  48. # sctp include SCTP support
  49. # 386 generate 80386 code
  50. # no-sse2 disables IA-32 SSE2 code, above option implies no-sse2
  51. # no-<cipher> build without specified algorithm (rsa, idea, rc5, ...)
  52. # -<xxx> +<xxx> compiler options are passed through
  53. #
  54. # DEBUG_SAFESTACK use type-safe stacks to enforce type-safety on stack items
  55. # provided to stack calls. Generates unique stack functions for
  56. # each possible stack type.
  57. # DES_PTR use pointer lookup vs arrays in the DES in crypto/des/des_locl.h
  58. # DES_RISC1 use different DES_ENCRYPT macro that helps reduce register
  59. # dependancies but needs to more registers, good for RISC CPU's
  60. # DES_RISC2 A different RISC variant.
  61. # DES_UNROLL unroll the inner DES loop, sometimes helps, somtimes hinders.
  62. # DES_INT use 'int' instead of 'long' for DES_LONG in crypto/des/des.h
  63. # This is used on the DEC Alpha where long is 8 bytes
  64. # and int is 4
  65. # BN_LLONG use the type 'long long' in crypto/bn/bn.h
  66. # MD2_CHAR use 'char' instead of 'int' for MD2_INT in crypto/md2/md2.h
  67. # MD2_LONG use 'long' instead of 'int' for MD2_INT in crypto/md2/md2.h
  68. # IDEA_SHORT use 'short' instead of 'int' for IDEA_INT in crypto/idea/idea.h
  69. # IDEA_LONG use 'long' instead of 'int' for IDEA_INT in crypto/idea/idea.h
  70. # RC2_SHORT use 'short' instead of 'int' for RC2_INT in crypto/rc2/rc2.h
  71. # RC2_LONG use 'long' instead of 'int' for RC2_INT in crypto/rc2/rc2.h
  72. # RC4_CHAR use 'char' instead of 'int' for RC4_INT in crypto/rc4/rc4.h
  73. # RC4_LONG use 'long' instead of 'int' for RC4_INT in crypto/rc4/rc4.h
  74. # RC4_INDEX define RC4_INDEX in crypto/rc4/rc4_locl.h. This turns on
  75. # array lookups instead of pointer use.
  76. # RC4_CHUNK enables code that handles data aligned at long (natural CPU
  77. # word) boundary.
  78. # RC4_CHUNK_LL enables code that handles data aligned at long long boundary
  79. # (intended for 64-bit CPUs running 32-bit OS).
  80. # BF_PTR use 'pointer arithmatic' for Blowfish (unsafe on Alpha).
  81. # BF_PTR2 intel specific version (generic version is more efficient).
  82. #
  83. # Following are set automatically by this script
  84. #
  85. # MD5_ASM use some extra md5 assember,
  86. # SHA1_ASM use some extra sha1 assember, must define L_ENDIAN for x86
  87. # RMD160_ASM use some extra ripemd160 assember,
  88. # SHA256_ASM sha256_block is implemented in assembler
  89. # SHA512_ASM sha512_block is implemented in assembler
  90. # AES_ASM ASE_[en|de]crypt is implemented in assembler
  91. # Minimum warning options... any contributions to OpenSSL should at least get
  92. # past these.
  93. my $gcc_devteam_warn = "-Wall -pedantic -DPEDANTIC -Wno-long-long -Wsign-compare -Wmissing-prototypes -Wshadow -Wformat -Wtype-limits -Werror -DCRYPTO_MDEBUG_ALL -DCRYPTO_MDEBUG_ABORT -DREF_CHECK -DDEBUG_UNUSED";
  94. # These are used in addition to $gcc_devteam_warn when the compiler is clang.
  95. # TODO(openssl-team): fix problems and investigate if (at least) the
  96. # following warnings can also be enabled:
  97. # -Wswitch-enum, -Wunused-macros, -Wmissing-field-initializers,
  98. # -Wcast-align,
  99. # -Wunreachable-code -Wunused-parameter -Wlanguage-extension-token
  100. # -Wextended-offsetof
  101. my $clang_devteam_warn = "-Wno-unused-parameter -Wno-missing-field-initializers -Wno-language-extension-token -Wno-extended-offsetof -Wconditional-uninitialized -Qunused-arguments -Wincompatible-pointer-types-discards-qualifiers -Wmissing-variable-declarations";
  102. # These are used in addition to $gcc_devteam_warn unless this is a mingw build.
  103. # This adds backtrace information to the memory leak info.
  104. my $memleak_devteam_backtrace = "-rdynamic -DCRYPTO_MDEBUG_BACKTRACE";
  105. my $strict_warnings = 0;
  106. my $x86_gcc_des="DES_PTR DES_RISC1 DES_UNROLL";
  107. # MD2_CHAR slags pentium pros
  108. my $x86_gcc_opts="RC4_INDEX MD2_INT";
  109. #$bits1="SIXTEEN_BIT ";
  110. #$bits2="THIRTY_TWO_BIT ";
  111. my $bits1="THIRTY_TWO_BIT ";
  112. my $bits2="SIXTY_FOUR_BIT ";
  113. # As for $BSDthreads. Idea is to maintain "collective" set of flags,
  114. # which would cover all BSD flavors. -pthread applies to them all,
  115. # but is treated differently. OpenBSD expands is as -D_POSIX_THREAD
  116. # -lc_r, which is sufficient. FreeBSD 4.x expands it as -lc_r,
  117. # which has to be accompanied by explicit -D_THREAD_SAFE and
  118. # sometimes -D_REENTRANT. FreeBSD 5.x expands it as -lc_r, which
  119. # seems to be sufficient?
  120. my $BSDthreads="-pthread -D_THREAD_SAFE -D_REENTRANT";
  121. # table of known configurations, read in from files
  122. #
  123. # The content of each entry can take one of two forms:
  124. #
  125. # - old style config-string, colon seperated fields with exactly the
  126. # following structure.:
  127. #
  128. # $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 : $perlasm_scheme : $dso_scheme : $shared_target : $shared_cflag : $shared_ldflag : $shared_extension : $ranlib : $arflags : $multilib
  129. #
  130. # We use the stringtohash function - defined below - to combine with the
  131. # fields and form a proper hash table from the string.
  132. #
  133. # - direct transfer of old style config string to hash table, using the names
  134. # of the fields as keys:
  135. #
  136. # {
  137. # cc => $cc,
  138. # cflags => $cflags,
  139. # unistd => $unistd,
  140. # thread_cflag => $thread_cflag,
  141. # sys_id => $sys_id,
  142. # lflags => $lflags,
  143. # bn_ops => $bn_ops,
  144. # cpuid_obj => $cpuid_obj,
  145. # bn_obj => $bn_obj,
  146. # ec_obj => $ec_obj,
  147. # des_obj => $des_obj,
  148. # aes_obj => $aes_obj,
  149. # bf_obj => $bf_obj,
  150. # md5_obj => $md5_obj,
  151. # sha1_obj => $sha1_obj,
  152. # cast_obj => $cast_obj,
  153. # rc4_obj => $rc4_obj,
  154. # rmd160_obj => $rmd160_obj,
  155. # rc5_obj => $rc5_obj,
  156. # wp_obj => $wp_obj,
  157. # cmll_obj => $cmll_obj,
  158. # modes_obj => $modes_obj,
  159. # engines_obj => $engines_obj,
  160. # perlasm_scheme => $perlasm_scheme,
  161. # dso_scheme => $dso_scheme,
  162. # shared_target => $shared_target,
  163. # shared_cflag => $shared_cflag,
  164. # shared_ldflag => $shared_ldflag,
  165. # shared_extension => $shared_extension,
  166. # ranlib => $ranlib,
  167. # arflags => $arflags,
  168. # multilib => $multilib
  169. # }
  170. #
  171. # - new style config hash table, which has additional attributes for debug
  172. # and non-debug flags to be added to the common flags, for cflags and lflags:
  173. #
  174. # {
  175. # cc => $cc,
  176. # cflags => $cflags,
  177. # debug_cflags => $debug_cflags,
  178. # release_cflags => $release_cflags,
  179. # unistd => $unistd,
  180. # thread_cflag => $thread_cflag,
  181. # sys_id => $sys_id,
  182. # lflags => $lflags,
  183. # debug_lflags => $debug_lflags,
  184. # release_lflags => $release_lflags,
  185. # bn_ops => $bn_ops,
  186. # cpuid_obj => $cpuid_obj,
  187. # bn_obj => $bn_obj,
  188. # ec_obj => $ec_obj,
  189. # des_obj => $des_obj,
  190. # aes_obj => $aes_obj,
  191. # bf_obj => $bf_obj,
  192. # md5_obj => $md5_obj,
  193. # sha1_obj => $sha1_obj,
  194. # cast_obj => $cast_obj,
  195. # rc4_obj => $rc4_obj,
  196. # rmd160_obj => $rmd160_obj,
  197. # rc5_obj => $rc5_obj,
  198. # wp_obj => $wp_obj,
  199. # cmll_obj => $cmll_obj,
  200. # modes_obj => $modes_obj,
  201. # engines_obj => $engines_obj,
  202. # dso_scheme => $dso_scheme,
  203. # shared_target => $shared_target,
  204. # shared_cflag => $shared_cflag,
  205. # shared_ldflag => $shared_ldflag,
  206. # shared_extension => $shared_extension,
  207. # ranlib => $ranlib,
  208. # arflags => $arflags,
  209. # multilib => $multilib
  210. # }
  211. #
  212. # The configuration reader will do what it can to translate everything into
  213. # new style config hash tables, including merging $target and debug-$target
  214. # if they are similar enough.
  215. #
  216. # The configuration hashes can refer to templates in two different manners:
  217. #
  218. # - as part of the hash, one can have a key called 'inherit_from' that
  219. # indicate what other configuration hashes to inherit data from.
  220. # These are resolved recursively.
  221. #
  222. # Inheritance works as a set of default values that can be overriden
  223. # by corresponding attribute values in the inheriting configuration.
  224. #
  225. # If several configurations are given in the 'inherit_from' array, the
  226. # values of same attribute are concatenated with space separation.
  227. # With this, it's possible to have several smaller templates for
  228. # different configuration aspects that can be combined into a complete
  229. # configuration.
  230. #
  231. # Example:
  232. #
  233. # "foo" => {
  234. # template => 1,
  235. # haha => "haha",
  236. # hoho => "ho"
  237. # },
  238. # "bar" => {
  239. # template => 1,
  240. # hoho => "ho",
  241. # hehe => "hehe"
  242. # },
  243. # "laughter" => {
  244. # inherit_from => [ "foo", "bar" ],
  245. # }
  246. #
  247. # The entry for "foo" will become as follows after processing:
  248. #
  249. # "laughter" => {
  250. # haha => "haha",
  251. # hoho => "ho ho",
  252. # hehe => "hehe"
  253. # }
  254. #
  255. # Note 1: any entry from the table can be used as a template.
  256. # Note 2: pure templates have the attribute 'template => 1' and cannot
  257. # be used as targets.
  258. #
  259. # - instead of a string, one can have a code block of the form
  260. # 'sub { /* your code here */ }', where the arguments are the list of
  261. # inherited values for that key. In fact, the concatenation of strings
  262. # is really done by using 'sub { join(" ",@_) }' on the list of inherited
  263. # values.
  264. #
  265. # Example:
  266. #
  267. # "foo" => {
  268. # template => 1,
  269. # haha => "ha ha",
  270. # hoho => "ho",
  271. # ignored => "This should not appear in the end result",
  272. # },
  273. # "bar" => {
  274. # template => 1,
  275. # haha => "ah",
  276. # hoho => "haho",
  277. # hehe => "hehe"
  278. # },
  279. # "laughter" => {
  280. # inherit_from => [ "foo", "bar" ],
  281. # hehe => sub { join(" ",(@_,"!!!")) },
  282. # ignored => "",
  283. # }
  284. #
  285. # The entry for "foo" will become as follows after processing:
  286. #
  287. # "laughter" => {
  288. # haha => "ha ha ah",
  289. # hoho => "ho haho",
  290. # hehe => "hehe !!!",
  291. # ignored => ""
  292. # }
  293. #
  294. my %table=(
  295. # All these templates are merely a translation of the corresponding
  296. # variables further up.
  297. #
  298. # Note: as long as someone might use old style configuration strings,
  299. # or we bother supporting that, those variables need to stay
  300. x86_asm => {
  301. template => 1,
  302. cpuid_obj => "x86cpuid.o",
  303. bn_obj => "bn-586.o co-586.o x86-mont.o x86-gf2m.o",
  304. ec_obj => "ecp_nistz256.o ecp_nistz256-x86.o",
  305. des_obj => "des-586.o crypt586.o",
  306. aes_obj => "aes-586.o vpaes-x86.o aesni-x86.o",
  307. bf_obj => "bf-586.o",
  308. md5_obj => "md5-586.o",
  309. sha1_obj => "sha1-586.o sha256-586.o sha512-586.o",
  310. rc4_obj => "rc4-586.o",
  311. rmd160_obj => "rmd-586.o",
  312. rc5_obj => "rc5-586.o",
  313. wp_obj => "wp_block.o wp-mmx.o",
  314. cmll_obj => "cmll-x86.o",
  315. modes_obj => "ghash-x86.o",
  316. engines_obj => "e_padlock-x86.o"
  317. },
  318. x86_elf_asm => {
  319. template => 1,
  320. inherit_from => [ "x86_asm" ],
  321. perlasm_scheme => "elf"
  322. },
  323. x86_64_asm => {
  324. template => 1,
  325. cpuid_obj => "x86_64cpuid.o",
  326. bn_obj => "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",
  327. ec_obj => "ecp_nistz256.o ecp_nistz256-x86_64.o",
  328. aes_obj => "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",
  329. md5_obj => "md5-x86_64.o",
  330. sha1_obj => "sha1-x86_64.o sha256-x86_64.o sha512-x86_64.o sha1-mb-x86_64.o sha256-mb-x86_64.o",
  331. rc4_obj => "rc4-x86_64.o rc4-md5-x86_64.o",
  332. wp_obj => "wp-x86_64.o",
  333. cmll_obj => "cmll-x86_64.o cmll_misc.o",
  334. modes_obj => "ghash-x86_64.o aesni-gcm-x86_64.o",
  335. engines_obj => "e_padlock-x86_64.o"
  336. },
  337. ia64_asm => {
  338. template => 1,
  339. cpuid_obj => "ia64cpuid.o",
  340. bn_obj => "bn-ia64.o ia64-mont.o",
  341. aes_obj => "aes_core.o aes_cbc.o aes-ia64.o",
  342. md5_obj => "md5-ia64.o",
  343. sha1_obj => "sha1-ia64.o sha256-ia64.o sha512-ia64.o",
  344. rc4_obj => "rc4-ia64.o rc4_skey.o",
  345. modes_obj => "ghash-ia64.o",
  346. perlasm_scheme => "void"
  347. },
  348. sparcv9_asm => {
  349. template => 1,
  350. cpuid_obj => "sparcv9cap.o sparccpuid.o",
  351. bn_obj => "bn-sparcv9.o sparcv9-mont.o sparcv9a-mont.o vis3-mont.o sparct4-mont.o sparcv9-gf2m.o",
  352. ec_obj => "ecp_nistz256.o ecp_nistz256-sparcv9.o",
  353. des_obj => "des_enc-sparc.o fcrypt_b.o dest4-sparcv9.o",
  354. aes_obj => "aes_core.o aes_cbc.o aes-sparcv9.o aest4-sparcv9.o",
  355. md5_obj => "md5-sparcv9.o",
  356. sha1_obj => "sha1-sparcv9.o sha256-sparcv9.o sha512-sparcv9.o",
  357. cmll_obj => "camellia.o cmll_misc.o cmll_cbc.o cmllt4-sparcv9.o",
  358. modes_obj => "ghash-sparcv9.o",
  359. perlasm_scheme => "void"
  360. },
  361. sparcv8_asm => {
  362. template => 1,
  363. cpuid_obj => "",
  364. bn_obj => "sparcv8.o",
  365. des_obj => "des_enc-sparc.o fcrypt_b.o",
  366. perlasm_scheme => "void"
  367. },
  368. alpha_asm => {
  369. template => 1,
  370. cpuid_obj => "alphacpuid.o",
  371. bn_obj => "bn_asm.o alpha-mont.o",
  372. sha1_obj => "sha1-alpha.o",
  373. modes_obj => "ghash-alpha.o",
  374. perlasm_scheme => "void"
  375. },
  376. mips32_asm => {
  377. template => 1,
  378. bn_obj => "bn-mips.o mips-mont.o",
  379. aes_obj => "aes_cbc.o aes-mips.o",
  380. sha1_obj => "sha1-mips.o sha256-mips.o",
  381. },
  382. mips64_asm => {
  383. inherit_from => [ "mips32_asm" ],
  384. template => 1,
  385. sha1_obj => sub { join(" ", @_, "sha512-mips.o") }
  386. },
  387. s390x_asm => {
  388. template => 1,
  389. cpuid_obj => "s390xcap.o s390xcpuid.o",
  390. bn_obj => "bn-s390x.o s390x-mont.o s390x-gf2m.o",
  391. aes_obj => "aes-s390x.o aes-ctr.o aes-xts.o",
  392. sha1_obj => "sha1-s390x.o sha256-s390x.o sha512-s390x.o",
  393. rc4_obj => "rc4-s390x.o",
  394. modes_obj => "ghash-s390x.o",
  395. },
  396. armv4_asm => {
  397. template => 1,
  398. cpuid_obj => "armcap.o armv4cpuid.o",
  399. bn_obj => "bn_asm.o armv4-mont.o armv4-gf2m.o",
  400. ec_obj => "ecp_nistz256.o ecp_nistz256-armv4.o",
  401. aes_obj => "aes_cbc.o aes-armv4.o bsaes-armv7.o aesv8-armx.o",
  402. sha1_obj => "sha1-armv4-large.o sha256-armv4.o sha512-armv4.o",
  403. modes_obj => "ghash-armv4.o ghashv8-armx.o",
  404. perlasm_scheme => "void"
  405. },
  406. aarch64_asm => {
  407. template => 1,
  408. cpuid_obj => "armcap.o arm64cpuid.o mem_clr.o",
  409. ec_obj => "ecp_nistz256.o ecp_nistz256-armv8.o",
  410. bn_obj => "bn_asm.o armv8-mont.o",
  411. aes_obj => "aes_core.o aes_cbc.o aesv8-armx.o vpaes-armv8.o",
  412. sha1_obj => "sha1-armv8.o sha256-armv8.o sha512-armv8.o",
  413. modes_obj => "ghashv8-armx.o",
  414. },
  415. parisc11_asm => {
  416. template => 1,
  417. cpuid_obj => "pariscid.o",
  418. bn_obj => "bn_asm.o parisc-mont.o",
  419. aes_obj => "aes_core.o aes_cbc.o aes-parisc.o",
  420. sha1_obj => "sha1-parisc.o sha256-parisc.o sha512-parisc.o",
  421. rc4_obj => "rc4-parisc.o",
  422. modes_obj => "ghash-parisc.o",
  423. perlasm_scheme => "32"
  424. },
  425. parisc20_64_asm => {
  426. template => 1,
  427. inherit_from => [ "parisc11_asm" ],
  428. bn_obj => sub { my $r=join(" ",@_); $r=~s/bn_asm/pa-risc2W/; $r; },
  429. perlasm_scheme => "64",
  430. },
  431. ppc64_asm => {
  432. template => 1,
  433. cpuid_obj => "ppccpuid.o ppccap.o",
  434. bn_obj => "bn-ppc.o ppc-mont.o ppc64-mont.o",
  435. aes_obj => "aes_core.o aes_cbc.o aes-ppc.o vpaes-ppc.o aesp8-ppc.o",
  436. sha1_obj => "sha1-ppc.o sha256-ppc.o sha512-ppc.o sha256p8-ppc.o sha512p8-ppc.o",
  437. modes_obj => "ghashp8-ppc.o",
  438. },
  439. ppc32_asm => {
  440. inherit_from => [ "ppc64_asm" ],
  441. template => 1
  442. },
  443. );
  444. { my $no_asm_templates=0;
  445. foreach (@ARGV) { $no_asm_templates=1 if (/^\-?no\-asm$/); }
  446. sub asm { $no_asm_templates?():@_; }
  447. }
  448. sub stringtohash {
  449. my $in = shift @_;
  450. if (ref($in) eq "HASH") {
  451. return $in;
  452. }
  453. my @stringsequence = (
  454. "cc",
  455. "cflags",
  456. "unistd",
  457. "thread_cflag",
  458. "sys_id",
  459. "lflags",
  460. "bn_ops",
  461. "cpuid_obj",
  462. "bn_obj",
  463. "ec_obj",
  464. "des_obj",
  465. "aes_obj",
  466. "bf_obj",
  467. "md5_obj",
  468. "sha1_obj",
  469. "cast_obj",
  470. "rc4_obj",
  471. "rmd160_obj",
  472. "rc5_obj",
  473. "wp_obj",
  474. "cmll_obj",
  475. "modes_obj",
  476. "engines_obj",
  477. "perlasm_scheme",
  478. "dso_scheme",
  479. "shared_target",
  480. "shared_cflag",
  481. "shared_ldflag",
  482. "shared_extension",
  483. "ranlib",
  484. "arflags",
  485. "multilib",
  486. );
  487. # return a ref to a hash, that's what the outer braces are for.
  488. return { map { shift @stringsequence => $_ } split /:/, $in };
  489. };
  490. # Read configuration target stanzas from a file, so that people can have
  491. # local files with their own definitions
  492. sub read_config {
  493. my $fname = shift;
  494. open(CONFFILE, "< $fname")
  495. or die "Can't open configuration file '$fname'!\n";
  496. my $x = $/;
  497. undef $/;
  498. my $content = <CONFFILE>;
  499. $/ = $x;
  500. close(CONFFILE);
  501. my %targets = ();
  502. eval $content;
  503. # Make sure we have debug- targets first
  504. my @keys =
  505. sort {
  506. my $a_nd = $a =~ m/^debug-/ ? $' :$a;
  507. my $b_nd = $b =~ m/^debug-/ ? $' :$b;
  508. my $res = 0;
  509. if (($a_nd == $a) == ($b_nd == $b)) {
  510. # they are both debug- or not, compare them as they are
  511. $res = $a cmp $b;
  512. } elsif ($a_nd != $a) {
  513. # $a is debug-, make it lesser
  514. $res = -1;
  515. } else {
  516. # $b is debug-, make $a greater
  517. $res = 1;
  518. }
  519. $res;
  520. } keys %targets;
  521. foreach (@keys) {
  522. if (ref($targets{$_}) ne "HASH") {
  523. # Value is assumed to be a string. Split it up to
  524. # become a hash table of parameters. Also, try to
  525. # merge debug- variants with the non-debug target.
  526. # Start with converting the value from a string to a
  527. # standardised hash of fields. Using $tohash is safe,
  528. # if the input is already a hash ref, it's just returned
  529. # back.
  530. $targets{$_} = stringtohash($targets{$_});
  531. # If the current target is a debug target, there might
  532. # be a corresponding non-debug target that we can merge
  533. # with. If it isn't a debug- target, we've already done
  534. # as much merging as we can and do not need to bother
  535. # with that any more.
  536. if ($_ =~ m/^debug-/) {
  537. my $debugkey = $_;
  538. my $nondebugkey = $';
  539. my $debug = $targets{$debugkey};
  540. my $nondebug;
  541. if ($targets{$nondebugkey}) {
  542. $nondebug = stringtohash($targets{$nondebugkey});
  543. }
  544. if ($nondebug) {
  545. # There's both a debug and non-debug variant of
  546. # this target, so we should try to merge them
  547. # together.
  548. # First, check that the non-debug variant isn't
  549. # already built up with all it should have.
  550. if ($nondebug->{debug_cflags}
  551. || $nondebug->{release_cflags}
  552. || $nondebug->{debug_lflags}
  553. || $nondebug->{release_lflags}) {
  554. warn "there's a debug target $debugkey to be merged with a target $nondebugkey, but the latter seems to already have both nodebug and debug information. This requires human intervention. Skipping $debugkey...";
  555. next;
  556. }
  557. # Now, check similarity.
  558. # For keys they have in common, support that
  559. # cflags and lflags can differ, otherwise they
  560. # must have exactly the same values for them
  561. # to be merged into one.
  562. my $similarenough = 1;
  563. for (keys %{$debug}) {
  564. if ($nondebug->{$_} ne $debug->{$_}
  565. && $_ !~ m/^[cl]flags$/) {
  566. $similarenough = 0;
  567. last;
  568. }
  569. }
  570. if ($similarenough) {
  571. # Here's where the magic happens, split the
  572. # options in the debug and non-debug variants
  573. # cflags and ldflags into three strings each,
  574. # one with common flags, one with extra debug
  575. # flags and one with extra non-debug flags.
  576. # The result ends up in %h_nondebug, which
  577. # becomes the merged variant when we're done.
  578. # for each of cflags and lflags, they are
  579. # replaced with cflags, debug_cflags,
  580. # release_cflags and similar for lflags.
  581. #
  582. # The purpose is that 'cflags' should be
  583. # used together with 'debug_cflags' or
  584. # 'release_cflags' depending on what the
  585. # user asks for.
  586. foreach (("cflags", "lflags")) {
  587. my @list_d = split /\s+/, $debug->{$_};
  588. my @list_nd = split /\s+/, $nondebug->{$_};
  589. my %presence = (); # bitmap
  590. # 1: present in @list_d
  591. # 2: present in @list_nd
  592. # 3: present in both
  593. map { $presence{$_} += 1; } @list_d;
  594. map { $presence{$_} += 2; } @list_nd;
  595. delete $nondebug->{$_};
  596. # Note: we build from the original lists to
  597. # preserve order, it might be important
  598. $nondebug->{"debug-".$_} =
  599. join(" ",
  600. grep { $presence{$_} == 1 } @list_d);
  601. $nondebug->{"nodebug-".$_} =
  602. join(" ",
  603. grep { $presence{$_} == 2 } @list_nd);
  604. $nondebug->{$_} =
  605. join(" ",
  606. grep { $presence{$_} == 3 } @list_d);
  607. }
  608. $targets{$nondebugkey} = $nondebug;
  609. delete $targets{$debugkey};
  610. }
  611. }
  612. }
  613. }
  614. }
  615. %table = (%table, %targets);
  616. # Local function to resolve inheritance
  617. my $resolve_inheritance;
  618. $resolve_inheritance =
  619. sub {
  620. my $target = shift;
  621. my @breadcrumbs = @_;
  622. if (grep { $_ eq $target } @breadcrumbs) {
  623. die "inherit_from loop! target backtrace:\n "
  624. ,$target,"\n ",join("\n ", @breadcrumbs),"\n";
  625. }
  626. # Recurse through all inheritances. They will be resolved on
  627. # the fly, so when this operation is done, they will all just
  628. # be a bunch of attributes with string values.
  629. # What we get here, though, are keys with references to lists
  630. # of the combined values of them all. We will deal with lists
  631. # after this stage is done.
  632. my %combined_inheritance = ();
  633. if ($table{$target}->{inherit_from}) {
  634. foreach (@{$table{$target}->{inherit_from}}) {
  635. my %inherited_config =
  636. $resolve_inheritance->($_, $target, @breadcrumbs);
  637. # 'template' is a marker that's considered private to
  638. # the config that had it.
  639. delete $inherited_config{template};
  640. map {
  641. if (!$combined_inheritance{$_}) {
  642. $combined_inheritance{$_} = [];
  643. }
  644. push @{$combined_inheritance{$_}}, $inherited_config{$_};
  645. } keys %inherited_config;
  646. }
  647. }
  648. # We won't need inherit_from in this target any more, since
  649. # we've resolved all the inheritances that lead to this
  650. delete $table{$target}->{inherit_from};
  651. # Now is the time to deal with those lists. Here's the place
  652. # to decide what shall be done with those lists, all based on
  653. # the values of the target we're currently dealing with.
  654. # - If a value is a coderef, it will be executed with the list
  655. # of inherited values as arguments.
  656. # - If the corresponding key doesn't have a value at all or is
  657. # the emoty string, the inherited value list will be run
  658. # through the default combiner (below), and the result
  659. # becomes this target's value.
  660. # - Otherwise, this target's value is assumed to be a string
  661. # that will simply override the inherited list of values.
  662. my $default_combiner = sub { join(' ',@_) };
  663. my %all_keys =
  664. map { $_ => 1 } (keys %combined_inheritance,
  665. keys %{$table{$target}});
  666. foreach (sort keys %all_keys) {
  667. # Current target doesn't have a value for the current key?
  668. # Assign it the default combiner, the rest of this loop
  669. # body will handle it just like any other coderef.
  670. if (!exists $table{$target}->{$_}) {
  671. $table{$target}->{$_} = $default_combiner;
  672. }
  673. my $valuetype = ref($table{$target}->{$_});
  674. if ($valuetype eq "CODE") {
  675. # CODE reference, execute it with the inherited values
  676. # as arguments.
  677. $table{$target}->{$_} =
  678. $table{$target}->{$_}->(@{$combined_inheritance{$_}});
  679. } elsif ($valuetype eq "") {
  680. # Scalar, just leave it as is.
  681. } else {
  682. # Some other type of reference that we don't handle.
  683. # Better to abort at this point.
  684. die "cannot handle reference type $valuetype,"
  685. ," found in target $target -> $_\n";
  686. }
  687. }
  688. # Finally done, return the result.
  689. %{$table{$target}};
  690. };
  691. # Go through all new targets and resolve inheritance and template
  692. # references.
  693. foreach (keys %targets) {
  694. # We're ignoring the returned values here, they are only valuable
  695. # to the inner recursion of this function.
  696. $resolve_inheritance->($_);
  697. }
  698. }
  699. my ($vol, $dir, $dummy) = File::Spec->splitpath($0);
  700. my $pattern = File::Spec->catpath($vol, $dir, "Configurations/*.conf");
  701. foreach (sort glob($pattern) ) {
  702. &read_config($_);
  703. }
  704. my @MK1MF_Builds=qw(VC-WIN64I VC-WIN64A
  705. debug-VC-WIN64I debug-VC-WIN64A
  706. VC-NT VC-CE VC-WIN32 debug-VC-WIN32
  707. BC-32
  708. netware-clib netware-clib-bsdsock
  709. netware-libc netware-libc-bsdsock);
  710. my $prefix="";
  711. my $libdir="";
  712. my $openssldir="";
  713. my $exe_ext="";
  714. my $install_prefix= "$ENV{'INSTALL_PREFIX'}";
  715. my $cross_compile_prefix="";
  716. my $fipslibdir="/usr/local/ssl/fips-2.0/lib/";
  717. my $nofipscanistercheck=0;
  718. my $baseaddr="0xFB00000";
  719. my $no_threads=0;
  720. my $threads=0;
  721. my $no_shared=0; # but "no-shared" is default
  722. my $zlib=1; # but "no-zlib" is default
  723. my $no_rfc3779=0;
  724. my $no_asm=0;
  725. my $no_dso=0;
  726. my $no_gmp=0;
  727. my @skip=();
  728. my $Makefile="Makefile";
  729. my $des_locl="crypto/des/des_locl.h";
  730. my $des ="include/openssl/des.h";
  731. my $bn ="include/openssl/bn.h";
  732. my $md2 ="include/openssl/md2.h";
  733. my $rc4 ="include/openssl/rc4.h";
  734. my $rc4_locl="crypto/rc4/rc4_locl.h";
  735. my $idea ="include/openssl/idea.h";
  736. my $rc2 ="include/openssl/rc2.h";
  737. my $bf ="crypto/bf/bf_locl.h";
  738. my $bn_asm ="bn_asm.o";
  739. my $des_enc="des_enc.o fcrypt_b.o";
  740. my $aes_enc="aes_core.o aes_cbc.o";
  741. my $bf_enc ="bf_enc.o";
  742. my $cast_enc="c_enc.o";
  743. my $rc4_enc="rc4_enc.o rc4_skey.o";
  744. my $rc5_enc="rc5_enc.o";
  745. my $cmll_enc="camellia.o cmll_misc.o cmll_cbc.o";
  746. my $processor="";
  747. my $default_ranlib;
  748. my $perl;
  749. my $fips=0;
  750. # Explicitelly known options that are possible to disable. They can
  751. # be regexps, and will be used like this: /^no-${option}$/
  752. # For developers: keep it sorted alphabetically
  753. my @disablables = (
  754. "aes",
  755. "asm",
  756. "bf",
  757. "camellia",
  758. "capieng",
  759. "cast",
  760. "cmac",
  761. "cms",
  762. "comp",
  763. "ct",
  764. "deprecated",
  765. "des",
  766. "dgram",
  767. "dh",
  768. "dsa",
  769. "dso",
  770. "dtls1?",
  771. "dynamic[-_]engine",
  772. "ec",
  773. "ec2m",
  774. "ec_nistp_64_gcc_128",
  775. "engine",
  776. "err", # Really???
  777. "gmp",
  778. "gost",
  779. "heartbeats",
  780. "hmac",
  781. "hw(-.+)?",
  782. "idea",
  783. "jpake",
  784. "locking", # Really???
  785. "md2",
  786. "md4",
  787. "md5",
  788. "mdc2",
  789. "md[-_]ghost94",
  790. "nextprotoneg",
  791. "ocb",
  792. "ocsp",
  793. "posix-io",
  794. "psk",
  795. "rc2",
  796. "rc4",
  797. "rc5",
  798. "rdrand",
  799. "rfc3779",
  800. "rijndael", # Old AES name
  801. "rmd160",
  802. "rsa",
  803. "scrypt",
  804. "sct",
  805. "sctp",
  806. "seed",
  807. "sha",
  808. "shared",
  809. "sock",
  810. "srp",
  811. "srtp",
  812. "sse2",
  813. "ssl",
  814. "ssl3",
  815. "ssl3-method",
  816. "ssl-trace",
  817. "static-engine",
  818. "stdio",
  819. "store",
  820. "threads",
  821. "tls",
  822. "tls1",
  823. "unit-test",
  824. "whirlpool",
  825. "zlib",
  826. "zlib-dynamic",
  827. );
  828. # All of the following is disabled by default (RC5 was enabled before 0.9.8):
  829. my %disabled = ( # "what" => "comment" [or special keyword "experimental"]
  830. "deprecated" => "default",
  831. "ec_nistp_64_gcc_128" => "default",
  832. "gmp" => "default",
  833. "jpake" => "experimental",
  834. "md2" => "default",
  835. "rc5" => "default",
  836. "sctp" => "default",
  837. "shared" => "default",
  838. "ssl-trace" => "default",
  839. "store" => "experimental",
  840. "unit-test" => "default",
  841. "zlib" => "default",
  842. "zlib-dynamic" => "default"
  843. );
  844. my @experimental = ();
  845. # This is what $depflags will look like with the above defaults
  846. # (we need this to see if we should advise the user to run "make depend"):
  847. my $default_depflags = " -DOPENSSL_NO_DEPRECATED -DOPENSSL_NO_EC_NISTP_64_GCC_128 -DOPENSSL_NO_GMP -DOPENSSL_NO_JPAKE -DOPENSSL_NO_MD2 -DOPENSSL_NO_RC5 -DOPENSSL_NO_SCTP -DOPENSSL_NO_SSL_TRACE -DOPENSSL_NO_STORE -DOPENSSL_NO_UNIT_TEST";
  848. # Explicit "no-..." options will be collected in %disabled along with the defaults.
  849. # To remove something from %disabled, use "enable-foo" (unless it's experimental).
  850. # For symmetry, "disable-foo" is a synonym for "no-foo".
  851. # For features called "experimental" here, a more explicit "experimental-foo" is needed to enable.
  852. # We will collect such requests in @experimental.
  853. # To avoid accidental use of experimental features, applications will have to use -DOPENSSL_EXPERIMENTAL_FOO.
  854. my $no_sse2=0;
  855. &usage if ($#ARGV < 0);
  856. my $flags;
  857. my $depflags;
  858. my $openssl_experimental_defines;
  859. my $openssl_algorithm_defines;
  860. my $openssl_thread_defines;
  861. my $openssl_sys_defines="";
  862. my $openssl_other_defines;
  863. my $libs;
  864. my $target;
  865. my $options;
  866. my $make_depend=0;
  867. my %withargs=();
  868. my $build_prefix = "release_";
  869. my @argvcopy=@ARGV;
  870. my $argvstring="";
  871. my $argv_unprocessed=1;
  872. while($argv_unprocessed)
  873. {
  874. $flags="";
  875. $depflags="";
  876. $openssl_experimental_defines="";
  877. $openssl_algorithm_defines="";
  878. $openssl_thread_defines="";
  879. $openssl_sys_defines="";
  880. $openssl_other_defines="";
  881. $libs="";
  882. $target="";
  883. $options="";
  884. $argv_unprocessed=0;
  885. $argvstring=join(' ',@argvcopy);
  886. PROCESS_ARGS:
  887. {
  888. my %unsupported_options = ();
  889. foreach (@argvcopy)
  890. {
  891. s /^-no-/no-/; # some people just can't read the instructions
  892. # rewrite some options in "enable-..." form
  893. s /^-?-?shared$/enable-shared/;
  894. s /^sctp$/enable-sctp/;
  895. s /^threads$/enable-threads/;
  896. s /^zlib$/enable-zlib/;
  897. s /^zlib-dynamic$/enable-zlib-dynamic/;
  898. if (/^(no|disable|enable|experimental)-(.+)$/)
  899. {
  900. my $word = $2;
  901. if (!grep { $word =~ /^${_}$/ } @disablables)
  902. {
  903. $unsupported_options{$_} = 1;
  904. next;
  905. }
  906. }
  907. if (/^no-(.+)$/ || /^disable-(.+)$/)
  908. {
  909. if (!($disabled{$1} eq "experimental"))
  910. {
  911. if ($1 eq "ssl")
  912. {
  913. $disabled{"ssl3"} = "option(ssl)";
  914. }
  915. elsif ($1 eq "tls")
  916. {
  917. $disabled{"tls1"} = "option(tls)"
  918. }
  919. elsif ($1 eq "ssl3-method")
  920. {
  921. $disabled{"ssl3-method"} = "option(ssl)";
  922. $disabled{"ssl3"} = "option(ssl)";
  923. }
  924. else
  925. {
  926. $disabled{$1} = "option";
  927. }
  928. }
  929. }
  930. elsif (/^enable-(.+)$/ || /^experimental-(.+)$/)
  931. {
  932. my $algo = $1;
  933. if ($disabled{$algo} eq "experimental")
  934. {
  935. die "You are requesting an experimental feature; please say 'experimental-$algo' if you are sure\n"
  936. unless (/^experimental-/);
  937. push @experimental, $algo;
  938. }
  939. delete $disabled{$algo};
  940. $threads = 1 if ($algo eq "threads");
  941. }
  942. elsif (/^--test-sanity$/)
  943. {
  944. exit(&test_sanity());
  945. }
  946. elsif (/^--strict-warnings$/)
  947. {
  948. $strict_warnings = 1;
  949. }
  950. elsif (/^--debug$/)
  951. {
  952. $build_prefix = "debug_";
  953. }
  954. elsif (/^--release$/)
  955. {
  956. $build_prefix = "release_";
  957. }
  958. elsif (/^reconfigure/ || /^reconf/)
  959. {
  960. if (open(IN,"<$Makefile"))
  961. {
  962. while (<IN>)
  963. {
  964. chomp;
  965. if (/^CONFIGURE_ARGS=(.*)/)
  966. {
  967. $argvstring=$1;
  968. @argvcopy=split(' ',$argvstring);
  969. die "Incorrect data to reconfigure, please do a normal configuration\n"
  970. if (grep(/^reconf/,@argvcopy));
  971. print "Reconfiguring with: $argvstring\n";
  972. $argv_unprocessed=1;
  973. close(IN);
  974. last PROCESS_ARGS;
  975. }
  976. }
  977. close(IN);
  978. }
  979. die "Insufficient data to reconfigure, please do a normal configuration\n";
  980. }
  981. elsif (/^386$/)
  982. { $processor=386; }
  983. elsif (/^fips$/)
  984. {
  985. $fips=1;
  986. }
  987. elsif (/^rsaref$/)
  988. {
  989. # No RSAref support any more since it's not needed.
  990. # The check for the option is there so scripts aren't
  991. # broken
  992. }
  993. elsif (/^nofipscanistercheck$/)
  994. {
  995. $fips = 1;
  996. $nofipscanistercheck = 1;
  997. }
  998. elsif (/^[-+]/)
  999. {
  1000. if (/^--prefix=(.*)$/)
  1001. {
  1002. $prefix=$1;
  1003. }
  1004. elsif (/^--libdir=(.*)$/)
  1005. {
  1006. $libdir=$1;
  1007. }
  1008. elsif (/^--openssldir=(.*)$/)
  1009. {
  1010. $openssldir=$1;
  1011. }
  1012. elsif (/^--install.prefix=(.*)$/)
  1013. {
  1014. $install_prefix=$1;
  1015. }
  1016. elsif (/^--with-zlib-lib=(.*)$/)
  1017. {
  1018. $withargs{"zlib-lib"}=$1;
  1019. }
  1020. elsif (/^--with-zlib-include=(.*)$/)
  1021. {
  1022. $withargs{"zlib-include"}="-I$1";
  1023. }
  1024. elsif (/^--with-fipslibdir=(.*)$/)
  1025. {
  1026. $fipslibdir="$1/";
  1027. }
  1028. elsif (/^--with-baseaddr=(.*)$/)
  1029. {
  1030. $baseaddr="$1";
  1031. }
  1032. elsif (/^--cross-compile-prefix=(.*)$/)
  1033. {
  1034. $cross_compile_prefix=$1;
  1035. }
  1036. elsif (/^--config=(.*)$/)
  1037. {
  1038. read_config $1;
  1039. }
  1040. elsif (/^-[lL](.*)$/ or /^-Wl,/)
  1041. {
  1042. $libs.=$_." ";
  1043. }
  1044. else # common if (/^[-+]/), just pass down...
  1045. {
  1046. $_ =~ s/%([0-9a-f]{1,2})/chr(hex($1))/gei;
  1047. $flags.=$_." ";
  1048. }
  1049. }
  1050. elsif ($_ =~ /^([^:]+):(.+)$/)
  1051. {
  1052. eval "\$table{\$1} = \"$2\""; # allow $xxx constructs in the string
  1053. $target=$1;
  1054. }
  1055. else
  1056. {
  1057. die "target already defined - $target (offending arg: $_)\n" if ($target ne "");
  1058. $target=$_;
  1059. }
  1060. unless ($_ eq $target || /^no-/ || /^disable-/)
  1061. {
  1062. # "no-..." follows later after implied disactivations
  1063. # have been derived. (Don't take this too seroiusly,
  1064. # we really only write OPTIONS to the Makefile out of
  1065. # nostalgia.)
  1066. if ($options eq "")
  1067. { $options = $_; }
  1068. else
  1069. { $options .= " ".$_; }
  1070. }
  1071. }
  1072. if (keys %unsupported_options)
  1073. {
  1074. die "***** Unsupported options: ",
  1075. join(", ", keys %unsupported_options), "\n";
  1076. }
  1077. }
  1078. }
  1079. if ($processor eq "386")
  1080. {
  1081. $disabled{"sse2"} = "forced";
  1082. }
  1083. if (!defined($disabled{"zlib-dynamic"}))
  1084. {
  1085. # "zlib-dynamic" was specifically enabled, so enable "zlib"
  1086. delete $disabled{"zlib"};
  1087. }
  1088. if (defined($disabled{"rijndael"}))
  1089. {
  1090. $disabled{"aes"} = "forced";
  1091. }
  1092. if (defined($disabled{"des"}))
  1093. {
  1094. $disabled{"mdc2"} = "forced";
  1095. }
  1096. if (defined($disabled{"ec"}))
  1097. {
  1098. $disabled{"ecdsa"} = "forced";
  1099. $disabled{"ecdh"} = "forced";
  1100. }
  1101. # SSL 3.0 and TLS requires MD5 and SHA and either RSA or DSA+DH
  1102. if (defined($disabled{"md5"}) || defined($disabled{"sha"})
  1103. || (defined($disabled{"rsa"})
  1104. && (defined($disabled{"dsa"}) || defined($disabled{"dh"}))))
  1105. {
  1106. $disabled{"ssl3"} = "forced";
  1107. $disabled{"tls1"} = "forced";
  1108. }
  1109. if (defined($disabled{"ec"}) || defined($disabled{"dsa"})
  1110. || defined($disabled{"dh"}) || defined($disabled{"stdio"}))
  1111. {
  1112. $disabled{"gost"} = "forced";
  1113. }
  1114. if ($target eq "TABLE") {
  1115. foreach $target (sort keys %table) {
  1116. print_table_entry($target, "TABLE");
  1117. }
  1118. exit 0;
  1119. }
  1120. if ($target eq "LIST") {
  1121. foreach (sort keys %table) {
  1122. print;
  1123. print "\n";
  1124. }
  1125. exit 0;
  1126. }
  1127. if ($target eq "HASH") {
  1128. print "%table = (\n";
  1129. foreach (sort keys %table) {
  1130. print_table_entry($_, "HASH");
  1131. }
  1132. exit 0;
  1133. }
  1134. if ($target =~ m/^CygWin32(-.*)$/) {
  1135. $target = "Cygwin".$1;
  1136. }
  1137. print "Configuring for $target\n";
  1138. # Support for legacy targets having a name starting with 'debug-'
  1139. my ($d, $t) = $target =~ m/^(debug-)?(.*)$/;
  1140. if ($d) {
  1141. $build_prefix = "debug_";
  1142. # If we do not find debug-foo in the table, the target is set to foo,
  1143. # but only if the foo target has a noon-empty debug_cflags or debug_lflags
  1144. # attribute.
  1145. if (!$table{$target} && ($table{$t}->{debug_cflags}
  1146. || $table{$t}->{debug_lflags})) {
  1147. $target = $t;
  1148. }
  1149. }
  1150. &usage if (!defined($table{$target})
  1151. || $table{$target}->{template}
  1152. || ($build_prefix eq "debug_"
  1153. && $target !~ /^debug-/
  1154. && !($table{$target}->{debug_cflags}
  1155. || $table{$target}->{debug_lflags})));
  1156. if ($fips)
  1157. {
  1158. delete $disabled{"shared"} if ($disabled{"shared"} eq "default");
  1159. }
  1160. foreach (sort (keys %disabled))
  1161. {
  1162. $options .= " no-$_";
  1163. printf " no-%-12s %-10s", $_, "[$disabled{$_}]";
  1164. if (/^dso$/)
  1165. { $no_dso = 1; }
  1166. elsif (/^threads$/)
  1167. { $no_threads = 1; }
  1168. elsif (/^shared$/)
  1169. { $no_shared = 1; }
  1170. elsif (/^zlib$/)
  1171. { $zlib = 0; }
  1172. elsif (/^static-engine$/)
  1173. { }
  1174. elsif (/^zlib-dynamic$/)
  1175. { }
  1176. elsif (/^sse2$/)
  1177. { $no_sse2 = 1; }
  1178. else
  1179. {
  1180. my ($ALGO, $algo);
  1181. ($ALGO = $algo = $_) =~ tr/[\-a-z]/[_A-Z]/;
  1182. if (/^asm$/ || /^err$/ || /^hw$/ || /^hw-/)
  1183. {
  1184. $openssl_other_defines .= "#define OPENSSL_NO_$ALGO\n";
  1185. print " OPENSSL_NO_$ALGO";
  1186. if (/^err$/) { $flags .= "-DOPENSSL_NO_ERR "; }
  1187. elsif (/^asm$/) { $no_asm = 1; }
  1188. }
  1189. else
  1190. {
  1191. ($ALGO,$algo) = ("RMD160","rmd160") if ($algo eq "ripemd");
  1192. $openssl_algorithm_defines .= "#define OPENSSL_NO_$ALGO\n";
  1193. print " OPENSSL_NO_$ALGO";
  1194. push @skip, $algo;
  1195. # fix-up crypto/directory name(s)
  1196. $skip[$#skip]="whrlpool" if $algo eq "whirlpool";
  1197. $skip[$#skip]="ripemd" if $algo eq "rmd160";
  1198. print " (skip dir)";
  1199. $depflags .= " -DOPENSSL_NO_$ALGO";
  1200. }
  1201. }
  1202. print "\n";
  1203. }
  1204. my $exp_cflags = "";
  1205. foreach (sort @experimental)
  1206. {
  1207. my $ALGO;
  1208. ($ALGO = $_) =~ tr/[a-z]/[A-Z]/;
  1209. # opensslconf.h will set OPENSSL_NO_... unless OPENSSL_EXPERIMENTAL_... is defined
  1210. $openssl_experimental_defines .= "#define OPENSSL_NO_$ALGO\n";
  1211. $exp_cflags .= " -DOPENSSL_EXPERIMENTAL_$ALGO";
  1212. }
  1213. my $IsMK1MF=scalar grep /^$target$/,@MK1MF_Builds;
  1214. $exe_ext=".exe" if ($target eq "Cygwin" || $target eq "DJGPP" || $target =~ /^mingw/);
  1215. $exe_ext=".nlm" if ($target =~ /netware/);
  1216. $exe_ext=".pm" if ($target =~ /vos/);
  1217. $openssldir="/usr/local/ssl" if ($openssldir eq "" and $prefix eq "");
  1218. $prefix=$openssldir if $prefix eq "";
  1219. $default_ranlib= &which("ranlib") or $default_ranlib="true";
  1220. $perl=$ENV{'PERL'} or $perl=&which("perl5") or $perl=&which("perl")
  1221. or $perl="perl";
  1222. my $make = $ENV{'MAKE'} || "make";
  1223. $cross_compile_prefix=$ENV{'CROSS_COMPILE'} if $cross_compile_prefix eq "";
  1224. chop $openssldir if $openssldir =~ /\/$/;
  1225. chop $prefix if $prefix =~ /.\/$/;
  1226. $openssldir=$prefix . "/ssl" if $openssldir eq "";
  1227. $openssldir=$prefix . "/" . $openssldir if $openssldir !~ /(^\/|^[a-zA-Z]:[\\\/])/;
  1228. print "IsMK1MF=$IsMK1MF\n";
  1229. # Allow environment CC to override compiler...
  1230. my $cc = $ENV{CC} || $table{$target}->{cc};
  1231. # For cflags and lflags, add the debug_ or release_ attributes
  1232. # Do it in such a way that no spurious space is appended (hence the grep).
  1233. my $cflags = join(" ",
  1234. grep { $_ } ($table{$target}->{cflags},
  1235. $table{$target}->{$build_prefix."cflags"}));
  1236. my $lflags = join(" ",
  1237. grep { $_ } ($table{$target}->{lflags},
  1238. $table{$target}->{$build_prefix."lflags"}));
  1239. my $unistd = $table{$target}->{unistd};
  1240. my $thread_cflag = $table{$target}->{thread_cflag};
  1241. my $sys_id = $table{$target}->{sys_id};
  1242. my $bn_ops = $table{$target}->{bn_ops};
  1243. my $cpuid_obj = $table{$target}->{cpuid_obj};
  1244. my $bn_obj = $table{$target}->{bn_obj};
  1245. my $ec_obj = $table{$target}->{ec_obj};
  1246. my $des_obj = $table{$target}->{des_obj};
  1247. my $aes_obj = $table{$target}->{aes_obj};
  1248. my $bf_obj = $table{$target}->{bf_obj};
  1249. my $md5_obj = $table{$target}->{md5_obj};
  1250. my $sha1_obj = $table{$target}->{sha1_obj};
  1251. my $cast_obj = $table{$target}->{cast_obj};
  1252. my $rc4_obj = $table{$target}->{rc4_obj};
  1253. my $rmd160_obj = $table{$target}->{rmd160_obj};
  1254. my $rc5_obj = $table{$target}->{rc5_obj};
  1255. my $wp_obj = $table{$target}->{wp_obj};
  1256. my $cmll_obj = $table{$target}->{cmll_obj};
  1257. my $modes_obj = $table{$target}->{modes_obj};
  1258. my $engines_obj = $table{$target}->{engines_obj};
  1259. my $perlasm_scheme = $table{$target}->{perlasm_scheme};
  1260. my $dso_scheme = $table{$target}->{dso_scheme};
  1261. my $shared_target = $table{$target}->{shared_target};
  1262. my $shared_cflag = $table{$target}->{shared_cflag};
  1263. my $shared_ldflag = $table{$target}->{shared_ldflag};
  1264. my $shared_extension = $table{$target}->{shared_extension};
  1265. my $ranlib = $ENV{'RANLIB'} || $table{$target}->{ranlib};
  1266. my $ar = $ENV{'AR'} || "ar";
  1267. my $arflags = $table{$target}->{arflags};
  1268. my $multilib = $table{$target}->{multilib};
  1269. # if $prefix/lib$multilib is not an existing directory, then
  1270. # assume that it's not searched by linker automatically, in
  1271. # which case adding $multilib suffix causes more grief than
  1272. # we're ready to tolerate, so don't...
  1273. $multilib="" if !-d "$prefix/lib$multilib";
  1274. $libdir="lib$multilib" if $libdir eq "";
  1275. $cflags = "$cflags$exp_cflags";
  1276. # '%' in $lflags is used to split flags to "pre-" and post-flags
  1277. my ($prelflags,$postlflags)=split('%',$lflags);
  1278. if (defined($postlflags)) { $lflags=$postlflags; }
  1279. else { $lflags=$prelflags; undef $prelflags; }
  1280. if ($target =~ /^mingw/ && `$cc --target-help 2>&1` !~ m/\-mno\-cygwin/m)
  1281. {
  1282. $cflags =~ s/\-mno\-cygwin\s*//;
  1283. $shared_ldflag =~ s/\-mno\-cygwin\s*//;
  1284. }
  1285. if ($target =~ /linux.*\-mips/ && !$no_asm && $flags !~ /\-m(ips|arch=)/) {
  1286. # minimally required architecture flags for assembly modules
  1287. $cflags="-mips2 $cflags" if ($target =~ /mips32/);
  1288. $cflags="-mips3 $cflags" if ($target =~ /mips64/);
  1289. }
  1290. my $no_shared_warn=0;
  1291. my $no_user_cflags=0;
  1292. if ($flags ne "") { $cflags="$flags$cflags"; }
  1293. else { $no_user_cflags=1; }
  1294. # The DSO code currently always implements all functions so that no
  1295. # applications will have to worry about that from a compilation point
  1296. # of view. However, the "method"s may return zero unless that platform
  1297. # has support compiled in for them. Currently each method is enabled
  1298. # by a define "DSO_<name>" ... we translate the "dso_scheme" config
  1299. # string entry into using the following logic;
  1300. my $dso_cflags;
  1301. if (!$no_dso && $dso_scheme ne "")
  1302. {
  1303. $dso_scheme =~ tr/[a-z]/[A-Z]/;
  1304. if ($dso_scheme eq "DLFCN")
  1305. {
  1306. $dso_cflags = "-DDSO_DLFCN -DHAVE_DLFCN_H";
  1307. }
  1308. elsif ($dso_scheme eq "DLFCN_NO_H")
  1309. {
  1310. $dso_cflags = "-DDSO_DLFCN";
  1311. }
  1312. else
  1313. {
  1314. $dso_cflags = "-DDSO_$dso_scheme";
  1315. }
  1316. $cflags = "$dso_cflags $cflags";
  1317. }
  1318. my $thread_cflags;
  1319. my $thread_defines;
  1320. if ($thread_cflag ne "(unknown)" && !$no_threads)
  1321. {
  1322. # If we know how to do it, support threads by default.
  1323. $threads = 1;
  1324. }
  1325. if ($thread_cflag eq "(unknown)" && $threads)
  1326. {
  1327. # If the user asked for "threads", [s]he is also expected to
  1328. # provide any system-dependent compiler options that are
  1329. # necessary.
  1330. if ($no_user_cflags)
  1331. {
  1332. print "You asked for multi-threading support, but didn't\n";
  1333. print "provide any system-specific compiler options\n";
  1334. exit(1);
  1335. }
  1336. $thread_cflags="-DOPENSSL_THREADS $cflags" ;
  1337. $thread_defines .= "#define OPENSSL_THREADS\n";
  1338. }
  1339. else
  1340. {
  1341. $thread_cflags="-DOPENSSL_THREADS $thread_cflag $cflags";
  1342. $thread_defines .= "#define OPENSSL_THREADS\n";
  1343. # my $def;
  1344. # foreach $def (split ' ',$thread_cflag)
  1345. # {
  1346. # if ($def =~ s/^-D// && $def !~ /^_/)
  1347. # {
  1348. # $thread_defines .= "#define $def\n";
  1349. # }
  1350. # }
  1351. }
  1352. $lflags="$libs$lflags" if ($libs ne "");
  1353. if ($no_asm)
  1354. {
  1355. $cpuid_obj=$bn_obj=$ec_obj=
  1356. $des_obj=$aes_obj=$bf_obj=$cast_obj=$rc4_obj=$rc5_obj=$cmll_obj=
  1357. $modes_obj=$sha1_obj=$md5_obj=$rmd160_obj=$wp_obj=$engines_obj="";
  1358. $cflags=~s/\-D[BL]_ENDIAN// if ($fips);
  1359. $thread_cflags=~s/\-D[BL]_ENDIAN// if ($fips);
  1360. }
  1361. elsif (defined($disabled{ec2m}))
  1362. {
  1363. $bn_obj =~ s/\w+-gf2m.o//;
  1364. }
  1365. if (!$no_shared)
  1366. {
  1367. $cast_obj=""; # CAST assembler is not PIC
  1368. }
  1369. if ($threads)
  1370. {
  1371. $cflags=$thread_cflags;
  1372. $openssl_thread_defines .= $thread_defines;
  1373. }
  1374. if ($zlib)
  1375. {
  1376. $cflags = "-DZLIB $cflags";
  1377. if (defined($disabled{"zlib-dynamic"}))
  1378. {
  1379. if (defined($withargs{"zlib-lib"}))
  1380. {
  1381. $lflags = "$lflags -L" . $withargs{"zlib-lib"} . " -lz";
  1382. }
  1383. else
  1384. {
  1385. $lflags = "$lflags -lz";
  1386. }
  1387. }
  1388. else
  1389. {
  1390. $cflags = "-DZLIB_SHARED $cflags";
  1391. }
  1392. }
  1393. #Build the library with OPENSSL_USE_DEPRECATED if deprecation is not disabled
  1394. if(!defined($disabled{"deprecated"}))
  1395. {
  1396. $cflags = "-DOPENSSL_USE_DEPRECATED $cflags";
  1397. }
  1398. # You will find shlib_mark1 and shlib_mark2 explained in Makefile.org
  1399. my $shared_mark = "";
  1400. if ($shared_target eq "")
  1401. {
  1402. $no_shared_warn = 1 if !$no_shared && !$fips;
  1403. $no_shared = 1;
  1404. }
  1405. if (!$no_shared)
  1406. {
  1407. if ($shared_cflag ne "")
  1408. {
  1409. $cflags = "$shared_cflag -DOPENSSL_PIC $cflags";
  1410. }
  1411. }
  1412. if (!$IsMK1MF)
  1413. {
  1414. # add {no-}static-engine to options to allow mkdef.pl to work without extra arguments
  1415. if ($no_shared)
  1416. {
  1417. $openssl_other_defines.="#define OPENSSL_NO_DYNAMIC_ENGINE\n";
  1418. $options.=" static-engine";
  1419. }
  1420. else
  1421. {
  1422. $openssl_other_defines.="#define OPENSSL_NO_STATIC_ENGINE\n";
  1423. $options.=" no-static-engine";
  1424. }
  1425. }
  1426. $cpuid_obj.=" uplink.o uplink-x86.o" if ($cflags =~ /\-DOPENSSL_USE_APPLINK/);
  1427. #
  1428. # Platform fix-ups
  1429. #
  1430. if ($target =~ /\-icc$/) # Intel C compiler
  1431. {
  1432. my $iccver=0;
  1433. if (open(FD,"$cc -V 2>&1 |"))
  1434. {
  1435. while(<FD>) { $iccver=$1 if (/Version ([0-9]+)\./); }
  1436. close(FD);
  1437. }
  1438. if ($iccver>=8)
  1439. {
  1440. $cflags=~s/\-KPIC/-fPIC/;
  1441. # Eliminate unnecessary dependency from libirc.a. This is
  1442. # essential for shared library support, as otherwise
  1443. # apps/openssl can end up in endless loop upon startup...
  1444. $cflags.=" -Dmemcpy=__builtin_memcpy -Dmemset=__builtin_memset";
  1445. }
  1446. if ($iccver>=9)
  1447. {
  1448. $lflags.=" -i-static";
  1449. $lflags=~s/\-no_cpprt/-no-cpprt/;
  1450. }
  1451. if ($iccver>=10)
  1452. {
  1453. $lflags=~s/\-i\-static/-static-intel/;
  1454. }
  1455. if ($iccver>=11)
  1456. {
  1457. $cflags.=" -no-intel-extensions"; # disable Cilk
  1458. $lflags=~s/\-no\-cpprt/-no-cxxlib/;
  1459. }
  1460. }
  1461. # Unlike other OSes (like Solaris, Linux, Tru64, IRIX) BSD run-time
  1462. # linkers (tested OpenBSD, NetBSD and FreeBSD) "demand" RPATH set on
  1463. # .so objects. Apparently application RPATH is not global and does
  1464. # not apply to .so linked with other .so. Problem manifests itself
  1465. # when libssl.so fails to load libcrypto.so. One can argue that we
  1466. # should engrave this into Makefile.shared rules or into BSD-* config
  1467. # lines above. Meanwhile let's try to be cautious and pass -rpath to
  1468. # linker only when --prefix is not /usr.
  1469. if ($target =~ /^BSD\-/)
  1470. {
  1471. $shared_ldflag.=" -Wl,-rpath,\$(LIBRPATH)" if ($prefix !~ m|^/usr[/]*$|);
  1472. }
  1473. if ($sys_id ne "")
  1474. {
  1475. #$cflags="-DOPENSSL_SYS_$sys_id $cflags";
  1476. $openssl_sys_defines="#define OPENSSL_SYS_$sys_id\n";
  1477. }
  1478. if ($ranlib eq "")
  1479. {
  1480. $ranlib = $default_ranlib;
  1481. }
  1482. #my ($bn1)=split(/\s+/,$bn_obj);
  1483. #$bn1 = "" unless defined $bn1;
  1484. #$bn1=$bn_asm unless ($bn1 =~ /\.o$/);
  1485. #$bn_obj="$bn1";
  1486. $cpuid_obj="" if ($processor eq "386");
  1487. $bn_obj = $bn_asm unless $bn_obj ne "";
  1488. # bn-586 is the only one implementing bn_*_part_words
  1489. $cflags.=" -DOPENSSL_BN_ASM_PART_WORDS" if ($bn_obj =~ /bn-586/);
  1490. $cflags.=" -DOPENSSL_IA32_SSE2" if (!$no_sse2 && $bn_obj =~ /86/);
  1491. $cflags.=" -DOPENSSL_BN_ASM_MONT" if ($bn_obj =~ /-mont/);
  1492. $cflags.=" -DOPENSSL_BN_ASM_MONT5" if ($bn_obj =~ /-mont5/);
  1493. $cflags.=" -DOPENSSL_BN_ASM_GF2m" if ($bn_obj =~ /-gf2m/);
  1494. if ($fips)
  1495. {
  1496. $openssl_other_defines.="#define OPENSSL_FIPS\n";
  1497. }
  1498. $cpuid_obj="mem_clr.o" unless ($cpuid_obj =~ /\.o$/);
  1499. $des_obj=$des_enc unless ($des_obj =~ /\.o$/);
  1500. $bf_obj=$bf_enc unless ($bf_obj =~ /\.o$/);
  1501. $cast_obj=$cast_enc unless ($cast_obj =~ /\.o$/);
  1502. $rc4_obj=$rc4_enc unless ($rc4_obj =~ /\.o$/);
  1503. $rc5_obj=$rc5_enc unless ($rc5_obj =~ /\.o$/);
  1504. if ($sha1_obj =~ /\.o$/)
  1505. {
  1506. # $sha1_obj=$sha1_enc;
  1507. $cflags.=" -DSHA1_ASM" if ($sha1_obj =~ /sx86/ || $sha1_obj =~ /sha1/);
  1508. $cflags.=" -DSHA256_ASM" if ($sha1_obj =~ /sha256/);
  1509. $cflags.=" -DSHA512_ASM" if ($sha1_obj =~ /sha512/);
  1510. if ($sha1_obj =~ /sse2/)
  1511. { if ($no_sse2)
  1512. { $sha1_obj =~ s/\S*sse2\S+//; }
  1513. elsif ($cflags !~ /OPENSSL_IA32_SSE2/)
  1514. { $cflags.=" -DOPENSSL_IA32_SSE2"; }
  1515. }
  1516. }
  1517. if ($md5_obj =~ /\.o$/)
  1518. {
  1519. # $md5_obj=$md5_enc;
  1520. $cflags.=" -DMD5_ASM";
  1521. }
  1522. if ($rmd160_obj =~ /\.o$/)
  1523. {
  1524. # $rmd160_obj=$rmd160_enc;
  1525. $cflags.=" -DRMD160_ASM";
  1526. }
  1527. if ($aes_obj =~ /\.o$/)
  1528. {
  1529. $cflags.=" -DAES_ASM" if ($aes_obj =~ m/\baes\-/);;
  1530. # aes-ctr.o is not a real file, only indication that assembler
  1531. # module implements AES_ctr32_encrypt...
  1532. $cflags.=" -DAES_CTR_ASM" if ($aes_obj =~ s/\s*aes\-ctr\.o//);
  1533. # aes-xts.o indicates presence of AES_xts_[en|de]crypt...
  1534. $cflags.=" -DAES_XTS_ASM" if ($aes_obj =~ s/\s*aes\-xts\.o//);
  1535. $aes_obj =~ s/\s*(vpaes|aesni)\-x86\.o//g if ($no_sse2);
  1536. $cflags.=" -DVPAES_ASM" if ($aes_obj =~ m/vpaes/);
  1537. $cflags.=" -DBSAES_ASM" if ($aes_obj =~ m/bsaes/);
  1538. }
  1539. else {
  1540. $aes_obj=$aes_enc;
  1541. }
  1542. $wp_obj="" if ($wp_obj =~ /mmx/ && $processor eq "386");
  1543. if ($wp_obj =~ /\.o$/ && !$disabled{"whirlpool"})
  1544. {
  1545. $cflags.=" -DWHIRLPOOL_ASM";
  1546. }
  1547. else {
  1548. $wp_obj="wp_block.o";
  1549. }
  1550. $cmll_obj=$cmll_enc unless ($cmll_obj =~ /.o$/);
  1551. if ($modes_obj =~ /ghash\-/)
  1552. {
  1553. $cflags.=" -DGHASH_ASM";
  1554. }
  1555. if ($ec_obj =~ /ecp_nistz256/)
  1556. {
  1557. $cflags.=" -DECP_NISTZ256_ASM";
  1558. }
  1559. # "Stringify" the C flags string. This permits it to be made part of a string
  1560. # and works as well on command lines.
  1561. $cflags =~ s/([\\\"])/\\\1/g;
  1562. my $version = "unknown";
  1563. my $version_num = "unknown";
  1564. my $major = "unknown";
  1565. my $minor = "unknown";
  1566. my $shlib_version_number = "unknown";
  1567. my $shlib_version_history = "unknown";
  1568. my $shlib_major = "unknown";
  1569. my $shlib_minor = "unknown";
  1570. open(IN,'<include/openssl/opensslv.h') || die "unable to read opensslv.h:$!\n";
  1571. while (<IN>)
  1572. {
  1573. $version=$1 if /OPENSSL.VERSION.TEXT.*OpenSSL (\S+) /;
  1574. $version_num=$1 if /OPENSSL.VERSION.NUMBER.*0x(\S+)/;
  1575. $shlib_version_number=$1 if /SHLIB_VERSION_NUMBER *"([^"]+)"/;
  1576. $shlib_version_history=$1 if /SHLIB_VERSION_HISTORY *"([^"]*)"/;
  1577. }
  1578. close(IN);
  1579. if ($shlib_version_history ne "") { $shlib_version_history .= ":"; }
  1580. if ($version =~ /(^[0-9]*)\.([0-9\.]*)/)
  1581. {
  1582. $major=$1;
  1583. $minor=$2;
  1584. }
  1585. if ($shlib_version_number =~ /(^[0-9]*)\.([0-9\.]*)/)
  1586. {
  1587. $shlib_major=$1;
  1588. $shlib_minor=$2;
  1589. }
  1590. my $ecc = $cc;
  1591. $ecc = "clang" if `$cc --version 2>&1` =~ /clang/;
  1592. if ($strict_warnings)
  1593. {
  1594. my $wopt;
  1595. die "ERROR --strict-warnings requires gcc or clang" unless ($ecc =~ /gcc(-\d(\.\d)*)?$/ or $ecc =~ /clang$/);
  1596. foreach $wopt (split /\s+/, $gcc_devteam_warn)
  1597. {
  1598. $cflags .= " $wopt" unless ($cflags =~ /(^|\s)$wopt(\s|$)/)
  1599. }
  1600. if ($ecc eq "clang")
  1601. {
  1602. foreach $wopt (split /\s+/, $clang_devteam_warn)
  1603. {
  1604. $cflags .= " $wopt" unless ($cflags =~ /(^|\s)$wopt(\s|$)/)
  1605. }
  1606. }
  1607. if ($target !~ /^mingw/)
  1608. {
  1609. foreach $wopt (split /\s+/, $memleak_devteam_backtrace)
  1610. {
  1611. $cflags .= " $wopt" unless ($cflags =~ /(^|\s)$wopt(\s|$)/)
  1612. }
  1613. }
  1614. }
  1615. open(IN,"<Makefile.org") || die "unable to read Makefile.org:$!\n";
  1616. unlink("$Makefile.new") || die "unable to remove old $Makefile.new:$!\n" if -e "$Makefile.new";
  1617. open(OUT,">$Makefile.new") || die "unable to create $Makefile.new:$!\n";
  1618. print OUT "### Generated automatically from Makefile.org by Configure.\n\n";
  1619. my $sdirs=0;
  1620. while (<IN>)
  1621. {
  1622. chomp;
  1623. $sdirs = 1 if /^SDIRS=/;
  1624. if ($sdirs) {
  1625. my $dir;
  1626. foreach $dir (@skip) {
  1627. s/(\s)$dir /$1/;
  1628. s/\s$dir$//;
  1629. }
  1630. }
  1631. $sdirs = 0 unless /\\$/;
  1632. s/fips // if (/^DIRS=/ && !$fips);
  1633. s/engines // if (/^DIRS=/ && $disabled{"engine"});
  1634. s/ccgost// if (/^ENGDIRS=/ && $disabled{"gost"});
  1635. s/^VERSION=.*/VERSION=$version/;
  1636. s/^MAJOR=.*/MAJOR=$major/;
  1637. s/^MINOR=.*/MINOR=$minor/;
  1638. s/^SHLIB_VERSION_NUMBER=.*/SHLIB_VERSION_NUMBER=$shlib_version_number/;
  1639. s/^SHLIB_VERSION_HISTORY=.*/SHLIB_VERSION_HISTORY=$shlib_version_history/;
  1640. s/^SHLIB_MAJOR=.*/SHLIB_MAJOR=$shlib_major/;
  1641. s/^SHLIB_MINOR=.*/SHLIB_MINOR=$shlib_minor/;
  1642. s/^SHLIB_EXT=.*/SHLIB_EXT=$shared_extension/;
  1643. s/^INSTALLTOP=.*$/INSTALLTOP=$prefix/;
  1644. s/^MULTILIB=.*$/MULTILIB=$multilib/;
  1645. s/^OPENSSLDIR=.*$/OPENSSLDIR=$openssldir/;
  1646. s/^LIBDIR=.*$/LIBDIR=$libdir/;
  1647. s/^INSTALL_PREFIX=.*$/INSTALL_PREFIX=$install_prefix/;
  1648. s/^PLATFORM=.*$/PLATFORM=$target/;
  1649. s/^OPTIONS=.*$/OPTIONS=$options/;
  1650. s/^CONFIGURE_ARGS=.*$/CONFIGURE_ARGS=$argvstring/;
  1651. if ($cross_compile_prefix)
  1652. {
  1653. s/^CC=.*$/CROSS_COMPILE= $cross_compile_prefix\nCC= \$\(CROSS_COMPILE\)$cc/;
  1654. s/^AR=\s*/AR= \$\(CROSS_COMPILE\)/;
  1655. s/^NM=\s*/NM= \$\(CROSS_COMPILE\)/;
  1656. s/^RANLIB=\s*/RANLIB= \$\(CROSS_COMPILE\)/;
  1657. s/^MAKEDEPPROG=.*$/MAKEDEPPROG= \$\(CROSS_COMPILE\)$cc/ if $cc eq "gcc";
  1658. }
  1659. else {
  1660. s/^CC=.*$/CC= $cc/;
  1661. s/^AR=\s*ar/AR= $ar/;
  1662. s/^RANLIB=.*/RANLIB= $ranlib/;
  1663. s/^MAKEDEPPROG=.*$/MAKEDEPPROG= $cc/ if $ecc eq "gcc" || $ecc eq "clang";
  1664. }
  1665. s/^CFLAG=.*$/CFLAG= $cflags/;
  1666. s/^DEPFLAG=.*$/DEPFLAG=$depflags/;
  1667. s/^PEX_LIBS=.*$/PEX_LIBS= $prelflags/;
  1668. s/^EX_LIBS=.*$/EX_LIBS= $lflags/;
  1669. s/^EXE_EXT=.*$/EXE_EXT= $exe_ext/;
  1670. s/^CPUID_OBJ=.*$/CPUID_OBJ= $cpuid_obj/;
  1671. s/^BN_ASM=.*$/BN_ASM= $bn_obj/;
  1672. s/^EC_ASM=.*$/EC_ASM= $ec_obj/;
  1673. s/^DES_ENC=.*$/DES_ENC= $des_obj/;
  1674. s/^AES_ENC=.*$/AES_ENC= $aes_obj/;
  1675. s/^BF_ENC=.*$/BF_ENC= $bf_obj/;
  1676. s/^CAST_ENC=.*$/CAST_ENC= $cast_obj/;
  1677. s/^RC4_ENC=.*$/RC4_ENC= $rc4_obj/;
  1678. s/^RC5_ENC=.*$/RC5_ENC= $rc5_obj/;
  1679. s/^MD5_ASM_OBJ=.*$/MD5_ASM_OBJ= $md5_obj/;
  1680. s/^SHA1_ASM_OBJ=.*$/SHA1_ASM_OBJ= $sha1_obj/;
  1681. s/^RMD160_ASM_OBJ=.*$/RMD160_ASM_OBJ= $rmd160_obj/;
  1682. s/^WP_ASM_OBJ=.*$/WP_ASM_OBJ= $wp_obj/;
  1683. s/^CMLL_ENC=.*$/CMLL_ENC= $cmll_obj/;
  1684. s/^MODES_ASM_OBJ.=*$/MODES_ASM_OBJ= $modes_obj/;
  1685. s/^ENGINES_ASM_OBJ.=*$/ENGINES_ASM_OBJ= $engines_obj/;
  1686. s/^PERLASM_SCHEME=.*$/PERLASM_SCHEME= $perlasm_scheme/;
  1687. s/^PROCESSOR=.*/PROCESSOR= $processor/;
  1688. s/^ARFLAGS=.*/ARFLAGS= $arflags/;
  1689. s/^PERL=.*/PERL= $perl/;
  1690. s/^LIBZLIB=.*/LIBZLIB=$withargs{"zlib-lib"}/;
  1691. s/^ZLIB_INCLUDE=.*/ZLIB_INCLUDE=$withargs{"zlib-include"}/;
  1692. s/^FIPSLIBDIR=.*/FIPSLIBDIR=$fipslibdir/;
  1693. s/^FIPSCANLIB=.*/FIPSCANLIB=libcrypto/ if $fips;
  1694. s/^SHARED_FIPS=.*/SHARED_FIPS=/;
  1695. s/^SHLIBDIRS=.*/SHLIBDIRS= crypto ssl/;
  1696. s/^BASEADDR=.*/BASEADDR=$baseaddr/;
  1697. s/^SHLIB_TARGET=.*/SHLIB_TARGET=$shared_target/;
  1698. s/^SHLIB_MARK=.*/SHLIB_MARK=$shared_mark/;
  1699. s/^SHARED_LIBS=.*/SHARED_LIBS=\$(SHARED_CRYPTO) \$(SHARED_SSL)/ if (!$no_shared);
  1700. if ($shared_extension ne "" && $shared_extension =~ /^\.s([ol])\.[^\.]*$/)
  1701. {
  1702. my $sotmp = $1;
  1703. s/^SHARED_LIBS_LINK_EXTS=.*/SHARED_LIBS_LINK_EXTS=.s$sotmp/;
  1704. }
  1705. elsif ($shared_extension ne "" && $shared_extension =~ /^\.[^\.]*\.dylib$/)
  1706. {
  1707. s/^SHARED_LIBS_LINK_EXTS=.*/SHARED_LIBS_LINK_EXTS=.dylib/;
  1708. }
  1709. elsif ($shared_extension ne "" && $shared_extension =~ /^\.s([ol])\.[^\.]*\.[^\.]*$/)
  1710. {
  1711. my $sotmp = $1;
  1712. s/^SHARED_LIBS_LINK_EXTS=.*/SHARED_LIBS_LINK_EXTS=.s$sotmp.\$(SHLIB_MAJOR) .s$sotmp/;
  1713. }
  1714. elsif ($shared_extension ne "" && $shared_extension =~ /^\.[^\.]*\.[^\.]*\.dylib$/)
  1715. {
  1716. s/^SHARED_LIBS_LINK_EXTS=.*/SHARED_LIBS_LINK_EXTS=.\$(SHLIB_MAJOR).dylib .dylib/;
  1717. }
  1718. s/^SHARED_LDFLAGS=.*/SHARED_LDFLAGS=$shared_ldflag/;
  1719. print OUT $_."\n";
  1720. }
  1721. close(IN);
  1722. close(OUT);
  1723. rename($Makefile,"$Makefile.bak") || die "unable to rename $Makefile\n" if -e $Makefile;
  1724. rename("$Makefile.new",$Makefile) || die "unable to rename $Makefile.new\n";
  1725. print "CC =$cc\n";
  1726. print "CFLAG =$cflags\n";
  1727. print "EX_LIBS =$lflags\n";
  1728. print "CPUID_OBJ =$cpuid_obj\n";
  1729. print "BN_ASM =$bn_obj\n";
  1730. print "EC_ASM =$ec_obj\n";
  1731. print "DES_ENC =$des_obj\n";
  1732. print "AES_ENC =$aes_obj\n";
  1733. print "BF_ENC =$bf_obj\n";
  1734. print "CAST_ENC =$cast_obj\n";
  1735. print "RC4_ENC =$rc4_obj\n";
  1736. print "RC5_ENC =$rc5_obj\n";
  1737. print "MD5_OBJ_ASM =$md5_obj\n";
  1738. print "SHA1_OBJ_ASM =$sha1_obj\n";
  1739. print "RMD160_OBJ_ASM=$rmd160_obj\n";
  1740. print "CMLL_ENC =$cmll_obj\n";
  1741. print "MODES_OBJ =$modes_obj\n";
  1742. print "ENGINES_OBJ =$engines_obj\n";
  1743. print "PROCESSOR =$processor\n";
  1744. print "RANLIB =$ranlib\n";
  1745. print "ARFLAGS =$arflags\n";
  1746. print "PERL =$perl\n";
  1747. my $des_ptr=0;
  1748. my $des_risc1=0;
  1749. my $des_risc2=0;
  1750. my $des_unroll=0;
  1751. my $bn_ll=0;
  1752. my $def_int=2;
  1753. my $rc4_int=$def_int;
  1754. my $md2_int=$def_int;
  1755. my $idea_int=$def_int;
  1756. my $rc2_int=$def_int;
  1757. my $rc4_idx=0;
  1758. my $rc4_chunk=0;
  1759. my $bf_ptr=0;
  1760. my @type=("char","short","int","long");
  1761. my ($b64l,$b64,$b32,$b16,$b8)=(0,0,1,0,0);
  1762. my $export_var_as_fn=0;
  1763. my $des_int;
  1764. foreach (sort split(/\s+/,$bn_ops))
  1765. {
  1766. $des_ptr=1 if /DES_PTR/;
  1767. $des_risc1=1 if /DES_RISC1/;
  1768. $des_risc2=1 if /DES_RISC2/;
  1769. $des_unroll=1 if /DES_UNROLL/;
  1770. $des_int=1 if /DES_INT/;
  1771. $bn_ll=1 if /BN_LLONG/;
  1772. $rc4_int=0 if /RC4_CHAR/;
  1773. $rc4_int=3 if /RC4_LONG/;
  1774. $rc4_idx=1 if /RC4_INDEX/;
  1775. $rc4_chunk=1 if /RC4_CHUNK/;
  1776. $rc4_chunk=2 if /RC4_CHUNK_LL/;
  1777. $md2_int=0 if /MD2_CHAR/;
  1778. $md2_int=3 if /MD2_LONG/;
  1779. $idea_int=1 if /IDEA_SHORT/;
  1780. $idea_int=3 if /IDEA_LONG/;
  1781. $rc2_int=1 if /RC2_SHORT/;
  1782. $rc2_int=3 if /RC2_LONG/;
  1783. $bf_ptr=1 if $_ eq "BF_PTR";
  1784. $bf_ptr=2 if $_ eq "BF_PTR2";
  1785. ($b64l,$b64,$b32,$b16,$b8)=(0,1,0,0,0) if /SIXTY_FOUR_BIT/;
  1786. ($b64l,$b64,$b32,$b16,$b8)=(1,0,0,0,0) if /SIXTY_FOUR_BIT_LONG/;
  1787. ($b64l,$b64,$b32,$b16,$b8)=(0,0,1,0,0) if /THIRTY_TWO_BIT/;
  1788. ($b64l,$b64,$b32,$b16,$b8)=(0,0,0,1,0) if /SIXTEEN_BIT/;
  1789. ($b64l,$b64,$b32,$b16,$b8)=(0,0,0,0,1) if /EIGHT_BIT/;
  1790. $export_var_as_fn=1 if /EXPORT_VAR_AS_FN/;
  1791. }
  1792. open(IN,'<crypto/opensslconf.h.in') || die "unable to read crypto/opensslconf.h.in:$!\n";
  1793. unlink("include/openssl/opensslconf.h.new") || die "unable to remove old include/openssl/opensslconf.h.new:$!\n" if -e "include/openssl/opensslconf.h.new";
  1794. open(OUT,'>include/openssl/opensslconf.h.new') || die "unable to create include/openssl/opensslconf.h.new:$!\n";
  1795. print OUT "/* opensslconf.h */\n";
  1796. print OUT "/* WARNING: Generated automatically from opensslconf.h.in by Configure. */\n\n";
  1797. print OUT "#ifdef __cplusplus\n";
  1798. print OUT "extern \"C\" {\n";
  1799. print OUT "#endif\n";
  1800. print OUT "/* OpenSSL was configured with the following options: */\n";
  1801. my $openssl_algorithm_defines_trans = $openssl_algorithm_defines;
  1802. $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;
  1803. $openssl_algorithm_defines_trans =~ s/^\s*#\s*define\s+OPENSSL_(.*)/# if defined(OPENSSL_$1) \&\& !defined($1)\n# define $1\n# endif/mg;
  1804. $openssl_algorithm_defines =~ s/^\s*#\s*define\s+(.*)/#ifndef $1\n# define $1\n#endif/mg;
  1805. $openssl_algorithm_defines = " /* no ciphers excluded */\n" if $openssl_algorithm_defines eq "";
  1806. $openssl_thread_defines =~ s/^\s*#\s*define\s+(.*)/#ifndef $1\n# define $1\n#endif/mg;
  1807. $openssl_sys_defines =~ s/^\s*#\s*define\s+(.*)/#ifndef $1\n# define $1\n#endif/mg;
  1808. $openssl_other_defines =~ s/^\s*#\s*define\s+(.*)/#ifndef $1\n# define $1\n#endif/mg;
  1809. print OUT $openssl_sys_defines;
  1810. print OUT "#ifndef OPENSSL_DOING_MAKEDEPEND\n\n";
  1811. print OUT $openssl_experimental_defines;
  1812. print OUT "\n";
  1813. print OUT $openssl_algorithm_defines;
  1814. print OUT "\n#endif /* OPENSSL_DOING_MAKEDEPEND */\n\n";
  1815. print OUT $openssl_thread_defines;
  1816. print OUT $openssl_other_defines,"\n";
  1817. print OUT "/* The OPENSSL_NO_* macros are also defined as NO_* if the application\n";
  1818. print OUT " asks for it. This is a transient feature that is provided for those\n";
  1819. print OUT " who haven't had the time to do the appropriate changes in their\n";
  1820. print OUT " applications. */\n";
  1821. print OUT "#ifdef OPENSSL_ALGORITHM_DEFINES\n";
  1822. print OUT $openssl_algorithm_defines_trans;
  1823. print OUT "#endif\n\n";
  1824. print OUT "#define OPENSSL_CPUID_OBJ\n\n" if ($cpuid_obj ne "mem_clr.o");
  1825. while (<IN>)
  1826. {
  1827. if (/^#define\s+OPENSSLDIR/)
  1828. {
  1829. my $foo = $openssldir;
  1830. $foo =~ s/\\/\\\\/g;
  1831. print OUT "#define OPENSSLDIR \"$foo\"\n";
  1832. }
  1833. elsif (/^#define\s+ENGINESDIR/)
  1834. {
  1835. my $foo = "$prefix/$libdir/engines";
  1836. $foo =~ s/\\/\\\\/g;
  1837. print OUT "#define ENGINESDIR \"$foo\"\n";
  1838. }
  1839. elsif (/^#((define)|(undef))\s+OPENSSL_EXPORT_VAR_AS_FUNCTION/)
  1840. { printf OUT "#undef OPENSSL_EXPORT_VAR_AS_FUNCTION\n"
  1841. if $export_var_as_fn;
  1842. printf OUT "#%s OPENSSL_EXPORT_VAR_AS_FUNCTION\n",
  1843. ($export_var_as_fn)?"define":"undef"; }
  1844. elsif (/^#define\s+OPENSSL_UNISTD/)
  1845. {
  1846. $unistd = "<unistd.h>" if $unistd eq "";
  1847. print OUT "#define OPENSSL_UNISTD $unistd\n";
  1848. }
  1849. elsif (/^#((define)|(undef))\s+SIXTY_FOUR_BIT_LONG/)
  1850. { printf OUT "#%s SIXTY_FOUR_BIT_LONG\n",($b64l)?"define":"undef"; }
  1851. elsif (/^#((define)|(undef))\s+SIXTY_FOUR_BIT/)
  1852. { printf OUT "#%s SIXTY_FOUR_BIT\n",($b64)?"define":"undef"; }
  1853. elsif (/^#((define)|(undef))\s+THIRTY_TWO_BIT/)
  1854. { printf OUT "#%s THIRTY_TWO_BIT\n",($b32)?"define":"undef"; }
  1855. elsif (/^#((define)|(undef))\s+SIXTEEN_BIT/)
  1856. { printf OUT "#%s SIXTEEN_BIT\n",($b16)?"define":"undef"; }
  1857. elsif (/^#((define)|(undef))\s+EIGHT_BIT/)
  1858. { printf OUT "#%s EIGHT_BIT\n",($b8)?"define":"undef"; }
  1859. elsif (/^#((define)|(undef))\s+BN_LLONG\s*$/)
  1860. { printf OUT "#%s BN_LLONG\n",($bn_ll)?"define":"undef"; }
  1861. elsif (/^\#define\s+DES_LONG\s+.*/)
  1862. { printf OUT "#define DES_LONG unsigned %s\n",
  1863. ($des_int)?'int':'long'; }
  1864. elsif (/^\#(define|undef)\s+DES_PTR/)
  1865. { printf OUT "#%s DES_PTR\n",($des_ptr)?'define':'undef'; }
  1866. elsif (/^\#(define|undef)\s+DES_RISC1/)
  1867. { printf OUT "#%s DES_RISC1\n",($des_risc1)?'define':'undef'; }
  1868. elsif (/^\#(define|undef)\s+DES_RISC2/)
  1869. { printf OUT "#%s DES_RISC2\n",($des_risc2)?'define':'undef'; }
  1870. elsif (/^\#(define|undef)\s+DES_UNROLL/)
  1871. { printf OUT "#%s DES_UNROLL\n",($des_unroll)?'define':'undef'; }
  1872. elsif (/^#define\s+RC4_INT\s/)
  1873. { printf OUT "#define RC4_INT unsigned %s\n",$type[$rc4_int]; }
  1874. elsif (/^#undef\s+RC4_CHUNK/)
  1875. {
  1876. printf OUT "#undef RC4_CHUNK\n" if $rc4_chunk==0;
  1877. printf OUT "#define RC4_CHUNK unsigned long\n" if $rc4_chunk==1;
  1878. printf OUT "#define RC4_CHUNK unsigned long long\n" if $rc4_chunk==2;
  1879. }
  1880. elsif (/^#((define)|(undef))\s+RC4_INDEX/)
  1881. { printf OUT "#%s RC4_INDEX\n",($rc4_idx)?"define":"undef"; }
  1882. elsif (/^#(define|undef)\s+I386_ONLY/)
  1883. { printf OUT "#%s I386_ONLY\n", ($processor eq "386")?
  1884. "define":"undef"; }
  1885. elsif (/^#define\s+MD2_INT\s/)
  1886. { printf OUT "#define MD2_INT unsigned %s\n",$type[$md2_int]; }
  1887. elsif (/^#define\s+IDEA_INT\s/)
  1888. {printf OUT "#define IDEA_INT unsigned %s\n",$type[$idea_int];}
  1889. elsif (/^#define\s+RC2_INT\s/)
  1890. {printf OUT "#define RC2_INT unsigned %s\n",$type[$rc2_int];}
  1891. elsif (/^#(define|undef)\s+BF_PTR/)
  1892. {
  1893. printf OUT "#undef BF_PTR\n" if $bf_ptr == 0;
  1894. printf OUT "#define BF_PTR\n" if $bf_ptr == 1;
  1895. printf OUT "#define BF_PTR2\n" if $bf_ptr == 2;
  1896. }
  1897. else
  1898. { print OUT $_; }
  1899. }
  1900. close(IN);
  1901. print OUT "#ifdef __cplusplus\n";
  1902. print OUT "}\n";
  1903. print OUT "#endif\n";
  1904. close(OUT);
  1905. rename("include/openssl/opensslconf.h","include/openssl/opensslconf.h.bak") || die "unable to rename include/openssl/opensslconf.h\n" if -e "include/openssl/opensslconf.h";
  1906. rename("include/openssl/opensslconf.h.new","include/openssl/opensslconf.h") || die "unable to rename include/openssl/opensslconf.h.new\n";
  1907. # Fix the date
  1908. print "SIXTY_FOUR_BIT_LONG mode\n" if $b64l;
  1909. print "SIXTY_FOUR_BIT mode\n" if $b64;
  1910. print "THIRTY_TWO_BIT mode\n" if $b32;
  1911. print "SIXTEEN_BIT mode\n" if $b16;
  1912. print "EIGHT_BIT mode\n" if $b8;
  1913. print "DES_PTR used\n" if $des_ptr;
  1914. print "DES_RISC1 used\n" if $des_risc1;
  1915. print "DES_RISC2 used\n" if $des_risc2;
  1916. print "DES_UNROLL used\n" if $des_unroll;
  1917. print "DES_INT used\n" if $des_int;
  1918. print "BN_LLONG mode\n" if $bn_ll;
  1919. print "RC4 uses u$type[$rc4_int]\n" if $rc4_int != $def_int;
  1920. print "RC4_INDEX mode\n" if $rc4_idx;
  1921. print "RC4_CHUNK is undefined\n" if $rc4_chunk==0;
  1922. print "RC4_CHUNK is unsigned long\n" if $rc4_chunk==1;
  1923. print "RC4_CHUNK is unsigned long long\n" if $rc4_chunk==2;
  1924. print "MD2 uses u$type[$md2_int]\n" if $md2_int != $def_int;
  1925. print "IDEA uses u$type[$idea_int]\n" if $idea_int != $def_int;
  1926. print "RC2 uses u$type[$rc2_int]\n" if $rc2_int != $def_int;
  1927. print "BF_PTR used\n" if $bf_ptr == 1;
  1928. print "BF_PTR2 used\n" if $bf_ptr == 2;
  1929. {
  1930. my $perlguess = $perl =~ m@^/@ ? $perl : '/usr/local/bin/perl';
  1931. &dofile("tools/c_rehash",$perlguess,
  1932. '^#!/' => '#!%s',
  1933. '^my \$dir;$' => 'my $dir = "' . $openssldir . '";',
  1934. '^my \$prefix;$' => 'my $prefix = "' . $prefix . '";');
  1935. &dofile("apps/CA.pl",$perl,
  1936. '^#!/' => '#!%s');
  1937. }
  1938. if($IsMK1MF) {
  1939. open (OUT,">crypto/buildinf.h") || die "Can't open buildinf.h";
  1940. printf OUT <<EOF;
  1941. #ifndef MK1MF_BUILD
  1942. /* auto-generated by Configure for crypto/cversion.c:
  1943. * for Unix builds, crypto/Makefile.ssl generates functional definitions;
  1944. * Windows builds (and other mk1mf builds) compile cversion.c with
  1945. * -DMK1MF_BUILD and use definitions added to this file by util/mk1mf.pl. */
  1946. #error "Windows builds (PLATFORM=$target) use mk1mf.pl-created Makefiles"
  1947. #endif
  1948. EOF
  1949. close(OUT);
  1950. } else {
  1951. my $make_command = "$make PERL=\'$perl\'";
  1952. my $make_targets = "";
  1953. $make_targets .= " depend" if $depflags ne $default_depflags && $make_depend;
  1954. (system $make_command.$make_targets) == 0 or die "make $make_targets failed"
  1955. if $make_targets ne "";
  1956. if ($depflags ne $default_depflags && !$make_depend) {
  1957. print <<EOF;
  1958. Since you've disabled or enabled at least one algorithm, you need to do
  1959. the following before building:
  1960. make depend
  1961. EOF
  1962. }
  1963. }
  1964. # create the ms/version32.rc file if needed
  1965. if ($IsMK1MF && ($target !~ /^netware/)) {
  1966. my ($v1, $v2, $v3, $v4);
  1967. if ($version_num =~ /(^[0-9a-f]{1})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})/i) {
  1968. $v1=hex $1;
  1969. $v2=hex $2;
  1970. $v3=hex $3;
  1971. $v4=hex $4;
  1972. }
  1973. open (OUT,">ms/version32.rc") || die "Can't open ms/version32.rc";
  1974. print OUT <<EOF;
  1975. #include <winver.h>
  1976. LANGUAGE 0x09,0x01
  1977. 1 VERSIONINFO
  1978. FILEVERSION $v1,$v2,$v3,$v4
  1979. PRODUCTVERSION $v1,$v2,$v3,$v4
  1980. FILEFLAGSMASK 0x3fL
  1981. #ifdef _DEBUG
  1982. FILEFLAGS 0x01L
  1983. #else
  1984. FILEFLAGS 0x00L
  1985. #endif
  1986. FILEOS VOS__WINDOWS32
  1987. FILETYPE VFT_DLL
  1988. FILESUBTYPE 0x0L
  1989. BEGIN
  1990. BLOCK "StringFileInfo"
  1991. BEGIN
  1992. BLOCK "040904b0"
  1993. BEGIN
  1994. // Required:
  1995. VALUE "CompanyName", "The OpenSSL Project, http://www.openssl.org/\\0"
  1996. VALUE "FileDescription", "OpenSSL Shared Library\\0"
  1997. VALUE "FileVersion", "$version\\0"
  1998. #if defined(CRYPTO)
  1999. VALUE "InternalName", "libeay32\\0"
  2000. VALUE "OriginalFilename", "libeay32.dll\\0"
  2001. #elif defined(SSL)
  2002. VALUE "InternalName", "ssleay32\\0"
  2003. VALUE "OriginalFilename", "ssleay32.dll\\0"
  2004. #endif
  2005. VALUE "ProductName", "The OpenSSL Toolkit\\0"
  2006. VALUE "ProductVersion", "$version\\0"
  2007. // Optional:
  2008. //VALUE "Comments", "\\0"
  2009. VALUE "LegalCopyright", "Copyright © 1998-2015 The OpenSSL Project. Copyright © 1995-1998 Eric A. Young, Tim J. Hudson. All rights reserved.\\0"
  2010. //VALUE "LegalTrademarks", "\\0"
  2011. //VALUE "PrivateBuild", "\\0"
  2012. //VALUE "SpecialBuild", "\\0"
  2013. END
  2014. END
  2015. BLOCK "VarFileInfo"
  2016. BEGIN
  2017. VALUE "Translation", 0x409, 0x4b0
  2018. END
  2019. END
  2020. EOF
  2021. close(OUT);
  2022. }
  2023. print <<EOF;
  2024. Configured for $target.
  2025. EOF
  2026. print <<\EOF if (!$no_threads && !$threads);
  2027. The library could not be configured for supporting multi-threaded
  2028. applications as the compiler options required on this system are not known.
  2029. See file INSTALL for details if you need multi-threading.
  2030. EOF
  2031. print <<\EOF if ($no_shared_warn);
  2032. You gave the option 'shared'. Normally, that would give you shared libraries.
  2033. Unfortunately, the OpenSSL configuration doesn't include shared library support
  2034. for this platform yet, so it will pretend you gave the option 'no-shared'. If
  2035. you can inform the developpers (openssl-dev\@openssl.org) how to support shared
  2036. libraries on this platform, they will at least look at it and try their best
  2037. (but please first make sure you have tried with a current version of OpenSSL).
  2038. EOF
  2039. exit(0);
  2040. sub usage
  2041. {
  2042. print STDERR $usage;
  2043. print STDERR "\npick os/compiler from:\n";
  2044. my $j=0;
  2045. my $i;
  2046. my $k=0;
  2047. foreach $i (sort keys %table)
  2048. {
  2049. next if $i =~ /^debug/;
  2050. $k += length($i) + 1;
  2051. if ($k > 78)
  2052. {
  2053. print STDERR "\n";
  2054. $k=length($i);
  2055. }
  2056. print STDERR $i . " ";
  2057. }
  2058. foreach $i (sort keys %table)
  2059. {
  2060. next if $i !~ /^debug/;
  2061. $k += length($i) + 1;
  2062. if ($k > 78)
  2063. {
  2064. print STDERR "\n";
  2065. $k=length($i);
  2066. }
  2067. print STDERR $i . " ";
  2068. }
  2069. print STDERR "\n\nNOTE: If in doubt, on Unix-ish systems use './config'.\n";
  2070. exit(1);
  2071. }
  2072. sub which
  2073. {
  2074. my($name)=@_;
  2075. my $path;
  2076. foreach $path (split /:/, $ENV{PATH})
  2077. {
  2078. if (-f "$path/$name$exe_ext" and -x _)
  2079. {
  2080. return "$path/$name$exe_ext" unless ($name eq "perl" and
  2081. system("$path/$name$exe_ext -e " . '\'exit($]<5.0);\''));
  2082. }
  2083. }
  2084. }
  2085. sub dofile
  2086. {
  2087. my $f; my $p; my %m; my @a; my $k; my $ff;
  2088. ($f,$p,%m)=@_;
  2089. open(IN,"<$f.in") || open(IN,"<$f") || die "unable to open $f:$!\n";
  2090. @a=<IN>;
  2091. close(IN);
  2092. foreach $k (keys %m)
  2093. {
  2094. grep(/$k/ && ($_=sprintf($m{$k}."\n",$p)),@a);
  2095. }
  2096. open(OUT,">$f.new") || die "unable to open $f.new:$!\n";
  2097. print OUT @a;
  2098. close(OUT);
  2099. rename($f,"$f.bak") || die "unable to rename $f\n" if -e $f;
  2100. rename("$f.new",$f) || die "unable to rename $f.new\n";
  2101. }
  2102. sub print_table_entry
  2103. {
  2104. my $target = shift;
  2105. my $type = shift;
  2106. # Don't print the templates
  2107. return if $table{$target}->{template};
  2108. if ($type eq "TABLE") {
  2109. print <<EOF
  2110. *** $target
  2111. \$cc = $table{$target}->{cc}
  2112. \$cflags = $table{$target}->{cflags}
  2113. \$debug_cflags = $table{$target}->{debug_cflags}
  2114. \$release_cflags = $table{$target}->{release_cflags}
  2115. \$unistd = $table{$target}->{unistd}
  2116. \$thread_cflag = $table{$target}->{thread_cflag}
  2117. \$sys_id = $table{$target}->{sys_id}
  2118. \$lflags = $table{$target}->{lflags}
  2119. \$debug_lflags = $table{$target}->{debug_lflags}
  2120. \$release_lflags = $table{$target}->{release_lflags}
  2121. \$bn_ops = $table{$target}->{bn_ops}
  2122. \$cpuid_obj = $table{$target}->{cpuid_obj}
  2123. \$bn_obj = $table{$target}->{bn_obj}
  2124. \$ec_obj = $table{$target}->{ec_obj}
  2125. \$des_obj = $table{$target}->{des_obj}
  2126. \$aes_obj = $table{$target}->{aes_obj}
  2127. \$bf_obj = $table{$target}->{bf_obj}
  2128. \$md5_obj = $table{$target}->{md5_obj}
  2129. \$sha1_obj = $table{$target}->{sha1_obj}
  2130. \$cast_obj = $table{$target}->{cast_obj}
  2131. \$rc4_obj = $table{$target}->{rc4_obj}
  2132. \$rmd160_obj = $table{$target}->{rmd160_obj}
  2133. \$rc5_obj = $table{$target}->{rc5_obj}
  2134. \$wp_obj = $table{$target}->{wp_obj}
  2135. \$cmll_obj = $table{$target}->{cmll_obj}
  2136. \$modes_obj = $table{$target}->{modes_obj}
  2137. \$engines_obj = $table{$target}->{engines_obj}
  2138. \$perlasm_scheme = $table{$target}->{perlasm_scheme}
  2139. \$dso_scheme = $table{$target}->{dso_scheme}
  2140. \$shared_target= $table{$target}->{shared_target}
  2141. \$shared_cflag = $table{$target}->{shared_cflag}
  2142. \$shared_ldflag = $table{$target}->{shared_ldflag}
  2143. \$shared_extension = $table{$target}->{shared_extension}
  2144. \$ranlib = $table{$target}->{ranlib}
  2145. \$arflags = $table{$target}->{arflags}
  2146. \$multilib = $table{$target}->{multilib}
  2147. EOF
  2148. } elsif ($type eq "HASH") {
  2149. my @sequence = (
  2150. "cc",
  2151. "cflags",
  2152. "debug_cflags",
  2153. "release_cflags",
  2154. "unistd",
  2155. "thread_cflag",
  2156. "sys_id",
  2157. "lflags",
  2158. "debug_lflags",
  2159. "release_lflags",
  2160. "bn_ops",
  2161. "cpuid_obj",
  2162. "bn_obj",
  2163. "ec_obj",
  2164. "des_obj",
  2165. "aes_obj",
  2166. "bf_obj",
  2167. "md5_obj",
  2168. "sha1_obj",
  2169. "cast_obj",
  2170. "rc4_obj",
  2171. "rmd160_obj",
  2172. "rc5_obj",
  2173. "wp_obj",
  2174. "cmll_obj",
  2175. "modes_obj",
  2176. "engines_obj",
  2177. "perlasm_scheme",
  2178. "dso_scheme",
  2179. "shared_target",
  2180. "shared_cflag",
  2181. "shared_ldflag",
  2182. "shared_extension",
  2183. "ranlib",
  2184. "arflags",
  2185. "multilib",
  2186. );
  2187. my $largest =
  2188. length((sort { length($a) <=> length($b) } @sequence)[-1]);
  2189. print " '$target' => {\n";
  2190. foreach (@sequence) {
  2191. if ($table{$target}->{$_}) {
  2192. print " '",$_,"'"," " x ($largest - length($_))," => '",$table{$target}->{$_},"',\n";
  2193. }
  2194. }
  2195. print " },\n";
  2196. }
  2197. }
  2198. sub test_sanity
  2199. {
  2200. my $errorcnt = 0;
  2201. print STDERR "=" x 70, "\n";
  2202. print STDERR "=== SANITY TESTING!\n";
  2203. print STDERR "=== No configuration will be done, all other arguments will be ignored!\n";
  2204. print STDERR "=" x 70, "\n";
  2205. foreach $target (sort keys %table)
  2206. {
  2207. my $pre_dso_scheme = "perlasm_scheme";
  2208. my $dso_scheme = "dso_scheme";
  2209. my $post_dso_scheme = "shared_target";
  2210. if ($table{$target}->{$pre_dso_scheme} =~ /^(beos|dl|dlfcn|win32|vms)$/)
  2211. {
  2212. $errorcnt++;
  2213. print STDERR "SANITY ERROR: '$target' has the dso_scheme values\n";
  2214. print STDERR " in the previous field\n";
  2215. }
  2216. elsif ($table{$target}->{$post_dso_scheme} =~ /^(beos|dl|dlfcn|win32|vms)$/)
  2217. {
  2218. $errorcnt++;
  2219. print STDERR "SANITY ERROR: '$target' has the dso_scheme values\n";
  2220. print STDERR " in the following field\n";
  2221. }
  2222. elsif ($table{$target}->{$dso_scheme} !~ /^(beos|dl|dlfcn|win32|vms|)$/)
  2223. {
  2224. $errorcnt++;
  2225. print STDERR "SANITY ERROR: '$target' has the dso_scheme field = ",$table{$target}->{$dso_scheme},"\n";
  2226. print STDERR " valid values are 'beos', 'dl', 'dlfcn', 'win32' and 'vms'\n";
  2227. }
  2228. }
  2229. print STDERR "No sanity errors detected!\n" if $errorcnt == 0;
  2230. return $errorcnt;
  2231. }