]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/gcov-iov.c
[Ada] Improved support for aspect alignment in CCG
[thirdparty/gcc.git] / gcc / gcov-iov.c
CommitLineData
4977bab6
ZW
1/* Generate gcov version string from version.c. See gcov-io.h for
2 description of how the version string is generated.
8d9254fc 3 Copyright (C) 2002-2020 Free Software Foundation, Inc.
4977bab6 4 Contributed by Nathan Sidwell <nathan@codesourcery.com>
1d088dee 5
4977bab6
ZW
6This file is part of GCC.
7
8GCC is free software; you can redistribute it and/or modify it under
9the terms of the GNU General Public License as published by the Free
9dcd6f09 10Software Foundation; either version 3, or (at your option) any later
4977bab6
ZW
11version.
12
13GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14WARRANTY; without even the implied warranty of MERCHANTABILITY or
15FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16for more details.
17
18You should have received a copy of the GNU General Public License
9dcd6f09
NC
19along with GCC; see the file COPYING3. If not see
20<http://www.gnu.org/licenses/>. */
4977bab6 21
de703cd7
RG
22#include "bconfig.h"
23#include "system.h"
4977bab6 24
a1286ef5
ZW
25/* Command line arguments are the base GCC version and the development
26 phase (the latter may be an empty string). */
4977bab6
ZW
27
28int
a1286ef5 29main (int argc, char **argv)
4977bab6 30{
a1286ef5 31 unsigned int version = 0;
4977bab6 32 unsigned char v[4];
a1286ef5
ZW
33 unsigned int ix;
34 unsigned long major;
35 unsigned long minor = 0;
36 char phase = 0;
37 char *ptr;
4977bab6 38
a1286ef5
ZW
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
e196f4b7
RG
51 /* For releases the development phase is an empty string, for
52 prerelease versions on a release branch it is "prerelease".
53 Consider both equal as patch-level releases do not change
54 the GCOV version either.
55 On the trunk the development phase is "experimental". */
a1286ef5 56 phase = argv[2][0];
e196f4b7
RG
57 if (phase == '\0'
58 || strcmp (argv[2], "prerelease") == 0)
a1286ef5 59 phase = '*';
4977bab6 60
e9e4348d
ML
61 v[0] = (major / 10) + 'A';
62 v[1] = (major % 10) + '0';
63 v[2] = minor + '0';
a1286ef5 64 v[3] = phase;
1d088dee 65
4977bab6
ZW
66 for (ix = 0; ix != 4; ix++)
67 version = (version << 8) | v[ix];
68
69 printf ("/* Generated automatically by the program `%s'\n", argv[0]);
a1286ef5
ZW
70 printf (" from `%s (%lu %lu) and %s (%c)'. */\n",
71 argv[1], major, minor, argv[2], phase);
4977bab6 72 printf ("\n");
7c393241 73 printf ("#define GCOV_VERSION ((gcov_unsigned_t)0x%08x) /* %.4s */\n",
4977bab6 74 version, v);
1d088dee 75
4977bab6
ZW
76 return 0;
77}