options.pas 62 KB

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