1# ****************************************************************************
2# RRDtool 1.2.19  Copyright by Tobi Oetiker, 1997-2007
3# ****************************************************************************
4# get_ver.awk   AWK Script for non-configure builds
5# ****************************************************************************
6# $Id: get_ver.awk 1000 2007-14-02 05:51:34Z oetiker $
7# ****************************************************************************
8BEGIN {
9  # fetch rrdtool version number from input file and write them to STDOUT
10  while ((getline < ARGV[1]) > 0) {
11    if (match ($0, /^AC_INIT/)) {
12      split($1, t, ",");
13      my_ver_str = substr(t[2],2,length(t[2])-3);
14      split(my_ver_str, v, ".");
15      gsub("[^0-9].*$", "", v[3]);
16      my_ver = v[1] "," v[2] "," v[3];
17    }
18    if (match ($0, /^NUMVERS=/)) {
19      split($1, t, "=");
20      my_ver_num = t[2];
21    }
22  }
23  # read from from input file, replace placeholders, and write to STDOUT
24  if (ARGV[2]) {
25    while ((getline < ARGV[2]) > 0) {
26      if (match ($0, /@@NUMVERS@@/)) {
27        gsub("@@NUMVERS@@", my_ver_num, $0);
28      }
29      if (match ($0, /@@PACKAGE_VERSION@@/)) {
30        gsub("@@PACKAGE_VERSION@@", "" my_ver_str "", $0);
31      }
32      print;
33    }
34  } else {
35    print "RRD_VERSION = " my_ver "";
36    print "RRD_VERSION_STR = " my_ver_str "";
37    print "RRD_NUMVERS = " my_ver_num "";
38  }
39}
40
41