options.pas 64 KB

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