options.pas 63 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153
  1. {
  2. Copyright (c) 1998-2002 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. globtype,globals,verbose,systems,cpuinfo;
  22. type
  23. TOption=class
  24. FirstPass,
  25. ParaLogo,
  26. NoPressEnter,
  27. LogoWritten : boolean;
  28. FileLevel : longint;
  29. QuickInfo : string;
  30. ParaIncludePath,
  31. ParaUnitPath,
  32. ParaObjectPath,
  33. ParaLibraryPath : TSearchPathList;
  34. ParaAlignment : TAlignmentInfo;
  35. Constructor Create;
  36. Destructor Destroy;override;
  37. procedure WriteLogo;
  38. procedure WriteInfo;
  39. procedure WriteHelpPages;
  40. procedure WriteQuickInfo;
  41. procedure IllegalPara(const opt:string);
  42. function Unsetbool(var Opts:string; Pos: Longint):boolean;
  43. procedure interpret_proc_specific_options(const opt:string);virtual;
  44. procedure interpret_option(const opt :string;ispara:boolean);
  45. procedure Interpret_envvar(const envname : string);
  46. procedure Interpret_file(const filename : string);
  47. procedure Read_Parameters;
  48. procedure parsecmd(cmd:string);
  49. procedure TargetDefines(def:boolean);
  50. end;
  51. TOptionClass=class of toption;
  52. var
  53. coption : TOptionClass;
  54. procedure read_arguments(cmd:string);
  55. implementation
  56. uses
  57. widestr,
  58. {$IFDEF USE_SYSUTILS}
  59. SysUtils,
  60. {$ELSE USE_SYSUTILS}
  61. dos,
  62. {$ENDIF USE_SYSUTILS}
  63. version,
  64. cutils,cmsgs,
  65. comphook,
  66. symtable
  67. {$ifdef BrowserLog}
  68. ,browlog
  69. {$endif BrowserLog}
  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,
  77. target_is_set : boolean; { do not allow contradictory target settings }
  78. asm_is_set : boolean; { -T also change initoutputformat if not set idrectly }
  79. fpcdir,
  80. ppccfg,
  81. ppcaltcfg,
  82. param_file : string; { file to compile specified on the commandline }
  83. {****************************************************************************
  84. Defines
  85. ****************************************************************************}
  86. procedure set_default_link_type;
  87. begin
  88. { win32 and wdosx need smartlinking by default to prevent including too much
  89. dll dependencies }
  90. if (target_info.system in [system_i386_win32,system_i386_wdosx]) then
  91. begin
  92. def_system_macro('FPC_LINK_SMART');
  93. undef_system_macro('FPC_LINK_STATIC');
  94. undef_system_macro('FPC_LINK_DYNAMIC');
  95. initglobalswitches:=initglobalswitches+[cs_link_smart];
  96. initglobalswitches:=initglobalswitches-[cs_link_shared,cs_link_static];
  97. end
  98. else
  99. begin
  100. undef_system_macro('FPC_LINK_SMART');
  101. def_system_macro('FPC_LINK_STATIC');
  102. undef_system_macro('FPC_LINK_DYNAMIC');
  103. initglobalswitches:=initglobalswitches+[cs_link_static];
  104. initglobalswitches:=initglobalswitches-[cs_link_shared,cs_link_smart];
  105. end;
  106. end;
  107. {****************************************************************************
  108. Toption
  109. ****************************************************************************}
  110. procedure StopOptions(err:longint);
  111. begin
  112. if assigned(Option) then
  113. begin
  114. Option.free;
  115. Option:=nil;
  116. end;
  117. raise ECompilerAbortSilent.Create;
  118. end;
  119. procedure Toption.WriteLogo;
  120. var
  121. p : pchar;
  122. begin
  123. if not LogoWritten then
  124. begin
  125. p:=MessagePchar(option_logo);
  126. while assigned(p) do
  127. Comment(V_Normal,GetMsgLine(p));
  128. LogoWritten:= true;
  129. end;
  130. end;
  131. procedure Toption.WriteInfo;
  132. var
  133. p : pchar;
  134. hs,hs1,s : TCmdStr;
  135. target : tsystem;
  136. cpu : tprocessors;
  137. fpu : tfputype;
  138. begin
  139. p:=MessagePchar(option_info);
  140. while assigned(p) do
  141. begin
  142. s:=GetMsgLine(p);
  143. { list OS Targets }
  144. if pos('$OSTARGETS',s)>0 then
  145. begin
  146. for target:=low(tsystem) to high(tsystem) do
  147. if assigned(targetinfos[target]) then
  148. begin
  149. hs:=s;
  150. hs1:=targetinfos[target]^.name;
  151. if tf_under_development in targetinfos[target]^.flags then
  152. hs1:=hs1+' (under development)';
  153. Replace(hs,'$OSTARGETS',hs1);
  154. Comment(V_Normal,hs);
  155. end;
  156. end
  157. else if pos('$INSTRUCTIONSETS',s)>0 then
  158. begin
  159. for cpu:=low(tprocessors) to high(tprocessors) do
  160. begin
  161. hs:=s;
  162. hs1:=processorsstr[cpu];
  163. if hs1<>'' then
  164. begin
  165. Replace(hs,'$INSTRUCTIONSETS',hs1);
  166. Comment(V_Normal,hs);
  167. end;
  168. end;
  169. end
  170. else if pos('$FPUINSTRUCTIONSETS',s)>0 then
  171. begin
  172. for fpu:=low(tfputype) to high(tfputype) do
  173. begin
  174. hs:=s;
  175. hs1:=fputypestr[fpu];
  176. if hs1<>'' then
  177. begin
  178. Replace(hs,'$FPUINSTRUCTIONSETS',hs1);
  179. Comment(V_Normal,hs);
  180. end;
  181. end;
  182. end
  183. else
  184. Comment(V_Normal,s);
  185. end;
  186. StopOptions(0);
  187. end;
  188. procedure Toption.WriteHelpPages;
  189. function PadEnd(s:string;i:longint):string;
  190. begin
  191. while (length(s)<i) do
  192. s:=s+' ';
  193. PadEnd:=s;
  194. end;
  195. var
  196. lastident,
  197. j,outline,
  198. ident,
  199. lines : longint;
  200. show : boolean;
  201. opt : string[32];
  202. input,
  203. s : string;
  204. p : pchar;
  205. begin
  206. WriteLogo;
  207. Lines:=4;
  208. Message1(option_usage,FixFileName(system.paramstr(0)));
  209. lastident:=0;
  210. p:=MessagePChar(option_help_pages);
  211. while assigned(p) do
  212. begin
  213. { get a line and reset }
  214. s:=GetMsgLine(p);
  215. ident:=0;
  216. show:=false;
  217. { parse options }
  218. case s[1] of
  219. {$ifdef UNITALIASES}
  220. 'a',
  221. {$endif}
  222. {$ifdef EXTDEBUG}
  223. 'e',
  224. {$endif EXTDEBUG}
  225. {$ifdef i386}
  226. '3',
  227. {$endif}
  228. {$ifdef x86_64}
  229. '4',
  230. {$endif}
  231. {$ifdef m68k}
  232. '6',
  233. {$endif}
  234. {$ifdef arm}
  235. 'A',
  236. {$endif}
  237. {$ifdef powerpc}
  238. 'P',
  239. {$endif}
  240. {$ifdef sparc}
  241. 'S',
  242. {$endif}
  243. {$ifdef vis}
  244. 'V',
  245. {$endif}
  246. '*' : show:=true;
  247. end;
  248. if show then
  249. begin
  250. case s[2] of
  251. {$ifdef GDB}
  252. 'g',
  253. {$endif}
  254. {$ifdef Unix}
  255. 'L',
  256. {$endif}
  257. {$ifdef os2}
  258. 'O',
  259. {$endif}
  260. '*' : show:=true;
  261. else
  262. show:=false;
  263. end;
  264. end;
  265. { now we may show the message or not }
  266. if show then
  267. begin
  268. case s[3] of
  269. '0' : begin
  270. ident:=0;
  271. outline:=0;
  272. end;
  273. '1' : begin
  274. ident:=2;
  275. outline:=7;
  276. end;
  277. '2' : begin
  278. ident:=6;
  279. outline:=11;
  280. end;
  281. '3' : begin
  282. ident:=9;
  283. outline:=11;
  284. end;
  285. end;
  286. j:=pos('_',s);
  287. opt:=Copy(s,4,j-4);
  288. if opt='*' then
  289. opt:=''
  290. else
  291. if opt=' ' then
  292. opt:=PadEnd(opt,outline)
  293. else
  294. opt:=PadEnd('-'+opt,outline);
  295. if (ident=0) and (lastident<>0) then
  296. begin
  297. Comment(V_Normal,'');
  298. inc(Lines);
  299. end;
  300. { page full ? }
  301. if (lines >= page_size - 1) then
  302. begin
  303. if not NoPressEnter then
  304. begin
  305. Message(option_help_press_enter);
  306. readln(input);
  307. if upper(input)='Q' then
  308. StopOptions(0);
  309. end;
  310. lines:=0;
  311. end;
  312. Comment(V_Normal,PadEnd('',ident)+opt+Copy(s,j+1,255));
  313. LastIdent:=Ident;
  314. inc(Lines);
  315. end;
  316. end;
  317. StopOptions(0);
  318. end;
  319. procedure Toption.IllegalPara(const opt:string);
  320. begin
  321. Message1(option_illegal_para,opt);
  322. Message(option_help_pages_para);
  323. StopOptions(1);
  324. end;
  325. function Toption.Unsetbool(var Opts:string; Pos: Longint):boolean;
  326. { checks if the character after pos in Opts is a + or a - and returns resp.
  327. false or true. If it is another character (or none), it also returns false }
  328. begin
  329. UnsetBool := false;
  330. if Length(Opts)>Pos then
  331. begin
  332. inc(Pos);
  333. UnsetBool := Opts[Pos] = '-';
  334. if Opts[Pos] in ['-','+']then
  335. delete(Opts,Pos,1);
  336. end;
  337. end;
  338. procedure TOption.interpret_proc_specific_options(const opt:string);
  339. begin
  340. end;
  341. procedure TOption.interpret_option(const opt:string;ispara:boolean);
  342. var
  343. code : integer;
  344. c : char;
  345. more : string;
  346. major,minor : longint;
  347. error : integer;
  348. j,l : longint;
  349. d : DirStr;
  350. e : ExtStr;
  351. s : string;
  352. forceasm : tasm;
  353. begin
  354. if opt='' then
  355. exit;
  356. { only parse define,undef,target,verbosity,link etc options the firsttime }
  357. if firstpass and
  358. not(
  359. (opt[1]='-') and
  360. (
  361. ((length(opt)>1) and (opt[2] in ['i','d','v','T','u','n','X','l'])) or
  362. ((length(opt)>3) and (opt[2]='F') and (opt[3]='e'))
  363. )
  364. ) then
  365. exit;
  366. Message1(option_handling_option,opt);
  367. case opt[1] of
  368. '-' :
  369. begin
  370. more:=Copy(opt,3,255);
  371. if firstpass then
  372. Message1(option_interpreting_firstpass_option,opt)
  373. else
  374. Message1(option_interpreting_option,opt);
  375. case opt[2] of
  376. '?' :
  377. WriteHelpPages;
  378. 'a' :
  379. begin
  380. include(initglobalswitches,cs_asm_leave);
  381. j:=1;
  382. while j<=length(more) do
  383. begin
  384. case more[j] of
  385. 'l' :
  386. include(initglobalswitches,cs_asm_source);
  387. 'r' :
  388. include(initglobalswitches,cs_asm_regalloc);
  389. 't' :
  390. include(initglobalswitches,cs_asm_tempalloc);
  391. 'n' :
  392. include(initglobalswitches,cs_asm_nodes);
  393. 'p' :
  394. begin
  395. exclude(initglobalswitches,cs_asm_leave);
  396. if UnsetBool(More, 0) then
  397. exclude(initglobalswitches,cs_asm_pipe)
  398. else
  399. include(initglobalswitches,cs_asm_pipe);
  400. end;
  401. '-' :
  402. initglobalswitches:=initglobalswitches -
  403. [cs_asm_leave, cs_asm_source,cs_asm_regalloc, cs_asm_tempalloc,
  404. cs_asm_nodes, cs_asm_pipe];
  405. else
  406. IllegalPara(opt);
  407. end;
  408. inc(j);
  409. end;
  410. end;
  411. 'A' :
  412. begin
  413. if set_target_asm_by_string(More) then
  414. asm_is_set:=true
  415. else
  416. IllegalPara(opt);
  417. end;
  418. 'b' :
  419. begin
  420. {$ifdef supportbrowser}
  421. if UnsetBool(More,0) then
  422. begin
  423. exclude(initmoduleswitches,cs_browser);
  424. exclude(initmoduleswitches,cs_local_browser);
  425. {$ifdef BrowserLog}
  426. exclude(initglobalswitches,cs_browser_log);
  427. {$endif}
  428. end
  429. else
  430. begin
  431. include(initmoduleswitches,cs_browser);
  432. {$ifdef BrowserLog}
  433. include(initglobalswitches,cs_browser_log);
  434. {$endif}
  435. end;
  436. if More<>'' then
  437. if (More='l') or (More='l+') then
  438. include(initmoduleswitches,cs_local_browser)
  439. else
  440. if More='l-' then
  441. exclude(initmoduleswitches,cs_local_browser)
  442. else
  443. {$ifdef BrowserLog}
  444. browserlog.elements_to_list.insert(more);
  445. {$else}
  446. IllegalPara(opt);
  447. {$endif}
  448. {$endif supportbrowser}
  449. end;
  450. 'B' :
  451. do_build:=not UnSetBool(more,0);
  452. 'C' :
  453. begin
  454. j:=1;
  455. while j<=length(more) do
  456. begin
  457. case more[j] of
  458. 'a' :
  459. Message2(option_obsolete_switch_use_new,'-Ca','-Or');
  460. 'c' :
  461. begin
  462. if not SetAktProcCall(upper(copy(more,j+1,length(more)-j)),true) then
  463. IllegalPara(opt);
  464. break;
  465. end;
  466. {$ifdef cpufpemu}
  467. 'e' :
  468. begin
  469. If UnsetBool(More, j) then
  470. exclude(initmoduleswitches,cs_fp_emulation)
  471. Else
  472. include(initmoduleswitches,cs_fp_emulation);
  473. end;
  474. {$endif cpufpemu}
  475. 'f' :
  476. begin
  477. s:=upper(copy(more,j+1,length(more)-j));
  478. if not(SetFpuType(s,true)) then
  479. IllegalPara(opt);
  480. break;
  481. end;
  482. 'g' :
  483. include(initmoduleswitches,cs_create_pic);
  484. 'h' :
  485. begin
  486. val(copy(more,j+1,length(more)-j),heapsize,code);
  487. if (code<>0) or (heapsize<1024) then
  488. IllegalPara(opt);
  489. break;
  490. end;
  491. 'i' :
  492. If UnsetBool(More, j) then
  493. exclude(initlocalswitches,cs_check_io)
  494. else
  495. include(initlocalswitches,cs_check_io);
  496. 'n' :
  497. If UnsetBool(More, j) then
  498. exclude(initglobalswitches,cs_link_extern)
  499. Else
  500. include(initglobalswitches,cs_link_extern);
  501. 'o' :
  502. If UnsetBool(More, j) then
  503. exclude(initlocalswitches,cs_check_overflow)
  504. Else
  505. include(initlocalswitches,cs_check_overflow);
  506. 'p' :
  507. begin
  508. s:=upper(copy(more,j+1,length(more)-j));
  509. if not(SetProcessor(s,true)) then
  510. IllegalPara(opt);
  511. break;
  512. end;
  513. 'r' :
  514. If UnsetBool(More, j) then
  515. exclude(initlocalswitches,cs_check_range)
  516. Else
  517. include(initlocalswitches,cs_check_range);
  518. 'R' :
  519. If UnsetBool(More, j) then
  520. begin
  521. exclude(initlocalswitches,cs_check_range);
  522. exclude(initlocalswitches,cs_check_object);
  523. end
  524. Else
  525. begin
  526. include(initlocalswitches,cs_check_range);
  527. include(initlocalswitches,cs_check_object);
  528. end;
  529. 's' :
  530. begin
  531. val(copy(more,j+1,length(more)-j),stacksize,code);
  532. if (code<>0) or (stacksize>=67107840) or (stacksize<1024) then
  533. IllegalPara(opt);
  534. break;
  535. end;
  536. 't' :
  537. If UnsetBool(More, j) then
  538. exclude(initlocalswitches,cs_check_stack)
  539. Else
  540. include(initlocalswitches,cs_check_stack);
  541. 'D' :
  542. If UnsetBool(More, j) then
  543. exclude(initmoduleswitches,cs_create_dynamic)
  544. Else
  545. include(initmoduleswitches,cs_create_dynamic);
  546. 'X' :
  547. If UnsetBool(More, j) then
  548. exclude(initmoduleswitches,cs_create_smart)
  549. Else
  550. include(initmoduleswitches,cs_create_smart);
  551. else
  552. IllegalPara(opt);
  553. end;
  554. inc(j);
  555. end;
  556. end;
  557. 'd' :
  558. if more <> '' then
  559. begin
  560. l:=Pos(':=',more);
  561. if l>0 then
  562. set_system_compvar(Copy(more,1,l-1),Copy(more,l+2,255))
  563. else
  564. def_system_macro(more);
  565. end;
  566. 'D' :
  567. begin
  568. include(initglobalswitches,cs_link_deffile);
  569. j:=1;
  570. while j<=length(more) do
  571. begin
  572. case more[j] of
  573. 'd' :
  574. begin
  575. description:=Copy(more,j+1,255);
  576. break;
  577. end;
  578. 'v' :
  579. begin
  580. dllversion:=Copy(more,j+1,255);
  581. l:=pos('.',dllversion);
  582. dllminor:=0;
  583. error:=0;
  584. if l>0 then
  585. begin
  586. val(copy(dllversion,l+1,255),minor,error);
  587. if (error=0) and
  588. (minor>=0) and (minor<=$ffff) then
  589. dllminor:=minor
  590. else
  591. if error=0 then
  592. error:=1;
  593. end;
  594. if l=0 then
  595. l:=256;
  596. dllmajor:=1;
  597. if error=0 then
  598. val(copy(dllversion,1,l-1),major,error);
  599. if (error=0) and (major>=0) and (major<=$ffff) then
  600. dllmajor:=major
  601. else
  602. if error=0 then
  603. error:=1;
  604. if error<>0 then
  605. Message1(scan_w_wrong_version_ignored,dllversion);
  606. break;
  607. end;
  608. 'w' :
  609. usewindowapi:=true;
  610. '-' :
  611. begin
  612. exclude(initglobalswitches,cs_link_deffile);
  613. usewindowapi:=false;
  614. end;
  615. else
  616. IllegalPara(opt);
  617. end;
  618. inc(j);
  619. end;
  620. end;
  621. 'e' :
  622. exepath:=FixPath(More,true);
  623. 'E' :
  624. begin
  625. if UnsetBool(More, 0) then
  626. exclude(initglobalswitches,cs_link_extern)
  627. else
  628. include(initglobalswitches,cs_link_extern);
  629. end;
  630. 'F' :
  631. begin
  632. c:=more[1];
  633. Delete(more,1,1);
  634. DefaultReplacements(More);
  635. case c of
  636. 'a' :
  637. autoloadunits:=more;
  638. 'c' :
  639. begin
  640. if (upper(more)='UTF8') or (upper(more)='UTF-8') then
  641. initsourcecodepage:='utf8'
  642. else if not(cpavailable(more)) then
  643. Message1(option_code_page_not_available,more)
  644. else
  645. initsourcecodepage:=more;
  646. end;
  647. 'D' :
  648. utilsdirectory:=FixPath(More,true);
  649. 'e' :
  650. SetRedirectFile(More);
  651. 'E' :
  652. OutputExeDir:=FixPath(More,true);
  653. 'i' :
  654. begin
  655. if ispara then
  656. ParaIncludePath.AddPath(More,false)
  657. else
  658. includesearchpath.AddPath(More,true);
  659. end;
  660. 'g' :
  661. Message2(option_obsolete_switch_use_new,'-Fg','-Fl');
  662. 'l' :
  663. begin
  664. if ispara then
  665. ParaLibraryPath.AddPath(More,false)
  666. else
  667. LibrarySearchPath.AddPath(More,true);
  668. end;
  669. 'L' :
  670. begin
  671. if More<>'' then
  672. ParaDynamicLinker:=More
  673. else
  674. IllegalPara(opt);
  675. end;
  676. 'o' :
  677. begin
  678. if ispara then
  679. ParaObjectPath.AddPath(More,false)
  680. else
  681. ObjectSearchPath.AddPath(More,true);
  682. end;
  683. 'r' :
  684. Msgfilename:=More;
  685. 'u' :
  686. begin
  687. if ispara then
  688. ParaUnitPath.AddPath(More,false)
  689. else
  690. unitsearchpath.AddPath(More,true);
  691. end;
  692. 'U' :
  693. OutputUnitDir:=FixPath(More,true);
  694. else
  695. IllegalPara(opt);
  696. end;
  697. end;
  698. 'g' : begin
  699. if UnsetBool(More, 0) then
  700. begin
  701. exclude(initmoduleswitches,cs_debuginfo);
  702. exclude(initglobalswitches,cs_gdb_dbx);
  703. exclude(initglobalswitches,cs_gdb_gsym);
  704. exclude(initglobalswitches,cs_gdb_heaptrc);
  705. exclude(initglobalswitches,cs_gdb_lineinfo);
  706. exclude(initlocalswitches,cs_checkpointer);
  707. end
  708. else
  709. begin
  710. {$ifdef GDB}
  711. include(initmoduleswitches,cs_debuginfo);
  712. {$else GDB}
  713. Message(option_no_debug_support);
  714. Message(option_no_debug_support_recompile_fpc);
  715. {$endif GDB}
  716. end;
  717. {$ifdef GDB}
  718. if not RelocSectionSetExplicitly then
  719. RelocSection:=false;
  720. j:=1;
  721. while j<=length(more) do
  722. begin
  723. case more[j] of
  724. 'd' :
  725. begin
  726. if UnsetBool(More, j) then
  727. exclude(initglobalswitches,cs_gdb_dbx)
  728. else
  729. include(initglobalswitches,cs_gdb_dbx);
  730. end;
  731. 'g' :
  732. begin
  733. if UnsetBool(More, j) then
  734. exclude(initglobalswitches,cs_gdb_gsym)
  735. else
  736. include(initglobalswitches,cs_gdb_gsym);
  737. end;
  738. 'h' :
  739. begin
  740. if UnsetBool(More, j) then
  741. exclude(initglobalswitches,cs_gdb_heaptrc)
  742. else
  743. include(initglobalswitches,cs_gdb_heaptrc);
  744. end;
  745. 'l' :
  746. begin
  747. if UnsetBool(More, j) then
  748. exclude(initglobalswitches,cs_gdb_lineinfo)
  749. else
  750. include(initglobalswitches,cs_gdb_lineinfo);
  751. end;
  752. 'c' :
  753. begin
  754. if UnsetBool(More, j) then
  755. exclude(initlocalswitches,cs_checkpointer)
  756. else
  757. include(initlocalswitches,cs_checkpointer);
  758. end;
  759. 'v' :
  760. begin
  761. if UnsetBool(More, j) then
  762. exclude(initglobalswitches,cs_gdb_valgrind)
  763. else
  764. include(initglobalswitches,cs_gdb_valgrind);
  765. end;
  766. 'w' :
  767. begin
  768. if UnsetBool(More, j) then
  769. exclude(initglobalswitches,cs_gdb_dwarf)
  770. else
  771. include(initglobalswitches,cs_gdb_dwarf);
  772. end;
  773. else
  774. IllegalPara(opt);
  775. end;
  776. inc(j);
  777. end;
  778. {$endif GDB}
  779. end;
  780. 'h' :
  781. begin
  782. NoPressEnter:=true;
  783. WriteHelpPages;
  784. end;
  785. 'i' :
  786. begin
  787. if More='' then
  788. WriteInfo
  789. else
  790. QuickInfo:=QuickInfo+More;
  791. end;
  792. 'I' :
  793. begin
  794. if ispara then
  795. ParaIncludePath.AddPath(More,false)
  796. else
  797. includesearchpath.AddPath(More,false);
  798. end;
  799. 'k' :
  800. begin
  801. if more<>'' then
  802. ParaLinkOptions:=ParaLinkOptions+' '+More
  803. else
  804. IllegalPara(opt);
  805. end;
  806. 'l' :
  807. if not UnSetBool(more,0) then
  808. ParaLogo:=true;
  809. 'm' :
  810. parapreprocess:=not UnSetBool(more,0);
  811. 'M' :
  812. begin
  813. more:=Upper(more);
  814. if not SetCompileMode(more, true) then
  815. IllegalPara(opt);
  816. end;
  817. 'n' :
  818. begin
  819. if More='' then
  820. disable_configfile:=true
  821. else
  822. IllegalPara(opt);
  823. end;
  824. 'N' :
  825. begin
  826. j:=1;
  827. while j<=length(more) do
  828. begin
  829. case more[j] of
  830. 'u' :
  831. initglobalswitches:=initglobalswitches+[cs_loopunroll];
  832. else
  833. IllegalPara(opt);
  834. end;
  835. inc(j);
  836. end;
  837. end;
  838. 'o' :
  839. begin
  840. if More<>'' then
  841. {$IFDEF USE_SYSUTILS}
  842. begin
  843. d := SplitPath(More);
  844. OutputFile := SplitFileName(More);
  845. end
  846. {$ELSE USE_SYSUTILS}
  847. Fsplit(More,d,OutputFile,e)
  848. {$ENDIF USE_SYSUTILS}
  849. else
  850. IllegalPara(opt);
  851. end;
  852. 'p' :
  853. begin
  854. if UnsetBool(More, 0) then
  855. begin
  856. initmoduleswitches:=initmoduleswitches-[cs_profile];
  857. undef_system_macro('FPC_PROFILE');
  858. end
  859. else
  860. if Length(More)=0 then
  861. IllegalPara(opt)
  862. else
  863. case more[1] of
  864. 'g' : if UnsetBool(more, 1) then
  865. begin
  866. exclude(initmoduleswitches,cs_profile);
  867. undef_system_macro('FPC_PROFILE');
  868. end
  869. else
  870. begin
  871. include(initmoduleswitches,cs_profile);
  872. def_system_macro('FPC_PROFILE');
  873. end;
  874. else
  875. IllegalPara(opt);
  876. end;
  877. end;
  878. 'P' : ; { Ignore used by fpc.pp }
  879. 's' :
  880. begin
  881. if UnsetBool(More, 0) then
  882. begin
  883. initglobalswitches:=initglobalswitches-[cs_asm_extern,cs_link_extern];
  884. if more<>'' then
  885. IllegalPara(opt);
  886. end
  887. else
  888. begin
  889. initglobalswitches:=initglobalswitches+[cs_asm_extern,cs_link_extern];
  890. if more='h' then
  891. initglobalswitches:=initglobalswitches-[cs_link_on_target]
  892. else if more='t' then
  893. initglobalswitches:=initglobalswitches+[cs_link_on_target]
  894. else if more='r' then
  895. initglobalswitches:=initglobalswitches+[cs_asm_leave,cs_no_regalloc]
  896. else if more<>'' then
  897. IllegalPara(opt);
  898. end;
  899. end;
  900. 'S' :
  901. begin
  902. if more[1]='I' then
  903. begin
  904. if upper(more)='ICOM' then
  905. initinterfacetype:=it_interfacecom
  906. else if upper(more)='ICORBA' then
  907. initinterfacetype:=it_interfacecorba
  908. else
  909. IllegalPara(opt);
  910. end
  911. else
  912. begin
  913. j:=1;
  914. while j<=length(more) do
  915. begin
  916. case more[j] of
  917. '2' : //an alternative to -Mobjfpc
  918. SetCompileMode('OBJFPC',true);
  919. 'a' :
  920. include(initlocalswitches,cs_do_assertion);
  921. 'c' :
  922. include(initmoduleswitches,cs_support_c_operators);
  923. 'd' : //an alternative to -Mdelphi
  924. SetCompileMode('DELPHI',true);
  925. 'e' :
  926. begin
  927. SetErrorFlags(copy(more,j+1,length(more)));
  928. break;
  929. end;
  930. 'g' :
  931. include(initmoduleswitches,cs_support_goto);
  932. 'h' :
  933. include(initlocalswitches,cs_ansistrings);
  934. 'i' :
  935. include(initmoduleswitches,cs_support_inline);
  936. 'k' :
  937. include(initglobalswitches,cs_load_fpcylix_unit);
  938. 'm' :
  939. include(initmoduleswitches,cs_support_macro);
  940. 'o' : //an alternative to -Mtp
  941. SetCompileMode('TP',true);
  942. 'p' : //an alternative to -Mgpc
  943. SetCompileMode('GPC',true);
  944. 's' :
  945. include(initglobalswitches,cs_constructor_name);
  946. 't' :
  947. include(initmoduleswitches,cs_static_keyword);
  948. '-' :
  949. begin
  950. exclude(initglobalswitches,cs_constructor_name);
  951. initlocalswitches:=InitLocalswitches - [cs_do_assertion, cs_ansistrings];
  952. initmoduleswitches:=initmoduleswitches - [cs_support_c_operators, cs_support_goto,
  953. cs_support_inline, cs_support_macro,
  954. cs_static_keyword];
  955. end;
  956. else
  957. IllegalPara(opt);
  958. end;
  959. inc(j);
  960. end;
  961. end;
  962. end;
  963. 'T' :
  964. begin
  965. more:=Upper(More);
  966. if not target_is_set then
  967. begin
  968. { remove old target define }
  969. TargetDefines(false);
  970. { Save assembler if set }
  971. if asm_is_set then
  972. forceasm:=target_asm.id;
  973. { load new target }
  974. if not(set_target_by_string(More)) then
  975. IllegalPara(opt);
  976. { also initialize assembler if not explicitly set }
  977. if asm_is_set then
  978. set_target_asm(forceasm);
  979. { set new define }
  980. TargetDefines(true);
  981. target_is_set:=true;
  982. end
  983. else
  984. if More<>upper(target_info.shortname) then
  985. Message1(option_target_is_already_set,target_info.shortname);
  986. end;
  987. 'u' :
  988. if more <> '' then
  989. undef_system_macro(more);
  990. 'U' :
  991. begin
  992. j:=1;
  993. while j<=length(more) do
  994. begin
  995. case more[j] of
  996. {$ifdef UNITALIASES}
  997. 'a' :
  998. begin
  999. AddUnitAlias(Copy(More,j+1,255));
  1000. break;
  1001. end;
  1002. {$endif UNITALIASES}
  1003. 'n' :
  1004. exclude(initglobalswitches,cs_check_unit_name);
  1005. 'p' :
  1006. begin
  1007. Message2(option_obsolete_switch_use_new,'-Up','-Fu');
  1008. break;
  1009. end;
  1010. 'r' :
  1011. do_release:=true;
  1012. 's' :
  1013. include(initmoduleswitches,cs_compilesystem);
  1014. '-' :
  1015. begin
  1016. exclude(initmoduleswitches,cs_compilesystem);
  1017. exclude(initglobalswitches,cs_check_unit_name);
  1018. end;
  1019. else
  1020. IllegalPara(opt);
  1021. end;
  1022. inc(j);
  1023. end;
  1024. end;
  1025. 'v' :
  1026. begin
  1027. if not setverbosity(More) then
  1028. IllegalPara(opt);
  1029. end;
  1030. 'V' : ; { Ignore used by fpc }
  1031. 'W' :
  1032. begin
  1033. j:=1;
  1034. while j<=length(More) do
  1035. begin
  1036. case More[j] of
  1037. 'A':
  1038. begin
  1039. if UnsetBool(More, j) then
  1040. apptype:=app_native
  1041. else
  1042. apptype:=app_cui;
  1043. end;
  1044. 'B':
  1045. begin
  1046. { -WB200000 means set trefered base address
  1047. to $200000, but does not change relocsection boolean
  1048. this way we can create both relocatble and
  1049. non relocatable DLL at a specific base address PM }
  1050. if (length(More)>j) then
  1051. begin
  1052. if DLLImageBase=nil then
  1053. DLLImageBase:=StringDup(Copy(More,j+1,255));
  1054. end
  1055. else
  1056. begin
  1057. RelocSection:=true;
  1058. RelocSectionSetExplicitly:=true;
  1059. end;
  1060. break;
  1061. end;
  1062. 'C':
  1063. begin
  1064. if UnsetBool(More, j) then
  1065. apptype:=app_gui
  1066. else
  1067. apptype:=app_cui;
  1068. end;
  1069. 'D':
  1070. begin
  1071. UseDeffileForExports:=not UnsetBool(More, j);
  1072. UseDeffileForExportsSetExplicitly:=true;
  1073. end;
  1074. 'F':
  1075. begin
  1076. if UnsetBool(More, j) then
  1077. apptype:=app_cui
  1078. else
  1079. apptype:=app_fs;
  1080. end;
  1081. 'G':
  1082. begin
  1083. if UnsetBool(More, j) then
  1084. apptype:=app_cui
  1085. else
  1086. apptype:=app_gui;
  1087. end;
  1088. 'T':
  1089. begin
  1090. if UnsetBool(More, j) then
  1091. apptype:=app_cui
  1092. else
  1093. apptype:=app_tool;
  1094. end;
  1095. 'N':
  1096. begin
  1097. RelocSection:=UnsetBool(More,j);
  1098. RelocSectionSetExplicitly:=true;
  1099. end;
  1100. 'R':
  1101. begin
  1102. { support -WR+ / -WR- as synonyms to -WR / -WN }
  1103. RelocSection:=not UnsetBool(More,j);
  1104. RelocSectionSetExplicitly:=true;
  1105. end;
  1106. else
  1107. IllegalPara(opt);
  1108. end;
  1109. inc(j);
  1110. end;
  1111. end;
  1112. 'X' :
  1113. begin
  1114. j:=1;
  1115. while j<=length(more) do
  1116. begin
  1117. case More[j] of
  1118. 'i' :
  1119. include(initglobalswitches,cs_link_internal);
  1120. 'm' :
  1121. include(initglobalswitches,cs_link_map);
  1122. 'f' :
  1123. include(initglobalswitches,cs_link_pthread);
  1124. 's' :
  1125. include(initglobalswitches,cs_link_strip);
  1126. 'c' : Cshared:=TRUE;
  1127. 't' :
  1128. include(initglobalswitches,cs_link_staticflag);
  1129. 'D' :
  1130. begin
  1131. def_system_macro('FPC_LINK_DYNAMIC');
  1132. undef_system_macro('FPC_LINK_SMART');
  1133. undef_system_macro('FPC_LINK_STATIC');
  1134. exclude(initglobalswitches,cs_link_static);
  1135. exclude(initglobalswitches,cs_link_smart);
  1136. include(initglobalswitches,cs_link_shared);
  1137. LinkTypeSetExplicitly:=true;
  1138. end;
  1139. 'd' : Dontlinkstdlibpath:=TRUE;
  1140. 'P' : Begin
  1141. utilsprefix:=Copy(more,2,length(More)-1);
  1142. DefaultReplacements(utilsprefix);
  1143. More:='';
  1144. End;
  1145. 'r' : Begin
  1146. rlinkpath:=Copy(more,2,length(More)-1);
  1147. DefaultReplacements(rlinkpath);
  1148. More:='';
  1149. end;
  1150. 'S' :
  1151. begin
  1152. def_system_macro('FPC_LINK_STATIC');
  1153. undef_system_macro('FPC_LINK_SMART');
  1154. undef_system_macro('FPC_LINK_DYNAMIC');
  1155. include(initglobalswitches,cs_link_static);
  1156. exclude(initglobalswitches,cs_link_smart);
  1157. exclude(initglobalswitches,cs_link_shared);
  1158. LinkTypeSetExplicitly:=true;
  1159. end;
  1160. 'X' :
  1161. begin
  1162. def_system_macro('FPC_LINK_SMART');
  1163. undef_system_macro('FPC_LINK_STATIC');
  1164. undef_system_macro('FPC_LINK_DYNAMIC');
  1165. exclude(initglobalswitches,cs_link_static);
  1166. include(initglobalswitches,cs_link_smart);
  1167. exclude(initglobalswitches,cs_link_shared);
  1168. LinkTypeSetExplicitly:=true;
  1169. end;
  1170. 'M' :
  1171. begin
  1172. mainaliasname:=Copy(more,2,length(More)-1);
  1173. More:='';
  1174. end;
  1175. '-' :
  1176. begin
  1177. exclude(initglobalswitches,cs_link_staticflag);
  1178. exclude(initglobalswitches,cs_link_strip);
  1179. exclude(initglobalswitches,cs_link_map);
  1180. set_default_link_type;
  1181. end;
  1182. else
  1183. IllegalPara(opt);
  1184. end;
  1185. inc(j);
  1186. end;
  1187. end;
  1188. { give processor specific options a chance }
  1189. else
  1190. interpret_proc_specific_options(opt);
  1191. end;
  1192. end;
  1193. '@' :
  1194. begin
  1195. Message(option_no_nested_response_file);
  1196. StopOptions(1);
  1197. end;
  1198. else
  1199. begin
  1200. if (length(param_file)<>0) then
  1201. Message(option_only_one_source_support);
  1202. param_file:=opt;
  1203. Message1(option_found_file,opt);
  1204. end;
  1205. end;
  1206. end;
  1207. procedure Toption.Interpret_file(const filename : string);
  1208. procedure RemoveSep(var fn:string);
  1209. var
  1210. i : longint;
  1211. begin
  1212. i:=0;
  1213. while (i<length(fn)) and (fn[i+1] in [',',' ',#9]) do
  1214. inc(i);
  1215. Delete(fn,1,i);
  1216. i:=length(fn);
  1217. while (i>0) and (fn[i] in [',',' ',#9]) do
  1218. dec(i);
  1219. fn:=copy(fn,1,i);
  1220. end;
  1221. function GetName(var fn:string):string;
  1222. var
  1223. i : longint;
  1224. begin
  1225. i:=0;
  1226. while (i<length(fn)) and (fn[i+1] in ['a'..'z','A'..'Z','0'..'9','_','-']) do
  1227. inc(i);
  1228. GetName:=Copy(fn,1,i);
  1229. Delete(fn,1,i);
  1230. end;
  1231. const
  1232. maxlevel=16;
  1233. var
  1234. f : text;
  1235. s, tmp,
  1236. opts : string;
  1237. skip : array[0..maxlevel-1] of boolean;
  1238. level : longint;
  1239. option_read : boolean;
  1240. begin
  1241. { avoid infinite loop }
  1242. Inc(FileLevel);
  1243. Option_read:=false;
  1244. If FileLevel>MaxLevel then
  1245. Message(option_too_many_cfg_files);
  1246. { open file }
  1247. Message1(option_using_file,filename);
  1248. {$ifdef USE_SYSUTILS}
  1249. assign(f,ExpandFileName(filename));
  1250. {$else USE_SYSUTILS}
  1251. assign(f,FExpand(filename));
  1252. {$endif USE_SYsUTILS}
  1253. {$I-}
  1254. reset(f);
  1255. {$I+}
  1256. if ioresult<>0 then
  1257. begin
  1258. Message1(option_unable_open_file,filename);
  1259. exit;
  1260. end;
  1261. Message1(option_start_reading_configfile,filename);
  1262. fillchar(skip,sizeof(skip),0);
  1263. level:=0;
  1264. while not eof(f) do
  1265. begin
  1266. readln(f,opts);
  1267. RemoveSep(opts);
  1268. if (opts<>'') and (opts[1]<>';') then
  1269. begin
  1270. if opts[1]='#' then
  1271. begin
  1272. Message1(option_interpreting_file_option,opts);
  1273. Delete(opts,1,1);
  1274. s:=upper(GetName(opts));
  1275. if (s='SECTION') then
  1276. begin
  1277. RemoveSep(opts);
  1278. s:=upper(GetName(opts));
  1279. if level=0 then
  1280. skip[level]:=not (assigned(search_macro(s)) or (s='COMMON'));
  1281. end
  1282. else
  1283. if (s='IFDEF') then
  1284. begin
  1285. RemoveSep(opts);
  1286. if Level>=maxlevel then
  1287. begin
  1288. Message(option_too_many_ifdef);
  1289. stopOptions(1);
  1290. end;
  1291. inc(Level);
  1292. skip[level]:=(skip[level-1] or not assigned(search_macro(upper(GetName(opts)))));
  1293. end
  1294. else
  1295. if (s='IFNDEF') then
  1296. begin
  1297. RemoveSep(opts);
  1298. if Level>=maxlevel then
  1299. begin
  1300. Message(option_too_many_ifdef);
  1301. stopOptions(1);
  1302. end;
  1303. inc(Level);
  1304. skip[level]:=(skip[level-1] or assigned(search_macro(upper(GetName(opts)))));
  1305. end
  1306. else
  1307. if (s='ELSE') then
  1308. skip[level]:=skip[level-1] or (not skip[level])
  1309. else
  1310. if (s='ENDIF') then
  1311. begin
  1312. skip[level]:=false;
  1313. if Level=0 then
  1314. begin
  1315. Message(option_too_many_endif);
  1316. stopOptions(1);
  1317. end;
  1318. dec(level);
  1319. end
  1320. else
  1321. if (not skip[level]) then
  1322. begin
  1323. if (s='DEFINE') then
  1324. begin
  1325. RemoveSep(opts);
  1326. tmp:= GetName(opts);
  1327. if tmp <> '' then
  1328. def_system_macro(tmp);
  1329. end
  1330. else
  1331. if (s='UNDEF') then
  1332. begin
  1333. RemoveSep(opts);
  1334. tmp:= GetName(opts);
  1335. if tmp <> '' then
  1336. undef_system_macro(tmp);
  1337. end
  1338. else
  1339. if (s='WRITE') then
  1340. begin
  1341. Delete(opts,1,1);
  1342. WriteLn(opts);
  1343. end
  1344. else
  1345. if (s='INCLUDE') then
  1346. begin
  1347. Delete(opts,1,1);
  1348. Interpret_file(opts);
  1349. end;
  1350. end;
  1351. end
  1352. else
  1353. begin
  1354. if (opts[1]='-') or (opts[1]='@') then
  1355. begin
  1356. if (not skip[level]) then
  1357. interpret_option(opts,false);
  1358. Option_read:=true;
  1359. end
  1360. else
  1361. Message1(option_illegal_para,opts);
  1362. end;
  1363. end;
  1364. end;
  1365. if Level>0 then
  1366. Message(option_too_less_endif);
  1367. if Not Option_read then
  1368. Message1(option_no_option_found,filename)
  1369. else
  1370. Message1(option_end_reading_configfile,filename);
  1371. Close(f);
  1372. Dec(FileLevel);
  1373. end;
  1374. procedure Toption.Interpret_envvar(const envname : string);
  1375. var
  1376. argstart,
  1377. env,
  1378. pc : pchar;
  1379. arglen : longint;
  1380. quote : set of char;
  1381. hs : string;
  1382. begin
  1383. Message1(option_using_env,envname);
  1384. env:=GetEnvPChar(envname);
  1385. pc:=env;
  1386. if assigned(pc) then
  1387. begin
  1388. repeat
  1389. { skip leading spaces }
  1390. while pc^ in [' ',#9,#13] do
  1391. inc(pc);
  1392. case pc^ of
  1393. #0 :
  1394. break;
  1395. '"' :
  1396. begin
  1397. quote:=['"'];
  1398. inc(pc);
  1399. end;
  1400. '''' :
  1401. begin
  1402. quote:=[''''];
  1403. inc(pc);
  1404. end;
  1405. else
  1406. quote:=[' ',#9,#13];
  1407. end;
  1408. { scan until the end of the argument }
  1409. argstart:=pc;
  1410. while (pc^<>#0) and not(pc^ in quote) do
  1411. inc(pc);
  1412. { create argument }
  1413. arglen:=pc-argstart;
  1414. hs[0]:=chr(arglen);
  1415. move(argstart^,hs[1],arglen);
  1416. interpret_option(hs,true);
  1417. { skip quote }
  1418. if pc^ in quote then
  1419. inc(pc);
  1420. until false;
  1421. end
  1422. else
  1423. Message1(option_no_option_found,'(env) '+envname);
  1424. FreeEnvPChar(env);
  1425. end;
  1426. procedure toption.read_parameters;
  1427. var
  1428. opts : string;
  1429. paramindex : longint;
  1430. begin
  1431. paramindex:=0;
  1432. while paramindex<paramcount do
  1433. begin
  1434. inc(paramindex);
  1435. opts:=system.paramstr(paramindex);
  1436. case opts[1] of
  1437. '@' :
  1438. if not firstpass then
  1439. begin
  1440. Delete(opts,1,1);
  1441. Message1(option_reading_further_from,opts);
  1442. interpret_file(opts);
  1443. end;
  1444. '!' :
  1445. if not firstpass then
  1446. begin
  1447. Delete(opts,1,1);
  1448. Message1(option_reading_further_from,'(env) '+opts);
  1449. interpret_envvar(opts);
  1450. end;
  1451. else
  1452. interpret_option(opts,true);
  1453. end;
  1454. end;
  1455. end;
  1456. procedure toption.parsecmd(cmd:string);
  1457. var
  1458. i,ps : longint;
  1459. opts : string;
  1460. begin
  1461. while (cmd<>'') do
  1462. begin
  1463. while cmd[1]=' ' do
  1464. delete(cmd,1,1);
  1465. i:=pos(' ',cmd);
  1466. if i=0 then
  1467. i:=256;
  1468. opts:=Copy(cmd,1,i-1);
  1469. Delete(cmd,1,i);
  1470. case opts[1] of
  1471. '@' :
  1472. if not firstpass then
  1473. begin
  1474. Delete(opts,1,1);
  1475. Message1(option_reading_further_from,opts);
  1476. interpret_file(opts);
  1477. end;
  1478. '!' :
  1479. if not firstpass then
  1480. begin
  1481. Delete(opts,1,1);
  1482. Message1(option_reading_further_from,'(env) '+opts);
  1483. interpret_envvar(opts);
  1484. end;
  1485. '"' :
  1486. begin
  1487. Delete(opts,1,1);
  1488. ps:=pos('"',cmd);
  1489. if (i<>256) and (ps>0) then
  1490. begin
  1491. opts:=opts + ' '+ copy(cmd,1,ps-1);
  1492. cmd:=copy(cmd,ps+1,255);
  1493. end;
  1494. interpret_option(opts,true);
  1495. end;
  1496. else
  1497. interpret_option(opts,true);
  1498. end;
  1499. end;
  1500. end;
  1501. procedure toption.writequickinfo;
  1502. var
  1503. s : string;
  1504. i : longint;
  1505. procedure addinfo(const hs:string);
  1506. begin
  1507. if s<>'' then
  1508. s:=s+' '+hs
  1509. else
  1510. s:=hs;
  1511. end;
  1512. begin
  1513. s:='';
  1514. i:=0;
  1515. while (i<length(quickinfo)) do
  1516. begin
  1517. inc(i);
  1518. case quickinfo[i] of
  1519. 'S' :
  1520. begin
  1521. inc(i);
  1522. case quickinfo[i] of
  1523. 'O' :
  1524. addinfo(lower(source_info.shortname));
  1525. 'P' :
  1526. addinfo(source_cpu_string);
  1527. else
  1528. IllegalPara('-i'+QuickInfo);
  1529. end;
  1530. end;
  1531. 'T' :
  1532. begin
  1533. inc(i);
  1534. case quickinfo[i] of
  1535. 'O' :
  1536. addinfo(lower(target_info.shortname));
  1537. 'P' :
  1538. AddInfo(target_cpu_string);
  1539. else
  1540. IllegalPara('-i'+QuickInfo);
  1541. end;
  1542. end;
  1543. 'V' :
  1544. AddInfo(version_string);
  1545. 'D' :
  1546. AddInfo(date_string);
  1547. '_' :
  1548. ;
  1549. else
  1550. IllegalPara('-i'+QuickInfo);
  1551. end;
  1552. end;
  1553. if s<>'' then
  1554. begin
  1555. writeln(s);
  1556. stopoptions(0);
  1557. end;
  1558. end;
  1559. procedure TOption.TargetDefines(def:boolean);
  1560. var
  1561. s : string;
  1562. i : integer;
  1563. begin
  1564. if def then
  1565. def_system_macro(target_info.shortname)
  1566. else
  1567. undef_system_macro(target_info.shortname);
  1568. s:=target_info.extradefines;
  1569. while (s<>'') do
  1570. begin
  1571. i:=pos(';',s);
  1572. if i=0 then
  1573. i:=length(s)+1;
  1574. if def then
  1575. def_system_macro(Copy(s,1,i-1))
  1576. else
  1577. undef_system_macro(Copy(s,1,i-1));
  1578. delete(s,1,i);
  1579. end;
  1580. end;
  1581. constructor TOption.create;
  1582. begin
  1583. LogoWritten:=false;
  1584. NoPressEnter:=false;
  1585. FirstPass:=false;
  1586. FileLevel:=0;
  1587. Quickinfo:='';
  1588. ParaIncludePath:=TSearchPathList.Create;
  1589. ParaObjectPath:=TSearchPathList.Create;
  1590. ParaUnitPath:=TSearchPathList.Create;
  1591. ParaLibraryPath:=TSearchPathList.Create;
  1592. FillChar(ParaAlignment,sizeof(ParaAlignment),0);
  1593. end;
  1594. destructor TOption.destroy;
  1595. begin
  1596. ParaIncludePath.Free;
  1597. ParaObjectPath.Free;
  1598. ParaUnitPath.Free;
  1599. ParaLibraryPath.Free;
  1600. end;
  1601. {****************************************************************************
  1602. Callable Routines
  1603. ****************************************************************************}
  1604. function check_configfile(const fn:string;var foundfn:string):boolean;
  1605. function CfgFileExists(const fn:string):boolean;
  1606. begin
  1607. Comment(V_Tried,'Configfile search: '+fn);
  1608. CfgFileExists:=FileExists(fn);
  1609. end;
  1610. var
  1611. configpath : pathstr;
  1612. begin
  1613. foundfn:=fn;
  1614. check_configfile:=true;
  1615. { retrieve configpath }
  1616. {$IFDEF USE_SYSUTILS}
  1617. configpath:=FixPath(GetEnvironmentVariable('PPC_CONFIG_PATH'),false);
  1618. {$ELSE USE_SYSUTILS}
  1619. configpath:=FixPath(dos.getenv('PPC_CONFIG_PATH'),false);
  1620. {$ENDIF USE_SYSUTILS}
  1621. {$ifdef Unix}
  1622. if configpath='' then
  1623. configpath:=CleanPath(FixPath(exepath+'../etc/',false));
  1624. {$endif}
  1625. {
  1626. Order to read configuration file :
  1627. try reading fpc.cfg in :
  1628. 1 - current dir
  1629. 2 - configpath
  1630. 3 - compiler path
  1631. }
  1632. if not FileExists(fn) then
  1633. begin
  1634. {$ifdef Unix}
  1635. {$IFDEF USE_SYSUTILS}
  1636. if (GetEnvironmentVariable('HOME')<>'') and CfgFileExists(FixPath(GetEnvironmentVariable('HOME'),false)+'.'+fn) then
  1637. foundfn:=FixPath(GetEnvironmentVariable('HOME'),false)+'.'+fn
  1638. {$ELSE USE_SYSUTILS}
  1639. if (dos.getenv('HOME')<>'') and CfgFileExists(FixPath(dos.getenv('HOME'),false)+'.'+fn) then
  1640. foundfn:=FixPath(dos.getenv('HOME'),false)+'.'+fn
  1641. {$ENDIF USE_SYSUTILS}
  1642. else
  1643. {$endif}
  1644. if CfgFileExists(configpath+fn) then
  1645. foundfn:=configpath+fn
  1646. else
  1647. {$ifndef Unix}
  1648. if CfgFileExists(exepath+fn) then
  1649. foundfn:=exepath+fn
  1650. else
  1651. {$else}
  1652. if CfgFileExists('/etc/'+fn) then
  1653. foundfn:='/etc/'+fn
  1654. else
  1655. {$endif}
  1656. check_configfile:=false;
  1657. end;
  1658. end;
  1659. procedure read_arguments(cmd:string);
  1660. begin
  1661. option:=coption.create;
  1662. disable_configfile:=false;
  1663. { get default messagefile }
  1664. {$IFDEF USE_SYSUTILS}
  1665. msgfilename:=GetEnvironmentVariable('PPC_ERROR_FILE');
  1666. {$ELSE USE_SYSUTILS}
  1667. msgfilename:=dos.getenv('PPC_ERROR_FILE');
  1668. {$ENDIF USE_SYSUTILS}
  1669. { default configfile can be specified on the commandline,
  1670. remove it first }
  1671. if (cmd<>'') and (cmd[1]='[') then
  1672. begin
  1673. ppccfg:=Copy(cmd,2,pos(']',cmd)-2);
  1674. Delete(cmd,1,pos(']',cmd));
  1675. end
  1676. else
  1677. begin
  1678. ppccfg:='fpc.cfg';
  1679. ppcaltcfg:='ppc386.cfg';
  1680. end;
  1681. { first pass reading of parameters, only -i -v -T etc.}
  1682. option.firstpass:=true;
  1683. if cmd<>'' then
  1684. option.parsecmd(cmd)
  1685. else
  1686. begin
  1687. option.read_parameters;
  1688. { Write only quickinfo }
  1689. if option.quickinfo<>'' then
  1690. option.writequickinfo;
  1691. end;
  1692. option.firstpass:=false;
  1693. { target is set here, for wince the default app type is gui }
  1694. if target_info.system in system_wince then
  1695. apptype:=app_gui;
  1696. { default defines }
  1697. def_system_macro(target_info.shortname);
  1698. def_system_macro('FPC');
  1699. def_system_macro('VER'+version_nr);
  1700. def_system_macro('VER'+version_nr+'_'+release_nr);
  1701. def_system_macro('VER'+version_nr+'_'+release_nr+'_'+patch_nr);
  1702. { Temporary defines, until things settle down }
  1703. { "main" symbol is generated in the main program, and left out of the system unit }
  1704. def_system_macro('FPC_DARWIN_PASCALMAIN');
  1705. def_system_macro('COMPPROCINLINEFIXED');
  1706. if pocall_default = pocall_register then
  1707. def_system_macro('REGCALL');
  1708. { using a case is pretty useless here (FK) }
  1709. { some stuff for TP compatibility }
  1710. {$ifdef i386}
  1711. def_system_macro('CPU86');
  1712. def_system_macro('CPU87');
  1713. {$endif}
  1714. {$ifdef m68k}
  1715. def_system_macro('CPU68');
  1716. {$endif}
  1717. { new processor stuff }
  1718. {$ifdef i386}
  1719. def_system_macro('CPUI386');
  1720. def_system_macro('CPU32');
  1721. def_system_macro('FPC_HAS_TYPE_EXTENDED');
  1722. def_system_macro('FPC_HAS_TYPE_DOUBLE');
  1723. def_system_macro('FPC_HAS_TYPE_SINGLE');
  1724. def_system_macro('FPC_HAS_RESOURCES');
  1725. {$endif}
  1726. {$ifdef m68k}
  1727. def_system_macro('CPU68K');
  1728. def_system_macro('CPUM68K');
  1729. def_system_macro('CPU32');
  1730. def_system_macro('FPC_CURRENCY_IS_INT64');
  1731. def_system_macro('FPC_COMP_IS_INT64');
  1732. {$endif}
  1733. {$ifdef ALPHA}
  1734. def_system_macro('CPUALPHA');
  1735. def_system_macro('CPU64');
  1736. {$endif}
  1737. {$ifdef powerpc}
  1738. def_system_macro('CPUPOWERPC');
  1739. def_system_macro('CPUPOWERPC32');
  1740. def_system_macro('CPU32');
  1741. def_system_macro('FPC_HAS_TYPE_DOUBLE');
  1742. def_system_macro('FPC_HAS_TYPE_SINGLE');
  1743. def_system_macro('FPC_INCLUDE_SOFTWARE_INT64_TO_DOUBLE');
  1744. def_system_macro('FPC_CURRENCY_IS_INT64');
  1745. def_system_macro('FPC_COMP_IS_INT64');
  1746. {$endif}
  1747. {$ifdef iA64}
  1748. def_system_macro('CPUIA64');
  1749. def_system_macro('CPU64');
  1750. {$endif}
  1751. {$ifdef x86_64}
  1752. def_system_macro('CPUX86_64');
  1753. def_system_macro('CPUAMD64');
  1754. def_system_macro('CPU64');
  1755. { not supported for now, afaik (FK)
  1756. def_system_macro('FPC_HAS_TYPE_FLOAT128'); }
  1757. { win64 doesn't support the legacy fpu }
  1758. if target_info.system<>system_x86_64_win64 then
  1759. def_system_macro('FPC_HAS_TYPE_EXTENDED')
  1760. else
  1761. begin
  1762. def_system_macro('FPC_CURRENCY_IS_INT64');
  1763. def_system_macro('FPC_COMP_IS_INT64');
  1764. undef_system_macro('FPC_HAS_TYPE_EXTENDED');
  1765. end;
  1766. def_system_macro('FPC_HAS_TYPE_DOUBLE');
  1767. def_system_macro('FPC_HAS_TYPE_SINGLE');
  1768. {$endif}
  1769. {$ifdef sparc}
  1770. def_system_macro('CPUSPARC');
  1771. def_system_macro('CPUSPARC32');
  1772. def_system_macro('CPU32');
  1773. def_system_macro('FPC_HAS_TYPE_DOUBLE');
  1774. def_system_macro('FPC_HAS_TYPE_SINGLE');
  1775. def_system_macro('FPC_INCLUDE_SOFTWARE_INT64_TO_DOUBLE');
  1776. def_system_macro('FPC_CURRENCY_IS_INT64');
  1777. def_system_macro('FPC_COMP_IS_INT64');
  1778. def_system_macro('FPC_REQUIRES_PROPER_ALIGNMENT');
  1779. {$endif}
  1780. {$ifdef vis}
  1781. def_system_macro('CPUVIS');
  1782. def_system_macro('CPU32');
  1783. {$endif}
  1784. {$ifdef arm}
  1785. def_system_macro('CPUARM');
  1786. def_system_macro('FPUFPA');
  1787. def_system_macro('CPU32');
  1788. def_system_macro('FPC_HAS_TYPE_DOUBLE');
  1789. def_system_macro('FPC_HAS_TYPE_SINGLE');
  1790. def_system_macro('FPC_INCLUDE_SOFTWARE_INT64_TO_DOUBLE');
  1791. def_system_macro('FPC_CURRENCY_IS_INT64');
  1792. def_system_macro('FPC_COMP_IS_INT64');
  1793. def_system_macro('FPC_REQUIRES_PROPER_ALIGNMENT');
  1794. {$endif arm}
  1795. if source_info.system<>target_info.system then
  1796. def_system_macro('FPC_CROSSCOMPILING');
  1797. if source_info.cpu<>target_info.cpu then
  1798. def_system_macro('FPC_CPUCROSSCOMPILING');
  1799. { read configuration file }
  1800. if (not disable_configfile) and
  1801. (ppccfg<>'') then
  1802. begin
  1803. read_configfile:=check_configfile(ppccfg,ppccfg);
  1804. { Maybe alternative configfile ? }
  1805. if (not read_configfile) and
  1806. (ppcaltcfg<>'') then
  1807. read_configfile:=check_configfile(ppcaltcfg,ppccfg);
  1808. end
  1809. else
  1810. read_configfile := false;
  1811. { Read commandline and configfile }
  1812. target_is_set:=false;
  1813. asm_is_set:=false;
  1814. param_file:='';
  1815. { read configfile }
  1816. if read_configfile then
  1817. option.interpret_file(ppccfg);
  1818. { read parameters again to override config file }
  1819. if cmd<>'' then
  1820. option.parsecmd(cmd)
  1821. else
  1822. begin
  1823. { Write help pages if no parameters are passed }
  1824. if (paramcount=0) then
  1825. Option.WriteHelpPages;
  1826. option.read_parameters;
  1827. { Write only quickinfo }
  1828. if option.quickinfo<>'' then
  1829. option.writequickinfo;
  1830. end;
  1831. { Stop if errors in options }
  1832. if ErrorCount>0 then
  1833. StopOptions(1);
  1834. { Write logo }
  1835. if option.ParaLogo then
  1836. option.writelogo;
  1837. { Non-core target defines }
  1838. Option.TargetDefines(true);
  1839. { endian define }
  1840. case target_info.endian of
  1841. endian_little :
  1842. begin
  1843. def_system_macro('ENDIAN_LITTLE');
  1844. def_system_macro('FPC_LITTLE_ENDIAN');
  1845. end;
  1846. endian_big :
  1847. begin
  1848. def_system_macro('ENDIAN_BIG');
  1849. def_system_macro('FPC_BIG_ENDIAN');
  1850. end;
  1851. end;
  1852. { abi define }
  1853. case target_info.abi of
  1854. abi_powerpc_sysv :
  1855. def_system_macro('FPC_ABI_SYSV');
  1856. abi_powerpc_aix :
  1857. def_system_macro('FPC_ABI_AIX');
  1858. end;
  1859. {$ifdef m68k}
  1860. if initoptprocessor=MC68020 then
  1861. def_system_macro('CPUM68020');
  1862. {$endif m68k}
  1863. { Check file to compile }
  1864. if param_file='' then
  1865. begin
  1866. Message(option_no_source_found);
  1867. StopOptions(1);
  1868. end;
  1869. {$ifndef Unix}
  1870. param_file:=FixFileName(param_file);
  1871. {$endif}
  1872. {$IFDEF USE_SYSUTILS}
  1873. inputdir := SplitPath(param_file);
  1874. inputfile := SplitName(param_file);
  1875. inputextension := SplitExtension(param_file);
  1876. {$ELSE USE_SYSUTILS}
  1877. fsplit(param_file,inputdir,inputfile,inputextension);
  1878. {$ENDIF USE_SYSUTILS}
  1879. if inputextension='' then
  1880. begin
  1881. if FileExists(inputdir+inputfile+sourceext) then
  1882. inputextension:=sourceext
  1883. else if FileExists(inputdir+inputfile+pasext) then
  1884. inputextension:=pasext
  1885. else if ((m_mac in aktmodeswitches) or target_info.p_ext_support)
  1886. and FileExists(inputdir+inputfile+pext) then
  1887. inputextension:=pext;
  1888. end;
  1889. { Check output dir }
  1890. if (OutputExeDir<>'') and
  1891. not PathExists(OutputExeDir) then
  1892. begin
  1893. Message1(general_e_path_does_not_exist,OutputExeDir);
  1894. StopOptions(1);
  1895. end;
  1896. { Add paths specified with parameters to the searchpaths }
  1897. UnitSearchPath.AddList(option.ParaUnitPath,true);
  1898. ObjectSearchPath.AddList(option.ParaObjectPath,true);
  1899. IncludeSearchPath.AddList(option.ParaIncludePath,true);
  1900. LibrarySearchPath.AddList(option.ParaLibraryPath,true);
  1901. { add unit environment and exepath to the unit search path }
  1902. if inputdir<>'' then
  1903. Unitsearchpath.AddPath(inputdir,true);
  1904. if not disable_configfile then
  1905. begin
  1906. {$IFDEF USE_SYSUTILS}
  1907. UnitSearchPath.AddPath(GetEnvironmentVariable(target_info.unit_env),false);
  1908. {$ELSE USE_SYSUTILS}
  1909. UnitSearchPath.AddPath(dos.getenv(target_info.unit_env),false);
  1910. {$ENDIF USE_SYSUTILS}
  1911. end;
  1912. {$ifdef Unix}
  1913. {$IFDEF USE_SYSUTILS}
  1914. fpcdir:=FixPath(GetEnvironmentVariable('FPCDIR'),false);
  1915. {$ELSE USE_SYSUTILS}
  1916. fpcdir:=FixPath(getenv('FPCDIR'),false);
  1917. {$ENDIF USE_SYSUTILS}
  1918. if fpcdir='' then
  1919. begin
  1920. if PathExists('/usr/local/lib/fpc/'+version_string) then
  1921. fpcdir:='/usr/local/lib/fpc/'+version_string+'/'
  1922. else
  1923. fpcdir:='/usr/lib/fpc/'+version_string+'/';
  1924. end;
  1925. {$else}
  1926. {$IFDEF USE_SYSUTILS}
  1927. fpcdir:=FixPath(GetEnvironmentVariable('FPCDIR'),false);
  1928. {$ELSE USE_SYSUTILS}
  1929. fpcdir:=FixPath(getenv('FPCDIR'),false);
  1930. {$ENDIF USE_SYSUTILS}
  1931. if fpcdir='' then
  1932. begin
  1933. fpcdir:=ExePath+'../';
  1934. if not(PathExists(fpcdir+'/units')) and
  1935. not(PathExists(fpcdir+'/rtl')) then
  1936. fpcdir:=fpcdir+'../';
  1937. end;
  1938. {$endif}
  1939. { first try development RTL, else use the default installation path }
  1940. if not disable_configfile then
  1941. begin
  1942. if PathExists(FpcDir+'rtl') then
  1943. if tf_use_8_3 in Source_Info.Flags then
  1944. UnitSearchPath.AddPath(FpcDir+'rtl/'+target_os_string,false)
  1945. else
  1946. UnitSearchPath.AddPath(FpcDir+'rtl/'+target_full_string,false)
  1947. else
  1948. if tf_use_8_3 in Source_Info.Flags then
  1949. UnitSearchPath.AddPath(FpcDir+'units/'+target_os_string+'/rtl',false)
  1950. else
  1951. UnitSearchPath.AddPath(FpcDir+'units/'+target_full_string+'/rtl',false);
  1952. end;
  1953. { Add exepath if the exe is not in the current dir, because that is always searched already.
  1954. Do not add it when linking on the target because then we can maybe already find
  1955. .o files that are not for the target }
  1956. if (ExePath<>GetCurrentDir) and
  1957. not(cs_link_on_target in initglobalswitches) then
  1958. UnitSearchPath.AddPath(ExePath,false);
  1959. { Add unit dir to the object and library path }
  1960. objectsearchpath.AddList(unitsearchpath,false);
  1961. librarysearchpath.AddList(unitsearchpath,false);
  1962. { switch assembler if it's binary and we got -a on the cmdline }
  1963. if (cs_asm_leave in initglobalswitches) and
  1964. (af_outputbinary in target_asm.flags) then
  1965. begin
  1966. Message(option_switch_bin_to_src_assembler);
  1967. set_target_asm(target_info.assemextern);
  1968. end;
  1969. if (target_asm.supported_target <> system_any) and
  1970. (target_asm.supported_target <> target_info.system) then
  1971. begin
  1972. Message2(option_incompatible_asm,target_asm.idtxt,target_info.name);
  1973. set_target_asm(target_info.assemextern);
  1974. Message1(option_asm_forced,target_asm.idtxt);
  1975. end;
  1976. { turn off stripping if compiling with debuginfo or profile }
  1977. if (cs_debuginfo in initmoduleswitches) or
  1978. (cs_profile in initmoduleswitches) then
  1979. exclude(initglobalswitches,cs_link_strip);
  1980. { force fpu emulation on arm/wince }
  1981. if target_info.system=system_arm_wince then
  1982. include(initmoduleswitches,cs_fp_emulation);
  1983. {$ifdef x86_64}
  1984. {$warning HACK: turn off smartlinking}
  1985. exclude(initmoduleswitches,cs_create_smart);
  1986. {$endif}
  1987. if not LinkTypeSetExplicitly then
  1988. set_default_link_type;
  1989. { Default alignment settings,
  1990. 1. load the defaults for the target
  1991. 2. override with generic optimizer setting (little size)
  1992. 3. override with the user specified -Oa }
  1993. UpdateAlignment(initalignment,target_info.alignment);
  1994. if (cs_littlesize in aktglobalswitches) then
  1995. begin
  1996. initalignment.procalign:=1;
  1997. initalignment.jumpalign:=1;
  1998. initalignment.loopalign:=1;
  1999. end;
  2000. UpdateAlignment(initalignment,option.paraalignment);
  2001. set_system_macro('FPC_VERSION',version_nr);
  2002. set_system_macro('FPC_RELEASE',release_nr);
  2003. set_system_macro('FPC_PATCH',patch_nr);
  2004. option.free;
  2005. Option:=nil;
  2006. end;
  2007. initialization
  2008. coption:=toption;
  2009. finalization
  2010. if assigned(option) then
  2011. option.free;
  2012. end.