]> gcc.gnu.org Git - gcc.git/blob - gcc/gcov-iov.c
vmsdbgout.c (ASM_OUTPUT_DEBUG_DATA1): Change format string placeholder from 0x%x...
[gcc.git] / gcc / gcov-iov.c
1 /* Generate gcov version string from version.c. See gcov-io.h for
2 description of how the version string is generated.
3 Copyright (C) 2002, 2003, 2005, 2007 Free Software Foundation, Inc.
4 Contributed by Nathan Sidwell <nathan@codesourcery.com>
5
6 This file is part of GCC.
7
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
11 version.
12
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
21
22 #include <stdio.h>
23 #include <stdlib.h>
24
25 /* Command line arguments are the base GCC version and the development
26 phase (the latter may be an empty string). */
27
28 int
29 main (int argc, char **argv)
30 {
31 unsigned int version = 0;
32 unsigned char v[4];
33 unsigned int ix;
34 unsigned long major;
35 unsigned long minor = 0;
36 char phase = 0;
37 char *ptr;
38
39 if (argc != 3)
40 {
41 fprintf (stderr, "usage: %s 'version' 'phase'\n", argv[0]);
42 return 1;
43 }
44
45 ptr = argv[1];
46 major = strtoul (ptr, &ptr, 10);
47
48 if (*ptr == '.')
49 minor = strtoul (ptr + 1, 0, 10);
50
51 phase = argv[2][0];
52 if (phase == '\0')
53 phase = '*';
54
55 v[0] = (major < 10 ? '0' : 'A' - 10) + major;
56 v[1] = (minor / 10) + '0';
57 v[2] = (minor % 10) + '0';
58 v[3] = phase;
59
60 for (ix = 0; ix != 4; ix++)
61 version = (version << 8) | v[ix];
62
63 printf ("/* Generated automatically by the program `%s'\n", argv[0]);
64 printf (" from `%s (%lu %lu) and %s (%c)'. */\n",
65 argv[1], major, minor, argv[2], phase);
66 printf ("\n");
67 printf ("#define GCOV_VERSION ((gcov_unsigned_t)0x%08x) /* %.4s */\n",
68 version, v);
69
70 return 0;
71 }
This page took 0.051536 seconds and 6 git commands to generate.