options.pas 56 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788
  1. {
  2. $Id$
  3. Copyright (c) 1993-98 by the FPC development team
  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. interface
  20. uses
  21. verbose;
  22. type
  23. POption=^TOption;
  24. TOption=object
  25. FirstPass,
  26. NoPressEnter,
  27. DoWriteLogo : boolean;
  28. FileLevel : longint;
  29. ParaIncludePath,
  30. ParaUnitPath,
  31. ParaObjectPath,
  32. ParaLibraryPath : string;
  33. Constructor Init;
  34. Destructor Done;
  35. procedure WriteLogo;
  36. procedure WriteInfo;
  37. procedure WriteHelpPages;
  38. procedure QuickInfo(const s:string);
  39. procedure IllegalPara(const opt:string);
  40. function Unsetbool(const opts:string; pos: Longint):boolean;
  41. procedure interpret_proc_specific_options(const opt:string);virtual;
  42. procedure interpret_option(const opt :string);
  43. procedure Interpret_file(const filename : string);
  44. procedure Read_Parameters;
  45. procedure parsecmd(cmd:string);
  46. end;
  47. procedure read_arguments(cmd:string);
  48. implementation
  49. uses
  50. {$ifdef Delphi}
  51. dmisc,
  52. {$else Delphi}
  53. dos,
  54. {$endif Delphi}
  55. globtype,version,systems,
  56. cobjects,globals,
  57. scanner,link,messages
  58. {$ifdef BrowserLog}
  59. ,browlog
  60. {$endif BrowserLog}
  61. {$ifdef i386}
  62. ,opts386
  63. {$endif}
  64. {$ifdef m68k}
  65. ,opts68k
  66. {$endif}
  67. ;
  68. const
  69. page_size = 24;
  70. var
  71. read_configfile, { read config file, set when a cfgfile is found }
  72. target_is_set : boolean; { do not allow contradictory target settings }
  73. asm_is_set : boolean; { -T also change initoutputformat if not set idrectly }
  74. ppccfg,
  75. msgfilename,
  76. param_file : string; { file to compile specified on the commandline }
  77. {****************************************************************************
  78. Defines
  79. ****************************************************************************}
  80. procedure def_symbol(const s : string);
  81. begin
  82. if s='' then
  83. exit;
  84. initdefines.concat(new(pstring_item,init(upper(s))));
  85. end;
  86. procedure undef_symbol(const s : string);
  87. var
  88. item,next : pstring_item;
  89. begin
  90. if s='' then
  91. exit;
  92. item:=pstring_item(initdefines.first);
  93. while assigned(item) do
  94. begin
  95. if (item^.str^=s) then
  96. begin
  97. next:=pstring_item(item^.next);
  98. initdefines.remove(item);
  99. dispose(item,done);
  100. item:=next;
  101. end
  102. else
  103. if item<>pstring_item(item^.next) then
  104. item:=pstring_item(item^.next)
  105. else
  106. break;
  107. end;
  108. end;
  109. function check_symbol(const s:string):boolean;
  110. var
  111. hp : pstring_item;
  112. begin
  113. hp:=pstring_item(initdefines.first);
  114. while assigned(hp) do
  115. begin
  116. if (hp^.str^=s) then
  117. begin
  118. check_symbol:=true;
  119. exit;
  120. end;
  121. hp:=pstring_item(hp^.next);
  122. end;
  123. check_symbol:=false;
  124. end;
  125. procedure MaybeLoadMessageFile;
  126. begin
  127. { Load new message file }
  128. if (msgfilename<>'') then
  129. begin
  130. if fileexists(msgfilename) then
  131. LoadMsgFile(msgfilename);
  132. msgfilename:='';
  133. end;
  134. end;
  135. {****************************************************************************
  136. Toption
  137. ****************************************************************************}
  138. procedure Toption.WriteLogo;
  139. var
  140. i : tmsgconst;
  141. begin
  142. MaybeLoadMessageFile;
  143. for i:=option_logo_start to option_logo_end do
  144. Message1(i,target_cpu_string);
  145. end;
  146. procedure Toption.WriteInfo;
  147. var
  148. i : tmsgconst;
  149. begin
  150. MaybeLoadMessageFile;
  151. for i:=option_info_start to option_info_end do
  152. Message(i);
  153. Stop;
  154. end;
  155. procedure Toption.WriteHelpPages;
  156. function PadEnd(s:string;i:longint):string;
  157. begin
  158. while (length(s)<i) do
  159. s:=s+' ';
  160. PadEnd:=s;
  161. end;
  162. var
  163. idx,
  164. lastident,
  165. j,outline,
  166. ident,
  167. lines : longint;
  168. show : boolean;
  169. opt : string[32];
  170. input,
  171. s : string;
  172. begin
  173. MaybeLoadMessageFile;
  174. Message1(option_usage,paramstr(0));
  175. lastident:=0;
  176. if DoWriteLogo then
  177. lines:=3
  178. else
  179. lines:=1;
  180. for idx:=ord(ol_begin) to ord(ol_end) do
  181. begin
  182. { get a line and reset }
  183. s:=msg^.Get(idx);
  184. ident:=0;
  185. show:=false;
  186. { parse options }
  187. case s[1] of
  188. {$ifdef i386}
  189. '3',
  190. {$endif}
  191. {$ifdef m68k}
  192. '6',
  193. {$endif}
  194. '*' : show:=true;
  195. end;
  196. if show then
  197. begin
  198. case s[2] of
  199. {$ifdef TP}
  200. 't',
  201. {$endif}
  202. {$ifdef GDB}
  203. 'g',
  204. {$endif}
  205. {$ifdef linux}
  206. 'L',
  207. {$endif}
  208. {$ifdef os2}
  209. 'O',
  210. {$endif}
  211. '*' : show:=true;
  212. else
  213. show:=false;
  214. end;
  215. end;
  216. { now we may show the message or not }
  217. if show then
  218. begin
  219. case s[3] of
  220. '0' : begin
  221. ident:=0;
  222. outline:=0;
  223. end;
  224. '1' : begin
  225. ident:=2;
  226. outline:=7;
  227. end;
  228. '2' : begin
  229. ident:=11;
  230. outline:=11;
  231. end;
  232. '3' : begin
  233. ident:=21;
  234. outline:=6;
  235. end;
  236. end;
  237. j:=pos('_',s);
  238. opt:=Copy(s,4,j-4);
  239. if opt='*' then
  240. opt:=''
  241. else
  242. opt:=PadEnd('-'+opt,outline);
  243. if (ident=0) and (lastident<>0) then
  244. begin
  245. Comment(V_Normal,'');
  246. inc(Lines);
  247. end;
  248. { page full ? }
  249. if (lines>=page_size) then
  250. begin
  251. if not NoPressEnter then
  252. begin
  253. write('*** press enter ***');
  254. readln(input);
  255. if upper(input)='Q' then
  256. stop;
  257. end;
  258. lines:=0;
  259. end;
  260. Comment(V_Normal,PadEnd('',ident)+opt+Copy(s,j+1,255));
  261. LastIdent:=Ident;
  262. inc(Lines);
  263. end;
  264. end;
  265. stop;
  266. end;
  267. procedure Toption.QuickInfo(const s:string);
  268. begin
  269. Writeln(s);
  270. Stop;
  271. end;
  272. procedure Toption.IllegalPara(const opt:string);
  273. begin
  274. Message1(option_illegal_para,opt);
  275. Message(option_help_pages_para);
  276. stop;
  277. end;
  278. function Toption.Unsetbool(const opts:string; pos: Longint):boolean;
  279. { checks if the character after pos in Opts is a + or a - and returns resp.
  280. false or true. If it is another character (or none), it also returns false }
  281. begin
  282. UnsetBool := (Length(Opts) > Pos) And (Opts[Succ(Pos)] = '-');
  283. end;
  284. procedure TOption.interpret_proc_specific_options(const opt:string);
  285. begin
  286. end;
  287. procedure TOption.interpret_option(const opt:string);
  288. var
  289. code : integer;
  290. c : char;
  291. more : string;
  292. j,l : longint;
  293. d : DirStr;
  294. e : ExtStr;
  295. begin
  296. if opt='' then
  297. exit;
  298. case opt[1] of
  299. '-' : begin
  300. more:=Copy(opt,3,255);
  301. case opt[2] of
  302. '!' : initlocalswitches:=initlocalswitches+[cs_ansistrings];
  303. '?' : WriteHelpPages;
  304. 'a' : begin
  305. initglobalswitches:=initglobalswitches+[cs_asm_leave];
  306. for j:=1 to length(more) do
  307. case more[j] of
  308. 'l' : initglobalswitches:=initglobalswitches+[cs_asm_source];
  309. 'r' : initglobalswitches:=initglobalswitches+[cs_asm_regalloc];
  310. 't' : initglobalswitches:=initglobalswitches+[cs_asm_tempalloc];
  311. '-' : initglobalswitches:=initglobalswitches-[cs_asm_leave,cs_asm_source,cs_asm_regalloc];
  312. else
  313. IllegalPara(opt);
  314. end;
  315. end;
  316. 'A' : begin
  317. if set_string_asm(More) then
  318. begin
  319. initoutputformat:=target_asm.id;
  320. asm_is_set:=true;
  321. end
  322. else
  323. IllegalPara(opt);
  324. end;
  325. 'b' : begin
  326. {$ifdef BrowserLog}
  327. initglobalswitches:=initglobalswitches+[cs_browser_log];
  328. {$endif}
  329. if More<>'' then
  330. if More='l' then
  331. initmoduleswitches:=initmoduleswitches+[cs_local_browser]
  332. else if More='-' then
  333. begin
  334. initmoduleswitches:=initmoduleswitches-[cs_browser,cs_local_browser];
  335. {$ifdef BrowserLog}
  336. initglobalswitches:=initglobalswitches-[cs_browser_log];
  337. {$endif}
  338. end
  339. else if More<>'+' then
  340. {$ifdef BrowserLog}
  341. browserlog.elements_to_list^.insert(more);
  342. {$else}
  343. IllegalPara(opt);
  344. {$endif}
  345. end;
  346. 'B' : if more='' then
  347. do_build:=true
  348. else
  349. if more = '-' then
  350. do_build := False
  351. else
  352. IllegalPara(opt);
  353. 'C' : begin
  354. j := 1;
  355. while j <= length(more) Do
  356. Begin
  357. case more[j] of
  358. 'a' : Simplify_ppu:=true;
  359. 'h' :
  360. begin
  361. val(copy(more,j+1,length(more)-j),heapsize,code);
  362. if (code<>0) or (heapsize>=67107840) or (heapsize<1024) then
  363. IllegalPara(opt);
  364. break;
  365. end;
  366. 'i' : If UnsetBool(More, j) then
  367. Begin
  368. initlocalswitches:=initlocalswitches-[cs_check_io];
  369. inc(j)
  370. End
  371. else initlocalswitches:=initlocalswitches+[cs_check_io];
  372. 'n' : If UnsetBool(More, j) then
  373. Begin
  374. initglobalswitches:=initglobalswitches-[cs_link_extern];
  375. inc(j)
  376. End
  377. Else initglobalswitches:=initglobalswitches+[cs_link_extern];
  378. 'o' :
  379. If UnsetBool(More, j) then
  380. Begin
  381. initlocalswitches:=initlocalswitches-[cs_check_overflow];
  382. inc(j);
  383. End
  384. Else
  385. initlocalswitches:=initlocalswitches+[cs_check_overflow];
  386. 'r' :
  387. If UnsetBool(More, j) then
  388. Begin
  389. initlocalswitches:=initlocalswitches-[cs_check_range];
  390. inc(j);
  391. End
  392. Else
  393. initlocalswitches:=initlocalswitches+[cs_check_range];
  394. 's' :
  395. begin
  396. val(copy(more,j+1,length(more)-j),stacksize,code);
  397. if (code<>0) or (stacksize>=67107840) or (stacksize<1024) then
  398. IllegalPara(opt);
  399. break;
  400. end;
  401. 't' :
  402. If UnsetBool(More, j) then
  403. Begin
  404. initlocalswitches:=initlocalswitches-[cs_check_stack];
  405. inc(j)
  406. End
  407. Else
  408. initlocalswitches:=initlocalswitches+[cs_check_stack];
  409. 'D' :
  410. If UnsetBool(More, j) then
  411. Begin
  412. initmoduleswitches:=initmoduleswitches-[cs_create_dynamic];
  413. inc(j)
  414. End
  415. Else
  416. initmoduleswitches:=initmoduleswitches+[cs_create_dynamic];
  417. 'X' :
  418. If UnsetBool(More, j) then
  419. Begin
  420. initmoduleswitches:=initmoduleswitches-[cs_create_smart];
  421. inc(j)
  422. End
  423. Else
  424. initmoduleswitches:=initmoduleswitches+[cs_create_smart];
  425. else
  426. IllegalPara(opt);
  427. end;
  428. inc(j);
  429. end;
  430. end;
  431. 'd' : def_symbol(more);
  432. 'D' : begin
  433. initglobalswitches:=initglobalswitches+[cs_link_deffile];
  434. for j:=1 to length(more) do
  435. case more[j] of
  436. 'd' : begin
  437. description:=Copy(more,j+1,255);
  438. break;
  439. end;
  440. 'w' : usewindowapi:=true;
  441. else
  442. IllegalPara(opt);
  443. end;
  444. end;
  445. 'e' : exepath:=FixPath(More,true);
  446. { Just used by RHIDE }
  447. 'E' : if (length(more)=0) or (UnsetBool(More, 0)) then
  448. initglobalswitches:=initglobalswitches+[cs_link_extern]
  449. else
  450. initglobalswitches:=initglobalswitches-[cs_link_extern];
  451. 'F' : begin
  452. c:=more[1];
  453. Delete(more,1,1);
  454. case c of
  455. 'D' : utilsdirectory:=FixPath(More,true);
  456. 'e' : SetRedirectFile(More);
  457. 'E' : OutputExeDir:=FixPath(More,true);
  458. 'i' : if firstpass then
  459. AddPathToList(includesearchpath,More,false)
  460. else
  461. AddPathToList(ParaIncludePath,More,false);
  462. 'g' : Message2(option_obsolete_switch_use_new,'-Fg','-Fl');
  463. 'l' : if firstpass then
  464. AddPathToList(LibrarySearchPath,More,false)
  465. else
  466. AddPathToList(ParaLibraryPath,More,false);
  467. 'L' : if More<>'' then
  468. ParaDynamicLinker:=More
  469. else
  470. IllegalPara(opt);
  471. 'o' : if firstpass then
  472. AddPathToList(objectsearchpath,More,false)
  473. else
  474. AddPathToList(ParaObjectPath,More,false);
  475. 'r' : Msgfilename:=More;
  476. 'u' : if firstpass then
  477. AddPathToList(unitsearchpath,More,false)
  478. else
  479. AddPathToList(ParaUnitPath,More,false);
  480. 'U' : OutputUnitDir:=FixPath(More,true);
  481. else
  482. IllegalPara(opt);
  483. end;
  484. end;
  485. 'g' : begin
  486. if UnsetBool(More, 0) then
  487. initmoduleswitches:=initmoduleswitches-[cs_debuginfo]
  488. else
  489. begin
  490. {$ifdef GDB}
  491. initmoduleswitches:=initmoduleswitches+[cs_debuginfo];
  492. for j:=1 to length(more) do
  493. case more[j] of
  494. 'd' : initglobalswitches:=initglobalswitches+[cs_gdb_dbx];
  495. 'g' : initglobalswitches:=initglobalswitches+[cs_gdb_gsym];
  496. 'h' : initglobalswitches:=initglobalswitches+[cs_gdb_heaptrc];
  497. 'c' : initglobalswitches:=initglobalswitches+[cs_checkpointer];
  498. {$ifdef EXTDEBUG}
  499. 'p' : only_one_pass:=true;
  500. {$endif EXTDEBUG}
  501. else
  502. IllegalPara(opt);
  503. end;
  504. {$else GDB}
  505. Message(option_no_debug_support);
  506. Message(option_no_debug_support_recompile_fpc);
  507. {$endif GDB}
  508. end;
  509. end;
  510. 'h' : begin
  511. NoPressEnter:=true;
  512. WriteHelpPages;
  513. end;
  514. 'i' : if more='' then
  515. WriteInfo
  516. else
  517. begin
  518. { Specific info, which can be used in Makefiles }
  519. case More[1] of
  520. 'S' : begin
  521. case More[2] of
  522. 'O' : QuickInfo(source_os.shortname);
  523. {$ifdef Delphi !!!!!!!!!}
  524. 'P' : QuickInfo('unknown');
  525. {$else}
  526. 'P' : QuickInfo(source_cpu_string);
  527. {$endif}
  528. end;
  529. end;
  530. 'T' : begin
  531. case More[2] of
  532. 'O' : QuickInfo(target_os.shortname);
  533. 'P' : QuickInfo(target_cpu_string);
  534. end;
  535. end;
  536. 'V' : QuickInfo(version_string);
  537. 'D' : QuickInfo(date_string);
  538. else
  539. IllegalPara(Opt);
  540. end;
  541. end;
  542. 'I' : if firstpass then
  543. AddPathToList(includesearchpath,More,false)
  544. else
  545. AddPathToList(ParaIncludePath,More,false);
  546. 'k' : if more<>'' then
  547. ParaLinkOptions:=ParaLinkOptions+' '+More
  548. else
  549. IllegalPara(opt);
  550. 'l' : if more='' then
  551. DoWriteLogo:=true
  552. else
  553. IllegalPara(opt);
  554. 'n' : if More='' then
  555. read_configfile:=false
  556. else
  557. IllegalPara(opt);
  558. 'o' : if More<>'' then
  559. Fsplit(More,d,OutputFile,e)
  560. else
  561. IllegalPara(opt);
  562. 'p' : begin
  563. if UnsetBool(More, 0) then
  564. begin
  565. initmoduleswitches:=initmoduleswitches-[cs_profile];
  566. undef_symbol('FPC_PROFILE');
  567. end
  568. else
  569. case more[1] of
  570. 'g' : if (length(opt)=3) and UnsetBool(more, 1) then
  571. begin
  572. initmoduleswitches:=initmoduleswitches-[cs_profile];
  573. undef_symbol('FPC_PROFILE');
  574. end
  575. else
  576. begin
  577. initmoduleswitches:=initmoduleswitches+[cs_profile];
  578. def_symbol('FPC_PROFILE');
  579. end;
  580. else
  581. IllegalPara(opt);
  582. end;
  583. end;
  584. {$ifdef linux}
  585. 'P' : initglobalswitches:=initglobalswitches+[cs_asm_pipe];
  586. {$endif}
  587. 's' : initglobalswitches:=initglobalswitches+[cs_asm_extern,cs_link_extern];
  588. 'S' : begin
  589. for j:=1 to length(more) do
  590. case more[j] of
  591. '2' : initmodeswitches:=objfpcmodeswitches;
  592. 'c' : initmoduleswitches:=initmoduleswitches+[cs_support_c_operators];
  593. 'd' : initmodeswitches:=delphimodeswitches;
  594. 'e' : begin
  595. val(copy(more,j+1,length(more)-j),l,code);
  596. if (code<>0) then
  597. SetMaxErrorCount(1)
  598. else
  599. begin
  600. SetMaxErrorCount(l);
  601. break;
  602. end;
  603. end;
  604. 'g' : initmoduleswitches:=initmoduleswitches+[cs_support_goto];
  605. 'h' : initlocalswitches:=initlocalswitches+[cs_ansistrings];
  606. 'i' : initmoduleswitches:=initmoduleswitches+[cs_support_inline];
  607. 'm' : initmoduleswitches:=initmoduleswitches+[cs_support_macro];
  608. 'o': initmodeswitches:=tpmodeswitches;
  609. 'p' : initmodeswitches:=gpcmodeswitches;
  610. 's' : initglobalswitches:=initglobalswitches+[cs_constructor_name];
  611. 't' : initmoduleswitches:=initmoduleswitches+[cs_static_keyword];
  612. 'v' : Message1(option_obsolete_switch,'-Sv');
  613. else
  614. IllegalPara(opt);
  615. end;
  616. end;
  617. 'T' : begin
  618. more:=Upper(More);
  619. if not target_is_set then
  620. begin
  621. { remove old target define }
  622. undef_symbol(target_info.short_name);
  623. { load new target }
  624. if not(set_string_target(More)) then
  625. IllegalPara(opt);
  626. { set new define }
  627. def_symbol(target_info.short_name);
  628. if not asm_is_set then
  629. initoutputformat:=target_asm.id;
  630. target_is_set:=true;
  631. end
  632. else
  633. if More<>target_info.short_name then
  634. Message1(option_target_is_already_set,target_info.short_name);
  635. end;
  636. 'u' : undef_symbol(upper(More));
  637. 'U' : begin
  638. for j:=1 to length(more) do
  639. case more[j] of
  640. 'n' : initglobalswitches:=initglobalswitches-[cs_check_unit_name];
  641. 'p' : begin
  642. Message2(option_obsolete_switch_use_new,'-Up','-Fu');
  643. break;
  644. end;
  645. 's' : initmoduleswitches:=initmoduleswitches+[cs_compilesystem];
  646. else
  647. IllegalPara(opt);
  648. end;
  649. end;
  650. 'v' : if not setverbosity(More) then
  651. IllegalPara(opt);
  652. 'W' : begin
  653. for j:=1 to length(More) do
  654. case More[j] of
  655. 'B': {bind_win32_dll:=true}
  656. begin
  657. { -WB200000 means set prefered base address
  658. to $200000, but does not change relocsection boolean
  659. this way we can create both relocatble and
  660. non relocatable DLL at a specific base address PM }
  661. if (length(More)>j) then
  662. begin
  663. if DLLImageBase=nil then
  664. DLLImageBase:=StringDup(Copy(More,j+1,255));
  665. end
  666. else
  667. RelocSection:=true;
  668. break;
  669. end;
  670. 'C': apptype:=at_cui;
  671. 'G': apptype:=at_gui;
  672. 'N': begin
  673. RelocSection:=false;
  674. end;
  675. 'R': RelocSection:=true;
  676. else
  677. IllegalPara(opt);
  678. end;
  679. end;
  680. 'X' : begin
  681. for j:=1 to length(More) do
  682. case More[j] of
  683. 'c' : initglobalswitches:=initglobalswitches+[cs_link_toc];
  684. 's' : initglobalswitches:=initglobalswitches+[cs_link_strip];
  685. 'D' : begin
  686. def_symbol('FPC_LINK_DYNAMIC');
  687. undef_symbol('FPC_LINK_SMART');
  688. undef_symbol('FPC_LINK_STATIC');
  689. initglobalswitches:=initglobalswitches+[cs_link_shared];
  690. initglobalswitches:=initglobalswitches-[cs_link_static,cs_link_smart];
  691. end;
  692. 'S' : begin
  693. def_symbol('FPC_LINK_STATIC');
  694. undef_symbol('FPC_LINK_SMART');
  695. undef_symbol('FPC_LINK_DYNAMIC');
  696. initglobalswitches:=initglobalswitches+[cs_link_static];
  697. initglobalswitches:=initglobalswitches-[cs_link_shared,cs_link_smart];
  698. end;
  699. 'X' : begin
  700. def_symbol('FPC_LINK_SMART');
  701. undef_symbol('FPC_LINK_STATIC');
  702. undef_symbol('FPC_LINK_DYNAMIC');
  703. initglobalswitches:=initglobalswitches+[cs_link_smart];
  704. initglobalswitches:=initglobalswitches-[cs_link_shared,cs_link_static];
  705. end;
  706. else
  707. IllegalPara(opt);
  708. end;
  709. end;
  710. { give processor specific options a chance }
  711. else
  712. interpret_proc_specific_options(opt);
  713. end;
  714. end;
  715. '@' : begin
  716. Message(option_no_nested_response_file);
  717. Stop;
  718. end;
  719. else
  720. begin
  721. if (length(param_file)<>0) then
  722. Message(option_only_one_source_support);
  723. param_file:=opt;
  724. end;
  725. end;
  726. end;
  727. procedure Toption.Interpret_file(const filename : string);
  728. procedure RemoveSep(var fn:string);
  729. var
  730. i : longint;
  731. begin
  732. i:=0;
  733. while (i<length(fn)) and (fn[i+1] in [',',' ',#9]) do
  734. inc(i);
  735. Delete(fn,1,i);
  736. i:=length(fn);
  737. while (i>0) and (fn[i] in [',',' ',#9]) do
  738. dec(i);
  739. fn:=copy(fn,1,i);
  740. end;
  741. function GetName(var fn:string):string;
  742. var
  743. i : longint;
  744. begin
  745. i:=0;
  746. while (i<length(fn)) and (fn[i+1] in ['a'..'z','A'..'Z','0'..'9','_','-']) do
  747. inc(i);
  748. GetName:=Copy(fn,1,i);
  749. Delete(fn,1,i);
  750. end;
  751. const
  752. maxlevel=16;
  753. var
  754. f : text;
  755. s,
  756. opts : string;
  757. skip : array[0..maxlevel-1] of boolean;
  758. level : longint;
  759. begin
  760. { avoid infinite loop }
  761. Inc(FileLevel);
  762. If FileLevel>MaxLevel then
  763. Message(option_too_many_cfg_files);
  764. { open file }
  765. assign(f,filename);
  766. {$ifdef extdebug}
  767. Comment(V_Info,'trying to open file: '+filename);
  768. {$endif extdebug}
  769. {$I-}
  770. reset(f);
  771. {$I+}
  772. if ioresult<>0 then
  773. begin
  774. Message1(option_unable_open_file,filename);
  775. exit;
  776. end;
  777. fillchar(skip,sizeof(skip),0);
  778. level:=0;
  779. while not eof(f) do
  780. begin
  781. readln(f,opts);
  782. RemoveSep(opts);
  783. if (opts<>'') then
  784. begin
  785. if opts[1]='#' then
  786. begin
  787. Delete(opts,1,1);
  788. s:=upper(GetName(opts));
  789. if (s='SECTION') then
  790. begin
  791. RemoveSep(opts);
  792. s:=upper(GetName(opts));
  793. if level=0 then
  794. skip[level]:=not (check_symbol(s) or (s='COMMON'));
  795. end
  796. else
  797. if (s='IFDEF') then
  798. begin
  799. RemoveSep(opts);
  800. if Level>=maxlevel then
  801. begin
  802. Message(option_too_many_ifdef);
  803. stop;
  804. end;
  805. inc(Level);
  806. skip[level]:=(skip[level-1] or (not check_symbol(upper(GetName(opts)))));
  807. end
  808. else
  809. if (s='IFNDEF') then
  810. begin
  811. RemoveSep(opts);
  812. if Level>=maxlevel then
  813. begin
  814. Message(option_too_many_ifdef);
  815. stop;
  816. end;
  817. inc(Level);
  818. skip[level]:=(skip[level-1] or (check_symbol(upper(GetName(opts)))));
  819. end
  820. else
  821. if (s='ELSE') then
  822. skip[level]:=skip[level-1] or (not skip[level])
  823. else
  824. if (s='ENDIF') then
  825. begin
  826. skip[level]:=false;
  827. if Level=0 then
  828. begin
  829. Message(option_too_many_endif);
  830. stop;
  831. end;
  832. dec(level);
  833. end
  834. else
  835. if (not skip[level]) then
  836. begin
  837. if (s='DEFINE') then
  838. begin
  839. RemoveSep(opts);
  840. def_symbol(upper(GetName(opts)));
  841. end
  842. else
  843. if (s='UNDEF') then
  844. begin
  845. RemoveSep(opts);
  846. undef_symbol(upper(GetName(opts)));
  847. end
  848. else
  849. if (s='WRITE') then
  850. begin
  851. Delete(opts,1,1);
  852. WriteLn(opts);
  853. end
  854. else
  855. if (s='INCLUDE') then
  856. begin
  857. Delete(opts,1,1);
  858. Interpret_file(opts);
  859. end;
  860. end;
  861. end
  862. else
  863. begin
  864. if (not skip[level]) and (opts[1]='-') then
  865. interpret_option(opts)
  866. end;
  867. end;
  868. end;
  869. if Level>0 then
  870. Message(option_too_less_endif);
  871. Close(f);
  872. Dec(FileLevel);
  873. end;
  874. procedure toption.read_parameters;
  875. var
  876. opts : string;
  877. paramindex : longint;
  878. begin
  879. paramindex:=0;
  880. while paramindex<paramcount do
  881. begin
  882. inc(paramindex);
  883. opts:=paramstr(paramindex);
  884. if firstpass then
  885. begin
  886. { only parse define,undef,target,verbosity and link options }
  887. if (opts[1]='-') and (opts[2] in ['i','d','v','T','u','n','X']) then
  888. interpret_option(opts);
  889. end
  890. else
  891. begin
  892. if opts[1]='@' then
  893. begin
  894. Delete(opts,1,1);
  895. Message1(option_reading_further_from,opts);
  896. interpret_file(opts);
  897. end
  898. else
  899. interpret_option(opts);
  900. end;
  901. end;
  902. end;
  903. procedure toption.parsecmd(cmd:string);
  904. var
  905. i : longint;
  906. opts : string;
  907. begin
  908. while (cmd<>'') do
  909. begin
  910. while cmd[1]=' ' do
  911. delete(cmd,1,1);
  912. i:=pos(' ',cmd);
  913. if i=0 then
  914. i:=255;
  915. opts:=Copy(cmd,1,i-1);
  916. Delete(cmd,1,i);
  917. if firstpass then
  918. begin
  919. { only parse define,undef,target,verbosity and link options }
  920. if (opts[1]='-') and (opts[2] in ['d','v','T','u','n','X']) then
  921. interpret_option(opts);
  922. end
  923. else
  924. begin
  925. if opts[1]='@' then
  926. begin
  927. Delete(opts,1,1);
  928. Message1(option_reading_further_from,opts);
  929. interpret_file(opts);
  930. end
  931. else
  932. interpret_option(opts);
  933. end;
  934. end;
  935. end;
  936. constructor TOption.Init;
  937. begin
  938. DoWriteLogo:=false;
  939. NoPressEnter:=false;
  940. FirstPass:=false;
  941. FileLevel:=0;
  942. ParaIncludePath:='';
  943. ParaObjectPath:='';
  944. ParaUnitPath:='';
  945. ParaLibraryPath:='';
  946. end;
  947. destructor TOption.Done;
  948. begin
  949. end;
  950. {****************************************************************************
  951. Callable Routines
  952. ****************************************************************************}
  953. procedure read_arguments(cmd:string);
  954. var
  955. configpath : pathstr;
  956. option : poption;
  957. begin
  958. {$ifdef Delphi}
  959. option:=new(poption386,Init);
  960. {$endif Delphi}
  961. {$ifdef i386}
  962. option:=new(poption386,Init);
  963. {$endif}
  964. {$ifdef m68k}
  965. option:=new(poption68k,Init);
  966. {$endif}
  967. {$ifdef alpha}
  968. option:=new(poption,Init);
  969. {$endif}
  970. {$ifdef powerpc}
  971. option:=new(poption,Init);
  972. {$endif}
  973. { Load messages }
  974. if (cmd='') and (paramcount=0) then
  975. Option^.WriteHelpPages;
  976. { default defines }
  977. def_symbol(target_info.short_name);
  978. def_symbol('FPK');
  979. def_symbol('FPC');
  980. def_symbol('VER'+version_nr);
  981. def_symbol('VER'+version_nr+'_'+release_nr);
  982. def_symbol('VER'+version_nr+'_'+release_nr+'_'+patch_nr);
  983. {$ifdef newcg}
  984. def_symbol('WITHNEWCG');
  985. {$endif}
  986. { Temporary defines, until things settle down }
  987. def_symbol('INT64');
  988. def_symbol('HASRESOURCESTRINGS');
  989. def_symbol('HASSAVEREGISTERS');
  990. def_symbol('NEWVMTOFFSET');
  991. def_symbol('HASINTERNMATH');
  992. def_symbol('SYSTEMTVARREC');
  993. { some stuff for TP compatibility }
  994. {$ifdef i386}
  995. def_symbol('CPU86');
  996. def_symbol('CPU87');
  997. {$endif}
  998. {$ifdef m68k}
  999. def_symbol('CPU68');
  1000. {$endif}
  1001. {$ifdef ALPHA}
  1002. def_symbol('CPUALPHA');
  1003. {$endif}
  1004. {$ifdef powerpc}
  1005. def_symbol('CPUPOWERPC');
  1006. {$endif}
  1007. {$ifdef m68k}
  1008. def_symbol('CPU68K');
  1009. {$endif}
  1010. { get default messagefile }
  1011. {$ifdef Delphi}
  1012. msgfilename:=dmisc.getenv('PPC_ERROR_FILE');
  1013. {$else Delphi}
  1014. msgfilename:=dos.getenv('PPC_ERROR_FILE');
  1015. {$endif Delphi}
  1016. { default configfile }
  1017. if (cmd<>'') and (cmd[1]='[') then
  1018. begin
  1019. ppccfg:=Copy(cmd,2,pos(']',cmd)-2);
  1020. Delete(cmd,1,pos(']',cmd));
  1021. end
  1022. else
  1023. begin
  1024. {$ifdef i386}
  1025. ppccfg:='ppc386.cfg';
  1026. {$endif i386}
  1027. {$ifdef m68k}
  1028. ppccfg:='ppc.cfg';
  1029. {$endif}
  1030. {$ifdef alpha}
  1031. ppccfg:='ppcalpha.cfg';
  1032. {$endif}
  1033. {$ifdef powerpc}
  1034. ppccfg:='ppcppc.cfg';
  1035. {$endif}
  1036. end;
  1037. { Order to read ppc386.cfg:
  1038. 1 - current dir
  1039. 2 - configpath
  1040. 3 - compiler path }
  1041. {$ifdef Delphi}
  1042. configpath:=FixPath(dmisc.getenv('PPC_CONFIG_PATH'),false);
  1043. {$else Delphi}
  1044. configpath:=FixPath(dos.getenv('PPC_CONFIG_PATH'),false);
  1045. {$endif Delphi}
  1046. {$ifdef linux}
  1047. if configpath='' then
  1048. configpath:='/etc/';
  1049. {$endif}
  1050. if ppccfg<>'' then
  1051. begin
  1052. read_configfile:=true;
  1053. if not FileExists(ppccfg) then
  1054. begin
  1055. {$ifdef linux}
  1056. if (dos.getenv('HOME')<>'') and FileExists(FixPath(dos.getenv('HOME'),false)+'.'+ppccfg) then
  1057. ppccfg:=FixPath(dos.getenv('HOME'),false)+'.'+ppccfg
  1058. else
  1059. {$endif}
  1060. if FileExists(configpath+ppccfg) then
  1061. ppccfg:=configpath+ppccfg
  1062. else
  1063. {$ifndef linux}
  1064. if FileExists(exepath+ppccfg) then
  1065. ppccfg:=exepath+ppccfg
  1066. else
  1067. {$endif}
  1068. read_configfile:=false;
  1069. end;
  1070. end
  1071. else
  1072. read_configfile:=false;
  1073. { Read commandline and configfile }
  1074. target_is_set:=false;
  1075. asm_is_set:=false;
  1076. param_file:='';
  1077. if read_configfile then
  1078. begin
  1079. { read the parameters quick, only -v -T }
  1080. option^.firstpass:=true;
  1081. if cmd<>'' then
  1082. option^.parsecmd(cmd)
  1083. else
  1084. option^.read_parameters;
  1085. if read_configfile then
  1086. begin
  1087. {$ifdef EXTDEBUG}
  1088. Comment(V_Debug,'read config file: '+ppccfg);
  1089. {$endif EXTDEBUG}
  1090. option^.interpret_file(ppccfg);
  1091. end;
  1092. end;
  1093. option^.firstpass:=false;
  1094. if cmd<>'' then
  1095. option^.parsecmd(cmd)
  1096. else
  1097. option^.read_parameters;
  1098. { Stop if errors in options }
  1099. if ErrorCount>0 then
  1100. Stop;
  1101. { write logo if set }
  1102. if option^.DoWriteLogo then
  1103. option^.WriteLogo;
  1104. { Check file to compile }
  1105. if param_file='' then
  1106. begin
  1107. Message(option_no_source_found);
  1108. Stop;
  1109. end;
  1110. {$ifndef linux}
  1111. param_file:=FixFileName(param_file);
  1112. {$endif}
  1113. fsplit(param_file,inputdir,inputfile,inputextension);
  1114. if inputextension='' then
  1115. begin
  1116. if FileExists(inputdir+inputfile+target_os.sourceext) then
  1117. inputextension:=target_os.sourceext
  1118. else
  1119. if FileExists(inputdir+inputfile+target_os.pasext) then
  1120. inputextension:=target_os.pasext;
  1121. end;
  1122. { Add paths specified with parameters to the searchpaths }
  1123. AddPathToList(UnitSearchPath,Option^.ParaUnitPath,true);
  1124. AddPathToList(ObjectSearchPath,Option^.ParaObjectPath,true);
  1125. AddPathToList(IncludeSearchPath,Option^.ParaIncludePath,true);
  1126. AddPathToList(LibrarySearchPath,Option^.ParaLibraryPath,true);
  1127. { add unit environment and exepath to the unit search path }
  1128. if inputdir<>'' then
  1129. AddPathToList(Unitsearchpath,inputdir,true);
  1130. {$ifdef Delphi}
  1131. AddPathToList(UnitSearchPath,dmisc.getenv(target_info.unit_env),false);
  1132. {$else}
  1133. AddPathToList(UnitSearchPath,dos.getenv(target_info.unit_env),false);
  1134. {$endif Delphi}
  1135. AddPathToList(UnitSearchPath,ExePath,false);
  1136. { Add unit dir to the object and library path }
  1137. AddPathToList(objectsearchpath,unitsearchpath,false);
  1138. AddPathToList(librarysearchpath,unitsearchpath,false);
  1139. { switch assembler if it's binary and we got -a on the cmdline }
  1140. if (cs_asm_leave in initglobalswitches) and
  1141. (target_asm.id in binassem) then
  1142. begin
  1143. Message(option_switch_bin_to_src_assembler);
  1144. set_target_asm(target_info.assemsrc);
  1145. initoutputformat:=target_asm.id;
  1146. end;
  1147. { turn off stripping if compiling with debuginfo or profile }
  1148. if (cs_debuginfo in initmoduleswitches) or
  1149. (cs_profile in initmoduleswitches) then
  1150. initglobalswitches:=initglobalswitches-[cs_link_strip];
  1151. { Set defines depending on the target }
  1152. if (target_info.target in [target_i386_GO32V1,target_i386_GO32V2]) then
  1153. def_symbol('DPMI'); { MSDOS is not defined in BP when target is DPMI }
  1154. MaybeLoadMessageFile;
  1155. dispose(option,Done);
  1156. end;
  1157. end.
  1158. {
  1159. $Log$
  1160. Revision 1.26 1999-10-14 14:57:52 florian
  1161. - removed the hcodegen use in the new cg, use cgbase instead
  1162. Revision 1.25 1999/10/13 10:24:49 peter
  1163. * dpmi can only be set after reading the options
  1164. Revision 1.24 1999/10/03 19:44:41 peter
  1165. * removed objpasunit reference, tvarrec is now searched in systemunit
  1166. where it already was located
  1167. Revision 1.23 1999/09/20 16:38:59 peter
  1168. * cs_create_smart instead of cs_smartlink
  1169. * -CX is create smartlink
  1170. * -CD is create dynamic, but does nothing atm.
  1171. Revision 1.22 1999/09/16 11:34:56 pierre
  1172. * typo correction
  1173. Revision 1.21 1999/09/15 20:35:40 florian
  1174. * small fix to operator overloading when in MMX mode
  1175. + the compiler uses now fldz and fld1 if possible
  1176. + some fixes to floating point registers
  1177. + some math. functions (arctan, ln, sin, cos, sqrt, sqr, pi) are now inlined
  1178. * .... ???
  1179. Revision 1.20 1999/09/03 09:31:22 peter
  1180. * reading of search paths fixed to work as expected
  1181. Revision 1.19 1999/09/01 22:07:20 peter
  1182. * turn off stripping if profiling or debugging
  1183. Revision 1.18 1999/08/28 17:46:10 peter
  1184. * resources are working correct
  1185. Revision 1.17 1999/08/28 15:34:19 florian
  1186. * bug 519 fixed
  1187. Revision 1.16 1999/08/27 10:45:03 pierre
  1188. options -Ca sets simply_ppu to true
  1189. Revision 1.15 1999/08/25 22:51:00 pierre
  1190. * remove trailing space in cfg files
  1191. Revision 1.14 1999/08/16 15:35:26 pierre
  1192. * fix for DLL relocation problems
  1193. * external bss vars had wrong stabs for pecoff
  1194. + -WB11000000 to specify default image base, allows to
  1195. load several DLLs with debugging info included
  1196. (relocatable DLL are stripped because the relocation
  1197. of the .Stab section is misplaced by ldw)
  1198. Revision 1.13 1999/08/11 17:26:35 peter
  1199. * tlinker object is now inherited for win32 and dos
  1200. * postprocessexecutable is now a method of tlinker
  1201. Revision 1.12 1999/08/10 12:51:17 pierre
  1202. * bind_win32_dll removed (Relocsection used instead)
  1203. * now relocsection is true by default ! (needs dlltool
  1204. for DLL generation)
  1205. Revision 1.11 1999/08/09 22:19:52 peter
  1206. * classes vmt changed to only positive addresses
  1207. * sharedlib creation is working
  1208. Revision 1.10 1999/08/05 23:45:10 peter
  1209. * saveregister is now working and used for assert and iocheck (which has
  1210. been moved to system.inc because it's now system independent)
  1211. Revision 1.9 1999/08/04 13:02:46 jonas
  1212. * all tokens now start with an underscore
  1213. * PowerPC compiles!!
  1214. Revision 1.8 1999/08/03 17:09:36 florian
  1215. * the alpha compiler can be compiled now
  1216. Revision 1.7 1999/08/02 23:13:19 florian
  1217. * more changes to compile for the Alpha
  1218. Revision 1.6 1999/07/23 22:56:27 michael
  1219. + Added HasResourceStrings define
  1220. Revision 1.5 1999/07/18 10:19:57 florian
  1221. * made it compilable with Dlephi 4 again
  1222. + fixed problem with large stack allocations on win32
  1223. Revision 1.4 1999/07/05 20:13:14 peter
  1224. * removed temp defines
  1225. Revision 1.3 1999/07/03 00:29:54 peter
  1226. * new link writing to the ppu, one .ppu is needed for all link types,
  1227. static (.o) is now always created also when smartlinking is used
  1228. Revision 1.2 1999/07/01 15:49:19 florian
  1229. * int64/qword type release
  1230. + lo/hi for int64/qword
  1231. Revision 1.1 1999/06/11 13:28:40 peter
  1232. * reinserted
  1233. Revision 1.111 1999/06/10 23:52:31 pierre
  1234. * merged from fixes branch
  1235. Revision 1.110.2.1 1999/06/10 23:37:17 pierre
  1236. * language switch before help screen
  1237. Revision 1.110 1999/05/27 19:44:40 peter
  1238. * removed oldasm
  1239. * plabel -> pasmlabel
  1240. * -a switches to source writing automaticly
  1241. * assembler readers OOPed
  1242. * asmsymbol automaticly external
  1243. * jumptables and other label fixes for asm readers
  1244. Revision 1.109 1999/05/18 14:11:46 peter
  1245. * stop after errors in options
  1246. Revision 1.108 1999/05/17 14:14:15 pierre
  1247. + -gc for check pointer with heaptrc
  1248. Revision 1.107 1999/05/16 02:28:59 peter
  1249. * removed -Fg and -Up
  1250. Revision 1.106 1999/05/06 09:05:20 peter
  1251. * generic write_float and str_float
  1252. * fixed constant float conversions
  1253. Revision 1.105 1999/05/04 21:44:51 florian
  1254. * changes to compile it with Delphi 4.0
  1255. Revision 1.104 1999/05/02 22:41:56 peter
  1256. * moved section names to systems
  1257. * fixed nasm,intel writer
  1258. Revision 1.103 1999/05/01 13:24:25 peter
  1259. * merged nasm compiler
  1260. * old asm moved to oldasm/
  1261. Revision 1.102 1999/04/26 18:29:55 peter
  1262. * farpointerdef moved into pointerdef.is_far
  1263. Revision 1.101 1999/04/26 13:31:35 peter
  1264. * release storenumber,double_checksum
  1265. Revision 1.100 1999/04/17 13:12:21 peter
  1266. * addr() internal
  1267. Revision 1.99 1999/04/16 11:49:44 peter
  1268. + tempalloc
  1269. + -at to show temp alloc info in .s file
  1270. Revision 1.98 1999/04/15 12:19:56 peter
  1271. + finalization support
  1272. Revision 1.97 1999/04/10 16:15:02 peter
  1273. * fixed browcol
  1274. + -ar to show regalloc info in .s file
  1275. Revision 1.96 1999/04/08 15:57:49 peter
  1276. + subrange checking for readln()
  1277. Revision 1.95 1999/04/01 22:07:52 peter
  1278. * universal string names (ansistr instead of stransi) for val/str
  1279. Revision 1.94 1999/03/26 00:05:32 peter
  1280. * released valintern
  1281. + deffile is now removed when compiling is finished
  1282. * ^( compiles now correct
  1283. + static directive
  1284. * shrd fixed
  1285. Revision 1.93 1999/03/25 16:55:32 peter
  1286. + unitpath,librarypath,includepath,objectpath directives
  1287. Revision 1.92 1999/03/24 23:17:08 peter
  1288. * fixed bugs 212,222,225,227,229,231,233
  1289. Revision 1.91 1999/03/16 17:52:51 jonas
  1290. * changes for internal Val code (do a "make cycle OPT=-dvalintern" to test)
  1291. * in cgi386inl: also range checking for subrange types (compile with "-dreadrangecheck")
  1292. * in cgai386: also small fixes to emitrangecheck
  1293. Revision 1.90 1999/03/11 13:39:15 pierre
  1294. * initoutputformat also set by -T arg
  1295. Revision 1.89 1999/03/02 02:56:13 peter
  1296. + stabs support for binary writers
  1297. * more fixes and missing updates from the previous commit :(
  1298. Revision 1.88 1999/02/22 13:06:57 pierre
  1299. + -b and -bl options work !
  1300. + cs_local_browser ($L+) is disabled if cs_browser ($Y+)
  1301. is not enabled when quitting global section
  1302. * local vars and procedures are not yet stored into PPU
  1303. Revision 1.87 1999/02/03 10:18:12 pierre
  1304. * conditional code for extended check of virtual methods
  1305. Revision 1.86 1999/01/12 14:25:28 peter
  1306. + BrowserLog for browser.log generation
  1307. + BrowserCol for browser info in TCollections
  1308. * released all other UseBrowser
  1309. Revision 1.85 1998/12/30 22:04:34 michael
  1310. + Added -Sh switch
  1311. Revision 1.84 1998/12/28 15:45:48 peter
  1312. * fixes for parse_cmd
  1313. Revision 1.83 1998/12/19 00:23:50 florian
  1314. * ansistring memory leaks fixed
  1315. Revision 1.82 1998/12/18 17:25:50 peter
  1316. * removed temp symbols again :)
  1317. Revision 1.81 1998/12/16 14:29:00 jonas
  1318. * use of UnsetBool instead of manually checking for -Option-
  1319. Revision 1.80 1998/12/16 13:36:05 jonas
  1320. * allow '-' after the -C? options to disable them
  1321. Revision 1.78 1998/12/15 10:23:25 peter
  1322. + -iSO, -iSP, -iTO, -iTP
  1323. Revision 1.77 1998/12/14 17:23:05 peter
  1324. + -iV, -iD
  1325. Revision 1.76 1998/12/11 00:03:21 peter
  1326. + globtype,tokens,version unit splitted from globals
  1327. Revision 1.75 1998/12/08 10:18:10 peter
  1328. + -gh for heaptrc unit
  1329. Revision 1.74 1998/11/30 13:26:24 pierre
  1330. * the code for ordering the exported procs/vars was buggy
  1331. + added -WB to force binding (Ozerski way of creating DLL)
  1332. this is off by default as direct writing of .edata section seems
  1333. OK
  1334. Revision 1.73 1998/11/30 09:43:18 pierre
  1335. * some range check bugs fixed (still not working !)
  1336. + added DLL writing support for win32 (also accepts variables)
  1337. + TempAnsi for code that could be used for Temporary ansi strings
  1338. handling
  1339. Revision 1.72 1998/11/28 14:09:45 peter
  1340. * NOATTCDQ define
  1341. Revision 1.71 1998/11/27 14:50:39 peter
  1342. + open strings, $P switch support
  1343. Revision 1.70 1998/11/18 09:18:02 pierre
  1344. + automatic loading of profile unit with -pg option
  1345. in go32v2 mode (also defines FPC_PROFILE)
  1346. * some memory leaks removed
  1347. * unreleased temp problem with sets solved
  1348. Revision 1.69 1998/11/17 11:32:45 peter
  1349. * optimize str:='' in H+ mode
  1350. + -! to test ansistrings
  1351. Revision 1.68 1998/11/17 00:36:46 peter
  1352. * more ansistring fixes
  1353. Revision 1.67 1998/11/13 15:40:20 pierre
  1354. + added -Se in Makefile cvstest target
  1355. + lexlevel cleanup
  1356. normal_function_level main_program_level and unit_init_level defined
  1357. * tins_cache grown to A_EMMS (gave range check error in asm readers)
  1358. (test added in code !)
  1359. * -Un option was wrong
  1360. * _FAIL and _SELF only keyword inside
  1361. constructors and methods respectively
  1362. Revision 1.66 1998/11/13 10:18:08 peter
  1363. + nil constants
  1364. Revision 1.65 1998/11/11 12:34:53 peter
  1365. * fixed small typo
  1366. Revision 1.64 1998/11/10 17:54:12 peter
  1367. * -g disables linker.strip
  1368. Revision 1.63 1998/11/05 12:02:49 peter
  1369. * released useansistring
  1370. * removed -Sv, its now available in fpc modes
  1371. Revision 1.62 1998/11/04 10:11:39 peter
  1372. * ansistring fixes
  1373. Revision 1.61 1998/10/27 08:24:11 pierre
  1374. -lS and -lT options changed to -iS and -iT
  1375. Revision 1.60 1998/10/26 22:23:33 peter
  1376. + fixpath() has an extra option to allow a ./ as path
  1377. Revision 1.59 1998/10/26 14:19:27 pierre
  1378. + added options -lS and -lT for source and target os output
  1379. (to have a easier way to test OS_SOURCE abd OS_TARGET in makefiles)
  1380. * several problems with rtti data
  1381. (type of sym was not checked)
  1382. assumed to be varsym when they could be procsym or property syms !!
  1383. Revision 1.58 1998/10/20 09:32:55 peter
  1384. * removed some unused vars
  1385. Revision 1.57 1998/10/16 13:37:23 florian
  1386. + switch -FD added to specify the path for utilities
  1387. Revision 1.56 1998/10/15 12:37:43 pierre
  1388. + passes vmt offset to HELP_CONSTRUCTOR for objects
  1389. Revision 1.55 1998/10/13 13:10:19 peter
  1390. * new style for m68k/i386 infos and enums
  1391. Revision 1.54 1998/10/13 08:19:40 pierre
  1392. + source_os is now set correctly for cross-processor compilers
  1393. (tos contains all target_infos and
  1394. we use CPU86 and CPU68 conditionals to
  1395. get the source operating system
  1396. this only works if you do not undefine
  1397. the source target !!)
  1398. * several cg68k memory leaks fixed
  1399. + started to change the code so that it should be possible to have
  1400. a complete compiler (both for m68k and i386 !!)
  1401. Revision 1.53 1998/10/09 13:00:25 pierre
  1402. * msgfile existence tested
  1403. Revision 1.52 1998/10/08 17:17:22 pierre
  1404. * current_module old scanner tagged as invalid if unit is recompiled
  1405. + added ppheap for better info on tracegetmem of heaptrc
  1406. (adds line column and file index)
  1407. * several memory leaks removed ith help of heaptrc !!
  1408. Revision 1.51 1998/10/05 13:53:42 peter
  1409. + -Se<value>
  1410. Revision 1.50 1998/10/02 09:24:21 peter
  1411. * more constant expression evaluators
  1412. Revision 1.49 1998/09/26 17:45:29 peter
  1413. + idtoken and only one token table
  1414. Revision 1.48 1998/09/25 09:57:07 peter
  1415. * moved -A to options.pas, becuase the code is the same
  1416. Revision 1.47 1998/09/24 23:47:03 peter
  1417. + -FE,-FU,-Sd
  1418. Revision 1.46 1998/09/23 15:39:06 pierre
  1419. * browser bugfixes
  1420. was adding a reference when looking for the symbol
  1421. if -bSYM_NAME was used
  1422. Revision 1.45 1998/09/22 17:13:47 pierre
  1423. + browsing updated and developed
  1424. records and objects fields are also stored
  1425. Revision 1.44 1998/09/21 08:45:11 pierre
  1426. + added vmt_offset in tobjectdef.write for fututre use
  1427. (first steps to have objects without vmt if no virtual !!)
  1428. + added fpu_used field for tabstractprocdef :
  1429. sets this level to 2 if the functions return with value in FPU
  1430. (is then set to correct value at parsing of implementation)
  1431. THIS MIGHT refuse some code with FPU expression too complex
  1432. that were accepted before and even in some cases
  1433. that don't overflow in fact
  1434. ( like if f : float; is a forward that finally in implementation
  1435. only uses one fpu register !!)
  1436. Nevertheless I think that it will improve security on
  1437. FPU operations !!
  1438. * most other changes only for UseBrowser code
  1439. (added symtable references for record and objects)
  1440. local switch for refs to args and local of each function
  1441. (static symtable still missing)
  1442. UseBrowser still not stable and probably broken by
  1443. the definition hash array !!
  1444. Revision 1.43 1998/09/18 08:01:33 pierre
  1445. + improvement on the usebrowser part
  1446. (does not work correctly for now)
  1447. Revision 1.42 1998/09/14 10:44:09 peter
  1448. * all internal RTL functions start with FPC_
  1449. Revision 1.41 1998/09/03 11:21:51 peter
  1450. * -al sets cs_asm_source
  1451. Revision 1.40 1998/08/31 08:50:32 peter
  1452. * fixed default msgfile loading which is now in verbose.pas
  1453. Revision 1.39 1998/08/29 13:52:38 peter
  1454. + new messagefile
  1455. * merged optione.msg into errore.msg
  1456. Revision 1.38 1998/08/25 12:42:38 pierre
  1457. * CDECL changed to CVAR for variables
  1458. specifications are read in structures also
  1459. + started adding GPC compatibility mode ( option -Sp)
  1460. * names changed to lowercase
  1461. Revision 1.37 1998/08/20 16:10:52 pierre
  1462. Q
  1463. * Changed the -E switch to get better use of RHIDE v1.4.5
  1464. Revision 1.36 1998/08/18 09:05:59 peter
  1465. * new library options
  1466. * smartlink is now -Cx
  1467. Revision 1.35 1998/08/17 09:17:48 peter
  1468. * static/shared linking updates
  1469. Revision 1.34 1998/08/14 21:56:35 peter
  1470. * setting the outputfile using -o works now to create static libs
  1471. Revision 1.33 1998/08/10 23:53:47 peter
  1472. * released all temporary defines
  1473. Revision 1.32 1998/08/10 14:50:03 peter
  1474. + localswitches, moduleswitches, globalswitches splitting
  1475. Revision 1.30 1998/08/10 08:33:17 michael
  1476. -d was destroyed by last comit
  1477. Revision 1.29 1998/08/08 15:31:04 michael
  1478. + Reinstated -e option for linux
  1479. Revision 1.28 1998/07/17 10:06:18 michael
  1480. + under linux, looking for ppc38.cfg in bindir removed.
  1481. Revision 1.27 1998/07/07 11:19:58 peter
  1482. + NEWINPUT for a better inputfile and scanner object
  1483. Revision 1.26 1998/07/06 15:51:17 michael
  1484. Added length checking for string reading
  1485. Revision 1.25 1998/07/04 10:00:22 peter
  1486. + define HAS_PROPERTY
  1487. Revision 1.24 1998/07/01 15:28:49 peter
  1488. + better writeln/readln handling, now 100% like tp7
  1489. Revision 1.22 1998/06/13 00:10:07 peter
  1490. * working browser and newppu
  1491. * some small fixes against crashes which occured in bp7 (but not in
  1492. fpc?!)
  1493. Revision 1.21 1998/06/12 16:15:32 pierre
  1494. * external name 'C_var';
  1495. export name 'intern_C_var';
  1496. cdecl;
  1497. cdecl;external;
  1498. are now supported only with -Sv switch
  1499. Revision 1.20 1998/06/08 22:59:47 peter
  1500. * smartlinking works for win32
  1501. * some defines to exclude some compiler parts
  1502. Revision 1.19 1998/06/04 23:51:46 peter
  1503. * m68k compiles
  1504. + .def file creation moved to gendef.pas so it could also be used
  1505. for win32
  1506. Revision 1.17 1998/05/25 17:11:40 pierre
  1507. * firstpasscount bug fixed
  1508. now all is already set correctly the first time
  1509. under EXTDEBUG try -gp to skip all other firstpasses
  1510. it works !!
  1511. * small bug fixes
  1512. - for smallsets with -dTESTSMALLSET
  1513. - some warnings removed (by correcting code !)
  1514. Revision 1.16 1998/05/23 01:21:12 peter
  1515. + aktasmmode, aktoptprocessor, aktoutputformat
  1516. + smartlink per module $SMARTLINK-/+ (like MMX) and moved to aktswitches
  1517. + $LIBNAME to set the library name where the unit will be put in
  1518. * splitted cgi386 a bit (codeseg to large for bp7)
  1519. * nasm, tasm works again. nasm moved to ag386nsm.pas
  1520. Revision 1.15 1998/05/20 09:42:34 pierre
  1521. + UseTokenInfo now default
  1522. * unit in interface uses and implementation uses gives error now
  1523. * only one error for unknown symbol (uses lastsymknown boolean)
  1524. the problem came from the label code !
  1525. + first inlined procedures and function work
  1526. (warning there might be allowed cases were the result is still wrong !!)
  1527. * UseBrower updated gives a global list of all position of all used symbols
  1528. with switch -gb
  1529. Revision 1.14 1998/05/12 10:46:59 peter
  1530. * moved printstatus to verb_def
  1531. + V_Normal which is between V_Error and V_Warning and doesn't have a
  1532. prefix like error: warning: and is included in V_Default
  1533. * fixed some messages
  1534. * first time parameter scan is only for -v and -T
  1535. - removed old style messages
  1536. Revision 1.13 1998/05/08 09:21:20 michael
  1537. * Added missing -Fl message to messages file.
  1538. * Corrected mangling of file names when doing Linklib
  1539. * -Fl now actually WORKS.
  1540. * Librarysearchpath is now a field in linker object.
  1541. Revision 1.12 1998/05/06 08:38:41 pierre
  1542. * better position info with UseTokenInfo
  1543. UseTokenInfo greatly simplified
  1544. + added check for changed tree after first time firstpass
  1545. (if we could remove all the cases were it happen
  1546. we could skip all firstpass if firstpasscount > 1)
  1547. Only with ExtDebug
  1548. Revision 1.11 1998/05/04 17:54:27 peter
  1549. + smartlinking works (only case jumptable left todo)
  1550. * redesign of systems.pas to support assemblers and linkers
  1551. + Unitname is now also in the PPU-file, increased version to 14
  1552. Revision 1.10 1998/05/01 16:38:44 florian
  1553. * handling of private and protected fixed
  1554. + change_keywords_to_tp implemented to remove
  1555. keywords which aren't supported by tp
  1556. * break and continue are now symbols of the system unit
  1557. + widestring, longstring and ansistring type released
  1558. Revision 1.9 1998/04/30 15:59:40 pierre
  1559. * GDB works again better :
  1560. correct type info in one pass
  1561. + UseTokenInfo for better source position
  1562. * fixed one remaining bug in scanner for line counts
  1563. * several little fixes
  1564. Revision 1.8 1998/04/27 15:45:20 peter
  1565. + -Xl for smartlink
  1566. + target_info.arext = .a
  1567. Revision 1.7 1998/04/23 12:07:25 peter
  1568. * fixed -i
  1569. Revision 1.6 1998/04/08 16:58:03 pierre
  1570. * several bugfixes
  1571. ADD ADC and AND are also sign extended
  1572. nasm output OK (program still crashes at end
  1573. and creates wrong assembler files !!)
  1574. procsym types sym in tdef removed !!
  1575. Revision 1.5 1998/04/08 12:31:00 peter
  1576. + .ppc386.cfg and #INCLUDE support
  1577. Revision 1.4 1998/04/07 13:19:46 pierre
  1578. * bugfixes for reset_gdb_info
  1579. in MEM parsing for go32v2
  1580. better external symbol creation
  1581. support for rhgdb.exe (lowercase file names)
  1582. }