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