options.pas 63 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141
  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. CClasses,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,scanner
  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. 'g' :
  726. begin
  727. { ignore for compatibility,
  728. the code for dbx and gsym is broken }
  729. end;
  730. 'h' :
  731. begin
  732. if UnsetBool(More, j) then
  733. exclude(initglobalswitches,cs_gdb_heaptrc)
  734. else
  735. include(initglobalswitches,cs_gdb_heaptrc);
  736. end;
  737. 'l' :
  738. begin
  739. if UnsetBool(More, j) then
  740. exclude(initglobalswitches,cs_gdb_lineinfo)
  741. else
  742. include(initglobalswitches,cs_gdb_lineinfo);
  743. end;
  744. 'c' :
  745. begin
  746. if UnsetBool(More, j) then
  747. exclude(initlocalswitches,cs_checkpointer)
  748. else
  749. include(initlocalswitches,cs_checkpointer);
  750. end;
  751. 'v' :
  752. begin
  753. if UnsetBool(More, j) then
  754. exclude(initglobalswitches,cs_gdb_valgrind)
  755. else
  756. include(initglobalswitches,cs_gdb_valgrind);
  757. end;
  758. 'w' :
  759. begin
  760. if UnsetBool(More, j) then
  761. exclude(initglobalswitches,cs_gdb_dwarf)
  762. else
  763. include(initglobalswitches,cs_gdb_dwarf);
  764. end;
  765. else
  766. IllegalPara(opt);
  767. end;
  768. inc(j);
  769. end;
  770. {$endif GDB}
  771. end;
  772. 'h' :
  773. begin
  774. NoPressEnter:=true;
  775. WriteHelpPages;
  776. end;
  777. 'i' :
  778. begin
  779. if More='' then
  780. WriteInfo
  781. else
  782. QuickInfo:=QuickInfo+More;
  783. end;
  784. 'I' :
  785. begin
  786. if ispara then
  787. ParaIncludePath.AddPath(More,false)
  788. else
  789. includesearchpath.AddPath(More,false);
  790. end;
  791. 'k' :
  792. begin
  793. if more<>'' then
  794. ParaLinkOptions:=ParaLinkOptions+' '+More
  795. else
  796. IllegalPara(opt);
  797. end;
  798. 'l' :
  799. if not UnSetBool(more,0) then
  800. ParaLogo:=true;
  801. 'm' :
  802. parapreprocess:=not UnSetBool(more,0);
  803. 'M' :
  804. begin
  805. more:=Upper(more);
  806. if not SetCompileMode(more, true) then
  807. IllegalPara(opt);
  808. end;
  809. 'n' :
  810. begin
  811. if More='' then
  812. disable_configfile:=true
  813. else
  814. IllegalPara(opt);
  815. end;
  816. 'o' :
  817. begin
  818. if More<>'' then
  819. begin
  820. DefaultReplacements(More);
  821. {$IFDEF USE_SYSUTILS}
  822. D:=SplitPath(More);
  823. OutputFile:=SplitFileName(More);
  824. OutputExtension:=SplitExtension(More);
  825. {$ELSE USE_SYSUTILS}
  826. FSplit(More,D,OutputFile,OutputExtension);
  827. {$ENDIF USE_SYSUTILS}
  828. if (D<>'') then
  829. OutputExeDir:=FixPath(D,True);
  830. end
  831. else
  832. IllegalPara(opt);
  833. end;
  834. 'p' :
  835. begin
  836. if UnsetBool(More, 0) then
  837. begin
  838. initmoduleswitches:=initmoduleswitches-[cs_profile];
  839. undef_system_macro('FPC_PROFILE');
  840. end
  841. else
  842. if Length(More)=0 then
  843. IllegalPara(opt)
  844. else
  845. case more[1] of
  846. 'g' : if UnsetBool(more, 1) then
  847. begin
  848. exclude(initmoduleswitches,cs_profile);
  849. undef_system_macro('FPC_PROFILE');
  850. end
  851. else
  852. begin
  853. include(initmoduleswitches,cs_profile);
  854. def_system_macro('FPC_PROFILE');
  855. end;
  856. else
  857. IllegalPara(opt);
  858. end;
  859. end;
  860. 'P' : ; { Ignore used by fpc.pp }
  861. 's' :
  862. begin
  863. if UnsetBool(More, 0) then
  864. begin
  865. initglobalswitches:=initglobalswitches-[cs_asm_extern,cs_link_extern];
  866. if more<>'' then
  867. IllegalPara(opt);
  868. end
  869. else
  870. begin
  871. initglobalswitches:=initglobalswitches+[cs_asm_extern,cs_link_extern];
  872. if more='h' then
  873. initglobalswitches:=initglobalswitches-[cs_link_on_target]
  874. else if more='t' then
  875. initglobalswitches:=initglobalswitches+[cs_link_on_target]
  876. else if more='r' then
  877. initglobalswitches:=initglobalswitches+[cs_asm_leave,cs_no_regalloc]
  878. else if more<>'' then
  879. IllegalPara(opt);
  880. end;
  881. end;
  882. 'S' :
  883. begin
  884. if more[1]='I' then
  885. begin
  886. if upper(more)='ICOM' then
  887. initinterfacetype:=it_interfacecom
  888. else if upper(more)='ICORBA' then
  889. initinterfacetype:=it_interfacecorba
  890. else
  891. IllegalPara(opt);
  892. end
  893. else
  894. begin
  895. j:=1;
  896. while j<=length(more) do
  897. begin
  898. case more[j] of
  899. '2' : //an alternative to -Mobjfpc
  900. SetCompileMode('OBJFPC',true);
  901. 'a' :
  902. include(initlocalswitches,cs_do_assertion);
  903. 'c' :
  904. include(initmoduleswitches,cs_support_c_operators);
  905. 'd' : //an alternative to -Mdelphi
  906. SetCompileMode('DELPHI',true);
  907. 'e' :
  908. begin
  909. SetErrorFlags(copy(more,j+1,length(more)));
  910. break;
  911. end;
  912. 'f' :
  913. include(initlocalswitches,cs_formal_annotation);
  914. 'g' :
  915. include(initmoduleswitches,cs_support_goto);
  916. 'h' :
  917. include(initlocalswitches,cs_ansistrings);
  918. 'i' :
  919. include(initmoduleswitches,cs_support_inline);
  920. 'k' :
  921. include(initglobalswitches,cs_load_fpcylix_unit);
  922. 'm' :
  923. include(initmoduleswitches,cs_support_macro);
  924. 'o' : //an alternative to -Mtp
  925. SetCompileMode('TP',true);
  926. 'p' : //an alternative to -Mgpc
  927. SetCompileMode('GPC',true);
  928. 's' :
  929. include(initglobalswitches,cs_constructor_name);
  930. 't' :
  931. include(initmoduleswitches,cs_static_keyword);
  932. '-' :
  933. begin
  934. exclude(initglobalswitches,cs_constructor_name);
  935. initlocalswitches:=InitLocalswitches - [cs_do_assertion, cs_ansistrings];
  936. initmoduleswitches:=initmoduleswitches - [cs_support_c_operators, cs_support_goto,
  937. cs_support_inline, cs_support_macro,
  938. cs_static_keyword];
  939. end;
  940. else
  941. IllegalPara(opt);
  942. end;
  943. inc(j);
  944. end;
  945. end;
  946. end;
  947. 'T' :
  948. begin
  949. more:=Upper(More);
  950. if not target_is_set then
  951. begin
  952. { remove old target define }
  953. TargetDefines(false);
  954. { Save assembler if set }
  955. if asm_is_set then
  956. forceasm:=target_asm.id;
  957. { load new target }
  958. if not(set_target_by_string(More)) then
  959. IllegalPara(opt);
  960. { also initialize assembler if not explicitly set }
  961. if asm_is_set then
  962. set_target_asm(forceasm);
  963. { set new define }
  964. TargetDefines(true);
  965. target_is_set:=true;
  966. end
  967. else
  968. if More<>upper(target_info.shortname) then
  969. Message1(option_target_is_already_set,target_info.shortname);
  970. end;
  971. 'u' :
  972. if more <> '' then
  973. undef_system_macro(more);
  974. 'U' :
  975. begin
  976. j:=1;
  977. while j<=length(more) do
  978. begin
  979. case more[j] of
  980. {$ifdef UNITALIASES}
  981. 'a' :
  982. begin
  983. AddUnitAlias(Copy(More,j+1,255));
  984. break;
  985. end;
  986. {$endif UNITALIASES}
  987. 'n' :
  988. exclude(initglobalswitches,cs_check_unit_name);
  989. 'p' :
  990. begin
  991. Message2(option_obsolete_switch_use_new,'-Up','-Fu');
  992. break;
  993. end;
  994. 'r' :
  995. do_release:=true;
  996. 's' :
  997. include(initmoduleswitches,cs_compilesystem);
  998. '-' :
  999. begin
  1000. exclude(initmoduleswitches,cs_compilesystem);
  1001. exclude(initglobalswitches,cs_check_unit_name);
  1002. end;
  1003. else
  1004. IllegalPara(opt);
  1005. end;
  1006. inc(j);
  1007. end;
  1008. end;
  1009. 'v' :
  1010. begin
  1011. if not setverbosity(More) then
  1012. IllegalPara(opt);
  1013. end;
  1014. 'V' : ; { Ignore used by fpc }
  1015. 'W' :
  1016. begin
  1017. j:=1;
  1018. while j<=length(More) do
  1019. begin
  1020. case More[j] of
  1021. 'B':
  1022. begin
  1023. { -WB200000 means set trefered base address
  1024. to $200000, but does not change relocsection boolean
  1025. this way we can create both relocatble and
  1026. non relocatable DLL at a specific base address PM }
  1027. if (length(More)>j) then
  1028. begin
  1029. if DLLImageBase=nil then
  1030. DLLImageBase:=StringDup(Copy(More,j+1,255));
  1031. end
  1032. else
  1033. begin
  1034. RelocSection:=true;
  1035. RelocSectionSetExplicitly:=true;
  1036. end;
  1037. break;
  1038. end;
  1039. 'C':
  1040. begin
  1041. if UnsetBool(More, j) then
  1042. apptype:=app_gui
  1043. else
  1044. apptype:=app_cui;
  1045. end;
  1046. 'D':
  1047. begin
  1048. UseDeffileForExports:=not UnsetBool(More, j);
  1049. UseDeffileForExportsSetExplicitly:=true;
  1050. end;
  1051. 'F':
  1052. begin
  1053. if UnsetBool(More, j) then
  1054. apptype:=app_cui
  1055. else
  1056. apptype:=app_fs;
  1057. end;
  1058. 'G':
  1059. begin
  1060. if UnsetBool(More, j) then
  1061. apptype:=app_cui
  1062. else
  1063. apptype:=app_gui;
  1064. end;
  1065. 'T':
  1066. begin
  1067. if UnsetBool(More, j) then
  1068. apptype:=app_cui
  1069. else
  1070. apptype:=app_tool;
  1071. end;
  1072. 'N':
  1073. begin
  1074. RelocSection:=UnsetBool(More,j);
  1075. RelocSectionSetExplicitly:=true;
  1076. end;
  1077. 'R':
  1078. begin
  1079. { support -WR+ / -WR- as synonyms to -WR / -WN }
  1080. RelocSection:=not UnsetBool(More,j);
  1081. RelocSectionSetExplicitly:=true;
  1082. end;
  1083. else
  1084. IllegalPara(opt);
  1085. end;
  1086. inc(j);
  1087. end;
  1088. end;
  1089. 'X' :
  1090. begin
  1091. j:=1;
  1092. while j<=length(more) do
  1093. begin
  1094. case More[j] of
  1095. 'i' :
  1096. include(initglobalswitches,cs_link_internal);
  1097. 'm' :
  1098. include(initglobalswitches,cs_link_map);
  1099. 'f' :
  1100. include(initglobalswitches,cs_link_pthread);
  1101. 's' :
  1102. include(initglobalswitches,cs_link_strip);
  1103. 'c' : Cshared:=TRUE;
  1104. 't' :
  1105. include(initglobalswitches,cs_link_staticflag);
  1106. 'D' :
  1107. begin
  1108. def_system_macro('FPC_LINK_DYNAMIC');
  1109. undef_system_macro('FPC_LINK_SMART');
  1110. undef_system_macro('FPC_LINK_STATIC');
  1111. exclude(initglobalswitches,cs_link_static);
  1112. exclude(initglobalswitches,cs_link_smart);
  1113. include(initglobalswitches,cs_link_shared);
  1114. LinkTypeSetExplicitly:=true;
  1115. end;
  1116. 'd' : Dontlinkstdlibpath:=TRUE;
  1117. 'P' : Begin
  1118. utilsprefix:=Copy(more,2,length(More)-1);
  1119. DefaultReplacements(utilsprefix);
  1120. More:='';
  1121. End;
  1122. 'r' : Begin
  1123. rlinkpath:=Copy(more,2,length(More)-1);
  1124. DefaultReplacements(rlinkpath);
  1125. More:='';
  1126. end;
  1127. 'L' : begin // -XLO is link order -XLA is link alias. -XLD avoids load defaults.
  1128. // these are not aggregable.
  1129. if (j=length(more)) or not (more[j+1] in ['O','A','D']) then
  1130. IllegalPara(opt)
  1131. else
  1132. begin
  1133. case more[j+1] of
  1134. 'A' : begin
  1135. s:=Copy(more,3,length(More)-2);
  1136. if not LinkLibraryAliases.AddDep(s) Then
  1137. IllegalPara(opt);
  1138. end;
  1139. 'O' : begin
  1140. s:=Copy(more,3,length(More)-2);
  1141. if not LinkLibraryOrder.AddWeight(s) Then
  1142. IllegalPara(opt);
  1143. end;
  1144. 'D' : include(initglobalswitches,cs_link_no_default_lib_order)
  1145. else
  1146. IllegalPara(opt);
  1147. end; {case}
  1148. j:=length(more);
  1149. end; {else begin}
  1150. end;
  1151. 'S' :
  1152. begin
  1153. def_system_macro('FPC_LINK_STATIC');
  1154. undef_system_macro('FPC_LINK_SMART');
  1155. undef_system_macro('FPC_LINK_DYNAMIC');
  1156. include(initglobalswitches,cs_link_static);
  1157. exclude(initglobalswitches,cs_link_smart);
  1158. exclude(initglobalswitches,cs_link_shared);
  1159. LinkTypeSetExplicitly:=true;
  1160. end;
  1161. 'X' :
  1162. begin
  1163. def_system_macro('FPC_LINK_SMART');
  1164. undef_system_macro('FPC_LINK_STATIC');
  1165. undef_system_macro('FPC_LINK_DYNAMIC');
  1166. exclude(initglobalswitches,cs_link_static);
  1167. include(initglobalswitches,cs_link_smart);
  1168. exclude(initglobalswitches,cs_link_shared);
  1169. LinkTypeSetExplicitly:=true;
  1170. end;
  1171. 'M' :
  1172. begin
  1173. mainaliasname:=Copy(more,2,length(More)-1);
  1174. More:='';
  1175. end;
  1176. '-' :
  1177. begin
  1178. exclude(initglobalswitches,cs_link_staticflag);
  1179. exclude(initglobalswitches,cs_link_strip);
  1180. exclude(initglobalswitches,cs_link_map);
  1181. set_default_link_type;
  1182. end;
  1183. else
  1184. IllegalPara(opt);
  1185. end;
  1186. inc(j);
  1187. end;
  1188. end;
  1189. { give processor specific options a chance }
  1190. else
  1191. interpret_proc_specific_options(opt);
  1192. end;
  1193. end;
  1194. '@' :
  1195. begin
  1196. Message(option_no_nested_response_file);
  1197. StopOptions(1);
  1198. end;
  1199. else
  1200. begin
  1201. if (length(param_file)<>0) then
  1202. Message(option_only_one_source_support);
  1203. param_file:=opt;
  1204. Message1(option_found_file,opt);
  1205. end;
  1206. end;
  1207. end;
  1208. procedure Toption.Interpret_file(const filename : string);
  1209. procedure RemoveSep(var fn:string);
  1210. var
  1211. i : longint;
  1212. begin
  1213. i:=0;
  1214. while (i<length(fn)) and (fn[i+1] in [',',' ',#9]) do
  1215. inc(i);
  1216. Delete(fn,1,i);
  1217. i:=length(fn);
  1218. while (i>0) and (fn[i] in [',',' ',#9]) do
  1219. dec(i);
  1220. fn:=copy(fn,1,i);
  1221. end;
  1222. function GetName(var fn:string):string;
  1223. var
  1224. i : longint;
  1225. begin
  1226. i:=0;
  1227. while (i<length(fn)) and (fn[i+1] in ['a'..'z','A'..'Z','0'..'9','_','-']) do
  1228. inc(i);
  1229. GetName:=Copy(fn,1,i);
  1230. Delete(fn,1,i);
  1231. end;
  1232. const
  1233. maxlevel=16;
  1234. var
  1235. f : text;
  1236. s, tmp,
  1237. opts : string;
  1238. skip : array[0..maxlevel-1] of boolean;
  1239. level : longint;
  1240. option_read : boolean;
  1241. begin
  1242. { avoid infinite loop }
  1243. Inc(FileLevel);
  1244. Option_read:=false;
  1245. If FileLevel>MaxLevel then
  1246. Message(option_too_many_cfg_files);
  1247. { Maybe It's Directory ?} //Jaro Change:
  1248. if DirectoryExists(filename) then
  1249. begin
  1250. Message1(option_config_is_dir,filename);
  1251. exit;
  1252. end;
  1253. { open file }
  1254. Message1(option_using_file,filename);
  1255. {$ifdef USE_SYSUTILS}
  1256. assign(f,ExpandFileName(filename));
  1257. {$else USE_SYSUTILS}
  1258. assign(f,FExpand(filename));
  1259. {$endif USE_SYsUTILS}
  1260. {$I-}
  1261. reset(f);
  1262. {$I+}
  1263. if ioresult<>0 then
  1264. begin
  1265. Message1(option_unable_open_file,filename);
  1266. exit;
  1267. end;
  1268. Message1(option_start_reading_configfile,filename);
  1269. fillchar(skip,sizeof(skip),0);
  1270. level:=0;
  1271. while not eof(f) do
  1272. begin
  1273. readln(f,opts);
  1274. RemoveSep(opts);
  1275. if (opts<>'') and (opts[1]<>';') then
  1276. begin
  1277. if opts[1]='#' then
  1278. begin
  1279. Message1(option_interpreting_file_option,opts);
  1280. Delete(opts,1,1);
  1281. s:=upper(GetName(opts));
  1282. if (s='SECTION') then
  1283. begin
  1284. RemoveSep(opts);
  1285. s:=upper(GetName(opts));
  1286. if level=0 then
  1287. skip[level]:=not (assigned(search_macro(s)) or (s='COMMON'));
  1288. end
  1289. else
  1290. if (s='IFDEF') then
  1291. begin
  1292. RemoveSep(opts);
  1293. if Level>=maxlevel then
  1294. begin
  1295. Message(option_too_many_ifdef);
  1296. stopOptions(1);
  1297. end;
  1298. inc(Level);
  1299. skip[level]:=(skip[level-1] or not assigned(search_macro(upper(GetName(opts)))));
  1300. end
  1301. else
  1302. if (s='IFNDEF') then
  1303. begin
  1304. RemoveSep(opts);
  1305. if Level>=maxlevel then
  1306. begin
  1307. Message(option_too_many_ifdef);
  1308. stopOptions(1);
  1309. end;
  1310. inc(Level);
  1311. skip[level]:=(skip[level-1] or assigned(search_macro(upper(GetName(opts)))));
  1312. end
  1313. else
  1314. if (s='ELSE') then
  1315. skip[level]:=skip[level-1] or (not skip[level])
  1316. else
  1317. if (s='ENDIF') then
  1318. begin
  1319. skip[level]:=false;
  1320. if Level=0 then
  1321. begin
  1322. Message(option_too_many_endif);
  1323. stopOptions(1);
  1324. end;
  1325. dec(level);
  1326. end
  1327. else
  1328. if (not skip[level]) then
  1329. begin
  1330. if (s='DEFINE') then
  1331. begin
  1332. RemoveSep(opts);
  1333. tmp:= GetName(opts);
  1334. if tmp <> '' then
  1335. def_system_macro(tmp);
  1336. end
  1337. else
  1338. if (s='UNDEF') then
  1339. begin
  1340. RemoveSep(opts);
  1341. tmp:= GetName(opts);
  1342. if tmp <> '' then
  1343. undef_system_macro(tmp);
  1344. end
  1345. else
  1346. if (s='WRITE') then
  1347. begin
  1348. Delete(opts,1,1);
  1349. WriteLn(opts);
  1350. end
  1351. else
  1352. if (s='INCLUDE') then
  1353. begin
  1354. Delete(opts,1,1);
  1355. Interpret_file(opts);
  1356. end;
  1357. end;
  1358. end
  1359. else
  1360. begin
  1361. if (opts[1]='-') or (opts[1]='@') then
  1362. begin
  1363. if (not skip[level]) then
  1364. interpret_option(opts,false);
  1365. Option_read:=true;
  1366. end
  1367. else
  1368. Message1(option_illegal_para,opts);
  1369. end;
  1370. end;
  1371. end;
  1372. if Level>0 then
  1373. Message(option_too_less_endif);
  1374. if Not Option_read then
  1375. Message1(option_no_option_found,filename)
  1376. else
  1377. Message1(option_end_reading_configfile,filename);
  1378. Close(f);
  1379. Dec(FileLevel);
  1380. end;
  1381. procedure Toption.Interpret_envvar(const envname : string);
  1382. var
  1383. argstart,
  1384. env,
  1385. pc : pchar;
  1386. arglen : longint;
  1387. quote : set of char;
  1388. hs : string;
  1389. begin
  1390. Message1(option_using_env,envname);
  1391. env:=GetEnvPChar(envname);
  1392. pc:=env;
  1393. if assigned(pc) then
  1394. begin
  1395. repeat
  1396. { skip leading spaces }
  1397. while pc^ in [' ',#9,#13] do
  1398. inc(pc);
  1399. case pc^ of
  1400. #0 :
  1401. break;
  1402. '"' :
  1403. begin
  1404. quote:=['"'];
  1405. inc(pc);
  1406. end;
  1407. '''' :
  1408. begin
  1409. quote:=[''''];
  1410. inc(pc);
  1411. end;
  1412. else
  1413. quote:=[' ',#9,#13];
  1414. end;
  1415. { scan until the end of the argument }
  1416. argstart:=pc;
  1417. while (pc^<>#0) and not(pc^ in quote) do
  1418. inc(pc);
  1419. { create argument }
  1420. arglen:=pc-argstart;
  1421. hs[0]:=chr(arglen);
  1422. move(argstart^,hs[1],arglen);
  1423. interpret_option(hs,true);
  1424. { skip quote }
  1425. if pc^ in quote then
  1426. inc(pc);
  1427. until false;
  1428. end
  1429. else
  1430. Message1(option_no_option_found,'(env) '+envname);
  1431. FreeEnvPChar(env);
  1432. end;
  1433. procedure toption.read_parameters;
  1434. var
  1435. opts : string;
  1436. paramindex : longint;
  1437. begin
  1438. paramindex:=0;
  1439. while paramindex<paramcount do
  1440. begin
  1441. inc(paramindex);
  1442. opts:=system.paramstr(paramindex);
  1443. case opts[1] of
  1444. '@' :
  1445. if not firstpass then
  1446. begin
  1447. Delete(opts,1,1);
  1448. Message1(option_reading_further_from,opts);
  1449. interpret_file(opts);
  1450. end;
  1451. '!' :
  1452. if not firstpass then
  1453. begin
  1454. Delete(opts,1,1);
  1455. Message1(option_reading_further_from,'(env) '+opts);
  1456. interpret_envvar(opts);
  1457. end;
  1458. else
  1459. interpret_option(opts,true);
  1460. end;
  1461. end;
  1462. end;
  1463. procedure toption.parsecmd(cmd:string);
  1464. var
  1465. i,ps : longint;
  1466. opts : string;
  1467. begin
  1468. while (cmd<>'') do
  1469. begin
  1470. while cmd[1]=' ' do
  1471. delete(cmd,1,1);
  1472. i:=pos(' ',cmd);
  1473. if i=0 then
  1474. i:=256;
  1475. opts:=Copy(cmd,1,i-1);
  1476. Delete(cmd,1,i);
  1477. case opts[1] of
  1478. '@' :
  1479. if not firstpass then
  1480. begin
  1481. Delete(opts,1,1);
  1482. Message1(option_reading_further_from,opts);
  1483. interpret_file(opts);
  1484. end;
  1485. '!' :
  1486. if not firstpass then
  1487. begin
  1488. Delete(opts,1,1);
  1489. Message1(option_reading_further_from,'(env) '+opts);
  1490. interpret_envvar(opts);
  1491. end;
  1492. '"' :
  1493. begin
  1494. Delete(opts,1,1);
  1495. ps:=pos('"',cmd);
  1496. if (i<>256) and (ps>0) then
  1497. begin
  1498. opts:=opts + ' '+ copy(cmd,1,ps-1);
  1499. cmd:=copy(cmd,ps+1,255);
  1500. end;
  1501. interpret_option(opts,true);
  1502. end;
  1503. else
  1504. interpret_option(opts,true);
  1505. end;
  1506. end;
  1507. end;
  1508. procedure toption.writequickinfo;
  1509. var
  1510. s : string;
  1511. i : longint;
  1512. procedure addinfo(const hs:string);
  1513. begin
  1514. if s<>'' then
  1515. s:=s+' '+hs
  1516. else
  1517. s:=hs;
  1518. end;
  1519. begin
  1520. s:='';
  1521. i:=0;
  1522. while (i<length(quickinfo)) do
  1523. begin
  1524. inc(i);
  1525. case quickinfo[i] of
  1526. 'S' :
  1527. begin
  1528. inc(i);
  1529. case quickinfo[i] of
  1530. 'O' :
  1531. addinfo(lower(source_info.shortname));
  1532. 'P' :
  1533. addinfo(source_cpu_string);
  1534. else
  1535. IllegalPara('-i'+QuickInfo);
  1536. end;
  1537. end;
  1538. 'T' :
  1539. begin
  1540. inc(i);
  1541. case quickinfo[i] of
  1542. 'O' :
  1543. addinfo(lower(target_info.shortname));
  1544. 'P' :
  1545. AddInfo(target_cpu_string);
  1546. else
  1547. IllegalPara('-i'+QuickInfo);
  1548. end;
  1549. end;
  1550. 'V' :
  1551. AddInfo(version_string);
  1552. 'W' :
  1553. AddInfo(full_version_string);
  1554. 'D' :
  1555. AddInfo(date_string);
  1556. '_' :
  1557. ;
  1558. else
  1559. IllegalPara('-i'+QuickInfo);
  1560. end;
  1561. end;
  1562. if s<>'' then
  1563. begin
  1564. writeln(s);
  1565. stopoptions(0);
  1566. end;
  1567. end;
  1568. procedure TOption.TargetDefines(def:boolean);
  1569. var
  1570. s : string;
  1571. i : integer;
  1572. begin
  1573. if def then
  1574. def_system_macro(target_info.shortname)
  1575. else
  1576. undef_system_macro(target_info.shortname);
  1577. s:=target_info.extradefines;
  1578. while (s<>'') do
  1579. begin
  1580. i:=pos(';',s);
  1581. if i=0 then
  1582. i:=length(s)+1;
  1583. if def then
  1584. def_system_macro(Copy(s,1,i-1))
  1585. else
  1586. undef_system_macro(Copy(s,1,i-1));
  1587. delete(s,1,i);
  1588. end;
  1589. end;
  1590. constructor TOption.create;
  1591. begin
  1592. LogoWritten:=false;
  1593. NoPressEnter:=false;
  1594. FirstPass:=false;
  1595. FileLevel:=0;
  1596. Quickinfo:='';
  1597. ParaIncludePath:=TSearchPathList.Create;
  1598. ParaObjectPath:=TSearchPathList.Create;
  1599. ParaUnitPath:=TSearchPathList.Create;
  1600. ParaLibraryPath:=TSearchPathList.Create;
  1601. FillChar(ParaAlignment,sizeof(ParaAlignment),0);
  1602. end;
  1603. destructor TOption.destroy;
  1604. begin
  1605. ParaIncludePath.Free;
  1606. ParaObjectPath.Free;
  1607. ParaUnitPath.Free;
  1608. ParaLibraryPath.Free;
  1609. end;
  1610. {****************************************************************************
  1611. Callable Routines
  1612. ****************************************************************************}
  1613. function check_configfile(const fn:string;var foundfn:string):boolean;
  1614. function CfgFileExists(const fn:string):boolean;
  1615. begin
  1616. Comment(V_Tried,'Configfile search: '+fn);
  1617. CfgFileExists:=FileExists(fn);
  1618. end;
  1619. var
  1620. configpath : pathstr;
  1621. begin
  1622. foundfn:=fn;
  1623. check_configfile:=true;
  1624. { retrieve configpath }
  1625. {$IFDEF USE_SYSUTILS}
  1626. configpath:=FixPath(GetEnvironmentVariable('PPC_CONFIG_PATH'),false);
  1627. {$ELSE USE_SYSUTILS}
  1628. configpath:=FixPath(dos.getenv('PPC_CONFIG_PATH'),false);
  1629. {$ENDIF USE_SYSUTILS}
  1630. {$ifdef Unix}
  1631. if configpath='' then
  1632. configpath:=CleanPath(FixPath(exepath+'../etc/',false));
  1633. {$endif}
  1634. {
  1635. Order to read configuration file :
  1636. try reading fpc.cfg in :
  1637. 1 - current dir
  1638. 2 - configpath
  1639. 3 - compiler path
  1640. }
  1641. if not FileExists(fn) then
  1642. begin
  1643. {$ifdef Unix}
  1644. {$IFDEF USE_SYSUTILS}
  1645. if (GetEnvironmentVariable('HOME')<>'') and CfgFileExists(FixPath(GetEnvironmentVariable('HOME'),false)+'.'+fn) then
  1646. foundfn:=FixPath(GetEnvironmentVariable('HOME'),false)+'.'+fn
  1647. {$ELSE USE_SYSUTILS}
  1648. if (dos.getenv('HOME')<>'') and CfgFileExists(FixPath(dos.getenv('HOME'),false)+'.'+fn) then
  1649. foundfn:=FixPath(dos.getenv('HOME'),false)+'.'+fn
  1650. {$ENDIF USE_SYSUTILS}
  1651. else
  1652. {$endif}
  1653. if CfgFileExists(configpath+fn) then
  1654. foundfn:=configpath+fn
  1655. else
  1656. {$ifndef Unix}
  1657. if CfgFileExists(exepath+fn) then
  1658. foundfn:=exepath+fn
  1659. else
  1660. {$else}
  1661. if CfgFileExists('/etc/'+fn) then
  1662. foundfn:='/etc/'+fn
  1663. else
  1664. {$endif}
  1665. check_configfile:=false;
  1666. end;
  1667. end;
  1668. procedure read_arguments(cmd:string);
  1669. begin
  1670. option:=coption.create;
  1671. disable_configfile:=false;
  1672. { get default messagefile }
  1673. {$IFDEF USE_SYSUTILS}
  1674. msgfilename:=GetEnvironmentVariable('PPC_ERROR_FILE');
  1675. {$ELSE USE_SYSUTILS}
  1676. msgfilename:=dos.getenv('PPC_ERROR_FILE');
  1677. {$ENDIF USE_SYSUTILS}
  1678. { default configfile can be specified on the commandline,
  1679. remove it first }
  1680. if (cmd<>'') and (cmd[1]='[') then
  1681. begin
  1682. ppccfg:=Copy(cmd,2,pos(']',cmd)-2);
  1683. Delete(cmd,1,pos(']',cmd));
  1684. end
  1685. else
  1686. begin
  1687. ppccfg:='fpc.cfg';
  1688. ppcaltcfg:='ppc386.cfg';
  1689. end;
  1690. { first pass reading of parameters, only -i -v -T etc.}
  1691. option.firstpass:=true;
  1692. if cmd<>'' then
  1693. option.parsecmd(cmd)
  1694. else
  1695. begin
  1696. option.read_parameters;
  1697. { Write only quickinfo }
  1698. if option.quickinfo<>'' then
  1699. option.writequickinfo;
  1700. end;
  1701. option.firstpass:=false;
  1702. { default defines }
  1703. def_system_macro(target_info.shortname);
  1704. def_system_macro('FPC');
  1705. def_system_macro('VER'+version_nr);
  1706. def_system_macro('VER'+version_nr+'_'+release_nr);
  1707. def_system_macro('VER'+version_nr+'_'+release_nr+'_'+patch_nr);
  1708. { Temporary defines, until things settle down }
  1709. def_system_macro('COMPPROCINLINEFIXED');
  1710. { "main" symbol is generated in the main program, and left out of the system unit }
  1711. def_system_macro('FPC_DARWIN_PASCALMAIN');
  1712. if pocall_default = pocall_register then
  1713. def_system_macro('REGCALL');
  1714. { using a case is pretty useless here (FK) }
  1715. { some stuff for TP compatibility }
  1716. {$ifdef i386}
  1717. def_system_macro('CPU86');
  1718. def_system_macro('CPU87');
  1719. def_system_macro('CPU386');
  1720. {$endif}
  1721. {$ifdef m68k}
  1722. def_system_macro('CPU68');
  1723. {$endif}
  1724. { new processor stuff }
  1725. {$ifdef i386}
  1726. def_system_macro('CPUI386');
  1727. def_system_macro('CPU32');
  1728. def_system_macro('FPC_HAS_TYPE_EXTENDED');
  1729. def_system_macro('FPC_HAS_TYPE_DOUBLE');
  1730. def_system_macro('FPC_HAS_TYPE_SINGLE');
  1731. def_system_macro('FPC_HAS_RESOURCES');
  1732. {$endif}
  1733. {$ifdef m68k}
  1734. def_system_macro('CPU68K');
  1735. def_system_macro('CPUM68K');
  1736. def_system_macro('CPU32');
  1737. def_system_macro('FPC_CURRENCY_IS_INT64');
  1738. def_system_macro('FPC_COMP_IS_INT64');
  1739. {$endif}
  1740. {$ifdef ALPHA}
  1741. def_system_macro('CPUALPHA');
  1742. def_system_macro('CPU64');
  1743. {$endif}
  1744. {$ifdef powerpc}
  1745. def_system_macro('CPUPOWERPC');
  1746. def_system_macro('CPUPOWERPC32');
  1747. def_system_macro('CPU32');
  1748. def_system_macro('FPC_HAS_TYPE_DOUBLE');
  1749. def_system_macro('FPC_HAS_TYPE_SINGLE');
  1750. def_system_macro('FPC_INCLUDE_SOFTWARE_INT64_TO_DOUBLE');
  1751. def_system_macro('FPC_CURRENCY_IS_INT64');
  1752. def_system_macro('FPC_COMP_IS_INT64');
  1753. {$endif}
  1754. {$ifdef iA64}
  1755. def_system_macro('CPUIA64');
  1756. def_system_macro('CPU64');
  1757. {$endif}
  1758. {$ifdef x86_64}
  1759. def_system_macro('CPUX86_64');
  1760. def_system_macro('CPUAMD64');
  1761. def_system_macro('CPU64');
  1762. { not supported for now, afaik (FK)
  1763. def_system_macro('FPC_HAS_TYPE_FLOAT128'); }
  1764. def_system_macro('FPC_HAS_TYPE_EXTENDED');
  1765. def_system_macro('FPC_HAS_TYPE_DOUBLE');
  1766. def_system_macro('FPC_HAS_TYPE_SINGLE');
  1767. {$endif}
  1768. {$ifdef sparc}
  1769. def_system_macro('CPUSPARC');
  1770. def_system_macro('CPUSPARC32');
  1771. def_system_macro('CPU32');
  1772. def_system_macro('FPC_HAS_TYPE_DOUBLE');
  1773. def_system_macro('FPC_HAS_TYPE_SINGLE');
  1774. def_system_macro('FPC_INCLUDE_SOFTWARE_INT64_TO_DOUBLE');
  1775. def_system_macro('FPC_CURRENCY_IS_INT64');
  1776. def_system_macro('FPC_COMP_IS_INT64');
  1777. def_system_macro('FPC_REQUIRES_PROPER_ALIGNMENT');
  1778. {$endif}
  1779. {$ifdef vis}
  1780. def_system_macro('CPUVIS');
  1781. def_system_macro('CPU32');
  1782. {$endif}
  1783. {$ifdef arm}
  1784. def_system_macro('CPUARM');
  1785. def_system_macro('FPUFPA');
  1786. def_system_macro('CPU32');
  1787. def_system_macro('FPC_HAS_TYPE_DOUBLE');
  1788. def_system_macro('FPC_HAS_TYPE_SINGLE');
  1789. def_system_macro('FPC_INCLUDE_SOFTWARE_INT64_TO_DOUBLE');
  1790. def_system_macro('FPC_CURRENCY_IS_INT64');
  1791. def_system_macro('FPC_COMP_IS_INT64');
  1792. def_system_macro('FPC_REQUIRES_PROPER_ALIGNMENT');
  1793. {$endif arm}
  1794. if source_info.system<>target_info.system then
  1795. def_system_macro('FPC_CROSSCOMPILING');
  1796. if source_info.cpu<>target_info.cpu then
  1797. def_system_macro('FPC_CPUCROSSCOMPILING');
  1798. { read configuration file }
  1799. if (not disable_configfile) and
  1800. (ppccfg<>'') then
  1801. begin
  1802. read_configfile:=check_configfile(ppccfg,ppccfg);
  1803. { Maybe alternative configfile ? }
  1804. if (not read_configfile) and
  1805. (ppcaltcfg<>'') then
  1806. read_configfile:=check_configfile(ppcaltcfg,ppccfg);
  1807. end
  1808. else
  1809. read_configfile := false;
  1810. { Read commandline and configfile }
  1811. target_is_set:=false;
  1812. asm_is_set:=false;
  1813. param_file:='';
  1814. { read configfile }
  1815. if read_configfile then
  1816. option.interpret_file(ppccfg);
  1817. { read parameters again to override config file }
  1818. if cmd<>'' then
  1819. option.parsecmd(cmd)
  1820. else
  1821. begin
  1822. { Write help pages if no parameters are passed }
  1823. if (paramcount=0) then
  1824. Option.WriteHelpPages;
  1825. option.read_parameters;
  1826. { Write only quickinfo }
  1827. if option.quickinfo<>'' then
  1828. option.writequickinfo;
  1829. end;
  1830. { Stop if errors in options }
  1831. if ErrorCount>0 then
  1832. StopOptions(1);
  1833. { Write logo }
  1834. if option.ParaLogo then
  1835. option.writelogo;
  1836. { Non-core target defines }
  1837. Option.TargetDefines(true);
  1838. { endian define }
  1839. case target_info.endian of
  1840. endian_little :
  1841. begin
  1842. def_system_macro('ENDIAN_LITTLE');
  1843. def_system_macro('FPC_LITTLE_ENDIAN');
  1844. end;
  1845. endian_big :
  1846. begin
  1847. def_system_macro('ENDIAN_BIG');
  1848. def_system_macro('FPC_BIG_ENDIAN');
  1849. end;
  1850. end;
  1851. { abi define }
  1852. case target_info.abi of
  1853. abi_powerpc_sysv :
  1854. def_system_macro('FPC_ABI_SYSV');
  1855. abi_powerpc_aix :
  1856. def_system_macro('FPC_ABI_AIX');
  1857. end;
  1858. {$ifdef m68k}
  1859. if initoptprocessor=MC68020 then
  1860. def_system_macro('CPUM68020');
  1861. {$endif m68k}
  1862. { Check file to compile }
  1863. if param_file='' then
  1864. begin
  1865. Message(option_no_source_found);
  1866. StopOptions(1);
  1867. end;
  1868. {$ifndef Unix}
  1869. param_file:=FixFileName(param_file);
  1870. {$endif}
  1871. {$IFDEF USE_SYSUTILS}
  1872. inputdir := SplitPath(param_file);
  1873. inputfile := SplitName(param_file);
  1874. inputextension := SplitExtension(param_file);
  1875. {$ELSE USE_SYSUTILS}
  1876. fsplit(param_file,inputdir,inputfile,inputextension);
  1877. {$ENDIF USE_SYSUTILS}
  1878. if inputextension='' then
  1879. begin
  1880. if FileExists(inputdir+inputfile+sourceext) then
  1881. inputextension:=sourceext
  1882. else if FileExists(inputdir+inputfile+pasext) then
  1883. inputextension:=pasext
  1884. else if ((m_mac in aktmodeswitches) or target_info.p_ext_support)
  1885. and FileExists(inputdir+inputfile+pext) then
  1886. inputextension:=pext;
  1887. end;
  1888. { Check output dir }
  1889. if (OutputExeDir<>'') and
  1890. not PathExists(OutputExeDir) then
  1891. begin
  1892. Message1(general_e_path_does_not_exist,OutputExeDir);
  1893. StopOptions(1);
  1894. end;
  1895. { Add paths specified with parameters to the searchpaths }
  1896. UnitSearchPath.AddList(option.ParaUnitPath,true);
  1897. ObjectSearchPath.AddList(option.ParaObjectPath,true);
  1898. IncludeSearchPath.AddList(option.ParaIncludePath,true);
  1899. LibrarySearchPath.AddList(option.ParaLibraryPath,true);
  1900. { add unit environment and exepath to the unit search path }
  1901. if inputdir<>'' then
  1902. Unitsearchpath.AddPath(inputdir,true);
  1903. if not disable_configfile then
  1904. begin
  1905. {$IFDEF USE_SYSUTILS}
  1906. UnitSearchPath.AddPath(GetEnvironmentVariable(target_info.unit_env),false);
  1907. {$ELSE USE_SYSUTILS}
  1908. UnitSearchPath.AddPath(dos.getenv(target_info.unit_env),false);
  1909. {$ENDIF USE_SYSUTILS}
  1910. end;
  1911. {$ifdef Unix}
  1912. {$IFDEF USE_SYSUTILS}
  1913. fpcdir:=FixPath(GetEnvironmentVariable('FPCDIR'),false);
  1914. {$ELSE USE_SYSUTILS}
  1915. fpcdir:=FixPath(getenv('FPCDIR'),false);
  1916. {$ENDIF USE_SYSUTILS}
  1917. if fpcdir='' then
  1918. begin
  1919. if PathExists('/usr/local/lib/fpc/'+version_string) then
  1920. fpcdir:='/usr/local/lib/fpc/'+version_string+'/'
  1921. else
  1922. fpcdir:='/usr/lib/fpc/'+version_string+'/';
  1923. end;
  1924. {$else}
  1925. {$IFDEF USE_SYSUTILS}
  1926. fpcdir:=FixPath(GetEnvironmentVariable('FPCDIR'),false);
  1927. {$ELSE USE_SYSUTILS}
  1928. fpcdir:=FixPath(getenv('FPCDIR'),false);
  1929. {$ENDIF USE_SYSUTILS}
  1930. if fpcdir='' then
  1931. begin
  1932. fpcdir:=ExePath+'../';
  1933. if not(PathExists(fpcdir+'/units')) and
  1934. not(PathExists(fpcdir+'/rtl')) then
  1935. fpcdir:=fpcdir+'../';
  1936. end;
  1937. {$endif}
  1938. { first try development RTL, else use the default installation path }
  1939. if not disable_configfile then
  1940. begin
  1941. if PathExists(FpcDir+'rtl') then
  1942. if tf_use_8_3 in Source_Info.Flags then
  1943. UnitSearchPath.AddPath(FpcDir+'rtl/'+target_os_string,false)
  1944. else
  1945. UnitSearchPath.AddPath(FpcDir+'rtl/'+target_full_string,false)
  1946. else
  1947. if tf_use_8_3 in Source_Info.Flags then
  1948. UnitSearchPath.AddPath(FpcDir+'units/'+target_os_string+'/rtl',false)
  1949. else
  1950. UnitSearchPath.AddPath(FpcDir+'units/'+target_full_string+'/rtl',false);
  1951. end;
  1952. { Add exepath if the exe is not in the current dir, because that is always searched already.
  1953. Do not add it when linking on the target because then we can maybe already find
  1954. .o files that are not for the target }
  1955. if (ExePath<>GetCurrentDir) and
  1956. not(cs_link_on_target in initglobalswitches) then
  1957. UnitSearchPath.AddPath(ExePath,false);
  1958. { Add unit dir to the object and library path }
  1959. objectsearchpath.AddList(unitsearchpath,false);
  1960. librarysearchpath.AddList(unitsearchpath,false);
  1961. { switch assembler if it's binary and we got -a on the cmdline }
  1962. if (cs_asm_leave in initglobalswitches) and
  1963. (af_outputbinary in target_asm.flags) then
  1964. begin
  1965. Message(option_switch_bin_to_src_assembler);
  1966. set_target_asm(target_info.assemextern);
  1967. end;
  1968. if (target_asm.supported_target <> system_any) and
  1969. (target_asm.supported_target <> target_info.system) then
  1970. begin
  1971. Message2(option_incompatible_asm,target_asm.idtxt,target_info.name);
  1972. set_target_asm(target_info.assemextern);
  1973. Message1(option_asm_forced,target_asm.idtxt);
  1974. end;
  1975. { turn off stripping if compiling with debuginfo or profile }
  1976. if (cs_debuginfo in initmoduleswitches) or
  1977. (cs_profile in initmoduleswitches) then
  1978. exclude(initglobalswitches,cs_link_strip);
  1979. {$ifdef x86_64}
  1980. {$warning HACK: turn off smartlinking}
  1981. exclude(initmoduleswitches,cs_create_smart);
  1982. {$endif}
  1983. if not LinkTypeSetExplicitly then
  1984. set_default_link_type;
  1985. { Default alignment settings,
  1986. 1. load the defaults for the target
  1987. 2. override with generic optimizer setting (little size)
  1988. 3. override with the user specified -Oa }
  1989. UpdateAlignment(initalignment,target_info.alignment);
  1990. if (cs_littlesize in aktglobalswitches) then
  1991. begin
  1992. initalignment.procalign:=1;
  1993. initalignment.jumpalign:=1;
  1994. initalignment.loopalign:=1;
  1995. end;
  1996. UpdateAlignment(initalignment,option.paraalignment);
  1997. set_system_macro('FPC_VERSION',version_nr);
  1998. set_system_macro('FPC_RELEASE',release_nr);
  1999. set_system_macro('FPC_PATCH',patch_nr);
  2000. option.free;
  2001. Option:=nil;
  2002. end;
  2003. initialization
  2004. coption:=toption;
  2005. finalization
  2006. if assigned(option) then
  2007. option.free;
  2008. end.