options.pas 64 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199
  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. 'c' :
  597. begin
  598. if not(cpavailable(more)) then
  599. Message1(option_code_page_not_available,more)
  600. else
  601. initsourcecodepage:=more;
  602. end;
  603. 'D' :
  604. utilsdirectory:=FixPath(More,true);
  605. 'e' :
  606. SetRedirectFile(More);
  607. 'E' :
  608. OutputExeDir:=FixPath(More,true);
  609. 'i' :
  610. begin
  611. if ispara then
  612. ParaIncludePath.AddPath(More,false)
  613. else
  614. includesearchpath.AddPath(More,true);
  615. end;
  616. 'g' :
  617. Message2(option_obsolete_switch_use_new,'-Fg','-Fl');
  618. 'l' :
  619. begin
  620. if ispara then
  621. ParaLibraryPath.AddPath(More,false)
  622. else
  623. LibrarySearchPath.AddPath(More,true);
  624. end;
  625. 'L' :
  626. begin
  627. if More<>'' then
  628. ParaDynamicLinker:=More
  629. else
  630. IllegalPara(opt);
  631. end;
  632. 'o' :
  633. begin
  634. if ispara then
  635. ParaObjectPath.AddPath(More,false)
  636. else
  637. ObjectSearchPath.AddPath(More,true);
  638. end;
  639. 'r' :
  640. Msgfilename:=More;
  641. 'u' :
  642. begin
  643. if ispara then
  644. ParaUnitPath.AddPath(More,false)
  645. else
  646. unitsearchpath.AddPath(More,true);
  647. end;
  648. 'U' :
  649. OutputUnitDir:=FixPath(More,true);
  650. else
  651. IllegalPara(opt);
  652. end;
  653. end;
  654. 'g' : begin
  655. if UnsetBool(More, 0) then
  656. begin
  657. exclude(initmoduleswitches,cs_debuginfo);
  658. exclude(initglobalswitches,cs_gdb_dbx);
  659. exclude(initglobalswitches,cs_gdb_gsym);
  660. exclude(initglobalswitches,cs_gdb_heaptrc);
  661. exclude(initglobalswitches,cs_gdb_lineinfo);
  662. exclude(initlocalswitches,cs_checkpointer);
  663. end
  664. else
  665. begin
  666. {$ifdef GDB}
  667. include(initmoduleswitches,cs_debuginfo);
  668. {$else GDB}
  669. Message(option_no_debug_support);
  670. Message(option_no_debug_support_recompile_fpc);
  671. {$endif GDB}
  672. end;
  673. {$ifdef GDB}
  674. if not RelocSectionSetExplicitly then
  675. RelocSection:=false;
  676. j:=1;
  677. while j<=length(more) do
  678. begin
  679. case more[j] of
  680. 'd' :
  681. begin
  682. if UnsetBool(More, j) then
  683. exclude(initglobalswitches,cs_gdb_dbx)
  684. else
  685. include(initglobalswitches,cs_gdb_dbx);
  686. end;
  687. 'g' :
  688. begin
  689. if UnsetBool(More, j) then
  690. exclude(initglobalswitches,cs_gdb_gsym)
  691. else
  692. include(initglobalswitches,cs_gdb_gsym);
  693. end;
  694. 'h' :
  695. begin
  696. if UnsetBool(More, j) then
  697. exclude(initglobalswitches,cs_gdb_heaptrc)
  698. else
  699. include(initglobalswitches,cs_gdb_heaptrc);
  700. end;
  701. 'l' :
  702. begin
  703. if UnsetBool(More, j) then
  704. exclude(initglobalswitches,cs_gdb_lineinfo)
  705. else
  706. include(initglobalswitches,cs_gdb_lineinfo);
  707. end;
  708. 'c' :
  709. begin
  710. if UnsetBool(More, j) then
  711. exclude(initlocalswitches,cs_checkpointer)
  712. else
  713. include(initlocalswitches,cs_checkpointer);
  714. end;
  715. 'v' :
  716. begin
  717. if UnsetBool(More, j) then
  718. exclude(initglobalswitches,cs_gdb_valgrind)
  719. else
  720. include(initglobalswitches,cs_gdb_valgrind);
  721. end;
  722. 'w' :
  723. begin
  724. if UnsetBool(More, j) then
  725. exclude(initglobalswitches,cs_gdb_dwarf)
  726. else
  727. include(initglobalswitches,cs_gdb_dwarf);
  728. end;
  729. else
  730. IllegalPara(opt);
  731. end;
  732. inc(j);
  733. end;
  734. {$endif GDB}
  735. end;
  736. 'h' :
  737. begin
  738. NoPressEnter:=true;
  739. WriteHelpPages;
  740. end;
  741. 'i' :
  742. begin
  743. if More='' then
  744. WriteInfo
  745. else
  746. QuickInfo:=QuickInfo+More;
  747. end;
  748. 'I' :
  749. begin
  750. if ispara then
  751. ParaIncludePath.AddPath(More,false)
  752. else
  753. includesearchpath.AddPath(More,false);
  754. end;
  755. 'k' :
  756. begin
  757. if more<>'' then
  758. ParaLinkOptions:=ParaLinkOptions+' '+More
  759. else
  760. IllegalPara(opt);
  761. end;
  762. 'l' :
  763. if not UnSetBool(more,0) then
  764. WriteLogo;
  765. 'm' :
  766. parapreprocess:=not UnSetBool(more,0);
  767. 'M' :
  768. begin
  769. more:=Upper(more);
  770. if not SetCompileMode(more, true) then
  771. IllegalPara(opt);
  772. end;
  773. 'n' :
  774. begin
  775. if More='' then
  776. disable_configfile:=true
  777. else
  778. IllegalPara(opt);
  779. end;
  780. 'o' :
  781. begin
  782. if More<>'' then
  783. {$IFDEF USE_SYSUTILS}
  784. begin
  785. d := SplitPath(More);
  786. OutputFile := SplitFileName(More);
  787. end
  788. {$ELSE USE_SYSUTILS}
  789. Fsplit(More,d,OutputFile,e)
  790. {$ENDIF USE_SYSUTILS}
  791. else
  792. IllegalPara(opt);
  793. end;
  794. 'p' :
  795. begin
  796. if UnsetBool(More, 0) then
  797. begin
  798. initmoduleswitches:=initmoduleswitches-[cs_profile];
  799. undef_system_macro('FPC_PROFILE');
  800. end
  801. else
  802. if Length(More)=0 then
  803. IllegalPara(opt)
  804. else
  805. case more[1] of
  806. 'g' : if UnsetBool(more, 1) then
  807. begin
  808. exclude(initmoduleswitches,cs_profile);
  809. undef_system_macro('FPC_PROFILE');
  810. end
  811. else
  812. begin
  813. include(initmoduleswitches,cs_profile);
  814. def_system_macro('FPC_PROFILE');
  815. end;
  816. else
  817. IllegalPara(opt);
  818. end;
  819. end;
  820. 'P' : ; { Ignore used by fpc.pp }
  821. 's' :
  822. begin
  823. if UnsetBool(More, 0) then
  824. begin
  825. initglobalswitches:=initglobalswitches-[cs_asm_extern,cs_link_extern];
  826. if more<>'' then
  827. IllegalPara(opt);
  828. end
  829. else
  830. begin
  831. initglobalswitches:=initglobalswitches+[cs_asm_extern,cs_link_extern];
  832. if more='h' then
  833. initglobalswitches:=initglobalswitches-[cs_link_on_target]
  834. else if more='t' then
  835. initglobalswitches:=initglobalswitches+[cs_link_on_target]
  836. else if more='r' then
  837. initglobalswitches:=initglobalswitches+[cs_asm_leave,cs_no_regalloc]
  838. else if more<>'' then
  839. IllegalPara(opt);
  840. end;
  841. end;
  842. 'S' :
  843. begin
  844. if more[1]='I' then
  845. begin
  846. if upper(more)='ICOM' then
  847. initinterfacetype:=it_interfacecom
  848. else if upper(more)='ICORBA' then
  849. initinterfacetype:=it_interfacecorba
  850. else
  851. IllegalPara(opt);
  852. end
  853. else
  854. begin
  855. j:=1;
  856. while j<=length(more) do
  857. begin
  858. case more[j] of
  859. '2' : //an alternative to -Mobjfpc
  860. SetCompileMode('OBJFPC',true);
  861. 'a' :
  862. include(initlocalswitches,cs_do_assertion);
  863. 'c' :
  864. include(initmoduleswitches,cs_support_c_operators);
  865. 'd' : //an alternative to -Mdelphi
  866. SetCompileMode('DELPHI',true);
  867. 'e' :
  868. begin
  869. SetErrorFlags(copy(more,j+1,length(more)));
  870. break;
  871. end;
  872. 'g' :
  873. include(initmoduleswitches,cs_support_goto);
  874. 'h' :
  875. include(initlocalswitches,cs_ansistrings);
  876. 'i' :
  877. include(initmoduleswitches,cs_support_inline);
  878. 'm' :
  879. include(initmoduleswitches,cs_support_macro);
  880. 'o' : //an alternative to -Mtp
  881. SetCompileMode('TP',true);
  882. 'p' : //an alternative to -Mgpc
  883. SetCompileMode('GPC',true);
  884. 's' :
  885. include(initglobalswitches,cs_constructor_name);
  886. 't' :
  887. include(initmoduleswitches,cs_static_keyword);
  888. '-' :
  889. begin
  890. exclude(initglobalswitches,cs_constructor_name);
  891. initlocalswitches:=InitLocalswitches - [cs_do_assertion, cs_ansistrings];
  892. initmoduleswitches:=initmoduleswitches - [cs_support_c_operators, cs_support_goto,
  893. cs_support_inline, cs_support_macro,
  894. cs_static_keyword];
  895. end;
  896. else
  897. IllegalPara(opt);
  898. end;
  899. inc(j);
  900. end;
  901. end;
  902. end;
  903. 'T' :
  904. begin
  905. more:=Upper(More);
  906. if not target_is_set then
  907. begin
  908. { remove old target define }
  909. TargetDefines(false);
  910. { Save assembler if set }
  911. if asm_is_set then
  912. forceasm:=target_asm.id;
  913. { load new target }
  914. if not(set_target_by_string(More)) then
  915. IllegalPara(opt);
  916. { also initialize assembler if not explicitly set }
  917. if asm_is_set then
  918. set_target_asm(forceasm);
  919. { set new define }
  920. TargetDefines(true);
  921. target_is_set:=true;
  922. end
  923. else
  924. if More<>upper(target_info.shortname) then
  925. Message1(option_target_is_already_set,target_info.shortname);
  926. end;
  927. 'u' :
  928. if more <> '' then
  929. undef_system_macro(more);
  930. 'U' :
  931. begin
  932. j:=1;
  933. while j<=length(more) do
  934. begin
  935. case more[j] of
  936. {$ifdef UNITALIASES}
  937. 'a' :
  938. begin
  939. AddUnitAlias(Copy(More,j+1,255));
  940. break;
  941. end;
  942. {$endif UNITALIASES}
  943. 'n' :
  944. exclude(initglobalswitches,cs_check_unit_name);
  945. 'p' :
  946. begin
  947. Message2(option_obsolete_switch_use_new,'-Up','-Fu');
  948. break;
  949. end;
  950. 'r' :
  951. do_release:=true;
  952. 's' :
  953. include(initmoduleswitches,cs_compilesystem);
  954. '-' :
  955. begin
  956. exclude(initmoduleswitches,cs_compilesystem);
  957. exclude(initglobalswitches,cs_check_unit_name);
  958. end;
  959. else
  960. IllegalPara(opt);
  961. end;
  962. inc(j);
  963. end;
  964. end;
  965. 'v' :
  966. begin
  967. if not setverbosity(More) then
  968. IllegalPara(opt);
  969. end;
  970. 'V' : ; { Ignore used by fpc }
  971. 'W' :
  972. begin
  973. j:=1;
  974. while j<=length(More) do
  975. begin
  976. case More[j] of
  977. 'B':
  978. begin
  979. { -WB200000 means set trefered base address
  980. to $200000, but does not change relocsection boolean
  981. this way we can create both relocatble and
  982. non relocatable DLL at a specific base address PM }
  983. if (length(More)>j) then
  984. begin
  985. if DLLImageBase=nil then
  986. DLLImageBase:=StringDup(Copy(More,j+1,255));
  987. end
  988. else
  989. begin
  990. RelocSection:=true;
  991. RelocSectionSetExplicitly:=true;
  992. end;
  993. break;
  994. end;
  995. 'C':
  996. begin
  997. if UnsetBool(More, j) then
  998. apptype:=app_gui
  999. else
  1000. apptype:=app_cui;
  1001. end;
  1002. 'D':
  1003. begin
  1004. UseDeffileForExports:=not UnsetBool(More, j);
  1005. UseDeffileForExportsSetExplicitly:=true;
  1006. end;
  1007. 'F':
  1008. begin
  1009. if UnsetBool(More, j) then
  1010. apptype:=app_cui
  1011. else
  1012. apptype:=app_fs;
  1013. end;
  1014. 'G':
  1015. begin
  1016. if UnsetBool(More, j) then
  1017. apptype:=app_cui
  1018. else
  1019. apptype:=app_gui;
  1020. end;
  1021. 'T':
  1022. begin
  1023. if UnsetBool(More, j) then
  1024. apptype:=app_cui
  1025. else
  1026. apptype:=app_tool;
  1027. end;
  1028. 'N':
  1029. begin
  1030. RelocSection:=UnsetBool(More,j);
  1031. RelocSectionSetExplicitly:=true;
  1032. end;
  1033. 'R':
  1034. begin
  1035. { support -WR+ / -WR- as synonyms to -WR / -WN }
  1036. RelocSection:=not UnsetBool(More,j);
  1037. RelocSectionSetExplicitly:=true;
  1038. end;
  1039. else
  1040. IllegalPara(opt);
  1041. end;
  1042. inc(j);
  1043. end;
  1044. end;
  1045. 'X' :
  1046. begin
  1047. j:=1;
  1048. while j<=length(more) do
  1049. begin
  1050. case More[j] of
  1051. 'i' :
  1052. include(initglobalswitches,cs_link_internal);
  1053. 'm' :
  1054. include(initglobalswitches,cs_link_map);
  1055. 'f' :
  1056. include(initglobalswitches,cs_link_pthread);
  1057. 's' :
  1058. include(initglobalswitches,cs_link_strip);
  1059. 'c' : Cshared:=TRUE;
  1060. 't' :
  1061. include(initglobalswitches,cs_link_staticflag);
  1062. 'D' :
  1063. begin
  1064. def_system_macro('FPC_LINK_DYNAMIC');
  1065. undef_system_macro('FPC_LINK_SMART');
  1066. undef_system_macro('FPC_LINK_STATIC');
  1067. exclude(initglobalswitches,cs_link_static);
  1068. exclude(initglobalswitches,cs_link_smart);
  1069. include(initglobalswitches,cs_link_shared);
  1070. LinkTypeSetExplicitly:=true;
  1071. end;
  1072. 'd' : Dontlinkstdlibpath:=TRUE;
  1073. 'P' : Begin
  1074. utilsprefix:=Copy(more,2,length(More)-1);
  1075. More:='';
  1076. End;
  1077. 'r' : Begin
  1078. rlinkpath:=Copy(more,2,length(More)-1);
  1079. More:='';
  1080. end;
  1081. 'S' :
  1082. begin
  1083. def_system_macro('FPC_LINK_STATIC');
  1084. undef_system_macro('FPC_LINK_SMART');
  1085. undef_system_macro('FPC_LINK_DYNAMIC');
  1086. include(initglobalswitches,cs_link_static);
  1087. exclude(initglobalswitches,cs_link_smart);
  1088. exclude(initglobalswitches,cs_link_shared);
  1089. LinkTypeSetExplicitly:=true;
  1090. end;
  1091. 'X' :
  1092. begin
  1093. def_system_macro('FPC_LINK_SMART');
  1094. undef_system_macro('FPC_LINK_STATIC');
  1095. undef_system_macro('FPC_LINK_DYNAMIC');
  1096. exclude(initglobalswitches,cs_link_static);
  1097. include(initglobalswitches,cs_link_smart);
  1098. exclude(initglobalswitches,cs_link_shared);
  1099. LinkTypeSetExplicitly:=true;
  1100. end;
  1101. '-' :
  1102. begin
  1103. exclude(initglobalswitches,cs_link_staticflag);
  1104. exclude(initglobalswitches,cs_link_strip);
  1105. exclude(initglobalswitches,cs_link_map);
  1106. set_default_link_type;
  1107. end;
  1108. else
  1109. IllegalPara(opt);
  1110. end;
  1111. inc(j);
  1112. end;
  1113. end;
  1114. { give processor specific options a chance }
  1115. else
  1116. interpret_proc_specific_options(opt);
  1117. end;
  1118. end;
  1119. '@' :
  1120. begin
  1121. Message(option_no_nested_response_file);
  1122. StopOptions(1);
  1123. end;
  1124. else
  1125. begin
  1126. if (length(param_file)<>0) then
  1127. Message(option_only_one_source_support);
  1128. param_file:=opt;
  1129. Message1(option_found_file,opt);
  1130. end;
  1131. end;
  1132. end;
  1133. procedure Toption.Interpret_file(const filename : string);
  1134. procedure RemoveSep(var fn:string);
  1135. var
  1136. i : longint;
  1137. begin
  1138. i:=0;
  1139. while (i<length(fn)) and (fn[i+1] in [',',' ',#9]) do
  1140. inc(i);
  1141. Delete(fn,1,i);
  1142. i:=length(fn);
  1143. while (i>0) and (fn[i] in [',',' ',#9]) do
  1144. dec(i);
  1145. fn:=copy(fn,1,i);
  1146. end;
  1147. function GetName(var fn:string):string;
  1148. var
  1149. i : longint;
  1150. begin
  1151. i:=0;
  1152. while (i<length(fn)) and (fn[i+1] in ['a'..'z','A'..'Z','0'..'9','_','-']) do
  1153. inc(i);
  1154. GetName:=Copy(fn,1,i);
  1155. Delete(fn,1,i);
  1156. end;
  1157. const
  1158. maxlevel=16;
  1159. var
  1160. f : text;
  1161. s, tmp,
  1162. opts : string;
  1163. skip : array[0..maxlevel-1] of boolean;
  1164. level : longint;
  1165. option_read : boolean;
  1166. begin
  1167. { avoid infinite loop }
  1168. Inc(FileLevel);
  1169. Option_read:=false;
  1170. If FileLevel>MaxLevel then
  1171. Message(option_too_many_cfg_files);
  1172. { open file }
  1173. Message1(option_using_file,filename);
  1174. assign(f,FExpand(filename));
  1175. {$I-}
  1176. reset(f);
  1177. {$I+}
  1178. if ioresult<>0 then
  1179. begin
  1180. Message1(option_unable_open_file,filename);
  1181. exit;
  1182. end;
  1183. Message1(option_start_reading_configfile,filename);
  1184. fillchar(skip,sizeof(skip),0);
  1185. level:=0;
  1186. while not eof(f) do
  1187. begin
  1188. readln(f,opts);
  1189. RemoveSep(opts);
  1190. if (opts<>'') and (opts[1]<>';') then
  1191. begin
  1192. if opts[1]='#' then
  1193. begin
  1194. Message1(option_interpreting_file_option,opts);
  1195. Delete(opts,1,1);
  1196. s:=upper(GetName(opts));
  1197. if (s='SECTION') then
  1198. begin
  1199. RemoveSep(opts);
  1200. s:=upper(GetName(opts));
  1201. if level=0 then
  1202. skip[level]:=not (assigned(search_macro(s)) or (s='COMMON'));
  1203. end
  1204. else
  1205. if (s='IFDEF') then
  1206. begin
  1207. RemoveSep(opts);
  1208. if Level>=maxlevel then
  1209. begin
  1210. Message(option_too_many_ifdef);
  1211. stopOptions(1);
  1212. end;
  1213. inc(Level);
  1214. skip[level]:=(skip[level-1] or not assigned(search_macro(upper(GetName(opts)))));
  1215. end
  1216. else
  1217. if (s='IFNDEF') then
  1218. begin
  1219. RemoveSep(opts);
  1220. if Level>=maxlevel then
  1221. begin
  1222. Message(option_too_many_ifdef);
  1223. stopOptions(1);
  1224. end;
  1225. inc(Level);
  1226. skip[level]:=(skip[level-1] or assigned(search_macro(upper(GetName(opts)))));
  1227. end
  1228. else
  1229. if (s='ELSE') then
  1230. skip[level]:=skip[level-1] or (not skip[level])
  1231. else
  1232. if (s='ENDIF') then
  1233. begin
  1234. skip[level]:=false;
  1235. if Level=0 then
  1236. begin
  1237. Message(option_too_many_endif);
  1238. stopOptions(1);
  1239. end;
  1240. dec(level);
  1241. end
  1242. else
  1243. if (not skip[level]) then
  1244. begin
  1245. if (s='DEFINE') then
  1246. begin
  1247. RemoveSep(opts);
  1248. tmp:= GetName(opts);
  1249. if tmp <> '' then
  1250. def_system_macro(tmp);
  1251. end
  1252. else
  1253. if (s='UNDEF') then
  1254. begin
  1255. RemoveSep(opts);
  1256. tmp:= GetName(opts);
  1257. if tmp <> '' then
  1258. undef_system_macro(tmp);
  1259. end
  1260. else
  1261. if (s='WRITE') then
  1262. begin
  1263. Delete(opts,1,1);
  1264. WriteLn(opts);
  1265. end
  1266. else
  1267. if (s='INCLUDE') then
  1268. begin
  1269. Delete(opts,1,1);
  1270. Interpret_file(opts);
  1271. end;
  1272. end;
  1273. end
  1274. else
  1275. begin
  1276. if (opts[1]='-') or (opts[1]='@') then
  1277. begin
  1278. if (not skip[level]) then
  1279. interpret_option(opts,false);
  1280. Option_read:=true;
  1281. end
  1282. else
  1283. Message1(option_illegal_para,opts);
  1284. end;
  1285. end;
  1286. end;
  1287. if Level>0 then
  1288. Message(option_too_less_endif);
  1289. if Not Option_read then
  1290. Message1(option_no_option_found,filename)
  1291. else
  1292. Message1(option_end_reading_configfile,filename);
  1293. Close(f);
  1294. Dec(FileLevel);
  1295. end;
  1296. procedure Toption.Interpret_envvar(const envname : string);
  1297. var
  1298. argstart,
  1299. env,
  1300. pc : pchar;
  1301. arglen : longint;
  1302. quote : set of char;
  1303. hs : string;
  1304. begin
  1305. Message1(option_using_env,envname);
  1306. env:=GetEnvPChar(envname);
  1307. pc:=env;
  1308. if assigned(pc) then
  1309. begin
  1310. repeat
  1311. { skip leading spaces }
  1312. while pc^ in [' ',#9,#13] do
  1313. inc(pc);
  1314. case pc^ of
  1315. #0 :
  1316. break;
  1317. '"' :
  1318. begin
  1319. quote:=['"'];
  1320. inc(pc);
  1321. end;
  1322. '''' :
  1323. begin
  1324. quote:=[''''];
  1325. inc(pc);
  1326. end;
  1327. else
  1328. quote:=[' ',#9,#13];
  1329. end;
  1330. { scan until the end of the argument }
  1331. argstart:=pc;
  1332. while (pc^<>#0) and not(pc^ in quote) do
  1333. inc(pc);
  1334. { create argument }
  1335. arglen:=pc-argstart;
  1336. hs[0]:=chr(arglen);
  1337. move(argstart^,hs[1],arglen);
  1338. interpret_option(hs,true);
  1339. { skip quote }
  1340. if pc^ in quote then
  1341. inc(pc);
  1342. until false;
  1343. end
  1344. else
  1345. Message1(option_no_option_found,'(env) '+envname);
  1346. FreeEnvPChar(env);
  1347. end;
  1348. procedure toption.read_parameters;
  1349. var
  1350. opts : string;
  1351. paramindex : longint;
  1352. begin
  1353. paramindex:=0;
  1354. while paramindex<paramcount do
  1355. begin
  1356. inc(paramindex);
  1357. opts:=system.paramstr(paramindex);
  1358. case opts[1] of
  1359. '@' :
  1360. if not firstpass then
  1361. begin
  1362. Delete(opts,1,1);
  1363. Message1(option_reading_further_from,opts);
  1364. interpret_file(opts);
  1365. end;
  1366. '!' :
  1367. if not firstpass then
  1368. begin
  1369. Delete(opts,1,1);
  1370. Message1(option_reading_further_from,'(env) '+opts);
  1371. interpret_envvar(opts);
  1372. end;
  1373. else
  1374. interpret_option(opts,true);
  1375. end;
  1376. end;
  1377. end;
  1378. procedure toption.parsecmd(cmd:string);
  1379. var
  1380. i,ps : longint;
  1381. opts : string;
  1382. begin
  1383. while (cmd<>'') do
  1384. begin
  1385. while cmd[1]=' ' do
  1386. delete(cmd,1,1);
  1387. i:=pos(' ',cmd);
  1388. if i=0 then
  1389. i:=256;
  1390. opts:=Copy(cmd,1,i-1);
  1391. Delete(cmd,1,i);
  1392. case opts[1] of
  1393. '@' :
  1394. if not firstpass then
  1395. begin
  1396. Delete(opts,1,1);
  1397. Message1(option_reading_further_from,opts);
  1398. interpret_file(opts);
  1399. end;
  1400. '!' :
  1401. if not firstpass then
  1402. begin
  1403. Delete(opts,1,1);
  1404. Message1(option_reading_further_from,'(env) '+opts);
  1405. interpret_envvar(opts);
  1406. end;
  1407. '"' :
  1408. begin
  1409. Delete(opts,1,1);
  1410. ps:=pos('"',cmd);
  1411. if (i<>256) and (ps>0) then
  1412. begin
  1413. opts:=opts + ' '+ copy(cmd,1,ps-1);
  1414. cmd:=copy(cmd,ps+1,255);
  1415. end;
  1416. interpret_option(opts,true);
  1417. end;
  1418. else
  1419. interpret_option(opts,true);
  1420. end;
  1421. end;
  1422. end;
  1423. procedure toption.writequickinfo;
  1424. var
  1425. s : string;
  1426. i : longint;
  1427. procedure addinfo(const hs:string);
  1428. begin
  1429. if s<>'' then
  1430. s:=s+' '+hs
  1431. else
  1432. s:=hs;
  1433. end;
  1434. begin
  1435. s:='';
  1436. i:=0;
  1437. while (i<length(quickinfo)) do
  1438. begin
  1439. inc(i);
  1440. case quickinfo[i] of
  1441. 'S' :
  1442. begin
  1443. inc(i);
  1444. case quickinfo[i] of
  1445. 'O' :
  1446. addinfo(lower(source_info.shortname));
  1447. 'P' :
  1448. addinfo(source_cpu_string);
  1449. else
  1450. IllegalPara('-i'+QuickInfo);
  1451. end;
  1452. end;
  1453. 'T' :
  1454. begin
  1455. inc(i);
  1456. case quickinfo[i] of
  1457. 'O' :
  1458. addinfo(lower(target_info.shortname));
  1459. 'P' :
  1460. AddInfo(target_cpu_string);
  1461. else
  1462. IllegalPara('-i'+QuickInfo);
  1463. end;
  1464. end;
  1465. 'V' :
  1466. AddInfo(version_string);
  1467. 'D' :
  1468. AddInfo(date_string);
  1469. '_' :
  1470. ;
  1471. else
  1472. IllegalPara('-i'+QuickInfo);
  1473. end;
  1474. end;
  1475. if s<>'' then
  1476. begin
  1477. writeln(s);
  1478. stopoptions(0);
  1479. end;
  1480. end;
  1481. procedure TOption.TargetDefines(def:boolean);
  1482. var
  1483. s : string;
  1484. i : integer;
  1485. begin
  1486. if def then
  1487. def_system_macro(target_info.shortname)
  1488. else
  1489. undef_system_macro(target_info.shortname);
  1490. s:=target_info.extradefines;
  1491. while (s<>'') do
  1492. begin
  1493. i:=pos(';',s);
  1494. if i=0 then
  1495. i:=length(s)+1;
  1496. if def then
  1497. def_system_macro(Copy(s,1,i-1))
  1498. else
  1499. undef_system_macro(Copy(s,1,i-1));
  1500. delete(s,1,i);
  1501. end;
  1502. end;
  1503. constructor TOption.create;
  1504. begin
  1505. LogoWritten:=false;
  1506. NoPressEnter:=false;
  1507. FirstPass:=false;
  1508. FileLevel:=0;
  1509. Quickinfo:='';
  1510. ParaIncludePath:=TSearchPathList.Create;
  1511. ParaObjectPath:=TSearchPathList.Create;
  1512. ParaUnitPath:=TSearchPathList.Create;
  1513. ParaLibraryPath:=TSearchPathList.Create;
  1514. FillChar(ParaAlignment,sizeof(ParaAlignment),0);
  1515. end;
  1516. destructor TOption.destroy;
  1517. begin
  1518. ParaIncludePath.Free;
  1519. ParaObjectPath.Free;
  1520. ParaUnitPath.Free;
  1521. ParaLibraryPath.Free;
  1522. end;
  1523. {****************************************************************************
  1524. Callable Routines
  1525. ****************************************************************************}
  1526. function check_configfile(const fn:string;var foundfn:string):boolean;
  1527. function CfgFileExists(const fn:string):boolean;
  1528. begin
  1529. Comment(V_Tried,'Configfile search: '+fn);
  1530. CfgFileExists:=FileExists(fn);
  1531. end;
  1532. var
  1533. configpath : pathstr;
  1534. begin
  1535. foundfn:=fn;
  1536. check_configfile:=true;
  1537. { retrieve configpath }
  1538. {$IFDEF USE_SYSUTILS}
  1539. configpath:=FixPath(GetEnvironmentVariable('PPC_CONFIG_PATH'),false);
  1540. {$ELSE USE_SYSUTILS}
  1541. configpath:=FixPath(dos.getenv('PPC_CONFIG_PATH'),false);
  1542. {$ENDIF USE_SYSUTILS}
  1543. {$ifdef Unix}
  1544. if configpath='' then
  1545. configpath:=CleanPath(FixPath(exepath+'../etc/',false));
  1546. {$endif}
  1547. {
  1548. Order to read configuration file :
  1549. try reading fpc.cfg in :
  1550. 1 - current dir
  1551. 2 - configpath
  1552. 3 - compiler path
  1553. }
  1554. if not FileExists(fn) then
  1555. begin
  1556. {$ifdef Unix}
  1557. {$IFDEF USE_SYSUTILS}
  1558. if (GetEnvironmentVariable('HOME')<>'') and CfgFileExists(FixPath(GetEnvironmentVariable('HOME'),false)+'.'+fn) then
  1559. foundfn:=FixPath(GetEnvironmentVariable('HOME'),false)+'.'+fn
  1560. {$ELSE USE_SYSUTILS}
  1561. if (dos.getenv('HOME')<>'') and CfgFileExists(FixPath(dos.getenv('HOME'),false)+'.'+fn) then
  1562. foundfn:=FixPath(dos.getenv('HOME'),false)+'.'+fn
  1563. {$ENDIF USE_SYSUTILS}
  1564. else
  1565. {$endif}
  1566. if CfgFileExists(configpath+fn) then
  1567. foundfn:=configpath+fn
  1568. else
  1569. {$ifndef Unix}
  1570. if CfgFileExists(exepath+fn) then
  1571. foundfn:=exepath+fn
  1572. else
  1573. {$else}
  1574. if CfgFileExists('/etc/'+fn) then
  1575. foundfn:='/etc/'+fn
  1576. else
  1577. {$endif}
  1578. check_configfile:=false;
  1579. end;
  1580. end;
  1581. procedure read_arguments(cmd:string);
  1582. begin
  1583. option:=coption.create;
  1584. disable_configfile:=false;
  1585. { get default messagefile }
  1586. {$IFDEF USE_SYSUTILS}
  1587. msgfilename:=GetEnvironmentVariable('PPC_ERROR_FILE');
  1588. {$ELSE USE_SYSUTILS}
  1589. msgfilename:=dos.getenv('PPC_ERROR_FILE');
  1590. {$ENDIF USE_SYSUTILS}
  1591. { default configfile can be specified on the commandline,
  1592. remove it first }
  1593. if (cmd<>'') and (cmd[1]='[') then
  1594. begin
  1595. ppccfg:=Copy(cmd,2,pos(']',cmd)-2);
  1596. Delete(cmd,1,pos(']',cmd));
  1597. end
  1598. else
  1599. begin
  1600. ppccfg:='fpc.cfg';
  1601. ppcaltcfg:='ppc386.cfg';
  1602. end;
  1603. { first pass reading of parameters, only -i -v -T etc.}
  1604. option.firstpass:=true;
  1605. if cmd<>'' then
  1606. option.parsecmd(cmd)
  1607. else
  1608. begin
  1609. option.read_parameters;
  1610. { Write only quickinfo }
  1611. if option.quickinfo<>'' then
  1612. option.writequickinfo;
  1613. end;
  1614. option.firstpass:=false;
  1615. { default defines }
  1616. def_system_macro(target_info.shortname);
  1617. def_system_macro('FPC');
  1618. def_system_macro('VER'+version_nr);
  1619. def_system_macro('VER'+version_nr+'_'+release_nr);
  1620. def_system_macro('VER'+version_nr+'_'+release_nr+'_'+patch_nr);
  1621. { Temporary defines, until things settle down }
  1622. def_system_macro('HASWIDECHAR');
  1623. def_system_macro('HASWIDESTRING');
  1624. def_system_macro('HASOUT');
  1625. def_system_macro('HASGLOBALPROPERTY');
  1626. def_system_macro('FPC_HASPREFETCH');
  1627. def_system_macro('FPC_LINEEND_IN_TEXTREC');
  1628. def_system_macro('FPC_ALIGNSRTTI');
  1629. {$ifdef i386}
  1630. def_system_macro('HASINTF');
  1631. def_system_macro('HASVARIANT');
  1632. {$endif i386}
  1633. {$ifdef x86_64}
  1634. def_system_macro('HASINTF');
  1635. def_system_macro('HASVARIANT');
  1636. {$endif x86_64}
  1637. {$ifdef powerpc}
  1638. def_system_macro('HASINTF');
  1639. def_system_macro('HASVARIANT');
  1640. def_system_macro('FPC_MTFSB0_CORRECTED');
  1641. {$endif powerpc}
  1642. {$ifdef arm}
  1643. def_system_macro('HASINTF');
  1644. def_system_macro('HASVARIANT');
  1645. {$endif arm}
  1646. {$ifdef sparc}
  1647. def_system_macro('HASINTF');
  1648. def_system_macro('HASVARIANT');
  1649. {$endif sparc}
  1650. def_system_macro('INTERNSETLENGTH');
  1651. def_system_macro('INTERNLENGTH');
  1652. def_system_macro('INTERNCOPY');
  1653. def_system_macro('INT64FUNCRESOK');
  1654. def_system_macro('HAS_ADDR_STACK_ON_STACK');
  1655. def_system_macro('NOBOUNDCHECK');
  1656. def_system_macro('HASCOMPILERPROC');
  1657. def_system_macro('INTERNCONSTINTF');
  1658. def_system_macro('VALUEGETMEM');
  1659. def_system_macro('VALUEFREEMEM');
  1660. def_system_macro('HASCURRENCY');
  1661. def_system_macro('HASTHREADVAR');
  1662. def_system_macro('HAS_GENERICCONSTRUCTOR');
  1663. def_system_macro('NOCLASSHELPERS');
  1664. if pocall_default = pocall_register then
  1665. def_system_macro('REGCALL');
  1666. def_system_macro('DECRREFNOTNIL');
  1667. def_system_macro('HAS_INTERNAL_INTTYPES');
  1668. def_system_macro('STR_USES_VALINT');
  1669. def_system_macro('NOSAVEREGISTERS');
  1670. def_system_macro('SHORTSTRCOMPAREINREG');
  1671. def_system_macro('HASGETHEAPSTATUS');
  1672. { using a case is pretty useless here (FK) }
  1673. { some stuff for TP compatibility }
  1674. {$ifdef i386}
  1675. def_system_macro('CPU86');
  1676. def_system_macro('CPU87');
  1677. {$endif}
  1678. {$ifdef m68k}
  1679. def_system_macro('CPU68');
  1680. {$endif}
  1681. { new processor stuff }
  1682. {$ifdef i386}
  1683. def_system_macro('CPUI386');
  1684. def_system_macro('CPU32');
  1685. def_system_macro('FPC_HAS_TYPE_EXTENDED');
  1686. def_system_macro('FPC_HAS_TYPE_DOUBLE');
  1687. def_system_macro('FPC_HAS_TYPE_SINGLE');
  1688. {$endif}
  1689. {$ifdef m68k}
  1690. def_system_macro('CPU68K');
  1691. def_system_macro('CPUM68K');
  1692. def_system_macro('CPU32');
  1693. def_system_macro('FPC_CURRENCY_IS_INT64');
  1694. def_system_macro('FPC_COMP_IS_INT64');
  1695. {$endif}
  1696. {$ifdef ALPHA}
  1697. def_system_macro('CPUALPHA');
  1698. def_system_macro('CPU64');
  1699. {$endif}
  1700. {$ifdef powerpc}
  1701. def_system_macro('CPUPOWERPC');
  1702. def_system_macro('CPUPOWERPC32');
  1703. def_system_macro('CPU32');
  1704. def_system_macro('FPC_HAS_TYPE_DOUBLE');
  1705. def_system_macro('FPC_HAS_TYPE_SINGLE');
  1706. def_system_macro('FPC_INCLUDE_SOFTWARE_INT64_TO_DOUBLE');
  1707. def_system_macro('FPC_CURRENCY_IS_INT64');
  1708. def_system_macro('FPC_COMP_IS_INT64');
  1709. {$endif}
  1710. {$ifdef iA64}
  1711. def_system_macro('CPUIA64');
  1712. def_system_macro('CPU64');
  1713. {$endif}
  1714. {$ifdef x86_64}
  1715. def_system_macro('CPUX86_64');
  1716. def_system_macro('CPUAMD64');
  1717. def_system_macro('CPU64');
  1718. { not supported for now, afaik (FK)
  1719. def_system_macro('FPC_HAS_TYPE_FLOAT128'); }
  1720. def_system_macro('FPC_HAS_TYPE_EXTENDED');
  1721. def_system_macro('FPC_HAS_TYPE_DOUBLE');
  1722. def_system_macro('FPC_HAS_TYPE_SINGLE');
  1723. {$endif}
  1724. {$ifdef sparc}
  1725. def_system_macro('CPUSPARC');
  1726. def_system_macro('CPUSPARC32');
  1727. def_system_macro('CPU32');
  1728. def_system_macro('FPC_HAS_TYPE_DOUBLE');
  1729. def_system_macro('FPC_HAS_TYPE_SINGLE');
  1730. def_system_macro('FPC_INCLUDE_SOFTWARE_INT64_TO_DOUBLE');
  1731. def_system_macro('FPC_CURRENCY_IS_INT64');
  1732. def_system_macro('FPC_COMP_IS_INT64');
  1733. def_system_macro('FPC_REQUIRES_PROPER_ALIGNMENT');
  1734. {$endif}
  1735. {$ifdef vis}
  1736. def_system_macro('CPUVIS');
  1737. def_system_macro('CPU32');
  1738. {$endif}
  1739. {$ifdef arm}
  1740. def_system_macro('CPUARM');
  1741. def_system_macro('FPUFPA');
  1742. def_system_macro('CPU32');
  1743. def_system_macro('FPC_HAS_TYPE_DOUBLE');
  1744. def_system_macro('FPC_HAS_TYPE_SINGLE');
  1745. def_system_macro('FPC_INCLUDE_SOFTWARE_INT64_TO_DOUBLE');
  1746. def_system_macro('FPC_CURRENCY_IS_INT64');
  1747. def_system_macro('FPC_COMP_IS_INT64');
  1748. def_system_macro('FPC_REQUIRES_PROPER_ALIGNMENT');
  1749. {$endif arm}
  1750. { read configuration file }
  1751. if (not disable_configfile) and
  1752. (ppccfg<>'') then
  1753. begin
  1754. read_configfile:=check_configfile(ppccfg,ppccfg);
  1755. { Maybe alternative configfile ? }
  1756. if (not read_configfile) and
  1757. (ppcaltcfg<>'') then
  1758. read_configfile:=check_configfile(ppcaltcfg,ppccfg);
  1759. end
  1760. else
  1761. read_configfile := false;
  1762. { Read commandline and configfile }
  1763. target_is_set:=false;
  1764. asm_is_set:=false;
  1765. param_file:='';
  1766. { read configfile }
  1767. if read_configfile then
  1768. option.interpret_file(ppccfg);
  1769. { read parameters again to override config file }
  1770. if cmd<>'' then
  1771. option.parsecmd(cmd)
  1772. else
  1773. begin
  1774. option.read_parameters;
  1775. { Write only quickinfo }
  1776. if option.quickinfo<>'' then
  1777. option.writequickinfo;
  1778. end;
  1779. { Write help pages }
  1780. if (cmd='') and (paramcount=0) then
  1781. Option.WriteHelpPages;
  1782. { Stop if errors in options }
  1783. if ErrorCount>0 then
  1784. StopOptions(1);
  1785. { Non-core target defines }
  1786. Option.TargetDefines(true);
  1787. { endian define }
  1788. case target_info.endian of
  1789. endian_little :
  1790. begin
  1791. def_system_macro('ENDIAN_LITTLE');
  1792. def_system_macro('FPC_LITTLE_ENDIAN');
  1793. end;
  1794. endian_big :
  1795. begin
  1796. def_system_macro('ENDIAN_BIG');
  1797. def_system_macro('FPC_BIG_ENDIAN');
  1798. end;
  1799. end;
  1800. { abi define }
  1801. case target_info.abi of
  1802. abi_powerpc_sysv :
  1803. def_system_macro('FPC_ABI_SYSV');
  1804. abi_powerpc_aix :
  1805. def_system_macro('FPC_ABI_AIX');
  1806. end;
  1807. {$ifdef m68k}
  1808. if initoptprocessor=MC68020 then
  1809. def_system_macro('CPUM68020');
  1810. {$endif m68k}
  1811. { Check file to compile }
  1812. if param_file='' then
  1813. begin
  1814. Message(option_no_source_found);
  1815. StopOptions(1);
  1816. end;
  1817. {$ifndef Unix}
  1818. param_file:=FixFileName(param_file);
  1819. {$endif}
  1820. {$IFDEF USE_SYSUTILS}
  1821. inputdir := SplitPath(param_file);
  1822. inputfile := SplitName(param_file);
  1823. inputextension := SplitExtension(param_file);
  1824. {$ELSE USE_SYSUTILS}
  1825. fsplit(param_file,inputdir,inputfile,inputextension);
  1826. {$ENDIF USE_SYSUTILS}
  1827. if inputextension='' then
  1828. begin
  1829. if FileExists(inputdir+inputfile+target_info.sourceext) then
  1830. inputextension:=target_info.sourceext
  1831. else if FileExists(inputdir+inputfile+target_info.pasext) then
  1832. inputextension:=target_info.pasext
  1833. else if (m_mac in aktmodeswitches) and FileExists(inputdir+inputfile+'.p') then
  1834. inputextension:='.p';
  1835. end;
  1836. { Check output dir }
  1837. if (OutputExeDir<>'') and
  1838. not PathExists(OutputExeDir) then
  1839. begin
  1840. Message1(general_e_path_does_not_exist,OutputExeDir);
  1841. StopOptions(1);
  1842. end;
  1843. { Add paths specified with parameters to the searchpaths }
  1844. UnitSearchPath.AddList(option.ParaUnitPath,true);
  1845. ObjectSearchPath.AddList(option.ParaObjectPath,true);
  1846. IncludeSearchPath.AddList(option.ParaIncludePath,true);
  1847. LibrarySearchPath.AddList(option.ParaLibraryPath,true);
  1848. { add unit environment and exepath to the unit search path }
  1849. if inputdir<>'' then
  1850. Unitsearchpath.AddPath(inputdir,true);
  1851. if not disable_configfile then
  1852. begin
  1853. {$IFDEF USE_SYSUTILS}
  1854. UnitSearchPath.AddPath(GetEnvironmentVariable(target_info.unit_env),false);
  1855. {$ELSE USE_SYSUTILS}
  1856. UnitSearchPath.AddPath(dos.getenv(target_info.unit_env),false);
  1857. {$ENDIF USE_SYSUTILS}
  1858. end;
  1859. {$ifdef Unix}
  1860. {$IFDEF USE_SYSUTILS}
  1861. fpcdir:=FixPath(GetEnvironmentVariable('FPCDIR'),false);
  1862. {$ELSE USE_SYSUTILS}
  1863. fpcdir:=FixPath(getenv('FPCDIR'),false);
  1864. {$ENDIF USE_SYSUTILS}
  1865. if fpcdir='' then
  1866. begin
  1867. if PathExists('/usr/local/lib/fpc/'+version_string) then
  1868. fpcdir:='/usr/local/lib/fpc/'+version_string+'/'
  1869. else
  1870. fpcdir:='/usr/lib/fpc/'+version_string+'/';
  1871. end;
  1872. {$else}
  1873. {$IFDEF USE_SYSUTILS}
  1874. fpcdir:=FixPath(GetEnvironmentVariable('FPCDIR'),false);
  1875. {$ELSE USE_SYSUTILS}
  1876. fpcdir:=FixPath(getenv('FPCDIR'),false);
  1877. {$ENDIF USE_SYSUTILS}
  1878. if fpcdir='' then
  1879. begin
  1880. fpcdir:=ExePath+'../';
  1881. if not(PathExists(fpcdir+'/units')) and
  1882. not(PathExists(fpcdir+'/rtl')) then
  1883. fpcdir:=fpcdir+'../';
  1884. end;
  1885. {$endif}
  1886. { first try development RTL, else use the default installation path }
  1887. if not disable_configfile then
  1888. begin
  1889. if PathExists(FpcDir+'rtl') then
  1890. if tf_use_8_3 in Source_Info.Flags then
  1891. UnitSearchPath.AddPath(FpcDir+'rtl/'+target_os_string,false)
  1892. else
  1893. UnitSearchPath.AddPath(FpcDir+'rtl/'+target_full_string,false)
  1894. else
  1895. if tf_use_8_3 in Source_Info.Flags then
  1896. UnitSearchPath.AddPath(FpcDir+'units/'+target_os_string+'/rtl',false)
  1897. else
  1898. UnitSearchPath.AddPath(FpcDir+'units/'+target_full_string+'/rtl',false);
  1899. end;
  1900. { Add exepath if the exe is not in the current dir, because that is always searched already.
  1901. Do not add it when linking on the target because then we can maybe already find
  1902. .o files that are not for the target }
  1903. if (ExePath<>GetCurrentDir) and
  1904. not(cs_link_on_target in initglobalswitches) then
  1905. UnitSearchPath.AddPath(ExePath,false);
  1906. { Add unit dir to the object and library path }
  1907. objectsearchpath.AddList(unitsearchpath,false);
  1908. librarysearchpath.AddList(unitsearchpath,false);
  1909. { switch assembler if it's binary and we got -a on the cmdline }
  1910. if (cs_asm_leave in initglobalswitches) and
  1911. (af_outputbinary in target_asm.flags) then
  1912. begin
  1913. Message(option_switch_bin_to_src_assembler);
  1914. set_target_asm(target_info.assemextern);
  1915. end;
  1916. if (target_asm.supported_target <> system_any) and
  1917. (target_asm.supported_target <> target_info.system) then
  1918. begin
  1919. Message2(option_incompatible_asm,target_asm.idtxt,target_info.name);
  1920. set_target_asm(target_info.assemextern);
  1921. Message1(option_asm_forced,target_asm.idtxt);
  1922. end;
  1923. { turn off stripping if compiling with debuginfo or profile }
  1924. if (cs_debuginfo in initmoduleswitches) or
  1925. (cs_profile in initmoduleswitches) then
  1926. exclude(initglobalswitches,cs_link_strip);
  1927. {$ifdef x86_64}
  1928. {$warning HACK: turn off smartlinking}
  1929. exclude(initmoduleswitches,cs_create_smart);
  1930. {$endif}
  1931. if not LinkTypeSetExplicitly then
  1932. set_default_link_type;
  1933. { Default alignment settings,
  1934. 1. load the defaults for the target
  1935. 2. override with generic optimizer setting (little size)
  1936. 3. override with the user specified -Oa }
  1937. UpdateAlignment(initalignment,target_info.alignment);
  1938. if (cs_littlesize in aktglobalswitches) then
  1939. begin
  1940. initalignment.procalign:=1;
  1941. initalignment.jumpalign:=1;
  1942. initalignment.loopalign:=1;
  1943. end;
  1944. UpdateAlignment(initalignment,option.paraalignment);
  1945. set_system_macro('FPC_VERSION',version_nr);
  1946. set_system_macro('FPC_RELEASE',release_nr);
  1947. set_system_macro('FPC_PATCH',patch_nr);
  1948. option.free;
  1949. Option:=nil;
  1950. end;
  1951. initialization
  1952. coption:=toption;
  1953. finalization
  1954. if assigned(option) then
  1955. option.free;
  1956. end.
  1957. {
  1958. $Log$
  1959. Revision 1.162 2005-01-20 17:05:53 peter
  1960. * use val() for decoding integers
  1961. Revision 1.161 2005/01/09 20:24:43 olle
  1962. * rework of macro subsystem
  1963. + exportable macros for mode macpas
  1964. Revision 1.160 2005/01/08 23:14:50 peter
  1965. * Allow #include ~/.fpc.cfg
  1966. Revision 1.159 2005/01/04 16:19:52 florian
  1967. * arm sets FPUFPA by default for now
  1968. Revision 1.158 2005/01/03 20:27:47 peter
  1969. fix outline of 3rd level of options (-SI option mainly)
  1970. Revision 1.157 2004/12/28 20:43:01 hajny
  1971. * 8.3 fixes (short target name in paths)
  1972. Revision 1.156 2004/12/16 08:06:42 marco
  1973. * slash typo
  1974. Revision 1.155 2004/12/15 16:06:47 marco
  1975. * introduction "cleanpath" (=fexpand), fixfilename(paramstr(0)) + search $PREFIX/etc/fpc.cfg
  1976. Revision 1.154 2004/11/22 19:34:58 peter
  1977. * GetHeapStatus added, removed MaxAvail,MemAvail,HeapSize
  1978. Revision 1.153 2004/11/17 22:21:35 peter
  1979. mangledname setting moved to place after the complete proc declaration is read
  1980. import generation moved to place where body is also parsed (still gives problems with win32)
  1981. Revision 1.152 2004/11/01 12:43:28 peter
  1982. * shortstr compare with empty string fixed
  1983. * removed special i386 code
  1984. Revision 1.151 2004/10/31 19:09:54 peter
  1985. * default paths fixed
  1986. Revision 1.150 2004/10/26 15:11:01 peter
  1987. * -Ch for heapsize added again
  1988. * __heapsize contains the heapsize
  1989. Revision 1.149 2004/10/25 15:38:41 peter
  1990. * heap and heapsize removed
  1991. * checkpointer fixes
  1992. Revision 1.148 2004/10/24 20:01:08 peter
  1993. * remove saveregister calling convention
  1994. Revision 1.147 2004/10/15 09:14:17 mazen
  1995. - remove $IFDEF DELPHI and related code
  1996. - remove $IFDEF FPCPROCVAR and related code
  1997. Revision 1.146 2004/10/14 14:03:02 mazen
  1998. * Merge is complete for this file, cycles !
  1999. Revision 1.145 2004/10/05 20:21:02 florian
  2000. * bootstrapping with rtti alignment fixed
  2001. Revision 1.144 2004/09/21 23:33:43 hajny
  2002. * better PathExists, fix for too long command line, correction of message
  2003. Revision 1.143 2004/09/21 17:25:12 peter
  2004. * paraloc branch merged
  2005. Revision 1.142 2004/09/16 16:31:53 peter
  2006. * Use FExpand on paths passed to compiler
  2007. Revision 1.141 2004/09/10 21:00:23 jonas
  2008. * exit with exit code 0 instead of 1 after writing out quick options
  2009. (such as -iV)
  2010. Revision 1.140 2004/09/08 11:23:31 michael
  2011. + Check if outputdir exists, Fix exitcode when displaying help pages
  2012. Revision 1.139.4.1 2004/09/19 20:53:33 peter
  2013. * fixed compile without gdb
  2014. Revision 1.139 2004/08/27 21:59:26 peter
  2015. browser disabled
  2016. uf_local_symtable ppu flag when a localsymtable is stored
  2017. Revision 1.138 2004/07/05 21:26:28 olle
  2018. + allow fileextension .p, in mode macpas
  2019. Revision 1.137 2004/07/04 12:24:04 jonas
  2020. * fixed "-g-l" (and other "-g-*" combinations)
  2021. Revision 1.136 2004/06/20 08:55:30 florian
  2022. * logs truncated
  2023. Revision 1.135 2004/06/16 20:07:09 florian
  2024. * dwarf branch merged
  2025. Revision 1.134 2004/05/06 20:30:51 florian
  2026. * m68k compiler compilation fixed
  2027. Revision 1.133.2.10 2004/05/18 20:24:03 florian
  2028. * fixed crash with unknown symbols
  2029. Revision 1.133.2.9 2004/05/13 20:10:38 florian
  2030. * released variant and interface support
  2031. Revision 1.133.2.8 2004/05/03 14:59:57 peter
  2032. * no dlltool needed for win32 linking executables
  2033. }