fpmake.pp 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. {$ifndef ALLPACKAGES}
  2. {$mode objfpc}{$H+}
  3. program fpmake;
  4. uses
  5. fpmkunit,
  6. sysutils;
  7. {$endif ALLPACKAGES}
  8. procedure ide_check_gdb_availability(Sender: TObject);
  9. function DetectLibGDBDir: string;
  10. var
  11. SearchPath: string;
  12. const
  13. LibGDBName = 'libgdb.a';
  14. begin
  15. result:='';
  16. // First look for the GDBLIBDIR environment variable
  17. SearchPath := GetEnvironmentVariable('GDBLIBDIR');
  18. if (SearchPath<>'') and DirectoryExists(SearchPath) and FileExists(IncludeTrailingPathDelimiter(SearchPath)+LibGDBName) then
  19. begin
  20. result:=IncludeTrailingPathDelimiter(SearchPath);
  21. exit;
  22. end;
  23. // Search in the default locations
  24. SearchPath := '..'+PathDelim+'libgdb'+PathDelim+OSToString(Defaults.OS)+PathDelim+CPUToString(Defaults.CPU)+PathDelim;
  25. if DirectoryExists(SearchPath) and FileExists(SearchPath+LibGDBName) then
  26. begin
  27. result := SearchPath;
  28. exit;
  29. end;
  30. SearchPath := '..'+PathDelim+'libgdb'+PathDelim+OSToString(Defaults.OS)+PathDelim;
  31. if DirectoryExists(SearchPath) and FileExists(SearchPath+LibGDBName) then
  32. begin
  33. result := SearchPath;
  34. exit;
  35. end;
  36. // No custom libgdb.a found, try using system default library if available
  37. SearchPath := '..'+PathDelim+'lib'+PathDelim;
  38. if DirectoryExists(SearchPath) and FileExists(SearchPath+LibGDBName) then
  39. begin
  40. result := SearchPath;
  41. installer.BuildEngine.Log(vlWarning, 'Using system default libgdb file located in '+Result);
  42. exit;
  43. end;
  44. SearchPath := '..'+PathDelim+'usr'+PathDelim+'lib'+PathDelim;
  45. if DirectoryExists(SearchPath) and FileExists(SearchPath+LibGDBName) then
  46. begin
  47. result := SearchPath;
  48. installer.BuildEngine.Log(vlWarning, 'Using system default libgdb file located in '+Result);
  49. exit;
  50. end;
  51. SearchPath := '..'+PathDelim+'usr'+PathDelim+'local'+PathDelim+'lib'+PathDelim;
  52. if DirectoryExists(SearchPath) and FileExists(SearchPath+LibGDBName) then
  53. begin
  54. result := SearchPath;
  55. installer.BuildEngine.Log(vlWarning, 'Using system default libgdb file located in '+Result);
  56. exit;
  57. end;
  58. end;
  59. var
  60. s: string;
  61. GDBLibDir: string;
  62. P: TPackage;
  63. begin
  64. P := sender as TPackage;
  65. with installer do
  66. begin
  67. s := GetCustomFpmakeCommandlineOptionValue('NoGDB');
  68. if not ((s='1') or (s='Y')) then
  69. begin
  70. // Detection of GDB.
  71. GDBLibDir := DetectLibGDBDir;
  72. if GDBLibDir<>'' then
  73. begin
  74. // Include GDB
  75. BuildEngine.log(vlCommand, 'LibGDB was found, build IDE with debugger support');
  76. if FileExists(GDBLibDir+'gdblib.inc') then
  77. begin
  78. P.Options.Add('-dUSE_GDBLIBINC');
  79. P.Options.Add('-I'+GDBLibDir);
  80. end;
  81. P.Options.Add('-Fl'+GDBLibDir);
  82. case Defaults.OS of
  83. win32,
  84. win64 : begin
  85. P.Options.Add('-Xe');
  86. P.Options.Add('-k--allow-multiple-definition');
  87. end;
  88. freebsd : begin
  89. P.Options.Add('-Fl/usr/local/lib');
  90. P.Options.Add('-Xd');
  91. end;
  92. openbsd : begin
  93. P.Options.Add('-Fl/usr/local/lib');
  94. P.Options.Add('-Xd');
  95. end;
  96. netbsd : P.Options.Add('-Xd');
  97. linux : P.Options.Add('-Xd');
  98. end; {case}
  99. P.NeedLibc := true;
  100. end
  101. else
  102. begin
  103. BuildEngine.log(vlCommand, 'LibGDB was not found, IDE has no debugger support');
  104. P.Options.Add('-dNODEBUG');
  105. end;
  106. end
  107. else
  108. begin
  109. BuildEngine.log(vlCommand, 'Debugger support disabled');
  110. P.Options.Add('-dNODEBUG');
  111. end;
  112. end;
  113. end;
  114. procedure add_ide(const ADirectory: string);
  115. Var
  116. P : TPackage;
  117. T : TTarget;
  118. CompilerTarget : TCpu;
  119. s: string;
  120. begin
  121. AddCustomFpmakeCommandlineOption('CompilerTarget','Target CPU for the IDE''s compiler');
  122. AddCustomFpmakeCommandlineOption('NoGDB','If value=1 or ''Y'', no GDB support');
  123. With Installer do
  124. begin
  125. s :=GetCustomFpmakeCommandlineOptionValue('CompilerTarget');
  126. if s <> '' then
  127. CompilerTarget:=StringToCPU(s)
  128. else
  129. CompilerTarget:=Defaults.CPU;
  130. P:=AddPackage('ide');
  131. P.Version:='2.7.1';
  132. {$ifdef ALLPACKAGES}
  133. P.Directory:=ADirectory;
  134. {$endif ALLPACKAGES}
  135. P.Dependencies.Add('rtl');
  136. P.Dependencies.Add('fv');
  137. P.Dependencies.Add('chm');
  138. { This one is only needed if DEBUG is set }
  139. P.Dependencies.Add('regexpr');
  140. P.Dependencies.Add('gdbint',AllOSes-[morphos]);
  141. P.Dependencies.Add('graph',[go32v2]);
  142. P.SupportBuildModes:=[bmOneByOne];
  143. P.Options.Add('-Ur');
  144. P.Options.Add('-dNOCATCH');
  145. P.Options.Add('-dBrowserCol');
  146. P.Options.Add('-dGDB');
  147. P.Options.Add('-d'+CPUToString(CompilerTarget));
  148. P.Options.Add('-Fu../compiler');
  149. P.Options.Add('-Fu../compiler/'+CPUToString(CompilerTarget));
  150. P.Options.Add('-Fu../compiler/targets');
  151. P.Options.Add('-Fu../compiler/systems');
  152. P.Options.Add('-Fi../compiler/'+CPUToString(CompilerTarget));
  153. P.Options.Add('-Fi../compiler');
  154. if CompilerTarget in [x86_64, i386] then
  155. P.Options.Add('-Fu../compiler/x86');
  156. if CompilerTarget in [powerpc, powerpc64] then
  157. P.Options.Add('-Fu../compiler/ppcgen');
  158. if CompilerTarget = x86_64 then
  159. P.Options.Add('-dNOOPT');
  160. if CompilerTarget = mipsel then
  161. P.Options.Add('-Fu../compiler/mips');
  162. P.Options.Add('-Sg');
  163. T:=P.Targets.AddProgram('fp.pas');
  164. T.Dependencies.AddUnit('compunit');
  165. T:=P.Targets.AddUnit('compunit.pas');
  166. T.Directory:='compiler';
  167. T.Install:=false;
  168. P.InstallFiles.Add('fp.ans','$(BASEINSTALLDIR)/ide');
  169. P.InstallFiles.Add('gplprog.pt','$(BASEINSTALLDIR)/ide');
  170. P.InstallFiles.Add('gplunit.pt','$(BASEINSTALLDIR)/ide');
  171. P.InstallFiles.Add('program.pt','$(BASEINSTALLDIR)/ide');
  172. P.InstallFiles.Add('unit.pt','$(BASEINSTALLDIR)/ide');
  173. P.InstallFiles.Add('cvsco.tdf','$(BASEINSTALLDIR)/ide');
  174. P.InstallFiles.Add('cvsdiff.tdf','$(BASEINSTALLDIR)/ide');
  175. P.InstallFiles.Add('cvsup.tdf','$(BASEINSTALLDIR)/ide');
  176. P.InstallFiles.Add('grep.tdf','$(BASEINSTALLDIR)/ide');
  177. P.InstallFiles.Add('tpgrep.tdf','$(BASEINSTALLDIR)/ide');
  178. P.InstallFiles.Add('fp32.ico', [win32, win64], '$(BASEINSTALLDIR)/ide');
  179. P.Sources.AddDoc('readme.ide');
  180. P.CleanFiles.Add('$(UNITSOUTPUTDIR)ppheap.ppu');
  181. P.CleanFiles.Add('$(UNITSOUTPUTDIR)compiler.ppu');
  182. P.CleanFiles.Add('$(UNITSOUTPUTDIR)comphook.ppu');
  183. P.CleanFiles.Add('$(UNITSOUTPUTDIR)cpuinfo.ppu');
  184. P.CleanFiles.Add('$(UNITSOUTPUTDIR)browcol.ppu');
  185. P.CleanFiles.Add('$(UNITSOUTPUTDIR)ppheap.o');
  186. P.CleanFiles.Add('$(UNITSOUTPUTDIR)compiler.o');
  187. P.CleanFiles.Add('$(UNITSOUTPUTDIR)comphook.o');
  188. P.CleanFiles.Add('$(UNITSOUTPUTDIR)cpuinfo.o');
  189. P.CleanFiles.Add('$(UNITSOUTPUTDIR)browcol.o');
  190. P.BeforeCompileProc:=@ide_check_gdb_availability;
  191. end;
  192. end;
  193. {$ifndef ALLPACKAGES}
  194. begin
  195. add_ide('');
  196. Installer.Run;
  197. end.
  198. {$endif ALLPACKAGES}