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