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