/* Set up combined include path chain for the preprocessor.
Copyright (C) 1986, 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
- 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+ 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
Broken out of cppinit.c and cppfiles.c and rewritten Mar 2003.
#include "config.h"
#include "system.h"
#include "coretypes.h"
+#include "machmode.h"
+#include "target.h"
#include "tm.h"
#include "cpplib.h"
#include "prefix.h"
static void add_env_var_paths (const char *, int);
static void add_standard_paths (const char *, const char *, int);
-static void free_path (struct cpp_path *, int);
+static void free_path (struct cpp_dir *, int);
static void merge_include_chains (cpp_reader *, int);
-static struct cpp_path *remove_duplicates (cpp_reader *, struct cpp_path *,
- struct cpp_path *,
- struct cpp_path *, int);
+static struct cpp_dir *remove_duplicates (cpp_reader *, struct cpp_dir *,
+ struct cpp_dir *,
+ struct cpp_dir *, int);
/* Include chains heads and tails. */
-static struct cpp_path *heads[4];
-static struct cpp_path *tails[4];
+static struct cpp_dir *heads[4];
+static struct cpp_dir *tails[4];
static bool quote_ignores_source_dir;
enum { REASON_QUIET = 0, REASON_NOENT, REASON_DUP, REASON_DUP_SYS };
/* Free an element of the include chain, possibly giving a reason. */
static void
-free_path (struct cpp_path *path, int reason)
+free_path (struct cpp_dir *path, int reason)
{
switch (reason)
{
JOIN, unless it duplicates JOIN in which case the last path is
removed. Return the head of the resulting chain. Any of HEAD,
JOIN and SYSTEM can be NULL. */
-static struct cpp_path *
-remove_duplicates (cpp_reader *pfile, struct cpp_path *head,
- struct cpp_path *system, struct cpp_path *join,
+static struct cpp_dir *
+remove_duplicates (cpp_reader *pfile, struct cpp_dir *head,
+ struct cpp_dir *system, struct cpp_dir *join,
int verbose)
{
- struct cpp_path **pcur, *tmp, *cur;
+ struct cpp_dir **pcur, *tmp, *cur;
struct stat st;
for (pcur = &head; *pcur; )
int reason = REASON_QUIET;
cur = *pcur;
- cpp_simplify_path (cur->name);
if (stat (cur->name, &st))
{
/* Dirs that don't exist are silently ignored, unless verbose. */
if (errno != ENOENT)
- cpp_errno (pfile, DL_ERROR, cur->name);
+ cpp_errno (pfile, CPP_DL_ERROR, cur->name);
else
reason = REASON_NOENT;
}
else if (!S_ISDIR (st.st_mode))
- cpp_error_with_line (pfile, DL_ERROR, 0, 0,
+ cpp_error_with_line (pfile, CPP_DL_ERROR, 0, 0,
"%s: not a directory", cur->name);
else
{
if (!tmp)
{
- /* Dupicate of something earlier in the same chain? */
+ /* Duplicate of something earlier in the same chain? */
reason = REASON_DUP;
for (tmp = head; tmp != cur; tmp = tmp->next)
if (INO_T_EQ (cur->ino, tmp->ino) && cur->dev == tmp->dev)
/* If verbose, print the list of dirs to search. */
if (verbose)
{
- struct cpp_path *p;
+ struct cpp_dir *p;
fprintf (stderr, _("#include \"...\" search starts here:\n"));
for (p = heads[QUOTE];; p = p->next)
quote_ignores_source_dir = true;
}
+/* Add P to the chain specified by CHAIN. */
+
+void
+add_cpp_dir_path (cpp_dir *p, int chain)
+{
+ if (tails[chain])
+ tails[chain]->next = p;
+ else
+ heads[chain] = p;
+ tails[chain] = p;
+}
+
/* Add PATH to the include chain CHAIN. PATH must be malloc-ed and
NUL-terminated. */
void
add_path (char *path, int chain, int cxx_aware)
{
- struct cpp_path *p;
+ cpp_dir *p;
- p = (struct cpp_path *) xmalloc (sizeof (struct cpp_path));
+ p = xmalloc (sizeof (cpp_dir));
p->next = NULL;
p->name = path;
if (chain == SYSTEM || chain == AFTER)
p->sysp = 1 + !cxx_aware;
else
p->sysp = 0;
+ p->construct = 0;
if (tails[chain])
tails[chain]->next = p;
if (stdinc)
add_standard_paths (sysroot, iprefix, cxx_stdinc);
+ target_c_incpath.extra_includes (stdinc);
+
merge_include_chains (pfile, verbose);
cpp_set_include_chains (pfile, heads[QUOTE], heads[BRACKET],
quote_ignores_source_dir);
}
+
+#ifndef TARGET_EXTRA_INCLUDES
+static void hook_void_int(int u ATTRIBUTE_UNUSED) { }
+
+struct target_c_incpath_s target_c_incpath = { hook_void_int };
+#endif