options.pas 69 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352
  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. NoPressEnter,
  27. DoWriteLogo : 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 Delphi}
  59. dmisc,
  60. {$else Delphi}
  61. dos,
  62. {$endif Delphi}
  63. version,
  64. cutils,cmsgs
  65. {$ifdef BrowserLog}
  66. ,browlog
  67. {$endif BrowserLog}
  68. ;
  69. const
  70. page_size = 24;
  71. var
  72. option : toption;
  73. read_configfile, { read config file, set when a cfgfile is found }
  74. disable_configfile,
  75. target_is_set : boolean; { do not allow contradictory target settings }
  76. asm_is_set : boolean; { -T also change initoutputformat if not set idrectly }
  77. fpcdir,
  78. ppccfg,
  79. ppcaltcfg,
  80. param_file : string; { file to compile specified on the commandline }
  81. {****************************************************************************
  82. Defines
  83. ****************************************************************************}
  84. procedure def_symbol(const s : string);
  85. begin
  86. if s='' then
  87. exit;
  88. initdefines.insert(upper(s));
  89. Message1(option_defining_symbol,s);
  90. end;
  91. procedure undef_symbol(const s : string);
  92. begin
  93. if s='' then
  94. exit;
  95. InitDefines.Remove(s);
  96. Message1(option_undefining_symbol,s);
  97. end;
  98. function check_symbol(const s:string):boolean;
  99. begin
  100. check_symbol:=(initdefines.find(s)<>nil);
  101. end;
  102. procedure set_default_link_type;
  103. begin
  104. if (target_info.system in [system_i386_win32,system_i386_wdosx]) then
  105. begin
  106. def_symbol('FPC_LINK_SMART');
  107. undef_symbol('FPC_LINK_STATIC');
  108. undef_symbol('FPC_LINK_DYNAMIC');
  109. initglobalswitches:=initglobalswitches+[cs_link_smart];
  110. initglobalswitches:=initglobalswitches-[cs_link_shared,cs_link_static];
  111. end
  112. else
  113. begin
  114. undef_symbol('FPC_LINK_SMART');
  115. def_symbol('FPC_LINK_STATIC');
  116. undef_symbol('FPC_LINK_DYNAMIC');
  117. initglobalswitches:=initglobalswitches+[cs_link_static];
  118. initglobalswitches:=initglobalswitches-[cs_link_shared,cs_link_smart];
  119. end;
  120. end;
  121. {****************************************************************************
  122. Toption
  123. ****************************************************************************}
  124. procedure StopOptions;
  125. begin
  126. if assigned(Option) then
  127. begin
  128. Option.free;
  129. Option:=nil;
  130. end;
  131. DoneVerbose;
  132. Stop;
  133. end;
  134. procedure Toption.WriteLogo;
  135. var
  136. p : pchar;
  137. begin
  138. p:=MessagePchar(option_logo);
  139. while assigned(p) do
  140. Comment(V_Normal,GetMsgLine(p));
  141. end;
  142. procedure Toption.WriteInfo;
  143. var
  144. p : pchar;
  145. hs,hs1,s : string;
  146. target : tsystem;
  147. begin
  148. p:=MessagePchar(option_info);
  149. while assigned(p) do
  150. begin
  151. s:=GetMsgLine(p);
  152. { list OS Targets }
  153. if pos('$OSTARGETS',s)>0 then
  154. begin
  155. for target:=low(tsystem) to high(tsystem) do
  156. if assigned(targetinfos[target]) then
  157. begin
  158. hs:=s;
  159. hs1:=targetinfos[target]^.name;
  160. if tf_under_development in targetinfos[target]^.flags then
  161. hs1:=hs1+' (under development)';
  162. Replace(hs,'$OSTARGETS',hs1);
  163. Comment(V_Normal,hs);
  164. end;
  165. end
  166. else
  167. Comment(V_Normal,s);
  168. end;
  169. StopOptions;
  170. end;
  171. procedure Toption.WriteHelpPages;
  172. function PadEnd(s:string;i:longint):string;
  173. begin
  174. while (length(s)<i) do
  175. s:=s+' ';
  176. PadEnd:=s;
  177. end;
  178. var
  179. lastident,
  180. j,outline,
  181. ident,
  182. lines : longint;
  183. show : boolean;
  184. opt : string[32];
  185. input,
  186. s : string;
  187. p : pchar;
  188. begin
  189. WriteLogo;
  190. Lines:=4;
  191. Message1(option_usage,system.paramstr(0));
  192. lastident:=0;
  193. p:=MessagePChar(option_help_pages);
  194. while assigned(p) do
  195. begin
  196. { get a line and reset }
  197. s:=GetMsgLine(p);
  198. ident:=0;
  199. show:=false;
  200. { parse options }
  201. case s[1] of
  202. {$ifdef UNITALIASES}
  203. 'a',
  204. {$endif}
  205. {$ifdef EXTDEBUG}
  206. 'e',
  207. {$endif EXTDEBUG}
  208. {$ifdef i386}
  209. '3',
  210. {$endif}
  211. {$ifdef powerpc}
  212. 'P',
  213. {$endif}
  214. {$ifdef vis}
  215. 'V',
  216. {$endif}
  217. {$ifdef sparc}
  218. 'S',
  219. {$endif}
  220. {$ifdef m68k}
  221. '6',
  222. {$endif}
  223. '*' : show:=true;
  224. end;
  225. if show then
  226. begin
  227. case s[2] of
  228. {$ifdef GDB}
  229. 'g',
  230. {$endif}
  231. {$ifdef Unix}
  232. 'L',
  233. {$endif}
  234. {$ifdef os2}
  235. 'O',
  236. {$endif}
  237. '*' : show:=true;
  238. else
  239. show:=false;
  240. end;
  241. end;
  242. { now we may show the message or not }
  243. if show then
  244. begin
  245. case s[3] of
  246. '0' : begin
  247. ident:=0;
  248. outline:=0;
  249. end;
  250. '1' : begin
  251. ident:=2;
  252. outline:=7;
  253. end;
  254. '2' : begin
  255. ident:=6;
  256. outline:=11;
  257. end;
  258. '3' : begin
  259. ident:=9;
  260. outline:=6;
  261. end;
  262. end;
  263. j:=pos('_',s);
  264. opt:=Copy(s,4,j-4);
  265. if opt='*' then
  266. opt:=''
  267. else
  268. if opt=' ' then
  269. opt:=PadEnd(opt,outline)
  270. else
  271. opt:=PadEnd('-'+opt,outline);
  272. if (ident=0) and (lastident<>0) then
  273. begin
  274. Comment(V_Normal,'');
  275. inc(Lines);
  276. end;
  277. { page full ? }
  278. if (lines >= page_size - 1) then
  279. begin
  280. if not NoPressEnter then
  281. begin
  282. Message(option_help_press_enter);
  283. readln(input);
  284. if upper(input)='Q' then
  285. StopOptions;
  286. end;
  287. lines:=0;
  288. end;
  289. Comment(V_Normal,PadEnd('',ident)+opt+Copy(s,j+1,255));
  290. LastIdent:=Ident;
  291. inc(Lines);
  292. end;
  293. end;
  294. StopOptions;
  295. end;
  296. procedure Toption.IllegalPara(const opt:string);
  297. begin
  298. Message1(option_illegal_para,opt);
  299. Message(option_help_pages_para);
  300. StopOptions;
  301. end;
  302. function Toption.Unsetbool(var Opts:string; Pos: Longint):boolean;
  303. { checks if the character after pos in Opts is a + or a - and returns resp.
  304. false or true. If it is another character (or none), it also returns false }
  305. begin
  306. UnsetBool := false;
  307. if Length(Opts)>Pos then
  308. begin
  309. inc(Pos);
  310. UnsetBool := Opts[Pos] = '-';
  311. if Opts[Pos] in ['-','+']then
  312. delete(Opts,Pos,1);
  313. end;
  314. end;
  315. procedure TOption.interpret_proc_specific_options(const opt:string);
  316. begin
  317. end;
  318. procedure TOption.interpret_option(const opt:string;ispara:boolean);
  319. var
  320. code : integer;
  321. c : char;
  322. more : string;
  323. major,minor : longint;
  324. error : integer;
  325. j,l : longint;
  326. d : DirStr;
  327. e : ExtStr;
  328. s : string;
  329. forceasm : tasm;
  330. begin
  331. if opt='' then
  332. exit;
  333. { only parse define,undef,target,verbosity and link options the firsttime }
  334. if firstpass and
  335. not((opt[1]='-') and (opt[2] in ['i','d','v','T','u','n','X'])) then
  336. exit;
  337. Message1(option_handling_option,opt);
  338. case opt[1] of
  339. '-' :
  340. begin
  341. more:=Copy(opt,3,255);
  342. if firstpass then
  343. Message1(option_interpreting_firstpass_option,opt)
  344. else
  345. Message1(option_interpreting_option,opt);
  346. case opt[2] of
  347. '?' :
  348. WriteHelpPages;
  349. 'a' :
  350. begin
  351. include(initglobalswitches,cs_asm_leave);
  352. j:=1;
  353. while j<=length(more) do
  354. begin
  355. case more[j] of
  356. 'l' :
  357. include(initglobalswitches,cs_asm_source);
  358. 'r' :
  359. include(initglobalswitches,cs_asm_regalloc);
  360. 't' :
  361. include(initglobalswitches,cs_asm_tempalloc);
  362. 'n' :
  363. include(initglobalswitches,cs_asm_nodes);
  364. 'p' :
  365. begin
  366. exclude(initglobalswitches,cs_asm_leave);
  367. if UnsetBool(More, 0) then
  368. exclude(initglobalswitches,cs_asm_pipe)
  369. else
  370. include(initglobalswitches,cs_asm_pipe);
  371. end;
  372. '-' :
  373. initglobalswitches:=initglobalswitches -
  374. [cs_asm_leave, cs_asm_source,cs_asm_regalloc, cs_asm_tempalloc,
  375. cs_asm_nodes, cs_asm_pipe];
  376. else
  377. IllegalPara(opt);
  378. end;
  379. inc(j);
  380. end;
  381. end;
  382. 'A' :
  383. begin
  384. if set_target_asm_by_string(More) then
  385. asm_is_set:=true
  386. else
  387. IllegalPara(opt);
  388. end;
  389. 'b' :
  390. begin
  391. if UnsetBool(More,0) then
  392. begin
  393. exclude(initmoduleswitches,cs_browser);
  394. exclude(initmoduleswitches,cs_local_browser);
  395. {$ifdef BrowserLog}
  396. exclude(initglobalswitches,cs_browser_log);
  397. {$endif}
  398. end
  399. else
  400. begin
  401. include(initmoduleswitches,cs_browser);
  402. {$ifdef BrowserLog}
  403. include(initglobalswitches,cs_browser_log);
  404. {$endif}
  405. end;
  406. if More<>'' then
  407. if (More='l') or (More='l+') then
  408. include(initmoduleswitches,cs_local_browser)
  409. else
  410. if More='l-' then
  411. exclude(initmoduleswitches,cs_local_browser)
  412. else
  413. {$ifdef BrowserLog}
  414. browserlog.elements_to_list.insert(more);
  415. {$else}
  416. IllegalPara(opt);
  417. {$endif}
  418. end;
  419. 'B' :
  420. do_build:=not UnSetBool(more,0);
  421. 'C' :
  422. begin
  423. j:=1;
  424. while j<=length(more) do
  425. begin
  426. case more[j] of
  427. 'a' :
  428. Message2(option_obsolete_switch_use_new,'-Ca','-Or');
  429. 'c' :
  430. begin
  431. if not SetAktProcCall(upper(copy(more,j+1,length(more)-j)),true) then
  432. IllegalPara(opt);
  433. break;
  434. end;
  435. {$ifdef cpufpemu}
  436. 'e' :
  437. begin
  438. If UnsetBool(More, j) then
  439. exclude(initmoduleswitches,cs_fp_emulation)
  440. Else
  441. include(initmoduleswitches,cs_fp_emulation);
  442. end;
  443. {$endif cpufpemu}
  444. 'f' :
  445. begin
  446. s:=upper(copy(more,j+1,length(more)-j));
  447. if not(SetFpuType(s,true)) then
  448. IllegalPara(opt);
  449. break;
  450. end;
  451. 'g' :
  452. include(initmoduleswitches,cs_create_pic);
  453. 'h' :
  454. begin
  455. val(copy(more,j+1,length(more)-j),heapsize,code);
  456. if (code<>0) or
  457. {$WARNING Is the upper limit for heapsize needed / useful?}
  458. { (heapsize>=67107840) or }
  459. (heapsize<1024) then
  460. IllegalPara(opt);
  461. break;
  462. end;
  463. 'i' :
  464. If UnsetBool(More, j) then
  465. exclude(initlocalswitches,cs_check_io)
  466. else
  467. include(initlocalswitches,cs_check_io);
  468. 'n' :
  469. If UnsetBool(More, j) then
  470. exclude(initglobalswitches,cs_link_extern)
  471. Else
  472. include(initglobalswitches,cs_link_extern);
  473. 'o' :
  474. If UnsetBool(More, j) then
  475. exclude(initlocalswitches,cs_check_overflow)
  476. Else
  477. include(initlocalswitches,cs_check_overflow);
  478. 'p' :
  479. begin
  480. s:=upper(copy(more,j+1,length(more)-j));
  481. if not(SetProcessor(s,true)) then
  482. IllegalPara(opt);
  483. break;
  484. end;
  485. 'r' :
  486. If UnsetBool(More, j) then
  487. exclude(initlocalswitches,cs_check_range)
  488. Else
  489. include(initlocalswitches,cs_check_range);
  490. 'R' :
  491. If UnsetBool(More, j) then
  492. begin
  493. exclude(initlocalswitches,cs_check_range);
  494. exclude(initlocalswitches,cs_check_object);
  495. end
  496. Else
  497. begin
  498. include(initlocalswitches,cs_check_range);
  499. include(initlocalswitches,cs_check_object);
  500. end;
  501. 's' :
  502. begin
  503. val(copy(more,j+1,length(more)-j),stacksize,code);
  504. if (code<>0) or (stacksize>=67107840) or (stacksize<1024) then
  505. IllegalPara(opt);
  506. break;
  507. end;
  508. 't' :
  509. If UnsetBool(More, j) then
  510. exclude(initlocalswitches,cs_check_stack)
  511. Else
  512. include(initlocalswitches,cs_check_stack);
  513. 'D' :
  514. If UnsetBool(More, j) then
  515. exclude(initmoduleswitches,cs_create_dynamic)
  516. Else
  517. include(initmoduleswitches,cs_create_dynamic);
  518. 'X' :
  519. If UnsetBool(More, j) then
  520. exclude(initmoduleswitches,cs_create_smart)
  521. Else
  522. include(initmoduleswitches,cs_create_smart);
  523. else
  524. IllegalPara(opt);
  525. end;
  526. inc(j);
  527. end;
  528. end;
  529. 'd' :
  530. def_symbol(more);
  531. 'D' :
  532. begin
  533. include(initglobalswitches,cs_link_deffile);
  534. j:=1;
  535. while j<=length(more) do
  536. begin
  537. case more[j] of
  538. 'd' :
  539. begin
  540. description:=Copy(more,j+1,255);
  541. break;
  542. end;
  543. 'v' :
  544. begin
  545. dllversion:=Copy(more,j+1,255);
  546. l:=pos('.',dllversion);
  547. dllminor:=0;
  548. error:=0;
  549. if l>0 then
  550. begin
  551. valint(copy(dllversion,l+1,255),minor,error);
  552. if (error=0) and
  553. (minor>=0) and (minor<=$ffff) then
  554. dllminor:=minor
  555. else
  556. if error=0 then
  557. error:=1;
  558. end;
  559. if l=0 then
  560. l:=256;
  561. dllmajor:=1;
  562. if error=0 then
  563. valint(copy(dllversion,1,l-1),major,error);
  564. if (error=0) and (major>=0) and (major<=$ffff) then
  565. dllmajor:=major
  566. else
  567. if error=0 then
  568. error:=1;
  569. if error<>0 then
  570. Message1(scan_w_wrong_version_ignored,dllversion);
  571. break;
  572. end;
  573. 'w' :
  574. usewindowapi:=true;
  575. '-' :
  576. begin
  577. exclude(initglobalswitches,cs_link_deffile);
  578. usewindowapi:=false;
  579. end;
  580. else
  581. IllegalPara(opt);
  582. end;
  583. inc(j);
  584. end;
  585. end;
  586. 'e' :
  587. exepath:=FixPath(More,true);
  588. 'E' :
  589. begin
  590. if UnsetBool(More, 0) then
  591. exclude(initglobalswitches,cs_link_extern)
  592. else
  593. include(initglobalswitches,cs_link_extern);
  594. end;
  595. 'F' :
  596. begin
  597. c:=more[1];
  598. Delete(more,1,1);
  599. DefaultReplacements(More);
  600. case c of
  601. 'c' :
  602. begin
  603. if not(cpavailable(more)) then
  604. Message1(option_code_page_not_available,more)
  605. else
  606. initsourcecodepage:=more;
  607. end;
  608. 'D' :
  609. utilsdirectory:=FixPath(More,true);
  610. 'e' :
  611. SetRedirectFile(More);
  612. 'E' :
  613. OutputExeDir:=FixPath(More,true);
  614. 'i' :
  615. begin
  616. if ispara then
  617. ParaIncludePath.AddPath(More,false)
  618. else
  619. includesearchpath.AddPath(More,true);
  620. end;
  621. 'g' :
  622. Message2(option_obsolete_switch_use_new,'-Fg','-Fl');
  623. 'l' :
  624. begin
  625. if ispara then
  626. ParaLibraryPath.AddPath(More,false)
  627. else
  628. LibrarySearchPath.AddPath(More,true);
  629. end;
  630. 'L' :
  631. begin
  632. if More<>'' then
  633. ParaDynamicLinker:=More
  634. else
  635. IllegalPara(opt);
  636. end;
  637. 'o' :
  638. begin
  639. if ispara then
  640. ParaObjectPath.AddPath(More,false)
  641. else
  642. ObjectSearchPath.AddPath(More,true);
  643. end;
  644. 'r' :
  645. Msgfilename:=More;
  646. 'u' :
  647. begin
  648. if ispara then
  649. ParaUnitPath.AddPath(More,false)
  650. else
  651. unitsearchpath.AddPath(More,true);
  652. end;
  653. 'U' :
  654. OutputUnitDir:=FixPath(More,true);
  655. else
  656. IllegalPara(opt);
  657. end;
  658. end;
  659. 'g' : begin
  660. if UnsetBool(More, 0) then
  661. begin
  662. exclude(initmoduleswitches,cs_debuginfo);
  663. exclude(initglobalswitches,cs_gdb_dbx);
  664. exclude(initglobalswitches,cs_gdb_gsym);
  665. exclude(initglobalswitches,cs_gdb_heaptrc);
  666. exclude(initglobalswitches,cs_gdb_lineinfo);
  667. exclude(initglobalswitches,cs_checkpointer);
  668. end
  669. else
  670. begin
  671. {$ifdef GDB}
  672. include(initmoduleswitches,cs_debuginfo);
  673. if not RelocSectionSetExplicitly then
  674. RelocSection:=false;
  675. j:=1;
  676. while j<=length(more) do
  677. begin
  678. case more[j] of
  679. 'd' :
  680. begin
  681. if UnsetBool(More, j) then
  682. exclude(initglobalswitches,cs_gdb_dbx)
  683. else
  684. include(initglobalswitches,cs_gdb_dbx);
  685. end;
  686. 'g' :
  687. begin
  688. if UnsetBool(More, j) then
  689. exclude(initglobalswitches,cs_gdb_gsym)
  690. else
  691. include(initglobalswitches,cs_gdb_gsym);
  692. end;
  693. 'h' :
  694. begin
  695. if UnsetBool(More, j) then
  696. exclude(initglobalswitches,cs_gdb_heaptrc)
  697. else
  698. include(initglobalswitches,cs_gdb_heaptrc);
  699. end;
  700. 'l' :
  701. begin
  702. if UnsetBool(More, j) then
  703. exclude(initglobalswitches,cs_gdb_lineinfo)
  704. else
  705. include(initglobalswitches,cs_gdb_lineinfo);
  706. end;
  707. 'c' :
  708. begin
  709. if UnsetBool(More, j) then
  710. exclude(initglobalswitches,cs_checkpointer)
  711. else
  712. include(initglobalswitches,cs_checkpointer);
  713. end;
  714. 'v' :
  715. begin
  716. if UnsetBool(More, j) then
  717. exclude(initglobalswitches,cs_gdb_valgrind)
  718. else
  719. include(initglobalswitches,cs_gdb_valgrind);
  720. end;
  721. else
  722. IllegalPara(opt);
  723. end;
  724. inc(j);
  725. end;
  726. {$else GDB}
  727. Message(option_no_debug_support);
  728. Message(option_no_debug_support_recompile_fpc);
  729. {$endif GDB}
  730. end;
  731. end;
  732. 'h' :
  733. begin
  734. NoPressEnter:=true;
  735. WriteHelpPages;
  736. end;
  737. 'i' :
  738. begin
  739. if More='' then
  740. WriteInfo
  741. else
  742. QuickInfo:=QuickInfo+More;
  743. end;
  744. 'I' :
  745. begin
  746. if ispara then
  747. ParaIncludePath.AddPath(More,false)
  748. else
  749. includesearchpath.AddPath(More,false);
  750. end;
  751. 'k' :
  752. begin
  753. if more<>'' then
  754. ParaLinkOptions:=ParaLinkOptions+' '+More
  755. else
  756. IllegalPara(opt);
  757. end;
  758. 'l' :
  759. DoWriteLogo:=not UnSetBool(more,0);
  760. 'm' :
  761. parapreprocess:=not UnSetBool(more,0);
  762. 'n' :
  763. begin
  764. if More='' then
  765. disable_configfile:=true
  766. else
  767. IllegalPara(opt);
  768. end;
  769. 'o' :
  770. begin
  771. if More<>'' then
  772. Fsplit(More,d,OutputFile,e)
  773. else
  774. IllegalPara(opt);
  775. end;
  776. 'p' :
  777. begin
  778. if UnsetBool(More, 0) then
  779. begin
  780. initmoduleswitches:=initmoduleswitches-[cs_profile];
  781. undef_symbol('FPC_PROFILE');
  782. end
  783. else
  784. if Length(More)=0 then
  785. IllegalPara(opt)
  786. else
  787. case more[1] of
  788. 'g' : if UnsetBool(more, 1) then
  789. begin
  790. exclude(initmoduleswitches,cs_profile);
  791. undef_symbol('FPC_PROFILE');
  792. end
  793. else
  794. begin
  795. include(initmoduleswitches,cs_profile);
  796. def_symbol('FPC_PROFILE');
  797. end;
  798. else
  799. IllegalPara(opt);
  800. end;
  801. end;
  802. {$ifdef Unix}
  803. 'P' : ; { Ignore used by fpc.pp }
  804. {$endif Unix}
  805. 's' :
  806. begin
  807. if UnsetBool(More, 0) then
  808. begin
  809. initglobalswitches:=initglobalswitches-[cs_asm_extern,cs_link_extern];
  810. if more<>'' then
  811. IllegalPara(opt);
  812. end
  813. else
  814. begin
  815. initglobalswitches:=initglobalswitches+[cs_asm_extern,cs_link_extern];
  816. if more='h' then
  817. initglobalswitches:=initglobalswitches-[cs_link_on_target]
  818. else if more='t' then
  819. initglobalswitches:=initglobalswitches+[cs_link_on_target]
  820. else if more='r' then
  821. initglobalswitches:=initglobalswitches+[cs_asm_leave,cs_no_regalloc]
  822. else if more<>'' then
  823. IllegalPara(opt);
  824. end;
  825. end;
  826. 'M' :
  827. begin
  828. more:=Upper(more);
  829. if not SetCompileMode(more, true) then
  830. IllegalPara(opt);
  831. end;
  832. 'S' :
  833. begin
  834. if more[1]='I' then
  835. begin
  836. if upper(more)='ICOM' then
  837. initinterfacetype:=it_interfacecom
  838. else if upper(more)='ICORBA' then
  839. initinterfacetype:=it_interfacecorba
  840. else
  841. IllegalPara(opt);
  842. end
  843. else
  844. begin
  845. j:=1;
  846. while j<=length(more) do
  847. begin
  848. case more[j] of
  849. '2' : //an alternative to -Mobjfpc
  850. SetCompileMode('OBJFPC',true);
  851. 'a' :
  852. include(initlocalswitches,cs_do_assertion);
  853. 'c' :
  854. include(initmoduleswitches,cs_support_c_operators);
  855. 'd' : //an alternative to -Mdelphi
  856. SetCompileMode('DELPHI',true);
  857. 'e' :
  858. begin
  859. SetErrorFlags(copy(more,j+1,length(more)));
  860. break;
  861. end;
  862. 'g' :
  863. include(initmoduleswitches,cs_support_goto);
  864. 'h' :
  865. include(initlocalswitches,cs_ansistrings);
  866. 'i' :
  867. include(initmoduleswitches,cs_support_inline);
  868. 'm' :
  869. include(initmoduleswitches,cs_support_macro);
  870. 'o' : //an alternative to -Mtp
  871. SetCompileMode('TP',true);
  872. 'p' : //an alternative to -Mgpc
  873. SetCompileMode('GPC',true);
  874. 's' :
  875. include(initglobalswitches,cs_constructor_name);
  876. 't' :
  877. include(initmoduleswitches,cs_static_keyword);
  878. '-' :
  879. begin
  880. exclude(initglobalswitches,cs_constructor_name);
  881. initlocalswitches:=InitLocalswitches - [cs_do_assertion, cs_ansistrings];
  882. initmoduleswitches:=initmoduleswitches - [cs_support_c_operators, cs_support_goto,
  883. cs_support_inline, cs_support_macro,
  884. cs_static_keyword];
  885. end;
  886. else
  887. IllegalPara(opt);
  888. end;
  889. inc(j);
  890. end;
  891. end;
  892. end;
  893. 'T' :
  894. begin
  895. more:=Upper(More);
  896. if not target_is_set then
  897. begin
  898. { remove old target define }
  899. TargetDefines(false);
  900. { Save assembler if set }
  901. if asm_is_set then
  902. forceasm:=target_asm.id;
  903. { load new target }
  904. if not(set_target_by_string(More)) then
  905. IllegalPara(opt);
  906. { also initialize assembler if not explicitly set }
  907. if asm_is_set then
  908. set_target_asm(forceasm);
  909. { set new define }
  910. TargetDefines(true);
  911. target_is_set:=true;
  912. end
  913. else
  914. if More<>upper(target_info.shortname) then
  915. Message1(option_target_is_already_set,target_info.shortname);
  916. end;
  917. 'u' :
  918. undef_symbol(upper(More));
  919. 'U' :
  920. begin
  921. j:=1;
  922. while j<=length(more) do
  923. begin
  924. case more[j] of
  925. {$ifdef UNITALIASES}
  926. 'a' :
  927. begin
  928. AddUnitAlias(Copy(More,j+1,255));
  929. break;
  930. end;
  931. {$endif UNITALIASES}
  932. 'n' :
  933. exclude(initglobalswitches,cs_check_unit_name);
  934. 'p' :
  935. begin
  936. Message2(option_obsolete_switch_use_new,'-Up','-Fu');
  937. break;
  938. end;
  939. 'r' :
  940. do_release:=true;
  941. 's' :
  942. include(initmoduleswitches,cs_compilesystem);
  943. '-' :
  944. begin
  945. exclude(initmoduleswitches,cs_compilesystem);
  946. exclude(initglobalswitches,cs_check_unit_name);
  947. end;
  948. else
  949. IllegalPara(opt);
  950. end;
  951. inc(j);
  952. end;
  953. end;
  954. 'v' :
  955. begin
  956. if not setverbosity(More) then
  957. IllegalPara(opt);
  958. end;
  959. 'V' : ; { Ignore used by fpc }
  960. 'W' :
  961. begin
  962. j:=1;
  963. while j<=length(More) do
  964. begin
  965. case More[j] of
  966. 'B':
  967. begin
  968. { -WB200000 means set trefered base address
  969. to $200000, but does not change relocsection boolean
  970. this way we can create both relocatble and
  971. non relocatable DLL at a specific base address PM }
  972. if (length(More)>j) then
  973. begin
  974. if DLLImageBase=nil then
  975. DLLImageBase:=StringDup(Copy(More,j+1,255));
  976. end
  977. else
  978. begin
  979. RelocSection:=true;
  980. RelocSectionSetExplicitly:=true;
  981. end;
  982. break;
  983. end;
  984. 'C':
  985. begin
  986. if UnsetBool(More, j) then
  987. apptype:=app_gui
  988. else
  989. apptype:=app_cui;
  990. end;
  991. 'D':
  992. ForceDeffileForExport:=not UnsetBool(More, j);
  993. 'F':
  994. begin
  995. if UnsetBool(More, j) then
  996. apptype:=app_cui
  997. else
  998. apptype:=app_fs;
  999. end;
  1000. 'G':
  1001. begin
  1002. if UnsetBool(More, j) then
  1003. apptype:=app_cui
  1004. else
  1005. apptype:=app_gui;
  1006. end;
  1007. 'T':
  1008. begin
  1009. if UnsetBool(More, j) then
  1010. apptype:=app_cui
  1011. else
  1012. apptype:=app_tool;
  1013. end;
  1014. 'N':
  1015. begin
  1016. RelocSection:=UnsetBool(More,j);
  1017. RelocSectionSetExplicitly:=true;
  1018. end;
  1019. 'R':
  1020. begin
  1021. { support -WR+ / -WR- as synonyms to -WR / -WN }
  1022. RelocSection:=not UnsetBool(More,j);
  1023. RelocSectionSetExplicitly:=true;
  1024. end;
  1025. else
  1026. IllegalPara(opt);
  1027. end;
  1028. inc(j);
  1029. end;
  1030. end;
  1031. 'X' :
  1032. begin
  1033. j:=1;
  1034. while j<=length(more) do
  1035. begin
  1036. case More[j] of
  1037. 'i' :
  1038. include(initglobalswitches,cs_link_internal);
  1039. 'm' :
  1040. include(initglobalswitches,cs_link_map);
  1041. 'f' :
  1042. include(initglobalswitches,cs_link_pthread);
  1043. 's' :
  1044. include(initglobalswitches,cs_link_strip);
  1045. 'c' : Cshared:=TRUE;
  1046. 't' :
  1047. include(initglobalswitches,cs_link_staticflag);
  1048. 'D' :
  1049. begin
  1050. def_symbol('FPC_LINK_DYNAMIC');
  1051. undef_symbol('FPC_LINK_SMART');
  1052. undef_symbol('FPC_LINK_STATIC');
  1053. exclude(initglobalswitches,cs_link_static);
  1054. exclude(initglobalswitches,cs_link_smart);
  1055. include(initglobalswitches,cs_link_shared);
  1056. LinkTypeSetExplicitly:=true;
  1057. end;
  1058. 'd' : Dontlinkstdlibpath:=TRUE;
  1059. 'P' : Begin
  1060. utilsprefix:=Copy(more,2,length(More)-1);
  1061. More:='';
  1062. End;
  1063. 'r' : Begin
  1064. rlinkpath:=Copy(more,2,length(More)-1);
  1065. More:='';
  1066. end;
  1067. 'S' :
  1068. begin
  1069. def_symbol('FPC_LINK_STATIC');
  1070. undef_symbol('FPC_LINK_SMART');
  1071. undef_symbol('FPC_LINK_DYNAMIC');
  1072. include(initglobalswitches,cs_link_static);
  1073. exclude(initglobalswitches,cs_link_smart);
  1074. exclude(initglobalswitches,cs_link_shared);
  1075. LinkTypeSetExplicitly:=true;
  1076. end;
  1077. 'X' :
  1078. begin
  1079. def_symbol('FPC_LINK_SMART');
  1080. undef_symbol('FPC_LINK_STATIC');
  1081. undef_symbol('FPC_LINK_DYNAMIC');
  1082. exclude(initglobalswitches,cs_link_static);
  1083. include(initglobalswitches,cs_link_smart);
  1084. exclude(initglobalswitches,cs_link_shared);
  1085. LinkTypeSetExplicitly:=true;
  1086. end;
  1087. '-' :
  1088. begin
  1089. exclude(initglobalswitches,cs_link_staticflag);
  1090. exclude(initglobalswitches,cs_link_strip);
  1091. exclude(initglobalswitches,cs_link_map);
  1092. set_default_link_type;
  1093. end;
  1094. else
  1095. IllegalPara(opt);
  1096. end;
  1097. inc(j);
  1098. end;
  1099. end;
  1100. { give processor specific options a chance }
  1101. else
  1102. interpret_proc_specific_options(opt);
  1103. end;
  1104. end;
  1105. '@' :
  1106. begin
  1107. Message(option_no_nested_response_file);
  1108. StopOptions;
  1109. end;
  1110. else
  1111. begin
  1112. if (length(param_file)<>0) then
  1113. Message(option_only_one_source_support);
  1114. param_file:=opt;
  1115. Message1(option_found_file,opt);
  1116. end;
  1117. end;
  1118. end;
  1119. procedure Toption.Interpret_file(const filename : string);
  1120. procedure RemoveSep(var fn:string);
  1121. var
  1122. i : longint;
  1123. begin
  1124. i:=0;
  1125. while (i<length(fn)) and (fn[i+1] in [',',' ',#9]) do
  1126. inc(i);
  1127. Delete(fn,1,i);
  1128. i:=length(fn);
  1129. while (i>0) and (fn[i] in [',',' ',#9]) do
  1130. dec(i);
  1131. fn:=copy(fn,1,i);
  1132. end;
  1133. function GetName(var fn:string):string;
  1134. var
  1135. i : longint;
  1136. begin
  1137. i:=0;
  1138. while (i<length(fn)) and (fn[i+1] in ['a'..'z','A'..'Z','0'..'9','_','-']) do
  1139. inc(i);
  1140. GetName:=Copy(fn,1,i);
  1141. Delete(fn,1,i);
  1142. end;
  1143. const
  1144. maxlevel=16;
  1145. var
  1146. f : text;
  1147. s,
  1148. opts : string;
  1149. skip : array[0..maxlevel-1] of boolean;
  1150. level : longint;
  1151. option_read : boolean;
  1152. begin
  1153. { avoid infinite loop }
  1154. Inc(FileLevel);
  1155. Option_read:=false;
  1156. If FileLevel>MaxLevel then
  1157. Message(option_too_many_cfg_files);
  1158. { open file }
  1159. Message1(option_using_file,filename);
  1160. assign(f,filename);
  1161. {$I-}
  1162. reset(f);
  1163. {$I+}
  1164. if ioresult<>0 then
  1165. begin
  1166. Message1(option_unable_open_file,filename);
  1167. exit;
  1168. end;
  1169. Message1(option_start_reading_configfile,filename);
  1170. fillchar(skip,sizeof(skip),0);
  1171. level:=0;
  1172. while not eof(f) do
  1173. begin
  1174. readln(f,opts);
  1175. RemoveSep(opts);
  1176. if (opts<>'') and (opts[1]<>';') then
  1177. begin
  1178. if opts[1]='#' then
  1179. begin
  1180. Message1(option_interpreting_file_option,opts);
  1181. Delete(opts,1,1);
  1182. s:=upper(GetName(opts));
  1183. if (s='SECTION') then
  1184. begin
  1185. RemoveSep(opts);
  1186. s:=upper(GetName(opts));
  1187. if level=0 then
  1188. skip[level]:=not (check_symbol(s) or (s='COMMON'));
  1189. end
  1190. else
  1191. if (s='IFDEF') then
  1192. begin
  1193. RemoveSep(opts);
  1194. if Level>=maxlevel then
  1195. begin
  1196. Message(option_too_many_ifdef);
  1197. stopOptions;
  1198. end;
  1199. inc(Level);
  1200. skip[level]:=(skip[level-1] or (not check_symbol(upper(GetName(opts)))));
  1201. end
  1202. else
  1203. if (s='IFNDEF') then
  1204. begin
  1205. RemoveSep(opts);
  1206. if Level>=maxlevel then
  1207. begin
  1208. Message(option_too_many_ifdef);
  1209. stopOptions;
  1210. end;
  1211. inc(Level);
  1212. skip[level]:=(skip[level-1] or (check_symbol(upper(GetName(opts)))));
  1213. end
  1214. else
  1215. if (s='ELSE') then
  1216. skip[level]:=skip[level-1] or (not skip[level])
  1217. else
  1218. if (s='ENDIF') then
  1219. begin
  1220. skip[level]:=false;
  1221. if Level=0 then
  1222. begin
  1223. Message(option_too_many_endif);
  1224. stopOptions;
  1225. end;
  1226. dec(level);
  1227. end
  1228. else
  1229. if (not skip[level]) then
  1230. begin
  1231. if (s='DEFINE') then
  1232. begin
  1233. RemoveSep(opts);
  1234. def_symbol(upper(GetName(opts)));
  1235. end
  1236. else
  1237. if (s='UNDEF') then
  1238. begin
  1239. RemoveSep(opts);
  1240. undef_symbol(upper(GetName(opts)));
  1241. end
  1242. else
  1243. if (s='WRITE') then
  1244. begin
  1245. Delete(opts,1,1);
  1246. WriteLn(opts);
  1247. end
  1248. else
  1249. if (s='INCLUDE') then
  1250. begin
  1251. Delete(opts,1,1);
  1252. Interpret_file(opts);
  1253. end;
  1254. end;
  1255. end
  1256. else
  1257. begin
  1258. if (opts[1]='-') or (opts[1]='@') then
  1259. begin
  1260. if (not skip[level]) then
  1261. interpret_option(opts,false);
  1262. Option_read:=true;
  1263. end
  1264. else
  1265. Message1(option_illegal_para,opts);
  1266. end;
  1267. end;
  1268. end;
  1269. if Level>0 then
  1270. Message(option_too_less_endif);
  1271. if Not Option_read then
  1272. Message1(option_no_option_found,filename)
  1273. else
  1274. Message1(option_end_reading_configfile,filename);
  1275. Close(f);
  1276. Dec(FileLevel);
  1277. end;
  1278. procedure Toption.Interpret_envvar(const envname : string);
  1279. var
  1280. argstart,
  1281. env,
  1282. pc : pchar;
  1283. arglen : longint;
  1284. quote : set of char;
  1285. hs : string;
  1286. begin
  1287. Message1(option_using_env,envname);
  1288. env:=GetEnvPChar(envname);
  1289. pc:=env;
  1290. if assigned(pc) then
  1291. begin
  1292. repeat
  1293. { skip leading spaces }
  1294. while pc^ in [' ',#9,#13] do
  1295. inc(pc);
  1296. case pc^ of
  1297. #0 :
  1298. break;
  1299. '"' :
  1300. begin
  1301. quote:=['"'];
  1302. inc(pc);
  1303. end;
  1304. '''' :
  1305. begin
  1306. quote:=[''''];
  1307. inc(pc);
  1308. end;
  1309. else
  1310. quote:=[' ',#9,#13];
  1311. end;
  1312. { scan until the end of the argument }
  1313. argstart:=pc;
  1314. while (pc^<>#0) and not(pc^ in quote) do
  1315. inc(pc);
  1316. { create argument }
  1317. arglen:=pc-argstart;
  1318. hs[0]:=chr(arglen);
  1319. move(argstart^,hs[1],arglen);
  1320. interpret_option(hs,true);
  1321. { skip quote }
  1322. if pc^ in quote then
  1323. inc(pc);
  1324. until false;
  1325. end
  1326. else
  1327. Message1(option_no_option_found,'(env) '+envname);
  1328. FreeEnvPChar(env);
  1329. end;
  1330. procedure toption.read_parameters;
  1331. var
  1332. opts : string;
  1333. paramindex : longint;
  1334. begin
  1335. paramindex:=0;
  1336. while paramindex<paramcount do
  1337. begin
  1338. inc(paramindex);
  1339. opts:=system.paramstr(paramindex);
  1340. case opts[1] of
  1341. '@' :
  1342. if not firstpass then
  1343. begin
  1344. Delete(opts,1,1);
  1345. Message1(option_reading_further_from,opts);
  1346. interpret_file(opts);
  1347. end;
  1348. '!' :
  1349. if not firstpass then
  1350. begin
  1351. Delete(opts,1,1);
  1352. Message1(option_reading_further_from,'(env) '+opts);
  1353. interpret_envvar(opts);
  1354. end;
  1355. else
  1356. interpret_option(opts,true);
  1357. end;
  1358. end;
  1359. end;
  1360. procedure toption.parsecmd(cmd:string);
  1361. var
  1362. i,ps : longint;
  1363. opts : string;
  1364. begin
  1365. while (cmd<>'') do
  1366. begin
  1367. while cmd[1]=' ' do
  1368. delete(cmd,1,1);
  1369. i:=pos(' ',cmd);
  1370. if i=0 then
  1371. i:=256;
  1372. opts:=Copy(cmd,1,i-1);
  1373. Delete(cmd,1,i);
  1374. case opts[1] of
  1375. '@' :
  1376. if not firstpass then
  1377. begin
  1378. Delete(opts,1,1);
  1379. Message1(option_reading_further_from,opts);
  1380. interpret_file(opts);
  1381. end;
  1382. '!' :
  1383. if not firstpass then
  1384. begin
  1385. Delete(opts,1,1);
  1386. Message1(option_reading_further_from,'(env) '+opts);
  1387. interpret_envvar(opts);
  1388. end;
  1389. '"' :
  1390. begin
  1391. Delete(opts,1,1);
  1392. ps:=pos('"',cmd);
  1393. if (i<>256) and (ps>0) then
  1394. begin
  1395. opts:=opts + ' '+ copy(cmd,1,ps-1);
  1396. cmd:=copy(cmd,ps+1,255);
  1397. end;
  1398. interpret_option(opts,true);
  1399. end;
  1400. else
  1401. interpret_option(opts,true);
  1402. end;
  1403. end;
  1404. end;
  1405. procedure toption.writequickinfo;
  1406. var
  1407. s : string;
  1408. i : longint;
  1409. procedure addinfo(const hs:string);
  1410. begin
  1411. if s<>'' then
  1412. s:=s+' '+hs
  1413. else
  1414. s:=hs;
  1415. end;
  1416. begin
  1417. s:='';
  1418. i:=0;
  1419. while (i<length(quickinfo)) do
  1420. begin
  1421. inc(i);
  1422. case quickinfo[i] of
  1423. 'S' :
  1424. begin
  1425. inc(i);
  1426. case quickinfo[i] of
  1427. 'O' :
  1428. addinfo(lower(source_info.shortname));
  1429. {$ifdef Delphi}
  1430. 'P' :
  1431. addinfo('i386');
  1432. {$else Delphi}
  1433. 'P' :
  1434. addinfo(source_cpu_string);
  1435. {$endif Delphi}
  1436. else
  1437. IllegalPara('-i'+QuickInfo);
  1438. end;
  1439. end;
  1440. 'T' :
  1441. begin
  1442. inc(i);
  1443. case quickinfo[i] of
  1444. 'O' :
  1445. addinfo(lower(target_info.shortname));
  1446. 'P' :
  1447. AddInfo(target_cpu_string);
  1448. else
  1449. IllegalPara('-i'+QuickInfo);
  1450. end;
  1451. end;
  1452. 'V' :
  1453. AddInfo(version_string);
  1454. 'D' :
  1455. AddInfo(date_string);
  1456. '_' :
  1457. ;
  1458. else
  1459. IllegalPara('-i'+QuickInfo);
  1460. end;
  1461. end;
  1462. if s<>'' then
  1463. begin
  1464. writeln(s);
  1465. stopoptions;
  1466. end;
  1467. end;
  1468. procedure TOption.TargetDefines(def:boolean);
  1469. var
  1470. s : string;
  1471. i : integer;
  1472. begin
  1473. if def then
  1474. def_symbol(upper(target_info.shortname))
  1475. else
  1476. undef_symbol(upper(target_info.shortname));
  1477. s:=target_info.extradefines;
  1478. while (s<>'') do
  1479. begin
  1480. i:=pos(';',s);
  1481. if i=0 then
  1482. i:=length(s)+1;
  1483. if def then
  1484. def_symbol(Copy(s,1,i-1))
  1485. else
  1486. undef_symbol(Copy(s,1,i-1));
  1487. delete(s,1,i);
  1488. end;
  1489. end;
  1490. constructor TOption.create;
  1491. begin
  1492. DoWriteLogo:=false;
  1493. NoPressEnter:=false;
  1494. FirstPass:=false;
  1495. FileLevel:=0;
  1496. Quickinfo:='';
  1497. ParaIncludePath:=TSearchPathList.Create;
  1498. ParaObjectPath:=TSearchPathList.Create;
  1499. ParaUnitPath:=TSearchPathList.Create;
  1500. ParaLibraryPath:=TSearchPathList.Create;
  1501. FillChar(ParaAlignment,sizeof(ParaAlignment),0);
  1502. end;
  1503. destructor TOption.destroy;
  1504. begin
  1505. ParaIncludePath.Free;
  1506. ParaObjectPath.Free;
  1507. ParaUnitPath.Free;
  1508. ParaLibraryPath.Free;
  1509. end;
  1510. {****************************************************************************
  1511. Callable Routines
  1512. ****************************************************************************}
  1513. function check_configfile(const fn:string;var foundfn:string):boolean;
  1514. function CfgFileExists(const fn:string):boolean;
  1515. begin
  1516. Comment(V_Tried,'Configfile search: '+fn);
  1517. CfgFileExists:=FileExists(fn);
  1518. end;
  1519. var
  1520. configpath : pathstr;
  1521. begin
  1522. foundfn:=fn;
  1523. check_configfile:=true;
  1524. { retrieve configpath }
  1525. {$ifdef Delphi}
  1526. configpath:=FixPath(dmisc.getenv('PPC_CONFIG_PATH'),false);
  1527. {$else Delphi}
  1528. configpath:=FixPath(dos.getenv('PPC_CONFIG_PATH'),false);
  1529. {$endif Delphi}
  1530. {$ifdef Unix}
  1531. if configpath='' then
  1532. configpath:='/etc/';
  1533. {$endif}
  1534. {
  1535. Order to read configuration file :
  1536. try reading fpc.cfg in :
  1537. 1 - current dir
  1538. 2 - configpath
  1539. 3 - compiler path
  1540. }
  1541. if not FileExists(fn) then
  1542. begin
  1543. {$ifdef Unix}
  1544. if (dos.getenv('HOME')<>'') and CfgFileExists(FixPath(dos.getenv('HOME'),false)+'.'+fn) then
  1545. foundfn:=FixPath(dos.getenv('HOME'),false)+'.'+fn
  1546. else
  1547. {$endif}
  1548. if CfgFileExists(configpath+fn) then
  1549. foundfn:=configpath+fn
  1550. else
  1551. {$ifndef Unix}
  1552. if CfgFileExists(exepath+fn) then
  1553. foundfn:=exepath+fn
  1554. else
  1555. {$endif}
  1556. check_configfile:=false;
  1557. end;
  1558. end;
  1559. procedure read_arguments(cmd:string);
  1560. begin
  1561. option:=coption.create;
  1562. disable_configfile:=false;
  1563. { default defines }
  1564. def_symbol(upper(target_info.shortname));
  1565. def_symbol('FPC');
  1566. def_symbol('VER'+version_nr);
  1567. def_symbol('VER'+version_nr+'_'+release_nr);
  1568. def_symbol('VER'+version_nr+'_'+release_nr+'_'+patch_nr);
  1569. { Temporary defines, until things settle down }
  1570. def_symbol('HASWIDECHAR');
  1571. def_symbol('HASWIDESTRING');
  1572. def_symbol('HASOUT');
  1573. def_symbol('HASGLOBALPROPERTY');
  1574. def_symbol('FPC_HASPREFETCH');
  1575. {$ifdef i386}
  1576. def_symbol('HASINTF');
  1577. def_symbol('HASVARIANT');
  1578. {$endif i386}
  1579. {$ifdef powerpc}
  1580. def_symbol('HASINTF');
  1581. def_symbol('HASVARIANT');
  1582. def_symbol('FPC_MTFSB0_CORRECTED');
  1583. {$endif powerpc}
  1584. {$ifdef arm}
  1585. def_symbol('HASINTF');
  1586. def_symbol('HASVARIANT');
  1587. {$endif arm}
  1588. def_symbol('INTERNSETLENGTH');
  1589. def_symbol('INTERNLENGTH');
  1590. def_symbol('INTERNCOPY');
  1591. def_symbol('INT64FUNCRESOK');
  1592. def_symbol('HAS_ADDR_STACK_ON_STACK');
  1593. def_symbol('NOBOUNDCHECK');
  1594. def_symbol('HASCOMPILERPROC');
  1595. def_symbol('VALUEGETMEM');
  1596. def_symbol('VALUEFREEMEM');
  1597. def_symbol('HASCURRENCY');
  1598. def_symbol('HASTHREADVAR');
  1599. def_symbol('HAS_GENERICCONSTRUCTOR');
  1600. def_symbol('NOCLASSHELPERS');
  1601. if pocall_default = pocall_register then
  1602. def_symbol('REGCALL');
  1603. def_symbol('DECRREFNOTNIL');
  1604. def_symbol('HAS_INTERNAL_INTTYPES');
  1605. { using a case is pretty useless here (FK) }
  1606. { some stuff for TP compatibility }
  1607. {$ifdef i386}
  1608. def_symbol('CPU86');
  1609. def_symbol('CPU87');
  1610. {$endif}
  1611. {$ifdef m68k}
  1612. def_symbol('CPU68');
  1613. {$endif}
  1614. { new processor stuff }
  1615. {$ifdef i386}
  1616. def_symbol('CPUI386');
  1617. def_symbol('CPU32');
  1618. def_symbol('FPC_HAS_TYPE_EXTENDED');
  1619. def_symbol('FPC_HAS_TYPE_DOUBLE');
  1620. def_symbol('FPC_HAS_TYPE_SINGLE');
  1621. {$endif}
  1622. {$ifdef m68k}
  1623. def_symbol('CPU68K');
  1624. def_symbol('CPU32');
  1625. def_symbol('FPC_CURRENCY_IS_INT64');
  1626. def_symbol('FPC_COMP_IS_INT64');
  1627. {$endif}
  1628. {$ifdef ALPHA}
  1629. def_symbol('CPUALPHA');
  1630. def_symbol('CPU64');
  1631. {$endif}
  1632. {$ifdef powerpc}
  1633. def_symbol('CPUPOWERPC');
  1634. def_symbol('CPUPOWERPC32');
  1635. def_symbol('CPU32');
  1636. def_symbol('FPC_HAS_TYPE_DOUBLE');
  1637. def_symbol('FPC_HAS_TYPE_SINGLE');
  1638. def_symbol('FPC_INCLUDE_SOFTWARE_INT64_TO_DOUBLE');
  1639. def_symbol('FPC_CURRENCY_IS_INT64');
  1640. def_symbol('FPC_COMP_IS_INT64');
  1641. {$endif}
  1642. {$ifdef iA64}
  1643. def_symbol('CPUIA64');
  1644. def_symbol('CPU64');
  1645. {$endif}
  1646. {$ifdef x86_64}
  1647. def_symbol('CPUX86_64');
  1648. def_symbol('CPU64');
  1649. { not supported for now, afaik (FK)
  1650. def_symbol('FPC_HAS_TYPE_FLOAT128'); }
  1651. def_symbol('FPC_HAS_TYPE_EXTENDED');
  1652. def_symbol('FPC_HAS_TYPE_DOUBLE');
  1653. def_symbol('FPC_HAS_TYPE_SINGLE');
  1654. {$endif}
  1655. {$ifdef sparc}
  1656. def_symbol('CPUSPARC');
  1657. def_symbol('CPUSPARC32');
  1658. def_symbol('CPU32');
  1659. def_symbol('FPC_HAS_TYPE_DOUBLE');
  1660. def_symbol('FPC_HAS_TYPE_SINGLE');
  1661. def_symbol('FPC_INCLUDE_SOFTWARE_INT64_TO_DOUBLE');
  1662. def_symbol('FPC_CURRENCY_IS_INT64');
  1663. def_symbol('FPC_COMP_IS_INT64');
  1664. {$endif}
  1665. {$ifdef vis}
  1666. def_symbol('CPUVIS');
  1667. def_symbol('CPU32');
  1668. {$endif}
  1669. {$ifdef arm}
  1670. def_symbol('CPUARM');
  1671. def_symbol('CPU32');
  1672. def_symbol('FPC_HAS_TYPE_DOUBLE');
  1673. def_symbol('FPC_HAS_TYPE_SINGLE');
  1674. def_symbol('FPC_INCLUDE_SOFTWARE_INT64_TO_DOUBLE');
  1675. def_symbol('FPC_CURRENCY_IS_INT64');
  1676. def_symbol('FPC_COMP_IS_INT64');
  1677. def_symbol('FPC_REQUIRES_PROPER_ALIGNMENT');
  1678. {$endif arm}
  1679. { get default messagefile }
  1680. {$ifdef Delphi}
  1681. msgfilename:=dmisc.getenv('PPC_ERROR_FILE');
  1682. {$else Delphi}
  1683. msgfilename:=dos.getenv('PPC_ERROR_FILE');
  1684. {$endif Delphi}
  1685. { default configfile can be specified on the commandline,
  1686. remove it first }
  1687. if (cmd<>'') and (cmd[1]='[') then
  1688. begin
  1689. ppccfg:=Copy(cmd,2,pos(']',cmd)-2);
  1690. Delete(cmd,1,pos(']',cmd));
  1691. end
  1692. else
  1693. begin
  1694. ppccfg:='fpc.cfg';
  1695. ppcaltcfg:='ppc386.cfg';
  1696. end;
  1697. { read the parameters quick, only -i -v -T }
  1698. option.firstpass:=true;
  1699. if cmd<>'' then
  1700. option.parsecmd(cmd)
  1701. else
  1702. begin
  1703. option.read_parameters;
  1704. { Write only quickinfo }
  1705. if option.quickinfo<>'' then
  1706. option.writequickinfo;
  1707. end;
  1708. option.firstpass:=false;
  1709. { read configuration file }
  1710. if (not disable_configfile) and
  1711. (ppccfg<>'') then
  1712. begin
  1713. read_configfile:=check_configfile(ppccfg,ppccfg);
  1714. { Maybe alternative configfile ? }
  1715. if (not read_configfile) and
  1716. (ppcaltcfg<>'') then
  1717. read_configfile:=check_configfile(ppcaltcfg,ppccfg);
  1718. end
  1719. else
  1720. read_configfile := false;
  1721. { Read commandline and configfile }
  1722. target_is_set:=false;
  1723. asm_is_set:=false;
  1724. param_file:='';
  1725. { read configfile }
  1726. if read_configfile then
  1727. option.interpret_file(ppccfg);
  1728. { read parameters again to override config file }
  1729. if cmd<>'' then
  1730. option.parsecmd(cmd)
  1731. else
  1732. begin
  1733. option.read_parameters;
  1734. { Write only quickinfo }
  1735. if option.quickinfo<>'' then
  1736. option.writequickinfo;
  1737. end;
  1738. { Write help pages }
  1739. if (cmd='') and (paramcount=0) then
  1740. Option.WriteHelpPages;
  1741. { Stop if errors in options }
  1742. if ErrorCount>0 then
  1743. StopOptions;
  1744. { Non-core target defines }
  1745. Option.TargetDefines(true);
  1746. { endian define }
  1747. case target_info.endian of
  1748. endian_little :
  1749. begin
  1750. def_symbol('ENDIAN_LITTLE');
  1751. def_symbol('FPC_LITTLE_ENDIAN');
  1752. end;
  1753. endian_big :
  1754. begin
  1755. def_symbol('ENDIAN_BIG');
  1756. def_symbol('FPC_BIG_ENDIAN');
  1757. end;
  1758. end;
  1759. { abi define }
  1760. case target_info.abi of
  1761. abi_powerpc_sysv :
  1762. def_symbol('FPC_ABI_SYSV');
  1763. abi_powerpc_aix :
  1764. def_symbol('FPC_ABI_AIX');
  1765. end;
  1766. {$ifdef m68k}
  1767. if initoptprocessor=MC68020 then
  1768. def_symbol('CPUM68020');
  1769. {$endif m68k}
  1770. { write logo if set }
  1771. if option.DoWriteLogo then
  1772. option.WriteLogo;
  1773. { Check file to compile }
  1774. if param_file='' then
  1775. begin
  1776. Message(option_no_source_found);
  1777. StopOptions;
  1778. end;
  1779. {$ifndef Unix}
  1780. param_file:=FixFileName(param_file);
  1781. {$endif}
  1782. fsplit(param_file,inputdir,inputfile,inputextension);
  1783. if inputextension='' then
  1784. begin
  1785. if FileExists(inputdir+inputfile+target_info.sourceext) then
  1786. inputextension:=target_info.sourceext
  1787. else
  1788. if FileExists(inputdir+inputfile+target_info.pasext) then
  1789. inputextension:=target_info.pasext;
  1790. end;
  1791. { Add paths specified with parameters to the searchpaths }
  1792. UnitSearchPath.AddList(option.ParaUnitPath,true);
  1793. ObjectSearchPath.AddList(option.ParaObjectPath,true);
  1794. IncludeSearchPath.AddList(option.ParaIncludePath,true);
  1795. LibrarySearchPath.AddList(option.ParaLibraryPath,true);
  1796. { add unit environment and exepath to the unit search path }
  1797. if inputdir<>'' then
  1798. Unitsearchpath.AddPath(inputdir,true);
  1799. if not disable_configfile then
  1800. begin
  1801. {$ifdef Delphi}
  1802. UnitSearchPath.AddPath(dmisc.getenv(target_info.unit_env),false);
  1803. {$else}
  1804. UnitSearchPath.AddPath(dos.getenv(target_info.unit_env),false);
  1805. {$endif Delphi}
  1806. end;
  1807. {$ifdef Unix}
  1808. fpcdir:=FixPath(getenv('FPCDIR'),false);
  1809. if fpcdir='' then
  1810. begin
  1811. if source_info.cpu<>target_info.cpu then
  1812. begin
  1813. if PathExists('/usr/local/lib/fpc/'+version_string+'/cross/'+cpu2str[target_info.cpu]+'-'+target_info.shortname) then
  1814. fpcdir:='/usr/local/lib/fpc/'+version_string+'/cross/'+cpu2str[target_info.cpu]+'-'+target_info.shortname+'/'
  1815. else
  1816. fpcdir:='/usr/lib/fpc/'+version_string+'/cross/'+cpu2str[target_info.cpu]+'-'+target_info.shortname+'/';
  1817. end
  1818. else
  1819. begin
  1820. if PathExists('/usr/local/lib/fpc/'+version_string) then
  1821. fpcdir:='/usr/local/lib/fpc/'+version_string+'/'
  1822. else
  1823. fpcdir:='/usr/lib/fpc/'+version_string+'/';
  1824. end;
  1825. end;
  1826. {$else}
  1827. fpcdir:=FixPath(getenv('FPCDIR'),false);
  1828. if fpcdir='' then
  1829. begin
  1830. fpcdir:=ExePath+'../';
  1831. if not(PathExists(fpcdir+'/units')) and
  1832. not(PathExists(fpcdir+'/rtl')) then
  1833. fpcdir:=fpcdir+'../';
  1834. end;
  1835. {$endif}
  1836. { first try development RTL, else use the default installation path }
  1837. if not disable_configfile then
  1838. begin
  1839. if source_info.cpu<>target_info.cpu then
  1840. begin
  1841. if PathExists(FpcDir+'rtl/'+lower(target_info.shortname)) then
  1842. UnitSearchPath.AddPath(FpcDir+'rtl/'+lower(target_info.shortname),false)
  1843. else
  1844. begin
  1845. UnitSearchPath.AddPath(FpcDir+'units/',false);
  1846. UnitSearchPath.AddPath(FpcDir+'units/rtl',false);
  1847. end;
  1848. end
  1849. else
  1850. begin
  1851. if PathExists(FpcDir+'rtl/'+lower(target_info.shortname)) then
  1852. UnitSearchPath.AddPath(FpcDir+'rtl/'+lower(target_info.shortname),false)
  1853. else
  1854. begin
  1855. UnitSearchPath.AddPath(FpcDir+'units/'+lower(target_info.shortname),false);
  1856. UnitSearchPath.AddPath(FpcDir+'units/'+lower(target_info.shortname)+'/rtl',false);
  1857. end;
  1858. end;
  1859. end;
  1860. { Add exepath if the exe is not in the current dir, because that is always searched already.
  1861. Do not add it when linking on the target because then we can maybe already find
  1862. .o files that are not for the target }
  1863. if (ExePath<>GetCurrentDir) and
  1864. not(cs_link_on_target in initglobalswitches) then
  1865. UnitSearchPath.AddPath(ExePath,false);
  1866. { Add unit dir to the object and library path }
  1867. objectsearchpath.AddList(unitsearchpath,false);
  1868. librarysearchpath.AddList(unitsearchpath,false);
  1869. { switch assembler if it's binary and we got -a on the cmdline }
  1870. if (cs_asm_leave in initglobalswitches) and
  1871. (target_asm.outputbinary) then
  1872. begin
  1873. Message(option_switch_bin_to_src_assembler);
  1874. set_target_asm(target_info.assemextern);
  1875. end;
  1876. if (target_asm.supported_target <> system_any) and
  1877. (target_asm.supported_target <> target_info.system) then
  1878. begin
  1879. Message2(option_incompatible_asm,target_asm.idtxt,target_info.name);
  1880. set_target_asm(target_info.assemextern);
  1881. Message1(option_asm_forced,target_asm.idtxt);
  1882. end;
  1883. { turn off stripping if compiling with debuginfo or profile }
  1884. if (cs_debuginfo in initmoduleswitches) or
  1885. (cs_profile in initmoduleswitches) then
  1886. exclude(initglobalswitches,cs_link_strip);
  1887. if not LinkTypeSetExplicitly then
  1888. set_default_link_type;
  1889. { Default alignment settings,
  1890. 1. load the defaults for the target
  1891. 2. override with generic optimizer setting (little size)
  1892. 3. override with the user specified -Oa }
  1893. UpdateAlignment(initalignment,target_info.alignment);
  1894. if (cs_littlesize in aktglobalswitches) then
  1895. begin
  1896. initalignment.procalign:=1;
  1897. initalignment.jumpalign:=1;
  1898. initalignment.loopalign:=1;
  1899. end;
  1900. UpdateAlignment(initalignment,option.paraalignment);
  1901. option.free;
  1902. Option:=nil;
  1903. end;
  1904. initialization
  1905. coption:=toption;
  1906. finalization
  1907. if assigned(option) then
  1908. option.free;
  1909. end.
  1910. {
  1911. $Log$
  1912. Revision 1.133 2004-04-04 18:46:09 olle
  1913. + added $APPTYPE TOOL for MPW tools on MacOS
  1914. Revision 1.132 2004/03/29 19:19:35 florian
  1915. + arm floating point register saving implemented
  1916. * hopefully stabs generation for MacOSX fixed
  1917. + some defines for arm added
  1918. Revision 1.131 2004/03/27 23:23:03 florian
  1919. + added FPC_COMP_IS_INT64 define
  1920. Revision 1.130 2004/03/23 22:34:49 peter
  1921. * constants ordinals now always have a type assigned
  1922. * integer constants have the smallest type, unsigned prefered over
  1923. signed
  1924. Revision 1.129 2004/03/21 22:40:15 florian
  1925. + added interface support for the arm
  1926. * added FPC_REQUIRES_PROPER_ALIGNMENT define for targets which require proper alignment
  1927. Revision 1.128 2004/03/20 22:57:07 florian
  1928. + cross compilation dir search added
  1929. Revision 1.127 2004/03/10 22:52:57 peter
  1930. * more stabs fixes
  1931. * special mode -gv for valgrind compatible stabs
  1932. Revision 1.126 2004/03/02 17:32:12 florian
  1933. * make cycle fixed
  1934. + pic support for darwin
  1935. + support of importing vars from shared libs on darwin implemented
  1936. Revision 1.125 2004/02/22 12:04:04 florian
  1937. + nx86set added
  1938. * some more x86-64 fixes
  1939. Revision 1.124 2004/02/15 16:34:18 marco
  1940. * pthread on -CURRENT related fixes.
  1941. Revision 1.123 2004/02/03 00:42:08 florian
  1942. + FPC_PREFETCH defined
  1943. Revision 1.122 2004/01/24 18:12:40 florian
  1944. * fixed several arm floating point issues
  1945. Revision 1.121 2004/01/21 22:13:20 peter
  1946. * decrrefcount resets temps to nil
  1947. Revision 1.120 2004/01/10 00:16:21 jonas
  1948. * fixed mtfsb0 instruction for assembler reader/writer
  1949. * fixed initialisation of fpscr register to avoid spurious SIGPFE's
  1950. (uses mtfsb0 instruction, so added extra define in options.pas to avoid
  1951. requiring to start with a cross compiler)
  1952. Revision 1.119 2004/01/02 17:19:04 jonas
  1953. * if currency = int64, FPC_CURRENCY_IS_INT64 is defined
  1954. + round and trunc for currency and comp if FPC_CURRENCY_IS_INT64 is
  1955. defined
  1956. * if currency = orddef, prefer currency -> int64/qword conversion over
  1957. currency -> float conversions
  1958. * optimized currency/currency if currency = orddef
  1959. * TODO: write FPC_DIV_CURRENCY and FPC_MUL_CURRENCY routines to prevent
  1960. precision loss if currency=int64 and bestreal = double
  1961. Revision 1.118 2003/12/17 22:50:42 hajny
  1962. * fixed incorrect error message
  1963. Revision 1.117 2003/12/11 18:15:06 florian
  1964. * HASGLOBALPROPERTY define introduce
  1965. Revision 1.116 2003/12/10 01:54:44 florian
  1966. * variants and interfaces on powerpc released
  1967. Revision 1.115 2003/11/11 21:10:34 peter
  1968. * define REGCALL when pocall_default=pocall_register
  1969. Revision 1.114 2003/11/07 15:58:32 florian
  1970. * Florian's culmutative nr. 1; contains:
  1971. - invalid calling conventions for a certain cpu are rejected
  1972. - arm softfloat calling conventions
  1973. - -Sp for cpu dependend code generation
  1974. - several arm fixes
  1975. - remaining code for value open array paras on heap
  1976. Revision 1.113 2003/10/22 15:40:44 marco
  1977. * -Xc -Xr support
  1978. Revision 1.112 2003/10/18 09:14:18 hajny
  1979. * upper limit for heapsize removed
  1980. Revision 1.110 2003/10/14 00:30:48 florian
  1981. + some code for PIC support added
  1982. Revision 1.109 2003/10/11 19:32:04 marco
  1983. * -Xd
  1984. Revision 1.108 2003/10/08 19:17:43 peter
  1985. * -P to -ap
  1986. * -V to -vv
  1987. Revision 1.107 2003/10/03 14:16:48 marco
  1988. * -XP<prefix> support
  1989. Revision 1.106 2003/09/17 21:37:07 olle
  1990. + added command line option for language mode -M<x>
  1991. Revision 1.105 2003/09/14 21:33:11 peter
  1992. * don't check exepath when linking on target
  1993. Revision 1.104 2003/09/06 10:41:54 olle
  1994. + compiler now define abi macros for powerpc FPC_ABI_AIX or FPC_ABI_SYSV
  1995. Revision 1.103 2003/09/05 17:41:12 florian
  1996. * merged Wiktor's Watcom patches in 1.1
  1997. Revision 1.102 2003/09/03 21:06:05 peter
  1998. * powerpc needs software int64 to double
  1999. Revision 1.101 2003/09/03 15:55:01 peter
  2000. * NEWRA branch merged
  2001. Revision 1.100 2003/09/03 11:18:37 florian
  2002. * fixed arm concatcopy
  2003. + arm support in the common compiler sources added
  2004. * moved some generic cg code around
  2005. + tfputype added
  2006. * ...
  2007. Revision 1.99.2.4 2003/09/02 17:48:42 peter
  2008. * sparc need software int64 to double
  2009. Revision 1.99.2.3 2003/09/01 21:02:55 peter
  2010. * sparc updates for new tregister
  2011. Revision 1.99.2.2 2003/08/31 16:18:05 peter
  2012. * more fixes
  2013. Revision 1.99.2.1 2003/08/31 13:50:15 daniel
  2014. * Remove sorting and use pregenerated indexes
  2015. * Some work on making things compile
  2016. Revision 1.99 2003/05/13 19:14:41 peter
  2017. * failn removed
  2018. * inherited result code check moven to pexpr
  2019. Revision 1.98 2003/05/11 19:17:16 florian
  2020. * FPC_LITTLE_ENDIAN and FPC_BIG_ENDIAN is now defined as well
  2021. Revision 1.97 2003/05/01 07:59:42 florian
  2022. * introduced defaultordconsttype to decribe the default size of ordinal constants
  2023. on 64 bit CPUs it's equal to cs64bitdef while on 32 bit CPUs it's equal to s32bitdef
  2024. + added defines CPU32 and CPU64 for 32 bit and 64 bit CPUs
  2025. * int64s/qwords are allowed as for loop counter on 64 bit CPUs
  2026. Revision 1.96 2003/04/30 16:35:00 florian
  2027. * fixed defines for x86-64
  2028. Revision 1.95 2003/04/24 11:21:45 florian
  2029. + HAS_TYPE_* defines for floats on i386 and powerpc added
  2030. Revision 1.94 2003/03/28 19:16:56 peter
  2031. * generic constructor working for i386
  2032. * remove fixed self register
  2033. * esi added as address register for i386
  2034. Revision 1.93 2003/03/23 23:20:38 hajny
  2035. + emx target added
  2036. Revision 1.92 2003/03/08 08:59:07 daniel
  2037. + $define newra will enable new register allocator
  2038. + getregisterint will return imaginary registers with $newra
  2039. + -sr switch added, will skip register allocation so you can see
  2040. the direct output of the code generator before register allocation
  2041. Revision 1.91 2002/12/06 16:56:58 peter
  2042. * only compile cs_fp_emulation support when cpufpuemu is defined
  2043. * define cpufpuemu for m68k only
  2044. Revision 1.90 2002/11/30 23:14:55 carl
  2045. - removed cs_fp_emulation checking for m68k, its now controled
  2046. by a global switch
  2047. + added powerpc/sparc/vis message options support
  2048. Revision 1.89 2002/11/30 21:29:56 carl
  2049. + -Ce for softfpu
  2050. Revision 1.88 2002/11/15 01:58:52 peter
  2051. * merged changes from 1.0.7 up to 04-11
  2052. - -V option for generating bug report tracing
  2053. - more tracing for option parsing
  2054. - errors for cdecl and high()
  2055. - win32 import stabs
  2056. - win32 records<=8 are returned in eax:edx (turned off by default)
  2057. - heaptrc update
  2058. - more info for temp management in .s file with EXTDEBUG
  2059. Revision 1.87 2002/10/23 17:07:40 peter
  2060. * fix -n that was broken in the previous commit
  2061. Revision 1.86 2002/10/23 16:57:16 peter
  2062. * first search for fpc.cfg instead of deprecated ppc386.cfg
  2063. * parse commandline options first before searching configfile so -vt
  2064. can be used to display the searched files
  2065. Revision 1.85 2002/10/13 21:33:01 peter
  2066. * define HASTHREADVAR
  2067. Revision 1.84 2002/10/02 18:20:52 peter
  2068. * Copy() is now internal syssym that calls compilerprocs
  2069. Revision 1.83 2002/09/22 14:02:35 carl
  2070. * stack checking cannot be called before system unit is initialized
  2071. * MC68020 define
  2072. Revision 1.82 2002/08/12 15:08:40 carl
  2073. + stab register indexes for powerpc (moved from gdb to cpubase)
  2074. + tprocessor enumeration moved to cpuinfo
  2075. + linker in target_info is now a class
  2076. * many many updates for m68k (will soon start to compile)
  2077. - removed some ifdef or correct them for correct cpu
  2078. Revision 1.81 2002/08/10 14:46:29 carl
  2079. + moved target_cpu_string to cpuinfo
  2080. * renamed asmmode enum.
  2081. * assembler reader has now less ifdef's
  2082. * move from nppcmem.pas -> ncgmem.pas vec. node.
  2083. Revision 1.80 2002/08/09 19:15:41 carl
  2084. - removed newcg define
  2085. Revision 1.79 2002/07/26 22:22:10 florian
  2086. * several PowerPC related fixes to get forward with system unit compilation
  2087. Revision 1.78 2002/07/26 21:15:39 florian
  2088. * rewrote the system handling
  2089. Revision 1.77 2002/07/20 17:16:03 florian
  2090. + source code page support
  2091. Revision 1.76 2002/07/04 20:43:01 florian
  2092. * first x86-64 patches
  2093. Revision 1.75 2002/07/01 18:46:24 peter
  2094. * internal linker
  2095. * reorganized aasm layer
  2096. Revision 1.74 2002/07/01 16:23:53 peter
  2097. * cg64 patch
  2098. * basics for currency
  2099. * asnode updates for class and interface (not finished)
  2100. Revision 1.73 2002/05/18 13:34:11 peter
  2101. * readded missing revisions
  2102. Revision 1.72 2002/05/16 19:46:41 carl
  2103. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  2104. + try to fix temp allocation (still in ifdef)
  2105. + generic constructor calls
  2106. + start of tassembler / tmodulebase class cleanup
  2107. Revision 1.70 2002/05/12 16:53:08 peter
  2108. * moved entry and exitcode to ncgutil and cgobj
  2109. * foreach gets extra argument for passing local data to the
  2110. iterator function
  2111. * -CR checks also class typecasts at runtime by changing them
  2112. into as
  2113. * fixed compiler to cycle with the -CR option
  2114. * fixed stabs with elf writer, finally the global variables can
  2115. be watched
  2116. * removed a lot of routines from cga unit and replaced them by
  2117. calls to cgobj
  2118. * u32bit-s32bit updates for and,or,xor nodes. When one element is
  2119. u32bit then the other is typecasted also to u32bit without giving
  2120. a rangecheck warning/error.
  2121. * fixed pascal calling method with reversing also the high tree in
  2122. the parast, detected by tcalcst3 test
  2123. Revision 1.69 2002/04/21 19:02:04 peter
  2124. * removed newn and disposen nodes, the code is now directly
  2125. inlined from pexpr
  2126. * -an option that will write the secondpass nodes to the .s file, this
  2127. requires EXTDEBUG define to actually write the info
  2128. * fixed various internal errors and crashes due recent code changes
  2129. Revision 1.68 2002/04/20 21:32:24 carl
  2130. + generic FPC_CHECKPOINTER
  2131. + first parameter offset in stack now portable
  2132. * rename some constants
  2133. + move some cpu stuff to other units
  2134. - remove unused constents
  2135. * fix stacksize for some targets
  2136. * fix generic size problems which depend now on EXTEND_SIZE constant
  2137. Revision 1.67 2002/04/07 10:22:35 carl
  2138. + CPU defines now depends on current target
  2139. Revision 1.66 2002/04/04 19:05:58 peter
  2140. * removed unused units
  2141. * use tlocation.size in cg.a_*loc*() routines
  2142. Revision 1.65 2002/04/04 18:39:45 carl
  2143. + added wdosx support (patch from Pavel)
  2144. }