options.pas 62 KB

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