options.pas 63 KB

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