* support/cpp/output.h, support/cpp/opts-common.c,
[fw/sdcc] / support / cpp / cppdefault.c
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 "cppdefault.h"
25
26 #ifndef STANDARD_INCLUDE_DIR
27 #define STANDARD_INCLUDE_DIR "/usr/include"
28 #endif
29
30 #ifndef STANDARD_INCLUDE_COMPONENT
31 #define STANDARD_INCLUDE_COMPONENT 0
32 #endif
33
34 #if defined (CROSS_DIRECTORY_STRUCTURE) && !defined (TARGET_SYSTEM_ROOT)
35 # undef LOCAL_INCLUDE_DIR
36 # undef SYSTEM_INCLUDE_DIR
37 # undef STANDARD_INCLUDE_DIR
38 #else
39 # undef CROSS_INCLUDE_DIR
40 #endif
41
42 const struct default_include cpp_include_defaults[]
43 #ifdef INCLUDE_DEFAULTS
44 = INCLUDE_DEFAULTS;
45 #else
46 = {
47 #ifdef GPLUSPLUS_INCLUDE_DIR
48     /* Pick up GNU C++ generic include files.  */
49     { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, 0, 0 },
50 #endif
51 #ifdef GPLUSPLUS_TOOL_INCLUDE_DIR
52     /* Pick up GNU C++ target-dependent include files.  */
53     { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1, 0, 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, 0, 0 },
58 #endif
59 #ifdef LOCAL_INCLUDE_DIR
60     /* /usr/local/include comes before the fixincluded header files.  */
61     { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 0 },
62 #endif
63 #ifdef PREFIX_INCLUDE_DIR
64     { PREFIX_INCLUDE_DIR, 0, 0, 1, 0, 0 },
65 #endif
66 #ifdef GCC_INCLUDE_DIR
67     /* This is the dir for gcc's private headers.  */
68     { GCC_INCLUDE_DIR, "GCC", 0, 0, 0, 0 },
69 #endif
70 #ifdef FIXED_INCLUDE_DIR
71     /* This is the dir for fixincludes.  */
72     { FIXED_INCLUDE_DIR, "GCC", 0, 0, 0,
73       /* A multilib suffix needs adding if different multilibs use
74          different headers.  */
75 #ifdef SYSROOT_HEADERS_SUFFIX_SPEC
76       1
77 #else
78       0
79 #endif
80     },
81 #endif
82 #ifdef CROSS_INCLUDE_DIR
83     /* One place the target system's headers might be.  */
84     { CROSS_INCLUDE_DIR, "GCC", 0, 0, 0, 0 },
85 #endif
86 #ifdef TOOL_INCLUDE_DIR
87     /* Another place the target system's headers might be.  */
88     { TOOL_INCLUDE_DIR, "BINUTILS", 0, 1, 0, 0 },
89 #endif
90 #ifdef SYSTEM_INCLUDE_DIR
91     /* Some systems have an extra dir of include files.  */
92     { SYSTEM_INCLUDE_DIR, 0, 0, 0, 1, 0 },
93 #endif
94 #ifdef STANDARD_INCLUDE_DIR
95     /* /usr/include comes dead last.  */
96     { STANDARD_INCLUDE_DIR, STANDARD_INCLUDE_COMPONENT, 0, 0, 1, 0 },
97 #endif
98     { 0, 0, 0, 0, 0, 0 }
99   };
100 #endif /* no INCLUDE_DEFAULTS */
101
102 #ifdef GCC_INCLUDE_DIR
103 const char cpp_GCC_INCLUDE_DIR[] = GCC_INCLUDE_DIR;
104 const size_t cpp_GCC_INCLUDE_DIR_len = sizeof GCC_INCLUDE_DIR - 8;
105 #else
106 const char cpp_GCC_INCLUDE_DIR[] = "";
107 const size_t cpp_GCC_INCLUDE_DIR_len = 0;
108 #endif
109
110 #if 0
111 /* The configured prefix.  */
112 const char cpp_PREFIX[] = PREFIX;
113 const size_t cpp_PREFIX_len = sizeof PREFIX - 1;
114 const char cpp_EXEC_PREFIX[] = STANDARD_EXEC_PREFIX;
115
116 /* This value is set by cpp_relocated at runtime */
117 const char *gcc_exec_prefix;
118
119 /* Return true if the toolchain is relocated.  */
120 bool
121 cpp_relocated (void)
122 {
123   static int relocated = -1;
124
125   /* A relocated toolchain ignores standard include directories.  */
126   if (relocated == -1)
127     {
128       /* Check if the toolchain was relocated?  */
129       GET_ENVIRONMENT (gcc_exec_prefix, "GCC_EXEC_PREFIX");
130       if (gcc_exec_prefix)
131        relocated = 1;
132       else
133        relocated = 0;
134     }
135
136   return relocated;
137 }
138 #endif