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