options.pas 62 KB

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