options.pas 58 KB

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