gdbver.pp 2.3 KB

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