options.pas 63 KB

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