gdbver.pp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. {
  2. $Id$
  3. Program to detect the version of libgdb that will be
  4. used for linking
  5. }
  6. program find_gdb_version;
  7. {$Linklib gdb}
  8. uses
  9. strings;
  10. const
  11. {$ifdef unix}
  12. ver_name = 'version';
  13. {$else not unix}
  14. ver_name = '_version';
  15. {$endif}
  16. { This variable should be change with
  17. change in GDB CVS PM }
  18. Current_cvs_version : longint = 502;
  19. Max_version_length = 25;
  20. var
  21. v5_version : array[0..0] of char;external name ver_name;
  22. v4_version : pchar;external name ver_name;
  23. version : pchar;
  24. subver_str : string;
  25. i, version_number,
  26. subversion_number : longint;
  27. error : word;
  28. only_ver : boolean;
  29. begin
  30. only_ver:=(Paramcount>0) and (ParamStr(1)='-n');
  31. getmem(version,Max_version_length+1);
  32. strlcopy(version,@v5_version,Max_version_length);
  33. version[Max_version_length]:=#0;
  34. if (version[0] in ['4','5','6','7','8','9']) and (version[1]='.') then
  35. begin
  36. if not only_ver then
  37. Writeln('GDB version is ',pchar(@v5_version));
  38. version_number:=ord(version[0])-ord('0');
  39. i:=2;
  40. subver_str:='';
  41. while version[i] in ['0'..'9'] do
  42. begin
  43. subver_str:=subver_str+version[i];
  44. inc(i);
  45. end;
  46. val(subver_str,subversion_number,error);
  47. if (error=0) and (subversion_number>=0) and
  48. (subversion_number<=99) then
  49. version_number:=version_number*100+subversion_number;
  50. end
  51. else if (version[0]='2') and (version[1]='0') and
  52. (version[2] in ['0'..'9']) and (version[3] in ['0'..'9']) then
  53. begin
  54. { CVS version from 2000 to 2099,
  55. assume current_cvs_version PM }
  56. version_number:=Current_cvs_version;
  57. end
  58. else
  59. begin
  60. if not only_ver then
  61. Writeln('GDB version is ',v4_version);
  62. version_number:=ord(v4_version[0])-ord('0');
  63. end;
  64. freemem(version,Max_version_length+1);
  65. if only_ver then
  66. Write(version_number);
  67. Halt(version_number);
  68. end.
  69. {
  70. $Log$
  71. Revision 1.1 2002-01-29 17:54:49 peter
  72. * splitted to base and extra
  73. Revision 1.5 2002/01/25 08:56:50 pierre
  74. + add subversion for version output
  75. Revision 1.4 2002/01/24 09:14:40 pierre
  76. * adapt to GDB 5.1
  77. Revision 1.3 2001/09/11 10:22:09 pierre
  78. * Hack to allow to recognize CVS version as 5.01
  79. Revision 1.2 2001/04/08 11:44:01 peter
  80. * new file
  81. }