globals.pas 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618
  1. {
  2. $Id$
  3. Copyright (C) 1998-2000 by Florian Klaempfl
  4. This unit implements some support functions and global variables
  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 globals;
  19. {$i defines.inc}
  20. interface
  21. uses
  22. {$ifdef win32}
  23. windows,
  24. {$endif}
  25. {$ifdef unix}
  26. {$ifdef ver1_0}
  27. linux,
  28. {$else}
  29. unix,
  30. {$endif}
  31. {$endif}
  32. {$ifdef os2}
  33. doscalls,
  34. {$endif}
  35. {$ifdef Delphi}
  36. SysUtils,
  37. dmisc,
  38. {$else}
  39. strings,
  40. dos,
  41. {$endif}
  42. cutils,cclasses,
  43. globtype,version,systems;
  44. const
  45. {$ifdef Splitheap}
  46. testsplit : boolean = false;
  47. {$endif Splitheap}
  48. delphimodeswitches : tmodeswitches=
  49. [m_delphi,m_tp,m_all,m_class,m_objpas,m_result,m_string_pchar,
  50. m_pointer_2_procedure,m_autoderef,m_tp_procvar,m_initfinal,m_default_ansistring,
  51. m_out,m_default_para,m_hintdirective];
  52. fpcmodeswitches : tmodeswitches=
  53. [m_fpc,m_all,m_string_pchar,m_nested_comment,m_repeat_forward,
  54. m_cvar_support,m_initfinal,m_add_pointer];
  55. objfpcmodeswitches : tmodeswitches=
  56. [m_objfpc,m_fpc,m_all,m_class,m_objpas,m_result,m_string_pchar,m_nested_comment,
  57. m_repeat_forward,m_cvar_support,m_initfinal,m_add_pointer,m_out,m_default_para];
  58. tpmodeswitches : tmodeswitches=
  59. [m_tp7,m_tp,m_all,m_tp_procvar];
  60. gpcmodeswitches : tmodeswitches=
  61. [m_gpc,m_all];
  62. type
  63. pfileposinfo = ^tfileposinfo;
  64. tfileposinfo = record
  65. line : longint;
  66. column : word;
  67. fileindex : word;
  68. end;
  69. TSearchPathList = class(TStringList)
  70. procedure AddPath(s:string;addfirst:boolean);
  71. procedure AddList(list:TSearchPathList;addfirst:boolean);
  72. function FindFile(const f : string;var foundfile:string):boolean;
  73. end;
  74. var
  75. { specified inputfile }
  76. inputdir : dirstr;
  77. inputfile : namestr;
  78. inputextension : extstr;
  79. { specified outputfile with -o parameter }
  80. outputfile : namestr;
  81. { specified with -FE or -FU }
  82. outputexedir : dirstr;
  83. outputunitdir : dirstr;
  84. { things specified with parameters }
  85. paralinkoptions,
  86. paradynamiclinker : string;
  87. parapreprocess : boolean;
  88. { directory where the utils can be found (options -FD) }
  89. utilsdirectory : dirstr;
  90. { some flags for global compiler switches }
  91. do_build,
  92. do_release,
  93. do_make : boolean;
  94. not_unit_proc : boolean;
  95. { path for searching units, different paths can be seperated by ; }
  96. exepath : dirstr; { Path to ppc }
  97. librarysearchpath,
  98. unitsearchpath,
  99. objectsearchpath,
  100. includesearchpath : TSearchPathList;
  101. { deffile }
  102. usewindowapi : boolean;
  103. description : string;
  104. dllversion : string;
  105. dllmajor,dllminor,dllrevision : word; { revision only for netware }
  106. akttokenpos, { position of the last token }
  107. aktfilepos : tfileposinfo; { current position }
  108. { ad 18.05.2001: Screen and Threadname for Netware }
  109. nwscreenname : string;
  110. nwthreadname : string;
  111. nwcopyright : string;
  112. block_type : tblock_type; { type of currently parsed block }
  113. in_args : boolean; { arguments must be checked especially }
  114. parsing_para_level : integer; { parameter level, used to convert
  115. proc calls to proc loads in firstcalln }
  116. compile_level : word;
  117. make_ref : boolean;
  118. resolving_forward : boolean; { used to add forward reference as second ref }
  119. use_esp_stackframe : boolean; { to test for call with ESP as stack frame }
  120. inlining_procedure : boolean; { are we inlining a procedure }
  121. statement_level : integer;
  122. exceptblockcounter : integer; { each except block gets a unique number check gotos }
  123. aktexceptblock : integer; { the exceptblock number of the current block (0 if none) }
  124. { commandline values }
  125. initdefines : tstringlist;
  126. initglobalswitches : tglobalswitches;
  127. initmoduleswitches : tmoduleswitches;
  128. initlocalswitches : tlocalswitches;
  129. initmodeswitches : tmodeswitches;
  130. {$IFDEF testvarsets}
  131. Initsetalloc, {0=fixed, 1 =var}
  132. {$ENDIF}
  133. initpackenum : longint;
  134. initalignment : talignmentinfo;
  135. initoptprocessor,
  136. initspecificoptprocessor : tprocessors;
  137. initasmmode : tasmmode;
  138. initinterfacetype : tinterfacetypes;
  139. initoutputformat : tasm;
  140. initdefproccall : TDefProcCall;
  141. { current state values }
  142. aktglobalswitches : tglobalswitches;
  143. aktmoduleswitches : tmoduleswitches;
  144. aktlocalswitches : tlocalswitches;
  145. nextaktlocalswitches : tlocalswitches;
  146. localswitcheschanged : boolean;
  147. aktmodeswitches : tmodeswitches;
  148. {$IFDEF testvarsets}
  149. aktsetalloc,
  150. {$ENDIF}
  151. aktpackenum : longint;
  152. aktmaxfpuregisters : longint;
  153. aktalignment : talignmentinfo;
  154. aktoptprocessor,
  155. aktspecificoptprocessor : tprocessors;
  156. aktasmmode : tasmmode;
  157. aktinterfacetype : tinterfacetypes;
  158. aktoutputformat : tasm;
  159. aktdefproccall : TDefProcCall;
  160. { Memory sizes }
  161. heapsize,
  162. maxheapsize,
  163. stacksize : longint;
  164. {$Ifdef EXTDEBUG}
  165. total_of_firstpass,
  166. firstpass_several : longint;
  167. {$ifdef FPC}
  168. EntryMemUsed : longint;
  169. {$endif FPC}
  170. { parameter switches }
  171. debugstop : boolean;
  172. {$EndIf EXTDEBUG}
  173. { windows / OS/2 application type }
  174. apptype : tapptype;
  175. const
  176. RelocSection : boolean = true;
  177. RelocSectionSetExplicitly : boolean = false;
  178. LinkTypeSetExplicitly : boolean = false;
  179. DLLsource : boolean = false;
  180. DLLImageBase : pstring = nil;
  181. UseDeffileForExport : boolean = true;
  182. ForceDeffileForExport : boolean = false;
  183. { used to set all registers used for each global function
  184. this should dramatically decrease the number of
  185. recompilations needed PM }
  186. simplify_ppu : boolean = true;
  187. { should we allow non static members ? }
  188. allow_only_static : boolean = false;
  189. Inside_asm_statement : boolean = false;
  190. global_unit_count : word = 0;
  191. { for error info in pp.pas }
  192. parser_current_file : string = '';
  193. {$ifdef m68k}
  194. { PalmOS resources }
  195. palmos_applicationname : string = 'FPC Application';
  196. palmos_applicationid : string[4] = 'FPCA';
  197. {$endif m68k}
  198. procedure abstract;
  199. function bstoslash(const s : string) : string;
  200. function getdatestr:string;
  201. function gettimestr:string;
  202. function filetimestring( t : longint) : string;
  203. procedure DefaultReplacements(var s:string);
  204. function GetCurrentDir:string;
  205. function path_absolute(const s : string) : boolean;
  206. Function PathExists ( F : String) : Boolean;
  207. Function FileExists ( Const F : String) : Boolean;
  208. Function RemoveFile(const f:string):boolean;
  209. Function RemoveDir(d:string):boolean;
  210. Function GetFileTime ( Var F : File) : Longint;
  211. Function GetNamedFileTime ( Const F : String) : Longint;
  212. Function SplitPath(const s:string):string;
  213. Function SplitFileName(const s:string):string;
  214. Function SplitName(const s:string):string;
  215. Function SplitExtension(Const HStr:String):String;
  216. Function AddExtension(Const HStr,ext:String):String;
  217. Function ForceExtension(Const HStr,ext:String):String;
  218. Function FixPath(s:string;allowdot:boolean):string;
  219. function FixFileName(const s:string):string;
  220. function TargetFixPath(s:string;allowdot:boolean):string;
  221. function TargetFixFileName(const s:string):string;
  222. procedure SplitBinCmd(const s:string;var bstr,cstr:string);
  223. function FindFile(const f : string;path : string;var foundfile:string):boolean;
  224. function FindExe(const bin:string;var foundfile:string):boolean;
  225. function GetShortName(const n:string):string;
  226. Procedure Shell(const command:string);
  227. function GetEnvPChar(const envname:string):pchar;
  228. procedure FreeEnvPChar(p:pchar);
  229. Function SetCompileMode(const s:string; changeInit: boolean):boolean;
  230. function SetAktProcCall(const s:string; changeInit: boolean):boolean;
  231. procedure InitGlobals;
  232. procedure DoneGlobals;
  233. function string2guid(const s: string; var GUID: TGUID): boolean;
  234. function guid2string(const GUID: TGUID): string;
  235. function UpdateAlignmentStr(s:string;var a:talignmentinfo):boolean;
  236. implementation
  237. uses
  238. comphook;
  239. procedure abstract;
  240. begin
  241. do_internalerror(255);
  242. end;
  243. function bstoslash(const s : string) : string;
  244. {
  245. return string s with all \ changed into /
  246. }
  247. var
  248. i : longint;
  249. begin
  250. for i:=1to length(s) do
  251. if s[i]='\' then
  252. bstoslash[i]:='/'
  253. else
  254. bstoslash[i]:=s[i];
  255. bstoslash[0]:=s[0];
  256. end;
  257. {****************************************************************************
  258. Time Handling
  259. ****************************************************************************}
  260. Function L0(l:longint):string;
  261. {
  262. return the string of value l, if l<10 then insert a zero, so
  263. the string is always at least 2 chars '01','02',etc
  264. }
  265. var
  266. s : string;
  267. begin
  268. Str(l,s);
  269. if l<10 then
  270. s:='0'+s;
  271. L0:=s;
  272. end;
  273. function gettimestr:string;
  274. {
  275. get the current time in a string HH:MM:SS
  276. }
  277. var
  278. hour,min,sec,hsec : word;
  279. begin
  280. {$ifdef delphi}
  281. dmisc.gettime(hour,min,sec,hsec);
  282. {$else delphi}
  283. dos.gettime(hour,min,sec,hsec);
  284. {$endif delphi}
  285. gettimestr:=L0(Hour)+':'+L0(min)+':'+L0(sec);
  286. end;
  287. function getdatestr:string;
  288. {
  289. get the current date in a string YY/MM/DD
  290. }
  291. var
  292. Year,Month,Day,Wday : Word;
  293. begin
  294. {$ifdef delphi}
  295. dmisc.getdate(year,month,day,wday);
  296. {$else}
  297. dos.getdate(year,month,day,wday);
  298. {$endif}
  299. getdatestr:=L0(Year)+'/'+L0(Month)+'/'+L0(Day);
  300. end;
  301. function filetimestring( t : longint) : string;
  302. {
  303. convert dos datetime t to a string YY/MM/DD HH:MM:SS
  304. }
  305. var
  306. DT : DateTime;
  307. begin
  308. if t=-1 then
  309. begin
  310. FileTimeString:='Not Found';
  311. exit;
  312. end;
  313. unpacktime(t,DT);
  314. filetimestring:=L0(dt.Year)+'/'+L0(dt.Month)+'/'+L0(dt.Day)+' '+L0(dt.Hour)+':'+L0(dt.min)+':'+L0(dt.sec);
  315. end;
  316. {****************************************************************************
  317. Default Macro Handling
  318. ****************************************************************************}
  319. procedure DefaultReplacements(var s:string);
  320. begin
  321. { Replace some macro's }
  322. Replace(s,'$FPCVER',version_string);
  323. Replace(s,'$VERSION',version_string);
  324. Replace(s,'$FULLVERSION',full_version_string);
  325. Replace(s,'$FPCDATE',date_string);
  326. Replace(s,'$FPCTARGET',target_cpu_string);
  327. Replace(s,'$FPCCPU',target_cpu_string);
  328. Replace(s,'$TARGET',target_path);
  329. Replace(s,'$FPCOS',target_path);
  330. end;
  331. {****************************************************************************
  332. File Handling
  333. ****************************************************************************}
  334. function GetCurrentDir:string;
  335. var
  336. CurrentDir : string;
  337. begin
  338. GetDir(0,CurrentDir);
  339. GetCurrentDir:=FixPath(CurrentDir,false);
  340. end;
  341. function path_absolute(const s : string) : boolean;
  342. {
  343. is path s an absolute path?
  344. }
  345. begin
  346. path_absolute:=false;
  347. {$ifdef unix}
  348. if (length(s)>0) and (s[1]='/') then
  349. path_absolute:=true;
  350. {$else unix}
  351. {$ifdef amiga}
  352. if ((length(s)>0) and ((s[1]='\') or (s[1]='/'))) or (Pos(':',s) = length(s)) then
  353. path_absolute:=true;
  354. {$else}
  355. if ((length(s)>0) and ((s[1]='\') or (s[1]='/'))) or
  356. ((length(s)>2) and (s[2]=':') and ((s[3]='\') or (s[3]='/'))) then
  357. path_absolute:=true;
  358. {$endif amiga}
  359. {$endif unix}
  360. end;
  361. {$ifndef FPC}
  362. Procedure FindClose(var Info : SearchRec);
  363. Begin
  364. End;
  365. {$endif not FPC}
  366. Function FileExists ( Const F : String) : Boolean;
  367. {$ifndef delphi}
  368. Var
  369. Info : SearchRec;
  370. {$endif}
  371. begin
  372. {$ifdef delphi}
  373. FileExists:=sysutils.FileExists(f);
  374. {$else}
  375. findfirst(F,readonly+archive+hidden,info);
  376. FileExists:=(doserror=0);
  377. findclose(Info);
  378. {$endif delphi}
  379. end;
  380. Function PathExists ( F : String) : Boolean;
  381. Var
  382. Info : SearchRec;
  383. {$ifdef i386}
  384. disk : byte;
  385. {$endif i386}
  386. begin
  387. {$ifdef i386}
  388. if (Length(f)=3) and (F[2]=':') and (F[3] in ['/','\']) then
  389. begin
  390. if F[1] in ['A'..'Z'] then
  391. disk:=ord(F[1])-ord('A')+1
  392. else if F[1] in ['a'..'z'] then
  393. disk:=ord(F[1])-ord('a')+1
  394. else
  395. disk:=255;
  396. if disk=255 then
  397. PathExists:=false
  398. else
  399. PathExists:=(DiskSize(disk)<>-1);
  400. exit;
  401. end;
  402. {$endif i386}
  403. if F[Length(f)] in ['/','\'] then
  404. Delete(f,length(f),1);
  405. findfirst(F,readonly+archive+hidden+directory,info);
  406. PathExists:=(doserror=0) and ((info.attr and directory)=directory);
  407. findclose(Info);
  408. end;
  409. Function RemoveFile(const f:string):boolean;
  410. var
  411. g : file;
  412. begin
  413. assign(g,f);
  414. {$I-}
  415. erase(g);
  416. {$I+}
  417. RemoveFile:=(ioresult=0);
  418. end;
  419. Function RemoveDir(d:string):boolean;
  420. begin
  421. if d[length(d)]=source_info.DirSep then
  422. Delete(d,length(d),1);
  423. {$I-}
  424. rmdir(d);
  425. {$I+}
  426. RemoveDir:=(ioresult=0);
  427. end;
  428. Function SplitPath(const s:string):string;
  429. var
  430. i : longint;
  431. begin
  432. i:=Length(s);
  433. while (i>0) and not(s[i] in ['/','\']) do
  434. dec(i);
  435. SplitPath:=Copy(s,1,i);
  436. end;
  437. Function SplitFileName(const s:string):string;
  438. var
  439. p : dirstr;
  440. n : namestr;
  441. e : extstr;
  442. begin
  443. FSplit(s,p,n,e);
  444. SplitFileName:=n+e;
  445. end;
  446. Function SplitName(const s:string):string;
  447. var
  448. i,j : longint;
  449. begin
  450. i:=Length(s);
  451. j:=Length(s);
  452. while (i>0) and not(s[i] in ['/','\']) do
  453. dec(i);
  454. while (j>0) and (s[j]<>'.') do
  455. dec(j);
  456. if j<=i then
  457. j:=255;
  458. SplitName:=Copy(s,i+1,j-(i+1));
  459. end;
  460. Function SplitExtension(Const HStr:String):String;
  461. var
  462. j : longint;
  463. begin
  464. j:=length(Hstr);
  465. while (j>0) and (Hstr[j]<>'.') do
  466. begin
  467. if hstr[j]=source_info.DirSep then
  468. j:=0
  469. else
  470. dec(j);
  471. end;
  472. if j=0 then
  473. j:=254;
  474. SplitExtension:=Copy(Hstr,j,255);
  475. end;
  476. Function AddExtension(Const HStr,ext:String):String;
  477. begin
  478. if (Ext<>'') and (SplitExtension(HStr)='') then
  479. AddExtension:=Hstr+Ext
  480. else
  481. AddExtension:=Hstr;
  482. end;
  483. Function ForceExtension(Const HStr,ext:String):String;
  484. var
  485. j : longint;
  486. begin
  487. j:=length(Hstr);
  488. while (j>0) and (Hstr[j]<>'.') do
  489. dec(j);
  490. if j=0 then
  491. j:=255;
  492. ForceExtension:=Copy(Hstr,1,j-1)+Ext;
  493. end;
  494. Function FixPath(s:string;allowdot:boolean):string;
  495. var
  496. i : longint;
  497. begin
  498. { Fix separator }
  499. for i:=1 to length(s) do
  500. if s[i] in ['/','\'] then
  501. s[i]:=source_info.DirSep;
  502. { Fix ending / }
  503. if (length(s)>0) and (s[length(s)]<>source_info.DirSep) and
  504. (s[length(s)]<>':') then
  505. s:=s+source_info.DirSep;
  506. { Remove ./ }
  507. if (not allowdot) and (s='.'+source_info.DirSep) then
  508. s:='';
  509. { return }
  510. if source_info.files_case_relevent then
  511. FixPath:=s
  512. else
  513. FixPath:=Lower(s);
  514. end;
  515. function FixFileName(const s:string):string;
  516. var
  517. i : longint;
  518. begin
  519. if source_info.files_case_relevent then
  520. begin
  521. for i:=1 to length(s) do
  522. begin
  523. case s[i] of
  524. '/','\' :
  525. FixFileName[i]:=source_info.dirsep;
  526. else
  527. FixFileName[i]:=s[i];
  528. end;
  529. end;
  530. end
  531. else
  532. begin
  533. for i:=1 to length(s) do
  534. begin
  535. case s[i] of
  536. '/','\' :
  537. FixFileName[i]:=source_info.dirsep;
  538. 'A'..'Z' :
  539. FixFileName[i]:=char(byte(s[i])+32);
  540. else
  541. FixFileName[i]:=s[i];
  542. end;
  543. end;
  544. end;
  545. FixFileName[0]:=s[0];
  546. end;
  547. Function TargetFixPath(s:string;allowdot:boolean):string;
  548. var
  549. i : longint;
  550. begin
  551. { Fix separator }
  552. for i:=1 to length(s) do
  553. if s[i] in ['/','\'] then
  554. s[i]:=target_info.DirSep;
  555. { Fix ending / }
  556. if (length(s)>0) and (s[length(s)]<>target_info.DirSep) and
  557. (s[length(s)]<>':') then
  558. s:=s+target_info.DirSep;
  559. { Remove ./ }
  560. if (not allowdot) and (s='.'+target_info.DirSep) then
  561. s:='';
  562. { return }
  563. if target_info.files_case_relevent then
  564. TargetFixPath:=s
  565. else
  566. TargetFixPath:=Lower(s);
  567. end;
  568. function TargetFixFileName(const s:string):string;
  569. var
  570. i : longint;
  571. begin
  572. if target_info.files_case_relevent then
  573. begin
  574. for i:=1 to length(s) do
  575. begin
  576. case s[i] of
  577. '/','\' :
  578. TargetFixFileName[i]:=target_info.dirsep;
  579. else
  580. TargetFixFileName[i]:=s[i];
  581. end;
  582. end;
  583. end
  584. else
  585. begin
  586. for i:=1 to length(s) do
  587. begin
  588. case s[i] of
  589. '/','\' :
  590. TargetFixFileName[i]:=target_info.dirsep;
  591. 'A'..'Z' :
  592. TargetFixFileName[i]:=char(byte(s[i])+32);
  593. else
  594. TargetFixFileName[i]:=s[i];
  595. end;
  596. end;
  597. end;
  598. TargetFixFileName[0]:=s[0];
  599. end;
  600. procedure SplitBinCmd(const s:string;var bstr,cstr:string);
  601. var
  602. i : longint;
  603. begin
  604. i:=pos(' ',s);
  605. if i>0 then
  606. begin
  607. bstr:=Copy(s,1,i-1);
  608. cstr:=Copy(s,i+1,length(s)-i);
  609. end
  610. else
  611. begin
  612. bstr:=s;
  613. cstr:='';
  614. end;
  615. end;
  616. procedure TSearchPathList.AddPath(s:string;addfirst:boolean);
  617. var
  618. j : longint;
  619. hs,hsd,
  620. CurrentDir,
  621. CurrPath : string;
  622. dir : searchrec;
  623. hp : TStringListItem;
  624. procedure addcurrpath;
  625. begin
  626. if addfirst then
  627. begin
  628. Remove(currPath);
  629. Insert(currPath);
  630. end
  631. else
  632. begin
  633. { Check if already in path, then we don't add it }
  634. hp:=Find(currPath);
  635. if not assigned(hp) then
  636. Concat(currPath);
  637. end;
  638. end;
  639. begin
  640. if s='' then
  641. exit;
  642. { Support default macro's }
  643. DefaultReplacements(s);
  644. { get current dir }
  645. CurrentDir:=GetCurrentDir;
  646. repeat
  647. { get currpath }
  648. if addfirst then
  649. begin
  650. j:=length(s);
  651. while (j>0) and (s[j]<>';') do
  652. dec(j);
  653. CurrPath:=FixPath(Copy(s,j+1,length(s)-j),false);
  654. if j=0 then
  655. s:=''
  656. else
  657. System.Delete(s,j,length(s)-j+1);
  658. end
  659. else
  660. begin
  661. j:=Pos(';',s);
  662. if j=0 then
  663. j:=255;
  664. CurrPath:=FixPath(Copy(s,1,j-1),false);
  665. System.Delete(s,1,j);
  666. end;
  667. { fix pathname }
  668. if CurrPath='' then
  669. CurrPath:='.'+source_info.DirSep
  670. else
  671. begin
  672. CurrPath:=FixPath(FExpand(CurrPath),false);
  673. if (CurrentDir<>'') and (Copy(CurrPath,1,length(CurrentDir))=CurrentDir) then
  674. CurrPath:='.'+source_info.DirSep+Copy(CurrPath,length(CurrentDir)+1,255);
  675. end;
  676. { wildcard adding ? }
  677. if pos('*',currpath)>0 then
  678. begin
  679. if currpath[length(currpath)]=source_info.dirsep then
  680. hs:=Copy(currpath,1,length(CurrPath)-1)
  681. else
  682. hs:=currpath;
  683. hsd:=SplitPath(hs);
  684. findfirst(hs,directory,dir);
  685. while doserror=0 do
  686. begin
  687. if (dir.name<>'.') and
  688. (dir.name<>'..') and
  689. ((dir.attr and directory)<>0) then
  690. begin
  691. currpath:=hsd+dir.name+source_info.dirsep;
  692. hp:=Find(currPath);
  693. if not assigned(hp) then
  694. AddCurrPath;
  695. end;
  696. findnext(dir);
  697. end;
  698. FindClose(dir);
  699. end
  700. else
  701. begin
  702. if PathExists(currpath) then
  703. addcurrpath;
  704. end;
  705. until (s='');
  706. end;
  707. procedure TSearchPathList.AddList(list:TSearchPathList;addfirst:boolean);
  708. var
  709. s : string;
  710. hl : TSearchPathList;
  711. hp,hp2 : TStringListItem;
  712. begin
  713. if list.empty then
  714. exit;
  715. { create temp and reverse the list }
  716. if addfirst then
  717. begin
  718. hl:=TSearchPathList.Create;
  719. hp:=TStringListItem(list.first);
  720. while assigned(hp) do
  721. begin
  722. hl.insert(hp.Str);
  723. hp:=TStringListItem(hp.next);
  724. end;
  725. while not hl.empty do
  726. begin
  727. s:=hl.GetFirst;
  728. Remove(s);
  729. Insert(s);
  730. end;
  731. hl.Free;
  732. end
  733. else
  734. begin
  735. hp:=TStringListItem(list.first);
  736. while assigned(hp) do
  737. begin
  738. hp2:=Find(hp.Str);
  739. { Check if already in path, then we don't add it }
  740. if not assigned(hp2) then
  741. Concat(hp.Str);
  742. hp:=TStringListItem(hp.next);
  743. end;
  744. end;
  745. end;
  746. function TSearchPathList.FindFile(const f : string;var foundfile:string):boolean;
  747. Var
  748. p : TStringListItem;
  749. begin
  750. FindFile:=false;
  751. p:=TStringListItem(first);
  752. while assigned(p) do
  753. begin
  754. {
  755. Search order for case sensitive systems:
  756. 1. lowercase
  757. 2. NormalCase
  758. 3. UPPERCASE
  759. None case sensitive only lowercase
  760. }
  761. FoundFile:=p.Str+Lower(f);
  762. If FileExists(FoundFile) then
  763. begin
  764. FindFile:=true;
  765. exit;
  766. end;
  767. {$ifdef UNIX}
  768. FoundFile:=p.Str+f;
  769. If FileExists(FoundFile) then
  770. begin
  771. FindFile:=true;
  772. exit;
  773. end;
  774. FoundFile:=p.Str+Upper(f);
  775. If FileExists(FoundFile) then
  776. begin
  777. FindFile:=true;
  778. exit;
  779. end;
  780. {$endif UNIX}
  781. p:=TStringListItem(p.next);
  782. end;
  783. { Return original filename if not found }
  784. FoundFile:=f;
  785. end;
  786. Function GetFileTime ( Var F : File) : Longint;
  787. Var
  788. {$ifdef unix}
  789. Info : Stat;
  790. {$endif}
  791. L : longint;
  792. begin
  793. {$ifdef unix}
  794. FStat (F,Info);
  795. L:=Info.Mtime;
  796. {$else}
  797. GetFTime(f,l);
  798. {$endif}
  799. GetFileTime:=L;
  800. end;
  801. Function GetNamedFileTime (Const F : String) : Longint;
  802. begin
  803. GetNamedFileTime:=do_getnamedfiletime(F);
  804. end;
  805. function FindFile(const f : string;path : string;var foundfile:string):boolean;
  806. Var
  807. singlepathstring : string;
  808. i : longint;
  809. begin
  810. {$ifdef Unix}
  811. for i:=1 to length(path) do
  812. if path[i]=':' then
  813. path[i]:=';';
  814. {$endif Unix}
  815. FindFile:=false;
  816. repeat
  817. i:=pos(';',path);
  818. if i=0 then
  819. i:=256;
  820. singlepathstring:=FixPath(copy(path,1,i-1),false);
  821. delete(path,1,i);
  822. {
  823. Search order for case sensitive systems:
  824. 1. lowercase
  825. 2. NormalCase
  826. 3. UPPERCASE
  827. None case sensitive only lowercase
  828. }
  829. FoundFile:=singlepathstring+Lower(f);
  830. If FileExists(FoundFile) then
  831. begin
  832. FindFile:=true;
  833. exit;
  834. end;
  835. {$ifdef UNIX}
  836. FoundFile:=singlepathstring+f;
  837. If FileExists(FoundFile) then
  838. begin
  839. FindFile:=true;
  840. exit;
  841. end;
  842. FoundFile:=singlepathstring+Upper(f);
  843. If FileExists(FoundFile) then
  844. begin
  845. FindFile:=true;
  846. exit;
  847. end;
  848. {$endif UNIX}
  849. until path='';
  850. FoundFile:=f;
  851. end;
  852. function FindExe(const bin:string;var foundfile:string):boolean;
  853. begin
  854. {$ifdef delphi}
  855. FindExe:=FindFile(FixFileName(AddExtension(bin,source_info.exeext)),'.;'+exepath+';'+dmisc.getenv('PATH'),foundfile);
  856. {$else delphi}
  857. FindExe:=FindFile(FixFileName(AddExtension(bin,source_info.exeext)),'.;'+exepath+';'+dos.getenv('PATH'),foundfile);
  858. {$endif delphi}
  859. end;
  860. function GetShortName(const n:string):string;
  861. {$ifdef win32}
  862. var
  863. hs,hs2 : string;
  864. i : longint;
  865. {$endif}
  866. {$ifdef go32v2}
  867. var
  868. hs : string;
  869. {$endif}
  870. begin
  871. GetShortName:=n;
  872. {$ifdef win32}
  873. hs:=n+#0;
  874. i:=Windows.GetShortPathName(@hs[1],@hs2[1],high(hs2));
  875. if (i>0) and (i<=high(hs2)) then
  876. begin
  877. hs2[0]:=chr(strlen(@hs2[1]));
  878. GetShortName:=hs2;
  879. end;
  880. {$endif}
  881. {$ifdef go32v2}
  882. hs:=n;
  883. if Dos.GetShortName(hs) then
  884. GetShortName:=hs;
  885. {$endif}
  886. end;
  887. {****************************************************************************
  888. OS Dependent things
  889. ****************************************************************************}
  890. function GetEnvPChar(const envname:string):pchar;
  891. {$ifdef win32}
  892. var
  893. s : string;
  894. i,len : longint;
  895. hp,p,p2 : pchar;
  896. {$endif}
  897. {$ifdef os2}
  898. var
  899. P1, P2: PChar;
  900. {$endif}
  901. begin
  902. {$ifdef unix}
  903. GetEnvPchar:={$ifdef ver1_0}Linux{$else}Unix{$endif}.Getenv(envname);
  904. {$define GETENVOK}
  905. {$endif}
  906. {$ifdef win32}
  907. GetEnvPchar:=nil;
  908. p:=GetEnvironmentStrings;
  909. hp:=p;
  910. while hp^<>#0 do
  911. begin
  912. s:=strpas(hp);
  913. i:=pos('=',s);
  914. len:=strlen(hp);
  915. if upper(copy(s,1,i-1))=upper(envname) then
  916. begin
  917. GetMem(p2,len-length(envname));
  918. Move(hp[i],p2^,len-length(envname));
  919. GetEnvPchar:=p2;
  920. break;
  921. end;
  922. { next string entry}
  923. hp:=hp+len+1;
  924. end;
  925. FreeEnvironmentStrings(p);
  926. {$define GETENVOK}
  927. {$endif}
  928. {$ifdef os2}
  929. P1 := StrPNew (EnvName);
  930. if Assigned (P1) then
  931. begin
  932. if DosCalls.DosScanEnv (P1, P2) = 0 then
  933. GetEnvPChar := P2
  934. else
  935. GetEnvPChar := nil;
  936. StrDispose (P1);
  937. end else GetEnvPChar := nil;
  938. {$define GETENVOK}
  939. {$endif}
  940. {$ifdef GETENVOK}
  941. {$undef GETENVOK}
  942. {$else}
  943. GetEnvPchar:=StrPNew({$ifdef delphi}DMisc{$else}Dos{$endif}.Getenv(envname));
  944. {$endif}
  945. end;
  946. procedure FreeEnvPChar(p:pchar);
  947. begin
  948. {$ifndef unix}
  949. {$ifndef os2}
  950. StrDispose(p);
  951. {$endif}
  952. {$endif}
  953. end;
  954. Procedure Shell(const command:string);
  955. { This is already defined in the linux.ppu for linux, need for the *
  956. expansion under linux }
  957. {$ifdef unix}
  958. begin
  959. {$ifdef ver1_0}Linux{$else}Unix{$endif}.Shell(command);
  960. end;
  961. {$else}
  962. var
  963. comspec : string;
  964. begin
  965. comspec:=getenv('COMSPEC');
  966. Exec(comspec,' /C '+command);
  967. end;
  968. {$endif}
  969. Function SetCompileMode(const s:string; changeInit: boolean):boolean;
  970. var
  971. b : boolean;
  972. begin
  973. b:=true;
  974. if s='DEFAULT' then
  975. aktmodeswitches:=initmodeswitches
  976. else
  977. if s='DELPHI' then
  978. aktmodeswitches:=delphimodeswitches
  979. else
  980. if s='TP' then
  981. aktmodeswitches:=tpmodeswitches
  982. else
  983. if s='FPC' then
  984. aktmodeswitches:=fpcmodeswitches
  985. else
  986. if s='OBJFPC' then
  987. aktmodeswitches:=objfpcmodeswitches
  988. else
  989. if s='GPC' then
  990. aktmodeswitches:=gpcmodeswitches
  991. else
  992. b:=false;
  993. if b and changeInit then
  994. initmodeswitches := aktmodeswitches;
  995. if b then
  996. begin
  997. { turn ansistrings on by default ? }
  998. if (m_delphi in aktmodeswitches) then
  999. begin
  1000. include(aktlocalswitches,cs_ansistrings);
  1001. if changeinit then
  1002. include(initlocalswitches,cs_ansistrings);
  1003. end
  1004. else
  1005. begin
  1006. exclude(aktlocalswitches,cs_ansistrings);
  1007. if changeinit then
  1008. exclude(initlocalswitches,cs_ansistrings);
  1009. end;
  1010. { enum packing }
  1011. if (m_tp7 in aktmodeswitches) then
  1012. aktpackenum:=1
  1013. else
  1014. aktpackenum:=4;
  1015. if changeinit then
  1016. initpackenum:=aktpackenum;
  1017. end;
  1018. SetCompileMode:=b;
  1019. end;
  1020. function SetAktProcCall(const s:string; changeInit:boolean):boolean;
  1021. const
  1022. DefProcCallName : array[TDefProcCall] of string[12] = (
  1023. 'CDECL',
  1024. 'CPPDECL',
  1025. 'FAR16',
  1026. 'FPCCALL',
  1027. 'INLINE',
  1028. 'PASCAL',
  1029. 'POPSTACK',
  1030. 'REGISTER',
  1031. 'SAFECALL',
  1032. 'STDCALL',
  1033. 'SYSTEM'
  1034. );
  1035. var
  1036. t : TDefProcCall;
  1037. begin
  1038. SetAktProcCall:=false;
  1039. for t:=low(TDefProcCall) to high(TDefProcCall) do
  1040. if DefProcCallName[t]=s then
  1041. begin
  1042. AktDefProcCall:=t;
  1043. SetAktProcCall:=true;
  1044. break;
  1045. end;
  1046. if changeinit then
  1047. InitDefProcCall:=AktDefProcCall;
  1048. end;
  1049. { '('D1:'00000000-'D2:'0000-'D3:'0000-'D4:'0000-000000000000)' }
  1050. function string2guid(const s: string; var GUID: TGUID): boolean;
  1051. function ishexstr(const hs: string): boolean;
  1052. var
  1053. i: integer;
  1054. begin
  1055. ishexstr:=false;
  1056. for i:=1 to Length(hs) do begin
  1057. if not (hs[i] in ['0'..'9','A'..'F','a'..'f']) then
  1058. exit;
  1059. end;
  1060. ishexstr:=true;
  1061. end;
  1062. function hexstr2longint(const hexs: string): longint;
  1063. var
  1064. i: integer;
  1065. rl: longint;
  1066. begin
  1067. rl:=0;
  1068. for i:=1 to length(hexs) do begin
  1069. rl:=rl shl 4;
  1070. case hexs[i] of
  1071. '0'..'9' : inc(rl,ord(hexs[i])-ord('0'));
  1072. 'A'..'F' : inc(rl,ord(hexs[i])-ord('A')+10);
  1073. 'a'..'f' : inc(rl,ord(hexs[i])-ord('a')+10);
  1074. end
  1075. end;
  1076. hexstr2longint:=rl;
  1077. end;
  1078. var
  1079. i: integer;
  1080. begin
  1081. if (Length(s)=38) and (s[1]='{') and (s[38]='}') and
  1082. (s[10]='-') and (s[15]='-') and (s[20]='-') and (s[25]='-') and
  1083. ishexstr(copy(s,2,8)) and ishexstr(copy(s,11,4)) and
  1084. ishexstr(copy(s,16,4)) and ishexstr(copy(s,21,4)) and
  1085. ishexstr(copy(s,26,12)) then begin
  1086. GUID.D1:=dword(hexstr2longint(copy(s,2,8)));
  1087. GUID.D2:=hexstr2longint(copy(s,11,4));
  1088. GUID.D3:=hexstr2longint(copy(s,16,4));
  1089. for i:=0 to 1 do
  1090. GUID.D4[i]:=hexstr2longint(copy(s,21+i*2,2));
  1091. for i:=2 to 7 do
  1092. GUID.D4[i]:=hexstr2longint(copy(s,22+i*2,2));
  1093. string2guid:=true;
  1094. end
  1095. else
  1096. string2guid:=false;
  1097. end;
  1098. function guid2string(const GUID: TGUID): string;
  1099. function long2hex(l, len: longint): string;
  1100. const
  1101. hextbl: array[0..15] of char = '0123456789ABCDEF';
  1102. var
  1103. rs: string;
  1104. i: integer;
  1105. begin
  1106. rs[0]:=chr(len);
  1107. for i:=len downto 1 do begin
  1108. rs[i]:=hextbl[l and $F];
  1109. l:=l shr 4;
  1110. end;
  1111. long2hex:=rs;
  1112. end;
  1113. begin
  1114. guid2string:=
  1115. '{'+long2hex(GUID.D1,8)+
  1116. '-'+long2hex(GUID.D2,4)+
  1117. '-'+long2hex(GUID.D3,4)+
  1118. '-'+long2hex(GUID.D4[0],2)+long2hex(GUID.D4[1],2)+
  1119. '-'+long2hex(GUID.D4[2],2)+long2hex(GUID.D4[3],2)+
  1120. long2hex(GUID.D4[4],2)+long2hex(GUID.D4[5],2)+
  1121. long2hex(GUID.D4[6],2)+long2hex(GUID.D4[7],2)+
  1122. '}';
  1123. end;
  1124. function UpdateAlignmentStr(s:string;var a:talignmentinfo):boolean;
  1125. var
  1126. tok : string;
  1127. vstr : string;
  1128. l : longint;
  1129. code : integer;
  1130. b : talignmentinfo;
  1131. begin
  1132. UpdateAlignmentStr:=true;
  1133. uppervar(s);
  1134. fillchar(b,sizeof(b),0);
  1135. repeat
  1136. tok:=GetToken(s,'=');
  1137. if tok='' then
  1138. break;
  1139. vstr:=GetToken(s,',');
  1140. val(vstr,l,code);
  1141. if tok='PROC' then
  1142. b.procalign:=l
  1143. else if tok='JUMP' then
  1144. b.jumpalign:=l
  1145. else if tok='LOOP' then
  1146. b.loopalign:=l
  1147. else if tok='CONSTMIN' then
  1148. b.constalignmin:=l
  1149. else if tok='CONSTMAX' then
  1150. b.constalignmax:=l
  1151. else if tok='VARMIN' then
  1152. b.varalignmin:=l
  1153. else if tok='VARMAX' then
  1154. b.varalignmax:=l
  1155. else if tok='LOCALMIN' then
  1156. b.localalignmin:=l
  1157. else if tok='LOCALMAX' then
  1158. b.localalignmax:=l
  1159. else if tok='RECORDMIN' then
  1160. b.recordalignmin:=l
  1161. else if tok='RECORDMAX' then
  1162. b.recordalignmax:=l
  1163. else if tok='PARAALIGN' then
  1164. b.paraalign:=l
  1165. else { Error }
  1166. UpdateAlignmentStr:=false;
  1167. until false;
  1168. UpdateAlignment(a,b);
  1169. end;
  1170. {****************************************************************************
  1171. Init
  1172. ****************************************************************************}
  1173. {$ifdef unix}
  1174. {$define need_path_search}
  1175. {$endif unix}
  1176. {$ifdef os2}
  1177. {$define need_path_search}
  1178. {$endif os2}
  1179. procedure get_exepath;
  1180. var
  1181. hs1 : namestr;
  1182. hs2 : extstr;
  1183. begin
  1184. {$ifdef delphi}
  1185. exepath:=dmisc.getenv('PPC_EXEC_PATH');
  1186. {$else delphi}
  1187. exepath:=dos.getenv('PPC_EXEC_PATH');
  1188. {$endif delphi}
  1189. if exepath='' then
  1190. fsplit(FixFileName(system.paramstr(0)),exepath,hs1,hs2);
  1191. {$ifdef need_path_search}
  1192. if exepath='' then
  1193. begin
  1194. if pos(source_info.exeext,hs1) <>
  1195. (length(hs1) - length(source_info.exeext)+1) then
  1196. hs1 := hs1 + source_info.exeext;
  1197. {$ifdef delphi}
  1198. findfile(hs1,dmisc.getenv('PATH'),exepath);
  1199. {$else delphi}
  1200. findfile(hs1,dos.getenv('PATH'),exepath);
  1201. {$endif delphi}
  1202. exepath:=SplitPath(exepath);
  1203. end;
  1204. {$endif need_path_search}
  1205. exepath:=FixPath(exepath,false);
  1206. end;
  1207. procedure DoneGlobals;
  1208. begin
  1209. initdefines.free;
  1210. if assigned(DLLImageBase) then
  1211. StringDispose(DLLImageBase);
  1212. RelocSection:=true;
  1213. RelocSectionSetExplicitly:=false;
  1214. UseDeffileForExport:=true;
  1215. librarysearchpath.Free;
  1216. unitsearchpath.Free;
  1217. objectsearchpath.Free;
  1218. includesearchpath.Free;
  1219. end;
  1220. procedure InitGlobals;
  1221. begin
  1222. get_exepath;
  1223. { reset globals }
  1224. do_build:=false;
  1225. do_release:=false;
  1226. do_make:=true;
  1227. compile_level:=0;
  1228. DLLsource:=false;
  1229. inlining_procedure:=false;
  1230. resolving_forward:=false;
  1231. in_args:=false;
  1232. make_ref:=false;
  1233. { Output }
  1234. OutputFile:='';
  1235. OutputExeDir:='';
  1236. OutputUnitDir:='';
  1237. { Utils directory }
  1238. utilsdirectory:='';
  1239. { Search Paths }
  1240. librarysearchpath:=TSearchPathList.Create;
  1241. unitsearchpath:=TSearchPathList.Create;
  1242. includesearchpath:=TSearchPathList.Create;
  1243. objectsearchpath:=TSearchPathList.Create;
  1244. { Def file }
  1245. usewindowapi:=false;
  1246. description:='Compiled by FPC '+version_string+' - '+target_cpu_string;
  1247. dllversion:='';
  1248. nwscreenname := '';
  1249. nwthreadname := '';
  1250. nwcopyright := '';
  1251. { Init values }
  1252. initmodeswitches:=fpcmodeswitches;
  1253. initlocalswitches:=[cs_check_io,cs_typed_const_writable];
  1254. initmoduleswitches:=[cs_extsyntax,cs_browser];
  1255. initglobalswitches:=[cs_check_unit_name,cs_link_static];
  1256. initoutputformat:=target_asm.id;
  1257. fillchar(initalignment,sizeof(talignmentinfo),0);
  1258. {$ifdef i386}
  1259. initoptprocessor:=Class386;
  1260. initspecificoptprocessor:=Class386;
  1261. initpackenum:=4;
  1262. {$IFDEF testvarsets}
  1263. initsetalloc:=0;
  1264. {$ENDIF}
  1265. initasmmode:=asmmode_i386_att;
  1266. {$else not i386}
  1267. {$ifdef m68k}
  1268. initoptprocessor:=MC68000;
  1269. include(initmoduleswitches,cs_fp_emulation);
  1270. initpackenum:=4;
  1271. {$IFDEF testvarsets}
  1272. initsetalloc:=0;
  1273. {$ENDIF}
  1274. initasmmode:=asmmode_m68k_mot;
  1275. {$endif m68k}
  1276. {$endif i386}
  1277. initinterfacetype:=it_interfacecom;
  1278. initdefproccall:=dpc_fpccall;
  1279. initdefines:=TStringList.Create;
  1280. { memory sizes, will be overriden by parameter or default for target
  1281. in options or init_parser }
  1282. stacksize:=0;
  1283. heapsize:=0;
  1284. maxheapsize:=0;
  1285. { compile state }
  1286. in_args:=false;
  1287. { must_be_valid:=true; obsolete PM }
  1288. not_unit_proc:=true;
  1289. apptype:=app_cui;
  1290. end;
  1291. {$ifdef EXTDEBUG}
  1292. begin
  1293. {$ifdef FPC}
  1294. EntryMemUsed:=system.HeapSize-MemAvail;
  1295. {$endif FPC}
  1296. {$endif}
  1297. end.
  1298. {
  1299. $Log$
  1300. Revision 1.48 2001-10-23 21:49:42 peter
  1301. * $calling directive and -Cc commandline patch added
  1302. from Pavel Ozerski
  1303. Revision 1.47 2001/10/21 12:33:05 peter
  1304. * array access for properties added
  1305. Revision 1.46 2001/10/20 20:30:20 peter
  1306. * read only typed const support, switch $J-
  1307. Revision 1.45 2001/10/16 15:10:34 jonas
  1308. * fixed goto/label/try bugs
  1309. Revision 1.44 2001/10/12 16:06:17 peter
  1310. * pathexists fix (merged)
  1311. Revision 1.43 2001/09/18 11:30:47 michael
  1312. * Fixes win32 linking problems with import libraries
  1313. * LINKLIB Libraries are now looked for using C file extensions
  1314. * get_exepath fix
  1315. Revision 1.42 2001/09/17 21:29:11 peter
  1316. * merged netbsd, fpu-overflow from fixes branch
  1317. Revision 1.41 2001/08/19 11:22:22 peter
  1318. * palmos support from v10 merged
  1319. Revision 1.40 2001/08/04 10:23:54 peter
  1320. * updates so it works with the ide
  1321. Revision 1.39 2001/07/01 20:16:15 peter
  1322. * alignmentinfo record added
  1323. * -Oa argument supports more alignment settings that can be specified
  1324. per type: PROC,LOOP,VARMIN,VARMAX,CONSTMIN,CONSTMAX,RECORDMIN
  1325. RECORDMAX,LOCALMIN,LOCALMAX. It is possible to set the mimimum
  1326. required alignment and the maximum usefull alignment. The final
  1327. alignment will be choosen per variable size dependent on these
  1328. settings
  1329. Revision 1.38 2001/06/18 20:36:24 peter
  1330. * -Ur switch (merged)
  1331. * masm fixes (merged)
  1332. * quoted filenames for go32v2 and win32
  1333. Revision 1.37 2001/06/03 21:57:35 peter
  1334. + hint directive parsing support
  1335. Revision 1.36 2001/06/03 20:21:08 peter
  1336. * Kylix fixes, mostly case names of units
  1337. Revision 1.35 2001/05/30 21:35:48 peter
  1338. * netware patches for copyright, screenname, threadname directives
  1339. Revision 1.34 2001/05/12 12:11:31 peter
  1340. * simplify_ppu is now the default, a recompile of the compiler now
  1341. only compiles pp.pas
  1342. Revision 1.33 2001/05/06 14:49:17 peter
  1343. * ppu object to class rewrite
  1344. * move ppu read and write stuff to fppu
  1345. Revision 1.32 2001/04/18 22:01:53 peter
  1346. * registration of targets and assemblers
  1347. Revision 1.31 2001/04/15 09:48:29 peter
  1348. * fixed crash in labelnode
  1349. * easier detection of goto and label in try blocks
  1350. Revision 1.30 2001/04/13 01:22:07 peter
  1351. * symtable change to classes
  1352. * range check generation and errors fixed, make cycle DEBUG=1 works
  1353. * memory leaks fixed
  1354. Revision 1.29 2001/04/04 21:30:42 florian
  1355. * applied several fixes to get the DD8 Delphi Unit compiled
  1356. e.g. "forward"-interfaces are working now
  1357. Revision 1.28 2001/02/20 21:41:16 peter
  1358. * new fixfilename, findfile for unix. Look first for lowercase, then
  1359. NormalCase and last for UPPERCASE names.
  1360. Revision 1.27 2001/02/09 23:05:45 peter
  1361. * default packenum=1 for tp7 mode
  1362. Revision 1.26 2001/02/05 20:47:00 peter
  1363. * support linux unit for ver1_0 compilers
  1364. Revision 1.25 2001/01/21 20:32:45 marco
  1365. * Renamefest. Compiler part. Not that hard.
  1366. Revision 1.24 2001/01/20 18:32:52 hajny
  1367. + APPTYPE support under OS/2, app_fs, GetEnvPChar for OS/2
  1368. Revision 1.23 2001/01/13 00:03:41 peter
  1369. * fixed findexe to also support already extension in name
  1370. Revision 1.22 2000/12/26 15:57:25 peter
  1371. * use system.paramstr()
  1372. Revision 1.21 2000/12/25 00:07:26 peter
  1373. + new tlinkedlist class (merge of old tstringqueue,tcontainer and
  1374. tlinkedlist objects)
  1375. Revision 1.20 2000/11/13 15:26:12 marco
  1376. * Renamefest
  1377. Revision 1.19 2000/11/12 22:20:37 peter
  1378. * create generic toutputsection for binary writers
  1379. Revision 1.18 2000/11/04 14:25:19 florian
  1380. + merged Attila's changes for interfaces, not tested yet
  1381. Revision 1.17 2000/10/31 22:02:46 peter
  1382. * symtable splitted, no real code changes
  1383. Revision 1.16 2000/10/04 14:51:08 pierre
  1384. * IsExe restored
  1385. Revision 1.15 2000/09/27 21:20:56 peter
  1386. * also set initlocalswitches in setcompilemode (merged)
  1387. Revision 1.14 2000/09/26 10:50:41 jonas
  1388. * initmodeswitches is changed is you change the compiler mode from the
  1389. command line (the -S<x> switches didn't work anymore for changing the
  1390. compiler mode) (merged from fixes branch)
  1391. Revision 1.13 2000/09/24 21:33:46 peter
  1392. * message updates merges
  1393. Revision 1.12 2000/09/24 21:19:50 peter
  1394. * delphi compile fixes
  1395. Revision 1.11 2000/09/24 15:12:40 peter
  1396. * fixed typo
  1397. Revision 1.10 2000/09/24 15:06:16 peter
  1398. * use defines.inc
  1399. Revision 1.9 2000/09/24 10:33:07 peter
  1400. * searching of exe in path also for OS/2
  1401. * fixed searching of exe in path.
  1402. Revision 1.8 2000/09/11 17:00:22 florian
  1403. + first implementation of Netware Module support, thanks to
  1404. Armin Diehl ([email protected]) for providing the patches
  1405. Revision 1.7 2000/08/27 16:11:51 peter
  1406. * moved some util functions from globals,cobjects to cutils
  1407. * splitted files into finput,fmodule
  1408. Revision 1.6 2000/08/12 19:14:58 peter
  1409. * ELF writer works now also with -g
  1410. * ELF writer is default again for linux
  1411. Revision 1.5 2000/08/12 15:30:44 peter
  1412. * IDE patch for stream reading (merged)
  1413. Revision 1.4 2000/08/02 19:49:59 peter
  1414. * first things for default parameters
  1415. Revision 1.3 2000/07/13 12:08:25 michael
  1416. + patched to 1.1.0 with former 1.09patch from peter
  1417. Revision 1.2 2000/07/13 11:32:41 michael
  1418. + removed logs
  1419. }