2
0

Configure 125 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441
  1. #! /usr/bin/env perl
  2. # -*- mode: perl; -*-
  3. # Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.
  4. #
  5. # Licensed under the Apache License 2.0 (the "License"). You may not use
  6. # this file except in compliance with the License. You can obtain a copy
  7. # in the file LICENSE in the source distribution or at
  8. # https://www.openssl.org/source/license.html
  9. ## Configure -- OpenSSL source tree configuration script
  10. use 5.10.0;
  11. use strict;
  12. use Config;
  13. use FindBin;
  14. use lib "$FindBin::Bin/util/perl";
  15. use File::Basename;
  16. use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs splitdir/;
  17. use File::Path qw/mkpath/;
  18. use OpenSSL::fallback "$FindBin::Bin/external/perl/MODULES.txt";
  19. use OpenSSL::Glob;
  20. use OpenSSL::Template;
  21. use OpenSSL::config;
  22. # see INSTALL.md for instructions.
  23. my $orig_death_handler = $SIG{__DIE__};
  24. $SIG{__DIE__} = \&death_handler;
  25. my $usage="Usage: Configure [no-<cipher> ...] [enable-<cipher> ...] [-Dxxx] [-lxxx] [-Lxxx] [-fxxx] [-Kxxx] [no-hw-xxx|no-hw] [[no-]threads] [[no-]shared] [[no-]zlib|zlib-dynamic] [no-asm] [no-egd] [sctp] [386] [--prefix=DIR] [--openssldir=OPENSSLDIR] [--with-xxx[=vvv]] [--config=FILE] os/compiler[:flags]\n";
  26. # Options:
  27. #
  28. # --config add the given configuration file, which will be read after
  29. # any "Configurations*" files that are found in the same
  30. # directory as this script.
  31. # --prefix prefix for the OpenSSL installation, which includes the
  32. # directories bin, lib, include, share/man, share/doc/openssl
  33. # This becomes the value of INSTALLTOP in Makefile
  34. # (Default: /usr/local)
  35. # --openssldir OpenSSL data area, such as openssl.cnf, certificates and keys.
  36. # If it's a relative directory, it will be added on the directory
  37. # given with --prefix.
  38. # This becomes the value of OPENSSLDIR in Makefile and in C.
  39. # (Default: PREFIX/ssl)
  40. #
  41. # --cross-compile-prefix Add specified prefix to binutils components.
  42. #
  43. # --api One of 0.9.8, 1.0.0, 1.0.1, 1.0.2, 1.1.0, 1.1.1, or 3.0
  44. # Define the public APIs as they were for that version
  45. # including patch releases. If 'no-deprecated' is also
  46. # given, do not compile support for interfaces deprecated
  47. # up to and including the specified OpenSSL version.
  48. #
  49. # no-hw-xxx do not compile support for specific crypto hardware.
  50. # Generic OpenSSL-style methods relating to this support
  51. # are always compiled but return NULL if the hardware
  52. # support isn't compiled.
  53. # no-hw do not compile support for any crypto hardware.
  54. # [no-]threads [don't] try to create a library that is suitable for
  55. # multithreaded applications (default is "threads" if we
  56. # know how to do it)
  57. # [no-]shared [don't] try to create shared libraries when supported.
  58. # [no-]pic [don't] try to build position independent code when supported.
  59. # If disabled, it also disables shared and dynamic-engine.
  60. # no-asm do not use assembler
  61. # no-egd do not compile support for the entropy-gathering daemon APIs
  62. # [no-]zlib [don't] compile support for zlib compression.
  63. # zlib-dynamic Like "zlib", but the zlib library is expected to be a shared
  64. # library and will be loaded in run-time by the OpenSSL library.
  65. # sctp include SCTP support
  66. # no-uplink Don't build support for UPLINK interface.
  67. # enable-weak-ssl-ciphers
  68. # Enable weak ciphers that are disabled by default.
  69. # 386 generate 80386 code in assembly modules
  70. # no-sse2 disables IA-32 SSE2 code in assembly modules, the above
  71. # mentioned '386' option implies this one
  72. # no-<cipher> build without specified algorithm (rsa, idea, rc5, ...)
  73. # -<xxx> +<xxx> All options which are unknown to the 'Configure' script are
  74. # /<xxx> passed through to the compiler. Unix-style options beginning
  75. # with a '-' or '+' are recognized, as well as Windows-style
  76. # options beginning with a '/'. If the option contains arguments
  77. # separated by spaces, then the URL-style notation %20 can be
  78. # used for the space character in order to avoid having to quote
  79. # the option. For example, -opt%20arg gets expanded to -opt arg.
  80. # In fact, any ASCII character can be encoded as %xx using its
  81. # hexadecimal encoding.
  82. # -static while -static is also a pass-through compiler option (and
  83. # as such is limited to environments where it's actually
  84. # meaningful), it triggers a number configuration options,
  85. # namely no-pic, no-shared and no-threads. It is
  86. # argued that the only reason to produce statically linked
  87. # binaries (and in context it means executables linked with
  88. # -static flag, and not just executables linked with static
  89. # libcrypto.a) is to eliminate dependency on specific run-time,
  90. # a.k.a. libc version. The mentioned config options are meant
  91. # to achieve just that. Unfortunately on Linux it's impossible
  92. # to eliminate the dependency completely for openssl executable
  93. # because of getaddrinfo and gethostbyname calls, which can
  94. # invoke dynamically loadable library facility anyway to meet
  95. # the lookup requests. For this reason on Linux statically
  96. # linked openssl executable has rather debugging value than
  97. # production quality.
  98. #
  99. # BN_LLONG use the type 'long long' in crypto/bn/bn.h
  100. # RC4_CHAR use 'char' instead of 'int' for RC4_INT in crypto/rc4/rc4.h
  101. # Following are set automatically by this script
  102. #
  103. # MD5_ASM use some extra md5 assembler,
  104. # SHA1_ASM use some extra sha1 assembler, must define L_ENDIAN for x86
  105. # RMD160_ASM use some extra ripemd160 assembler,
  106. # SHA256_ASM sha256_block is implemented in assembler
  107. # SHA512_ASM sha512_block is implemented in assembler
  108. # AES_ASM AES_[en|de]crypt is implemented in assembler
  109. # Minimum warning options... any contributions to OpenSSL should at least
  110. # get past these. Note that we only use these with C compilers, not with
  111. # C++ compilers.
  112. # DEBUG_UNUSED enables __owur (warn unused result) checks.
  113. # -DPEDANTIC complements -pedantic and is meant to mask code that
  114. # is not strictly standard-compliant and/or implementation-specific,
  115. # e.g. inline assembly, disregards to alignment requirements, such
  116. # that -pedantic would complain about. Incidentally -DPEDANTIC has
  117. # to be used even in sanitized builds, because sanitizer too is
  118. # supposed to and does take notice of non-standard behaviour. Then
  119. # -pedantic with pre-C9x compiler would also complain about 'long
  120. # long' not being supported. As 64-bit algorithms are common now,
  121. # it grew impossible to resolve this without sizeable additional
  122. # code, so we just tell compiler to be pedantic about everything
  123. # but 'long long' type.
  124. my @gcc_devteam_warn = qw(
  125. -DDEBUG_UNUSED
  126. -DPEDANTIC -pedantic -Wno-long-long
  127. -Wall
  128. -Wextra
  129. -Wno-unused-parameter
  130. -Wno-missing-field-initializers
  131. -Wswitch
  132. -Wsign-compare
  133. -Wshadow
  134. -Wformat
  135. -Wtype-limits
  136. -Wundef
  137. -Werror
  138. -Wmissing-prototypes
  139. -Wstrict-prototypes
  140. );
  141. # These are used in addition to $gcc_devteam_warn when the compiler is clang.
  142. # TODO(openssl-team): fix problems and investigate if (at least) the
  143. # following warnings can also be enabled:
  144. # -Wcast-align
  145. # -Wunreachable-code -- no, too ugly/compiler-specific
  146. # -Wlanguage-extension-token -- no, we use asm()
  147. # -Wunused-macros -- no, too tricky for BN and _XOPEN_SOURCE etc
  148. # -Wextended-offsetof -- no, needed in CMS ASN1 code
  149. my @clang_devteam_warn = qw(
  150. -Wno-unknown-warning-option
  151. -Wswitch-default
  152. -Wno-parentheses-equality
  153. -Wno-language-extension-token
  154. -Wno-extended-offsetof
  155. -Wconditional-uninitialized
  156. -Wincompatible-pointer-types-discards-qualifiers
  157. -Wmissing-variable-declarations
  158. );
  159. my @cl_devteam_warn = qw(
  160. /WX
  161. );
  162. my $strict_warnings = 0;
  163. # As for $BSDthreads. Idea is to maintain "collective" set of flags,
  164. # which would cover all BSD flavors. -pthread applies to them all,
  165. # but is treated differently. OpenBSD expands is as -D_POSIX_THREAD
  166. # -lc_r, which is sufficient. FreeBSD 4.x expands it as -lc_r,
  167. # which has to be accompanied by explicit -D_THREAD_SAFE and
  168. # sometimes -D_REENTRANT. FreeBSD 5.x expands it as -lc_r, which
  169. # seems to be sufficient?
  170. our $BSDthreads="-pthread -D_THREAD_SAFE -D_REENTRANT";
  171. #
  172. # API compatibility name to version number mapping.
  173. #
  174. my $apitable = {
  175. # This table expresses when API additions or changes can occur.
  176. # The numbering used changes from 3.0 and on because we updated
  177. # (solidified) our version numbering scheme at that point.
  178. # From 3.0 and on, we internalise the given version number in decimal
  179. # as MAJOR * 10000 + MINOR * 100 + 0
  180. "3.0.0" => 30000,
  181. "3.0" => 30000,
  182. # Note that before 3.0, we didn't have the same version number scheme.
  183. # Still, the numbering we use here covers what we need.
  184. "1.1.1" => 10101,
  185. "1.1.0" => 10100,
  186. "1.0.2" => 10002,
  187. "1.0.1" => 10001,
  188. "1.0.0" => 10000,
  189. "0.9.8" => 908,
  190. };
  191. # For OpenSSL::config::get_platform
  192. my %guess_opts = ();
  193. my $dryrun = 0;
  194. our %table = ();
  195. our %config = ();
  196. our %withargs = ();
  197. our $now_printing; # set to current entry's name in print_table_entry
  198. # (todo: right thing would be to encapsulate name
  199. # into %target [class] and make print_table_entry
  200. # a method)
  201. # Forward declarations ###############################################
  202. # read_config(filename)
  203. #
  204. # Reads a configuration file and populates %table with the contents
  205. # (which the configuration file places in %targets).
  206. sub read_config;
  207. # resolve_config(target)
  208. #
  209. # Resolves all the late evaluations, inheritances and so on for the
  210. # chosen target and any target it inherits from.
  211. sub resolve_config;
  212. # Information collection #############################################
  213. # Unified build supports separate build dir
  214. my $srcdir = catdir(absolutedir(dirname($0))); # catdir ensures local syntax
  215. my $blddir = catdir(absolutedir(".")); # catdir ensures local syntax
  216. # File::Spec::Unix doesn't detect case insensitivity, so we make sure to
  217. # check if the source and build directory are really the same, and make
  218. # them so. This avoids all kinds of confusion later on.
  219. # We must check @File::Spec::ISA rather than using File::Spec->isa() to
  220. # know if File::Spec ended up loading File::Spec::Unix.
  221. $srcdir = $blddir
  222. if (grep(/::Unix$/, @File::Spec::ISA)
  223. && samedir($srcdir, $blddir));
  224. my $dofile = abs2rel(catfile($srcdir, "util/dofile.pl"));
  225. my $local_config_envname = 'OPENSSL_LOCAL_CONFIG_DIR';
  226. $config{sourcedir} = abs2rel($srcdir, $blddir);
  227. $config{builddir} = abs2rel($blddir, $blddir);
  228. # echo -n 'holy hand grenade of antioch' | openssl sha256
  229. $config{FIPSKEY} =
  230. 'f4556650ac31d35461610bac4ed81b1a181b2d8a43ea2854cbae22ca74560813';
  231. # Collect reconfiguration information if needed
  232. my @argvcopy=@ARGV;
  233. if (grep /^reconf(igure)?$/, @argvcopy) {
  234. die "reconfiguring with other arguments present isn't supported"
  235. if scalar @argvcopy > 1;
  236. if (-f "./configdata.pm") {
  237. my $file = "./configdata.pm";
  238. unless (my $return = do $file) {
  239. die "couldn't parse $file: $@" if $@;
  240. die "couldn't do $file: $!" unless defined $return;
  241. die "couldn't run $file" unless $return;
  242. }
  243. @argvcopy = defined($configdata::config{perlargv}) ?
  244. @{$configdata::config{perlargv}} : ();
  245. die "Incorrect data to reconfigure, please do a normal configuration\n"
  246. if (grep(/^reconf/,@argvcopy));
  247. $config{perlenv} = $configdata::config{perlenv} // {};
  248. } else {
  249. die "Insufficient data to reconfigure, please do a normal configuration\n";
  250. }
  251. }
  252. $config{perlargv} = [ @argvcopy ];
  253. # Historical: if known directories in crypto/ have been removed, it means
  254. # that those sub-systems are disabled.
  255. # (the other option would be to removed them from the SUBDIRS statement in
  256. # crypto/build.info)
  257. # We reverse the input list for cosmetic purely reasons, to compensate that
  258. # 'unshift' adds at the front of the list (i.e. in reverse input order).
  259. foreach ( reverse sort( 'aes', 'aria', 'bf', 'camellia', 'cast', 'des', 'dh',
  260. 'dsa', 'ec', 'hmac', 'idea', 'md2', 'md5', 'mdc2',
  261. 'rc2', 'rc4', 'rc5', 'ripemd', 'rsa', 'seed', 'sha',
  262. 'sm2', 'sm3', 'sm4') ) {
  263. unshift @argvcopy, "no-$_" if ! -d catdir($srcdir, 'crypto', $_);
  264. }
  265. # Collect version numbers
  266. my %version = ();
  267. collect_information(
  268. collect_from_file(catfile($srcdir,'VERSION.dat')),
  269. qr/\s*(\w+)\s*=\s*(.*?)\s*$/ =>
  270. sub {
  271. # Only define it if there is a value at all
  272. if ($2 ne '') {
  273. my $k = $1;
  274. my $v = $2;
  275. # Some values are quoted. Trim the quotes
  276. $v = $1 if $v =~ /^"(.*)"$/;
  277. $version{uc $k} = $v;
  278. }
  279. },
  280. "OTHERWISE" =>
  281. sub { die "Something wrong with this line:\n$_\nin $srcdir/VERSION.dat" },
  282. );
  283. $config{major} = $version{MAJOR} // 'unknown';
  284. $config{minor} = $version{MINOR} // 'unknown';
  285. $config{patch} = $version{PATCH} // 'unknown';
  286. $config{prerelease} =
  287. defined $version{PRE_RELEASE_TAG} ? "-$version{PRE_RELEASE_TAG}" : '';
  288. $config{build_metadata} =
  289. defined $version{BUILD_METADATA} ? "+$version{BUILD_METADATA}" : '';
  290. $config{shlib_version} = $version{SHLIB_VERSION} // 'unknown';
  291. $config{release_date} = $version{RELEASE_DATE} // 'xx XXX xxxx';
  292. $config{version} = "$config{major}.$config{minor}.$config{patch}";
  293. $config{full_version} = "$config{version}$config{prerelease}$config{build_metadata}";
  294. die "erroneous version information in VERSION.dat: ",
  295. "$config{version}, $config{shlib_version}\n"
  296. unless (defined $version{MAJOR}
  297. && defined $version{MINOR}
  298. && defined $version{PATCH}
  299. && defined $version{SHLIB_VERSION});
  300. # Collect target configurations
  301. my $pattern = catfile(dirname($0), "Configurations", "*.conf");
  302. foreach (sort glob($pattern)) {
  303. &read_config($_);
  304. }
  305. if (defined env($local_config_envname)) {
  306. if ($^O eq 'VMS') {
  307. # VMS environment variables are logical names,
  308. # which can be used as is
  309. $pattern = $local_config_envname . ':' . '*.conf';
  310. } else {
  311. $pattern = catfile(env($local_config_envname), '*.conf');
  312. }
  313. foreach (sort glob($pattern)) {
  314. &read_config($_);
  315. }
  316. }
  317. # Save away perl command information
  318. $config{perl_cmd} = $^X;
  319. $config{perl_version} = $Config{version};
  320. $config{perl_archname} = $Config{archname};
  321. $config{prefix}="";
  322. $config{openssldir}="";
  323. $config{processor}="";
  324. $config{libdir}="";
  325. my $auto_threads=1; # enable threads automatically? true by default
  326. my $default_ranlib;
  327. # Known TLS and DTLS protocols
  328. my @tls = qw(ssl3 tls1 tls1_1 tls1_2 tls1_3);
  329. my @dtls = qw(dtls1 dtls1_2);
  330. # Explicitly known options that are possible to disable. They can
  331. # be regexps, and will be used like this: /^no-${option}$/
  332. # For developers: keep it sorted alphabetically
  333. my @disablables = (
  334. "acvp_tests",
  335. "afalgeng",
  336. "aria",
  337. "asan",
  338. "asm",
  339. "async",
  340. "autoalginit",
  341. "autoerrinit",
  342. "autoload-config",
  343. "bf",
  344. "blake2",
  345. "buildtest-c++",
  346. "camellia",
  347. "capieng",
  348. "cast",
  349. "chacha",
  350. "cmac",
  351. "cmp",
  352. "cms",
  353. "comp",
  354. "crypto-mdebug",
  355. "ct",
  356. "deprecated",
  357. "des",
  358. "devcryptoeng",
  359. "dgram",
  360. "dh",
  361. "dsa",
  362. "dso",
  363. "dtls",
  364. "dynamic-engine",
  365. "ec",
  366. "ec2m",
  367. "ecdh",
  368. "ecdsa",
  369. "ec_nistp_64_gcc_128",
  370. "egd",
  371. "engine",
  372. "err",
  373. "external-tests",
  374. "filenames",
  375. "fips",
  376. "fuzz-libfuzzer",
  377. "fuzz-afl",
  378. "gost",
  379. "idea",
  380. "ktls",
  381. "legacy",
  382. "makedepend",
  383. "md2",
  384. "md4",
  385. "mdc2",
  386. "module",
  387. "msan",
  388. "multiblock",
  389. "nextprotoneg",
  390. "pinshared",
  391. "ocb",
  392. "ocsp",
  393. "padlockeng",
  394. "pic",
  395. "poly1305",
  396. "posix-io",
  397. "psk",
  398. "rc2",
  399. "rc4",
  400. "rc5",
  401. "rdrand",
  402. "rfc3779",
  403. "rmd160",
  404. "scrypt",
  405. "sctp",
  406. "secure-memory",
  407. "seed",
  408. "shared",
  409. "siphash",
  410. "siv",
  411. "sm2",
  412. "sm3",
  413. "sm4",
  414. "sock",
  415. "srp",
  416. "srtp",
  417. "sse2",
  418. "ssl",
  419. "ssl-trace",
  420. "static-engine",
  421. "stdio",
  422. "tests",
  423. "threads",
  424. "tls",
  425. "trace",
  426. "ts",
  427. "ubsan",
  428. "ui-console",
  429. "unit-test",
  430. "uplink",
  431. "whirlpool",
  432. "weak-ssl-ciphers",
  433. "zlib",
  434. "zlib-dynamic",
  435. );
  436. foreach my $proto ((@tls, @dtls))
  437. {
  438. push(@disablables, $proto);
  439. push(@disablables, "$proto-method") unless $proto eq "tls1_3";
  440. }
  441. # Internal disablables, for aliasing purposes. They serve no special
  442. # purpose here, but allow scripts to get to know them through configdata.pm,
  443. # where these are merged with @disablables.
  444. # The actual aliasing mechanism is done via %disable_cascades
  445. my @disablables_int = qw(
  446. crmf
  447. );
  448. my %deprecated_disablables = (
  449. "ssl2" => undef,
  450. "buf-freelists" => undef,
  451. "crypto-mdebug-backtrace" => undef,
  452. "hw" => "hw", # causes cascade, but no macro
  453. "hw-padlock" => "padlockeng",
  454. "ripemd" => "rmd160",
  455. "ui" => "ui-console",
  456. "heartbeats" => undef,
  457. );
  458. # All of the following are disabled by default:
  459. our %disabled = ( # "what" => "comment"
  460. "asan" => "default",
  461. "buildtest-c++" => "default",
  462. "crypto-mdebug" => "default",
  463. "crypto-mdebug-backtrace" => "default",
  464. "devcryptoeng" => "default",
  465. "ec_nistp_64_gcc_128" => "default",
  466. "egd" => "default",
  467. "external-tests" => "default",
  468. "fuzz-libfuzzer" => "default",
  469. "fuzz-afl" => "default",
  470. "md2" => "default",
  471. "msan" => "default",
  472. "rc5" => "default",
  473. "sctp" => "default",
  474. "ssl-trace" => "default",
  475. "ssl3" => "default",
  476. "ssl3-method" => "default",
  477. "trace" => "default",
  478. "ubsan" => "default",
  479. "unit-test" => "default",
  480. "weak-ssl-ciphers" => "default",
  481. "zlib" => "default",
  482. "zlib-dynamic" => "default",
  483. "ktls" => "default",
  484. );
  485. # Note: => pair form used for aesthetics, not to truly make a hash table
  486. my @disable_cascades = (
  487. # "what" => [ "cascade", ... ]
  488. sub { $config{processor} eq "386" }
  489. => [ "sse2" ],
  490. "ssl" => [ "ssl3" ],
  491. "ssl3-method" => [ "ssl3" ],
  492. "zlib" => [ "zlib-dynamic" ],
  493. "des" => [ "mdc2" ],
  494. "ec" => [ "ecdsa", "ecdh", "sm2", "gost" ],
  495. sub { $disabled{"ec"} && $disabled{"dh"} }
  496. => [ "tls1_3" ],
  497. "dgram" => [ "dtls", "sctp" ],
  498. "sock" => [ "dgram" ],
  499. "dtls" => [ @dtls ],
  500. sub { 0 == scalar grep { !$disabled{$_} } @dtls }
  501. => [ "dtls" ],
  502. "tls" => [ @tls ],
  503. sub { 0 == scalar grep { !$disabled{$_} } @tls }
  504. => [ "tls" ],
  505. "crypto-mdebug" => [ "crypto-mdebug-backtrace" ],
  506. # If no modules, then no dynamic engines either
  507. "module" => [ "dynamic-engine" ],
  508. # Without shared libraries, dynamic engines aren't possible.
  509. # This is due to them having to link with libcrypto and register features
  510. # using the ENGINE functionality, and since that relies on global tables,
  511. # those *have* to be exacty the same as the ones accessed from the app,
  512. # which cannot be guaranteed if shared libraries aren't present.
  513. # (note that even with shared libraries, both the app and dynamic engines
  514. # must be linked with the same library)
  515. "shared" => [ "dynamic-engine", "uplink" ],
  516. "dso" => [ "dynamic-engine", "module" ],
  517. # Other modules don't necessarily have to link with libcrypto, so shared
  518. # libraries do not have to be a condition to produce those.
  519. # Without position independent code, there can be no shared libraries
  520. # or modules.
  521. "pic" => [ "shared", "module" ],
  522. "module" => [ "fips" ],
  523. "engine" => [ grep /eng$/, @disablables ],
  524. "hw" => [ "padlockeng" ],
  525. # no-autoalginit is only useful when building non-shared
  526. "autoalginit" => [ "shared", "apps" ],
  527. "stdio" => [ "apps", "capieng", "egd" ],
  528. "apps" => [ "tests" ],
  529. "tests" => [ "external-tests" ],
  530. "comp" => [ "zlib" ],
  531. "sm3" => [ "sm2" ],
  532. sub { !$disabled{"unit-test"} } => [ "heartbeats" ],
  533. sub { !$disabled{"msan"} } => [ "asm" ],
  534. sub { $disabled{cmac}; } => [ "siv" ],
  535. "legacy" => [ "md2" ],
  536. "cmp" => [ "crmf" ],
  537. sub { $disabled{"deprecated-3.0"} }
  538. => [ "engine" ]
  539. );
  540. # Avoid protocol support holes. Also disable all versions below N, if version
  541. # N is disabled while N+1 is enabled.
  542. #
  543. my @list = (reverse @tls);
  544. while ((my $first, my $second) = (shift @list, shift @list)) {
  545. last unless @list;
  546. push @disable_cascades, ( sub { !$disabled{$first} && $disabled{$second} }
  547. => [ @list ] );
  548. unshift @list, $second;
  549. }
  550. my @list = (reverse @dtls);
  551. while ((my $first, my $second) = (shift @list, shift @list)) {
  552. last unless @list;
  553. push @disable_cascades, ( sub { !$disabled{$first} && $disabled{$second} }
  554. => [ @list ] );
  555. unshift @list, $second;
  556. }
  557. # Explicit "no-..." options will be collected in %disabled along with the defaults.
  558. # To remove something from %disabled, use "enable-foo".
  559. # For symmetry, "disable-foo" is a synonym for "no-foo".
  560. # For the "make variables" CPPINCLUDES and CPPDEFINES, we support lists with
  561. # platform specific list separators. Users from those platforms should
  562. # recognise those separators from how you set up the PATH to find executables.
  563. # The default is the Unix like separator, :, but as an exception, we also
  564. # support the space as separator.
  565. my $list_separator_re =
  566. { VMS => qr/(?<!\^),/,
  567. MSWin32 => qr/(?<!\\);/ } -> {$^O} // qr/(?<!\\)[:\s]/;
  568. # All the "make variables" we support
  569. # Some get pre-populated for the sake of backward compatibility
  570. # (we supported those before the change to "make variable" support.
  571. my %user = (
  572. AR => env('AR'),
  573. ARFLAGS => [],
  574. AS => undef,
  575. ASFLAGS => [],
  576. CC => env('CC'),
  577. CFLAGS => [ env('CFLAGS') || () ],
  578. CXX => env('CXX'),
  579. CXXFLAGS => [ env('CXXFLAGS') || () ],
  580. CPP => undef,
  581. CPPFLAGS => [ env('CPPFLAGS') || () ], # -D, -I, -Wp,
  582. CPPDEFINES => [], # Alternative for -D
  583. CPPINCLUDES => [], # Alternative for -I
  584. CROSS_COMPILE => env('CROSS_COMPILE'),
  585. HASHBANGPERL=> env('HASHBANGPERL') || env('PERL'),
  586. LD => undef,
  587. LDFLAGS => [ env('LDFLAGS') || () ], # -L, -Wl,
  588. LDLIBS => [ env('LDLIBS') || () ], # -l
  589. MT => undef,
  590. MTFLAGS => [],
  591. PERL => env('PERL') || ($^O ne "VMS" ? $^X : "perl"),
  592. RANLIB => env('RANLIB'),
  593. RC => env('RC') || env('WINDRES'),
  594. RCFLAGS => [ env('RCFLAGS') || () ],
  595. RM => undef,
  596. );
  597. # Info about what "make variables" may be prefixed with the cross compiler
  598. # prefix. This should NEVER mention any such variable with a list for value.
  599. my @user_crossable = qw ( AR AS CC CXX CPP LD MT RANLIB RC );
  600. # The same but for flags given as Configure options. These are *additional*
  601. # input, as opposed to the VAR=string option that override the corresponding
  602. # config target attributes
  603. my %useradd = (
  604. CPPDEFINES => [],
  605. CPPINCLUDES => [],
  606. CPPFLAGS => [],
  607. CFLAGS => [],
  608. CXXFLAGS => [],
  609. LDFLAGS => [],
  610. LDLIBS => [],
  611. RCFLAGS => [],
  612. );
  613. my %user_synonyms = (
  614. HASHBANGPERL=> 'PERL',
  615. RC => 'WINDRES',
  616. );
  617. # Some target attributes have been renamed, this is the translation table
  618. my %target_attr_translate =(
  619. ar => 'AR',
  620. as => 'AS',
  621. cc => 'CC',
  622. cxx => 'CXX',
  623. cpp => 'CPP',
  624. hashbangperl => 'HASHBANGPERL',
  625. ld => 'LD',
  626. mt => 'MT',
  627. ranlib => 'RANLIB',
  628. rc => 'RC',
  629. rm => 'RM',
  630. );
  631. # Initialisers coming from 'config' scripts
  632. $config{defines} = [ split(/$list_separator_re/, env('__CNF_CPPDEFINES')) ];
  633. $config{includes} = [ split(/$list_separator_re/, env('__CNF_CPPINCLUDES')) ];
  634. $config{cppflags} = [ env('__CNF_CPPFLAGS') || () ];
  635. $config{cflags} = [ env('__CNF_CFLAGS') || () ];
  636. $config{cxxflags} = [ env('__CNF_CXXFLAGS') || () ];
  637. $config{lflags} = [ env('__CNF_LDFLAGS') || () ];
  638. $config{ex_libs} = [ env('__CNF_LDLIBS') || () ];
  639. $config{openssl_api_defines}=[];
  640. $config{openssl_sys_defines}=[];
  641. $config{openssl_feature_defines}=[];
  642. $config{options}="";
  643. $config{build_type} = "release";
  644. my $target="";
  645. my %cmdvars = (); # Stores FOO='blah' type arguments
  646. my %unsupported_options = ();
  647. my %deprecated_options = ();
  648. # If you change this, update apps/version.c
  649. my @known_seed_sources = qw(getrandom devrandom os egd none rdcpu librandom);
  650. my @seed_sources = ();
  651. while (@argvcopy)
  652. {
  653. $_ = shift @argvcopy;
  654. # Support env variable assignments among the options
  655. if (m|^(\w+)=(.+)?$|)
  656. {
  657. $cmdvars{$1} = $2;
  658. # Every time a variable is given as a configuration argument,
  659. # it acts as a reset if the variable.
  660. if (exists $user{$1})
  661. {
  662. $user{$1} = ref $user{$1} eq "ARRAY" ? [] : undef;
  663. }
  664. #if (exists $useradd{$1})
  665. # {
  666. # $useradd{$1} = [];
  667. # }
  668. next;
  669. }
  670. # VMS is a case insensitive environment, and depending on settings
  671. # out of our control, we may receive options uppercased. Let's
  672. # downcase at least the part before any equal sign.
  673. if ($^O eq "VMS")
  674. {
  675. s/^([^=]*)/lc($1)/e;
  676. }
  677. # some people just can't read the instructions, clang people have to...
  678. s/^-no-(?!integrated-as)/no-/;
  679. # rewrite some options in "enable-..." form
  680. s /^-?-?shared$/enable-shared/;
  681. s /^sctp$/enable-sctp/;
  682. s /^threads$/enable-threads/;
  683. s /^zlib$/enable-zlib/;
  684. s /^zlib-dynamic$/enable-zlib-dynamic/;
  685. if (/^(no|disable|enable)-(.+)$/)
  686. {
  687. my $word = $2;
  688. if ($word !~ m|hw(?:-.+)| # special treatment for hw regexp opt
  689. && !exists $deprecated_disablables{$word}
  690. && !grep { $word eq $_ } @disablables)
  691. {
  692. $unsupported_options{$_} = 1;
  693. next;
  694. }
  695. }
  696. if (/^no-(.+)$/ || /^disable-(.+)$/)
  697. {
  698. foreach my $proto ((@tls, @dtls))
  699. {
  700. if ($1 eq "$proto-method")
  701. {
  702. $disabled{"$proto"} = "option($proto-method)";
  703. last;
  704. }
  705. }
  706. if ($1 eq "dtls")
  707. {
  708. foreach my $proto (@dtls)
  709. {
  710. $disabled{$proto} = "option(dtls)";
  711. }
  712. $disabled{"dtls"} = "option(dtls)";
  713. }
  714. elsif ($1 eq "ssl")
  715. {
  716. # Last one of its kind
  717. $disabled{"ssl3"} = "option(ssl)";
  718. }
  719. elsif ($1 eq "tls")
  720. {
  721. # XXX: Tests will fail if all SSL/TLS
  722. # protocols are disabled.
  723. foreach my $proto (@tls)
  724. {
  725. $disabled{$proto} = "option(tls)";
  726. }
  727. }
  728. elsif ($1 eq "static-engine")
  729. {
  730. delete $disabled{"dynamic-engine"};
  731. }
  732. elsif ($1 eq "dynamic-engine")
  733. {
  734. $disabled{"dynamic-engine"} = "option";
  735. }
  736. elsif (exists $deprecated_disablables{$1})
  737. {
  738. $deprecated_options{$_} = 1;
  739. if (defined $deprecated_disablables{$1})
  740. {
  741. $disabled{$deprecated_disablables{$1}} = "option";
  742. }
  743. }
  744. elsif ($1 =~ m|hw(?:-.+)|) # deprecate hw options in regexp form
  745. {
  746. $deprecated_options{$_} = 1;
  747. }
  748. else
  749. {
  750. $disabled{$1} = "option";
  751. }
  752. # No longer an automatic choice
  753. $auto_threads = 0 if ($1 eq "threads");
  754. }
  755. elsif (/^enable-(.+)$/)
  756. {
  757. if ($1 eq "static-engine")
  758. {
  759. $disabled{"dynamic-engine"} = "option";
  760. }
  761. elsif ($1 eq "dynamic-engine")
  762. {
  763. delete $disabled{"dynamic-engine"};
  764. }
  765. elsif ($1 eq "zlib-dynamic")
  766. {
  767. delete $disabled{"zlib"};
  768. }
  769. my $algo = $1;
  770. delete $disabled{$algo};
  771. # No longer an automatic choice
  772. $auto_threads = 0 if ($1 eq "threads");
  773. }
  774. elsif (/^-d$/) # From older 'config'
  775. {
  776. $config{build_type} = "debug";
  777. }
  778. elsif (/^-v$/) # From older 'config'
  779. {
  780. $guess_opts{verbose} = 1;
  781. }
  782. elsif (/^-w$/) # From older 'config'
  783. {
  784. $guess_opts{nowait} = 1;
  785. }
  786. elsif (/^-t$/) # From older 'config'
  787. {
  788. $dryrun = 1;
  789. }
  790. elsif (/^--strict-warnings$/)
  791. {
  792. # Pretend that our strict flags is a C flag, and replace it
  793. # with the proper flags later on
  794. push @{$useradd{CFLAGS}}, '--ossl-strict-warnings';
  795. $strict_warnings=1;
  796. }
  797. elsif (/^--debug$/)
  798. {
  799. $config{build_type} = "debug";
  800. }
  801. elsif (/^--release$/)
  802. {
  803. $config{build_type} = "release";
  804. }
  805. elsif (/^386$/)
  806. { $config{processor}=386; }
  807. elsif (/^fips$/)
  808. {
  809. die "FIPS mode not supported\n";
  810. }
  811. elsif (/^rsaref$/)
  812. {
  813. # No RSAref support any more since it's not needed.
  814. # The check for the option is there so scripts aren't
  815. # broken
  816. }
  817. elsif (/^nofipscanistercheck$/)
  818. {
  819. die "FIPS mode not supported\n";
  820. }
  821. elsif (m|^[-+/]|)
  822. {
  823. if (/^--prefix=(.*)$/)
  824. {
  825. $config{prefix}=$1;
  826. die "Directory given with --prefix MUST be absolute\n"
  827. unless file_name_is_absolute($config{prefix});
  828. }
  829. elsif (/^--api=(.*)$/)
  830. {
  831. my $api = $1;
  832. die "Unknown API compatibility level $api"
  833. unless defined $apitable->{$api};
  834. $config{api}=$apitable->{$api};
  835. }
  836. elsif (/^--libdir=(.*)$/)
  837. {
  838. $config{libdir}=$1;
  839. }
  840. elsif (/^--openssldir=(.*)$/)
  841. {
  842. $config{openssldir}=$1;
  843. }
  844. elsif (/^--with-zlib-lib=(.*)$/)
  845. {
  846. $withargs{zlib_lib}=$1;
  847. }
  848. elsif (/^--with-zlib-include=(.*)$/)
  849. {
  850. $withargs{zlib_include}=$1;
  851. }
  852. elsif (/^--with-fuzzer-lib=(.*)$/)
  853. {
  854. $withargs{fuzzer_lib}=$1;
  855. }
  856. elsif (/^--with-fuzzer-include=(.*)$/)
  857. {
  858. $withargs{fuzzer_include}=$1;
  859. }
  860. elsif (/^--with-rand-seed=(.*)$/)
  861. {
  862. foreach my $x (split(m|,|, $1))
  863. {
  864. die "Unknown --with-rand-seed choice $x\n"
  865. if ! grep { $x eq $_ } @known_seed_sources;
  866. push @seed_sources, $x;
  867. }
  868. }
  869. elsif (/^--fips-key=(.*)$/)
  870. {
  871. $user{FIPSKEY}=lc($1);
  872. die "Non-hex character in FIPS key\n"
  873. if $user{FIPSKEY} =~ /[^a-f0-9]/;
  874. die "FIPS key must have even number of characters\n"
  875. if length $1 & 1;
  876. die "FIPS key too long (64 bytes max)\n"
  877. if length $1 > 64;
  878. }
  879. elsif (/^--cross-compile-prefix=(.*)$/)
  880. {
  881. $user{CROSS_COMPILE}=$1;
  882. }
  883. elsif (/^--config=(.*)$/)
  884. {
  885. read_config $1;
  886. }
  887. elsif (/^-l(.*)$/)
  888. {
  889. push @{$useradd{LDLIBS}}, $_;
  890. }
  891. elsif (/^-framework$/)
  892. {
  893. push @{$useradd{LDLIBS}}, $_, shift(@argvcopy);
  894. }
  895. elsif (/^-L(.*)$/ or /^-Wl,/)
  896. {
  897. push @{$useradd{LDFLAGS}}, $_;
  898. }
  899. elsif (/^-rpath$/ or /^-R$/)
  900. # -rpath is the OSF1 rpath flag
  901. # -R is the old Solaris rpath flag
  902. {
  903. my $rpath = shift(@argvcopy) || "";
  904. $rpath .= " " if $rpath ne "";
  905. push @{$useradd{LDFLAGS}}, $_, $rpath;
  906. }
  907. elsif (/^-static$/)
  908. {
  909. push @{$useradd{LDFLAGS}}, $_;
  910. }
  911. elsif (m|^[-/]D(.*)$|)
  912. {
  913. push @{$useradd{CPPDEFINES}}, $1;
  914. }
  915. elsif (m|^[-/]I(.*)$|)
  916. {
  917. push @{$useradd{CPPINCLUDES}}, $1;
  918. }
  919. elsif (/^-Wp,$/)
  920. {
  921. push @{$useradd{CPPFLAGS}}, $1;
  922. }
  923. else # common if (/^[-+]/), just pass down...
  924. {
  925. # Treat %xx as an ASCII code (e.g. replace %20 by a space character).
  926. # This provides a simple way to pass options with arguments separated
  927. # by spaces without quoting (e.g. -opt%20arg translates to -opt arg).
  928. $_ =~ s/%([0-9a-f]{1,2})/chr(hex($1))/gei;
  929. push @{$useradd{CFLAGS}}, $_;
  930. push @{$useradd{CXXFLAGS}}, $_;
  931. }
  932. }
  933. elsif (m|^/|)
  934. {
  935. # Treat %xx as an ASCII code (e.g. replace %20 by a space character).
  936. # This provides a simple way to pass options with arguments separated
  937. # by spaces without quoting (e.g. /opt%20arg translates to /opt arg).
  938. $_ =~ s/%([0-9a-f]{1,2})/chr(hex($1))/gei;
  939. push @{$useradd{CFLAGS}}, $_;
  940. push @{$useradd{CXXFLAGS}}, $_;
  941. }
  942. else
  943. {
  944. die "target already defined - $target (offending arg: $_)\n" if ($target ne "");
  945. $target=$_;
  946. }
  947. unless ($_ eq $target || /^no-/ || /^disable-/)
  948. {
  949. # "no-..." follows later after implied deactivations
  950. # have been derived. (Don't take this too seriously,
  951. # we really only write OPTIONS to the Makefile out of
  952. # nostalgia.)
  953. if ($config{options} eq "")
  954. { $config{options} = $_; }
  955. else
  956. { $config{options} .= " ".$_; }
  957. }
  958. }
  959. if (keys %deprecated_options)
  960. {
  961. warn "***** Deprecated options: ",
  962. join(", ", keys %deprecated_options), "\n";
  963. }
  964. if (keys %unsupported_options)
  965. {
  966. die "***** Unsupported options: ",
  967. join(", ", keys %unsupported_options), "\n";
  968. }
  969. # If any %useradd entry has been set, we must check that the "make
  970. # variables" haven't been set. We start by checking of any %useradd entry
  971. # is set.
  972. if (grep { scalar @$_ > 0 } values %useradd) {
  973. # Hash of env / make variables names. The possible values are:
  974. # 1 - "make vars"
  975. # 2 - %useradd entry set
  976. # 3 - both set
  977. my %detected_vars =
  978. map { my $v = 0;
  979. $v += 1 if $cmdvars{$_};
  980. $v += 2 if @{$useradd{$_}};
  981. $_ => $v }
  982. keys %useradd;
  983. # If any of the corresponding "make variables" is set, we error
  984. if (grep { $_ & 1 } values %detected_vars) {
  985. my $names = join(', ', grep { $detected_vars{$_} > 0 }
  986. sort keys %detected_vars);
  987. die <<"_____";
  988. ***** Mixing make variables and additional compiler/linker flags as
  989. ***** configure command line option is not permitted.
  990. ***** Affected make variables: $names
  991. _____
  992. }
  993. }
  994. # Check through all supported command line variables to see if any of them
  995. # were set, and canonicalise the values we got. If no compiler or linker
  996. # flag or anything else that affects %useradd was set, we also check the
  997. # environment for values.
  998. my $anyuseradd =
  999. grep { defined $_ && (ref $_ ne 'ARRAY' || @$_) } values %useradd;
  1000. foreach (keys %user) {
  1001. my $value = $cmdvars{$_};
  1002. $value //= env($_) unless $anyuseradd;
  1003. $value //=
  1004. defined $user_synonyms{$_} ? $cmdvars{$user_synonyms{$_}} : undef;
  1005. $value //= defined $user_synonyms{$_} ? env($user_synonyms{$_}) : undef
  1006. unless $anyuseradd;
  1007. if (defined $value) {
  1008. if (ref $user{$_} eq 'ARRAY') {
  1009. if ($_ eq 'CPPDEFINES' || $_ eq 'CPPINCLUDES') {
  1010. $user{$_} = [ split /$list_separator_re/, $value ];
  1011. } else {
  1012. $user{$_} = [ $value ];
  1013. }
  1014. } elsif (!defined $user{$_}) {
  1015. $user{$_} = $value;
  1016. }
  1017. }
  1018. }
  1019. if (grep { /-rpath\b/ } ($user{LDFLAGS} ? @{$user{LDFLAGS}} : ())
  1020. && !$disabled{shared}
  1021. && !($disabled{asan} && $disabled{msan} && $disabled{ubsan})) {
  1022. die "***** Cannot simultaneously use -rpath, shared libraries, and\n",
  1023. "***** any of asan, msan or ubsan\n";
  1024. }
  1025. # If no target was given, try guessing.
  1026. unless ($target) {
  1027. my %system_config = OpenSSL::config::get_platform(%guess_opts, %user);
  1028. # The $system_config{disable} is used to populate %disabled with
  1029. # entries that aren't already there.
  1030. foreach ( @{$system_config{disable} // []} ) {
  1031. $disabled{$_} = 'system' unless defined $disabled{$_};
  1032. }
  1033. delete $system_config{disable};
  1034. # Override config entries with stuff from the guesser.
  1035. # It's assumed that this really is nothing new.
  1036. %config = ( %config, %system_config );
  1037. $target = $system_config{target};
  1038. }
  1039. sub disable {
  1040. my $disable_type = shift;
  1041. for (@_) {
  1042. $disabled{$_} = $disable_type;
  1043. }
  1044. my @tocheckfor = (@_ ? @_ : keys %disabled);
  1045. while (@tocheckfor) {
  1046. my %new_tocheckfor = ();
  1047. my @cascade_copy = (@disable_cascades);
  1048. while (@cascade_copy) {
  1049. my ($test, $descendents) =
  1050. (shift @cascade_copy, shift @cascade_copy);
  1051. if (ref($test) eq "CODE" ? $test->() : defined($disabled{$test})) {
  1052. foreach (grep { !defined($disabled{$_}) } @$descendents) {
  1053. $new_tocheckfor{$_} = 1; $disabled{$_} = "cascade";
  1054. }
  1055. }
  1056. }
  1057. @tocheckfor = (keys %new_tocheckfor);
  1058. }
  1059. }
  1060. disable(); # First cascade run
  1061. our $die = sub { die @_; };
  1062. if ($target eq "TABLE") {
  1063. local $die = sub { warn @_; };
  1064. foreach (sort keys %table) {
  1065. print_table_entry($_, "TABLE");
  1066. }
  1067. exit 0;
  1068. }
  1069. if ($target eq "LIST") {
  1070. foreach (sort keys %table) {
  1071. print $_,"\n" unless $table{$_}->{template};
  1072. }
  1073. exit 0;
  1074. }
  1075. if ($target eq "HASH") {
  1076. local $die = sub { warn @_; };
  1077. print "%table = (\n";
  1078. foreach (sort keys %table) {
  1079. print_table_entry($_, "HASH");
  1080. }
  1081. exit 0;
  1082. }
  1083. print "Configuring OpenSSL version $config{full_version} ";
  1084. print "for target $target\n";
  1085. if (scalar(@seed_sources) == 0) {
  1086. print "Using os-specific seed configuration\n";
  1087. push @seed_sources, 'os';
  1088. }
  1089. if (scalar(grep { $_ eq 'egd' } @seed_sources) > 0) {
  1090. delete $disabled{'egd'};
  1091. }
  1092. if (scalar(grep { $_ eq 'none' } @seed_sources) > 0) {
  1093. die "Cannot seed with none and anything else" if scalar(@seed_sources) > 1;
  1094. warn <<_____ if scalar(@seed_sources) == 1;
  1095. ============================== WARNING ===============================
  1096. You have selected the --with-rand-seed=none option, which effectively
  1097. disables automatic reseeding of the OpenSSL random generator.
  1098. All operations depending on the random generator such as creating keys
  1099. will not work unless the random generator is seeded manually by the
  1100. application.
  1101. Please read the 'Note on random number generation' section in the
  1102. INSTALL.md instructions and the RAND_DRBG(7) manual page for more
  1103. details.
  1104. ============================== WARNING ===============================
  1105. _____
  1106. }
  1107. push @{$config{openssl_feature_defines}},
  1108. map { (my $x = $_) =~ tr|[\-a-z]|[_A-Z]|; "OPENSSL_RAND_SEED_$x" }
  1109. @seed_sources;
  1110. # Backward compatibility?
  1111. if ($target =~ m/^CygWin32(-.*)$/) {
  1112. $target = "Cygwin".$1;
  1113. }
  1114. # Support for legacy targets having a name starting with 'debug-'
  1115. my ($d, $t) = $target =~ m/^(debug-)?(.*)$/;
  1116. if ($d) {
  1117. $config{build_type} = "debug";
  1118. # If we do not find debug-foo in the table, the target is set to foo.
  1119. if (!$table{$target}) {
  1120. $target = $t;
  1121. }
  1122. }
  1123. if ($target) {
  1124. # It's possible that we have different config targets for specific
  1125. # toolchains, so we try to detect them, and go for the plain config
  1126. # target if not.
  1127. my $found;
  1128. foreach ( ( "$target-$user{CC}", "$target", undef ) ) {
  1129. $found=$_ if $table{$_} && !$table{$_}->{template};
  1130. last if $found;
  1131. }
  1132. $target = $found;
  1133. } else {
  1134. # If we don't have a config target now, we try the C compiler as we
  1135. # fallback
  1136. my $cc = $user{CC} // 'cc';
  1137. $target = $cc if $table{$cc} && !$table{$cc}->{template};
  1138. }
  1139. &usage unless $target;
  1140. exit 0 if $dryrun; # From older 'config'
  1141. $config{target} = $target;
  1142. my %target = resolve_config($target);
  1143. foreach (keys %target_attr_translate) {
  1144. $target{$target_attr_translate{$_}} = $target{$_}
  1145. if $target{$_};
  1146. delete $target{$_};
  1147. }
  1148. %target = ( %{$table{DEFAULTS}}, %target );
  1149. my %conf_files = map { $_ => 1 } (@{$target{_conf_fname_int}});
  1150. $config{conf_files} = [ sort keys %conf_files ];
  1151. # Using sub disable within these loops may prove fragile, so we run
  1152. # a cascade afterwards
  1153. foreach my $feature (@{$target{disable}}) {
  1154. if (exists $deprecated_disablables{$feature}) {
  1155. warn "***** config $target disables deprecated feature $feature\n";
  1156. } elsif (!grep { $feature eq $_ } @disablables) {
  1157. die "***** config $target disables unknown feature $feature\n";
  1158. }
  1159. $disabled{$feature} = 'config';
  1160. }
  1161. foreach my $feature (@{$target{enable}}) {
  1162. if ("default" eq ($disabled{$feature} // "")) {
  1163. if (exists $deprecated_disablables{$feature}) {
  1164. warn "***** config $target enables deprecated feature $feature\n";
  1165. } elsif (!grep { $feature eq $_ } @disablables) {
  1166. die "***** config $target enables unknown feature $feature\n";
  1167. }
  1168. delete $disabled{$feature};
  1169. }
  1170. }
  1171. # If uplink_arch isn't defined, disable uplink
  1172. $disabled{uplink} = 'no uplink_arch' unless (defined $target{uplink_arch});
  1173. # If asm_arch isn't defined, disable asm
  1174. $disabled{asm} = 'no asm_arch' unless (defined $target{asm_arch});
  1175. disable(); # Run a cascade now
  1176. $target{CXXFLAGS}//=$target{CFLAGS} if $target{CXX};
  1177. $target{cxxflags}//=$target{cflags} if $target{CXX};
  1178. $target{exe_extension}=".exe" if ($config{target} eq "DJGPP");
  1179. $target{exe_extension}=".pm" if ($config{target} =~ /vos/);
  1180. # Fill %config with values from %user, and in case those are undefined or
  1181. # empty, use values from %target (acting as a default).
  1182. foreach (keys %user) {
  1183. my $ref_type = ref $user{$_};
  1184. # Temporary function. Takes an intended ref type (empty string or "ARRAY")
  1185. # and a value that's to be coerced into that type.
  1186. my $mkvalue = sub {
  1187. my $type = shift;
  1188. my $value = shift;
  1189. my $undef_p = shift;
  1190. die "Too many arguments for \$mkvalue" if @_;
  1191. while (ref $value eq 'CODE') {
  1192. $value = $value->();
  1193. }
  1194. if ($type eq 'ARRAY') {
  1195. return undef unless defined $value;
  1196. return undef if ref $value ne 'ARRAY' && !$value;
  1197. return undef if ref $value eq 'ARRAY' && !@$value;
  1198. return [ $value ] unless ref $value eq 'ARRAY';
  1199. }
  1200. return undef unless $value;
  1201. return $value;
  1202. };
  1203. $config{$_} =
  1204. $mkvalue->($ref_type, $user{$_})
  1205. || $mkvalue->($ref_type, $target{$_});
  1206. delete $config{$_} unless defined $config{$_};
  1207. }
  1208. # Finish up %config by appending things the user gave us on the command line
  1209. # apart from "make variables"
  1210. foreach (keys %useradd) {
  1211. # The must all be lists, so we assert that here
  1212. die "internal error: \$useradd{$_} isn't an ARRAY\n"
  1213. unless ref $useradd{$_} eq 'ARRAY';
  1214. if (defined $config{$_}) {
  1215. push @{$config{$_}}, @{$useradd{$_}};
  1216. } else {
  1217. $config{$_} = [ @{$useradd{$_}} ];
  1218. }
  1219. }
  1220. # At this point, we can forget everything about %user and %useradd,
  1221. # because it's now all been merged into the corresponding $config entry
  1222. # Allow overriding the build file name
  1223. $config{build_file} = env('BUILDFILE') || $target{build_file} || "Makefile";
  1224. # Make sure build_scheme is consistent.
  1225. $target{build_scheme} = [ $target{build_scheme} ]
  1226. if ref($target{build_scheme}) ne "ARRAY";
  1227. my ($builder, $builder_platform, @builder_opts) =
  1228. @{$target{build_scheme}};
  1229. foreach my $checker (($builder_platform."-".$target{build_file}."-checker.pm",
  1230. $builder_platform."-checker.pm")) {
  1231. my $checker_path = catfile($srcdir, "Configurations", $checker);
  1232. if (-f $checker_path) {
  1233. my $fn = $ENV{CONFIGURE_CHECKER_WARN}
  1234. ? sub { warn $@; } : sub { die $@; };
  1235. if (! do $checker_path) {
  1236. if ($@) {
  1237. $fn->($@);
  1238. } elsif ($!) {
  1239. $fn->($!);
  1240. } else {
  1241. $fn->("The detected tools didn't match the platform\n");
  1242. }
  1243. }
  1244. last;
  1245. }
  1246. }
  1247. push @{$config{defines}}, "NDEBUG" if $config{build_type} eq "release";
  1248. if ($target =~ /^mingw/ && `$config{CC} --target-help 2>&1` =~ m/-mno-cygwin/m)
  1249. {
  1250. push @{$config{cflags}}, "-mno-cygwin";
  1251. push @{$config{cxxflags}}, "-mno-cygwin" if $config{CXX};
  1252. push @{$config{shared_ldflag}}, "-mno-cygwin";
  1253. }
  1254. if ($target =~ /linux.*-mips/ && !$disabled{asm}
  1255. && !grep { $_ !~ /-m(ips|arch=)/ } (@{$config{CFLAGS}})) {
  1256. # minimally required architecture flags for assembly modules
  1257. my $value;
  1258. $value = '-mips2' if ($target =~ /mips32/);
  1259. $value = '-mips3' if ($target =~ /mips64/);
  1260. unshift @{$config{cflags}}, $value;
  1261. unshift @{$config{cxxflags}}, $value if $config{CXX};
  1262. }
  1263. # If threads aren't disabled, check how possible they are
  1264. unless ($disabled{threads}) {
  1265. if ($auto_threads) {
  1266. # Enabled by default, disable it forcibly if unavailable
  1267. if ($target{thread_scheme} eq "(unknown)") {
  1268. disable("unavailable", 'threads');
  1269. }
  1270. } else {
  1271. # The user chose to enable threads explicitly, let's see
  1272. # if there's a chance that's possible
  1273. if ($target{thread_scheme} eq "(unknown)") {
  1274. # If the user asked for "threads" and we don't have internal
  1275. # knowledge how to do it, [s]he is expected to provide any
  1276. # system-dependent compiler options that are necessary. We
  1277. # can't truly check that the given options are correct, but
  1278. # we expect the user to know what [s]He is doing.
  1279. if (!@{$config{CFLAGS}} && !@{$config{CPPDEFINES}}) {
  1280. die "You asked for multi-threading support, but didn't\n"
  1281. ,"provide any system-specific compiler options\n";
  1282. }
  1283. }
  1284. }
  1285. }
  1286. # Find out if clang's sanitizers have been enabled with -fsanitize
  1287. # flags and ensure that the corresponding %disabled elements area
  1288. # removed to reflect that the sanitizers are indeed enabled.
  1289. my %detected_sanitizers = ();
  1290. foreach (grep /^-fsanitize=/, @{$config{CFLAGS} || []}) {
  1291. (my $checks = $_) =~ s/^-fsanitize=//;
  1292. foreach (split /,/, $checks) {
  1293. my $d = { address => 'asan',
  1294. undefined => 'ubsan',
  1295. memory => 'msan' } -> {$_};
  1296. next unless defined $d;
  1297. $detected_sanitizers{$d} = 1;
  1298. if (defined $disabled{$d}) {
  1299. die "***** Conflict between disabling $d and enabling $_ sanitizer"
  1300. if $disabled{$d} ne "default";
  1301. delete $disabled{$d};
  1302. }
  1303. }
  1304. }
  1305. # If threads still aren't disabled, add a C macro to ensure the source
  1306. # code knows about it. Any other flag is taken care of by the configs.
  1307. unless($disabled{threads}) {
  1308. push @{$config{openssl_feature_defines}}, "OPENSSL_THREADS";
  1309. }
  1310. my $no_shared_warn=0;
  1311. if ($target{shared_target} eq "")
  1312. {
  1313. $no_shared_warn = 1
  1314. if (!$disabled{shared} || !$disabled{"dynamic-engine"});
  1315. disable('no-shared-target', 'pic');
  1316. }
  1317. if ($disabled{"dynamic-engine"}) {
  1318. $config{dynamic_engines} = 0;
  1319. } else {
  1320. $config{dynamic_engines} = 1;
  1321. }
  1322. unless ($disabled{asan} || defined $detected_sanitizers{asan}) {
  1323. push @{$config{cflags}}, "-fsanitize=address";
  1324. }
  1325. unless ($disabled{ubsan} || defined $detected_sanitizers{ubsan}) {
  1326. # -DPEDANTIC or -fnosanitize=alignment may also be required on some
  1327. # platforms.
  1328. push @{$config{cflags}}, "-fsanitize=undefined", "-fno-sanitize-recover=all";
  1329. }
  1330. unless ($disabled{msan} || defined $detected_sanitizers{msan}) {
  1331. push @{$config{cflags}}, "-fsanitize=memory";
  1332. }
  1333. unless ($disabled{"fuzz-libfuzzer"} && $disabled{"fuzz-afl"}
  1334. && $disabled{asan} && $disabled{ubsan} && $disabled{msan}) {
  1335. push @{$config{cflags}}, "-fno-omit-frame-pointer", "-g";
  1336. push @{$config{cxxflags}}, "-fno-omit-frame-pointer", "-g" if $config{CXX};
  1337. }
  1338. #
  1339. # Platform fix-ups
  1340. #
  1341. # This saves the build files from having to check
  1342. if ($disabled{pic})
  1343. {
  1344. foreach (qw(shared_cflag shared_cxxflag shared_cppflag
  1345. shared_defines shared_includes shared_ldflag
  1346. module_cflags module_cxxflags module_cppflags
  1347. module_defines module_includes module_lflags))
  1348. {
  1349. delete $config{$_};
  1350. $target{$_} = "";
  1351. }
  1352. }
  1353. else
  1354. {
  1355. push @{$config{lib_defines}}, "OPENSSL_PIC";
  1356. }
  1357. if ($target{sys_id} ne "")
  1358. {
  1359. push @{$config{openssl_sys_defines}}, "OPENSSL_SYS_$target{sys_id}";
  1360. }
  1361. my %predefined_C = compiler_predefined($config{CROSS_COMPILE}.$config{CC});
  1362. my %predefined_CXX = $config{CXX}
  1363. ? compiler_predefined($config{CROSS_COMPILE}.$config{CXX})
  1364. : ();
  1365. unless ($disabled{asm}) {
  1366. # big endian systems can use ELFv2 ABI
  1367. if ($target eq "linux-ppc64") {
  1368. $target{perlasm_scheme} = "linux64v2" if ($predefined_C{_CALL_ELF} == 2);
  1369. }
  1370. }
  1371. # Check for makedepend capabilities.
  1372. if (!$disabled{makedepend}) {
  1373. if ($config{target} =~ /^(VC|vms)-/) {
  1374. # For VC- and vms- targets, there's nothing more to do here. The
  1375. # functionality is hard coded in the corresponding build files for
  1376. # cl (Windows) and CC/DECC (VMS).
  1377. } elsif (($predefined_C{__GNUC__} // -1) >= 3
  1378. && !($predefined_C{__APPLE_CC__} && !$predefined_C{__clang__})) {
  1379. # We know that GNU C version 3 and up as well as all clang
  1380. # versions support dependency generation, but Xcode did not
  1381. # handle $cc -M before clang support (but claims __GNUC__ = 3)
  1382. $config{makedepprog} = "\$(CROSS_COMPILE)$config{CC}";
  1383. } else {
  1384. # In all other cases, we look for 'makedepend', and disable the
  1385. # capability if not found.
  1386. $config{makedepprog} = which('makedepend');
  1387. disable('unavailable', 'makedepend') unless $config{makedepprog};
  1388. }
  1389. }
  1390. if (!$disabled{asm} && !$predefined_C{__MACH__} && $^O ne 'VMS') {
  1391. # probe for -Wa,--noexecstack option...
  1392. if ($predefined_C{__clang__}) {
  1393. # clang has builtin assembler, which doesn't recognize --help,
  1394. # but it apparently recognizes the option in question on all
  1395. # supported platforms even when it's meaningless. In other words
  1396. # probe would fail, but probed option always accepted...
  1397. push @{$config{cflags}}, "-Wa,--noexecstack", "-Qunused-arguments";
  1398. } else {
  1399. my $cc = $config{CROSS_COMPILE}.$config{CC};
  1400. open(PIPE, "$cc -Wa,--help -c -o null.$$.o -x assembler /dev/null 2>&1 |");
  1401. while(<PIPE>) {
  1402. if (m/--noexecstack/) {
  1403. push @{$config{cflags}}, "-Wa,--noexecstack";
  1404. last;
  1405. }
  1406. }
  1407. close(PIPE);
  1408. unlink("null.$$.o");
  1409. }
  1410. }
  1411. # Deal with bn_ops ###################################################
  1412. $config{bn_ll} =0;
  1413. my $def_int="unsigned int";
  1414. $config{rc4_int} =$def_int;
  1415. ($config{b64l},$config{b64},$config{b32})=(0,0,1);
  1416. my $count = 0;
  1417. foreach (sort split(/\s+/,$target{bn_ops})) {
  1418. $count++ if /SIXTY_FOUR_BIT|SIXTY_FOUR_BIT_LONG|THIRTY_TWO_BIT/;
  1419. $config{bn_ll}=1 if $_ eq 'BN_LLONG';
  1420. $config{rc4_int}="unsigned char" if $_ eq 'RC4_CHAR';
  1421. ($config{b64l},$config{b64},$config{b32})
  1422. =(0,1,0) if $_ eq 'SIXTY_FOUR_BIT';
  1423. ($config{b64l},$config{b64},$config{b32})
  1424. =(1,0,0) if $_ eq 'SIXTY_FOUR_BIT_LONG';
  1425. ($config{b64l},$config{b64},$config{b32})
  1426. =(0,0,1) if $_ eq 'THIRTY_TWO_BIT';
  1427. }
  1428. die "Exactly one of SIXTY_FOUR_BIT|SIXTY_FOUR_BIT_LONG|THIRTY_TWO_BIT can be set in bn_ops\n"
  1429. if $count > 1;
  1430. $config{api} = $config{major} * 10000 + $config{minor} * 100
  1431. unless $config{api};
  1432. foreach (keys %$apitable) {
  1433. $disabled{"deprecated-$_"} = "deprecation"
  1434. if $disabled{deprecated} && $config{api} >= $apitable->{$_};
  1435. }
  1436. disable(); # Run a cascade now
  1437. # Hack cflags for better warnings (dev option) #######################
  1438. # "Stringify" the C and C++ flags string. This permits it to be made part of
  1439. # a string and works as well on command lines.
  1440. $config{cflags} = [ map { (my $x = $_) =~ s/([\\\"])/\\$1/g; $x }
  1441. @{$config{cflags}} ];
  1442. $config{cxxflags} = [ map { (my $x = $_) =~ s/([\\\"])/\\$1/g; $x }
  1443. @{$config{cxxflags}} ] if $config{CXX};
  1444. $config{openssl_api_defines} = [
  1445. "OPENSSL_CONFIGURED_API=".$config{api},
  1446. ];
  1447. my @strict_warnings_collection=();
  1448. if ($strict_warnings)
  1449. {
  1450. my $wopt;
  1451. my $gccver = $predefined_C{__GNUC__} // -1;
  1452. if ($gccver >= 4)
  1453. {
  1454. push @strict_warnings_collection, @gcc_devteam_warn;
  1455. push @strict_warnings_collection, @clang_devteam_warn
  1456. if (defined($predefined_C{__clang__}));
  1457. }
  1458. elsif ($config{target} =~ /^VC-/)
  1459. {
  1460. push @strict_warnings_collection, @cl_devteam_warn;
  1461. }
  1462. else
  1463. {
  1464. warn "WARNING --strict-warnings requires gcc[>=4] or gcc-alike, or MSVC"
  1465. }
  1466. }
  1467. if (grep { $_ =~ /(?:^|\s)-static(?:\s|$)/ } @{$config{LDFLAGS}}) {
  1468. disable('static', 'pic', 'threads');
  1469. }
  1470. $config{CFLAGS} = [ map { $_ eq '--ossl-strict-warnings'
  1471. ? @strict_warnings_collection
  1472. : ( $_ ) }
  1473. @{$config{CFLAGS}} ];
  1474. unless ($disabled{afalgeng}) {
  1475. $config{afalgeng}="";
  1476. if (grep { $_ eq 'afalgeng' } @{$target{enable}}) {
  1477. my $minver = 4*10000 + 1*100 + 0;
  1478. if ($config{CROSS_COMPILE} eq "") {
  1479. my $verstr = `uname -r`;
  1480. my ($ma, $mi1, $mi2) = split("\\.", $verstr);
  1481. ($mi2) = $mi2 =~ /(\d+)/;
  1482. my $ver = $ma*10000 + $mi1*100 + $mi2;
  1483. if ($ver < $minver) {
  1484. disable('too-old-kernel', 'afalgeng');
  1485. } else {
  1486. push @{$config{engdirs}}, "afalg";
  1487. }
  1488. } else {
  1489. disable('cross-compiling', 'afalgeng');
  1490. }
  1491. } else {
  1492. disable('not-linux', 'afalgeng');
  1493. }
  1494. }
  1495. unless ($disabled{devcryptoeng}) {
  1496. if ($target =~ m/^BSD/) {
  1497. my $maxver = 5*100 + 7;
  1498. my $sysstr = `uname -s`;
  1499. my $verstr = `uname -r`;
  1500. $sysstr =~ s|\R$||;
  1501. $verstr =~ s|\R$||;
  1502. my ($ma, $mi, @rest) = split m|\.|, $verstr;
  1503. my $ver = $ma*100 + $mi;
  1504. if ($sysstr eq 'OpenBSD' && $ver >= $maxver) {
  1505. disable('too-new-kernel', 'devcryptoeng');
  1506. }
  1507. }
  1508. }
  1509. unless ($disabled{ktls}) {
  1510. $config{ktls}="";
  1511. if ($target =~ m/^linux/) {
  1512. my $usr = "/usr/$config{cross_compile_prefix}";
  1513. chop($usr);
  1514. if ($config{cross_compile_prefix} eq "") {
  1515. $usr = "/usr";
  1516. }
  1517. my $minver = (4 << 16) + (13 << 8) + 0;
  1518. my @verstr = split(" ",`cat $usr/include/linux/version.h | grep LINUX_VERSION_CODE`);
  1519. if ($verstr[2] < $minver) {
  1520. disable('too-old-kernel', 'ktls');
  1521. }
  1522. } elsif ($target =~ m/^BSD/) {
  1523. my $cc = $config{CROSS_COMPILE}.$config{CC};
  1524. system("printf '#include <sys/types.h>\n#include <sys/ktls.h>' | $cc -E - >/dev/null 2>&1");
  1525. if ($? != 0) {
  1526. disable('too-old-freebsd', 'ktls');
  1527. }
  1528. } else {
  1529. disable('not-linux-or-freebsd', 'ktls');
  1530. }
  1531. }
  1532. push @{$config{openssl_other_defines}}, "OPENSSL_NO_KTLS" if ($disabled{ktls});
  1533. # Get the extra flags used when building shared libraries and modules. We
  1534. # do this late because some of them depend on %disabled.
  1535. # Make the flags to build DSOs the same as for shared libraries unless they
  1536. # are already defined
  1537. $target{module_cflags} = $target{shared_cflag} unless defined $target{module_cflags};
  1538. $target{module_cxxflags} = $target{shared_cxxflag} unless defined $target{module_cxxflags};
  1539. $target{module_ldflags} = $target{shared_ldflag} unless defined $target{module_ldflags};
  1540. {
  1541. my $shared_info_pl =
  1542. catfile(dirname($0), "Configurations", "shared-info.pl");
  1543. my %shared_info = read_eval_file($shared_info_pl);
  1544. push @{$target{_conf_fname_int}}, $shared_info_pl;
  1545. my $si = $target{shared_target};
  1546. while (ref $si ne "HASH") {
  1547. last if ! defined $si;
  1548. if (ref $si eq "CODE") {
  1549. $si = $si->();
  1550. } else {
  1551. $si = $shared_info{$si};
  1552. }
  1553. }
  1554. # Some of the 'shared_target' values don't have any entries in
  1555. # %shared_info. That's perfectly fine, AS LONG AS the build file
  1556. # template knows how to handle this. That is currently the case for
  1557. # Windows and VMS.
  1558. if (defined $si) {
  1559. # Just as above, copy certain shared_* attributes to the corresponding
  1560. # module_ attribute unless the latter is already defined
  1561. $si->{module_cflags} = $si->{shared_cflag} unless defined $si->{module_cflags};
  1562. $si->{module_cxxflags} = $si->{shared_cxxflag} unless defined $si->{module_cxxflags};
  1563. $si->{module_ldflags} = $si->{shared_ldflag} unless defined $si->{module_ldflags};
  1564. foreach (sort keys %$si) {
  1565. $target{$_} = defined $target{$_}
  1566. ? add($si->{$_})->($target{$_})
  1567. : $si->{$_};
  1568. }
  1569. }
  1570. }
  1571. # ALL MODIFICATIONS TO %disabled, %config and %target MUST BE DONE FROM HERE ON
  1572. ######################################################################
  1573. # Build up information for skipping certain directories depending on disabled
  1574. # features, as well as setting up macros for disabled features.
  1575. # This is a tentative database of directories to skip. Some entries may not
  1576. # correspond to anything real, but that's ok, they will simply be ignored.
  1577. # The actual processing of these entries is done in the build.info lookup
  1578. # loop further down.
  1579. #
  1580. # The key is a Unix formatted path in the source tree, the value is an index
  1581. # into %disabled_info, so any existing path gets added to a corresponding
  1582. # 'skipped' entry in there with the list of skipped directories.
  1583. my %skipdir = ();
  1584. my %disabled_info = (); # For configdata.pm
  1585. foreach my $what (sort keys %disabled) {
  1586. # There are deprecated disablables that translate to themselves.
  1587. # They cause disabling cascades, but should otherwise not regiter.
  1588. next if $deprecated_disablables{$what};
  1589. # The generated $disabled{"deprecated-x.y"} entries are special
  1590. # and treated properly elsewhere
  1591. next if $what =~ m|^deprecated-|;
  1592. $config{options} .= " no-$what";
  1593. if (!grep { $what eq $_ } ( 'buildtest-c++', 'fips', 'threads', 'shared',
  1594. 'module', 'pic', 'dynamic-engine', 'makedepend',
  1595. 'zlib-dynamic', 'zlib', 'sse2', 'legacy' )) {
  1596. (my $WHAT = uc $what) =~ s|-|_|g;
  1597. my $skipdir = $what;
  1598. # fix-up crypto/directory name(s)
  1599. $skipdir = "ripemd" if $what eq "rmd160";
  1600. $skipdir = "whrlpool" if $what eq "whirlpool";
  1601. my $macro = $disabled_info{$what}->{macro} = "OPENSSL_NO_$WHAT";
  1602. push @{$config{openssl_feature_defines}}, $macro;
  1603. $skipdir{engines} = $what if $what eq 'engine';
  1604. $skipdir{"crypto/$skipdir"} = $what
  1605. unless $what eq 'async' || $what eq 'err' || $what eq 'dso';
  1606. }
  1607. }
  1608. if ($disabled{"dynamic-engine"}) {
  1609. push @{$config{openssl_feature_defines}}, "OPENSSL_NO_DYNAMIC_ENGINE";
  1610. } else {
  1611. push @{$config{openssl_feature_defines}}, "OPENSSL_NO_STATIC_ENGINE";
  1612. }
  1613. # If we use the unified build, collect information from build.info files
  1614. my %unified_info = ();
  1615. my $buildinfo_debug = defined($ENV{CONFIGURE_DEBUG_BUILDINFO});
  1616. if ($builder eq "unified") {
  1617. use Text::Template 1.46;
  1618. sub cleandir {
  1619. my $base = shift;
  1620. my $dir = shift;
  1621. my $relativeto = shift || ".";
  1622. $dir = catdir($base,$dir) unless isabsolute($dir);
  1623. # Make sure the directories we're building in exists
  1624. mkpath($dir);
  1625. my $res = abs2rel(absolutedir($dir), rel2abs($relativeto));
  1626. #print STDERR "DEBUG[cleandir]: $dir , $base => $res\n";
  1627. return $res;
  1628. }
  1629. sub cleanfile {
  1630. my $base = shift;
  1631. my $file = shift;
  1632. my $relativeto = shift || ".";
  1633. $file = catfile($base,$file) unless isabsolute($file);
  1634. my $d = dirname($file);
  1635. my $f = basename($file);
  1636. # Make sure the directories we're building in exists
  1637. mkpath($d);
  1638. my $res = abs2rel(catfile(absolutedir($d), $f), rel2abs($relativeto));
  1639. #print STDERR "DEBUG[cleanfile]: $d , $f => $res\n";
  1640. return $res;
  1641. }
  1642. # Store the name of the template file we will build the build file from
  1643. # in %config. This may be useful for the build file itself.
  1644. my @build_file_template_names =
  1645. ( $builder_platform."-".$target{build_file}.".tmpl",
  1646. $target{build_file}.".tmpl" );
  1647. my @build_file_templates = ();
  1648. # First, look in the user provided directory, if given
  1649. if (defined env($local_config_envname)) {
  1650. @build_file_templates =
  1651. map {
  1652. if ($^O eq 'VMS') {
  1653. # VMS environment variables are logical names,
  1654. # which can be used as is
  1655. $local_config_envname . ':' . $_;
  1656. } else {
  1657. catfile(env($local_config_envname), $_);
  1658. }
  1659. }
  1660. @build_file_template_names;
  1661. }
  1662. # Then, look in our standard directory
  1663. push @build_file_templates,
  1664. ( map { cleanfile($srcdir, catfile("Configurations", $_), $blddir) }
  1665. @build_file_template_names );
  1666. my $build_file_template;
  1667. for $_ (@build_file_templates) {
  1668. $build_file_template = $_;
  1669. last if -f $build_file_template;
  1670. $build_file_template = undef;
  1671. }
  1672. if (!defined $build_file_template) {
  1673. die "*** Couldn't find any of:\n", join("\n", @build_file_templates), "\n";
  1674. }
  1675. $config{build_file_templates}
  1676. = [ cleanfile($srcdir, catfile("Configurations", "common0.tmpl"),
  1677. $blddir),
  1678. $build_file_template,
  1679. cleanfile($srcdir, catfile("Configurations", "common.tmpl"),
  1680. $blddir) ];
  1681. my @build_dirs = ( [ ] ); # current directory
  1682. $config{build_infos} = [ ];
  1683. my %ordinals = ();
  1684. while (@build_dirs) {
  1685. my @curd = @{shift @build_dirs};
  1686. my $sourced = catdir($srcdir, @curd);
  1687. my $buildd = catdir($blddir, @curd);
  1688. my $unixdir = join('/', @curd);
  1689. if (exists $skipdir{$unixdir}) {
  1690. my $what = $skipdir{$unixdir};
  1691. push @{$disabled_info{$what}->{skipped}}, catdir(@curd);
  1692. next;
  1693. }
  1694. mkpath($buildd);
  1695. my $f = 'build.info';
  1696. # The basic things we're trying to build
  1697. my @programs = ();
  1698. my @libraries = ();
  1699. my @modules = ();
  1700. my @scripts = ();
  1701. my %sources = ();
  1702. my %shared_sources = ();
  1703. my %includes = ();
  1704. my %defines = ();
  1705. my %depends = ();
  1706. my %generate = ();
  1707. my %htmldocs = ();
  1708. my %mandocs = ();
  1709. # Support for $variablename in build.info files.
  1710. # Embedded perl code is the ultimate master, still. If its output
  1711. # contains a dollar sign, it had better be escaped, or it will be
  1712. # taken for a variable name prefix.
  1713. my %variables = ();
  1714. # Variable name syntax
  1715. my $variable_name_re = qr/(?P<VARIABLE>[[:alpha:]][[:alnum:]_]*)/;
  1716. # Value modifier syntaxes
  1717. my $variable_subst_re = qr/\/(?P<RE>(?:\\\/|.)*?)\/(?P<SUBST>.*?)/;
  1718. # Variable reference
  1719. my $variable_simple_re = qr/(?<!\\)\$${variable_name_re}/;
  1720. my $variable_w_mod_re =
  1721. qr/(?<!\\)\$\{${variable_name_re}(?P<MOD>(?:\\\/|.)*?)\}/;
  1722. # Tie it all together
  1723. my $variable_re = qr/${variable_simple_re}|${variable_w_mod_re}/;
  1724. my $expand_variables = sub {
  1725. my $value = '';
  1726. my $value_rest = shift;
  1727. if ($ENV{CONFIGURE_DEBUG_VARIABLE_EXPAND}) {
  1728. print STDERR
  1729. "DEBUG[\$expand_variables] Parsed '$value_rest' ...\n"
  1730. }
  1731. while ($value_rest =~ /${variable_re}/) {
  1732. # We must save important regexp values, because the next
  1733. # regexp clears them
  1734. my $mod = $+{MOD};
  1735. my $variable_value = $variables{$+{VARIABLE}};
  1736. $value_rest = $';
  1737. $value .= $`;
  1738. # Process modifier expressions, if present
  1739. if (defined $mod) {
  1740. if ($mod =~ /^${variable_subst_re}$/) {
  1741. my $re = $+{RE};
  1742. my $subst = $+{SUBST};
  1743. $variable_value =~ s/\Q$re\E/$subst/g;
  1744. if ($ENV{CONFIGURE_DEBUG_VARIABLE_EXPAND}) {
  1745. print STDERR
  1746. "DEBUG[\$expand_variables] ... and substituted ",
  1747. "'$re' with '$subst'\n";
  1748. }
  1749. }
  1750. }
  1751. $value .= $variable_value;
  1752. }
  1753. if ($ENV{CONFIGURE_DEBUG_VARIABLE_EXPAND}) {
  1754. print STDERR
  1755. "DEBUG[\$expand_variables] ... into: '$value$value_rest'\n";
  1756. }
  1757. return $value . $value_rest;
  1758. };
  1759. # Support for attributes in build.info files
  1760. my %attributes = ();
  1761. my $handle_attributes = sub {
  1762. my $attr_str = shift;
  1763. my $ref = shift;
  1764. my @goals = @_;
  1765. return unless defined $attr_str;
  1766. my @a = tokenize($attr_str, qr|\s*,\s*|);
  1767. foreach my $a (@a) {
  1768. my $ac = 1;
  1769. my $ak = $a;
  1770. my $av = 1;
  1771. if ($a =~ m|^(!)?(.*?)\s* = \s*(.*?)$|x) {
  1772. $ac = ! $1;
  1773. $ak = $2;
  1774. $av = $3;
  1775. }
  1776. foreach my $g (@goals) {
  1777. if ($ac) {
  1778. $$ref->{$g}->{$ak} = $av;
  1779. } else {
  1780. delete $$ref->{$g}->{$ak};
  1781. }
  1782. }
  1783. }
  1784. };
  1785. # Support for pushing values on multiple indexes of a given hash
  1786. # array.
  1787. my $push_to = sub {
  1788. my $valueref = shift;
  1789. my $index_str = shift; # May be undef or empty
  1790. my $attrref = shift; # May be undef
  1791. my $attr_str = shift;
  1792. my @values = @_;
  1793. if (defined $index_str) {
  1794. my @indexes = ( '' );
  1795. if ($index_str !~ m|^\s*$|) {
  1796. @indexes = tokenize($index_str);
  1797. }
  1798. foreach (@indexes) {
  1799. push @{$valueref->{$_}}, @values;
  1800. if (defined $attrref) {
  1801. $handle_attributes->($attr_str, \$$attrref->{$_},
  1802. @values);
  1803. }
  1804. }
  1805. } else {
  1806. push @$valueref, @values;
  1807. $handle_attributes->($attr_str, $attrref, @values)
  1808. if defined $attrref;
  1809. }
  1810. };
  1811. # We want to detect configdata.pm in the source tree, so we
  1812. # don't use it if the build tree is different.
  1813. my $src_configdata = cleanfile($srcdir, "configdata.pm", $blddir);
  1814. if ($buildinfo_debug) {
  1815. print STDERR "DEBUG: Reading ",catfile($sourced, $f),"\n";
  1816. }
  1817. push @{$config{build_infos}}, catfile(abs2rel($sourced, $blddir), $f);
  1818. my $template =
  1819. Text::Template->new(TYPE => 'FILE',
  1820. SOURCE => catfile($sourced, $f),
  1821. PREPEND => qq{use lib "$FindBin::Bin/util/perl";});
  1822. die "Something went wrong with $sourced/$f: $!\n" unless $template;
  1823. my @text =
  1824. split /^/m,
  1825. $template->fill_in(HASH => { config => \%config,
  1826. target => \%target,
  1827. disabled => \%disabled,
  1828. withargs => \%withargs,
  1829. builddir => abs2rel($buildd, $blddir),
  1830. sourcedir => abs2rel($sourced, $blddir),
  1831. buildtop => abs2rel($blddir, $blddir),
  1832. sourcetop => abs2rel($srcdir, $blddir) },
  1833. DELIMITERS => [ "{-", "-}" ]);
  1834. # The top item of this stack has the following values
  1835. # -2 positive already run and we found ELSE (following ELSIF should fail)
  1836. # -1 positive already run (skip until ENDIF)
  1837. # 0 negatives so far (if we're at a condition, check it)
  1838. # 1 last was positive (don't skip lines until next ELSE, ELSIF or ENDIF)
  1839. # 2 positive ELSE (following ELSIF should fail)
  1840. my @skip = ();
  1841. # A few useful generic regexps
  1842. my $index_re = qr/\[\s*(?P<INDEX>(?:\\.|.)*?)\s*\]/;
  1843. my $cond_re = qr/\[\s*(?P<COND>(?:\\.|.)*?)\s*\]/;
  1844. my $attribs_re = qr/(?:\{\s*(?P<ATTRIBS>(?:\\.|.)*?)\s*\})?/;
  1845. my $value_re = qr/\s*(?P<VALUE>.*?)\s*/;
  1846. collect_information(
  1847. collect_from_array([ @text ],
  1848. qr/\\$/ => sub { my $l1 = shift; my $l2 = shift;
  1849. $l1 =~ s/\\$//; $l1.$l2 }),
  1850. # Info we're looking for
  1851. qr/^\s* IF ${cond_re} \s*$/x
  1852. => sub {
  1853. if (! @skip || $skip[$#skip] > 0) {
  1854. push @skip, !! $expand_variables->($+{COND});
  1855. } else {
  1856. push @skip, -1;
  1857. }
  1858. },
  1859. qr/^\s* ELSIF ${cond_re} \s*$/x
  1860. => sub { die "ELSIF out of scope" if ! @skip;
  1861. die "ELSIF following ELSE" if abs($skip[$#skip]) == 2;
  1862. $skip[$#skip] = -1 if $skip[$#skip] != 0;
  1863. $skip[$#skip] = !! $expand_variables->($+{COND})
  1864. if $skip[$#skip] == 0; },
  1865. qr/^\s* ELSE \s*$/x
  1866. => sub { die "ELSE out of scope" if ! @skip;
  1867. $skip[$#skip] = -2 if $skip[$#skip] != 0;
  1868. $skip[$#skip] = 2 if $skip[$#skip] == 0; },
  1869. qr/^\s* ENDIF \s*$/x
  1870. => sub { die "ENDIF out of scope" if ! @skip;
  1871. pop @skip; },
  1872. qr/^\s* ${variable_re} \s* = ${value_re} $/x
  1873. => sub {
  1874. if (!@skip || $skip[$#skip] > 0) {
  1875. $variables{$+{VARIABLE}} = $expand_variables->($+{VALUE});
  1876. }
  1877. },
  1878. qr/^\s* SUBDIRS \s* = ${value_re} $/x
  1879. => sub {
  1880. if (!@skip || $skip[$#skip] > 0) {
  1881. foreach (tokenize($expand_variables->($+{VALUE}))) {
  1882. push @build_dirs, [ @curd, splitdir($_, 1) ];
  1883. }
  1884. }
  1885. },
  1886. qr/^\s* PROGRAMS ${attribs_re} \s* = ${value_re} $/x
  1887. => sub { $push_to->(\@programs, undef,
  1888. \$attributes{programs}, $+{ATTRIBS},
  1889. tokenize($expand_variables->($+{VALUE})))
  1890. if !@skip || $skip[$#skip] > 0; },
  1891. qr/^\s* LIBS ${attribs_re} \s* = ${value_re} $/x
  1892. => sub { $push_to->(\@libraries, undef,
  1893. \$attributes{libraries}, $+{ATTRIBS},
  1894. tokenize($expand_variables->($+{VALUE})))
  1895. if !@skip || $skip[$#skip] > 0; },
  1896. qr/^\s* MODULES ${attribs_re} \s* = ${value_re} $/x
  1897. => sub { $push_to->(\@modules, undef,
  1898. \$attributes{modules}, $+{ATTRIBS},
  1899. tokenize($expand_variables->($+{VALUE})))
  1900. if !@skip || $skip[$#skip] > 0; },
  1901. qr/^\s* SCRIPTS ${attribs_re} \s* = ${value_re} $/x
  1902. => sub { $push_to->(\@scripts, undef,
  1903. \$attributes{scripts}, $+{ATTRIBS},
  1904. tokenize($expand_variables->($+{VALUE})))
  1905. if !@skip || $skip[$#skip] > 0; },
  1906. qr/^\s* HTMLDOCS ${index_re} = ${value_re} $/x
  1907. => sub { $push_to->(\%htmldocs, $expand_variables->($+{INDEX}),
  1908. undef, undef,
  1909. tokenize($expand_variables->($+{VALUE})))
  1910. if !@skip || $skip[$#skip] > 0; },
  1911. qr/^\s* MANDOCS ${index_re} = ${value_re} $/x
  1912. => sub { $push_to->(\%mandocs, $expand_variables->($+{INDEX}),
  1913. undef, undef,
  1914. tokenize($expand_variables->($+{VALUE})))
  1915. if !@skip || $skip[$#skip] > 0; },
  1916. qr/^\s* SOURCE ${index_re} = ${value_re} $/x
  1917. => sub { $push_to->(\%sources, $expand_variables->($+{INDEX}),
  1918. undef, undef,
  1919. tokenize($expand_variables->($+{VALUE})))
  1920. if !@skip || $skip[$#skip] > 0; },
  1921. qr/^\s* SHARED_SOURCE ${index_re} = ${value_re} $/x
  1922. => sub { $push_to->(\%shared_sources, $expand_variables->($+{INDEX}),
  1923. undef, undef,
  1924. tokenize($expand_variables->($+{VALUE})))
  1925. if !@skip || $skip[$#skip] > 0; },
  1926. qr/^\s* INCLUDE ${index_re} = ${value_re} $/x
  1927. => sub { $push_to->(\%includes, $expand_variables->($+{INDEX}),
  1928. undef, undef,
  1929. tokenize($expand_variables->($+{VALUE})))
  1930. if !@skip || $skip[$#skip] > 0; },
  1931. qr/^\s* DEFINE ${index_re} = ${value_re} $/x
  1932. => sub { $push_to->(\%defines, $expand_variables->($+{INDEX}),
  1933. undef, undef,
  1934. tokenize($expand_variables->($+{VALUE})))
  1935. if !@skip || $skip[$#skip] > 0; },
  1936. qr/^\s* DEPEND ${index_re} ${attribs_re} = ${value_re} $/x
  1937. => sub { $push_to->(\%depends, $expand_variables->($+{INDEX}),
  1938. \$attributes{depends}, $+{ATTRIBS},
  1939. tokenize($expand_variables->($+{VALUE})))
  1940. if !@skip || $skip[$#skip] > 0; },
  1941. qr/^\s* GENERATE ${index_re} = ${value_re} $/x
  1942. => sub { $push_to->(\%generate, $expand_variables->($+{INDEX}),
  1943. undef, undef, $+{VALUE})
  1944. if !@skip || $skip[$#skip] > 0; },
  1945. qr/^\s* (?:\#.*)? $/x => sub { },
  1946. "OTHERWISE" => sub { die "Something wrong with this line:\n$_\nat $sourced/$f" },
  1947. "BEFORE" => sub {
  1948. if ($buildinfo_debug) {
  1949. print STDERR "DEBUG: Parsing ",join(" ", @_),"\n";
  1950. print STDERR "DEBUG: ... before parsing, skip stack is ",join(" ", map { int($_) } @skip),"\n";
  1951. }
  1952. },
  1953. "AFTER" => sub {
  1954. if ($buildinfo_debug) {
  1955. print STDERR "DEBUG: .... after parsing, skip stack is ",join(" ", map { int($_) } @skip),"\n";
  1956. }
  1957. },
  1958. );
  1959. die "runaway IF?" if (@skip);
  1960. if (grep { defined $attributes{modules}->{$_}->{engine} } keys %attributes
  1961. and !$config{dynamic_engines}) {
  1962. die <<"EOF"
  1963. ENGINES can only be used if configured with 'dynamic-engine'.
  1964. This is usually a fault in a build.info file.
  1965. EOF
  1966. }
  1967. {
  1968. my %infos = ( programs => [ @programs ],
  1969. libraries => [ @libraries ],
  1970. modules => [ @modules ],
  1971. scripts => [ @scripts ] );
  1972. foreach my $k (keys %infos) {
  1973. foreach (@{$infos{$k}}) {
  1974. my $item = cleanfile($buildd, $_, $blddir);
  1975. $unified_info{$k}->{$item} = 1;
  1976. # Fix up associated attributes
  1977. $unified_info{attributes}->{$k}->{$item} =
  1978. $attributes{$k}->{$_}
  1979. if defined $attributes{$k}->{$_};
  1980. }
  1981. }
  1982. }
  1983. # Check that we haven't defined any library as both shared and
  1984. # explicitly static. That is forbidden.
  1985. my @doubles = ();
  1986. foreach (grep /\.a$/, keys %{$unified_info{libraries}}) {
  1987. (my $l = $_) =~ s/\.a$//;
  1988. push @doubles, $l if defined $unified_info{libraries}->{$l};
  1989. }
  1990. die "these libraries are both explicitly static and shared:\n ",
  1991. join(" ", @doubles), "\n"
  1992. if @doubles;
  1993. foreach (keys %sources) {
  1994. my $dest = $_;
  1995. my $ddest = cleanfile($buildd, $_, $blddir);
  1996. foreach (@{$sources{$dest}}) {
  1997. my $s = cleanfile($sourced, $_, $blddir);
  1998. # If it's generated or we simply don't find it in the source
  1999. # tree, we assume it's in the build tree.
  2000. if ($s eq $src_configdata || $generate{$_} || ! -f $s) {
  2001. $s = cleanfile($buildd, $_, $blddir);
  2002. }
  2003. # We recognise C++, C and asm files
  2004. if ($s =~ /\.(cc|cpp|c|s|S)$/) {
  2005. my $o = $_;
  2006. $o =~ s/\.[csS]$/.o/; # C and assembler
  2007. $o =~ s/\.(cc|cpp)$/_cc.o/; # C++
  2008. $o = cleanfile($buildd, $o, $blddir);
  2009. $unified_info{sources}->{$ddest}->{$o} = -1;
  2010. $unified_info{sources}->{$o}->{$s} = -1;
  2011. } elsif ($s =~ /\.rc$/) {
  2012. # We also recognise resource files
  2013. my $o = $_;
  2014. $o =~ s/\.rc$/.res/; # Resource configuration
  2015. my $o = cleanfile($buildd, $o, $blddir);
  2016. $unified_info{sources}->{$ddest}->{$o} = -1;
  2017. $unified_info{sources}->{$o}->{$s} = -1;
  2018. } else {
  2019. $unified_info{sources}->{$ddest}->{$s} = 1;
  2020. }
  2021. }
  2022. }
  2023. foreach (keys %shared_sources) {
  2024. my $dest = $_;
  2025. my $ddest = cleanfile($buildd, $_, $blddir);
  2026. foreach (@{$shared_sources{$dest}}) {
  2027. my $s = cleanfile($sourced, $_, $blddir);
  2028. # If it's generated or we simply don't find it in the source
  2029. # tree, we assume it's in the build tree.
  2030. if ($s eq $src_configdata || $generate{$_} || ! -f $s) {
  2031. $s = cleanfile($buildd, $_, $blddir);
  2032. }
  2033. if ($s =~ /\.(cc|cpp|c|s|S)$/) {
  2034. # We recognise C++, C and asm files
  2035. my $o = $_;
  2036. $o =~ s/\.[csS]$/.o/; # C and assembler
  2037. $o =~ s/\.(cc|cpp)$/_cc.o/; # C++
  2038. $o = cleanfile($buildd, $o, $blddir);
  2039. $unified_info{shared_sources}->{$ddest}->{$o} = -1;
  2040. $unified_info{sources}->{$o}->{$s} = -1;
  2041. } elsif ($s =~ /\.rc$/) {
  2042. # We also recognise resource files
  2043. my $o = $_;
  2044. $o =~ s/\.rc$/.res/; # Resource configuration
  2045. my $o = cleanfile($buildd, $o, $blddir);
  2046. $unified_info{shared_sources}->{$ddest}->{$o} = -1;
  2047. $unified_info{sources}->{$o}->{$s} = -1;
  2048. } elsif ($s =~ /\.ld$/) {
  2049. # We also recognise linker scripts (or corresponding)
  2050. # We know they are generated files
  2051. my $ld = cleanfile($buildd, $_, $blddir);
  2052. $unified_info{shared_sources}->{$ddest}->{$ld} = 1;
  2053. } else {
  2054. die "unrecognised source file type for shared library: $s\n";
  2055. }
  2056. }
  2057. }
  2058. foreach (keys %generate) {
  2059. my $dest = $_;
  2060. my $ddest = cleanfile($buildd, $_, $blddir);
  2061. die "more than one generator for $dest: "
  2062. ,join(" ", @{$generate{$_}}),"\n"
  2063. if scalar @{$generate{$_}} > 1;
  2064. my @generator = split /\s+/, $generate{$dest}->[0];
  2065. my $gen = $generator[0];
  2066. $generator[0] = cleanfile($sourced, $gen, $blddir);
  2067. # If the generator is itself generated, it's in the build tree
  2068. if ($generate{$gen}) {
  2069. $generator[0] = cleanfile($buildd, $gen, $blddir);
  2070. }
  2071. $unified_info{generate}->{$ddest} = [ @generator ];
  2072. }
  2073. foreach (keys %depends) {
  2074. my $dest = $_;
  2075. my $ddest = $dest eq "" ? "" : cleanfile($sourced, $_, $blddir);
  2076. # If the destination doesn't exist in source, it can only be
  2077. # a generated file in the build tree.
  2078. if ($ddest ne "" && ($ddest eq $src_configdata || ! -f $ddest)) {
  2079. $ddest = cleanfile($buildd, $_, $blddir);
  2080. }
  2081. foreach (@{$depends{$dest}}) {
  2082. my $d = cleanfile($sourced, $_, $blddir);
  2083. # If we know it's generated, or assume it is because we can't
  2084. # find it in the source tree, we set file we depend on to be
  2085. # in the build tree rather than the source tree.
  2086. if ($d eq $src_configdata
  2087. || (grep { $d eq $_ }
  2088. map { cleanfile($srcdir, $_, $blddir) }
  2089. grep { /\.h$/ } keys %{$unified_info{generate}})
  2090. || ! -f $d) {
  2091. $d = cleanfile($buildd, $_, $blddir);
  2092. }
  2093. $unified_info{depends}->{$ddest}->{$d} = 1;
  2094. # Fix up associated attributes
  2095. $unified_info{attributes}->{depends}->{$ddest}->{$d} =
  2096. $attributes{depends}->{$dest}->{$_}
  2097. if defined $attributes{depends}->{$dest}->{$_};
  2098. }
  2099. }
  2100. foreach (keys %includes) {
  2101. my $dest = $_;
  2102. my $ddest = cleanfile($sourced, $_, $blddir);
  2103. # If the destination doesn't exist in source, it can only be
  2104. # a generated file in the build tree.
  2105. if ($ddest eq $src_configdata || ! -f $ddest) {
  2106. $ddest = cleanfile($buildd, $_, $blddir);
  2107. }
  2108. foreach (@{$includes{$dest}}) {
  2109. my $is = cleandir($sourced, $_, $blddir);
  2110. my $ib = cleandir($buildd, $_, $blddir);
  2111. push @{$unified_info{includes}->{$ddest}->{source}}, $is
  2112. unless grep { $_ eq $is } @{$unified_info{includes}->{$ddest}->{source}};
  2113. push @{$unified_info{includes}->{$ddest}->{build}}, $ib
  2114. unless grep { $_ eq $ib } @{$unified_info{includes}->{$ddest}->{build}};
  2115. }
  2116. }
  2117. foreach my $dest (keys %defines) {
  2118. my $ddest;
  2119. if ($dest ne "") {
  2120. $ddest = cleanfile($sourced, $dest, $blddir);
  2121. # If the destination doesn't exist in source, it can only
  2122. # be a generated file in the build tree.
  2123. if (! -f $ddest) {
  2124. $ddest = cleanfile($buildd, $dest, $blddir);
  2125. }
  2126. }
  2127. foreach my $v (@{$defines{$dest}}) {
  2128. $v =~ m|^([^=]*)(=.*)?$|;
  2129. die "0 length macro name not permitted\n" if $1 eq "";
  2130. if ($dest ne "") {
  2131. die "$1 defined more than once\n"
  2132. if defined $unified_info{defines}->{$ddest}->{$1};
  2133. $unified_info{defines}->{$ddest}->{$1} = $2;
  2134. } else {
  2135. die "$1 defined more than once\n"
  2136. if grep { $v eq $_ } @{$config{defines}};
  2137. push @{$config{defines}}, $v;
  2138. }
  2139. }
  2140. }
  2141. foreach my $section (keys %htmldocs) {
  2142. foreach (@{$htmldocs{$section}}) {
  2143. my $htmldocs = cleanfile($buildd, $_, $blddir);
  2144. $unified_info{htmldocs}->{$section}->{$htmldocs} = 1;
  2145. }
  2146. }
  2147. foreach my $section (keys %mandocs) {
  2148. foreach (@{$mandocs{$section}}) {
  2149. my $mandocs = cleanfile($buildd, $_, $blddir);
  2150. $unified_info{mandocs}->{$section}->{$mandocs} = 1;
  2151. }
  2152. }
  2153. }
  2154. my $ordinals_text = join(', ', sort keys %ordinals);
  2155. warn <<"EOF" if $ordinals_text;
  2156. WARNING: ORDINALS were specified for $ordinals_text
  2157. They are ignored and should be replaced with a combination of GENERATE,
  2158. DEPEND and SHARED_SOURCE.
  2159. EOF
  2160. # Go through the sources of all libraries and check that the same basename
  2161. # doesn't appear more than once. Some static library archivers depend on
  2162. # them being unique.
  2163. {
  2164. my $err = 0;
  2165. foreach my $prod (keys %{$unified_info{libraries}}) {
  2166. my @prod_sources =
  2167. map { keys %{$unified_info{sources}->{$_}} }
  2168. keys %{$unified_info{sources}->{$prod}};
  2169. my %srccnt = ();
  2170. # Count how many times a given each source basename
  2171. # appears for each product.
  2172. foreach my $src (@prod_sources) {
  2173. $srccnt{basename $src}++;
  2174. }
  2175. foreach my $src (keys %srccnt) {
  2176. if ((my $cnt = $srccnt{$src}) > 1) {
  2177. print STDERR "$src appears $cnt times for the product $prod\n";
  2178. $err++
  2179. }
  2180. }
  2181. }
  2182. die if $err > 0;
  2183. }
  2184. # Massage the result
  2185. # If we depend on a header file or a perl module, add an inclusion of
  2186. # its directory to allow smoothe inclusion
  2187. foreach my $dest (keys %{$unified_info{depends}}) {
  2188. next if $dest eq "";
  2189. foreach my $d (keys %{$unified_info{depends}->{$dest}}) {
  2190. next unless $d =~ /\.(h|pm)$/;
  2191. my $i = dirname($d);
  2192. my $spot =
  2193. $d eq "configdata.pm" || defined($unified_info{generate}->{$d})
  2194. ? 'build' : 'source';
  2195. push @{$unified_info{includes}->{$dest}->{$spot}}, $i
  2196. unless grep { $_ eq $i } @{$unified_info{includes}->{$dest}->{$spot}};
  2197. }
  2198. }
  2199. # Go through all intermediary files and change their names to something that
  2200. # reflects what they will be built for. Note that for some source files,
  2201. # this leads to duplicate object files because they are used multiple times.
  2202. # the goal is to rename all object files according to this scheme:
  2203. # {productname}-{midfix}-{origobjname}.[o|res]
  2204. # the {midfix} is a keyword indicating the type of product, which is mostly
  2205. # valuable for libraries since they come in two forms.
  2206. #
  2207. # This also reorganises the {sources} and {shared_sources} so that the
  2208. # former only contains ALL object files that are supposed to end up in
  2209. # static libraries and programs, while the latter contains ALL object files
  2210. # that are supposed to end up in shared libraries and DSOs.
  2211. # The main reason for having two different source structures is to allow
  2212. # the same name to be used for the static and the shared variants of a
  2213. # library.
  2214. {
  2215. # Take copies so we don't get interference from added stuff
  2216. my %unified_copy = ();
  2217. foreach (('sources', 'shared_sources')) {
  2218. $unified_copy{$_} = { %{$unified_info{$_}} }
  2219. if defined($unified_info{$_});
  2220. delete $unified_info{$_};
  2221. }
  2222. foreach my $prodtype (('programs', 'libraries', 'modules', 'scripts')) {
  2223. # $intent serves multi purposes:
  2224. # - give a prefix for the new object files names
  2225. # - in the case of libraries, rearrange the object files so static
  2226. # libraries use the 'sources' structure exclusively, while shared
  2227. # libraries use the 'shared_sources' structure exclusively.
  2228. my $intent = {
  2229. programs => { bin => { src => [ 'sources' ],
  2230. dst => 'sources' } },
  2231. libraries => { lib => { src => [ 'sources' ],
  2232. dst => 'sources' },
  2233. shlib => { prodselect =>
  2234. sub { grep !/\.a$/, @_ },
  2235. src => [ 'sources',
  2236. 'shared_sources' ],
  2237. dst => 'shared_sources' } },
  2238. modules => { dso => { src => [ 'sources' ],
  2239. dst => 'sources' } },
  2240. scripts => { script => { src => [ 'sources' ],
  2241. dst => 'sources' } }
  2242. } -> {$prodtype};
  2243. foreach my $kind (keys %$intent) {
  2244. next if ($intent->{$kind}->{dst} eq 'shared_sources'
  2245. && $disabled{shared});
  2246. my @src = @{$intent->{$kind}->{src}};
  2247. my $dst = $intent->{$kind}->{dst};
  2248. my $prodselect = $intent->{$kind}->{prodselect} // sub { @_ };
  2249. foreach my $prod ($prodselect->(keys %{$unified_info{$prodtype}})) {
  2250. # %prod_sources has all applicable objects as keys, and
  2251. # their corresponding sources as values
  2252. my %prod_sources =
  2253. map { $_ => [ keys %{$unified_copy{sources}->{$_}} ] }
  2254. map { keys %{$unified_copy{$_}->{$prod}} }
  2255. @src;
  2256. foreach (keys %prod_sources) {
  2257. # Only affect object files and resource files,
  2258. # the others simply get a new value
  2259. # (+1 instead of -1)
  2260. if ($_ =~ /\.(o|res)$/) {
  2261. (my $prodname = $prod) =~ s|\.a$||;
  2262. my $newobj =
  2263. catfile(dirname($_),
  2264. basename($prodname)
  2265. . '-' . $kind
  2266. . '-' . basename($_));
  2267. $unified_info{$dst}->{$prod}->{$newobj} = 1;
  2268. foreach my $src (@{$prod_sources{$_}}) {
  2269. $unified_info{sources}->{$newobj}->{$src} = 1;
  2270. }
  2271. # Adjust dependencies
  2272. foreach my $deps (keys %{$unified_info{depends}->{$_}}) {
  2273. $unified_info{depends}->{$_}->{$deps} = -1;
  2274. $unified_info{depends}->{$newobj}->{$deps} = 1;
  2275. }
  2276. # Adjust includes
  2277. foreach my $k (('source', 'build')) {
  2278. next unless
  2279. defined($unified_info{includes}->{$_}->{$k});
  2280. my @incs = @{$unified_info{includes}->{$_}->{$k}};
  2281. $unified_info{includes}->{$newobj}->{$k} = [ @incs ];
  2282. }
  2283. } else {
  2284. $unified_info{$dst}->{$prod}->{$_} = 1;
  2285. }
  2286. }
  2287. }
  2288. }
  2289. }
  2290. }
  2291. # At this point, we have a number of sources with the value -1. They
  2292. # aren't part of the local build and are probably meant for a different
  2293. # platform, and can therefore be cleaned away. That happens when making
  2294. # %unified_info more efficient below.
  2295. ### Make unified_info a bit more efficient
  2296. # One level structures
  2297. foreach (("programs", "libraries", "modules", "scripts")) {
  2298. $unified_info{$_} = [ sort keys %{$unified_info{$_}} ];
  2299. }
  2300. # Two level structures
  2301. foreach my $l1 (("sources", "shared_sources", "ldadd", "depends",
  2302. "htmldocs", "mandocs")) {
  2303. foreach my $l2 (sort keys %{$unified_info{$l1}}) {
  2304. my @items =
  2305. sort
  2306. grep { $unified_info{$l1}->{$l2}->{$_} > 0 }
  2307. keys %{$unified_info{$l1}->{$l2}};
  2308. if (@items) {
  2309. $unified_info{$l1}->{$l2} = [ @items ];
  2310. } else {
  2311. delete $unified_info{$l1}->{$l2};
  2312. }
  2313. }
  2314. }
  2315. # Defines
  2316. foreach my $dest (sort keys %{$unified_info{defines}}) {
  2317. $unified_info{defines}->{$dest}
  2318. = [ map { $_.$unified_info{defines}->{$dest}->{$_} }
  2319. sort keys %{$unified_info{defines}->{$dest}} ];
  2320. }
  2321. # Includes
  2322. foreach my $dest (sort keys %{$unified_info{includes}}) {
  2323. if (defined($unified_info{includes}->{$dest}->{build})) {
  2324. my @source_includes = ();
  2325. @source_includes = ( @{$unified_info{includes}->{$dest}->{source}} )
  2326. if defined($unified_info{includes}->{$dest}->{source});
  2327. $unified_info{includes}->{$dest} =
  2328. [ @{$unified_info{includes}->{$dest}->{build}} ];
  2329. foreach my $inc (@source_includes) {
  2330. push @{$unified_info{includes}->{$dest}}, $inc
  2331. unless grep { $_ eq $inc } @{$unified_info{includes}->{$dest}};
  2332. }
  2333. } elsif (defined($unified_info{includes}->{$dest}->{source})) {
  2334. $unified_info{includes}->{$dest} =
  2335. [ @{$unified_info{includes}->{$dest}->{source}} ];
  2336. } else {
  2337. delete $unified_info{includes}->{$dest};
  2338. }
  2339. }
  2340. # For convenience collect information regarding directories where
  2341. # files are generated, those generated files and the end product
  2342. # they end up in where applicable. Then, add build rules for those
  2343. # directories
  2344. my %loopinfo = ( "lib" => [ @{$unified_info{libraries}} ],
  2345. "dso" => [ @{$unified_info{modules}} ],
  2346. "bin" => [ @{$unified_info{programs}} ],
  2347. "script" => [ @{$unified_info{scripts}} ],
  2348. "docs" => [ (map { @{$unified_info{htmldocs}->{$_} // []} }
  2349. keys %{$unified_info{htmldocs} // {}}),
  2350. (map { @{$unified_info{mandocs}->{$_} // []} }
  2351. keys %{$unified_info{mandocs} // {}}) ] );
  2352. foreach my $type (keys %loopinfo) {
  2353. foreach my $product (@{$loopinfo{$type}}) {
  2354. my %dirs = ();
  2355. my $pd = dirname($product);
  2356. foreach (@{$unified_info{sources}->{$product} // []},
  2357. @{$unified_info{shared_sources}->{$product} // []}) {
  2358. my $d = dirname($_);
  2359. # We don't want to create targets for source directories
  2360. # when building out of source
  2361. next if ($config{sourcedir} ne $config{builddir}
  2362. && $d =~ m|^\Q$config{sourcedir}\E|);
  2363. # We already have a "test" target, and the current directory
  2364. # is just silly to make a target for
  2365. next if $d eq "test" || $d eq ".";
  2366. $dirs{$d} = 1;
  2367. push @{$unified_info{dirinfo}->{$d}->{deps}}, $_
  2368. if $d ne $pd;
  2369. }
  2370. foreach (keys %dirs) {
  2371. push @{$unified_info{dirinfo}->{$_}->{products}->{$type}},
  2372. $product;
  2373. }
  2374. }
  2375. }
  2376. }
  2377. # For the schemes that need it, we provide the old *_obj configs
  2378. # from the *_asm_obj ones
  2379. foreach (grep /_(asm|aux)_src$/, keys %target) {
  2380. my $src = $_;
  2381. (my $obj = $_) =~ s/_(asm|aux)_src$/_obj/;
  2382. $target{$obj} = $target{$src};
  2383. $target{$obj} =~ s/\.[csS]\b/.o/g; # C and assembler
  2384. $target{$obj} =~ s/\.(cc|cpp)\b/_cc.o/g; # C++
  2385. }
  2386. # Write down our configuration where it fits #########################
  2387. my %template_vars = (
  2388. config => \%config,
  2389. target => \%target,
  2390. disablables => \@disablables,
  2391. disablables_int => \@disablables_int,
  2392. disabled => \%disabled,
  2393. withargs => \%withargs,
  2394. unified_info => \%unified_info,
  2395. tls => \@tls,
  2396. dtls => \@dtls,
  2397. makevars => [ sort keys %user ],
  2398. disabled_info => \%disabled_info,
  2399. user_crossable => \@user_crossable,
  2400. );
  2401. my $configdata_outname = 'configdata.pm';
  2402. print "Creating $configdata_outname\n";
  2403. open CONFIGDATA, ">$configdata_outname.new"
  2404. or die "Trying to create $configdata_outname.new: $!";
  2405. my $configdata_tmplname = cleanfile($srcdir, "configdata.pm.in", $blddir);
  2406. my $configdata_tmpl =
  2407. OpenSSL::Template->new(TYPE => 'FILE', SOURCE => $configdata_tmplname);
  2408. $configdata_tmpl->fill_in(
  2409. FILENAME => $configdata_tmplname,
  2410. OUTPUT => \*CONFIGDATA,
  2411. HASH => { %template_vars,
  2412. autowarntext => [
  2413. 'WARNING: do not edit!',
  2414. "Generated by Configure from $configdata_tmplname",
  2415. ] }
  2416. ) or die $Text::Template::ERROR;
  2417. close CONFIGDATA;
  2418. rename "$configdata_outname.new", $configdata_outname;
  2419. if ($builder_platform eq 'unix') {
  2420. my $mode = (0755 & ~umask);
  2421. chmod $mode, 'configdata.pm'
  2422. or warn sprintf("WARNING: Couldn't change mode for 'configdata.pm' to 0%03o: %s\n",$mode,$!);
  2423. }
  2424. print "Running $configdata_outname\n";
  2425. my $perlcmd = (quotify("maybeshell", $config{PERL}))[0];
  2426. my $cmd = "$perlcmd $configdata_outname";
  2427. #print STDERR "DEBUG[run_dofile]: \$cmd = $cmd\n";
  2428. system($cmd);
  2429. exit 1 if $? != 0;
  2430. $SIG{__DIE__} = $orig_death_handler;
  2431. print <<"EOF" if ($disabled{threads} eq "unavailable");
  2432. The library could not be configured for supporting multi-threaded
  2433. applications as the compiler options required on this system are not known.
  2434. See file INSTALL.md for details if you need multi-threading.
  2435. EOF
  2436. print <<"EOF" if ($no_shared_warn);
  2437. The options 'shared', 'pic' and 'dynamic-engine' aren't supported on this
  2438. platform, so we will pretend you gave the option 'no-pic', which also disables
  2439. 'shared' and 'dynamic-engine'. If you know how to implement shared libraries
  2440. or position independent code, please let us know (but please first make sure
  2441. you have tried with a current version of OpenSSL).
  2442. EOF
  2443. print <<"EOF";
  2444. **********************************************************************
  2445. *** ***
  2446. *** OpenSSL has been successfully configured ***
  2447. *** ***
  2448. *** If you encounter a problem while building, please open an ***
  2449. *** issue on GitHub <https://github.com/openssl/openssl/issues> ***
  2450. *** and include the output from the following command: ***
  2451. *** ***
  2452. *** perl configdata.pm --dump ***
  2453. *** ***
  2454. *** (If you are new to OpenSSL, you might want to consult the ***
  2455. *** 'Troubleshooting' section in the INSTALL.md file first) ***
  2456. *** ***
  2457. **********************************************************************
  2458. EOF
  2459. exit(0);
  2460. ######################################################################
  2461. #
  2462. # Helpers and utility functions
  2463. #
  2464. # Death handler, to print a helpful message in case of failure #######
  2465. #
  2466. sub death_handler {
  2467. die @_ if $^S; # To prevent the added message in eval blocks
  2468. my $build_file = $target{build_file} // "build file";
  2469. my @message = ( <<"_____", @_ );
  2470. Failure! $build_file wasn't produced.
  2471. Please read INSTALL.md and associated NOTES-* files. You may also have to
  2472. look over your available compiler tool chain or change your configuration.
  2473. _____
  2474. # Dying is terminal, so it's ok to reset the signal handler here.
  2475. $SIG{__DIE__} = $orig_death_handler;
  2476. die @message;
  2477. }
  2478. # Configuration file reading #########################################
  2479. # Note: All of the helper functions are for lazy evaluation. They all
  2480. # return a CODE ref, which will return the intended value when evaluated.
  2481. # Thus, whenever there's mention of a returned value, it's about that
  2482. # intended value.
  2483. # Helper function to implement conditional value variants, with a default
  2484. # plus additional values based on the value of $config{build_type}.
  2485. # Arguments are given in hash table form:
  2486. #
  2487. # picker(default => "Basic string: ",
  2488. # debug => "debug",
  2489. # release => "release")
  2490. #
  2491. # When configuring with --debug, the resulting string will be
  2492. # "Basic string: debug", and when not, it will be "Basic string: release"
  2493. #
  2494. # This can be used to create variants of sets of flags according to the
  2495. # build type:
  2496. #
  2497. # cflags => picker(default => "-Wall",
  2498. # debug => "-g -O0",
  2499. # release => "-O3")
  2500. #
  2501. sub picker {
  2502. my %opts = @_;
  2503. return sub { add($opts{default} || (),
  2504. $opts{$config{build_type}} || ())->(); }
  2505. }
  2506. # Helper function to combine several values of different types into one.
  2507. # This is useful if you want to combine a string with the result of a
  2508. # lazy function, such as:
  2509. #
  2510. # cflags => combine("-Wall", sub { $disabled{zlib} ? () : "-DZLIB" })
  2511. #
  2512. sub combine {
  2513. my @stuff = @_;
  2514. return sub { add(@stuff)->(); }
  2515. }
  2516. # Helper function to implement conditional values depending on the value
  2517. # of $disabled{threads}. Can be used as follows:
  2518. #
  2519. # cflags => combine("-Wall", threads("-pthread"))
  2520. #
  2521. sub threads {
  2522. my @flags = @_;
  2523. return sub { add($disabled{threads} ? () : @flags)->(); }
  2524. }
  2525. sub shared {
  2526. my @flags = @_;
  2527. return sub { add($disabled{shared} ? () : @flags)->(); }
  2528. }
  2529. our $add_called = 0;
  2530. # Helper function to implement adding values to already existing configuration
  2531. # values. It handles elements that are ARRAYs, CODEs and scalars
  2532. sub _add {
  2533. my $separator = shift;
  2534. # If there's any ARRAY in the collection of values OR the separator
  2535. # is undef, we will return an ARRAY of combined values, otherwise a
  2536. # string of joined values with $separator as the separator.
  2537. my $found_array = !defined($separator);
  2538. my @values =
  2539. map {
  2540. my $res = $_;
  2541. while (ref($res) eq "CODE") {
  2542. $res = $res->();
  2543. }
  2544. if (defined($res)) {
  2545. if (ref($res) eq "ARRAY") {
  2546. $found_array = 1;
  2547. @$res;
  2548. } else {
  2549. $res;
  2550. }
  2551. } else {
  2552. ();
  2553. }
  2554. } (@_);
  2555. $add_called = 1;
  2556. if ($found_array) {
  2557. [ @values ];
  2558. } else {
  2559. join($separator, grep { defined($_) && $_ ne "" } @values);
  2560. }
  2561. }
  2562. sub add_before {
  2563. my $separator = " ";
  2564. if (ref($_[$#_]) eq "HASH") {
  2565. my $opts = pop;
  2566. $separator = $opts->{separator};
  2567. }
  2568. my @x = @_;
  2569. sub { _add($separator, @x, @_) };
  2570. }
  2571. sub add {
  2572. my $separator = " ";
  2573. if (ref($_[$#_]) eq "HASH") {
  2574. my $opts = pop;
  2575. $separator = $opts->{separator};
  2576. }
  2577. my @x = @_;
  2578. sub { _add($separator, @_, @x) };
  2579. }
  2580. sub read_eval_file {
  2581. my $fname = shift;
  2582. my $content;
  2583. my @result;
  2584. open F, "< $fname" or die "Can't open '$fname': $!\n";
  2585. {
  2586. undef local $/;
  2587. $content = <F>;
  2588. }
  2589. close F;
  2590. {
  2591. local $@;
  2592. @result = ( eval $content );
  2593. warn $@ if $@;
  2594. }
  2595. return wantarray ? @result : $result[0];
  2596. }
  2597. # configuration reader, evaluates the input file as a perl script and expects
  2598. # it to fill %targets with target configurations. Those are then added to
  2599. # %table.
  2600. sub read_config {
  2601. my $fname = shift;
  2602. my %targets;
  2603. {
  2604. # Protect certain tables from tampering
  2605. local %table = ();
  2606. %targets = read_eval_file($fname);
  2607. }
  2608. my %preexisting = ();
  2609. foreach (sort keys %targets) {
  2610. $preexisting{$_} = 1 if $table{$_};
  2611. }
  2612. die <<"EOF",
  2613. The following config targets from $fname
  2614. shadow pre-existing config targets with the same name:
  2615. EOF
  2616. map { " $_\n" } sort keys %preexisting
  2617. if %preexisting;
  2618. # For each target, check that it's configured with a hash table.
  2619. foreach (keys %targets) {
  2620. if (ref($targets{$_}) ne "HASH") {
  2621. if (ref($targets{$_}) eq "") {
  2622. warn "Deprecated target configuration for $_, ignoring...\n";
  2623. } else {
  2624. warn "Misconfigured target configuration for $_ (should be a hash table), ignoring...\n";
  2625. }
  2626. delete $targets{$_};
  2627. } else {
  2628. $targets{$_}->{_conf_fname_int} = add([ $fname ]);
  2629. }
  2630. }
  2631. %table = (%table, %targets);
  2632. }
  2633. # configuration resolver. Will only resolve all the lazy evaluation
  2634. # codeblocks for the chosen target and all those it inherits from,
  2635. # recursively
  2636. sub resolve_config {
  2637. my $target = shift;
  2638. my @breadcrumbs = @_;
  2639. # my $extra_checks = defined($ENV{CONFIGURE_EXTRA_CHECKS});
  2640. if (grep { $_ eq $target } @breadcrumbs) {
  2641. die "inherit_from loop! target backtrace:\n "
  2642. ,$target,"\n ",join("\n ", @breadcrumbs),"\n";
  2643. }
  2644. if (!defined($table{$target})) {
  2645. warn "Warning! target $target doesn't exist!\n";
  2646. return ();
  2647. }
  2648. # Recurse through all inheritances. They will be resolved on the
  2649. # fly, so when this operation is done, they will all just be a
  2650. # bunch of attributes with string values.
  2651. # What we get here, though, are keys with references to lists of
  2652. # the combined values of them all. We will deal with lists after
  2653. # this stage is done.
  2654. my %combined_inheritance = ();
  2655. if ($table{$target}->{inherit_from}) {
  2656. my @inherit_from =
  2657. map { ref($_) eq "CODE" ? $_->() : $_ } @{$table{$target}->{inherit_from}};
  2658. foreach (@inherit_from) {
  2659. my %inherited_config = resolve_config($_, $target, @breadcrumbs);
  2660. # 'template' is a marker that's considered private to
  2661. # the config that had it.
  2662. delete $inherited_config{template};
  2663. foreach (keys %inherited_config) {
  2664. if (!$combined_inheritance{$_}) {
  2665. $combined_inheritance{$_} = [];
  2666. }
  2667. push @{$combined_inheritance{$_}}, $inherited_config{$_};
  2668. }
  2669. }
  2670. }
  2671. # We won't need inherit_from in this target any more, since we've
  2672. # resolved all the inheritances that lead to this
  2673. delete $table{$target}->{inherit_from};
  2674. # Now is the time to deal with those lists. Here's the place to
  2675. # decide what shall be done with those lists, all based on the
  2676. # values of the target we're currently dealing with.
  2677. # - If a value is a coderef, it will be executed with the list of
  2678. # inherited values as arguments.
  2679. # - If the corresponding key doesn't have a value at all or is the
  2680. # empty string, the inherited value list will be run through the
  2681. # default combiner (below), and the result becomes this target's
  2682. # value.
  2683. # - Otherwise, this target's value is assumed to be a string that
  2684. # will simply override the inherited list of values.
  2685. my $default_combiner = add();
  2686. my %all_keys =
  2687. map { $_ => 1 } (keys %combined_inheritance,
  2688. keys %{$table{$target}});
  2689. sub process_values {
  2690. my $object = shift;
  2691. my $inherited = shift; # Always a [ list ]
  2692. my $target = shift;
  2693. my $entry = shift;
  2694. $add_called = 0;
  2695. while(ref($object) eq "CODE") {
  2696. $object = $object->(@$inherited);
  2697. }
  2698. if (!defined($object)) {
  2699. return ();
  2700. }
  2701. elsif (ref($object) eq "ARRAY") {
  2702. local $add_called; # To make sure recursive calls don't affect it
  2703. return [ map { process_values($_, $inherited, $target, $entry) }
  2704. @$object ];
  2705. } elsif (ref($object) eq "") {
  2706. return $object;
  2707. } else {
  2708. die "cannot handle reference type ",ref($object)
  2709. ," found in target ",$target," -> ",$entry,"\n";
  2710. }
  2711. }
  2712. foreach (sort keys %all_keys) {
  2713. my $previous = $combined_inheritance{$_};
  2714. # Current target doesn't have a value for the current key?
  2715. # Assign it the default combiner, the rest of this loop body
  2716. # will handle it just like any other coderef.
  2717. if (!exists $table{$target}->{$_}) {
  2718. $table{$target}->{$_} = $default_combiner;
  2719. }
  2720. $table{$target}->{$_} = process_values($table{$target}->{$_},
  2721. $combined_inheritance{$_},
  2722. $target, $_);
  2723. unless(defined($table{$target}->{$_})) {
  2724. delete $table{$target}->{$_};
  2725. }
  2726. # if ($extra_checks &&
  2727. # $previous && !($add_called || $previous ~~ $table{$target}->{$_})) {
  2728. # warn "$_ got replaced in $target\n";
  2729. # }
  2730. }
  2731. # Finally done, return the result.
  2732. return %{$table{$target}};
  2733. }
  2734. sub usage
  2735. {
  2736. print STDERR $usage;
  2737. print STDERR "\npick os/compiler from:\n";
  2738. my $j=0;
  2739. my $i;
  2740. my $k=0;
  2741. foreach $i (sort keys %table)
  2742. {
  2743. next if $table{$i}->{template};
  2744. next if $i =~ /^debug/;
  2745. $k += length($i) + 1;
  2746. if ($k > 78)
  2747. {
  2748. print STDERR "\n";
  2749. $k=length($i);
  2750. }
  2751. print STDERR $i . " ";
  2752. }
  2753. foreach $i (sort keys %table)
  2754. {
  2755. next if $table{$i}->{template};
  2756. next if $i !~ /^debug/;
  2757. $k += length($i) + 1;
  2758. if ($k > 78)
  2759. {
  2760. print STDERR "\n";
  2761. $k=length($i);
  2762. }
  2763. print STDERR $i . " ";
  2764. }
  2765. exit(1);
  2766. }
  2767. sub compiler_predefined {
  2768. state %predefined;
  2769. my $cc = shift;
  2770. return () if $^O eq 'VMS';
  2771. die 'compiler_predefined called without a compiler command'
  2772. unless $cc;
  2773. if (! $predefined{$cc}) {
  2774. $predefined{$cc} = {};
  2775. # collect compiler pre-defines from gcc or gcc-alike...
  2776. open(PIPE, "$cc -dM -E -x c /dev/null 2>&1 |");
  2777. while (my $l = <PIPE>) {
  2778. $l =~ m/^#define\s+(\w+(?:\(\w+\))?)(?:\s+(.+))?/ or last;
  2779. $predefined{$cc}->{$1} = $2 // '';
  2780. }
  2781. close(PIPE);
  2782. }
  2783. return %{$predefined{$cc}};
  2784. }
  2785. sub which
  2786. {
  2787. my ($name)=@_;
  2788. if (eval { require IPC::Cmd; 1; }) {
  2789. IPC::Cmd->import();
  2790. return scalar IPC::Cmd::can_run($name);
  2791. } else {
  2792. # if there is $directories component in splitpath,
  2793. # then it's not something to test with $PATH...
  2794. return $name if (File::Spec->splitpath($name))[1];
  2795. foreach (File::Spec->path()) {
  2796. my $fullpath = catfile($_, "$name$target{exe_extension}");
  2797. if (-f $fullpath and -x $fullpath) {
  2798. return $fullpath;
  2799. }
  2800. }
  2801. }
  2802. }
  2803. sub env
  2804. {
  2805. my $name = shift;
  2806. my %opts = @_;
  2807. unless ($opts{cacheonly}) {
  2808. # Note that if $ENV{$name} doesn't exist or is undefined,
  2809. # $config{perlenv}->{$name} will be created with the value
  2810. # undef. This is intentional.
  2811. $config{perlenv}->{$name} = $ENV{$name}
  2812. if ! exists $config{perlenv}->{$name};
  2813. }
  2814. return $config{perlenv}->{$name};
  2815. }
  2816. # Configuration printer ##############################################
  2817. sub print_table_entry
  2818. {
  2819. local $now_printing = shift;
  2820. my %target = resolve_config($now_printing);
  2821. my $type = shift;
  2822. # Don't print the templates
  2823. return if $target{template};
  2824. my @sequence = (
  2825. "sys_id",
  2826. "cpp",
  2827. "cppflags",
  2828. "defines",
  2829. "includes",
  2830. "cc",
  2831. "cflags",
  2832. "ld",
  2833. "lflags",
  2834. "loutflag",
  2835. "ex_libs",
  2836. "bn_ops",
  2837. "poly1035_asm_src",
  2838. "thread_scheme",
  2839. "perlasm_scheme",
  2840. "dso_scheme",
  2841. "shared_target",
  2842. "shared_cflag",
  2843. "shared_defines",
  2844. "shared_ldflag",
  2845. "shared_rcflag",
  2846. "shared_extension",
  2847. "dso_extension",
  2848. "obj_extension",
  2849. "exe_extension",
  2850. "ranlib",
  2851. "ar",
  2852. "arflags",
  2853. "aroutflag",
  2854. "rc",
  2855. "rcflags",
  2856. "rcoutflag",
  2857. "mt",
  2858. "mtflags",
  2859. "mtinflag",
  2860. "mtoutflag",
  2861. "multilib",
  2862. "build_scheme",
  2863. );
  2864. if ($type eq "TABLE") {
  2865. print "\n";
  2866. print "*** $now_printing\n";
  2867. foreach (@sequence) {
  2868. if (ref($target{$_}) eq "ARRAY") {
  2869. printf "\$%-12s = %s\n", $_, join(" ", @{$target{$_}});
  2870. } else {
  2871. printf "\$%-12s = %s\n", $_, $target{$_};
  2872. }
  2873. }
  2874. } elsif ($type eq "HASH") {
  2875. my $largest =
  2876. length((sort { length($a) <=> length($b) } @sequence)[-1]);
  2877. print " '$now_printing' => {\n";
  2878. foreach (@sequence) {
  2879. if ($target{$_}) {
  2880. if (ref($target{$_}) eq "ARRAY") {
  2881. print " '",$_,"'"," " x ($largest - length($_))," => [ ",join(", ", map { "'$_'" } @{$target{$_}})," ],\n";
  2882. } else {
  2883. print " '",$_,"'"," " x ($largest - length($_))," => '",$target{$_},"',\n";
  2884. }
  2885. }
  2886. }
  2887. print " },\n";
  2888. }
  2889. }
  2890. # Utility routines ###################################################
  2891. # On VMS, if the given file is a logical name, File::Spec::Functions
  2892. # will consider it an absolute path. There are cases when we want a
  2893. # purely syntactic check without checking the environment.
  2894. sub isabsolute {
  2895. my $file = shift;
  2896. # On non-platforms, we just use file_name_is_absolute().
  2897. return file_name_is_absolute($file) unless $^O eq "VMS";
  2898. # If the file spec includes a device or a directory spec,
  2899. # file_name_is_absolute() is perfectly safe.
  2900. return file_name_is_absolute($file) if $file =~ m|[:\[]|;
  2901. # Here, we know the given file spec isn't absolute
  2902. return 0;
  2903. }
  2904. # Makes a directory absolute and cleans out /../ in paths like foo/../bar
  2905. # On some platforms, this uses rel2abs(), while on others, realpath() is used.
  2906. # realpath() requires that at least all path components except the last is an
  2907. # existing directory. On VMS, the last component of the directory spec must
  2908. # exist.
  2909. sub absolutedir {
  2910. my $dir = shift;
  2911. # realpath() is quite buggy on VMS. It uses LIB$FID_TO_NAME, which
  2912. # will return the volume name for the device, no matter what. Also,
  2913. # it will return an incorrect directory spec if the argument is a
  2914. # directory that doesn't exist.
  2915. if ($^O eq "VMS") {
  2916. return rel2abs($dir);
  2917. }
  2918. # We use realpath() on Unix, since no other will properly clean out
  2919. # a directory spec.
  2920. use Cwd qw/realpath/;
  2921. return realpath($dir);
  2922. }
  2923. # Check if all paths are one and the same, using stat. They must both exist
  2924. # We need this for the cases when File::Spec doesn't detect case insensitivity
  2925. # (File::Spec::Unix assumes case sensitivity)
  2926. sub samedir {
  2927. die "samedir expects two arguments\n" unless scalar @_ == 2;
  2928. my @stat0 = stat($_[0]); # First argument
  2929. my @stat1 = stat($_[1]); # Second argument
  2930. die "Couldn't stat $_[0]" unless @stat0;
  2931. die "Couldn't stat $_[1]" unless @stat1;
  2932. # Compare device number
  2933. return 0 unless ($stat0[0] == $stat1[0]);
  2934. # Compare "inode". The perl manual recommends comparing as
  2935. # string rather than as number.
  2936. return 0 unless ($stat0[1] eq $stat1[1]);
  2937. return 1; # All the same
  2938. }
  2939. sub quotify {
  2940. my %processors = (
  2941. perl => sub { my $x = shift;
  2942. $x =~ s/([\\\$\@"])/\\$1/g;
  2943. return '"'.$x.'"'; },
  2944. maybeshell => sub { my $x = shift;
  2945. (my $y = $x) =~ s/([\\\"])/\\$1/g;
  2946. if ($x ne $y || $x =~ m|\s|) {
  2947. return '"'.$y.'"';
  2948. } else {
  2949. return $x;
  2950. }
  2951. },
  2952. );
  2953. my $for = shift;
  2954. my $processor =
  2955. defined($processors{$for}) ? $processors{$for} : sub { shift; };
  2956. return map { $processor->($_); } @_;
  2957. }
  2958. # collect_from_file($filename, $line_concat_cond_re, $line_concat)
  2959. # $filename is a file name to read from
  2960. # $line_concat_cond_re is a regexp detecting a line continuation ending
  2961. # $line_concat is a CODEref that takes care of concatenating two lines
  2962. sub collect_from_file {
  2963. my $filename = shift;
  2964. my $line_concat_cond_re = shift;
  2965. my $line_concat = shift;
  2966. open my $fh, $filename || die "unable to read $filename: $!\n";
  2967. return sub {
  2968. my $saved_line = "";
  2969. $_ = "";
  2970. while (<$fh>) {
  2971. s|\R$||;
  2972. if (defined $line_concat) {
  2973. $_ = $line_concat->($saved_line, $_);
  2974. $saved_line = "";
  2975. }
  2976. if (defined $line_concat_cond_re && /$line_concat_cond_re/) {
  2977. $saved_line = $_;
  2978. next;
  2979. }
  2980. return $_;
  2981. }
  2982. die "$filename ending with continuation line\n" if $_;
  2983. close $fh;
  2984. return undef;
  2985. }
  2986. }
  2987. # collect_from_array($array, $line_concat_cond_re, $line_concat)
  2988. # $array is an ARRAYref of lines
  2989. # $line_concat_cond_re is a regexp detecting a line continuation ending
  2990. # $line_concat is a CODEref that takes care of concatenating two lines
  2991. sub collect_from_array {
  2992. my $array = shift;
  2993. my $line_concat_cond_re = shift;
  2994. my $line_concat = shift;
  2995. my @array = (@$array);
  2996. return sub {
  2997. my $saved_line = "";
  2998. $_ = "";
  2999. while (defined($_ = shift @array)) {
  3000. s|\R$||;
  3001. if (defined $line_concat) {
  3002. $_ = $line_concat->($saved_line, $_);
  3003. $saved_line = "";
  3004. }
  3005. if (defined $line_concat_cond_re && /$line_concat_cond_re/) {
  3006. $saved_line = $_;
  3007. next;
  3008. }
  3009. return $_;
  3010. }
  3011. die "input text ending with continuation line\n" if $_;
  3012. return undef;
  3013. }
  3014. }
  3015. # collect_information($lineiterator, $line_continue, $regexp => $CODEref, ...)
  3016. # $lineiterator is a CODEref that delivers one line at a time.
  3017. # All following arguments are regex/CODEref pairs, where the regexp detects a
  3018. # line and the CODEref does something with the result of the regexp.
  3019. sub collect_information {
  3020. my $lineiterator = shift;
  3021. my %collectors = @_;
  3022. while(defined($_ = $lineiterator->())) {
  3023. s|\R$||;
  3024. my $found = 0;
  3025. if ($collectors{"BEFORE"}) {
  3026. $collectors{"BEFORE"}->($_);
  3027. }
  3028. foreach my $re (keys %collectors) {
  3029. if ($re !~ /^OTHERWISE|BEFORE|AFTER$/ && /$re/) {
  3030. $collectors{$re}->($lineiterator);
  3031. $found = 1;
  3032. };
  3033. }
  3034. if ($collectors{"OTHERWISE"}) {
  3035. $collectors{"OTHERWISE"}->($lineiterator, $_)
  3036. unless $found || !defined $collectors{"OTHERWISE"};
  3037. }
  3038. if ($collectors{"AFTER"}) {
  3039. $collectors{"AFTER"}->($_);
  3040. }
  3041. }
  3042. }
  3043. # tokenize($line)
  3044. # tokenize($line,$separator)
  3045. # $line is a line of text to split up into tokens
  3046. # $separator [optional] is a regular expression that separates the tokens,
  3047. # the default being spaces. Do not use quotes of any kind as separators,
  3048. # that will give undefined results.
  3049. # Returns a list of tokens.
  3050. #
  3051. # Tokens are divided by separator (spaces by default). If the tokens include
  3052. # the separators, they have to be quoted with single or double quotes.
  3053. # Double quotes inside a double quoted token must be escaped. Escaping is done
  3054. # with backslash.
  3055. # Basically, the same quoting rules apply for " and ' as in any
  3056. # Unix shell.
  3057. sub tokenize {
  3058. my $line = my $debug_line = shift;
  3059. my $separator = shift // qr|\s+|;
  3060. my @result = ();
  3061. if ($ENV{CONFIGURE_DEBUG_TOKENIZE}) {
  3062. print STDERR "DEBUG[tokenize]: \$separator = $separator\n";
  3063. }
  3064. while ($line =~ s|^${separator}||, $line ne "") {
  3065. my $token = "";
  3066. again:
  3067. $line =~ m/^(.*?)(${separator}|"|'|$)/;
  3068. $token .= $1;
  3069. $line = $2.$';
  3070. if ($line =~ m/^"((?:[^"\\]+|\\.)*)"/) {
  3071. $token .= $1;
  3072. $line = $';
  3073. goto again;
  3074. } elsif ($line =~ m/^'([^']*)'/) {
  3075. $token .= $1;
  3076. $line = $';
  3077. goto again;
  3078. }
  3079. push @result, $token;
  3080. }
  3081. if ($ENV{CONFIGURE_DEBUG_TOKENIZE}) {
  3082. print STDERR "DEBUG[tokenize]: Parsed '$debug_line' into:\n";
  3083. print STDERR "DEBUG[tokenize]: ('", join("', '", @result), "')\n";
  3084. }
  3085. return @result;
  3086. }