Configure 125 KB

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