globals.pas 59 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 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 fpcdefs.inc}
  20. { Use the internal linker by default }
  21. { define INTERNALLINKER}
  22. interface
  23. uses
  24. {$ifdef win32}
  25. windows,
  26. {$endif}
  27. {$ifdef hasunix}
  28. {$ifdef havelinuxrtl10}
  29. linux,
  30. {$else}
  31. Baseunix,unix,
  32. {$endif}
  33. {$endif}
  34. {$ifdef Delphi}
  35. SysUtils,
  36. dmisc,
  37. {$else}
  38. strings,
  39. dos,
  40. {$endif}
  41. cutils,cclasses,
  42. globtype,version,systems,cpuinfo;
  43. const
  44. {$ifdef Splitheap}
  45. testsplit : boolean = false;
  46. {$endif Splitheap}
  47. delphimodeswitches : tmodeswitches=
  48. [m_delphi,m_all,m_class,m_objpas,m_result,m_string_pchar,
  49. m_pointer_2_procedure,m_autoderef,m_tp_procvar,m_initfinal,m_default_ansistring,
  50. m_out,m_default_para,m_duplicate_names,m_hintdirective,m_add_pointer];
  51. fpcmodeswitches : tmodeswitches=
  52. [m_fpc,m_all,m_string_pchar,m_nested_comment,m_repeat_forward,
  53. m_cvar_support,m_initfinal,m_add_pointer,m_hintdirective];
  54. objfpcmodeswitches : tmodeswitches=
  55. [m_objfpc,m_fpc,m_all,m_class,m_objpas,m_result,m_string_pchar,m_nested_comment,
  56. m_repeat_forward,m_cvar_support,m_initfinal,m_add_pointer,m_out,m_default_para,m_hintdirective];
  57. tpmodeswitches : tmodeswitches=
  58. [m_tp7,m_all,m_tp_procvar,m_duplicate_names];
  59. gpcmodeswitches : tmodeswitches=
  60. [m_gpc,m_all];
  61. macmodeswitches : tmodeswitches=
  62. [m_mac,m_all,m_result,m_repeat_forward,m_cvar_support];
  63. { maximum number of locals in bytes before warning is emitted }
  64. maxlocalsize = high(smallint);
  65. { maximum number of paras in bytes before warning is emitted }
  66. maxparasize = high(word);
  67. { maximum nesting of routines }
  68. maxnesting = 32;
  69. treelogfilename = 'tree.log';
  70. { I don't know if this endian dependend }
  71. MathQNaN : array[0..7] of byte = (0,0,0,0,0,0,252,255);
  72. MathInf : array[0..7] of byte = (0,0,0,0,0,0,240,127);
  73. MathNegInf : array[0..7] of byte = (0,0,0,0,0,0,240,255);
  74. type
  75. TFPUException = (exInvalidOp, exDenormalized, exZeroDivide,
  76. exOverflow, exUnderflow, exPrecision);
  77. TFPUExceptionMask = set of TFPUException;
  78. pfileposinfo = ^tfileposinfo;
  79. tfileposinfo = record
  80. line : longint;
  81. column : word;
  82. fileindex : word;
  83. { moduleindex : word; }
  84. end;
  85. TSearchPathList = class(TStringList)
  86. procedure AddPath(s:string;addfirst:boolean);overload;
  87. procedure AddPath(SrcPath,s:string;addfirst:boolean);overload;
  88. procedure AddList(list:TSearchPathList;addfirst:boolean);
  89. function FindFile(const f : string;var foundfile:string):boolean;
  90. end;
  91. tcodepagestring = string[20];
  92. var
  93. { specified inputfile }
  94. inputdir : dirstr;
  95. inputfile : namestr;
  96. inputextension : extstr;
  97. { specified outputfile with -o parameter }
  98. outputfile : namestr;
  99. outputprefix : pstring;
  100. outputsuffix : pstring;
  101. outputextension : namestr;
  102. { specified with -FE or -FU }
  103. outputexedir : dirstr;
  104. outputunitdir : dirstr;
  105. { things specified with parameters }
  106. paralinkoptions,
  107. paradynamiclinker : string;
  108. paraprintnodetree : byte;
  109. parapreprocess : boolean;
  110. printnodefile : text;
  111. { typical cross compiling params}
  112. { directory where the utils can be found (options -FD) }
  113. utilsdirectory : dirstr;
  114. { targetname specific prefix used by these utils (options -XP<path>) }
  115. utilsprefix : dirstr;
  116. cshared : boolean; { pass --shared to ld to link C libs shared}
  117. Dontlinkstdlibpath: Boolean; { Don't add std paths to linkpath}
  118. rlinkpath : dirstr; { rpath-link linkdir override}
  119. { some flags for global compiler switches }
  120. do_build,
  121. do_release,
  122. do_make : boolean;
  123. { path for searching units, different paths can be seperated by ; }
  124. exepath : dirstr; { Path to ppc }
  125. librarysearchpath,
  126. unitsearchpath,
  127. objectsearchpath,
  128. includesearchpath : TSearchPathList;
  129. { linking }
  130. usewindowapi : boolean;
  131. description : string;
  132. DescriptionSetExplicity : boolean;
  133. dllversion : string;
  134. dllmajor,
  135. dllminor,
  136. dllrevision : word; { revision only for netware }
  137. UseDeffileForExports : boolean;
  138. UseDeffileForExportsSetExplicitly : boolean;
  139. RelocSection : boolean;
  140. RelocSectionSetExplicitly : boolean;
  141. LinkTypeSetExplicitly : boolean;
  142. akttokenpos, { position of the last token }
  143. aktfilepos : tfileposinfo; { current position }
  144. nwscreenname : string;
  145. nwthreadname : string;
  146. nwcopyright : string;
  147. codegenerror : boolean; { true if there is an error reported }
  148. block_type : tblock_type; { type of currently parsed block }
  149. parsing_para_level : integer; { parameter level, used to convert
  150. proc calls to proc loads in firstcalln }
  151. compile_level : word;
  152. make_ref : boolean;
  153. resolving_forward : boolean; { used to add forward reference as second ref }
  154. inlining_procedure : boolean; { are we inlining a procedure }
  155. exceptblockcounter : integer; { each except block gets a unique number check gotos }
  156. aktexceptblock : integer; { the exceptblock number of the current block (0 if none) }
  157. { commandline values }
  158. initdefines : tstringlist;
  159. initglobalswitches : tglobalswitches;
  160. initmoduleswitches : tmoduleswitches;
  161. initlocalswitches : tlocalswitches;
  162. initmodeswitches : tmodeswitches;
  163. {$IFDEF testvarsets}
  164. Initsetalloc, {0=fixed, 1 =var}
  165. {$ENDIF}
  166. initpackenum : shortint;
  167. {$ifdef ansistring_bits}
  168. initansistring_bits: Tstringbits;
  169. {$endif}
  170. initalignment : talignmentinfo;
  171. initoptprocessor,
  172. initspecificoptprocessor : tprocessors;
  173. initfputype : tfputype;
  174. initasmmode : tasmmode;
  175. initinterfacetype : tinterfacetypes;
  176. initoutputformat : tasm;
  177. initdefproccall : tproccalloption;
  178. initsourcecodepage : tcodepagestring;
  179. { current state values }
  180. aktglobalswitches : tglobalswitches;
  181. aktmoduleswitches : tmoduleswitches;
  182. aktlocalswitches : tlocalswitches;
  183. nextaktlocalswitches : tlocalswitches;
  184. localswitcheschanged : boolean;
  185. aktmodeswitches : tmodeswitches;
  186. {$IFDEF testvarsets}
  187. aktsetalloc,
  188. {$ENDIF}
  189. aktpackrecords,
  190. aktpackenum : longint;
  191. {$ifdef ansistring_bits}
  192. aktansistring_bits : Tstringbits;
  193. {$endif}
  194. aktmaxfpuregisters : longint;
  195. aktalignment : talignmentinfo;
  196. aktoptprocessor,
  197. aktspecificoptprocessor : tprocessors;
  198. aktfputype : tfputype;
  199. aktasmmode : tasmmode;
  200. aktinterfacetype : tinterfacetypes;
  201. aktoutputformat : tasm;
  202. aktdefproccall : tproccalloption;
  203. aktsourcecodepage : tcodepagestring;
  204. { Memory sizes }
  205. heapsize,
  206. stacksize : longint;
  207. {$Ifdef EXTDEBUG}
  208. { parameter switches }
  209. debugstop : boolean;
  210. {$EndIf EXTDEBUG}
  211. { windows / OS/2 application type }
  212. apptype : tapptype;
  213. const
  214. DLLsource : boolean = false;
  215. DLLImageBase : pstring = nil;
  216. { used to set all registers used for each global function
  217. this should dramatically decrease the number of
  218. recompilations needed PM }
  219. simplify_ppu : boolean = true;
  220. { should we allow non static members ? }
  221. allow_only_static : boolean = false;
  222. Inside_asm_statement : boolean = false;
  223. global_unit_count : word = 0;
  224. { for error info in pp.pas }
  225. parser_current_file : string = '';
  226. {$ifdef m68k}
  227. { PalmOS resources }
  228. palmos_applicationname : string = 'FPC Application';
  229. palmos_applicationid : string[4] = 'FPCA';
  230. {$endif m68k}
  231. procedure abstract;
  232. function bstoslash(const s : string) : string;
  233. function getdatestr:string;
  234. function gettimestr:string;
  235. function filetimestring( t : longint) : string;
  236. procedure DefaultReplacements(var s:string);
  237. function GetCurrentDir:string;
  238. function path_absolute(const s : string) : boolean;
  239. Function PathExists ( F : String) : Boolean;
  240. Function FileExists ( Const F : String) : Boolean;
  241. function FileExistsNonCase(const path,fn:string;var foundfile:string):boolean;
  242. Function RemoveFile(const f:string):boolean;
  243. Function RemoveDir(d:string):boolean;
  244. Function GetFileTime ( Var F : File) : Longint;
  245. Function GetNamedFileTime ( Const F : String) : Longint;
  246. Function SplitPath(const s:string):string;
  247. Function SplitFileName(const s:string):string;
  248. Function SplitName(const s:string):string;
  249. Function SplitExtension(Const HStr:String):String;
  250. Function AddExtension(Const HStr,ext:String):String;
  251. Function ForceExtension(Const HStr,ext:String):String;
  252. Function FixPath(s:string;allowdot:boolean):string;
  253. function FixFileName(const s:string):string;
  254. function TargetFixPath(s:string;allowdot:boolean):string;
  255. function TargetFixFileName(const s:string):string;
  256. procedure SplitBinCmd(const s:string;var bstr,cstr:string);
  257. function FindFile(const f : string;path : string;var foundfile:string):boolean;
  258. function FindFilePchar(const f : string;path : pchar;var foundfile:string):boolean;
  259. function FindExe(const bin:string;var foundfile:string):boolean;
  260. function GetShortName(const n:string):string;
  261. function Shell(const command:string): longint;
  262. function GetEnvPChar(const envname:string):pchar;
  263. procedure FreeEnvPChar(p:pchar);
  264. procedure SetFPUExceptionMask(const Mask: TFPUExceptionMask);
  265. function is_number_float(d : double) : boolean;
  266. Function SetCompileMode(const s:string; changeInit: boolean):boolean;
  267. function SetAktProcCall(const s:string; changeInit: boolean):boolean;
  268. function SetProcessor(const s:string; changeInit: boolean):boolean;
  269. function SetFpuType(const s:string; changeInit: boolean):boolean;
  270. procedure InitGlobals;
  271. procedure DoneGlobals;
  272. function string2guid(const s: string; var GUID: TGUID): boolean;
  273. function guid2string(const GUID: TGUID): string;
  274. function UpdateAlignmentStr(s:string;var a:talignmentinfo):boolean;
  275. {# Routine to get the required alignment for size of data, which will
  276. be placed in bss segment, according to the current alignment requirements }
  277. function var_align(siz: longint): longint;
  278. {# Routine to get the required alignment for size of data, which will
  279. be placed in data/const segment, according to the current alignment requirements }
  280. function const_align(siz: longint): longint;
  281. implementation
  282. uses
  283. {$ifdef macos}
  284. macutils,
  285. {$endif}
  286. comphook;
  287. procedure abstract;
  288. begin
  289. do_internalerror(255);
  290. end;
  291. procedure WarnNonExistingPath(const path : string);
  292. begin
  293. if assigned({$ifndef FPCPROCVAR}@{$endif}do_comment) then
  294. do_comment(V_Hint,'Path "'+path+'" not found');
  295. end;
  296. function bstoslash(const s : string) : string;
  297. {
  298. return string s with all \ changed into /
  299. }
  300. var
  301. i : longint;
  302. begin
  303. for i:=1to length(s) do
  304. if s[i]='\' then
  305. bstoslash[i]:='/'
  306. else
  307. bstoslash[i]:=s[i];
  308. bstoslash[0]:=s[0];
  309. end;
  310. {****************************************************************************
  311. Time Handling
  312. ****************************************************************************}
  313. Function L0(l:longint):string;
  314. {
  315. return the string of value l, if l<10 then insert a zero, so
  316. the string is always at least 2 chars '01','02',etc
  317. }
  318. var
  319. s : string;
  320. begin
  321. Str(l,s);
  322. if l<10 then
  323. s:='0'+s;
  324. L0:=s;
  325. end;
  326. function gettimestr:string;
  327. {
  328. get the current time in a string HH:MM:SS
  329. }
  330. var
  331. hour,min,sec,hsec : word;
  332. begin
  333. {$ifdef delphi}
  334. dmisc.gettime(hour,min,sec,hsec);
  335. {$else delphi}
  336. dos.gettime(hour,min,sec,hsec);
  337. {$endif delphi}
  338. gettimestr:=L0(Hour)+':'+L0(min)+':'+L0(sec);
  339. end;
  340. function getdatestr:string;
  341. {
  342. get the current date in a string YY/MM/DD
  343. }
  344. var
  345. Year,Month,Day,Wday : Word;
  346. begin
  347. {$ifdef delphi}
  348. dmisc.getdate(year,month,day,wday);
  349. {$else}
  350. dos.getdate(year,month,day,wday);
  351. {$endif}
  352. getdatestr:=L0(Year)+'/'+L0(Month)+'/'+L0(Day);
  353. end;
  354. function filetimestring( t : longint) : string;
  355. {
  356. convert dos datetime t to a string YY/MM/DD HH:MM:SS
  357. }
  358. var
  359. DT : DateTime;
  360. begin
  361. if t=-1 then
  362. begin
  363. FileTimeString:='Not Found';
  364. exit;
  365. end;
  366. unpacktime(t,DT);
  367. filetimestring:=L0(dt.Year)+'/'+L0(dt.Month)+'/'+L0(dt.Day)+' '+L0(dt.Hour)+':'+L0(dt.min)+':'+L0(dt.sec);
  368. end;
  369. {****************************************************************************
  370. Default Macro Handling
  371. ****************************************************************************}
  372. procedure DefaultReplacements(var s:string);
  373. begin
  374. { Replace some macros }
  375. Replace(s,'$FPCVER',version_string);
  376. Replace(s,'$VERSION',version_string);
  377. Replace(s,'$FULLVERSION',full_version_string);
  378. Replace(s,'$FPCDATE',date_string);
  379. Replace(s,'$FPCTARGET',target_cpu_string);
  380. Replace(s,'$FPCCPU',target_cpu_string);
  381. Replace(s,'$TARGET',target_path);
  382. Replace(s,'$FPCOS',target_path);
  383. end;
  384. {****************************************************************************
  385. File Handling
  386. ****************************************************************************}
  387. var
  388. CachedCurrentDir : string;
  389. function GetCurrentDir:string;
  390. begin
  391. if CachedCurrentDir='' then
  392. begin
  393. GetDir(0,CachedCurrentDir);
  394. CachedCurrentDir:=FixPath(CachedCurrentDir,false);
  395. end;
  396. result:=CachedCurrentDir;
  397. end;
  398. function path_absolute(const s : string) : boolean;
  399. {
  400. is path s an absolute path?
  401. }
  402. begin
  403. path_absolute:=false;
  404. {$ifdef unix}
  405. if (length(s)>0) and (s[1]='/') then
  406. path_absolute:=true;
  407. {$else unix}
  408. {$ifdef amiga}
  409. if ((length(s)>0) and ((s[1]='\') or (s[1]='/'))) or (Pos(':',s) = length(s)) then
  410. path_absolute:=true;
  411. {$else}
  412. {$ifdef macos}
  413. if IsMacFullPath(s) then
  414. path_absolute:=true;
  415. {$else}
  416. if ((length(s)>0) and ((s[1]='\') or (s[1]='/'))) or
  417. ((length(s)>2) and (s[2]=':') and ((s[3]='\') or (s[3]='/'))) then
  418. path_absolute:=true;
  419. {$endif macos}
  420. {$endif amiga}
  421. {$endif unix}
  422. end;
  423. {$ifndef FPC}
  424. Procedure FindClose(var Info : SearchRec);
  425. Begin
  426. End;
  427. {$endif not FPC}
  428. Function FileExists ( Const F : String) : Boolean;
  429. Var
  430. res : boolean;
  431. {$ifndef delphi}
  432. Info : SearchRec;
  433. {$endif}
  434. begin
  435. {$ifdef delphi}
  436. res:=sysutils.FileExists(f);
  437. {$else}
  438. findfirst(F,readonly+archive+hidden,info);
  439. res:=(doserror=0);
  440. findclose(Info);
  441. {$endif delphi}
  442. if assigned({$ifndef FPCPROVCAR}@{$endif}do_comment) then
  443. begin
  444. if res then
  445. do_comment(V_Tried,'Searching file '+F+'... found')
  446. else
  447. do_comment(V_Tried,'Searching file '+F+'... not found');
  448. end;
  449. FileExists:=res;
  450. end;
  451. function FileExistsNonCase(const path,fn:string;var foundfile:string):boolean;
  452. var
  453. fn2 : string;
  454. begin
  455. result:=false;
  456. if source_info.files_case_relevent then
  457. begin
  458. {
  459. Search order for case sensitive systems:
  460. 1. NormalCase
  461. 2. lowercase
  462. 3. UPPERCASE
  463. }
  464. FoundFile:=path+fn;
  465. If FileExists(FoundFile) then
  466. begin
  467. result:=true;
  468. exit;
  469. end;
  470. fn2:=Lower(fn);
  471. if fn2<>fn then
  472. begin
  473. FoundFile:=path+fn2;
  474. If FileExists(FoundFile) then
  475. begin
  476. result:=true;
  477. exit;
  478. end;
  479. end;
  480. fn2:=Upper(fn);
  481. if fn2<>fn then
  482. begin
  483. FoundFile:=path+fn2;
  484. If FileExists(FoundFile) then
  485. begin
  486. result:=true;
  487. exit;
  488. end;
  489. end;
  490. end
  491. else
  492. begin
  493. { None case sensitive only lowercase }
  494. FoundFile:=path+Lower(fn);
  495. If FileExists(FoundFile) then
  496. begin
  497. result:=true;
  498. exit;
  499. end;
  500. end;
  501. { Set foundfile to something usefull }
  502. FoundFile:=fn;
  503. end;
  504. Function PathExists ( F : String) : Boolean;
  505. Var
  506. FF : file;
  507. A: word;
  508. I: longint;
  509. begin
  510. if F = '' then
  511. begin
  512. PathExists := true;
  513. exit;
  514. end;
  515. F := FExpand (F);
  516. I := Pos (DriveSeparator, F);
  517. if (F [Length (F)] = DirectorySeparator)
  518. and (((I = 0) and (Length (F) > 1)) or (I <> Length (F) - 1))
  519. then
  520. Delete (F, Length (F), 1);
  521. Assign (FF, FExpand (F));
  522. GetFAttr (FF, A);
  523. PathExists := (DosError = 0) and (A and Directory = Directory);
  524. end;
  525. Function RemoveFile(const f:string):boolean;
  526. var
  527. g : file;
  528. begin
  529. assign(g,f);
  530. {$I-}
  531. erase(g);
  532. {$I+}
  533. RemoveFile:=(ioresult=0);
  534. end;
  535. Function RemoveDir(d:string):boolean;
  536. begin
  537. if d[length(d)]=source_info.DirSep then
  538. Delete(d,length(d),1);
  539. {$I-}
  540. rmdir(d);
  541. {$I+}
  542. RemoveDir:=(ioresult=0);
  543. end;
  544. Function SplitPath(const s:string):string;
  545. var
  546. i : longint;
  547. begin
  548. i:=Length(s);
  549. while (i>0) and not(s[i] in ['/','\']) do
  550. dec(i);
  551. SplitPath:=Copy(s,1,i);
  552. end;
  553. Function SplitFileName(const s:string):string;
  554. var
  555. p : dirstr;
  556. n : namestr;
  557. e : extstr;
  558. begin
  559. FSplit(s,p,n,e);
  560. SplitFileName:=n+e;
  561. end;
  562. Function SplitName(const s:string):string;
  563. var
  564. i,j : longint;
  565. begin
  566. i:=Length(s);
  567. j:=Length(s);
  568. while (i>0) and not(s[i] in ['/','\']) do
  569. dec(i);
  570. while (j>0) and (s[j]<>'.') do
  571. dec(j);
  572. if j<=i then
  573. j:=255;
  574. SplitName:=Copy(s,i+1,j-(i+1));
  575. end;
  576. Function SplitExtension(Const HStr:String):String;
  577. var
  578. j : longint;
  579. begin
  580. j:=length(Hstr);
  581. while (j>0) and (Hstr[j]<>'.') do
  582. begin
  583. if hstr[j]=source_info.DirSep then
  584. j:=0
  585. else
  586. dec(j);
  587. end;
  588. if j=0 then
  589. j:=254;
  590. SplitExtension:=Copy(Hstr,j,255);
  591. end;
  592. Function AddExtension(Const HStr,ext:String):String;
  593. begin
  594. if (Ext<>'') and (SplitExtension(HStr)='') then
  595. AddExtension:=Hstr+Ext
  596. else
  597. AddExtension:=Hstr;
  598. end;
  599. Function ForceExtension(Const HStr,ext:String):String;
  600. var
  601. j : longint;
  602. begin
  603. j:=length(Hstr);
  604. while (j>0) and (Hstr[j]<>'.') do
  605. dec(j);
  606. if j=0 then
  607. j:=255;
  608. ForceExtension:=Copy(Hstr,1,j-1)+Ext;
  609. end;
  610. Function FixPath(s:string;allowdot:boolean):string;
  611. var
  612. i : longint;
  613. begin
  614. { Fix separator }
  615. for i:=1 to length(s) do
  616. if s[i] in ['/','\'] then
  617. s[i]:=source_info.DirSep;
  618. { Fix ending / }
  619. if (length(s)>0) and (s[length(s)]<>source_info.DirSep) and
  620. (s[length(s)]<>':') then
  621. s:=s+source_info.DirSep;
  622. { Remove ./ }
  623. if (not allowdot) and (s='.'+source_info.DirSep) then
  624. s:='';
  625. { return }
  626. if source_info.files_case_relevent then
  627. FixPath:=s
  628. else
  629. FixPath:=Lower(s);
  630. end;
  631. {Actually the version in macutils.pp could be used,
  632. but that would not work for crosscompiling, so this is a slightly modified
  633. version of it.}
  634. function TranslatePathToMac (const path: string; mpw: Boolean): string;
  635. function GetVolumeIdentifier: string;
  636. begin
  637. GetVolumeIdentifier := '{Boot}'
  638. (*
  639. if mpw then
  640. GetVolumeIdentifier := '{Boot}'
  641. else
  642. GetVolumeIdentifier := macosBootVolumeName;
  643. *)
  644. end;
  645. var
  646. slashPos, oldpos, newpos, oldlen, maxpos: Longint;
  647. begin
  648. oldpos := 1;
  649. slashPos := Pos('/', path);
  650. if (slashPos <> 0) then {its a unix path}
  651. begin
  652. if slashPos = 1 then
  653. begin {its a full path}
  654. oldpos := 2;
  655. TranslatePathToMac := GetVolumeIdentifier;
  656. end
  657. else {its a partial path}
  658. TranslatePathToMac := ':';
  659. end
  660. else
  661. begin
  662. slashPos := Pos('\', path);
  663. if (slashPos <> 0) then {its a dos path}
  664. begin
  665. if slashPos = 1 then
  666. begin {its a full path, without drive letter}
  667. oldpos := 2;
  668. TranslatePathToMac := GetVolumeIdentifier;
  669. end
  670. else if (Length(path) >= 2) and (path[2] = ':') then {its a full path, with drive letter}
  671. begin
  672. oldpos := 4;
  673. TranslatePathToMac := GetVolumeIdentifier;
  674. end
  675. else {its a partial path}
  676. TranslatePathToMac := ':';
  677. end;
  678. end;
  679. if (slashPos <> 0) then {its a unix or dos path}
  680. begin
  681. {Translate "/../" to "::" , "/./" to ":" and "/" to ":" }
  682. newpos := Length(TranslatePathToMac);
  683. oldlen := Length(path);
  684. SetLength(TranslatePathToMac, newpos + oldlen); {It will be no longer than what is already}
  685. {prepended plus length of path.}
  686. maxpos := Length(TranslatePathToMac); {Get real maxpos, can be short if String is ShortString}
  687. {There is never a slash in the beginning, because either it was an absolute path, and then the}
  688. {drive and slash was removed, or it was a relative path without a preceding slash.}
  689. while oldpos <= oldlen do
  690. begin
  691. {Check if special dirs, ./ or ../ }
  692. if path[oldPos] = '.' then
  693. if (oldpos + 1 <= oldlen) and (path[oldPos + 1] = '.') then
  694. begin
  695. if (oldpos + 2 > oldlen) or (path[oldPos + 2] in ['/', '\']) then
  696. begin
  697. {It is "../" or ".." translates to ":" }
  698. if newPos = maxPos then
  699. begin {Shouldn't actually happen, but..}
  700. Exit('');
  701. end;
  702. newPos := newPos + 1;
  703. TranslatePathToMac[newPos] := ':';
  704. oldPos := oldPos + 3;
  705. continue; {Start over again}
  706. end;
  707. end
  708. else if (oldpos + 1 > oldlen) or (path[oldPos + 1] in ['/', '\']) then
  709. begin
  710. {It is "./" or "." ignor it }
  711. oldPos := oldPos + 2;
  712. continue; {Start over again}
  713. end;
  714. {Collect file or dir name}
  715. while (oldpos <= oldlen) and not (path[oldPos] in ['/', '\']) do
  716. begin
  717. if newPos = maxPos then
  718. begin {Shouldn't actually happen, but..}
  719. Exit('');
  720. end;
  721. newPos := newPos + 1;
  722. TranslatePathToMac[newPos] := path[oldPos];
  723. oldPos := oldPos + 1;
  724. end;
  725. {When we come here there is either a slash or we are at the end.}
  726. if (oldpos <= oldlen) then
  727. begin
  728. if newPos = maxPos then
  729. begin {Shouldn't actually happen, but..}
  730. Exit('');
  731. end;
  732. newPos := newPos + 1;
  733. TranslatePathToMac[newPos] := ':';
  734. oldPos := oldPos + 1;
  735. end;
  736. end;
  737. SetLength(TranslatePathToMac, newpos);
  738. end
  739. else if (path = '.') then
  740. TranslatePathToMac := ':'
  741. else if (path = '..') then
  742. TranslatePathToMac := '::'
  743. else
  744. TranslatePathToMac := path; {its a mac path}
  745. end;
  746. function FixFileName(const s:string):string;
  747. var
  748. i : longint;
  749. begin
  750. if source_info.system = system_powerpc_MACOS then
  751. FixFileName:= TranslatePathToMac(s, true)
  752. else if source_info.files_case_relevent then
  753. begin
  754. for i:=1 to length(s) do
  755. begin
  756. case s[i] of
  757. '/','\' :
  758. FixFileName[i]:=source_info.dirsep;
  759. else
  760. FixFileName[i]:=s[i];
  761. end;
  762. end;
  763. FixFileName[0]:=s[0];
  764. end
  765. else
  766. begin
  767. for i:=1 to length(s) do
  768. begin
  769. case s[i] of
  770. '/','\' :
  771. FixFileName[i]:=source_info.dirsep;
  772. 'A'..'Z' :
  773. FixFileName[i]:=char(byte(s[i])+32);
  774. else
  775. FixFileName[i]:=s[i];
  776. end;
  777. end;
  778. FixFileName[0]:=s[0];
  779. end;
  780. end;
  781. Function TargetFixPath(s:string;allowdot:boolean):string;
  782. var
  783. i : longint;
  784. begin
  785. { Fix separator }
  786. for i:=1 to length(s) do
  787. if s[i] in ['/','\'] then
  788. s[i]:=target_info.DirSep;
  789. { Fix ending / }
  790. if (length(s)>0) and (s[length(s)]<>target_info.DirSep) and
  791. (s[length(s)]<>':') then
  792. s:=s+target_info.DirSep;
  793. { Remove ./ }
  794. if (not allowdot) and (s='.'+target_info.DirSep) then
  795. s:='';
  796. { return }
  797. if target_info.files_case_relevent then
  798. TargetFixPath:=s
  799. else
  800. TargetFixPath:=Lower(s);
  801. end;
  802. function TargetFixFileName(const s:string):string;
  803. var
  804. i : longint;
  805. begin
  806. if target_info.system = system_powerpc_MACOS then
  807. TargetFixFileName:= TranslatePathToMac(s, true)
  808. else if target_info.files_case_relevent then
  809. begin
  810. for i:=1 to length(s) do
  811. begin
  812. case s[i] of
  813. '/','\' :
  814. TargetFixFileName[i]:=target_info.dirsep;
  815. else
  816. TargetFixFileName[i]:=s[i];
  817. end;
  818. end;
  819. TargetFixFileName[0]:=s[0];
  820. end
  821. else
  822. begin
  823. for i:=1 to length(s) do
  824. begin
  825. case s[i] of
  826. '/','\' :
  827. TargetFixFileName[i]:=target_info.dirsep;
  828. 'A'..'Z' :
  829. TargetFixFileName[i]:=char(byte(s[i])+32);
  830. else
  831. TargetFixFileName[i]:=s[i];
  832. end;
  833. end;
  834. TargetFixFileName[0]:=s[0];
  835. end;
  836. end;
  837. procedure SplitBinCmd(const s:string;var bstr,cstr:string);
  838. var
  839. i : longint;
  840. begin
  841. i:=pos(' ',s);
  842. if i>0 then
  843. begin
  844. bstr:=Copy(s,1,i-1);
  845. cstr:=Copy(s,i+1,length(s)-i);
  846. end
  847. else
  848. begin
  849. bstr:=s;
  850. cstr:='';
  851. end;
  852. end;
  853. procedure TSearchPathList.AddPath(s:string;addfirst:boolean);
  854. begin
  855. AddPath('',s,AddFirst);
  856. end;
  857. procedure TSearchPathList.AddPath(SrcPath,s:string;addfirst:boolean);
  858. var
  859. j : longint;
  860. hs,hsd,
  861. CurrentDir,
  862. currPath : string;
  863. subdirfound : boolean;
  864. dir : searchrec;
  865. hp : TStringListItem;
  866. procedure AddCurrPath;
  867. begin
  868. if addfirst then
  869. begin
  870. Remove(currPath);
  871. Insert(currPath);
  872. end
  873. else
  874. begin
  875. { Check if already in path, then we don't add it }
  876. hp:=Find(currPath);
  877. if not assigned(hp) then
  878. Concat(currPath);
  879. end;
  880. end;
  881. begin
  882. if s='' then
  883. exit;
  884. { Support default macro's }
  885. DefaultReplacements(s);
  886. { get current dir }
  887. CurrentDir:=GetCurrentDir;
  888. repeat
  889. { get currpath }
  890. if addfirst then
  891. begin
  892. j:=length(s);
  893. while (j>0) and (s[j]<>';') do
  894. dec(j);
  895. currPath:= TrimSpace(Copy(s,j+1,length(s)-j));
  896. DePascalQuote(currPath);
  897. currPath:=FixPath(currPath,false);
  898. if j=0 then
  899. s:=''
  900. else
  901. System.Delete(s,j,length(s)-j+1);
  902. end
  903. else
  904. begin
  905. j:=Pos(';',s);
  906. if j=0 then
  907. j:=255;
  908. currPath:= TrimSpace(Copy(s,1,j-1));
  909. DePascalQuote(currPath);
  910. currPath:=SrcPath+FixPath(currPath,false);
  911. System.Delete(s,1,j);
  912. end;
  913. { fix pathname }
  914. if currPath='' then
  915. currPath:='.'+source_info.DirSep
  916. else
  917. begin
  918. currPath:=FixPath(FExpand(currPath),false);
  919. if (CurrentDir<>'') and (Copy(currPath,1,length(CurrentDir))=CurrentDir) then
  920. begin
  921. {$ifdef AMIGA}
  922. currPath:=CurrentDir+Copy(currPath,length(CurrentDir)+1,255);
  923. {$else}
  924. currPath:='.'+source_info.DirSep+Copy(currPath,length(CurrentDir)+1,255);
  925. {$endif}
  926. end;
  927. end;
  928. { wildcard adding ? }
  929. if pos('*',currpath)>0 then
  930. begin
  931. if currpath[length(currpath)]=source_info.dirsep then
  932. hs:=Copy(currpath,1,length(currPath)-1)
  933. else
  934. hs:=currpath;
  935. hsd:=SplitPath(hs);
  936. findfirst(hs,directory,dir);
  937. subdirfound:=false;
  938. while doserror=0 do
  939. begin
  940. if (dir.name<>'.') and
  941. (dir.name<>'..') and
  942. ((dir.attr and directory)<>0) then
  943. begin
  944. subdirfound:=true;
  945. currpath:=hsd+dir.name+source_info.dirsep;
  946. hp:=Find(currPath);
  947. if not assigned(hp) then
  948. AddCurrPath;
  949. end;
  950. findnext(dir);
  951. if not subdirfound then
  952. WarnNonExistingPath(currpath);
  953. end;
  954. FindClose(dir);
  955. end
  956. else
  957. begin
  958. if PathExists(currpath) then
  959. AddCurrPath
  960. else
  961. WarnNonExistingPath(currpath);
  962. end;
  963. until (s='');
  964. end;
  965. procedure TSearchPathList.AddList(list:TSearchPathList;addfirst:boolean);
  966. var
  967. s : string;
  968. hl : TSearchPathList;
  969. hp,hp2 : TStringListItem;
  970. begin
  971. if list.empty then
  972. exit;
  973. { create temp and reverse the list }
  974. if addfirst then
  975. begin
  976. hl:=TSearchPathList.Create;
  977. hp:=TStringListItem(list.first);
  978. while assigned(hp) do
  979. begin
  980. hl.insert(hp.Str);
  981. hp:=TStringListItem(hp.next);
  982. end;
  983. while not hl.empty do
  984. begin
  985. s:=hl.GetFirst;
  986. Remove(s);
  987. Insert(s);
  988. end;
  989. hl.Free;
  990. end
  991. else
  992. begin
  993. hp:=TStringListItem(list.first);
  994. while assigned(hp) do
  995. begin
  996. hp2:=Find(hp.Str);
  997. { Check if already in path, then we don't add it }
  998. if not assigned(hp2) then
  999. Concat(hp.Str);
  1000. hp:=TStringListItem(hp.next);
  1001. end;
  1002. end;
  1003. end;
  1004. function TSearchPathList.FindFile(const f : string;var foundfile:string):boolean;
  1005. Var
  1006. p : TStringListItem;
  1007. begin
  1008. FindFile:=false;
  1009. p:=TStringListItem(first);
  1010. while assigned(p) do
  1011. begin
  1012. result:=FileExistsNonCase(p.Str,f,FoundFile);
  1013. if result then
  1014. exit;
  1015. p:=TStringListItem(p.next);
  1016. end;
  1017. { Return original filename if not found }
  1018. FoundFile:=f;
  1019. end;
  1020. Function GetFileTime ( Var F : File) : Longint;
  1021. Var
  1022. {$ifdef hasunix}
  1023. info: Stat;
  1024. {$endif}
  1025. L : longint;
  1026. begin
  1027. {$ifdef hasunix}
  1028. {$IFDEF havelinuxrtl10}
  1029. FStat (F,Info);
  1030. L:=Info.Mtime;
  1031. {$ELSE}
  1032. FPFStat (F,Info);
  1033. L:=Info.st_Mtime;
  1034. {$ENDIF}
  1035. {$else}
  1036. GetFTime(f,l);
  1037. {$endif}
  1038. GetFileTime:=L;
  1039. end;
  1040. Function GetNamedFileTime (Const F : String) : Longint;
  1041. begin
  1042. GetNamedFileTime:=do_getnamedfiletime(F);
  1043. end;
  1044. function FindFile(const f : string;path : string;var foundfile:string):boolean;
  1045. Var
  1046. singlepathstring : string;
  1047. i : longint;
  1048. begin
  1049. {$ifdef Unix}
  1050. for i:=1 to length(path) do
  1051. if path[i]=':' then
  1052. path[i]:=';';
  1053. {$endif Unix}
  1054. FindFile:=false;
  1055. repeat
  1056. i:=pos(';',path);
  1057. if i=0 then
  1058. i:=256;
  1059. singlepathstring:=FixPath(copy(path,1,i-1),false);
  1060. delete(path,1,i);
  1061. result:=FileExistsNonCase(singlepathstring,f,FoundFile);
  1062. if result then
  1063. exit;
  1064. until path='';
  1065. FoundFile:=f;
  1066. end;
  1067. function FindFilePchar(const f : string;path : pchar;var foundfile:string):boolean;
  1068. Var
  1069. singlepathstring : string;
  1070. startpc,pc : pchar;
  1071. sepch : char;
  1072. begin
  1073. {$ifdef Unix}
  1074. sepch:=':';
  1075. {$else}
  1076. {$ifdef macos}
  1077. sepch:=',';
  1078. {$else}
  1079. sepch:=';';
  1080. {$endif macos}
  1081. {$endif Unix}
  1082. FindFilePchar:=false;
  1083. pc:=path;
  1084. repeat
  1085. startpc:=pc;
  1086. while (pc^<>sepch) and (pc^<>';') and (pc^<>#0) do
  1087. inc(pc);
  1088. move(startpc^,singlepathstring[1],pc-startpc);
  1089. singlepathstring[0]:=char(longint(pc-startpc));
  1090. singlepathstring:=FixPath(singlepathstring,false);
  1091. result:=FileExistsNonCase(singlepathstring,f,FoundFile);
  1092. if result then
  1093. exit;
  1094. if (pc^=#0) then
  1095. break;
  1096. inc(pc);
  1097. until false;
  1098. foundfile:=f;
  1099. end;
  1100. function FindExe(const bin:string;var foundfile:string):boolean;
  1101. var
  1102. p : pchar;
  1103. found : boolean;
  1104. begin
  1105. found:=FindFile(FixFileName(AddExtension(bin,source_info.exeext)),'.;'+exepath,foundfile);
  1106. if not found then
  1107. begin
  1108. {$ifdef macos}
  1109. p:=GetEnvPchar('Commands');
  1110. {$else}
  1111. p:=GetEnvPchar('PATH');
  1112. {$endif}
  1113. found:=FindFilePChar(FixFileName(AddExtension(bin,source_info.exeext)),p,foundfile);
  1114. FreeEnvPChar(p);
  1115. end;
  1116. FindExe:=found;
  1117. end;
  1118. function GetShortName(const n:string):string;
  1119. {$ifdef win32}
  1120. var
  1121. hs,hs2 : string;
  1122. i : longint;
  1123. {$endif}
  1124. {$ifdef go32v2}
  1125. var
  1126. hs : string;
  1127. {$endif}
  1128. {$ifdef watcom}
  1129. var
  1130. hs : string;
  1131. {$endif}
  1132. begin
  1133. GetShortName:=n;
  1134. {$ifdef win32}
  1135. hs:=n+#0;
  1136. i:=Windows.GetShortPathName(@hs[1],@hs2[1],high(hs2));
  1137. if (i>0) and (i<=high(hs2)) then
  1138. begin
  1139. hs2[0]:=chr(strlen(@hs2[1]));
  1140. GetShortName:=hs2;
  1141. end;
  1142. {$endif}
  1143. {$ifdef go32v2}
  1144. hs:=n;
  1145. if Dos.GetShortName(hs) then
  1146. GetShortName:=hs;
  1147. {$endif}
  1148. {$ifdef watcom}
  1149. hs:=n;
  1150. if Dos.GetShortName(hs) then
  1151. GetShortName:=hs;
  1152. {$endif}
  1153. end;
  1154. {****************************************************************************
  1155. OS Dependent things
  1156. ****************************************************************************}
  1157. function GetEnvPChar(const envname:string):pchar;
  1158. {$ifdef win32}
  1159. var
  1160. s : string;
  1161. i,len : longint;
  1162. hp,p,p2 : pchar;
  1163. {$endif}
  1164. begin
  1165. {$ifdef hasunix}
  1166. GetEnvPchar:={$ifdef havelinuxrtl10}Linux.getenv{$else}BaseUnix.fpGetEnv{$endif}(envname);
  1167. {$define GETENVOK}
  1168. {$endif}
  1169. {$ifdef win32}
  1170. GetEnvPchar:=nil;
  1171. p:=GetEnvironmentStrings;
  1172. hp:=p;
  1173. while hp^<>#0 do
  1174. begin
  1175. s:=strpas(hp);
  1176. i:=pos('=',s);
  1177. len:=strlen(hp);
  1178. if upper(copy(s,1,i-1))=upper(envname) then
  1179. begin
  1180. GetMem(p2,len-length(envname));
  1181. Move(hp[i],p2^,len-length(envname));
  1182. GetEnvPchar:=p2;
  1183. break;
  1184. end;
  1185. { next string entry}
  1186. hp:=hp+len+1;
  1187. end;
  1188. FreeEnvironmentStrings(p);
  1189. {$define GETENVOK}
  1190. {$endif}
  1191. {$ifdef os2}
  1192. GetEnvPChar := Dos.GetEnvPChar (EnvName);
  1193. {$define GETENVOK}
  1194. {$endif}
  1195. {$ifdef GETENVOK}
  1196. {$undef GETENVOK}
  1197. {$else}
  1198. GetEnvPchar:=StrPNew({$ifdef delphi}DMisc{$else}Dos{$endif}.Getenv(envname));
  1199. {$endif}
  1200. end;
  1201. procedure FreeEnvPChar(p:pchar);
  1202. begin
  1203. {$ifndef hasunix}
  1204. {$ifndef os2}
  1205. StrDispose(p);
  1206. {$endif}
  1207. {$endif}
  1208. end;
  1209. function Shell(const command:string): longint;
  1210. { This is already defined in the linux.ppu for linux, need for the *
  1211. expansion under linux }
  1212. {$ifdef hasunix}
  1213. begin
  1214. result := {$ifdef havelinuxrtl10}Linux{$else}Unix{$endif}.Shell(command);
  1215. end;
  1216. {$else}
  1217. {$ifdef amiga}
  1218. begin
  1219. exec('',command);
  1220. if (doserror <> 0) then
  1221. result := doserror
  1222. else
  1223. result := dosexitcode;
  1224. end;
  1225. {$else}
  1226. var
  1227. comspec : string;
  1228. begin
  1229. comspec:=getenv('COMSPEC');
  1230. Exec(comspec,' /C '+command);
  1231. if (doserror <> 0) then
  1232. result := doserror
  1233. else
  1234. result := dosexitcode;
  1235. end;
  1236. {$endif}
  1237. {$endif}
  1238. {$ifdef CPUI386}
  1239. {$define HASSETFPUEXCEPTIONMASK}
  1240. { later, this should be replaced by the math unit }
  1241. const
  1242. Default8087CW : word = $1332;
  1243. procedure Set8087CW(cw:word);assembler;
  1244. asm
  1245. movw cw,%ax
  1246. movw %ax,default8087cw
  1247. fnclex
  1248. fldcw default8087cw
  1249. end;
  1250. function Get8087CW:word;assembler;
  1251. asm
  1252. pushl $0
  1253. fnstcw (%esp)
  1254. popl %eax
  1255. end;
  1256. procedure SetFPUExceptionMask(const Mask: TFPUExceptionMask);
  1257. var
  1258. CtlWord: Word;
  1259. begin
  1260. CtlWord:=Get8087CW;
  1261. Set8087CW( (CtlWord and $FFC0) or Byte(Longint(Mask)) );
  1262. end;
  1263. {$endif CPUI386}
  1264. {$ifdef CPUX86_64}
  1265. {$define HASSETFPUEXCEPTIONMASK}
  1266. { later, this should be replaced by the math unit }
  1267. const
  1268. Default8087CW : word = $1332;
  1269. procedure Set8087CW(cw:word);assembler;
  1270. asm
  1271. movw cw,%ax
  1272. movw %ax,default8087cw
  1273. fnclex
  1274. fldcw default8087cw
  1275. end;
  1276. function Get8087CW:word;assembler;
  1277. asm
  1278. pushq $0
  1279. fnstcw (%rsp)
  1280. popq %rax
  1281. end;
  1282. procedure SetFPUExceptionMask(const Mask: TFPUExceptionMask);
  1283. var
  1284. CtlWord: Word;
  1285. begin
  1286. CtlWord:=Get8087CW;
  1287. Set8087CW( (CtlWord and $FFC0) or Byte(Longint(Mask)) );
  1288. end;
  1289. {$endif CPUX86_64}
  1290. {$ifdef CPUPOWERPC}
  1291. {$define HASSETFPUEXCEPTIONMASK}
  1292. procedure SetFPUExceptionMask(const Mask: TFPUExceptionMask);
  1293. var
  1294. newmask: record
  1295. case byte of
  1296. 1: (d: double);
  1297. 2: (a,b: cardinal);
  1298. end;
  1299. begin
  1300. { load current control register contents }
  1301. asm
  1302. mffs f0
  1303. stfd f0,newmask.d
  1304. end;
  1305. { invalid operation: bit 24 (big endian, bit 0 = left-most bit) }
  1306. if (exInvalidOp in mask) then
  1307. newmask.b := newmask.b and not(1 shl (31-24))
  1308. else
  1309. newmask.b := newmask.b or (1 shl (31-24));
  1310. { denormals can not cause exceptions on the PPC }
  1311. { zero divide: bit 27 }
  1312. if (exZeroDivide in mask) then
  1313. newmask.b := newmask.b and not(1 shl (31-27))
  1314. else
  1315. newmask.b := newmask.b or (1 shl (31-27));
  1316. { overflow: bit 25 }
  1317. if (exOverflow in mask) then
  1318. newmask.b := newmask.b and not(1 shl (31-25))
  1319. else
  1320. newmask.b := newmask.b or (1 shl (31-25));
  1321. { underflow: bit 26 }
  1322. if (exUnderflow in mask) then
  1323. newmask.b := newmask.b and not(1 shl (31-26))
  1324. else
  1325. newmask.b := newmask.b or (1 shl (31-26));
  1326. { Precision (inexact result): bit 28 }
  1327. if (exPrecision in mask) then
  1328. newmask.b := newmask.b and not(1 shl (31-28))
  1329. else
  1330. newmask.b := newmask.b or (1 shl (31-28));
  1331. { update control register contents }
  1332. asm
  1333. lfd f0, newmask.d
  1334. mtfsf 255,f0
  1335. end;
  1336. end;
  1337. {$endif CPUPOWERPC}
  1338. {$ifdef CPUSPARC}
  1339. {$define HASSETFPUEXCEPTIONMASK}
  1340. procedure SetFPUExceptionMask(const Mask: TFPUExceptionMask);
  1341. var
  1342. fsr : cardinal;
  1343. begin
  1344. { load current control register contents }
  1345. asm
  1346. st %fsr,fsr
  1347. end;
  1348. { invalid operation: bit 27 }
  1349. if (exInvalidOp in mask) then
  1350. fsr:=fsr and not(1 shl 27)
  1351. else
  1352. fsr:=fsr or (1 shl 27);
  1353. { zero divide: bit 24 }
  1354. if (exZeroDivide in mask) then
  1355. fsr:=fsr and not(1 shl 24)
  1356. else
  1357. fsr:=fsr or (1 shl 24);
  1358. { overflow: bit 26 }
  1359. if (exOverflow in mask) then
  1360. fsr:=fsr and not(1 shl 26)
  1361. else
  1362. fsr:=fsr or (1 shl 26);
  1363. { underflow: bit 25 }
  1364. if (exUnderflow in mask) then
  1365. fsr:=fsr and not(1 shl 25)
  1366. else
  1367. fsr:=fsr or (1 shl 25);
  1368. { Precision (inexact result): bit 23 }
  1369. if (exPrecision in mask) then
  1370. fsr:=fsr and not(1 shl 23)
  1371. else
  1372. fsr:=fsr or (1 shl 23);
  1373. { update control register contents }
  1374. asm
  1375. ld fsr,%fsr
  1376. end;
  1377. end;
  1378. {$endif CPUSPARC}
  1379. {$ifndef HASSETFPUEXCEPTIONMASK}
  1380. function SetFPUExceptionMask(const Mask: TFPUExceptionMask): TFPUExceptionMask;
  1381. begin
  1382. end;
  1383. {$endif HASSETFPUEXCEPTIONMASK}
  1384. function is_number_float(d : double) : boolean;
  1385. var
  1386. bytearray : array[0..7] of byte;
  1387. begin
  1388. move(d,bytearray,8);
  1389. { only 1.1 save, 1.0.x will use always little endian }
  1390. {$ifdef FPC_BIG_ENDIAN}
  1391. result:=((bytearray[0] and $7f)<>$7f) or ((bytearray[1] and $f0)<>$f0);
  1392. {$else FPC_BIG_ENDIAN}
  1393. result:=((bytearray[7] and $7f)<>$7f) or ((bytearray[6] and $f0)<>$f0);
  1394. {$endif FPC_BIG_ENDIAN}
  1395. end;
  1396. Function SetCompileMode(const s:string; changeInit: boolean):boolean;
  1397. var
  1398. b : boolean;
  1399. begin
  1400. b:=true;
  1401. if s='DEFAULT' then
  1402. aktmodeswitches:=initmodeswitches
  1403. else
  1404. if s='DELPHI' then
  1405. aktmodeswitches:=delphimodeswitches
  1406. else
  1407. if s='TP' then
  1408. aktmodeswitches:=tpmodeswitches
  1409. else
  1410. if s='FPC' then
  1411. aktmodeswitches:=fpcmodeswitches
  1412. else
  1413. if s='OBJFPC' then
  1414. aktmodeswitches:=objfpcmodeswitches
  1415. else
  1416. if s='GPC' then
  1417. aktmodeswitches:=gpcmodeswitches
  1418. else
  1419. if s='MACPAS' then
  1420. aktmodeswitches:=macmodeswitches
  1421. else
  1422. b:=false;
  1423. if b and changeInit then
  1424. initmodeswitches := aktmodeswitches;
  1425. if b then
  1426. begin
  1427. { turn ansistrings on by default ? }
  1428. if (m_delphi in aktmodeswitches) then
  1429. begin
  1430. include(aktlocalswitches,cs_ansistrings);
  1431. if changeinit then
  1432. include(initlocalswitches,cs_ansistrings);
  1433. end
  1434. else
  1435. begin
  1436. exclude(aktlocalswitches,cs_ansistrings);
  1437. if changeinit then
  1438. exclude(initlocalswitches,cs_ansistrings);
  1439. end;
  1440. { Default enum packing for delphi/tp7 }
  1441. if (m_tp7 in aktmodeswitches) or
  1442. (m_delphi in aktmodeswitches) then
  1443. aktpackenum:=1
  1444. else
  1445. aktpackenum:=4;
  1446. if changeinit then
  1447. initpackenum:=aktpackenum;
  1448. {$ifdef i386}
  1449. { Default to intel assembler for delphi/tp7 on i386 }
  1450. if (m_delphi in aktmodeswitches) or
  1451. (m_tp7 in aktmodeswitches) then
  1452. aktasmmode:=asmmode_i386_intel;
  1453. if changeinit then
  1454. initasmmode:=aktasmmode;
  1455. {$endif i386}
  1456. end;
  1457. SetCompileMode:=b;
  1458. end;
  1459. function SetAktProcCall(const s:string; changeInit:boolean):boolean;
  1460. const
  1461. DefProcCallName : array[tproccalloption] of string[12] = ('',
  1462. 'CDECL',
  1463. 'CPPDECL',
  1464. '', { compilerproc }
  1465. 'FAR16',
  1466. 'FPCCALL',
  1467. 'INLINE',
  1468. '', { internproc }
  1469. '', { syscall }
  1470. 'PASCAL',
  1471. 'REGISTER',
  1472. 'SAFECALL',
  1473. 'STDCALL',
  1474. 'SOFTFLOAT'
  1475. );
  1476. var
  1477. t : tproccalloption;
  1478. begin
  1479. result:=false;
  1480. for t:=low(tproccalloption) to high(tproccalloption) do
  1481. if DefProcCallName[t]=s then
  1482. begin
  1483. AktDefProcCall:=t;
  1484. result:=true;
  1485. break;
  1486. end;
  1487. if changeinit then
  1488. InitDefProcCall:=AktDefProcCall;
  1489. end;
  1490. function SetProcessor(const s:string; changeInit: boolean):boolean;
  1491. var
  1492. t : tprocessors;
  1493. begin
  1494. SetProcessor:=false;
  1495. for t:=low(tprocessors) to high(tprocessors) do
  1496. if processorsstr[t]=s then
  1497. begin
  1498. aktspecificoptprocessor:=t;
  1499. SetProcessor:=true;
  1500. break;
  1501. end;
  1502. if changeinit then
  1503. initspecificoptprocessor:=aktspecificoptprocessor;
  1504. end;
  1505. function SetFpuType(const s:string; changeInit: boolean):boolean;
  1506. var
  1507. t : tfputype;
  1508. begin
  1509. SetFpuType:=false;
  1510. for t:=low(tfputype) to high(tfputype) do
  1511. if fputypestr[t]=s then
  1512. begin
  1513. aktfputype:=t;
  1514. SetFpuType:=true;
  1515. break;
  1516. end;
  1517. if changeinit then
  1518. initfputype:=aktfputype;
  1519. end;
  1520. { '('D1:'00000000-'D2:'0000-'D3:'0000-'D4:'0000-000000000000)' }
  1521. function string2guid(const s: string; var GUID: TGUID): boolean;
  1522. function ishexstr(const hs: string): boolean;
  1523. var
  1524. i: integer;
  1525. begin
  1526. ishexstr:=false;
  1527. for i:=1 to Length(hs) do begin
  1528. if not (hs[i] in ['0'..'9','A'..'F','a'..'f']) then
  1529. exit;
  1530. end;
  1531. ishexstr:=true;
  1532. end;
  1533. function hexstr2longint(const hexs: string): longint;
  1534. var
  1535. i: integer;
  1536. rl: longint;
  1537. begin
  1538. rl:=0;
  1539. for i:=1 to length(hexs) do begin
  1540. rl:=rl shl 4;
  1541. case hexs[i] of
  1542. '0'..'9' : inc(rl,ord(hexs[i])-ord('0'));
  1543. 'A'..'F' : inc(rl,ord(hexs[i])-ord('A')+10);
  1544. 'a'..'f' : inc(rl,ord(hexs[i])-ord('a')+10);
  1545. end
  1546. end;
  1547. hexstr2longint:=rl;
  1548. end;
  1549. var
  1550. i: integer;
  1551. begin
  1552. if (Length(s)=38) and (s[1]='{') and (s[38]='}') and
  1553. (s[10]='-') and (s[15]='-') and (s[20]='-') and (s[25]='-') and
  1554. ishexstr(copy(s,2,8)) and ishexstr(copy(s,11,4)) and
  1555. ishexstr(copy(s,16,4)) and ishexstr(copy(s,21,4)) and
  1556. ishexstr(copy(s,26,12)) then begin
  1557. GUID.D1:=dword(hexstr2longint(copy(s,2,8)));
  1558. { these values are arealdy in the correct range (4 chars = word) }
  1559. GUID.D2:=word(hexstr2longint(copy(s,11,4)));
  1560. GUID.D3:=word(hexstr2longint(copy(s,16,4)));
  1561. for i:=0 to 1 do
  1562. GUID.D4[i]:=byte(hexstr2longint(copy(s,21+i*2,2)));
  1563. for i:=2 to 7 do
  1564. GUID.D4[i]:=byte(hexstr2longint(copy(s,22+i*2,2)));
  1565. string2guid:=true;
  1566. end
  1567. else
  1568. string2guid:=false;
  1569. end;
  1570. function guid2string(const GUID: TGUID): string;
  1571. function long2hex(l, len: longint): string;
  1572. const
  1573. hextbl: array[0..15] of char = '0123456789ABCDEF';
  1574. var
  1575. rs: string;
  1576. i: integer;
  1577. begin
  1578. rs[0]:=chr(len);
  1579. for i:=len downto 1 do begin
  1580. rs[i]:=hextbl[l and $F];
  1581. l:=l shr 4;
  1582. end;
  1583. long2hex:=rs;
  1584. end;
  1585. begin
  1586. guid2string:=
  1587. '{'+long2hex(GUID.D1,8)+
  1588. '-'+long2hex(GUID.D2,4)+
  1589. '-'+long2hex(GUID.D3,4)+
  1590. '-'+long2hex(GUID.D4[0],2)+long2hex(GUID.D4[1],2)+
  1591. '-'+long2hex(GUID.D4[2],2)+long2hex(GUID.D4[3],2)+
  1592. long2hex(GUID.D4[4],2)+long2hex(GUID.D4[5],2)+
  1593. long2hex(GUID.D4[6],2)+long2hex(GUID.D4[7],2)+
  1594. '}';
  1595. end;
  1596. function UpdateAlignmentStr(s:string;var a:talignmentinfo):boolean;
  1597. var
  1598. tok : string;
  1599. vstr : string;
  1600. l : longint;
  1601. code : integer;
  1602. b : talignmentinfo;
  1603. begin
  1604. UpdateAlignmentStr:=true;
  1605. uppervar(s);
  1606. fillchar(b,sizeof(b),0);
  1607. repeat
  1608. tok:=GetToken(s,'=');
  1609. if tok='' then
  1610. break;
  1611. vstr:=GetToken(s,',');
  1612. val(vstr,l,code);
  1613. if tok='PROC' then
  1614. b.procalign:=l
  1615. else if tok='JUMP' then
  1616. b.jumpalign:=l
  1617. else if tok='LOOP' then
  1618. b.loopalign:=l
  1619. else if tok='CONSTMIN' then
  1620. b.constalignmin:=l
  1621. else if tok='CONSTMAX' then
  1622. b.constalignmax:=l
  1623. else if tok='VARMIN' then
  1624. b.varalignmin:=l
  1625. else if tok='VARMAX' then
  1626. b.varalignmax:=l
  1627. else if tok='LOCALMIN' then
  1628. b.localalignmin:=l
  1629. else if tok='LOCALMAX' then
  1630. b.localalignmax:=l
  1631. else if tok='RECORDMIN' then
  1632. b.recordalignmin:=l
  1633. else if tok='RECORDMAX' then
  1634. b.recordalignmax:=l
  1635. else { Error }
  1636. UpdateAlignmentStr:=false;
  1637. until false;
  1638. UpdateAlignment(a,b);
  1639. end;
  1640. function var_align(siz: longint): longint;
  1641. begin
  1642. siz := size_2_align(siz);
  1643. var_align := used_align(siz,aktalignment.varalignmin,aktalignment.varalignmax);
  1644. end;
  1645. function const_align(siz: longint): longint;
  1646. begin
  1647. siz := size_2_align(siz);
  1648. const_align := used_align(siz,aktalignment.constalignmin,aktalignment.constalignmax);
  1649. end;
  1650. {****************************************************************************
  1651. Init
  1652. ****************************************************************************}
  1653. {$ifdef unix}
  1654. {$define need_path_search}
  1655. {$endif unix}
  1656. {$ifdef os2}
  1657. {$define need_path_search}
  1658. {$endif os2}
  1659. procedure get_exepath;
  1660. var
  1661. hs1 : namestr;
  1662. hs2 : extstr;
  1663. {$ifdef need_path_search}
  1664. p : pchar;
  1665. {$endif need_path_search}
  1666. begin
  1667. {$ifdef delphi}
  1668. exepath:=dmisc.getenv('PPC_EXEC_PATH');
  1669. {$else delphi}
  1670. exepath:=dos.getenv('PPC_EXEC_PATH');
  1671. {$endif delphi}
  1672. if exepath='' then
  1673. fsplit(FixFileName(system.paramstr(0)),exepath,hs1,hs2);
  1674. {$ifdef need_path_search}
  1675. if exepath='' then
  1676. begin
  1677. if pos(source_info.exeext,hs1) <>
  1678. (length(hs1) - length(source_info.exeext)+1) then
  1679. hs1 := hs1 + source_info.exeext;
  1680. p:=GetEnvPchar('PATH');
  1681. FindFilePChar(hs1,p,exepath);
  1682. FreeEnvPChar(p);
  1683. exepath:=SplitPath(exepath);
  1684. end;
  1685. {$endif need_path_search}
  1686. exepath:=FixPath(exepath,false);
  1687. end;
  1688. procedure DoneGlobals;
  1689. begin
  1690. initdefines.free;
  1691. if assigned(DLLImageBase) then
  1692. StringDispose(DLLImageBase);
  1693. librarysearchpath.Free;
  1694. unitsearchpath.Free;
  1695. objectsearchpath.Free;
  1696. includesearchpath.Free;
  1697. end;
  1698. procedure InitGlobals;
  1699. begin
  1700. get_exepath;
  1701. { reset globals }
  1702. do_build:=false;
  1703. do_release:=false;
  1704. do_make:=true;
  1705. compile_level:=0;
  1706. DLLsource:=false;
  1707. inlining_procedure:=false;
  1708. resolving_forward:=false;
  1709. make_ref:=false;
  1710. LinkTypeSetExplicitly:=false;
  1711. { Output }
  1712. OutputFile:='';
  1713. OutputPrefix:=Nil;
  1714. OutputSuffix:=Nil;
  1715. OutputExtension:='';
  1716. OutputExeDir:='';
  1717. OutputUnitDir:='';
  1718. { Utils directory }
  1719. utilsdirectory:='';
  1720. utilsprefix:='';
  1721. cshared:=false;
  1722. rlinkpath:='';
  1723. { Search Paths }
  1724. librarysearchpath:=TSearchPathList.Create;
  1725. unitsearchpath:=TSearchPathList.Create;
  1726. includesearchpath:=TSearchPathList.Create;
  1727. objectsearchpath:=TSearchPathList.Create;
  1728. { Def file }
  1729. usewindowapi:=false;
  1730. description:='Compiled by FPC '+version_string+' - '+target_cpu_string;
  1731. DescriptionSetExplicity:=false;
  1732. dllversion:='';
  1733. dllmajor:=1;
  1734. dllminor:=0;
  1735. dllrevision:=0;
  1736. nwscreenname := '';
  1737. nwthreadname := '';
  1738. nwcopyright := '';
  1739. UseDeffileForExports:=false;
  1740. UseDeffileForExportsSetExplicitly:=false;
  1741. RelocSection:=false;
  1742. RelocSectionSetExplicitly:=false;
  1743. LinkTypeSetExplicitly:=false;
  1744. { Init values }
  1745. initmodeswitches:=fpcmodeswitches;
  1746. initlocalswitches:=[cs_check_io,cs_typed_const_writable];
  1747. initmoduleswitches:=[cs_extsyntax,cs_implicit_exceptions];
  1748. initsourcecodepage:='8859-1';
  1749. initglobalswitches:=[cs_check_unit_name,cs_link_static{$ifdef INTERNALLINKER},cs_link_internal,cs_link_map{$endif}];
  1750. initoutputformat:=target_asm.id;
  1751. fillchar(initalignment,sizeof(talignmentinfo),0);
  1752. { might be overridden later }
  1753. initasmmode:=asmmode_standard;
  1754. {$ifdef i386}
  1755. initoptprocessor:=Class386;
  1756. initspecificoptprocessor:=Class386;
  1757. initfputype:=fpu_x87;
  1758. initpackenum:=4;
  1759. {$IFDEF testvarsets}
  1760. initsetalloc:=0;
  1761. {$ENDIF}
  1762. initasmmode:=asmmode_i386_att;
  1763. {$endif i386}
  1764. {$ifdef m68k}
  1765. initoptprocessor:=MC68020;
  1766. initpackenum:=4;
  1767. {$IFDEF testvarsets}
  1768. initsetalloc:=0;
  1769. {$ENDIF}
  1770. {$endif m68k}
  1771. {$ifdef powerpc}
  1772. initoptprocessor:=PPC604;
  1773. initpackenum:=4;
  1774. {$IFDEF testvarsets}
  1775. initsetalloc:=0;
  1776. {$ENDIF}
  1777. initfputype:=fpu_standard;
  1778. {$endif powerpc}
  1779. {$ifdef sparc}
  1780. initoptprocessor:=SPARC_V8;
  1781. initpackenum:=4;
  1782. {$IFDEF testvarsets}
  1783. initsetalloc:=0;
  1784. {$ENDIF}
  1785. {$endif sparc}
  1786. {$ifdef arm}
  1787. initpackenum:=4;
  1788. {$IFDEF testvarsets}
  1789. initsetalloc:=0;
  1790. {$ENDIF}
  1791. initfputype:=fpu_fpa;
  1792. {$endif arm}
  1793. {$ifdef x86_64}
  1794. initoptprocessor:=ClassAthlon64;
  1795. initspecificoptprocessor:=ClassAthlon64;
  1796. initfputype:=fpu_sse64;
  1797. initpackenum:=4;
  1798. {$IFDEF testvarsets}
  1799. initsetalloc:=0;
  1800. {$ENDIF}
  1801. initasmmode:=asmmode_x86_64_gas;
  1802. {$endif x86_64}
  1803. initinterfacetype:=it_interfacecom;
  1804. initdefproccall:=pocall_default;
  1805. initdefines:=TStringList.Create;
  1806. { memory sizes, will be overriden by parameter or default for target
  1807. in options or init_parser }
  1808. stacksize:=0;
  1809. heapsize:=0;
  1810. apptype:=app_cui;
  1811. end;
  1812. end.
  1813. {
  1814. $Log$
  1815. Revision 1.141 2004-09-21 23:33:43 hajny
  1816. * better PathExists, fix for too long command line, correction of message
  1817. Revision 1.140 2004/09/21 19:59:51 peter
  1818. * x86_64 fixes
  1819. * cleanup of fpcdefs.icn
  1820. Revision 1.139 2004/09/21 17:25:12 peter
  1821. * paraloc branch merged
  1822. Revision 1.138 2004/09/08 11:23:31 michael
  1823. + Check if outputdir exists, Fix exitcode when displaying help pages
  1824. Revision 1.137 2004/08/31 22:02:30 olle
  1825. + support for quoting of paths in TSearchPathList.AddPath so that
  1826. compiler directives which take paths, will support quotes.
  1827. * uppdated TranslateMacPath
  1828. Revision 1.136.4.2 2004/09/12 18:31:26 peter
  1829. * fpu exception support for sparc and x86_64
  1830. Revision 1.136.4.1 2004/09/12 15:30:16 peter
  1831. * cache currentdir
  1832. Revision 1.136 2004/08/28 20:25:25 peter
  1833. * optimized search for noncasesensitive names. It now searches
  1834. first for NormalCase and skips double tests
  1835. Revision 1.135 2004/08/20 10:29:31 olle
  1836. + made fpc work as an MPW tool, by itself calling asm and link.
  1837. * bugfix in fp exception flag settings routine
  1838. Revision 1.134 2004/08/02 07:15:54 michael
  1839. + Patch from Christian Iversen to implement LIBPREFIX/SUFFIX/EXTENSION directives
  1840. Revision 1.133 2004/07/17 15:51:57 jonas
  1841. * shell now returns an exitcode
  1842. * print an error if linking failed when linking was done using a script
  1843. Revision 1.132 2004/07/05 23:28:24 olle
  1844. + FixFileName now handles Mac OS paths
  1845. Revision 1.131 2004/06/20 08:55:29 florian
  1846. * logs truncated
  1847. Revision 1.130 2004/06/16 20:07:07 florian
  1848. * dwarf branch merged
  1849. Revision 1.129 2004/05/11 18:20:52 olle
  1850. * changed $mode mac to $mode macpas
  1851. * changed macmodeswitches to be more faithful to the mac dialect
  1852. Revision 1.128 2004/04/29 19:56:36 daniel
  1853. * Prepare compiler infrastructure for multiple ansistring types
  1854. Revision 1.127 2004/04/28 15:19:03 florian
  1855. + syscall directive support for MorphOS added
  1856. Revision 1.126.2.4 2004/05/09 15:47:21 peter
  1857. * fix typecast from word->set
  1858. }