options.pas 65 KB

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