Debian Codegraph @

gcc/m2/gm2-gcc/m2configure.cc

raw
1 /* m2configure.cc provides an interface to some configuration values.
2
3 Copyright (C) 2022-2025 Free Software Foundation, Inc.
4 Contributed by Gaius Mulley <[email protected]>.
5
6 This file is part of GNU Modula-2.
7
8 GNU Modula-2 is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
11 any later version.
12
13 GNU Modula-2 is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with GNU Modula-2; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
21
22 #include "config.h"
23 #include "system.h"
24 #include "libiberty.h"
25
26 #include "gcc-consolidation.h"
27
28 #include "../gm2-lang.h"
29 #include "../m2-tree.h"
30 #include "m2convert.h"
31
32 /* Prototypes. */
33
34 #define m2configure_c
35
36 #include "m2assert.h"
37 #include "m2builtins.h"
38 #include "m2convert.h"
39 #include "m2decl.h"
40 #include "m2expr.h"
41 #include "m2options.h"
42 #include "m2configure.h"
43
44 #include "m2/gm2version.h"
45 #include "m2/gm2config.h"
46
47 #define CPPPROGRAM "cc1"
48
49
50 /* gen_gm2_libexec returns a string containing libexec /
51 DEFAULT_TARGET_MACHINE string / DEFAULT_TARGET_MACHINE. */
52
53 static char *
54 gen_gm2_libexec (const char *libexec)
55 {
56 int l = strlen (libexec) + 1 + strlen (DEFAULT_TARGET_MACHINE) + 1
57 + strlen (DEFAULT_TARGET_VERSION) + 1;
58 char *s = (char *)xmalloc (l);
59 char dir_sep[2];
60
61 dir_sep[0] = DIR_SEPARATOR;
62 dir_sep[1] = (char)0;
63
64 strcpy (s, libexec);
65 strcat (s, dir_sep);
66 strcat (s, DEFAULT_TARGET_MACHINE);
67 strcat (s, dir_sep);
68 strcat (s, DEFAULT_TARGET_VERSION);
69 return s;
70 }
71
72 /* FullPathCPP returns the fullpath and program name to cpp. */
73
74 char *
75 m2configure_FullPathCPP (void)
76 {
77 if (M2Options_GetCpp ())
78 {
79 char *path = (char *) M2Options_GetB ();
80
81 if (path == NULL)
82 path = gen_gm2_libexec (STANDARD_LIBEXEC_PREFIX);
83
84 if (strcmp (path, "") == 0)
85 return xstrdup (CPPPROGRAM);
86
87 char *full = (char *)xmalloc (strlen (path) + 1 + strlen (CPPPROGRAM) + 1);
88 strcpy (full, path);
89 char *sep = (char *)alloca (2);
90 sep[0] = DIR_SEPARATOR;
91 sep[1] = (char)0;
92 strcat (full, sep);
93 strcat (full, CPPPROGRAM);
94 return full;
95 }
96 return NULL;
97 }
98
99 /* Return the value of TARGET_IEEEQUAD_DEFAULT. If it is undefined
100 -1 is returned. A value of 0 indicates the default target long
101 double uses the IBM 128 representation. A value of 1 indicates
102 the default target long double (LONGREAL) is __float128. */
103
104 int
105 m2configure_TargetIEEEQuadDefault (void)
106 {
107 #ifdef TARGET_IEEEQUAD_DEFAULT
108 return TARGET_IEEEQUAD_DEFAULT;
109 #else
110 return -1;
111 #endif
112 }