gdbver.pp 3.1 KB

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