get_ver.awk 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. # ***************************************************************************
  2. # * _ _ ____ _
  3. # * Project ___| | | | _ \| |
  4. # * / __| | | | |_) | |
  5. # * | (__| |_| | _ <| |___
  6. # * \___|\___/|_| \_\_____|
  7. # *
  8. # * Copyright (C) 1998 - 2008, Daniel Stenberg, <[email protected]>, et al.
  9. # *
  10. # * This software is licensed as described in the file COPYING, which
  11. # * you should have received as part of this distribution. The terms
  12. # * are also available at http://curl.haxx.se/docs/copyright.html.
  13. # *
  14. # * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  15. # * copies of the Software, and permit persons to whom the Software is
  16. # * furnished to do so, under the terms of the COPYING file.
  17. # *
  18. # * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  19. # * KIND, either express or implied.
  20. # *
  21. # * $Id$
  22. # ***************************************************************************
  23. # awk script which fetches curl / ares version number and string from input
  24. # file and writes them to STDOUT. Here you can get an awk version for Win32:
  25. # http://www.gknw.net/development/prgtools/awk-20070501.zip
  26. #
  27. BEGIN {
  28. if (match (ARGV[1], /curlver.h/)) {
  29. while ((getline < ARGV[1]) > 0) {
  30. if (match ($0, /^#define LIBCURL_COPYRIGHT "[^"]+"$/)) {
  31. libcurl_copyright_str = substr($0, 28, length($0)-28);
  32. }
  33. else if (match ($0, /^#define LIBCURL_VERSION "[^"]+"$/)) {
  34. libcurl_ver_str = substr($3, 2, length($3)-2);
  35. }
  36. else if (match ($0, /^#define LIBCURL_VERSION_MAJOR [0-9]+$/)) {
  37. libcurl_ver_major = substr($3, 1, length($3));
  38. }
  39. else if (match ($0, /^#define LIBCURL_VERSION_MINOR [0-9]+$/)) {
  40. libcurl_ver_minor = substr($3, 1, length($3));
  41. }
  42. else if (match ($0, /^#define LIBCURL_VERSION_PATCH [0-9]+$/)) {
  43. libcurl_ver_patch = substr($3, 1, length($3));
  44. }
  45. }
  46. libcurl_ver = libcurl_ver_major "," libcurl_ver_minor "," libcurl_ver_patch;
  47. print "LIBCURL_VERSION = " libcurl_ver "";
  48. print "LIBCURL_VERSION_STR = " libcurl_ver_str "";
  49. print "LIBCURL_COPYRIGHT_STR = " libcurl_copyright_str "";
  50. }
  51. if (match (ARGV[1], /ares_version.h/)) {
  52. while ((getline < ARGV[1]) > 0) {
  53. if (match ($0, /^#define ARES_COPYRIGHT "[^"]+"$/)) {
  54. libcares_copyright_str = substr($0, 25, length($0)-25);
  55. }
  56. else if (match ($0, /^#define ARES_VERSION_STR "[^"]+"$/)) {
  57. libcares_ver_str = substr($3, 2, length($3)-2);
  58. }
  59. else if (match ($0, /^#define ARES_VERSION_MAJOR [0-9]+$/)) {
  60. libcares_ver_major = substr($3, 1, length($3));
  61. }
  62. else if (match ($0, /^#define ARES_VERSION_MINOR [0-9]+$/)) {
  63. libcares_ver_minor = substr($3, 1, length($3));
  64. }
  65. else if (match ($0, /^#define ARES_VERSION_PATCH [0-9]+$/)) {
  66. libcares_ver_patch = substr($3, 1, length($3));
  67. }
  68. }
  69. libcares_ver = libcares_ver_major "," libcares_ver_minor "," libcares_ver_patch;
  70. print "LIBCARES_VERSION = " libcares_ver "";
  71. print "LIBCARES_VERSION_STR = " libcares_ver_str "";
  72. print "LIBCARES_COPYRIGHT_STR = " libcares_copyright_str "";
  73. }
  74. }