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