globals.pas 45 KB

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