options.pas 108 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286
  1. {
  2. Copyright (c) 1998-2008 by Florian Klaempfl and Peter Vreman
  3. Reads command line options and config files
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. ****************************************************************************
  16. }
  17. unit options;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. CClasses,cfileutl,
  22. globtype,globals,verbose,systems,cpuinfo, comprsrc;
  23. Type
  24. TOption=class
  25. FirstPass,
  26. ParaLogo,
  27. NoPressEnter,
  28. FPCHelpLines,
  29. LogoWritten,
  30. FPUSetExplicitly,
  31. CPUSetExplicitly,
  32. OptCPUSetExplicitly: boolean;
  33. FileLevel : longint;
  34. QuickInfo : string;
  35. FPCBinaryPath: string;
  36. ParaIncludePath,
  37. ParaUnitPath,
  38. ParaObjectPath,
  39. ParaLibraryPath,
  40. ParaFrameworkPath : TSearchPathList;
  41. ParaAlignment : TAlignmentInfo;
  42. Constructor Create;
  43. Destructor Destroy;override;
  44. procedure WriteLogo;
  45. procedure WriteInfo;
  46. procedure WriteHelpPages;
  47. procedure WriteQuickInfo;
  48. procedure IllegalPara(const opt:TCmdStr);
  49. procedure UnsupportedPara(const opt:TCmdStr);
  50. procedure IgnoredPara(const opt:TCmdStr);
  51. function Unsetbool(var Opts:TCmdStr; Pos: Longint):boolean;
  52. procedure interpret_option(const opt :TCmdStr;ispara:boolean);
  53. procedure Interpret_envvar(const envname : TCmdStr);
  54. procedure Interpret_file(const filename : TPathStr);
  55. procedure Read_Parameters;
  56. procedure parsecmd(cmd:TCmdStr);
  57. procedure TargetOptions(def:boolean);
  58. procedure CheckOptionsCompatibility;
  59. procedure ForceStaticLinking;
  60. protected
  61. MacVersionSet: boolean;
  62. function ParseMacVersionMin(out minstr, emptystr: string; const compvarname, value: string; ios: boolean): boolean;
  63. procedure MaybeSetDefaultMacVersionMacro;
  64. end;
  65. TOptionClass=class of toption;
  66. var
  67. coption : TOptionClass;
  68. procedure read_arguments(cmd:TCmdStr);
  69. implementation
  70. uses
  71. widestr,
  72. {$if FPC_FULLVERSION<20700}ccharset{$else}charset{$endif},
  73. SysUtils,
  74. version,
  75. cutils,cmsgs,
  76. comphook,
  77. symtable,scanner,rabase,
  78. wpobase,
  79. symconst,
  80. i_bsd;
  81. const
  82. page_size = 24;
  83. var
  84. option : toption;
  85. read_configfile, { read config file, set when a cfgfile is found }
  86. disable_configfile : boolean;
  87. fpcdir,
  88. ppccfg,
  89. param_file : string; { file to compile specified on the commandline }
  90. {****************************************************************************
  91. Options not supported on all platforms
  92. ****************************************************************************}
  93. const
  94. { pointer checking (requires special code in FPC_CHECKPOINTER,
  95. and can never work for libc-based targets or any other program
  96. linking to an external library)
  97. }
  98. supported_targets_gc = [system_i386_linux,system_powerpc_linux]
  99. + [system_i386_win32]
  100. + [system_i386_GO32V2]
  101. + [system_i386_os2]
  102. + [system_i386_beos,system_i386_haiku]
  103. + [system_powerpc_morphos];
  104. { gprof (requires implementation of g_profilecode in the code generator) }
  105. supported_targets_pg = [system_i386_linux,system_x86_64_linux]
  106. + [system_i386_win32]
  107. + [system_powerpc_darwin,system_x86_64_darwin]
  108. + [system_i386_GO32V2]
  109. + [system_i386_freebsd]
  110. + [system_i386_netbsd]
  111. + [system_i386_wdosx];
  112. suppported_targets_x_smallr = systems_linux + systems_solaris
  113. + [system_i386_haiku]
  114. + [system_i386_beos];
  115. {****************************************************************************
  116. Defines
  117. ****************************************************************************}
  118. procedure set_default_link_type;
  119. begin
  120. undef_system_macro('FPC_LINK_SMART');
  121. def_system_macro('FPC_LINK_STATIC');
  122. undef_system_macro('FPC_LINK_DYNAMIC');
  123. init_settings.globalswitches:=init_settings.globalswitches+[cs_link_static];
  124. init_settings.globalswitches:=init_settings.globalswitches-[cs_link_shared,cs_link_smart];
  125. end;
  126. {****************************************************************************
  127. Toption
  128. ****************************************************************************}
  129. procedure StopOptions(err:longint);
  130. begin
  131. if assigned(Option) then
  132. begin
  133. Option.free;
  134. Option:=nil;
  135. end;
  136. raise ECompilerAbortSilent.Create;
  137. end;
  138. procedure Toption.WriteLogo;
  139. var
  140. p : pchar;
  141. begin
  142. if not LogoWritten then
  143. begin
  144. p:=MessagePchar(option_logo);
  145. while assigned(p) do
  146. Comment(V_Normal,GetMsgLine(p));
  147. LogoWritten:= true;
  148. end;
  149. end;
  150. procedure Toption.WriteInfo;
  151. var
  152. p : pchar;
  153. hs,hs1,s : TCmdStr;
  154. target : tsystem;
  155. cpu : tcputype;
  156. fpu : tfputype;
  157. opt : toptimizerswitch;
  158. wpopt: twpoptimizerswitch;
  159. abi : tabi;
  160. {$if defined(arm) or defined(avr)}
  161. controllertype : tcontrollertype;
  162. {$endif defined(arm) or defined(avr)}
  163. begin
  164. p:=MessagePchar(option_info);
  165. while assigned(p) do
  166. begin
  167. s:=GetMsgLine(p);
  168. { list OS Targets }
  169. if pos('$OSTARGETS',s)>0 then
  170. begin
  171. for target:=low(tsystem) to high(tsystem) do
  172. if assigned(targetinfos[target]) then
  173. begin
  174. hs:=s;
  175. hs1:=targetinfos[target]^.name;
  176. if tf_under_development in targetinfos[target]^.flags then
  177. hs1:=hs1+' (under development)';
  178. Replace(hs,'$OSTARGETS',hs1);
  179. Comment(V_Normal,hs);
  180. end;
  181. end
  182. else if pos('$INSTRUCTIONSETS',s)>0 then
  183. begin
  184. for cpu:=low(tcputype) to high(tcputype) do
  185. begin
  186. hs:=s;
  187. hs1:=cputypestr[cpu];
  188. if hs1<>'' then
  189. begin
  190. Replace(hs,'$INSTRUCTIONSETS',hs1);
  191. Comment(V_Normal,hs);
  192. end;
  193. end;
  194. end
  195. else if pos('$FPUINSTRUCTIONSETS',s)>0 then
  196. begin
  197. for fpu:=low(tfputype) to high(tfputype) do
  198. begin
  199. hs:=s;
  200. hs1:=fputypestr[fpu];
  201. if hs1<>'' then
  202. begin
  203. Replace(hs,'$FPUINSTRUCTIONSETS',hs1);
  204. Comment(V_Normal,hs);
  205. end;
  206. end;
  207. end
  208. else if pos('$ABITARGETS',s)>0 then
  209. begin
  210. for abi:=low(abi) to high(abi) do
  211. begin
  212. hs:=s;
  213. hs1:=abi2str[abi];
  214. if hs1<>'' then
  215. begin
  216. Replace(hs,'$ABITARGETS',hs1);
  217. Comment(V_Normal,hs);
  218. end;
  219. end;
  220. end
  221. else if pos('$OPTIMIZATIONS',s)>0 then
  222. begin
  223. for opt:=low(toptimizerswitch) to high(toptimizerswitch) do
  224. begin
  225. if opt in supported_optimizerswitches then
  226. begin
  227. hs:=s;
  228. hs1:=OptimizerSwitchStr[opt];
  229. if hs1<>'' then
  230. begin
  231. Replace(hs,'$OPTIMIZATIONS',hs1);
  232. Comment(V_Normal,hs);
  233. end;
  234. end;
  235. end;
  236. end
  237. else if pos('$WPOPTIMIZATIONS',s)>0 then
  238. begin
  239. for wpopt:=low(twpoptimizerswitch) to high(twpoptimizerswitch) do
  240. begin
  241. { currently all whole program optimizations are platform-independent
  242. if opt in supported_wpoptimizerswitches then
  243. }
  244. begin
  245. hs:=s;
  246. hs1:=WPOptimizerSwitchStr[wpopt];
  247. if hs1<>'' then
  248. begin
  249. Replace(hs,'$WPOPTIMIZATIONS',hs1);
  250. Comment(V_Normal,hs);
  251. end;
  252. end;
  253. end
  254. end
  255. else if pos('$CONTROLLERTYPES',s)>0 then
  256. begin
  257. {$if defined(arm) or defined(avr)}
  258. for controllertype:=low(tcontrollertype) to high(tcontrollertype) do
  259. begin
  260. { currently all whole program optimizations are platform-independent
  261. if opt in supported_wpoptimizerswitches then
  262. }
  263. begin
  264. hs:=s;
  265. hs1:=embedded_controllers[controllertype].ControllerTypeStr;
  266. if hs1<>'' then
  267. begin
  268. Replace(hs,'$CONTROLLERTYPES',hs1);
  269. Comment(V_Normal,hs);
  270. end;
  271. end;
  272. end
  273. {$else defined(arm) or defined(avr)}
  274. {$endif defined(arm) or defined(avr)}
  275. end
  276. else
  277. Comment(V_Normal,s);
  278. end;
  279. StopOptions(0);
  280. end;
  281. procedure Toption.WriteHelpPages;
  282. function PadEnd(s:string;i:longint):string;
  283. begin
  284. while (length(s)<i) do
  285. s:=s+' ';
  286. PadEnd:=s;
  287. end;
  288. var
  289. lastident,
  290. j,outline,
  291. ident,
  292. lines : longint;
  293. show : boolean;
  294. opt : string[32];
  295. input,
  296. s : string;
  297. p : pchar;
  298. begin
  299. WriteLogo;
  300. Lines:=4;
  301. if FPCHelpLines then
  302. Message1(option_usage,FixFileName(FPCBinaryPath))
  303. else
  304. Message1(option_usage,FixFileName(system.paramstr(0)));
  305. lastident:=0;
  306. p:=MessagePChar(option_help_pages);
  307. while assigned(p) do
  308. begin
  309. { get a line and reset }
  310. s:=GetMsgLine(p);
  311. ident:=0;
  312. show:=false;
  313. { parse options }
  314. case s[1] of
  315. 'F': if FPCHelpLines then
  316. Show := true;
  317. {$ifdef UNITALIASES}
  318. 'a',
  319. {$endif}
  320. {$ifdef EXTDEBUG}
  321. 'e',
  322. {$endif EXTDEBUG}
  323. {$ifdef i386}
  324. '3',
  325. {$endif}
  326. {$ifdef x86_64}
  327. '4',
  328. {$endif}
  329. {$ifdef m68k}
  330. '6',
  331. {$endif}
  332. {$ifdef arm}
  333. 'A',
  334. {$endif}
  335. {$ifdef powerpc}
  336. 'P',
  337. {$endif}
  338. {$ifdef powerpc64}
  339. 'p',
  340. {$endif}
  341. {$ifdef sparc}
  342. 'S',
  343. {$endif}
  344. {$ifdef vis}
  345. 'I',
  346. {$endif}
  347. {$ifdef avr}
  348. 'V',
  349. {$endif}
  350. {$ifdef jvm}
  351. 'J',
  352. {$endif}
  353. '*' : show:=true;
  354. end;
  355. if show then
  356. begin
  357. case s[2] of
  358. 'g',
  359. {$ifdef Unix}
  360. 'L',
  361. {$endif}
  362. {$ifdef os2}
  363. 'O',
  364. {$endif}
  365. '*' : show:=true;
  366. else
  367. show:=false;
  368. end;
  369. end;
  370. { now we may show the message or not }
  371. if show then
  372. begin
  373. case s[3] of
  374. '0' : begin
  375. ident:=0;
  376. outline:=0;
  377. end;
  378. '1' : begin
  379. ident:=2;
  380. outline:=7;
  381. end;
  382. '2' : begin
  383. ident:=6;
  384. outline:=11;
  385. end;
  386. '3' : begin
  387. ident:=9;
  388. outline:=11;
  389. end;
  390. end;
  391. j:=pos('_',s);
  392. opt:=Copy(s,4,j-4);
  393. if opt='*' then
  394. opt:=''
  395. else
  396. if opt=' ' then
  397. opt:=PadEnd(opt,outline)
  398. else
  399. opt:=PadEnd('-'+opt,outline);
  400. if (ident=0) and (lastident<>0) then
  401. begin
  402. Comment(V_Normal,'');
  403. inc(Lines);
  404. end;
  405. { page full ? }
  406. if (lines >= page_size - 1) then
  407. begin
  408. if not NoPressEnter then
  409. begin
  410. Message(option_help_press_enter);
  411. readln(input);
  412. if upper(input)='Q' then
  413. StopOptions(0);
  414. end;
  415. lines:=0;
  416. end;
  417. Comment(V_Normal,PadEnd('',ident)+opt+Copy(s,j+1,255));
  418. LastIdent:=Ident;
  419. inc(Lines);
  420. end;
  421. end;
  422. StopOptions(0);
  423. end;
  424. procedure Toption.IllegalPara(const opt:TCmdStr);
  425. begin
  426. Message1(option_illegal_para,opt);
  427. Message(option_help_pages_para);
  428. StopOptions(1);
  429. end;
  430. procedure toption.UnsupportedPara(const opt: TCmdStr);
  431. begin
  432. Message1(option_unsupported_target,opt);
  433. StopOptions(1);
  434. end;
  435. procedure toption.IgnoredPara(const opt: TCmdStr);
  436. begin
  437. Message1(option_ignored_target,opt);
  438. end;
  439. procedure toption.ForceStaticLinking;
  440. begin
  441. def_system_macro('FPC_LINK_STATIC');
  442. undef_system_macro('FPC_LINK_SMART');
  443. undef_system_macro('FPC_LINK_DYNAMIC');
  444. include(init_settings.globalswitches,cs_link_static);
  445. exclude(init_settings.globalswitches,cs_link_smart);
  446. exclude(init_settings.globalswitches,cs_link_shared);
  447. LinkTypeSetExplicitly:=true;
  448. end;
  449. function toption.ParseMacVersionMin(out minstr, emptystr: string; const compvarname, value: string; ios: boolean): boolean;
  450. function subval(start,maxlen: longint; out stop: longint): string;
  451. var
  452. i: longint;
  453. begin
  454. result:='';
  455. i:=start;
  456. while (i<=length(value)) and
  457. (value[i] in ['0'..'9']) do
  458. inc(i);
  459. { sufficient amount of digits? }
  460. if (i=start) or
  461. (i-start>maxlen) then
  462. exit;
  463. result:=copy(value,start,i-start);
  464. stop:=i;
  465. end;
  466. var
  467. temp,
  468. compvarvalue: string[15];
  469. i: longint;
  470. begin
  471. minstr:=value;
  472. emptystr:='';
  473. MacVersionSet:=false;
  474. { check whether the value is a valid version number }
  475. if value='' then
  476. begin
  477. undef_system_macro(compvarname);
  478. exit(true);
  479. end;
  480. { major version number }
  481. compvarvalue:=subval(1,2,i);
  482. { not enough digits -> invalid }
  483. if compvarvalue='' then
  484. exit(false);
  485. { already end of string -> invalid }
  486. if (i>=length(value)) or
  487. (value[i]<>'.') then
  488. exit(false);
  489. { minor version number }
  490. temp:=subval(i+1,2,i);
  491. if temp='' then
  492. exit(false);
  493. { on Mac OS X, the minor version number is limited to 1 digit }
  494. if not ios then
  495. begin
  496. if length(temp)<>1 then
  497. exit(false);
  498. end
  499. { the minor version number always takes up two digits on iOS }
  500. else if length(temp)=1 then
  501. temp:='0'+temp;
  502. compvarvalue:=compvarvalue+temp;
  503. { optional patch level }
  504. if i<=length(value) then
  505. begin
  506. if value[i]<>'.' then
  507. exit(false);
  508. temp:=subval(i+1,2,i);
  509. if temp='' then
  510. exit(false);
  511. { there's only room for a single digit patch level in the version macro
  512. for Mac OS X. gcc sets it to zero if there are more digits, but that
  513. seems worse than clamping to 9 (don't declare as invalid like with
  514. minor version number, because there is a precedent like 10.4.11)
  515. }
  516. if not ios then
  517. begin
  518. if length(temp)<>1 then
  519. temp:='9';
  520. end
  521. else
  522. begin
  523. { on iOS, the patch level is always two digits }
  524. if length(temp)=1 then
  525. temp:='0'+temp;
  526. end;
  527. compvarvalue:=compvarvalue+temp;
  528. { must be the end }
  529. if i<=length(value) then
  530. exit(false);
  531. end
  532. else if not ios then
  533. compvarvalue:=compvarvalue+'0'
  534. else
  535. compvarvalue:=compvarvalue+'00';
  536. set_system_compvar(compvarname,compvarvalue);
  537. MacVersionSet:=true;
  538. result:=true;
  539. end;
  540. procedure TOption.MaybeSetDefaultMacVersionMacro;
  541. var
  542. envstr: ansistring;
  543. begin
  544. if not(target_info.system in systems_darwin) then
  545. exit;
  546. if MacVersionSet then
  547. exit;
  548. { check for deployment target set via environment variable }
  549. if not(target_info.system in [system_i386_iphonesim,system_arm_darwin]) then
  550. begin
  551. envstr:=GetEnvironmentVariable('MACOSX_DEPLOYMENT_TARGET');
  552. if envstr<>'' then
  553. if not ParseMacVersionMin(MacOSXVersionMin,iPhoneOSVersionMin,'MAC_OS_X_VERSION_MIN_REQUIRED',envstr,false) then
  554. Message1(option_invalid_macosx_deployment_target,envstr)
  555. else
  556. exit;
  557. end
  558. else
  559. begin
  560. envstr:=GetEnvironmentVariable('IPHONEOS_DEPLOYMENT_TARGET');
  561. if envstr<>'' then
  562. if not ParseMacVersionMin(iPhoneOSVersionMin,MacOSXVersionMin,'IPHONE_OS_VERSION_MIN_REQUIRED',envstr,true) then
  563. Message1(option_invalid_iphoneos_deployment_target,envstr)
  564. else
  565. exit;
  566. end;
  567. { nothing specified -> defaults }
  568. case target_info.system of
  569. system_powerpc_darwin:
  570. begin
  571. set_system_compvar('MAC_OS_X_VERSION_MIN_REQUIRED','1030');
  572. MacOSXVersionMin:='10.3';
  573. end;
  574. system_powerpc64_darwin,
  575. system_i386_darwin:
  576. begin
  577. set_system_compvar('MAC_OS_X_VERSION_MIN_REQUIRED','1040');
  578. MacOSXVersionMin:='10.4';
  579. end;
  580. system_x86_64_darwin:
  581. begin
  582. { actually already works on 10.4, but it's unlikely any 10.4 system
  583. with an x86-64 is still in use, so don't default to it }
  584. set_system_compvar('MAC_OS_X_VERSION_MIN_REQUIRED','1050');
  585. MacOSXVersionMin:='10.5';
  586. end;
  587. system_arm_darwin,
  588. system_i386_iphonesim:
  589. begin
  590. set_system_compvar('IPHONE_OS_VERSION_MIN_REQUIRED','30000');
  591. iPhoneOSVersionMin:='3.0';
  592. end;
  593. else
  594. internalerror(2012031001);
  595. end;
  596. end;
  597. function Toption.Unsetbool(var Opts:TCmdStr; Pos: Longint):boolean;
  598. { checks if the character after pos in Opts is a + or a - and returns resp.
  599. false or true. If it is another character (or none), it also returns false }
  600. begin
  601. UnsetBool := false;
  602. if Length(Opts)>Pos then
  603. begin
  604. inc(Pos);
  605. UnsetBool := Opts[Pos] = '-';
  606. if Opts[Pos] in ['-','+']then
  607. delete(Opts,Pos,1);
  608. end;
  609. end;
  610. procedure TOption.interpret_option(const opt:TCmdStr;ispara:boolean);
  611. var
  612. code : integer;
  613. c : char;
  614. more : TCmdStr;
  615. major,minor : longint;
  616. error : integer;
  617. j,l : longint;
  618. d,s : TCmdStr;
  619. unicodemapping : punicodemap;
  620. begin
  621. if opt='' then
  622. exit;
  623. { only parse define,undef,target,verbosity,link etc options the firsttime }
  624. if firstpass and
  625. not(
  626. (opt[1]='-') and
  627. (
  628. ((length(opt)>1) and (opt[2] in ['i','d','v','T','u','n','X','l'])) or
  629. ((length(opt)>3) and (opt[2]='F') and (opt[3]='e'))
  630. )
  631. ) then
  632. exit;
  633. Message1(option_handling_option,opt);
  634. case opt[1] of
  635. '-' :
  636. begin
  637. more:=Copy(opt,3,2147483647);
  638. if firstpass then
  639. Message1(option_interpreting_firstpass_option,opt)
  640. else
  641. Message1(option_interpreting_option,opt);
  642. case opt[2] of
  643. '?' :
  644. begin
  645. if (More <> '') and (More [1] = 'F') then
  646. begin
  647. FPCHelpLines := true;
  648. Delete (More, 1, 1);
  649. FPCBinaryPath := More;
  650. end;
  651. WriteHelpPages;
  652. end;
  653. 'a' :
  654. begin
  655. include(init_settings.globalswitches,cs_asm_leave);
  656. j:=1;
  657. while j<=length(more) do
  658. begin
  659. case more[j] of
  660. 'l' :
  661. include(init_settings.globalswitches,cs_asm_source);
  662. 'r' :
  663. include(init_settings.globalswitches,cs_asm_regalloc);
  664. 't' :
  665. include(init_settings.globalswitches,cs_asm_tempalloc);
  666. 'n' :
  667. include(init_settings.globalswitches,cs_asm_nodes);
  668. 'p' :
  669. begin
  670. exclude(init_settings.globalswitches,cs_asm_leave);
  671. if UnsetBool(More, 0) then
  672. exclude(init_settings.globalswitches,cs_asm_pipe)
  673. else
  674. include(init_settings.globalswitches,cs_asm_pipe);
  675. end;
  676. '-' :
  677. init_settings.globalswitches:=init_settings.globalswitches -
  678. [cs_asm_leave, cs_asm_source,cs_asm_regalloc, cs_asm_tempalloc,
  679. cs_asm_nodes, cs_asm_pipe];
  680. else
  681. IllegalPara(opt);
  682. end;
  683. inc(j);
  684. end;
  685. end;
  686. 'A' :
  687. begin
  688. paratargetasm:=find_asm_by_string(More);
  689. if paratargetasm=as_none then
  690. IllegalPara(opt);
  691. end;
  692. 'b' :
  693. begin
  694. // Message1(option_obsolete_switch,'-b');
  695. if UnsetBool(More,0) then
  696. begin
  697. init_settings.moduleswitches:=init_settings.moduleswitches-[cs_browser];
  698. init_settings.moduleswitches:=init_settings.moduleswitches-[cs_local_browser];
  699. end
  700. else
  701. begin
  702. init_settings.moduleswitches:=init_settings.moduleswitches+[cs_browser];
  703. end;
  704. if More<>'' then
  705. if (More='l') or (More='l+') then
  706. init_settings.moduleswitches:=init_settings.moduleswitches+[cs_local_browser]
  707. else if More='l-' then
  708. init_settings.moduleswitches:=init_settings.moduleswitches-[cs_local_browser]
  709. else
  710. IllegalPara(opt);
  711. end;
  712. 'B' :
  713. do_build:=not UnSetBool(more,0);
  714. 'C' :
  715. begin
  716. j:=1;
  717. while j<=length(more) do
  718. begin
  719. case more[j] of
  720. '3' :
  721. If UnsetBool(More, j) then
  722. exclude(init_settings.localswitches,cs_ieee_errors)
  723. Else
  724. include(init_settings.localswitches,cs_ieee_errors);
  725. 'a' :
  726. begin
  727. s:=upper(copy(more,j+1,length(more)-j));
  728. if not(SetAbiType(s,target_info.abi)) then
  729. IllegalPara(opt);
  730. break;
  731. end;
  732. 'b' :
  733. begin
  734. if UnsetBool(More, j) then
  735. target_info.endian:=endian_little
  736. else
  737. target_info.endian:=endian_big;
  738. end;
  739. 'c' :
  740. begin
  741. if not SetAktProcCall(upper(copy(more,j+1,length(more)-j)),init_settings.defproccall) then
  742. IllegalPara(opt);
  743. break;
  744. end;
  745. {$ifdef cpufpemu}
  746. 'e' :
  747. begin
  748. If UnsetBool(More, j) then
  749. exclude(init_settings.moduleswitches,cs_fp_emulation)
  750. Else
  751. include(init_settings.moduleswitches,cs_fp_emulation);
  752. end;
  753. {$endif cpufpemu}
  754. 'f' :
  755. begin
  756. s:=upper(copy(more,j+1,length(more)-j));
  757. if not(SetFpuType(s,init_settings.fputype)) then
  758. IllegalPara(opt);
  759. FPUSetExplicitly:=True;
  760. break;
  761. end;
  762. 'F' :
  763. begin
  764. if not SetMinFPConstPrec(copy(more,j+1,length(more)-j),init_settings.minfpconstprec) then
  765. IllegalPara(opt);
  766. break;
  767. end;
  768. 'g' :
  769. begin
  770. if tf_no_pic_supported in target_info.flags then
  771. begin
  772. { consume a possible '-' coming after it }
  773. UnsetBool(More, j);
  774. message(scan_w_pic_ignored);
  775. end
  776. else if UnsetBool(More, j) then
  777. exclude(init_settings.moduleswitches,cs_create_pic)
  778. else
  779. include(init_settings.moduleswitches,cs_create_pic);
  780. end;
  781. 'h' :
  782. begin
  783. val(copy(more,j+1,length(more)-j),heapsize,code);
  784. if (code<>0) or (heapsize<1024) then
  785. IllegalPara(opt);
  786. break;
  787. end;
  788. 'i' :
  789. If UnsetBool(More, j) then
  790. exclude(init_settings.localswitches,cs_check_io)
  791. else
  792. include(init_settings.localswitches,cs_check_io);
  793. 'n' :
  794. If UnsetBool(More, j) then
  795. exclude(init_settings.globalswitches,cs_link_nolink)
  796. Else
  797. include(init_settings.globalswitches,cs_link_nolink);
  798. 'N' :
  799. If UnsetBool(More, j) then
  800. exclude(init_settings.localswitches,cs_check_low_addr_load)
  801. Else
  802. include(init_settings.localswitches,cs_check_low_addr_load);
  803. 'o' :
  804. If UnsetBool(More, j) then
  805. exclude(init_settings.localswitches,cs_check_overflow)
  806. Else
  807. include(init_settings.localswitches,cs_check_overflow);
  808. 'O' :
  809. If UnsetBool(More, j) then
  810. exclude(init_settings.localswitches,cs_check_ordinal_size)
  811. Else
  812. include(init_settings.localswitches,cs_check_ordinal_size);
  813. 'p' :
  814. begin
  815. s:=upper(copy(more,j+1,length(more)-j));
  816. if not(Setcputype(s,init_settings.cputype)) then
  817. IllegalPara(opt);
  818. CPUSetExplicitly:=true;
  819. break;
  820. end;
  821. 'P':
  822. begin
  823. delete(more,1,1);
  824. if upper(copy(more,1,pos('=',more)-1))='PACKSET' then
  825. begin
  826. delete(more,1,pos('=',more));
  827. if more='0' then
  828. init_settings.setalloc:=0
  829. else if (more='1') or (more='DEFAULT') or (more='NORMAL') then
  830. init_settings.setalloc:=1
  831. else if more='2' then
  832. init_settings.setalloc:=2
  833. else if more='4' then
  834. init_settings.setalloc:=4
  835. else if more='8' then
  836. init_settings.setalloc:=8
  837. else
  838. IllegalPara(opt);
  839. end
  840. else
  841. IllegalPara(opt);
  842. end;
  843. 'r' :
  844. If UnsetBool(More, j) then
  845. exclude(init_settings.localswitches,cs_check_range)
  846. Else
  847. include(init_settings.localswitches,cs_check_range);
  848. 'R' :
  849. If UnsetBool(More, j) then
  850. begin
  851. exclude(init_settings.localswitches,cs_check_range);
  852. exclude(init_settings.localswitches,cs_check_object);
  853. end
  854. Else
  855. begin
  856. include(init_settings.localswitches,cs_check_range);
  857. include(init_settings.localswitches,cs_check_object);
  858. end;
  859. 's' :
  860. begin
  861. val(copy(more,j+1,length(more)-j),stacksize,code);
  862. if (code<>0) or (stacksize>=67107840) or (stacksize<1024) then
  863. IllegalPara(opt);
  864. break;
  865. end;
  866. 't' :
  867. If UnsetBool(More, j) then
  868. exclude(init_settings.localswitches,cs_check_stack)
  869. Else
  870. include(init_settings.localswitches,cs_check_stack);
  871. 'D' :
  872. If UnsetBool(More, j) then
  873. exclude(init_settings.moduleswitches,cs_create_dynamic)
  874. Else
  875. include(init_settings.moduleswitches,cs_create_dynamic);
  876. 'X' :
  877. If UnsetBool(More, j) then
  878. exclude(init_settings.moduleswitches,cs_create_smart)
  879. Else
  880. include(init_settings.moduleswitches,cs_create_smart);
  881. 'T' :
  882. begin
  883. if not UpdateTargetSwitchStr(copy(more,j+1,length(more)),init_settings.targetswitches) then
  884. IllegalPara(opt);
  885. break;
  886. end;
  887. 'v' :
  888. If target_info.system in systems_jvm then
  889. If UnsetBool(More, j) then
  890. exclude(init_settings.localswitches,cs_check_var_copyout)
  891. Else
  892. include(init_settings.localswitches,cs_check_var_copyout)
  893. else
  894. IllegalPara(opt)
  895. else
  896. IllegalPara(opt);
  897. end;
  898. inc(j);
  899. end;
  900. end;
  901. 'd' :
  902. if more <> '' then
  903. begin
  904. l:=Pos(':=',more);
  905. if l>0 then
  906. set_system_compvar(Copy(more,1,l-1),Copy(more,l+2,255))
  907. else
  908. def_system_macro(more);
  909. end;
  910. 'D' :
  911. begin
  912. include(init_settings.globalswitches,cs_link_deffile);
  913. j:=1;
  914. while j<=length(more) do
  915. begin
  916. case more[j] of
  917. 'd' :
  918. begin
  919. description:=Copy(more,j+1,255);
  920. break;
  921. end;
  922. 'v' :
  923. begin
  924. dllversion:=Copy(more,j+1,255);
  925. l:=pos('.',dllversion);
  926. dllminor:=0;
  927. error:=0;
  928. if l>0 then
  929. begin
  930. val(copy(dllversion,l+1,255),minor,error);
  931. if (error=0) and
  932. (minor>=0) and (minor<=$ffff) then
  933. dllminor:=minor
  934. else
  935. if error=0 then
  936. error:=1;
  937. end;
  938. if l=0 then
  939. l:=256;
  940. dllmajor:=1;
  941. if error=0 then
  942. val(copy(dllversion,1,l-1),major,error);
  943. if (error=0) and (major>=0) and (major<=$ffff) then
  944. dllmajor:=major
  945. else
  946. if error=0 then
  947. error:=1;
  948. if error<>0 then
  949. Message1(scan_w_wrong_version_ignored,dllversion);
  950. break;
  951. end;
  952. 'w' :
  953. usewindowapi:=true;
  954. '-' :
  955. begin
  956. exclude(init_settings.globalswitches,cs_link_deffile);
  957. usewindowapi:=false;
  958. end;
  959. else
  960. IllegalPara(opt);
  961. end;
  962. inc(j);
  963. end;
  964. end;
  965. 'e' :
  966. exepath:=FixPath(More,true);
  967. 'E' :
  968. begin
  969. if UnsetBool(More, 0) then
  970. exclude(init_settings.globalswitches,cs_link_nolink)
  971. else
  972. include(init_settings.globalswitches,cs_link_nolink);
  973. end;
  974. 'f' :
  975. begin
  976. if more='PIC' then
  977. begin
  978. if tf_no_pic_supported in target_info.flags then
  979. message(scan_w_pic_ignored)
  980. else
  981. include(init_settings.moduleswitches,cs_create_pic)
  982. end
  983. else
  984. IllegalPara(opt);
  985. end;
  986. 'F' :
  987. begin
  988. if more='' then
  989. IllegalPara(opt);
  990. c:=more[1];
  991. Delete(more,1,1);
  992. DefaultReplacements(More);
  993. case c of
  994. 'a' :
  995. autoloadunits:=more;
  996. 'c' :
  997. begin
  998. if (upper(more)='UTF8') or (upper(more)='UTF-8') then
  999. init_settings.sourcecodepage:=CP_UTF8
  1000. else if not(cpavailable(more)) then
  1001. Message1(option_code_page_not_available,more)
  1002. else
  1003. init_settings.sourcecodepage:=codepagebyname(more);
  1004. include(init_settings.moduleswitches,cs_explicit_codepage);
  1005. end;
  1006. 'C' :
  1007. RCCompiler := More;
  1008. 'd' :
  1009. if UnsetBool(more, 0) then
  1010. init_settings.disabledircache:=false
  1011. else
  1012. init_settings.disabledircache:=true;
  1013. 'D' :
  1014. utilsdirectory:=FixPath(More,true);
  1015. 'e' :
  1016. SetRedirectFile(More);
  1017. 'E' :
  1018. OutputExeDir:=FixPath(More,true);
  1019. 'f' :
  1020. if (target_info.system in systems_darwin) then
  1021. if ispara then
  1022. ParaFrameworkPath.AddPath(More,false)
  1023. else
  1024. frameworksearchpath.AddPath(More,true)
  1025. else
  1026. IllegalPara(opt);
  1027. 'i' :
  1028. begin
  1029. if ispara then
  1030. ParaIncludePath.AddPath(More,false)
  1031. else
  1032. includesearchpath.AddPath(More,true);
  1033. end;
  1034. 'm' :
  1035. begin
  1036. s:=ExtractFileDir(more);
  1037. if TryStrToInt(ExtractFileName(more),j) then
  1038. begin
  1039. unicodemapping:=loadunicodemapping(More,More+'.txt',j);
  1040. if assigned(unicodemapping) then
  1041. registermapping(unicodemapping)
  1042. else
  1043. IllegalPara(opt);
  1044. end
  1045. else
  1046. IllegalPara(opt);
  1047. end;
  1048. 'g' :
  1049. Message2(option_obsolete_switch_use_new,'-Fg','-Fl');
  1050. 'l' :
  1051. begin
  1052. if ispara then
  1053. ParaLibraryPath.AddPath(sysrootpath,More,false)
  1054. else
  1055. LibrarySearchPath.AddPath(sysrootpath,More,true);
  1056. end;
  1057. 'L' :
  1058. begin
  1059. if More<>'' then
  1060. ParaDynamicLinker:=More
  1061. else
  1062. IllegalPara(opt);
  1063. end;
  1064. 'o' :
  1065. begin
  1066. if ispara then
  1067. ParaObjectPath.AddPath(More,false)
  1068. else
  1069. ObjectSearchPath.AddPath(More,true);
  1070. end;
  1071. 'r' :
  1072. Msgfilename:=More;
  1073. 'R' :
  1074. ResCompiler := More;
  1075. 'u' :
  1076. begin
  1077. if ispara then
  1078. ParaUnitPath.AddPath(More,false)
  1079. else
  1080. unitsearchpath.AddPath(More,true);
  1081. end;
  1082. 'U' :
  1083. OutputUnitDir:=FixPath(More,true);
  1084. 'W',
  1085. 'w':
  1086. begin
  1087. if More<>'' then
  1088. begin
  1089. DefaultReplacements(More);
  1090. D:=ExtractFilePath(More);
  1091. if (D<>'') then
  1092. D:=FixPath(D,True);
  1093. D:=D+ExtractFileName(More);
  1094. if (c='W') then
  1095. WpoFeedbackOutput:=D
  1096. else
  1097. WpoFeedbackInput:=D;
  1098. end
  1099. else
  1100. IllegalPara(opt);
  1101. end;
  1102. else
  1103. IllegalPara(opt);
  1104. end;
  1105. end;
  1106. 'g' :
  1107. begin
  1108. if UnsetBool(More, 0) then
  1109. begin
  1110. exclude(init_settings.moduleswitches,cs_debuginfo);
  1111. exclude(init_settings.globalswitches,cs_use_heaptrc);
  1112. exclude(init_settings.globalswitches,cs_use_lineinfo);
  1113. exclude(init_settings.localswitches,cs_checkpointer);
  1114. localvartrashing := -1;
  1115. end
  1116. else
  1117. begin
  1118. include(init_settings.moduleswitches,cs_debuginfo);
  1119. if paratargetdbg=dbg_none then
  1120. paratargetdbg:=target_info.dbg;
  1121. end;
  1122. if not RelocSectionSetExplicitly then
  1123. RelocSection:=false;
  1124. j:=1;
  1125. while j<=length(more) do
  1126. begin
  1127. case more[j] of
  1128. 'c' :
  1129. begin
  1130. if UnsetBool(More, j) then
  1131. exclude(init_settings.localswitches,cs_checkpointer)
  1132. else if (target_info.system in supported_targets_gc) then
  1133. include(init_settings.localswitches,cs_checkpointer)
  1134. else
  1135. UnsupportedPara('-gc');
  1136. end;
  1137. 'h' :
  1138. begin
  1139. if UnsetBool(More, j) then
  1140. exclude(init_settings.globalswitches,cs_use_heaptrc)
  1141. else
  1142. include(init_settings.globalswitches,cs_use_heaptrc);
  1143. end;
  1144. 'l' :
  1145. begin
  1146. if UnsetBool(More, j) then
  1147. exclude(init_settings.globalswitches,cs_use_lineinfo)
  1148. else
  1149. include(init_settings.globalswitches,cs_use_lineinfo);
  1150. end;
  1151. 'o' :
  1152. begin
  1153. if not UpdateDebugStr(copy(more,j+1,length(more)),init_settings.debugswitches) then
  1154. IllegalPara(opt);
  1155. break;
  1156. end;
  1157. 'p' :
  1158. begin
  1159. if UnsetBool(More, j) then
  1160. exclude(init_settings.globalswitches,cs_stabs_preservecase)
  1161. else
  1162. include(init_settings.globalswitches,cs_stabs_preservecase);
  1163. end;
  1164. 's' :
  1165. begin
  1166. paratargetdbg:=dbg_stabs;
  1167. end;
  1168. 't' :
  1169. begin
  1170. if UnsetBool(More, j) then
  1171. localvartrashing := -1
  1172. else
  1173. localvartrashing := (localvartrashing + 1) mod nroftrashvalues;
  1174. end;
  1175. 'v' :
  1176. begin
  1177. if UnsetBool(More, j) then
  1178. exclude(init_settings.globalswitches,cs_gdb_valgrind)
  1179. else
  1180. include(init_settings.globalswitches,cs_gdb_valgrind);
  1181. end;
  1182. 'w' :
  1183. begin
  1184. if (j<length(more)) and (more[j+1] in ['2','3','4']) then
  1185. begin
  1186. case more[j+1] of
  1187. '2': paratargetdbg:=dbg_dwarf2;
  1188. '3': paratargetdbg:=dbg_dwarf3;
  1189. '4': paratargetdbg:=dbg_dwarf4;
  1190. end;
  1191. inc(j);
  1192. end
  1193. else
  1194. paratargetdbg:=dbg_dwarf2;
  1195. end;
  1196. else
  1197. IllegalPara(opt);
  1198. end;
  1199. inc(j);
  1200. end;
  1201. end;
  1202. 'h' :
  1203. begin
  1204. NoPressEnter:=true;
  1205. if (More <> '') and (More [1] = 'F') then
  1206. begin
  1207. FPCHelpLines := true;
  1208. Delete (More, 1, 1);
  1209. FPCBinaryPath := More;
  1210. end;
  1211. WriteHelpPages;
  1212. end;
  1213. 'i' :
  1214. begin
  1215. if More='' then
  1216. WriteInfo
  1217. else
  1218. QuickInfo:=QuickInfo+More;
  1219. end;
  1220. 'I' :
  1221. begin
  1222. if ispara then
  1223. ParaIncludePath.AddPath(More,false)
  1224. else
  1225. includesearchpath.AddPath(More,false);
  1226. end;
  1227. 'k' :
  1228. begin
  1229. if more<>'' then
  1230. ParaLinkOptions:=ParaLinkOptions+' '+More
  1231. else
  1232. IllegalPara(opt);
  1233. end;
  1234. 'l' :
  1235. ParaLogo:=not UnSetBool(more,0);
  1236. 'm' :
  1237. parapreprocess:=not UnSetBool(more,0);
  1238. 'M' :
  1239. begin
  1240. more:=Upper(more);
  1241. if not SetCompileMode(more, true) then
  1242. if not SetCompileModeSwitch(more, true) then
  1243. IllegalPara(opt);
  1244. end;
  1245. 'n' :
  1246. begin
  1247. if More='' then
  1248. disable_configfile:=true
  1249. else
  1250. IllegalPara(opt);
  1251. end;
  1252. 'o' :
  1253. begin
  1254. if More<>'' then
  1255. begin
  1256. DefaultReplacements(More);
  1257. D:=ExtractFilePath(More);
  1258. if (D<>'') then
  1259. OutputExeDir:=FixPath(D,True);
  1260. OutputFileName:=ExtractFileName(More);
  1261. end
  1262. else
  1263. IllegalPara(opt);
  1264. end;
  1265. 'O' :
  1266. begin
  1267. j:=1;
  1268. while j<=length(more) do
  1269. begin
  1270. case more[j] of
  1271. '1' :
  1272. init_settings.optimizerswitches:=init_settings.optimizerswitches+level1optimizerswitches;
  1273. '2' :
  1274. init_settings.optimizerswitches:=init_settings.optimizerswitches+level2optimizerswitches;
  1275. '3' :
  1276. init_settings.optimizerswitches:=init_settings.optimizerswitches+level3optimizerswitches;
  1277. 'a' :
  1278. begin
  1279. if not(UpdateAlignmentStr(Copy(Opt,j+3,255),ParaAlignment)) then
  1280. IllegalPara(opt);
  1281. break;
  1282. end;
  1283. 's' :
  1284. include(init_settings.optimizerswitches,cs_opt_size);
  1285. 'p' :
  1286. begin
  1287. if not Setcputype(copy(more,j+1,length(more)),init_settings.optimizecputype) then
  1288. begin
  1289. OptCPUSetExplicitly:=true;
  1290. { Give warning for old i386 switches }
  1291. if (Length(More)-j=1) and
  1292. (More[j+1]>='1') and (More[j+1]<='5')then
  1293. Message2(option_obsolete_switch_use_new,'-Op<nr>','-Op<name>')
  1294. else
  1295. IllegalPara(opt);
  1296. end;
  1297. break;
  1298. end;
  1299. 'o' :
  1300. begin
  1301. if not UpdateOptimizerStr(copy(more,j+1,length(more)),init_settings.optimizerswitches) then
  1302. IllegalPara(opt);
  1303. break;
  1304. end;
  1305. '-' :
  1306. begin
  1307. init_settings.optimizerswitches:=[];
  1308. FillChar(ParaAlignment,sizeof(ParaAlignment),0);
  1309. end;
  1310. { Obsolete switches }
  1311. 'g' :
  1312. Message2(option_obsolete_switch_use_new,'-Og','-Os');
  1313. 'G' :
  1314. Message1(option_obsolete_switch,'-OG');
  1315. 'r' :
  1316. Message2(option_obsolete_switch_use_new,'-Or','-O2 or -Ooregvar');
  1317. 'u' :
  1318. Message2(option_obsolete_switch_use_new,'-Ou','-Oouncertain');
  1319. 'w' :
  1320. begin
  1321. if not UpdateWpoStr(copy(more,j+1,length(more)),init_settings.dowpoptimizerswitches) then
  1322. IllegalPara(opt);
  1323. break;
  1324. end;
  1325. 'W' :
  1326. begin
  1327. if not UpdateWpoStr(copy(more,j+1,length(more)),init_settings.genwpoptimizerswitches) then
  1328. IllegalPara(opt);
  1329. break;
  1330. end;
  1331. else
  1332. IllegalPara(opt);
  1333. end;
  1334. inc(j);
  1335. end;
  1336. end;
  1337. 'p' :
  1338. begin
  1339. if UnsetBool(More, 0) then
  1340. begin
  1341. init_settings.moduleswitches:=init_settings.moduleswitches-[cs_profile];
  1342. undef_system_macro('FPC_PROFILE');
  1343. end
  1344. else
  1345. if Length(More)=0 then
  1346. IllegalPara(opt)
  1347. else
  1348. case more[1] of
  1349. 'g' : if UnsetBool(more, 1) then
  1350. begin
  1351. exclude(init_settings.moduleswitches,cs_profile);
  1352. undef_system_macro('FPC_PROFILE');
  1353. end
  1354. else if (target_info.system in supported_targets_pg) then
  1355. begin
  1356. include(init_settings.moduleswitches,cs_profile);
  1357. def_system_macro('FPC_PROFILE');
  1358. end
  1359. else
  1360. UnsupportedPara('-pg');
  1361. else
  1362. IllegalPara(opt);
  1363. end;
  1364. end;
  1365. 'P' : ; { Ignore used by fpc.pp }
  1366. 'R' :
  1367. begin
  1368. if not SetAsmReadMode(More,init_settings.asmmode) then
  1369. IllegalPara(opt);
  1370. end;
  1371. 's' :
  1372. begin
  1373. if UnsetBool(More, 0) then
  1374. begin
  1375. init_settings.globalswitches:=init_settings.globalswitches-[cs_asm_extern,cs_link_extern,cs_link_nolink];
  1376. if more<>'' then
  1377. IllegalPara(opt);
  1378. end
  1379. else
  1380. begin
  1381. init_settings.globalswitches:=init_settings.globalswitches+[cs_asm_extern,cs_link_extern,cs_link_nolink];
  1382. if more='h' then
  1383. init_settings.globalswitches:=init_settings.globalswitches-[cs_link_on_target]
  1384. else if more='t' then
  1385. init_settings.globalswitches:=init_settings.globalswitches+[cs_link_on_target]
  1386. else if more='r' then
  1387. init_settings.globalswitches:=init_settings.globalswitches+[cs_asm_leave,cs_no_regalloc]
  1388. else if more<>'' then
  1389. IllegalPara(opt);
  1390. end;
  1391. end;
  1392. 'S' :
  1393. begin
  1394. if more='' then
  1395. IllegalPara(opt);
  1396. if more[1]='I' then
  1397. begin
  1398. {$ifdef jvm}
  1399. UnsupportedPara('-SI');
  1400. {$endif}
  1401. if upper(more)='ICOM' then
  1402. init_settings.interfacetype:=it_interfacecom
  1403. else if upper(more)='ICORBA' then
  1404. init_settings.interfacetype:=it_interfacecorba
  1405. else
  1406. IllegalPara(opt);
  1407. end
  1408. else
  1409. begin
  1410. j:=1;
  1411. while j<=length(more) do
  1412. begin
  1413. case more[j] of
  1414. '2' : //an alternative to -Mobjfpc
  1415. SetCompileMode('OBJFPC',true);
  1416. 'a' :
  1417. If UnsetBool(More, j) then
  1418. exclude(init_settings.localswitches,cs_do_assertion)
  1419. else
  1420. include(init_settings.localswitches,cs_do_assertion);
  1421. 'c' :
  1422. If UnsetBool(More, j) then
  1423. exclude(init_settings.moduleswitches,cs_support_c_operators)
  1424. else
  1425. include(init_settings.moduleswitches,cs_support_c_operators);
  1426. 'd' : //an alternative to -Mdelphi
  1427. SetCompileMode('DELPHI',true);
  1428. 'e' :
  1429. begin
  1430. SetErrorFlags(copy(more,j+1,length(more)));
  1431. break;
  1432. end;
  1433. 'f' :
  1434. begin
  1435. inc(j);
  1436. if more[j]='-' then
  1437. begin
  1438. features:=[];
  1439. if length(more)>j then
  1440. IllegalPara(opt);
  1441. end
  1442. else
  1443. begin
  1444. if (IncludeFeature(upper(copy(more,j,length(more)-j+1)))) then
  1445. j:=length(more)
  1446. else
  1447. IllegalPara(opt);
  1448. end;
  1449. end;
  1450. 'g' :
  1451. If UnsetBool(More, j) then
  1452. exclude(init_settings.moduleswitches,cs_support_goto)
  1453. else
  1454. include(init_settings.moduleswitches,cs_support_goto);
  1455. 'h' :
  1456. If UnsetBool(More, j) then
  1457. exclude(init_settings.localswitches,cs_refcountedstrings)
  1458. else
  1459. include(init_settings.localswitches,cs_refcountedstrings);
  1460. 'i' :
  1461. If UnsetBool(More, j) then
  1462. exclude(init_settings.localswitches,cs_do_inline)
  1463. else
  1464. include(init_settings.localswitches,cs_do_inline);
  1465. 'k' :
  1466. If UnsetBool(More, j) then
  1467. exclude(init_settings.globalswitches,cs_load_fpcylix_unit)
  1468. else
  1469. include(init_settings.globalswitches,cs_load_fpcylix_unit);
  1470. 'm' :
  1471. If UnsetBool(More, j) then
  1472. exclude(init_settings.moduleswitches,cs_support_macro)
  1473. else
  1474. include(init_settings.moduleswitches,cs_support_macro);
  1475. 'o' : //an alternative to -Mtp
  1476. SetCompileMode('TP',true);
  1477. {$ifdef gpc_mode}
  1478. 'p' : //an alternative to -Mgpc
  1479. SetCompileMode('GPC',true);
  1480. {$endif}
  1481. 's' :
  1482. If UnsetBool(More, j) then
  1483. exclude(init_settings.globalswitches,cs_constructor_name)
  1484. else
  1485. include(init_settings.globalswitches,cs_constructor_name);
  1486. 't' :
  1487. Message1(option_obsolete_switch,'-St');
  1488. 'v' :
  1489. If UnsetBool(More, j) then
  1490. exclude(init_settings.globalswitches,cs_support_vectors)
  1491. else
  1492. include(init_settings.globalswitches,cs_support_vectors);
  1493. 'x' :
  1494. If UnsetBool(More, j) then
  1495. exclude(init_settings.globalswitches,cs_support_exceptions)
  1496. else
  1497. include(init_settings.globalswitches,cs_support_exceptions);
  1498. 'y' :
  1499. If UnsetBool(More, j) then
  1500. exclude(init_settings.localswitches,cs_typed_addresses)
  1501. else
  1502. include(init_settings.localswitches,cs_typed_addresses);
  1503. '-' :
  1504. begin
  1505. init_settings.globalswitches:=init_settings.globalswitches - [cs_constructor_name,cs_support_exceptions,
  1506. cs_support_vectors,cs_load_fpcylix_unit];
  1507. init_settings.localswitches:=init_settings.localswitches - [cs_do_assertion,cs_do_inline, cs_refcountedstrings,
  1508. cs_typed_addresses];
  1509. init_settings.moduleswitches:=init_settings.moduleswitches - [cs_support_c_operators, cs_support_goto,
  1510. cs_support_macro];
  1511. end;
  1512. else
  1513. IllegalPara(opt);
  1514. end;
  1515. inc(j);
  1516. end;
  1517. end;
  1518. end;
  1519. 'T' :
  1520. begin
  1521. more:=Upper(More);
  1522. if paratarget=system_none then
  1523. begin
  1524. { remove old target define }
  1525. TargetOptions(false);
  1526. { load new target }
  1527. paratarget:=find_system_by_string(More);
  1528. if paratarget<>system_none then
  1529. set_target(paratarget)
  1530. else
  1531. IllegalPara(opt);
  1532. { set new define }
  1533. TargetOptions(true);
  1534. end
  1535. else
  1536. if More<>upper(target_info.shortname) then
  1537. Message1(option_target_is_already_set,target_info.shortname);
  1538. end;
  1539. 'u' :
  1540. if more <> '' then
  1541. undef_system_macro(more);
  1542. 'U' :
  1543. begin
  1544. j:=1;
  1545. while j<=length(more) do
  1546. begin
  1547. case more[j] of
  1548. {$ifdef UNITALIASES}
  1549. 'a' :
  1550. begin
  1551. AddUnitAlias(Copy(More,j+1,255));
  1552. break;
  1553. end;
  1554. {$endif UNITALIASES}
  1555. 'n' :
  1556. exclude(init_settings.globalswitches,cs_check_unit_name);
  1557. 'p' :
  1558. begin
  1559. Message2(option_obsolete_switch_use_new,'-Up','-Fu');
  1560. break;
  1561. end;
  1562. 'r' :
  1563. do_release:=true;
  1564. 's' :
  1565. include(init_settings.moduleswitches,cs_compilesystem);
  1566. '-' :
  1567. begin
  1568. exclude(init_settings.moduleswitches,cs_compilesystem);
  1569. exclude(init_settings.globalswitches,cs_check_unit_name);
  1570. end;
  1571. else
  1572. IllegalPara(opt);
  1573. end;
  1574. inc(j);
  1575. end;
  1576. end;
  1577. 'v' :
  1578. begin
  1579. if not setverbosity(More) then
  1580. IllegalPara(opt);
  1581. end;
  1582. 'V' : ; { Ignore used by fpc }
  1583. 'W' :
  1584. begin
  1585. j:=1;
  1586. while j<=length(More) do
  1587. begin
  1588. case More[j] of
  1589. 'A':
  1590. begin
  1591. if target_info.system in systems_all_windows then
  1592. begin
  1593. if UnsetBool(More, j) then
  1594. apptype:=app_cui
  1595. else
  1596. apptype:=app_native;
  1597. end
  1598. else
  1599. IllegalPara(opt);
  1600. end;
  1601. 'b':
  1602. begin
  1603. if target_info.system in systems_darwin then
  1604. begin
  1605. if UnsetBool(More, j) then
  1606. apptype:=app_cui
  1607. else
  1608. apptype:=app_bundle
  1609. end
  1610. else
  1611. IllegalPara(opt);
  1612. end;
  1613. 'B':
  1614. begin
  1615. if target_info.system in systems_all_windows+systems_symbian then
  1616. begin
  1617. { -WB200000 means set trefered base address
  1618. to $200000, but does not change relocsection boolean
  1619. this way we can create both relocatble and
  1620. non relocatable DLL at a specific base address PM }
  1621. if (length(More)>j) then
  1622. begin
  1623. val('$'+Copy(More,j+1,255),imagebase,code);
  1624. if code<>0 then
  1625. IllegalPara(opt);
  1626. ImageBaseSetExplicity:=true;
  1627. end
  1628. else
  1629. begin
  1630. RelocSection:=true;
  1631. RelocSectionSetExplicitly:=true;
  1632. end;
  1633. break;
  1634. end
  1635. else
  1636. IllegalPara(opt);
  1637. end;
  1638. 'C':
  1639. begin
  1640. if target_info.system in systems_all_windows+systems_os2+systems_macos then
  1641. begin
  1642. if UnsetBool(More, j) then
  1643. apptype:=app_gui
  1644. else
  1645. apptype:=app_cui;
  1646. end
  1647. else
  1648. IllegalPara(opt);
  1649. end;
  1650. 'D':
  1651. begin
  1652. if target_info.system in systems_all_windows then
  1653. begin
  1654. UseDeffileForExports:=not UnsetBool(More, j);
  1655. UseDeffileForExportsSetExplicitly:=true;
  1656. end
  1657. else
  1658. IllegalPara(opt);
  1659. end;
  1660. 'e':
  1661. begin
  1662. if (target_info.system in systems_darwin) then
  1663. begin
  1664. RegisterRes(res_macosx_ext_info,TWinLikeResourceFile);
  1665. set_target_res(res_ext);
  1666. target_info.resobjext:='.fpcres';
  1667. end
  1668. else
  1669. IllegalPara(opt);
  1670. end;
  1671. 'F':
  1672. begin
  1673. if target_info.system in systems_os2 then
  1674. begin
  1675. if UnsetBool(More, j) then
  1676. apptype:=app_cui
  1677. else
  1678. apptype:=app_fs;
  1679. end
  1680. else
  1681. IllegalPara(opt);
  1682. end;
  1683. 'G':
  1684. begin
  1685. if target_info.system in systems_all_windows+systems_os2+systems_macos then
  1686. begin
  1687. if UnsetBool(More, j) then
  1688. apptype:=app_cui
  1689. else
  1690. apptype:=app_gui;
  1691. end
  1692. else
  1693. IllegalPara(opt);
  1694. end;
  1695. 'I':
  1696. begin
  1697. if target_info.system in systems_all_windows then
  1698. begin
  1699. GenerateImportSection:=not UnsetBool(More,j);
  1700. GenerateImportSectionSetExplicitly:=true;
  1701. end
  1702. else
  1703. IllegalPara(opt);
  1704. end;
  1705. 'i':
  1706. begin
  1707. if (target_info.system in systems_darwin) then
  1708. begin
  1709. set_target_res(res_macho);
  1710. target_info.resobjext:=
  1711. targetinfos[target_info.system]^.resobjext;
  1712. end
  1713. else
  1714. IllegalPara(opt);
  1715. end;
  1716. 'M':
  1717. begin
  1718. if (target_info.system in (systems_darwin-[system_i386_iphonesim])) and
  1719. ParseMacVersionMin(MacOSXVersionMin,iPhoneOSVersionMin,'MAC_OS_X_VERSION_MIN_REQUIRED',copy(More,2,255),false) then
  1720. begin
  1721. break;
  1722. end
  1723. else
  1724. IllegalPara(opt);
  1725. end;
  1726. 'N':
  1727. begin
  1728. if target_info.system in systems_all_windows then
  1729. begin
  1730. RelocSection:=UnsetBool(More,j);
  1731. RelocSectionSetExplicitly:=true;
  1732. end
  1733. else
  1734. IllegalPara(opt);
  1735. end;
  1736. 'p':
  1737. begin
  1738. {$if defined(arm) or defined(avr)}
  1739. if (target_info.system in systems_embedded) then
  1740. begin
  1741. s:=upper(copy(more,j+1,length(more)-j));
  1742. if not(SetControllerType(s,init_settings.controllertype)) then
  1743. IllegalPara(opt);
  1744. break;
  1745. end
  1746. else
  1747. {$endif defined(arm) or defined(avr)}
  1748. IllegalPara(opt);
  1749. end;
  1750. 'P':
  1751. begin
  1752. if (target_info.system in [system_i386_iphonesim,system_arm_darwin]) and
  1753. ParseMacVersionMin(iPhoneOSVersionMin,MacOSXVersionMin,'IPHONE_OS_VERSION_MIN_REQUIRED',copy(More,2,255),true) then
  1754. begin
  1755. break;
  1756. end
  1757. else
  1758. IllegalPara(opt);
  1759. end;
  1760. 'R':
  1761. begin
  1762. if target_info.system in systems_all_windows then
  1763. begin
  1764. { support -WR+ / -WR- as synonyms to -WR / -WN }
  1765. RelocSection:=not UnsetBool(More,j);
  1766. RelocSectionSetExplicitly:=true;
  1767. end
  1768. else
  1769. IllegalPara(opt);
  1770. end;
  1771. 'T':
  1772. begin
  1773. if target_info.system in systems_macos then
  1774. begin
  1775. if UnsetBool(More, j) then
  1776. apptype:=app_cui
  1777. else
  1778. apptype:=app_tool;
  1779. end
  1780. else
  1781. IllegalPara(opt);
  1782. end;
  1783. 'X':
  1784. begin
  1785. if (target_info.system in systems_linux) then
  1786. begin
  1787. if UnsetBool(More, j) then
  1788. exclude(init_settings.moduleswitches,cs_executable_stack)
  1789. else
  1790. include(init_settings.moduleswitches,cs_executable_stack)
  1791. end
  1792. else
  1793. IllegalPara(opt);
  1794. end
  1795. else
  1796. IllegalPara(opt);
  1797. end;
  1798. inc(j);
  1799. end;
  1800. end;
  1801. 'X' :
  1802. begin
  1803. j:=1;
  1804. while j<=length(more) do
  1805. begin
  1806. case More[j] of
  1807. 'c' : Cshared:=TRUE;
  1808. 'd' : Dontlinkstdlibpath:=TRUE;
  1809. 'e' :
  1810. begin
  1811. If UnsetBool(More, j) then
  1812. exclude(init_settings.globalswitches,cs_link_extern)
  1813. else
  1814. include(init_settings.globalswitches,cs_link_extern);
  1815. end;
  1816. 'f' :
  1817. include(init_settings.globalswitches,cs_link_pthread);
  1818. 'g' :
  1819. begin
  1820. If UnsetBool(More, j) then
  1821. exclude(init_settings.globalswitches,cs_link_separate_dbg_file)
  1822. else
  1823. include(init_settings.globalswitches,cs_link_separate_dbg_file);
  1824. end;
  1825. 'i' :
  1826. begin
  1827. If UnsetBool(More, j) then
  1828. include(init_settings.globalswitches,cs_link_extern)
  1829. else
  1830. exclude(init_settings.globalswitches,cs_link_extern);
  1831. end;
  1832. 'n' :
  1833. begin
  1834. If UnsetBool(More, j) then
  1835. exclude(init_settings.globalswitches,cs_link_native)
  1836. else
  1837. include(init_settings.globalswitches,cs_link_native);
  1838. end;
  1839. 'm' :
  1840. begin
  1841. If UnsetBool(More, j) then
  1842. exclude(init_settings.globalswitches,cs_link_map)
  1843. else
  1844. include(init_settings.globalswitches,cs_link_map);
  1845. end;
  1846. 'p' : ; { Ignore used by fpc.pp }
  1847. 'r' :
  1848. begin
  1849. if (target_info.system in suppported_targets_x_smallr) then
  1850. begin
  1851. rlinkpath:=Copy(more,2,length(More)-1);
  1852. DefaultReplacements(rlinkpath);
  1853. end
  1854. else
  1855. IgnoredPara('-Xr');
  1856. more:='';
  1857. end;
  1858. 'R' :
  1859. begin
  1860. sysrootpath:=copy(more,2,length(more)-1);
  1861. defaultreplacements(sysrootpath);
  1862. more:='';
  1863. end;
  1864. 's' :
  1865. begin
  1866. If UnsetBool(More, j) then
  1867. exclude(init_settings.globalswitches,cs_link_strip)
  1868. else
  1869. include(init_settings.globalswitches,cs_link_strip);
  1870. end;
  1871. 't' :
  1872. include(init_settings.globalswitches,cs_link_staticflag);
  1873. 'v' :
  1874. begin
  1875. If UnsetBool(More, j) then
  1876. exclude(init_settings.globalswitches,cs_link_opt_vtable)
  1877. else
  1878. include(init_settings.globalswitches,cs_link_opt_vtable);
  1879. end;
  1880. 'D' :
  1881. begin
  1882. def_system_macro('FPC_LINK_DYNAMIC');
  1883. undef_system_macro('FPC_LINK_SMART');
  1884. undef_system_macro('FPC_LINK_STATIC');
  1885. exclude(init_settings.globalswitches,cs_link_static);
  1886. exclude(init_settings.globalswitches,cs_link_smart);
  1887. include(init_settings.globalswitches,cs_link_shared);
  1888. LinkTypeSetExplicitly:=true;
  1889. end;
  1890. 'M' :
  1891. begin
  1892. mainaliasname:=Copy(more,2,length(More)-1);
  1893. More:='';
  1894. end;
  1895. 'P' :
  1896. begin
  1897. utilsprefix:=Copy(more,2,length(More)-1);
  1898. DefaultReplacements(utilsprefix);
  1899. More:='';
  1900. end;
  1901. 'L' : begin // -XLO is link order -XLA is link alias. -XLD avoids load defaults.
  1902. // these are not aggregable.
  1903. if (j=length(more)) or not (more[j+1] in ['O','A','D']) then
  1904. IllegalPara(opt)
  1905. else
  1906. begin
  1907. case more[j+1] of
  1908. 'A' : begin
  1909. s:=Copy(more,3,length(More)-2);
  1910. if not LinkLibraryAliases.AddDep(s) Then
  1911. IllegalPara(opt);
  1912. end;
  1913. 'O' : begin
  1914. s:=Copy(more,3,length(More)-2);
  1915. if not LinkLibraryOrder.AddWeight(s) Then
  1916. IllegalPara(opt);
  1917. end;
  1918. 'D' : include(init_settings.globalswitches,cs_link_no_default_lib_order)
  1919. else
  1920. IllegalPara(opt);
  1921. end; {case}
  1922. j:=length(more);
  1923. end; {else begin}
  1924. end;
  1925. 'S' :
  1926. begin
  1927. ForceStaticLinking;
  1928. end;
  1929. 'X' :
  1930. begin
  1931. def_system_macro('FPC_LINK_SMART');
  1932. undef_system_macro('FPC_LINK_STATIC');
  1933. undef_system_macro('FPC_LINK_DYNAMIC');
  1934. exclude(init_settings.globalswitches,cs_link_static);
  1935. include(init_settings.globalswitches,cs_link_smart);
  1936. exclude(init_settings.globalswitches,cs_link_shared);
  1937. LinkTypeSetExplicitly:=true;
  1938. end;
  1939. '-' :
  1940. begin
  1941. exclude(init_settings.globalswitches,cs_link_staticflag);
  1942. exclude(init_settings.globalswitches,cs_link_strip);
  1943. exclude(init_settings.globalswitches,cs_link_map);
  1944. set_default_link_type;
  1945. end;
  1946. else
  1947. IllegalPara(opt);
  1948. end;
  1949. inc(j);
  1950. end;
  1951. end;
  1952. else
  1953. IllegalPara(opt);
  1954. end;
  1955. end;
  1956. '@' :
  1957. begin
  1958. Message(option_no_nested_response_file);
  1959. StopOptions(1);
  1960. end;
  1961. else
  1962. begin
  1963. if (length(param_file)<>0) then
  1964. Message2(option_only_one_source_support,param_file,opt);
  1965. param_file:=opt;
  1966. Message1(option_found_file,opt);
  1967. end;
  1968. end;
  1969. end;
  1970. procedure Toption.Interpret_file(const filename : TPathStr);
  1971. procedure RemoveSep(var fn:TPathStr);
  1972. var
  1973. i : longint;
  1974. begin
  1975. i:=0;
  1976. while (i<length(fn)) and (fn[i+1] in [',',' ',#9]) do
  1977. inc(i);
  1978. Delete(fn,1,i);
  1979. i:=length(fn);
  1980. while (i>0) and (fn[i] in [',',' ',#9]) do
  1981. dec(i);
  1982. fn:=copy(fn,1,i);
  1983. end;
  1984. function GetName(var fn:TPathStr):TPathStr;
  1985. var
  1986. i : longint;
  1987. begin
  1988. i:=0;
  1989. while (i<length(fn)) and (fn[i+1] in ['a'..'z','A'..'Z','0'..'9','_','-']) do
  1990. inc(i);
  1991. GetName:=Copy(fn,1,i);
  1992. Delete(fn,1,i);
  1993. end;
  1994. const
  1995. maxlevel = 15;
  1996. var
  1997. f : text;
  1998. s, tmp,
  1999. opts : TCmdStr;
  2000. skip : array[0..maxlevel] of boolean;
  2001. line,
  2002. level : longint;
  2003. option_read : boolean;
  2004. begin
  2005. { avoid infinite loop }
  2006. Inc(FileLevel);
  2007. Option_read:=false;
  2008. If FileLevel>MaxLevel then
  2009. Message(option_too_many_cfg_files);
  2010. { Maybe It's Directory ?} //Jaro Change:
  2011. if PathExists(filename,false) then
  2012. begin
  2013. Message1(option_config_is_dir,filename);
  2014. exit;
  2015. end;
  2016. { open file }
  2017. Message1(option_using_file,filename);
  2018. assign(f,ExpandFileName(filename));
  2019. {$push}{$I-}
  2020. reset(f);
  2021. {$pop}
  2022. if ioresult<>0 then
  2023. begin
  2024. Message1(option_unable_open_file,filename);
  2025. exit;
  2026. end;
  2027. Message1(option_start_reading_configfile,filename);
  2028. fillchar(skip,sizeof(skip),0);
  2029. level:=0;
  2030. line:=0;
  2031. while not eof(f) do
  2032. begin
  2033. readln(f,opts);
  2034. inc(line);
  2035. RemoveSep(opts);
  2036. if (opts<>'') and (opts[1]<>';') then
  2037. begin
  2038. if opts[1]='#' then
  2039. begin
  2040. Message1(option_interpreting_file_option,opts);
  2041. Delete(opts,1,1);
  2042. s:=upper(GetName(opts));
  2043. if (s='SECTION') then
  2044. begin
  2045. RemoveSep(opts);
  2046. s:=upper(GetName(opts));
  2047. if level=0 then
  2048. skip[level]:=not defined_macro(s) or (s='COMMON');
  2049. end
  2050. else
  2051. if (s='IFDEF') then
  2052. begin
  2053. RemoveSep(opts);
  2054. if Level>=maxlevel then
  2055. begin
  2056. Message2(option_too_many_ifdef,filename,tostr(line));
  2057. stopOptions(1);
  2058. end;
  2059. inc(Level);
  2060. skip[level]:=(skip[level-1] or not defined_macro(upper(GetName(opts))));
  2061. end
  2062. else
  2063. if (s='IFNDEF') then
  2064. begin
  2065. RemoveSep(opts);
  2066. if Level>=maxlevel then
  2067. begin
  2068. Message2(option_too_many_ifdef,filename,tostr(line));
  2069. stopOptions(1);
  2070. end;
  2071. inc(Level);
  2072. skip[level]:=(skip[level-1] or defined_macro(upper(GetName(opts))));
  2073. end
  2074. else
  2075. if (s='ELSE') then
  2076. begin
  2077. if Level=0 then
  2078. begin
  2079. Message2(option_else_without_if,filename,tostr(line));
  2080. stopOptions(1);
  2081. end
  2082. else
  2083. skip[level]:=skip[level-1] or (not skip[level])
  2084. end
  2085. else
  2086. if (s='ENDIF') then
  2087. begin
  2088. skip[level]:=false;
  2089. if Level=0 then
  2090. begin
  2091. Message2(option_too_many_endif,filename,tostr(line));
  2092. stopOptions(1);
  2093. end;
  2094. dec(level);
  2095. end
  2096. else
  2097. if (not skip[level]) then
  2098. begin
  2099. if (s='DEFINE') then
  2100. begin
  2101. RemoveSep(opts);
  2102. tmp:= GetName(opts);
  2103. if tmp <> '' then
  2104. def_system_macro(tmp);
  2105. Option_read:=true;
  2106. end
  2107. else
  2108. if (s='UNDEF') then
  2109. begin
  2110. RemoveSep(opts);
  2111. tmp:= GetName(opts);
  2112. if tmp <> '' then
  2113. undef_system_macro(tmp);
  2114. Option_read:=true;
  2115. end
  2116. else
  2117. if (s='WRITE') then
  2118. begin
  2119. Delete(opts,1,1);
  2120. WriteLn(opts);
  2121. Option_read:=true;
  2122. end
  2123. else
  2124. if (s='INCLUDE') then
  2125. begin
  2126. Delete(opts,1,1);
  2127. Interpret_file(opts);
  2128. Option_read:=true;
  2129. end;
  2130. end;
  2131. end
  2132. else
  2133. begin
  2134. if (opts[1]='-') or (opts[1]='@') then
  2135. begin
  2136. if (not skip[level]) then
  2137. interpret_option(opts,false);
  2138. Option_read:=true;
  2139. end
  2140. else
  2141. Message1(option_illegal_para,opts);
  2142. end;
  2143. end;
  2144. end;
  2145. if Level>0 then
  2146. Message(option_too_less_endif);
  2147. if Not Option_read then
  2148. Message1(option_no_option_found,filename)
  2149. else
  2150. Message1(option_end_reading_configfile,filename);
  2151. Close(f);
  2152. Dec(FileLevel);
  2153. end;
  2154. procedure Toption.Interpret_envvar(const envname : TCmdStr);
  2155. var
  2156. argstart,
  2157. env,
  2158. pc : pchar;
  2159. arglen : longint;
  2160. quote : set of char;
  2161. hs : TCmdStr;
  2162. begin
  2163. Message1(option_using_env,envname);
  2164. env:=GetEnvPChar(envname);
  2165. pc:=env;
  2166. if assigned(pc) then
  2167. begin
  2168. repeat
  2169. { skip leading spaces }
  2170. while pc^ in [' ',#9,#13] do
  2171. inc(pc);
  2172. case pc^ of
  2173. #0 :
  2174. break;
  2175. '"' :
  2176. begin
  2177. quote:=['"'];
  2178. inc(pc);
  2179. end;
  2180. '''' :
  2181. begin
  2182. quote:=[''''];
  2183. inc(pc);
  2184. end;
  2185. else
  2186. quote:=[' ',#9,#13];
  2187. end;
  2188. { scan until the end of the argument }
  2189. argstart:=pc;
  2190. while (pc^<>#0) and not(pc^ in quote) do
  2191. inc(pc);
  2192. { create argument }
  2193. arglen:=pc-argstart;
  2194. { TODO: FIXME: silent truncation of environment parameters }
  2195. if (arglen > 255) then
  2196. arglen := 255;
  2197. setlength(hs,arglen);
  2198. move(argstart^,hs[1],arglen);
  2199. interpret_option(hs,true);
  2200. { skip quote }
  2201. if pc^ in quote then
  2202. inc(pc);
  2203. until false;
  2204. end
  2205. else
  2206. Message1(option_no_option_found,'(env) '+envname);
  2207. FreeEnvPChar(env);
  2208. end;
  2209. procedure toption.read_parameters;
  2210. var
  2211. opts : TCmdStr;
  2212. paramindex : longint;
  2213. begin
  2214. paramindex:=0;
  2215. while paramindex<paramcount do
  2216. begin
  2217. inc(paramindex);
  2218. opts:=objpas.paramstr(paramindex);
  2219. if length(opts)>0 then
  2220. case opts[1] of
  2221. '@' :
  2222. if not firstpass then
  2223. begin
  2224. Delete(opts,1,1);
  2225. Message1(option_reading_further_from,opts);
  2226. interpret_file(opts);
  2227. end;
  2228. '!' :
  2229. if not firstpass then
  2230. begin
  2231. Delete(opts,1,1);
  2232. Message1(option_reading_further_from,'(env) '+opts);
  2233. interpret_envvar(opts);
  2234. end;
  2235. else
  2236. interpret_option(opts,true);
  2237. end;
  2238. end;
  2239. end;
  2240. procedure toption.parsecmd(cmd:TCmdStr);
  2241. var
  2242. i,ps : longint;
  2243. opts : TCmdStr;
  2244. begin
  2245. while (cmd<>'') do
  2246. begin
  2247. while cmd[1]=' ' do
  2248. delete(cmd,1,1);
  2249. i:=pos(' ',cmd);
  2250. if i=0 then
  2251. i:=2147483647;
  2252. opts:=Copy(cmd,1,i-1);
  2253. Delete(cmd,1,i);
  2254. case opts[1] of
  2255. '@' :
  2256. if not firstpass then
  2257. begin
  2258. Delete(opts,1,1);
  2259. Message1(option_reading_further_from,opts);
  2260. interpret_file(opts);
  2261. end;
  2262. '!' :
  2263. if not firstpass then
  2264. begin
  2265. Delete(opts,1,1);
  2266. Message1(option_reading_further_from,'(env) '+opts);
  2267. interpret_envvar(opts);
  2268. end;
  2269. '"' :
  2270. begin
  2271. Delete(opts,1,1);
  2272. ps:=pos('"',cmd);
  2273. if (i<>256) and (ps>0) then
  2274. begin
  2275. opts:=opts + ' '+ copy(cmd,1,ps-1);
  2276. cmd:=copy(cmd,ps+1,255);
  2277. end;
  2278. interpret_option(opts,true);
  2279. end;
  2280. else
  2281. interpret_option(opts,true);
  2282. end;
  2283. end;
  2284. end;
  2285. procedure toption.writequickinfo;
  2286. var
  2287. s : string;
  2288. i : longint;
  2289. procedure addinfo(const hs:string);
  2290. begin
  2291. if s<>'' then
  2292. s:=s+' '+hs
  2293. else
  2294. s:=hs;
  2295. end;
  2296. begin
  2297. s:='';
  2298. i:=0;
  2299. while (i<length(quickinfo)) do
  2300. begin
  2301. inc(i);
  2302. case quickinfo[i] of
  2303. 'S' :
  2304. begin
  2305. inc(i);
  2306. case quickinfo[i] of
  2307. 'O' :
  2308. addinfo(lower(source_info.shortname));
  2309. 'P' :
  2310. addinfo(source_cpu_string);
  2311. else
  2312. IllegalPara('-i'+QuickInfo);
  2313. end;
  2314. end;
  2315. 'T' :
  2316. begin
  2317. inc(i);
  2318. case quickinfo[i] of
  2319. 'O' :
  2320. addinfo(lower(target_info.shortname));
  2321. 'P' :
  2322. AddInfo(target_cpu_string);
  2323. else
  2324. IllegalPara('-i'+QuickInfo);
  2325. end;
  2326. end;
  2327. 'V' :
  2328. AddInfo(version_string);
  2329. 'W' :
  2330. AddInfo(full_version_string);
  2331. 'D' :
  2332. AddInfo(date_string);
  2333. '_' :
  2334. ;
  2335. else
  2336. IllegalPara('-i'+QuickInfo);
  2337. end;
  2338. end;
  2339. if s<>'' then
  2340. begin
  2341. writeln(s);
  2342. stopoptions(0);
  2343. end;
  2344. end;
  2345. procedure TOption.TargetOptions(def:boolean);
  2346. var
  2347. s : string;
  2348. i : integer;
  2349. target_unsup_features : tfeatures;
  2350. begin
  2351. if def then
  2352. def_system_macro(target_info.shortname)
  2353. else
  2354. undef_system_macro(target_info.shortname);
  2355. s:=target_info.extradefines;
  2356. while (s<>'') do
  2357. begin
  2358. i:=pos(';',s);
  2359. if i=0 then
  2360. i:=length(s)+1;
  2361. if def then
  2362. def_system_macro(Copy(s,1,i-1))
  2363. else
  2364. undef_system_macro(Copy(s,1,i-1));
  2365. delete(s,1,i);
  2366. end;
  2367. if (tf_winlikewidestring in target_info.flags) then
  2368. if def then
  2369. def_system_macro('FPC_WINLIKEWIDESTRING')
  2370. else
  2371. undef_system_macro('FPC_WINLIKEWIDESTRING');
  2372. if (tf_requires_proper_alignment in target_info.flags) then
  2373. if def then
  2374. def_system_macro('FPC_REQUIRES_PROPER_ALIGNMENT')
  2375. else
  2376. undef_system_macro('FPC_REQUIRES_PROPER_ALIGNMENT');
  2377. if source_info.system<>target_info.system then
  2378. if def then
  2379. def_system_macro('FPC_CROSSCOMPILING')
  2380. else
  2381. undef_system_macro('FPC_CROSSCOMPILING');
  2382. if source_info.cpu<>target_info.cpu then
  2383. if def then
  2384. def_system_macro('FPC_CPUCROSSCOMPILING')
  2385. else
  2386. def_system_macro('FPC_CPUCROSSCOMPILING');
  2387. if (tf_no_generic_stackcheck in target_info.flags) then
  2388. if def then
  2389. def_system_macro('FPC_NO_GENERIC_STACK_CHECK')
  2390. else
  2391. undef_system_macro('FPC_NO_GENERIC_STACK_CHECK');
  2392. if (tf_section_threadvars in target_info.flags) then
  2393. if def then
  2394. def_system_macro('FPC_SECTION_THREADVARS')
  2395. else
  2396. undef_system_macro('FPC_SECTION_THREADVARS');
  2397. { Code generation flags }
  2398. if def and
  2399. (tf_pic_default in target_info.flags) then
  2400. include(init_settings.moduleswitches,cs_create_pic)
  2401. else
  2402. exclude(init_settings.moduleswitches,cs_create_pic);
  2403. { Resources support }
  2404. if (tf_has_winlike_resources in target_info.flags) then
  2405. if def then
  2406. def_system_macro('FPC_HAS_WINLIKERESOURCES')
  2407. else
  2408. undef_system_macro('FPC_HAS_WINLIKERESOURCES');
  2409. { Features }
  2410. case target_info.system of
  2411. system_arm_gba:
  2412. target_unsup_features:=[f_dynlibs];
  2413. system_arm_nds:
  2414. target_unsup_features:=[f_threading,f_commandargs,f_fileio,f_textio,f_consoleio,f_dynlibs];
  2415. system_i386_nativent:
  2416. // until these features are implemented, they are disabled in the compiler
  2417. target_unsup_features:=[f_stackcheck];
  2418. system_jvm_java32,
  2419. system_jvm_android32:
  2420. target_unsup_features:=[f_heap,f_textio,f_consoleio,f_fileio,
  2421. f_variants,f_objects,f_threading,f_commandargs,
  2422. f_processes,f_stackcheck,f_dynlibs,f_softfpu,f_objectivec1,f_resources];
  2423. else
  2424. target_unsup_features:=[];
  2425. end;
  2426. if def then
  2427. features:=features-target_unsup_features
  2428. else
  2429. features:=features+target_unsup_features;
  2430. end;
  2431. procedure TOption.checkoptionscompatibility;
  2432. begin
  2433. if (paratargetdbg in [dbg_dwarf2,dbg_dwarf3]) and
  2434. not(target_info.system in systems_darwin) then
  2435. begin
  2436. { smartlink creation does not yet work with DWARF
  2437. debug info on most targets, but it works in internal assembler }
  2438. if (cs_create_smart in init_settings.moduleswitches) and
  2439. not (af_outputbinary in target_asm.flags) then
  2440. begin
  2441. Message(option_dwarf_smartlink_creation);
  2442. exclude(init_settings.moduleswitches,cs_create_smart);
  2443. end;
  2444. { smart linking does not yet work with DWARF debug info on most targets }
  2445. if (cs_link_smart in init_settings.globalswitches) then
  2446. begin
  2447. Message(option_dwarf_smart_linking);
  2448. ForceStaticLinking;
  2449. end;
  2450. end;
  2451. { external debug info is only supported for DWARF on darwin }
  2452. if (target_info.system in systems_darwin) and
  2453. (cs_link_separate_dbg_file in init_settings.globalswitches) and
  2454. not(paratargetdbg in [dbg_dwarf2,dbg_dwarf3]) then
  2455. begin
  2456. Message(option_debug_external_unsupported);
  2457. exclude(init_settings.globalswitches,cs_link_separate_dbg_file);
  2458. end;
  2459. end;
  2460. constructor TOption.create;
  2461. begin
  2462. LogoWritten:=false;
  2463. NoPressEnter:=false;
  2464. FirstPass:=false;
  2465. FPUSetExplicitly:=false;
  2466. CPUSetExplicitly:=false;
  2467. OptCPUSetExplicitly:=false;
  2468. FileLevel:=0;
  2469. Quickinfo:='';
  2470. ParaIncludePath:=TSearchPathList.Create;
  2471. ParaObjectPath:=TSearchPathList.Create;
  2472. ParaUnitPath:=TSearchPathList.Create;
  2473. ParaLibraryPath:=TSearchPathList.Create;
  2474. ParaFrameworkPath:=TSearchPathList.Create;
  2475. FillChar(ParaAlignment,sizeof(ParaAlignment),0);
  2476. MacVersionSet:=false;
  2477. end;
  2478. destructor TOption.destroy;
  2479. begin
  2480. ParaIncludePath.Free;
  2481. ParaObjectPath.Free;
  2482. ParaUnitPath.Free;
  2483. ParaLibraryPath.Free;
  2484. ParaFrameworkPath.Free;
  2485. end;
  2486. {****************************************************************************
  2487. Callable Routines
  2488. ****************************************************************************}
  2489. function check_configfile(const fn:string;var foundfn:string):boolean;
  2490. function CfgFileExists(const fn:string):boolean;
  2491. begin
  2492. Comment(V_Tried,'Configfile search: '+fn);
  2493. CfgFileExists:=FileExists(fn);
  2494. end;
  2495. var
  2496. {$ifdef Unix}
  2497. hs,
  2498. {$endif Unix}
  2499. configpath : string;
  2500. begin
  2501. foundfn:=fn;
  2502. check_configfile:=true;
  2503. { retrieve configpath }
  2504. configpath:=FixPath(GetEnvironmentVariable('PPC_CONFIG_PATH'),false);
  2505. {$ifdef Unix}
  2506. if configpath='' then
  2507. configpath:=ExpandFileName(FixPath(exepath+'../etc/',false));
  2508. {$endif}
  2509. {
  2510. Order to read configuration file :
  2511. try reading fpc.cfg in :
  2512. 1 - current dir
  2513. 2 - configpath
  2514. 3 - compiler path
  2515. }
  2516. if not FileExists(fn) then
  2517. begin
  2518. {$ifdef Unix}
  2519. hs:=GetEnvironmentVariable('HOME');
  2520. if (hs<>'') and CfgFileExists(FixPath(hs,false)+'.'+fn) then
  2521. foundfn:=FixPath(hs,false)+'.'+fn
  2522. else
  2523. {$endif}
  2524. if CfgFileExists(configpath+fn) then
  2525. foundfn:=configpath+fn
  2526. else
  2527. {$ifdef WINDOWS}
  2528. if (GetEnvironmentVariable('USERPROFILE')<>'') and CfgFileExists(FixPath(GetEnvironmentVariable('USERPROFILE'),false)+fn) then
  2529. foundfn:=FixPath(GetEnvironmentVariable('USERPROFILE'),false)+fn
  2530. else
  2531. if (GetEnvironmentVariable('ALLUSERSPROFILE')<>'') and CfgFileExists(FixPath(GetEnvironmentVariable('ALLUSERSPROFILE'),false)+fn) then
  2532. foundfn:=FixPath(GetEnvironmentVariable('ALLUSERSPROFILE'),false)+fn
  2533. else
  2534. {$endif WINDOWS}
  2535. {$ifndef Unix}
  2536. if CfgFileExists(exepath+fn) then
  2537. foundfn:=exepath+fn
  2538. else
  2539. {$else}
  2540. if CfgFileExists('/etc/'+fn) then
  2541. foundfn:='/etc/'+fn
  2542. else
  2543. {$endif}
  2544. check_configfile:=false;
  2545. end;
  2546. end;
  2547. procedure read_arguments(cmd:TCmdStr);
  2548. var
  2549. env: ansistring;
  2550. i : tfeature;
  2551. abi : tabi;
  2552. begin
  2553. option:=coption.create;
  2554. disable_configfile:=false;
  2555. { Non-core target defines }
  2556. Option.TargetOptions(true);
  2557. { get default messagefile }
  2558. msgfilename:=GetEnvironmentVariable('PPC_ERROR_FILE');
  2559. { default configfile can be specified on the commandline,
  2560. remove it first }
  2561. if (cmd<>'') and (cmd[1]='[') then
  2562. begin
  2563. ppccfg:=Copy(cmd,2,pos(']',cmd)-2);
  2564. Delete(cmd,1,pos(']',cmd));
  2565. end
  2566. else
  2567. ppccfg:='fpc.cfg';
  2568. { first pass reading of parameters, only -i -v -T etc.}
  2569. option.firstpass:=true;
  2570. if cmd<>'' then
  2571. option.parsecmd(cmd)
  2572. else
  2573. begin
  2574. option.read_parameters;
  2575. { Write only quickinfo }
  2576. if option.quickinfo<>'' then
  2577. option.writequickinfo;
  2578. end;
  2579. option.firstpass:=false;
  2580. { redefine target options so all defines are written even if no -Txxx is passed on the command line }
  2581. Option.TargetOptions(true);
  2582. { target is set here, for wince the default app type is gui }
  2583. if target_info.system in systems_wince then
  2584. apptype:=app_gui;
  2585. { default defines }
  2586. def_system_macro(target_info.shortname);
  2587. def_system_macro('FPC');
  2588. def_system_macro('VER'+version_nr);
  2589. def_system_macro('VER'+version_nr+'_'+release_nr);
  2590. def_system_macro('VER'+version_nr+'_'+release_nr+'_'+patch_nr);
  2591. { Temporary defines, until things settle down }
  2592. def_system_macro('RESSTRSECTIONS');
  2593. def_system_macro('FPC_HASFIXED64BITVARIANT');
  2594. def_system_macro('FPC_HASINTERNALOLEVARIANT2VARIANTCAST');
  2595. def_system_macro('FPC_HAS_VARSETS');
  2596. def_system_macro('FPC_HAS_VALGRINDBOOL');
  2597. def_system_macro('FPC_HAS_STR_CURRENCY');
  2598. def_system_macro('FPC_REAL2REAL_FIXED');
  2599. def_system_macro('FPC_STRTOCHARARRAYPROC');
  2600. def_system_macro('FPC_STRTOSHORTSTRINGPROC');
  2601. def_system_macro('FPC_OBJFPC_EXTENDED_IF');
  2602. def_system_macro('FPC_HAS_OPERATOR_ENUMERATOR');
  2603. def_system_macro('FPC_HAS_CONSTREF');
  2604. def_system_macro('FPC_STATICRIPFIXED');
  2605. def_system_macro('FPC_VARIANTCOPY_FIXED');
  2606. def_system_macro('FPC_DYNARRAYCOPY_FIXED');
  2607. {$if defined(x86) or defined(powerpc) or defined(powerpc64) or defined(cpuarm)}
  2608. def_system_macro('FPC_HAS_INTERNAL_ABS_LONG');
  2609. {$endif}
  2610. def_system_macro('FPC_HAS_UNICODESTRING');
  2611. def_system_macro('FPC_RTTI_PACKSET1');
  2612. def_system_macro('FPC_HAS_CPSTRING');
  2613. {$ifdef x86_64}
  2614. def_system_macro('FPC_HAS_RIP_RELATIVE');
  2615. {$endif x86_64}
  2616. def_system_macro('FPC_HAS_CEXTENDED');
  2617. def_system_macro('FPC_HAS_RESSTRINITS');
  2618. { these cpus have an inline rol/ror implementaion }
  2619. {$ifdef cpurox}
  2620. def_system_macro('FPC_HAS_INTERNAL_ROX');
  2621. {$endif}
  2622. { these cpus have an inline sar implementaion }
  2623. { currently, all supported CPUs have an internal sar implementation }
  2624. { $if defined(x86) or defined(arm) or defined(powerpc) or defined(powerpc64) or defined(sparc) or defined(mips)}
  2625. def_system_macro('FPC_HAS_INTERNAL_SAR');
  2626. { $endif}
  2627. { inline bsf/bsr implementation }
  2628. {$if defined(x86) or defined(x86_64)}
  2629. def_system_macro('FPC_HAS_INTERNAL_BSX');
  2630. {$endif}
  2631. {$ifdef powerpc64}
  2632. def_system_macro('FPC_HAS_LWSYNC');
  2633. {$endif}
  2634. def_system_macro('FPC_HAS_MEMBAR');
  2635. def_system_macro('FPC_SETBASE_USED');
  2636. {$if defined(x86) or defined(arm) or defined(jvm)}
  2637. def_system_macro('INTERNAL_BACKTRACE');
  2638. {$endif}
  2639. def_system_macro('STR_CONCAT_PROCS');
  2640. {$warnings off}
  2641. if pocall_default = pocall_register then
  2642. def_system_macro('REGCALL');
  2643. {$warnings on}
  2644. { don't remove this, it's also for fpdoc necessary (FK) }
  2645. def_system_macro('FPC_HAS_FEATURE_SUPPORT');
  2646. { using a case is pretty useless here (FK) }
  2647. { some stuff for TP compatibility }
  2648. {$ifdef i386}
  2649. def_system_macro('CPU86');
  2650. def_system_macro('CPU87');
  2651. def_system_macro('CPU386');
  2652. {$endif}
  2653. { new processor stuff }
  2654. {$ifdef i386}
  2655. def_system_macro('CPUI386');
  2656. def_system_macro('CPU32');
  2657. def_system_macro('CPUX86');
  2658. def_system_macro('FPC_HAS_TYPE_EXTENDED');
  2659. def_system_macro('FPC_HAS_TYPE_DOUBLE');
  2660. def_system_macro('FPC_HAS_TYPE_SINGLE');
  2661. {$endif}
  2662. {$ifdef m68k}
  2663. def_system_macro('CPU68');
  2664. def_system_macro('CPU68K');
  2665. def_system_macro('CPUM68K');
  2666. def_system_macro('CPU32');
  2667. def_system_macro('FPC_CURRENCY_IS_INT64');
  2668. def_system_macro('FPC_COMP_IS_INT64');
  2669. {$endif}
  2670. {$ifdef ALPHA}
  2671. def_system_macro('CPUALPHA');
  2672. def_system_macro('CPU64');
  2673. {$endif}
  2674. {$ifdef powerpc}
  2675. def_system_macro('CPUPOWERPC');
  2676. def_system_macro('CPUPOWERPC32');
  2677. def_system_macro('CPU32');
  2678. def_system_macro('FPC_CURRENCY_IS_INT64');
  2679. def_system_macro('FPC_COMP_IS_INT64');
  2680. {$endif}
  2681. {$ifdef POWERPC64}
  2682. def_system_macro('CPUPOWERPC');
  2683. def_system_macro('CPUPOWERPC64');
  2684. def_system_macro('CPU64');
  2685. def_system_macro('FPC_CURRENCY_IS_INT64');
  2686. def_system_macro('FPC_COMP_IS_INT64');
  2687. {$endif}
  2688. {$ifdef iA64}
  2689. def_system_macro('CPUIA64');
  2690. def_system_macro('CPU64');
  2691. {$endif}
  2692. {$ifdef x86_64}
  2693. def_system_macro('CPUX86_64');
  2694. def_system_macro('CPUAMD64');
  2695. def_system_macro('CPU64');
  2696. def_system_macro('CPUX64');
  2697. { not supported for now, afaik (FK)
  2698. def_system_macro('FPC_HAS_TYPE_FLOAT128'); }
  2699. { win64 doesn't support the legacy fpu }
  2700. if target_info.system=system_x86_64_win64 then
  2701. begin
  2702. def_system_macro('FPC_CURRENCY_IS_INT64');
  2703. def_system_macro('FPC_COMP_IS_INT64');
  2704. end;
  2705. {$endif}
  2706. {$ifdef sparc}
  2707. def_system_macro('CPUSPARC');
  2708. def_system_macro('CPUSPARC32');
  2709. def_system_macro('CPU32');
  2710. def_system_macro('FPC_CURRENCY_IS_INT64');
  2711. def_system_macro('FPC_COMP_IS_INT64');
  2712. {$endif}
  2713. {$ifdef vis}
  2714. def_system_macro('CPUVIS');
  2715. def_system_macro('CPU32');
  2716. {$endif}
  2717. {$ifdef arm}
  2718. def_system_macro('CPUARM');
  2719. def_system_macro('CPU32');
  2720. def_system_macro('FPC_CURRENCY_IS_INT64');
  2721. def_system_macro('FPC_COMP_IS_INT64');
  2722. {$endif arm}
  2723. {$ifdef avr}
  2724. def_system_macro('CPUAVR');
  2725. def_system_macro('CPU16');
  2726. def_system_macro('FPC_CURRENCY_IS_INT64');
  2727. def_system_macro('FPC_COMP_IS_INT64');
  2728. {$endif avr}
  2729. {$ifdef jvm}
  2730. def_system_macro('CPUJVM');
  2731. def_system_macro('CPU32');
  2732. def_system_macro('FPC_CURRENCY_IS_INT64');
  2733. def_system_macro('FPC_COMP_IS_INT64');
  2734. {$endif jvm}
  2735. {$ifdef mipsel}
  2736. def_system_macro('CPUMIPS');
  2737. def_system_macro('CPUMIPS32');
  2738. def_system_macro('CPUMIPSEL');
  2739. def_system_macro('CPUMIPSEL32');
  2740. def_system_macro('CPU32');
  2741. def_system_macro('FPC_HAS_TYPE_DOUBLE');
  2742. def_system_macro('FPC_HAS_TYPE_SINGLE');
  2743. def_system_macro('FPC_INCLUDE_SOFTWARE_INT64_TO_DOUBLE');
  2744. def_system_macro('FPC_CURRENCY_IS_INT64');
  2745. def_system_macro('FPC_COMP_IS_INT64');
  2746. def_system_macro('FPC_REQUIRES_PROPER_ALIGNMENT');
  2747. { On most systems, locals are accessed relative to base pointer,
  2748. but for MIPS cpu, they are accessed relative to stack pointer.
  2749. This needs adaptation for so low level routines,
  2750. like MethodPointerLocal and related objects unit functions. }
  2751. def_system_macro('FPC_LOCALS_ARE_STACK_REG_RELATIVE');
  2752. {$endif mipsel}
  2753. {$ifdef mipseb}
  2754. def_system_macro('CPUMIPS');
  2755. def_system_macro('CPUMIPS32');
  2756. def_system_macro('CPUMIPSEB');
  2757. def_system_macro('CPUMIPSEB32');
  2758. def_system_macro('CPU32');
  2759. def_system_macro('FPC_HAS_TYPE_DOUBLE');
  2760. def_system_macro('FPC_HAS_TYPE_SINGLE');
  2761. def_system_macro('FPC_INCLUDE_SOFTWARE_INT64_TO_DOUBLE');
  2762. def_system_macro('FPC_CURRENCY_IS_INT64');
  2763. def_system_macro('FPC_COMP_IS_INT64');
  2764. def_system_macro('FPC_REQUIRES_PROPER_ALIGNMENT');
  2765. { See comment above for mipsel }
  2766. def_system_macro('FPC_LOCALS_ARE_STACK_REG_RELATIVE');
  2767. {$endif}
  2768. { read configuration file }
  2769. if (not disable_configfile) and
  2770. (ppccfg<>'') then
  2771. read_configfile:=check_configfile(ppccfg,ppccfg)
  2772. else
  2773. read_configfile := false;
  2774. { Read commandline and configfile }
  2775. param_file:='';
  2776. { read configfile }
  2777. if read_configfile then
  2778. option.interpret_file(ppccfg);
  2779. { read parameters again to override config file }
  2780. if cmd<>'' then
  2781. option.parsecmd(cmd)
  2782. else
  2783. begin
  2784. { Write help pages if no parameters are passed }
  2785. if (paramcount=0) then
  2786. Option.WriteHelpPages;
  2787. option.read_parameters;
  2788. { Write only quickinfo }
  2789. if option.quickinfo<>'' then
  2790. option.writequickinfo;
  2791. end;
  2792. { check the compatibility of different options and adjust them if necessary
  2793. (and print possible errors)
  2794. }
  2795. option.checkoptionscompatibility;
  2796. { Stop if errors in options }
  2797. if ErrorCount>0 then
  2798. StopOptions(1);
  2799. { endian define }
  2800. case target_info.endian of
  2801. endian_little :
  2802. begin
  2803. def_system_macro('ENDIAN_LITTLE');
  2804. def_system_macro('FPC_LITTLE_ENDIAN');
  2805. end;
  2806. endian_big :
  2807. begin
  2808. def_system_macro('ENDIAN_BIG');
  2809. def_system_macro('FPC_BIG_ENDIAN');
  2810. end;
  2811. end;
  2812. { define abi }
  2813. for abi:=low(tabi) to high(tabi) do
  2814. undef_system_macro('FPC_ABI_'+abi2str[abi]);
  2815. def_system_macro('FPC_ABI_'+abi2str[target_info.abi]);
  2816. { Define FPC_ABI_EABI in addition to FPC_ABI_EABIHF on EABI VFP hardfloat
  2817. systems since most code needs to behave the same on both}
  2818. if target_info.abi = abi_eabihf then
  2819. def_system_macro('FPC_ABI_EABI');
  2820. { Write logo }
  2821. if option.ParaLogo then
  2822. option.writelogo;
  2823. { Check file to compile }
  2824. if param_file='' then
  2825. begin
  2826. Message(option_no_source_found);
  2827. StopOptions(1);
  2828. end;
  2829. {$ifndef Unix}
  2830. param_file:=FixFileName(param_file);
  2831. {$endif not unix}
  2832. inputfilepath:=ExtractFilePath(param_file);
  2833. inputfilename:=ExtractFileName(param_file);
  2834. if ExtractFileExt(inputfilename)='' then
  2835. begin
  2836. if FileExists(inputfilepath+ChangeFileExt(inputfilename,sourceext)) then
  2837. inputfilename:=ChangeFileExt(inputfilename,sourceext)
  2838. else if FileExists(inputfilepath+ChangeFileExt(inputfilename,pasext)) then
  2839. inputfilename:=ChangeFileExt(inputfilename,pasext)
  2840. else if ((m_mac in current_settings.modeswitches) or
  2841. (tf_p_ext_support in target_info.flags))
  2842. and FileExists(inputfilepath+ChangeFileExt(inputfilename,pext)) then
  2843. inputfilename:=ChangeFileExt(inputfilename,pext);
  2844. end;
  2845. { Check output dir }
  2846. if (OutputExeDir<>'') and
  2847. not PathExists(OutputExeDir,false) then
  2848. begin
  2849. Message1(general_e_path_does_not_exist,OutputExeDir);
  2850. StopOptions(1);
  2851. end;
  2852. { Add paths specified with parameters to the searchpaths }
  2853. UnitSearchPath.AddList(option.ParaUnitPath,true);
  2854. ObjectSearchPath.AddList(option.ParaObjectPath,true);
  2855. IncludeSearchPath.AddList(option.ParaIncludePath,true);
  2856. LibrarySearchPath.AddList(option.ParaLibraryPath,true);
  2857. FrameworkSearchPath.AddList(option.ParaFrameworkPath,true);
  2858. { add unit environment and exepath to the unit search path }
  2859. if inputfilepath<>'' then
  2860. Unitsearchpath.AddPath(inputfilepath,true);
  2861. if not disable_configfile then
  2862. begin
  2863. env:=GetEnvironmentVariable(target_info.unit_env);
  2864. if env<>'' then
  2865. UnitSearchPath.AddPath(GetEnvironmentVariable(target_info.unit_env),false);
  2866. end;
  2867. {$ifdef Unix}
  2868. fpcdir:=FixPath(GetEnvironmentVariable('FPCDIR'),false);
  2869. if fpcdir='' then
  2870. begin
  2871. if PathExists('/usr/local/lib/fpc/'+version_string,true) then
  2872. fpcdir:='/usr/local/lib/fpc/'+version_string+'/'
  2873. else
  2874. fpcdir:='/usr/lib/fpc/'+version_string+'/';
  2875. end;
  2876. {$else unix}
  2877. fpcdir:=FixPath(GetEnvironmentVariable('FPCDIR'),false);
  2878. if fpcdir='' then
  2879. begin
  2880. fpcdir:=ExePath+'../';
  2881. if not(PathExists(fpcdir+'units',true)) and
  2882. not(PathExists(fpcdir+'rtl',true)) then
  2883. fpcdir:=fpcdir+'../';
  2884. end;
  2885. {$endif unix}
  2886. { first try development RTL, else use the default installation path }
  2887. if not disable_configfile then
  2888. begin
  2889. if PathExists(FpcDir+'rtl',true) then
  2890. if tf_use_8_3 in Source_Info.Flags then
  2891. UnitSearchPath.AddPath(FpcDir+'rtl/'+target_os_string,false)
  2892. else
  2893. UnitSearchPath.AddPath(FpcDir+'rtl/'+target_full_string,false)
  2894. else
  2895. if tf_use_8_3 in Source_Info.Flags then
  2896. UnitSearchPath.AddPath(FpcDir+'units/'+target_os_string+'/rtl',false)
  2897. else
  2898. UnitSearchPath.AddPath(FpcDir+'units/'+target_full_string+'/rtl',false);
  2899. end;
  2900. { Add exepath if the exe is not in the current dir, because that is always searched already.
  2901. Do not add it when linking on the target because then we can maybe already find
  2902. .o files that are not for the target }
  2903. if (ExePath<>GetCurrentDir) and
  2904. not(cs_link_on_target in init_settings.globalswitches) then
  2905. UnitSearchPath.AddPath(ExePath,false);
  2906. { Add unit dir to the object and library path }
  2907. objectsearchpath.AddList(unitsearchpath,false);
  2908. librarysearchpath.AddList(unitsearchpath,false);
  2909. { maybe override assembler }
  2910. if (paratargetasm<>as_none) then
  2911. begin
  2912. if not set_target_asm(paratargetasm) then
  2913. begin
  2914. Message2(option_incompatible_asm,asminfos[paratargetasm]^.idtxt,target_info.name);
  2915. set_target_asm(target_info.assemextern);
  2916. Message1(option_asm_forced,target_asm.idtxt);
  2917. end;
  2918. if (af_no_debug in asminfos[paratargetasm]^.flags) and
  2919. (paratargetdbg<>dbg_none) then
  2920. begin
  2921. Message1(option_confict_asm_debug,
  2922. asminfos[paratargetasm]^.idtxt);
  2923. paratargetdbg:=dbg_none;
  2924. exclude(init_settings.moduleswitches,cs_debuginfo);
  2925. end;
  2926. end;
  2927. {TOptionheck a second time as we might have changed assembler just above }
  2928. option.checkoptionscompatibility;
  2929. { maybe override debug info format }
  2930. if (paratargetdbg<>dbg_none) then
  2931. set_target_dbg(paratargetdbg);
  2932. { switch assembler if it's binary and we got -a on the cmdline }
  2933. if (cs_asm_leave in init_settings.globalswitches) and
  2934. (af_outputbinary in target_asm.flags) then
  2935. begin
  2936. Message(option_switch_bin_to_src_assembler);
  2937. set_target_asm(target_info.assemextern);
  2938. end;
  2939. { Force use of external linker if there is no
  2940. internal linker or the linking is skipped }
  2941. if not(cs_link_extern in init_settings.globalswitches) and
  2942. (not assigned(target_info.link) or
  2943. (cs_link_nolink in init_settings.globalswitches)) then
  2944. include(init_settings.globalswitches,cs_link_extern);
  2945. { turn off stripping if compiling with debuginfo or profile }
  2946. if (
  2947. (cs_debuginfo in init_settings.moduleswitches) or
  2948. (cs_profile in init_settings.moduleswitches)
  2949. ) and
  2950. not(cs_link_separate_dbg_file in init_settings.globalswitches) then
  2951. exclude(init_settings.globalswitches,cs_link_strip);
  2952. { set Mac OS X version default macros if not specified explicitly }
  2953. option.MaybeSetDefaultMacVersionMacro;
  2954. { force fpu emulation on arm/wince, arm/gba, arm/embedded, arm/nds and
  2955. arm/darwin if fpu type not explicitly set }
  2956. if not(option.FPUSetExplicitly) and
  2957. ((target_info.system in [system_arm_wince,system_arm_gba,system_m68k_amiga,
  2958. system_m68k_linux,system_arm_nds,system_arm_embedded,system_arm_darwin])
  2959. {$ifdef arm}
  2960. or (target_info.abi=abi_eabi)
  2961. {$endif arm}
  2962. )
  2963. {$ifdef arm}
  2964. or (init_settings.fputype=fpu_soft)
  2965. {$endif arm}
  2966. then
  2967. begin
  2968. {$ifdef cpufpemu}
  2969. include(init_settings.moduleswitches,cs_fp_emulation);
  2970. { cs_fp_emulation and fpu_soft are equal on arm }
  2971. init_settings.fputype:=fpu_soft;
  2972. {$endif cpufpemu}
  2973. end;
  2974. {$ifdef arm}
  2975. if target_info.abi = abi_eabihf then
  2976. begin
  2977. if not(option.FPUSetExplicitly) then
  2978. begin
  2979. init_settings.fputype:=fpu_vfpv3_d16
  2980. end
  2981. else
  2982. begin
  2983. if not (init_settings.fputype in [fpu_vfpv2,fpu_vfpv3,fpu_vfpv3_d16]) then
  2984. begin
  2985. Message(option_illegal_fpu_eabihf);
  2986. StopOptions(1);
  2987. end;
  2988. end;
  2989. end;
  2990. {$endif arm}
  2991. {$ifdef arm}
  2992. { set default cpu type to ARMv6 for Darwin unless specified otherwise }
  2993. if (target_info.system=system_arm_darwin) then
  2994. begin
  2995. if not option.CPUSetExplicitly then
  2996. init_settings.cputype:=cpu_armv6;
  2997. if not option.OptCPUSetExplicitly then
  2998. init_settings.optimizecputype:=cpu_armv6;
  2999. end;
  3000. { set default cpu type to ARMv7 for ARMHF unless specified otherwise }
  3001. if (target_info.abi = abi_eabihf) then
  3002. begin
  3003. if not option.CPUSetExplicitly then
  3004. init_settings.cputype:=cpu_armv7;
  3005. if not option.OptCPUSetExplicitly then
  3006. init_settings.optimizecputype:=cpu_armv7;
  3007. end;
  3008. {$endif arm}
  3009. {$ifdef jvm}
  3010. { set default CPU type to Dalvik when targeting Android }
  3011. if target_info.system=system_jvm_android32 then
  3012. begin
  3013. if not option.CPUSetExplicitly then
  3014. init_settings.cputype:=cpu_dalvik;
  3015. end;
  3016. {$endif jvm}
  3017. { now we can define cpu and fpu type }
  3018. def_system_macro('CPU'+Cputypestr[init_settings.cputype]);
  3019. def_system_macro('FPU'+fputypestr[init_settings.fputype]);
  3020. if init_settings.fputype<>fpu_none then
  3021. begin
  3022. {$if defined(i386)}
  3023. def_system_macro('FPC_HAS_TYPE_EXTENDED');
  3024. {$endif}
  3025. def_system_macro('FPC_HAS_TYPE_SINGLE');
  3026. def_system_macro('FPC_HAS_TYPE_DOUBLE');
  3027. {$if not defined(i386) and not defined(x86_64)}
  3028. def_system_macro('FPC_INCLUDE_SOFTWARE_INT64_TO_DOUBLE');
  3029. {$endif}
  3030. {$ifdef x86_64}
  3031. { win64 doesn't support the legacy fpu }
  3032. if target_info.system=system_x86_64_win64 then
  3033. undef_system_macro('FPC_HAS_TYPE_EXTENDED')
  3034. else
  3035. def_system_macro('FPC_HAS_TYPE_EXTENDED');
  3036. {$endif}
  3037. end;
  3038. { Enable now for testing }
  3039. {$ifndef DISABLE_TLS_DIRECTORY}
  3040. if target_info.system in systems_windows then
  3041. def_system_macro('FPC_USE_TLS_DIRECTORY');
  3042. {$endif not DISABLE_TLS_DIRECTORY}
  3043. {$ifdef TEST_WIN64_SEH}
  3044. if target_info.system=system_x86_64_win64 then
  3045. def_system_macro('FPC_USE_WIN64_SEH');
  3046. {$endif TEST_WIN64_SEH}
  3047. {$ifdef ARM}
  3048. { define FPC_DOUBLE_HILO_SWAPPED if needed to properly handle doubles in RTL }
  3049. if (init_settings.fputype in [fpu_fpa,fpu_fpa10,fpu_fpa11]) and
  3050. not(cs_fp_emulation in init_settings.moduleswitches) then
  3051. def_system_macro('FPC_DOUBLE_HILO_SWAPPED');
  3052. {$endif ARM}
  3053. { Section smartlinking conflicts with import sections on Windows }
  3054. if GenerateImportSection and
  3055. (target_info.system in [system_i386_win32,system_x86_64_win64]) then
  3056. exclude(target_info.flags,tf_smartlink_sections);
  3057. if not LinkTypeSetExplicitly then
  3058. set_default_link_type;
  3059. { Default alignment settings,
  3060. 1. load the defaults for the target
  3061. 2. override with generic optimizer setting (little size)
  3062. 3. override with the user specified -Oa }
  3063. UpdateAlignment(init_settings.alignment,target_info.alignment);
  3064. if (cs_opt_size in current_settings.optimizerswitches) then
  3065. begin
  3066. init_settings.alignment.procalign:=1;
  3067. init_settings.alignment.jumpalign:=1;
  3068. init_settings.alignment.loopalign:=1;
  3069. end;
  3070. UpdateAlignment(init_settings.alignment,option.paraalignment);
  3071. set_system_macro('FPC_VERSION',version_nr);
  3072. set_system_macro('FPC_RELEASE',release_nr);
  3073. set_system_macro('FPC_PATCH',patch_nr);
  3074. set_system_macro('FPC_FULLVERSION',Format('%d%.02d%.02d',[StrToInt(version_nr),StrToInt(release_nr),StrToInt(patch_nr)]));
  3075. if not(target_info.system in systems_windows) then
  3076. def_system_macro('FPC_WIDESTRING_EQUAL_UNICODESTRING');
  3077. for i:=low(tfeature) to high(tfeature) do
  3078. if i in features then
  3079. def_system_macro('FPC_HAS_FEATURE_'+featurestr[i]);
  3080. option.free;
  3081. Option:=nil;
  3082. clearstack_pocalls := [pocall_cdecl,pocall_cppdecl,pocall_syscall,pocall_mwpascal];
  3083. cdecl_pocalls := [pocall_cdecl, pocall_cppdecl];
  3084. if (tf_safecall_clearstack in target_info.flags) then
  3085. begin
  3086. include (cdecl_pocalls, pocall_safecall);
  3087. include (clearstack_pocalls, pocall_safecall)
  3088. end;
  3089. end;
  3090. initialization
  3091. coption:=toption;
  3092. finalization
  3093. if assigned(option) then
  3094. option.free;
  3095. end.