options.pas 71 KB

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