options.pas 88 KB

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