* configure.in, configure, config_vc.awk: sdcc version number is now
[fw/sdcc] / configure_vc.awk
1 #!/usr/bin/awk
2
3 # configure_vc.awk - Genarate sdcc_vc.h using sdcc_vc_in.h as template
4 #                    and insert the version number definitions from configure.in
5 #
6 # Written By - Borut Razem borut.razem@siol.net
7 #
8 # This file is part of sdcc.
9 #
10 # This program is free software; you can redistribute it and/or modify it
11 # under the terms of the GNU General Public License as published by the
12 # Free Software Foundation; either version 2, or (at your option) any
13 # later version.
14 #
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 # GNU General Public License for more details.
19 #
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write to the Free Software
22 # Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23
24 BEGIN {
25   # get the values from configure.in
26
27   while (getline <"configure.in" > 0) {
28     if ($0 ~ "^AC_INIT\\(.*\\)") {
29       package = gensub("^AC_INIT\\(\\[([^]]*)\\].*", "\\1", "1", $0);
30       version = gensub("^AC_INIT\\(\\[[^]]*\\], \\[([^]]*)\\].*", "\\1", "1", $0);
31       bugreport = gensub("^AC_INIT\\(\\[[^]]*\\], \\[[^]]*\\], \\[([^]]*)\\].*", "\\1", "1", $0);
32
33       version_high = gensub(/^([^.]*).([^.]*).([^.]*)/, "\\1", "1", version)
34       version_lo = gensub(/^([^.]*).([^.]*).([^.]*)/, "\\2", "1", version)
35       version_patch = gensub(/^([^.]*).([^.]*).([^.]*)/, "\\3", "1", version)
36     }
37   }
38
39   print "/*"
40   print " * sdcc_vc.h"
41   print " * Generated automatically by configure_vc.awk, DO NOT edit!"
42   print " * To make changes to sdcc_vc.h edit sdcc_vc_in.h instead."
43   print " */" 
44   print "" 
45 }
46
47 /^#undef SDCC_VERSION_HI$/ {
48   print("#define SDCC_VERSION_HI " version_high);
49   next
50 }
51
52 /^#undef SDCC_VERSION_LO$/ {
53   print("#define SDCC_VERSION_LO " version_lo);
54   next
55 }
56
57 /^#undef SDCC_VERSION_P$/ {
58   print("#define SDCC_VERSION_P " version_patch);
59   next
60 }
61
62 /^#undef SDCC_VERSION_STR$/ {
63   print("#define SDCC_VERSION_STR " "\"" version "\"");
64   next
65 }
66
67 {
68   print
69 }