options.pas 89 KB

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