options.pas 62 KB

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