xref: /netbsd-src/external/gpl3/gcc.old/dist/gcc/cppdefault.c (revision 8feb0f0b7eaff0608f8350bbfa3098827b4bb91b)
11debfc3dSmrg /* CPP Library.
2*8feb0f0bSmrg    Copyright (C) 1986-2020 Free Software Foundation, Inc.
31debfc3dSmrg    Contributed by Per Bothner, 1994-95.
41debfc3dSmrg    Based on CCCP program by Paul Rubin, June 1986
51debfc3dSmrg    Adapted to ANSI C, Richard Stallman, Jan 1987
61debfc3dSmrg 
71debfc3dSmrg    This program is free software; you can redistribute it and/or modify it
81debfc3dSmrg    under the terms of the GNU General Public License as published by the
91debfc3dSmrg    Free Software Foundation; either version 3, or (at your option) any
101debfc3dSmrg    later version.
111debfc3dSmrg 
121debfc3dSmrg    This program is distributed in the hope that it will be useful,
131debfc3dSmrg    but WITHOUT ANY WARRANTY; without even the implied warranty of
141debfc3dSmrg    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
151debfc3dSmrg    GNU General Public License for more details.
161debfc3dSmrg 
171debfc3dSmrg    You should have received a copy of the GNU General Public License
181debfc3dSmrg    along with this program; see the file COPYING3.  If not see
191debfc3dSmrg    <http://www.gnu.org/licenses/>.  */
201debfc3dSmrg 
211debfc3dSmrg #include "config.h"
221debfc3dSmrg #include "system.h"
231debfc3dSmrg #include "coretypes.h"
241debfc3dSmrg #include "tm.h"
251debfc3dSmrg #include "cppdefault.h"
261debfc3dSmrg 
271debfc3dSmrg #ifndef NATIVE_SYSTEM_HEADER_COMPONENT
281debfc3dSmrg #define NATIVE_SYSTEM_HEADER_COMPONENT 0
291debfc3dSmrg #endif
301debfc3dSmrg 
311debfc3dSmrg #if defined (CROSS_DIRECTORY_STRUCTURE) && !defined (TARGET_SYSTEM_ROOT)
321debfc3dSmrg # undef LOCAL_INCLUDE_DIR
331debfc3dSmrg # undef NATIVE_SYSTEM_HEADER_DIR
341debfc3dSmrg #else
351debfc3dSmrg # undef CROSS_INCLUDE_DIR
361debfc3dSmrg #endif
371debfc3dSmrg 
381debfc3dSmrg const struct default_include cpp_include_defaults[]
391debfc3dSmrg #ifdef INCLUDE_DEFAULTS
401debfc3dSmrg = INCLUDE_DEFAULTS;
411debfc3dSmrg #else
421debfc3dSmrg = {
431debfc3dSmrg #ifdef GPLUSPLUS_INCLUDE_DIR
441debfc3dSmrg     /* Pick up GNU C++ generic include files.  */
451debfc3dSmrg     { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1,
461debfc3dSmrg       GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 },
471debfc3dSmrg #endif
481debfc3dSmrg #ifdef GPLUSPLUS_TOOL_INCLUDE_DIR
491debfc3dSmrg     /* Pick up GNU C++ target-dependent include files.  */
501debfc3dSmrg     { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1,
511debfc3dSmrg       GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 1 },
521debfc3dSmrg #endif
531debfc3dSmrg #ifdef GPLUSPLUS_BACKWARD_INCLUDE_DIR
541debfc3dSmrg     /* Pick up GNU C++ backward and deprecated include files.  */
551debfc3dSmrg     { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1,
561debfc3dSmrg       GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 },
571debfc3dSmrg #endif
581debfc3dSmrg #ifdef GCC_INCLUDE_DIR
591debfc3dSmrg #ifndef GCC_INCLUDE_DIR_ADD_SYSROOT
601debfc3dSmrg #define GCC_INCLUDE_DIR_ADD_SYSROOT 0
611debfc3dSmrg #endif
621debfc3dSmrg     /* This is the dir for gcc's private headers.  */
631debfc3dSmrg     { GCC_INCLUDE_DIR, "GCC", 0, 0,
641debfc3dSmrg       GCC_INCLUDE_DIR_ADD_SYSROOT, 0 },
651debfc3dSmrg #endif
661debfc3dSmrg #ifdef LOCAL_INCLUDE_DIR
671debfc3dSmrg     /* /usr/local/include comes before the fixincluded header files.  */
681debfc3dSmrg     { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 2 },
691debfc3dSmrg     { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 0 },
701debfc3dSmrg #endif
711debfc3dSmrg #ifdef PREFIX_INCLUDE_DIR
721debfc3dSmrg     { PREFIX_INCLUDE_DIR, 0, 0, 1, 0, 0 },
731debfc3dSmrg #endif
741debfc3dSmrg #ifdef FIXED_INCLUDE_DIR
751debfc3dSmrg     /* This is the dir for fixincludes.  */
761debfc3dSmrg     { FIXED_INCLUDE_DIR, "GCC", 0, 0, 0,
771debfc3dSmrg       /* A multilib suffix needs adding if different multilibs use
781debfc3dSmrg 	 different headers.  */
791debfc3dSmrg #ifdef SYSROOT_HEADERS_SUFFIX_SPEC
801debfc3dSmrg       1
811debfc3dSmrg #else
821debfc3dSmrg       0
831debfc3dSmrg #endif
841debfc3dSmrg     },
851debfc3dSmrg #endif
861debfc3dSmrg #ifdef CROSS_INCLUDE_DIR
871debfc3dSmrg     /* One place the target system's headers might be.  */
881debfc3dSmrg     { CROSS_INCLUDE_DIR, "GCC", 0, 0, 0, 0 },
891debfc3dSmrg #endif
901debfc3dSmrg #ifdef TOOL_INCLUDE_DIR
911debfc3dSmrg     /* Another place the target system's headers might be.  */
921debfc3dSmrg     { TOOL_INCLUDE_DIR, "BINUTILS", 0, 1, 0, 0 },
931debfc3dSmrg #endif
941debfc3dSmrg #ifdef NATIVE_SYSTEM_HEADER_DIR
951debfc3dSmrg     /* /usr/include comes dead last.  */
961debfc3dSmrg     { NATIVE_SYSTEM_HEADER_DIR, NATIVE_SYSTEM_HEADER_COMPONENT, 0, 0, 1, 2 },
971debfc3dSmrg     { NATIVE_SYSTEM_HEADER_DIR, NATIVE_SYSTEM_HEADER_COMPONENT, 0, 0, 1, 0 },
981debfc3dSmrg #endif
991debfc3dSmrg     { 0, 0, 0, 0, 0, 0 }
1001debfc3dSmrg   };
1011debfc3dSmrg #endif /* no INCLUDE_DEFAULTS */
1021debfc3dSmrg 
1031debfc3dSmrg #ifdef GCC_INCLUDE_DIR
1041debfc3dSmrg const char cpp_GCC_INCLUDE_DIR[] = GCC_INCLUDE_DIR;
1051debfc3dSmrg const size_t cpp_GCC_INCLUDE_DIR_len = sizeof GCC_INCLUDE_DIR - 8;
1061debfc3dSmrg #else
1071debfc3dSmrg const char cpp_GCC_INCLUDE_DIR[] = "";
1081debfc3dSmrg const size_t cpp_GCC_INCLUDE_DIR_len = 0;
1091debfc3dSmrg #endif
1101debfc3dSmrg 
1111debfc3dSmrg /* The configured prefix.  */
1121debfc3dSmrg const char cpp_PREFIX[] = PREFIX;
1131debfc3dSmrg const size_t cpp_PREFIX_len = sizeof PREFIX - 1;
1141debfc3dSmrg const char cpp_EXEC_PREFIX[] = STANDARD_EXEC_PREFIX;
1151debfc3dSmrg 
1161debfc3dSmrg /* This value is set by cpp_relocated at runtime */
1171debfc3dSmrg const char *gcc_exec_prefix;
1181debfc3dSmrg 
1191debfc3dSmrg /* Return true if the toolchain is relocated.  */
1201debfc3dSmrg bool
cpp_relocated(void)1211debfc3dSmrg cpp_relocated (void)
1221debfc3dSmrg {
1231debfc3dSmrg   static int relocated = -1;
1241debfc3dSmrg 
1251debfc3dSmrg   /* A relocated toolchain ignores standard include directories.  */
1261debfc3dSmrg   if (relocated == -1)
1271debfc3dSmrg     {
1281debfc3dSmrg       /* Check if the toolchain was relocated?  */
1291debfc3dSmrg       gcc_exec_prefix = getenv ("GCC_EXEC_PREFIX");
1301debfc3dSmrg       if (gcc_exec_prefix)
1311debfc3dSmrg        relocated = 1;
1321debfc3dSmrg       else
1331debfc3dSmrg        relocated = 0;
1341debfc3dSmrg     }
1351debfc3dSmrg 
1361debfc3dSmrg   return relocated;
1371debfc3dSmrg }
138