]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/genversion.cc
combine: Fix ICE in try_combine on pr112494.c [PR112560]
[thirdparty/gcc.git] / gcc / genversion.cc
CommitLineData
e3a682f4 1/* Generate version strings. See gcov-io.h for
4977bab6 2 description of how the version string is generated.
a945c346 3 Copyright (C) 2002-2024 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
e3a682f4 29main (void)
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;
e3a682f4
ML
37 char basever[] = BASEVER;
38 char *ptr = basever;
4977bab6 39
a1286ef5
ZW
40 major = strtoul (ptr, &ptr, 10);
41
42 if (*ptr == '.')
43 minor = strtoul (ptr + 1, 0, 10);
44
e196f4b7
RG
45 /* For releases the development phase is an empty string, for
46 prerelease versions on a release branch it is "prerelease".
47 Consider both equal as patch-level releases do not change
48 the GCOV version either.
49 On the trunk the development phase is "experimental". */
e3a682f4 50 phase = DEVPHASE[0];
e196f4b7 51 if (phase == '\0'
e3a682f4 52 || strcmp (DEVPHASE, "prerelease") == 0)
a1286ef5 53 phase = '*';
4977bab6 54
e9e4348d
ML
55 v[0] = (major / 10) + 'A';
56 v[1] = (major % 10) + '0';
57 v[2] = minor + '0';
a1286ef5 58 v[3] = phase;
1d088dee 59
4977bab6
ZW
60 for (ix = 0; ix != 4; ix++)
61 version = (version << 8) | v[ix];
62
e3a682f4
ML
63 printf ("#ifndef VERSION_H\n");
64 printf ("#define VERSION_H\n\n");
65 printf ("/* Generated automatically by genversion. */\n");
4977bab6 66 printf ("\n");
e3a682f4
ML
67 printf ("#define GCC_major_version %lu\n\n", major);
68
69 printf ("/* The complete version string, assembled from several pieces.\n"
70 "BASEVER, DATESTAMP, DEVPHASE, and REVISION are defined by the\n"
71 "Makefile. */\n\n");
72
73 printf ("#define version_string \"" BASEVER DATESTAMP DEVPHASE REVISION "\"\n");
74 printf ("#define pkgversion_string \"" PKGVERSION "\"\n\n");
75
76 printf ("/* This is the location of the online document giving instructions for\n"
77 "reporting bugs. If you distribute a modified version of GCC,\n"
78 "please configure with --with-bugurl pointing to a document giving\n"
79 "instructions for reporting bugs to you, not us. (You are of course\n"
80 "welcome to forward us bugs reported to you, if you determine that\n"
81 "they are not bugs in your modifications.) */\n\n");
82 printf ("#define bug_report_url \"" BUGURL "\"\n\n");
83
7c393241 84 printf ("#define GCOV_VERSION ((gcov_unsigned_t)0x%08x) /* %.4s */\n",
4977bab6 85 version, v);
e3a682f4 86 printf ("\n#endif /* VERSION_H */\n");
1d088dee 87
4977bab6
ZW
88 return 0;
89}