]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/cppdefault.c
Correct a function pre/postcondition [PR102403].
[thirdparty/gcc.git] / gcc / cppdefault.c
CommitLineData
60893f43 1/* CPP Library.
99dee823 2 Copyright (C) 1986-2021 Free Software Foundation, Inc.
60893f43
ZW
3 Contributed by Per Bothner, 1994-95.
4 Based on CCCP program by Paul Rubin, June 1986
5 Adapted to ANSI C, Richard Stallman, Jan 1987
6
9dcd6f09
NC
7 This program is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3, or (at your option) any
10 later version.
60893f43 11
9dcd6f09
NC
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
60893f43 16
9dcd6f09
NC
17 You should have received a copy of the GNU General Public License
18 along with this program; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
60893f43 20
60893f43
ZW
21#include "config.h"
22#include "system.h"
4977bab6
ZW
23#include "coretypes.h"
24#include "tm.h"
60893f43
ZW
25#include "cppdefault.h"
26
08b2bad2
SB
27#ifndef NATIVE_SYSTEM_HEADER_COMPONENT
28#define NATIVE_SYSTEM_HEADER_COMPONENT 0
5793b276
NB
29#endif
30
2989d30c 31#if defined (CROSS_DIRECTORY_STRUCTURE) && !defined (TARGET_SYSTEM_ROOT)
5793b276 32# undef LOCAL_INCLUDE_DIR
859ed2a7 33# undef NATIVE_SYSTEM_HEADER_DIR
5793b276
NB
34#else
35# undef CROSS_INCLUDE_DIR
36#endif
37
60893f43
ZW
38const struct default_include cpp_include_defaults[]
39#ifdef INCLUDE_DEFAULTS
40= INCLUDE_DEFAULTS;
41#else
42= {
43#ifdef GPLUSPLUS_INCLUDE_DIR
e2187d3b 44 /* Pick up GNU C++ generic include files. */
17719d09
HS
45 { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1,
46 GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 },
60893f43 47#endif
e2187d3b
BK
48#ifdef GPLUSPLUS_TOOL_INCLUDE_DIR
49 /* Pick up GNU C++ target-dependent include files. */
17719d09
HS
50 { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1,
51 GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 1 },
e2187d3b 52#endif
98c2359b
BK
53#ifdef GPLUSPLUS_BACKWARD_INCLUDE_DIR
54 /* Pick up GNU C++ backward and deprecated include files. */
17719d09
HS
55 { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1,
56 GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 },
98c2359b 57#endif
662b9c55
IS
58#ifdef GPLUSPLUS_LIBCXX_INCLUDE_DIR
59 /* Pick up libc++ include files, if we have -stdlib=libc++. */
60 { GPLUSPLUS_LIBCXX_INCLUDE_DIR, "G++", 2, 1,
61 GPLUSPLUS_LIBCXX_INCLUDE_DIR_ADD_SYSROOT, 0 },
62#endif
da46381f
KT
63#ifdef GCC_INCLUDE_DIR
64 /* This is the dir for gcc's private headers. */
65 { GCC_INCLUDE_DIR, "GCC", 0, 0, 0, 0 },
66#endif
60893f43
ZW
67#ifdef LOCAL_INCLUDE_DIR
68 /* /usr/local/include comes before the fixincluded header files. */
e0cdc09f 69 { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 2 },
2b6dd222 70 { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 0 },
60893f43 71#endif
793e9558 72#ifdef PREFIX_INCLUDE_DIR
2b6dd222 73 { PREFIX_INCLUDE_DIR, 0, 0, 1, 0, 0 },
793e9558 74#endif
f686ec05
JM
75#ifdef FIXED_INCLUDE_DIR
76 /* This is the dir for fixincludes. */
14da6073
JM
77 { FIXED_INCLUDE_DIR, "GCC", 0, 0, 0,
78 /* A multilib suffix needs adding if different multilibs use
79 different headers. */
80#ifdef SYSROOT_HEADERS_SUFFIX_SPEC
81 1
82#else
83 0
84#endif
85 },
f686ec05 86#endif
60893f43
ZW
87#ifdef CROSS_INCLUDE_DIR
88 /* One place the target system's headers might be. */
2b6dd222 89 { CROSS_INCLUDE_DIR, "GCC", 0, 0, 0, 0 },
60893f43
ZW
90#endif
91#ifdef TOOL_INCLUDE_DIR
92 /* Another place the target system's headers might be. */
2b6dd222 93 { TOOL_INCLUDE_DIR, "BINUTILS", 0, 1, 0, 0 },
60893f43 94#endif
859ed2a7 95#ifdef NATIVE_SYSTEM_HEADER_DIR
60893f43 96 /* /usr/include comes dead last. */
e0cdc09f 97 { NATIVE_SYSTEM_HEADER_DIR, NATIVE_SYSTEM_HEADER_COMPONENT, 0, 0, 1, 2 },
08b2bad2 98 { NATIVE_SYSTEM_HEADER_DIR, NATIVE_SYSTEM_HEADER_COMPONENT, 0, 0, 1, 0 },
859ed2a7 99#endif
2b6dd222 100 { 0, 0, 0, 0, 0, 0 }
60893f43
ZW
101 };
102#endif /* no INCLUDE_DEFAULTS */
103
104#ifdef GCC_INCLUDE_DIR
105const char cpp_GCC_INCLUDE_DIR[] = GCC_INCLUDE_DIR;
106const size_t cpp_GCC_INCLUDE_DIR_len = sizeof GCC_INCLUDE_DIR - 8;
107#else
108const char cpp_GCC_INCLUDE_DIR[] = "";
109const size_t cpp_GCC_INCLUDE_DIR_len = 0;
110#endif
76642aab
CD
111
112/* The configured prefix. */
113const char cpp_PREFIX[] = PREFIX;
114const size_t cpp_PREFIX_len = sizeof PREFIX - 1;
6d4817e3 115const char cpp_EXEC_PREFIX[] = STANDARD_EXEC_PREFIX;
76642aab
CD
116
117/* This value is set by cpp_relocated at runtime */
118const char *gcc_exec_prefix;
119
120/* Return true if the toolchain is relocated. */
121bool
122cpp_relocated (void)
123{
124 static int relocated = -1;
125
126 /* A relocated toolchain ignores standard include directories. */
127 if (relocated == -1)
128 {
129 /* Check if the toolchain was relocated? */
71f3e391 130 gcc_exec_prefix = getenv ("GCC_EXEC_PREFIX");
76642aab
CD
131 if (gcc_exec_prefix)
132 relocated = 1;
133 else
134 relocated = 0;
135 }
136
137 return relocated;
138}