fpc.pp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. {
  2. $Id$
  3. Copyright (c) 2000 by Florian Klaempfl
  4. This file is the "loader" for the Free Pascal compiler
  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. program fpc;
  18. uses
  19. dos;
  20. const
  21. {$ifdef UNIX}
  22. exeext='';
  23. {$else UNIX}
  24. exeext='.exe';
  25. {$endif UNIX}
  26. procedure error(const s : string);
  27. begin
  28. writeln('Error: ',s);
  29. halt(1);
  30. end;
  31. function SplitPath(Const HStr:ShortString):ShortString;
  32. var
  33. i : longint;
  34. begin
  35. i:=Length(Hstr);
  36. while (i>0) and not(Hstr[i] in ['\','/']) do
  37. dec(i);
  38. SplitPath:=Copy(Hstr,1,i);
  39. end;
  40. function FileExists ( Const F : ShortString) : Boolean;
  41. var
  42. Info : SearchRec;
  43. begin
  44. findfirst(F,readonly+archive+hidden,info);
  45. FileExists:=(doserror=0);
  46. findclose(Info);
  47. end;
  48. var
  49. s,path,
  50. ppcbin,
  51. processorstr : shortstring;
  52. ppccommandline : ansistring;
  53. i : longint;
  54. begin
  55. ppccommandline:='';
  56. {$ifdef i386}
  57. ppcbin:='ppc386';
  58. {$endif i386}
  59. {$ifdef m68k}
  60. ppcbin:='ppc68k';
  61. {$endif m68k}
  62. {$ifdef alpha}
  63. ppcbin:='ppcapx';
  64. {$endif alpha}
  65. {$ifdef powerpc}
  66. ppcbin:='ppcppc';
  67. {$endif powerpc}
  68. for i:=1 to paramcount do
  69. begin
  70. s:=paramstr(i);
  71. if pos('-P',s)=1 then
  72. begin
  73. processorstr:=copy(s,3,length(s)-2);
  74. if processorstr='i386' then
  75. ppcbin:='ppc386'
  76. else if processorstr='m68k' then
  77. ppcbin:='ppc68k'
  78. else if processorstr='alpha' then
  79. ppcbin:='ppcapx'
  80. else if processorstr='powerpc' then
  81. ppcbin:='ppcppc'
  82. else error('Illegal processor type "'+processorstr+'"');
  83. end
  84. else
  85. ppccommandline:=ppccommandline+s+' ';
  86. end;
  87. { add .exe extension }
  88. ppcbin:=ppcbin+exeext;
  89. { get path of fpc.exe }
  90. path:=splitpath(paramstr(0));
  91. if FileExists(path+ppcbin) then
  92. ppcbin:=path+ppcbin
  93. else
  94. begin
  95. path:=FSearch(ppcbin,getenv('PATH'));
  96. if path<>'' then
  97. ppcbin:=path;
  98. end;
  99. { call ppcXXX }
  100. swapvectors;
  101. exec(ppcbin,ppccommandline);
  102. swapvectors;
  103. if doserror<>0 then
  104. error(ppcbin+' can''t be executed');
  105. halt(dosexitcode);
  106. end.
  107. {
  108. $Log$
  109. Revision 1.1 2001-04-25 22:40:07 peter
  110. * compiler dependent utils in utils/ subdir
  111. }