gdbver.pp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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 OpenBSD}
  13. ver_name = '_version';
  14. {$else}
  15. {$ifdef unix}
  16. ver_name = 'version';
  17. {$else not unix}
  18. ver_name = '_version';
  19. {$endif}
  20. {$endif}
  21. { This variable should be change with
  22. change in GDB CVS PM }
  23. Current_cvs_version : longint = 503;
  24. Max_version_length = 255;
  25. var
  26. v5_version : array[0..0] of char;external name ver_name;
  27. v4_version : pchar;external name ver_name;
  28. version : pchar;
  29. subver_str : string;
  30. i, version_number,
  31. subversion_number : longint;
  32. subsubversion_number : longint;
  33. error : word;
  34. only_ver : boolean;
  35. begin
  36. only_ver:=(Paramcount>0) and (ParamStr(1)='-n');
  37. getmem(version,Max_version_length+1);
  38. strlcopy(version,@v5_version,Max_version_length);
  39. version[Max_version_length]:=#0;
  40. if (version[0] in ['4','5','6','7','8','9']) and (version[1]='.') then
  41. begin
  42. if not only_ver then
  43. Writeln('GDB version is ',pchar(@v5_version));
  44. version_number:=ord(version[0])-ord('0');
  45. i:=2;
  46. subver_str:='';
  47. while version[i] in ['0'..'9'] do
  48. begin
  49. subver_str:=subver_str+version[i];
  50. inc(i);
  51. end;
  52. val(subver_str,subversion_number,error);
  53. inc(i);
  54. subver_str:='';
  55. while version[i] in ['0'..'9'] do
  56. begin
  57. subver_str:=subver_str+version[i];
  58. inc(i);
  59. end;
  60. if subver_str<>'' then
  61. val(subver_str,subsubversion_number,error);
  62. { 5.02.90 is a pretest of 5.03.. PM }
  63. if subsubversion_number>=90 then
  64. inc(subversion_number);
  65. if (error=0) and (subversion_number>=0) and
  66. (subversion_number<=99) then
  67. version_number:=version_number*100+subversion_number;
  68. end
  69. else if (version[0]='2') and (version[1]='0') and
  70. (version[2] in ['0'..'9']) and (version[3] in ['0'..'9']) then
  71. begin
  72. { CVS version from 2000 to 2099,
  73. assume current_cvs_version PM }
  74. version_number:=Current_cvs_version;
  75. end
  76. else
  77. begin
  78. if not only_ver then
  79. Writeln('GDB version is ',v4_version);
  80. version_number:=ord(v4_version[0])-ord('0');
  81. end;
  82. freemem(version,Max_version_length+1);
  83. if only_ver then
  84. Write(version_number);
  85. Halt(version_number);
  86. end.
  87. {
  88. $Log$
  89. Revision 1.6 2003-02-09 19:14:48 marco
  90. * ugly openbsd fix
  91. Revision 1.5 2002/12/12 14:17:59 pierre
  92. * 5.3 was not correctly parsed
  93. Revision 1.4 2002/12/02 13:59:16 pierre
  94. convert 5.02.90 into 5.03
  95. Revision 1.3 2002/09/10 12:17:15 pierre
  96. * avoid RTE 201
  97. Revision 1.2 2002/09/07 15:42:52 peter
  98. * old logs removed and tabs fixed
  99. Revision 1.1 2002/01/29 17:54:49 peter
  100. * splitted to base and extra
  101. Revision 1.5 2002/01/25 08:56:50 pierre
  102. + add subversion for version output
  103. Revision 1.4 2002/01/24 09:14:40 pierre
  104. * adapt to GDB 5.1
  105. }