options.pas 62 KB

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