options.pas 62 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. 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. { open file }
  1218. Message1(option_using_file,filename);
  1219. {$ifdef USE_SYSUTILS}
  1220. assign(f,ExpandFileName(filename));
  1221. {$else USE_SYSUTILS}
  1222. assign(f,FExpand(filename));
  1223. {$endif USE_SYsUTILS}
  1224. {$I-}
  1225. reset(f);
  1226. {$I+}
  1227. if ioresult<>0 then
  1228. begin
  1229. Message1(option_unable_open_file,filename);
  1230. exit;
  1231. end;
  1232. Message1(option_start_reading_configfile,filename);
  1233. fillchar(skip,sizeof(skip),0);
  1234. level:=0;
  1235. while not eof(f) do
  1236. begin
  1237. readln(f,opts);
  1238. RemoveSep(opts);
  1239. if (opts<>'') and (opts[1]<>';') then
  1240. begin
  1241. if opts[1]='#' then
  1242. begin
  1243. Message1(option_interpreting_file_option,opts);
  1244. Delete(opts,1,1);
  1245. s:=upper(GetName(opts));
  1246. if (s='SECTION') then
  1247. begin
  1248. RemoveSep(opts);
  1249. s:=upper(GetName(opts));
  1250. if level=0 then
  1251. skip[level]:=not (assigned(search_macro(s)) or (s='COMMON'));
  1252. end
  1253. else
  1254. if (s='IFDEF') then
  1255. begin
  1256. RemoveSep(opts);
  1257. if Level>=maxlevel then
  1258. begin
  1259. Message(option_too_many_ifdef);
  1260. stopOptions(1);
  1261. end;
  1262. inc(Level);
  1263. skip[level]:=(skip[level-1] or not assigned(search_macro(upper(GetName(opts)))));
  1264. end
  1265. else
  1266. if (s='IFNDEF') then
  1267. begin
  1268. RemoveSep(opts);
  1269. if Level>=maxlevel then
  1270. begin
  1271. Message(option_too_many_ifdef);
  1272. stopOptions(1);
  1273. end;
  1274. inc(Level);
  1275. skip[level]:=(skip[level-1] or assigned(search_macro(upper(GetName(opts)))));
  1276. end
  1277. else
  1278. if (s='ELSE') then
  1279. skip[level]:=skip[level-1] or (not skip[level])
  1280. else
  1281. if (s='ENDIF') then
  1282. begin
  1283. skip[level]:=false;
  1284. if Level=0 then
  1285. begin
  1286. Message(option_too_many_endif);
  1287. stopOptions(1);
  1288. end;
  1289. dec(level);
  1290. end
  1291. else
  1292. if (not skip[level]) then
  1293. begin
  1294. if (s='DEFINE') then
  1295. begin
  1296. RemoveSep(opts);
  1297. tmp:= GetName(opts);
  1298. if tmp <> '' then
  1299. def_system_macro(tmp);
  1300. end
  1301. else
  1302. if (s='UNDEF') then
  1303. begin
  1304. RemoveSep(opts);
  1305. tmp:= GetName(opts);
  1306. if tmp <> '' then
  1307. undef_system_macro(tmp);
  1308. end
  1309. else
  1310. if (s='WRITE') then
  1311. begin
  1312. Delete(opts,1,1);
  1313. WriteLn(opts);
  1314. end
  1315. else
  1316. if (s='INCLUDE') then
  1317. begin
  1318. Delete(opts,1,1);
  1319. Interpret_file(opts);
  1320. end;
  1321. end;
  1322. end
  1323. else
  1324. begin
  1325. if (opts[1]='-') or (opts[1]='@') then
  1326. begin
  1327. if (not skip[level]) then
  1328. interpret_option(opts,false);
  1329. Option_read:=true;
  1330. end
  1331. else
  1332. Message1(option_illegal_para,opts);
  1333. end;
  1334. end;
  1335. end;
  1336. if Level>0 then
  1337. Message(option_too_less_endif);
  1338. if Not Option_read then
  1339. Message1(option_no_option_found,filename)
  1340. else
  1341. Message1(option_end_reading_configfile,filename);
  1342. Close(f);
  1343. Dec(FileLevel);
  1344. end;
  1345. procedure Toption.Interpret_envvar(const envname : string);
  1346. var
  1347. argstart,
  1348. env,
  1349. pc : pchar;
  1350. arglen : longint;
  1351. quote : set of char;
  1352. hs : string;
  1353. begin
  1354. Message1(option_using_env,envname);
  1355. env:=GetEnvPChar(envname);
  1356. pc:=env;
  1357. if assigned(pc) then
  1358. begin
  1359. repeat
  1360. { skip leading spaces }
  1361. while pc^ in [' ',#9,#13] do
  1362. inc(pc);
  1363. case pc^ of
  1364. #0 :
  1365. break;
  1366. '"' :
  1367. begin
  1368. quote:=['"'];
  1369. inc(pc);
  1370. end;
  1371. '''' :
  1372. begin
  1373. quote:=[''''];
  1374. inc(pc);
  1375. end;
  1376. else
  1377. quote:=[' ',#9,#13];
  1378. end;
  1379. { scan until the end of the argument }
  1380. argstart:=pc;
  1381. while (pc^<>#0) and not(pc^ in quote) do
  1382. inc(pc);
  1383. { create argument }
  1384. arglen:=pc-argstart;
  1385. hs[0]:=chr(arglen);
  1386. move(argstart^,hs[1],arglen);
  1387. interpret_option(hs,true);
  1388. { skip quote }
  1389. if pc^ in quote then
  1390. inc(pc);
  1391. until false;
  1392. end
  1393. else
  1394. Message1(option_no_option_found,'(env) '+envname);
  1395. FreeEnvPChar(env);
  1396. end;
  1397. procedure toption.read_parameters;
  1398. var
  1399. opts : string;
  1400. paramindex : longint;
  1401. begin
  1402. paramindex:=0;
  1403. while paramindex<paramcount do
  1404. begin
  1405. inc(paramindex);
  1406. opts:=system.paramstr(paramindex);
  1407. case opts[1] of
  1408. '@' :
  1409. if not firstpass then
  1410. begin
  1411. Delete(opts,1,1);
  1412. Message1(option_reading_further_from,opts);
  1413. interpret_file(opts);
  1414. end;
  1415. '!' :
  1416. if not firstpass then
  1417. begin
  1418. Delete(opts,1,1);
  1419. Message1(option_reading_further_from,'(env) '+opts);
  1420. interpret_envvar(opts);
  1421. end;
  1422. else
  1423. interpret_option(opts,true);
  1424. end;
  1425. end;
  1426. end;
  1427. procedure toption.parsecmd(cmd:string);
  1428. var
  1429. i,ps : longint;
  1430. opts : string;
  1431. begin
  1432. while (cmd<>'') do
  1433. begin
  1434. while cmd[1]=' ' do
  1435. delete(cmd,1,1);
  1436. i:=pos(' ',cmd);
  1437. if i=0 then
  1438. i:=256;
  1439. opts:=Copy(cmd,1,i-1);
  1440. Delete(cmd,1,i);
  1441. case opts[1] of
  1442. '@' :
  1443. if not firstpass then
  1444. begin
  1445. Delete(opts,1,1);
  1446. Message1(option_reading_further_from,opts);
  1447. interpret_file(opts);
  1448. end;
  1449. '!' :
  1450. if not firstpass then
  1451. begin
  1452. Delete(opts,1,1);
  1453. Message1(option_reading_further_from,'(env) '+opts);
  1454. interpret_envvar(opts);
  1455. end;
  1456. '"' :
  1457. begin
  1458. Delete(opts,1,1);
  1459. ps:=pos('"',cmd);
  1460. if (i<>256) and (ps>0) then
  1461. begin
  1462. opts:=opts + ' '+ copy(cmd,1,ps-1);
  1463. cmd:=copy(cmd,ps+1,255);
  1464. end;
  1465. interpret_option(opts,true);
  1466. end;
  1467. else
  1468. interpret_option(opts,true);
  1469. end;
  1470. end;
  1471. end;
  1472. procedure toption.writequickinfo;
  1473. var
  1474. s : string;
  1475. i : longint;
  1476. procedure addinfo(const hs:string);
  1477. begin
  1478. if s<>'' then
  1479. s:=s+' '+hs
  1480. else
  1481. s:=hs;
  1482. end;
  1483. begin
  1484. s:='';
  1485. i:=0;
  1486. while (i<length(quickinfo)) do
  1487. begin
  1488. inc(i);
  1489. case quickinfo[i] of
  1490. 'S' :
  1491. begin
  1492. inc(i);
  1493. case quickinfo[i] of
  1494. 'O' :
  1495. addinfo(lower(source_info.shortname));
  1496. 'P' :
  1497. addinfo(source_cpu_string);
  1498. else
  1499. IllegalPara('-i'+QuickInfo);
  1500. end;
  1501. end;
  1502. 'T' :
  1503. begin
  1504. inc(i);
  1505. case quickinfo[i] of
  1506. 'O' :
  1507. addinfo(lower(target_info.shortname));
  1508. 'P' :
  1509. AddInfo(target_cpu_string);
  1510. else
  1511. IllegalPara('-i'+QuickInfo);
  1512. end;
  1513. end;
  1514. 'V' :
  1515. AddInfo(version_string);
  1516. 'D' :
  1517. AddInfo(date_string);
  1518. '_' :
  1519. ;
  1520. else
  1521. IllegalPara('-i'+QuickInfo);
  1522. end;
  1523. end;
  1524. if s<>'' then
  1525. begin
  1526. writeln(s);
  1527. stopoptions(0);
  1528. end;
  1529. end;
  1530. procedure TOption.TargetDefines(def:boolean);
  1531. var
  1532. s : string;
  1533. i : integer;
  1534. begin
  1535. if def then
  1536. def_system_macro(target_info.shortname)
  1537. else
  1538. undef_system_macro(target_info.shortname);
  1539. s:=target_info.extradefines;
  1540. while (s<>'') do
  1541. begin
  1542. i:=pos(';',s);
  1543. if i=0 then
  1544. i:=length(s)+1;
  1545. if def then
  1546. def_system_macro(Copy(s,1,i-1))
  1547. else
  1548. undef_system_macro(Copy(s,1,i-1));
  1549. delete(s,1,i);
  1550. end;
  1551. end;
  1552. constructor TOption.create;
  1553. begin
  1554. LogoWritten:=false;
  1555. NoPressEnter:=false;
  1556. FirstPass:=false;
  1557. FileLevel:=0;
  1558. Quickinfo:='';
  1559. ParaIncludePath:=TSearchPathList.Create;
  1560. ParaObjectPath:=TSearchPathList.Create;
  1561. ParaUnitPath:=TSearchPathList.Create;
  1562. ParaLibraryPath:=TSearchPathList.Create;
  1563. FillChar(ParaAlignment,sizeof(ParaAlignment),0);
  1564. end;
  1565. destructor TOption.destroy;
  1566. begin
  1567. ParaIncludePath.Free;
  1568. ParaObjectPath.Free;
  1569. ParaUnitPath.Free;
  1570. ParaLibraryPath.Free;
  1571. end;
  1572. {****************************************************************************
  1573. Callable Routines
  1574. ****************************************************************************}
  1575. function check_configfile(const fn:string;var foundfn:string):boolean;
  1576. function CfgFileExists(const fn:string):boolean;
  1577. begin
  1578. Comment(V_Tried,'Configfile search: '+fn);
  1579. CfgFileExists:=FileExists(fn);
  1580. end;
  1581. var
  1582. configpath : pathstr;
  1583. begin
  1584. foundfn:=fn;
  1585. check_configfile:=true;
  1586. { retrieve configpath }
  1587. {$IFDEF USE_SYSUTILS}
  1588. configpath:=FixPath(GetEnvironmentVariable('PPC_CONFIG_PATH'),false);
  1589. {$ELSE USE_SYSUTILS}
  1590. configpath:=FixPath(dos.getenv('PPC_CONFIG_PATH'),false);
  1591. {$ENDIF USE_SYSUTILS}
  1592. {$ifdef Unix}
  1593. if configpath='' then
  1594. configpath:=CleanPath(FixPath(exepath+'../etc/',false));
  1595. {$endif}
  1596. {
  1597. Order to read configuration file :
  1598. try reading fpc.cfg in :
  1599. 1 - current dir
  1600. 2 - configpath
  1601. 3 - compiler path
  1602. }
  1603. if not FileExists(fn) then
  1604. begin
  1605. {$ifdef Unix}
  1606. {$IFDEF USE_SYSUTILS}
  1607. if (GetEnvironmentVariable('HOME')<>'') and CfgFileExists(FixPath(GetEnvironmentVariable('HOME'),false)+'.'+fn) then
  1608. foundfn:=FixPath(GetEnvironmentVariable('HOME'),false)+'.'+fn
  1609. {$ELSE USE_SYSUTILS}
  1610. if (dos.getenv('HOME')<>'') and CfgFileExists(FixPath(dos.getenv('HOME'),false)+'.'+fn) then
  1611. foundfn:=FixPath(dos.getenv('HOME'),false)+'.'+fn
  1612. {$ENDIF USE_SYSUTILS}
  1613. else
  1614. {$endif}
  1615. if CfgFileExists(configpath+fn) then
  1616. foundfn:=configpath+fn
  1617. else
  1618. {$ifndef Unix}
  1619. if CfgFileExists(exepath+fn) then
  1620. foundfn:=exepath+fn
  1621. else
  1622. {$else}
  1623. if CfgFileExists('/etc/'+fn) then
  1624. foundfn:='/etc/'+fn
  1625. else
  1626. {$endif}
  1627. check_configfile:=false;
  1628. end;
  1629. end;
  1630. procedure read_arguments(cmd:string);
  1631. begin
  1632. option:=coption.create;
  1633. disable_configfile:=false;
  1634. { get default messagefile }
  1635. {$IFDEF USE_SYSUTILS}
  1636. msgfilename:=GetEnvironmentVariable('PPC_ERROR_FILE');
  1637. {$ELSE USE_SYSUTILS}
  1638. msgfilename:=dos.getenv('PPC_ERROR_FILE');
  1639. {$ENDIF USE_SYSUTILS}
  1640. { default configfile can be specified on the commandline,
  1641. remove it first }
  1642. if (cmd<>'') and (cmd[1]='[') then
  1643. begin
  1644. ppccfg:=Copy(cmd,2,pos(']',cmd)-2);
  1645. Delete(cmd,1,pos(']',cmd));
  1646. end
  1647. else
  1648. begin
  1649. ppccfg:='fpc.cfg';
  1650. ppcaltcfg:='ppc386.cfg';
  1651. end;
  1652. { first pass reading of parameters, only -i -v -T etc.}
  1653. option.firstpass:=true;
  1654. if cmd<>'' then
  1655. option.parsecmd(cmd)
  1656. else
  1657. begin
  1658. option.read_parameters;
  1659. { Write only quickinfo }
  1660. if option.quickinfo<>'' then
  1661. option.writequickinfo;
  1662. end;
  1663. option.firstpass:=false;
  1664. { target is set here, for wince the default app type is gui }
  1665. if target_info.system in system_wince then
  1666. apptype:=app_gui;
  1667. { default defines }
  1668. def_system_macro(target_info.shortname);
  1669. def_system_macro('FPC');
  1670. def_system_macro('VER'+version_nr);
  1671. def_system_macro('VER'+version_nr+'_'+release_nr);
  1672. def_system_macro('VER'+version_nr+'_'+release_nr+'_'+patch_nr);
  1673. { Temporary defines, until things settle down }
  1674. { "main" symbol is generated in the main program, and left out of the system unit }
  1675. def_system_macro('FPC_DARWIN_PASCALMAIN');
  1676. def_system_macro('COMPPROCINLINEFIXED');
  1677. if pocall_default = pocall_register then
  1678. def_system_macro('REGCALL');
  1679. { using a case is pretty useless here (FK) }
  1680. { some stuff for TP compatibility }
  1681. {$ifdef i386}
  1682. def_system_macro('CPU86');
  1683. def_system_macro('CPU87');
  1684. {$endif}
  1685. {$ifdef m68k}
  1686. def_system_macro('CPU68');
  1687. {$endif}
  1688. { new processor stuff }
  1689. {$ifdef i386}
  1690. def_system_macro('CPUI386');
  1691. def_system_macro('CPU32');
  1692. def_system_macro('FPC_HAS_TYPE_EXTENDED');
  1693. def_system_macro('FPC_HAS_TYPE_DOUBLE');
  1694. def_system_macro('FPC_HAS_TYPE_SINGLE');
  1695. def_system_macro('FPC_HAS_RESOURCES');
  1696. {$endif}
  1697. {$ifdef m68k}
  1698. def_system_macro('CPU68K');
  1699. def_system_macro('CPUM68K');
  1700. def_system_macro('CPU32');
  1701. def_system_macro('FPC_CURRENCY_IS_INT64');
  1702. def_system_macro('FPC_COMP_IS_INT64');
  1703. {$endif}
  1704. {$ifdef ALPHA}
  1705. def_system_macro('CPUALPHA');
  1706. def_system_macro('CPU64');
  1707. {$endif}
  1708. {$ifdef powerpc}
  1709. def_system_macro('CPUPOWERPC');
  1710. def_system_macro('CPUPOWERPC32');
  1711. def_system_macro('CPU32');
  1712. def_system_macro('FPC_HAS_TYPE_DOUBLE');
  1713. def_system_macro('FPC_HAS_TYPE_SINGLE');
  1714. def_system_macro('FPC_INCLUDE_SOFTWARE_INT64_TO_DOUBLE');
  1715. def_system_macro('FPC_CURRENCY_IS_INT64');
  1716. def_system_macro('FPC_COMP_IS_INT64');
  1717. {$endif}
  1718. {$ifdef POWERPC64}
  1719. def_system_macro('CPUPOWERPC');
  1720. def_system_macro('CPUPOWERPC64');
  1721. def_system_macro('CPU64');
  1722. def_system_macro('FPC_HAS_TYPE_DOUBLE');
  1723. def_system_macro('FPC_HAS_TYPE_SINGLE');
  1724. def_system_macro('FPC_INCLUDE_SOFTWARE_INT64_TO_DOUBLE');
  1725. def_system_macro('FPC_CURRENCY_IS_INT64');
  1726. def_system_macro('FPC_COMP_IS_INT64');
  1727. def_system_macro('FPC_REQUIRES_PROPER_ALIGNMENT');
  1728. {$endif}
  1729. {$ifdef iA64}
  1730. def_system_macro('CPUIA64');
  1731. def_system_macro('CPU64');
  1732. {$endif}
  1733. {$ifdef x86_64}
  1734. def_system_macro('CPUX86_64');
  1735. def_system_macro('CPUAMD64');
  1736. def_system_macro('CPU64');
  1737. { not supported for now, afaik (FK)
  1738. def_system_macro('FPC_HAS_TYPE_FLOAT128'); }
  1739. { win64 doesn't support the legacy fpu }
  1740. if target_info.system<>system_x86_64_win64 then
  1741. def_system_macro('FPC_HAS_TYPE_EXTENDED')
  1742. else
  1743. begin
  1744. def_system_macro('FPC_CURRENCY_IS_INT64');
  1745. def_system_macro('FPC_COMP_IS_INT64');
  1746. undef_system_macro('FPC_HAS_TYPE_EXTENDED');
  1747. end;
  1748. def_system_macro('FPC_HAS_TYPE_DOUBLE');
  1749. def_system_macro('FPC_HAS_TYPE_SINGLE');
  1750. {$endif}
  1751. {$ifdef sparc}
  1752. def_system_macro('CPUSPARC');
  1753. def_system_macro('CPUSPARC32');
  1754. def_system_macro('CPU32');
  1755. def_system_macro('FPC_HAS_TYPE_DOUBLE');
  1756. def_system_macro('FPC_HAS_TYPE_SINGLE');
  1757. def_system_macro('FPC_INCLUDE_SOFTWARE_INT64_TO_DOUBLE');
  1758. def_system_macro('FPC_CURRENCY_IS_INT64');
  1759. def_system_macro('FPC_COMP_IS_INT64');
  1760. def_system_macro('FPC_REQUIRES_PROPER_ALIGNMENT');
  1761. {$endif}
  1762. {$ifdef vis}
  1763. def_system_macro('CPUVIS');
  1764. def_system_macro('CPU32');
  1765. {$endif}
  1766. {$ifdef arm}
  1767. def_system_macro('CPUARM');
  1768. def_system_macro('FPUFPA');
  1769. def_system_macro('CPU32');
  1770. def_system_macro('FPC_HAS_TYPE_DOUBLE');
  1771. def_system_macro('FPC_HAS_TYPE_SINGLE');
  1772. def_system_macro('FPC_INCLUDE_SOFTWARE_INT64_TO_DOUBLE');
  1773. def_system_macro('FPC_CURRENCY_IS_INT64');
  1774. def_system_macro('FPC_COMP_IS_INT64');
  1775. def_system_macro('FPC_REQUIRES_PROPER_ALIGNMENT');
  1776. {$endif arm}
  1777. if source_info.system<>target_info.system then
  1778. def_system_macro('FPC_CROSSCOMPILING');
  1779. if source_info.cpu<>target_info.cpu then
  1780. def_system_macro('FPC_CPUCROSSCOMPILING');
  1781. { read configuration file }
  1782. if (not disable_configfile) and
  1783. (ppccfg<>'') then
  1784. begin
  1785. read_configfile:=check_configfile(ppccfg,ppccfg);
  1786. { Maybe alternative configfile ? }
  1787. if (not read_configfile) and
  1788. (ppcaltcfg<>'') then
  1789. read_configfile:=check_configfile(ppcaltcfg,ppccfg);
  1790. end
  1791. else
  1792. read_configfile := false;
  1793. { Read commandline and configfile }
  1794. param_file:='';
  1795. { read configfile }
  1796. if read_configfile then
  1797. option.interpret_file(ppccfg);
  1798. { read parameters again to override config file }
  1799. if cmd<>'' then
  1800. option.parsecmd(cmd)
  1801. else
  1802. begin
  1803. { Write help pages if no parameters are passed }
  1804. if (paramcount=0) then
  1805. Option.WriteHelpPages;
  1806. option.read_parameters;
  1807. { Write only quickinfo }
  1808. if option.quickinfo<>'' then
  1809. option.writequickinfo;
  1810. end;
  1811. { Stop if errors in options }
  1812. if ErrorCount>0 then
  1813. StopOptions(1);
  1814. { Write logo }
  1815. if option.ParaLogo then
  1816. option.writelogo;
  1817. { Non-core target defines }
  1818. Option.TargetDefines(true);
  1819. { endian define }
  1820. case target_info.endian of
  1821. endian_little :
  1822. begin
  1823. def_system_macro('ENDIAN_LITTLE');
  1824. def_system_macro('FPC_LITTLE_ENDIAN');
  1825. end;
  1826. endian_big :
  1827. begin
  1828. def_system_macro('ENDIAN_BIG');
  1829. def_system_macro('FPC_BIG_ENDIAN');
  1830. end;
  1831. end;
  1832. { abi define }
  1833. case target_info.abi of
  1834. abi_powerpc_sysv :
  1835. def_system_macro('FPC_ABI_SYSV');
  1836. abi_powerpc_aix :
  1837. def_system_macro('FPC_ABI_AIX');
  1838. end;
  1839. {$ifdef m68k}
  1840. if initoptprocessor=MC68020 then
  1841. def_system_macro('CPUM68020');
  1842. {$endif m68k}
  1843. { Check file to compile }
  1844. if param_file='' then
  1845. begin
  1846. Message(option_no_source_found);
  1847. StopOptions(1);
  1848. end;
  1849. {$ifndef Unix}
  1850. param_file:=FixFileName(param_file);
  1851. {$endif}
  1852. {$IFDEF USE_SYSUTILS}
  1853. inputdir := SplitPath(param_file);
  1854. inputfile := SplitName(param_file);
  1855. inputextension := SplitExtension(param_file);
  1856. {$ELSE USE_SYSUTILS}
  1857. fsplit(param_file,inputdir,inputfile,inputextension);
  1858. {$ENDIF USE_SYSUTILS}
  1859. if inputextension='' then
  1860. begin
  1861. if FileExists(inputdir+inputfile+sourceext) then
  1862. inputextension:=sourceext
  1863. else if FileExists(inputdir+inputfile+pasext) then
  1864. inputextension:=pasext
  1865. else if ((m_mac in aktmodeswitches) or target_info.p_ext_support)
  1866. and FileExists(inputdir+inputfile+pext) then
  1867. inputextension:=pext;
  1868. end;
  1869. { Check output dir }
  1870. if (OutputExeDir<>'') and
  1871. not PathExists(OutputExeDir) then
  1872. begin
  1873. Message1(general_e_path_does_not_exist,OutputExeDir);
  1874. StopOptions(1);
  1875. end;
  1876. { Add paths specified with parameters to the searchpaths }
  1877. UnitSearchPath.AddList(option.ParaUnitPath,true);
  1878. ObjectSearchPath.AddList(option.ParaObjectPath,true);
  1879. IncludeSearchPath.AddList(option.ParaIncludePath,true);
  1880. LibrarySearchPath.AddList(option.ParaLibraryPath,true);
  1881. { add unit environment and exepath to the unit search path }
  1882. if inputdir<>'' then
  1883. Unitsearchpath.AddPath(inputdir,true);
  1884. if not disable_configfile then
  1885. begin
  1886. {$IFDEF USE_SYSUTILS}
  1887. UnitSearchPath.AddPath(GetEnvironmentVariable(target_info.unit_env),false);
  1888. {$ELSE USE_SYSUTILS}
  1889. UnitSearchPath.AddPath(dos.getenv(target_info.unit_env),false);
  1890. {$ENDIF USE_SYSUTILS}
  1891. end;
  1892. {$ifdef Unix}
  1893. {$IFDEF USE_SYSUTILS}
  1894. fpcdir:=FixPath(GetEnvironmentVariable('FPCDIR'),false);
  1895. {$ELSE USE_SYSUTILS}
  1896. fpcdir:=FixPath(getenv('FPCDIR'),false);
  1897. {$ENDIF USE_SYSUTILS}
  1898. if fpcdir='' then
  1899. begin
  1900. if PathExists('/usr/local/lib/fpc/'+version_string) then
  1901. fpcdir:='/usr/local/lib/fpc/'+version_string+'/'
  1902. else
  1903. fpcdir:='/usr/lib/fpc/'+version_string+'/';
  1904. end;
  1905. {$else}
  1906. {$IFDEF USE_SYSUTILS}
  1907. fpcdir:=FixPath(GetEnvironmentVariable('FPCDIR'),false);
  1908. {$ELSE USE_SYSUTILS}
  1909. fpcdir:=FixPath(getenv('FPCDIR'),false);
  1910. {$ENDIF USE_SYSUTILS}
  1911. if fpcdir='' then
  1912. begin
  1913. fpcdir:=ExePath+'../';
  1914. if not(PathExists(fpcdir+'/units')) and
  1915. not(PathExists(fpcdir+'/rtl')) then
  1916. fpcdir:=fpcdir+'../';
  1917. end;
  1918. {$endif}
  1919. { first try development RTL, else use the default installation path }
  1920. if not disable_configfile then
  1921. begin
  1922. if PathExists(FpcDir+'rtl') then
  1923. if tf_use_8_3 in Source_Info.Flags then
  1924. UnitSearchPath.AddPath(FpcDir+'rtl/'+target_os_string,false)
  1925. else
  1926. UnitSearchPath.AddPath(FpcDir+'rtl/'+target_full_string,false)
  1927. else
  1928. if tf_use_8_3 in Source_Info.Flags then
  1929. UnitSearchPath.AddPath(FpcDir+'units/'+target_os_string+'/rtl',false)
  1930. else
  1931. UnitSearchPath.AddPath(FpcDir+'units/'+target_full_string+'/rtl',false);
  1932. end;
  1933. { Add exepath if the exe is not in the current dir, because that is always searched already.
  1934. Do not add it when linking on the target because then we can maybe already find
  1935. .o files that are not for the target }
  1936. if (ExePath<>GetCurrentDir) and
  1937. not(cs_link_on_target in initglobalswitches) then
  1938. UnitSearchPath.AddPath(ExePath,false);
  1939. { Add unit dir to the object and library path }
  1940. objectsearchpath.AddList(unitsearchpath,false);
  1941. librarysearchpath.AddList(unitsearchpath,false);
  1942. { maybe override debug info format }
  1943. if (paratargetdbg<>dbg_none) then
  1944. set_target_dbg(paratargetdbg);
  1945. { maybe override assembler }
  1946. if (paratargetasm<>as_none) then
  1947. set_target_asm(paratargetasm);
  1948. { switch assembler if it's binary and we got -a on the cmdline }
  1949. if (cs_asm_leave in initglobalswitches) and
  1950. (af_outputbinary in target_asm.flags) then
  1951. begin
  1952. Message(option_switch_bin_to_src_assembler);
  1953. set_target_asm(target_info.assemextern);
  1954. end;
  1955. if (target_asm.supported_target <> system_any) and
  1956. (target_asm.supported_target <> target_info.system) then
  1957. begin
  1958. Message2(option_incompatible_asm,target_asm.idtxt,target_info.name);
  1959. set_target_asm(target_info.assemextern);
  1960. Message1(option_asm_forced,target_asm.idtxt);
  1961. end;
  1962. { turn off stripping if compiling with debuginfo or profile }
  1963. if (cs_debuginfo in initmoduleswitches) or
  1964. (cs_profile in initmoduleswitches) then
  1965. exclude(initglobalswitches,cs_link_strip);
  1966. { force fpu emulation on arm/wince }
  1967. if target_info.system=system_arm_wince then
  1968. include(initmoduleswitches,cs_fp_emulation);
  1969. {$ifdef x86_64}
  1970. {$warning HACK: turn off smartlinking}
  1971. exclude(initmoduleswitches,cs_create_smart);
  1972. {$endif}
  1973. if not LinkTypeSetExplicitly then
  1974. set_default_link_type;
  1975. { Default alignment settings,
  1976. 1. load the defaults for the target
  1977. 2. override with generic optimizer setting (little size)
  1978. 3. override with the user specified -Oa }
  1979. UpdateAlignment(initalignment,target_info.alignment);
  1980. if (cs_littlesize in aktglobalswitches) then
  1981. begin
  1982. initalignment.procalign:=1;
  1983. initalignment.jumpalign:=1;
  1984. initalignment.loopalign:=1;
  1985. end;
  1986. UpdateAlignment(initalignment,option.paraalignment);
  1987. set_system_macro('FPC_VERSION',version_nr);
  1988. set_system_macro('FPC_RELEASE',release_nr);
  1989. set_system_macro('FPC_PATCH',patch_nr);
  1990. option.free;
  1991. Option:=nil;
  1992. end;
  1993. initialization
  1994. coption:=toption;
  1995. finalization
  1996. if assigned(option) then
  1997. option.free;
  1998. end.