Makefile.in (PREPROCESSOR_DEFINES): Add @TARGET_SYSTEM_ROOT_DEFINE@.

* Makefile.in (PREPROCESSOR_DEFINES): Add
	@TARGET_SYSTEM_ROOT_DEFINE@.
	* configure.in (PREFIX_INCLUDE_DIR): Don't define if $with_sysroot
	is specified or if building a cross compiler.
	(TARGET_SYSTEM_ROOT_DEFINE): Add TARGET_SYSTEM_ROOT_RELOCATABLE
	if the sysroot is under $exec_prefix.
	* configure: Regenerated.
	* cppdefault.h: Use native include paths if TARGET_SYSTEM_ROOT is
	defined.
	(struct default_include): Add add_sysroot field.
	(cpp_SYSROOT): Declare.
	* cppdefault.c (cpp_include_defaults): Fill in add_sysroot
	field.
	(cpp_SYSROOT): New variable.
	* cppinit.c (cpp_create_reader): Initialize
	CPP_OPTION (pfile, sysroot).
	(init_standard_includes): Handle add_sysroot.  Do not
	add unrelocated copies of relocated directories.
	(COMMAND_LINE_OPTIONS): Add -isysroot.
	(cpp_handle_option): Handle -isysroot.
	* cpplib.h (struct cpp_options): Add sysroot member.
	* gcc.c (The Specs Language): Update description of %I.
	(target_system_root_changed): New variable.
	(process_command): Conditionalize make_relative_prefix call
	on !VMS and TARGET_SYSTEM_ROOT_RELOCATABLE.  Set
	target_system_root_changed.
	(do_spec_1): Add -isysroot to %I.
	* doc/invoke.texi (Spec Files): Update description of %I.
	* doc/install.texi (--with-sysroot): Update comment about
	relocation.

From-SVN: r62853
This commit is contained in:
Daniel Jacobowitz 2003-02-13 17:23:56 +00:00 committed by Daniel Jacobowitz
parent 902cf50c93
commit 047d636f54
11 changed files with 427 additions and 316 deletions

View File

@ -1,3 +1,36 @@
2003-02-13 Daniel Jacobowitz <drow@mvista.com>
* Makefile.in (PREPROCESSOR_DEFINES): Add
@TARGET_SYSTEM_ROOT_DEFINE@.
* configure.in (PREFIX_INCLUDE_DIR): Don't define if $with_sysroot
is specified or if building a cross compiler.
(TARGET_SYSTEM_ROOT_DEFINE): Add TARGET_SYSTEM_ROOT_RELOCATABLE
if the sysroot is under $exec_prefix.
* configure: Regenerated.
* cppdefault.h: Use native include paths if TARGET_SYSTEM_ROOT is
defined.
(struct default_include): Add add_sysroot field.
(cpp_SYSROOT): Declare.
* cppdefault.c (cpp_include_defaults): Fill in add_sysroot
field.
(cpp_SYSROOT): New variable.
* cppinit.c (cpp_create_reader): Initialize
CPP_OPTION (pfile, sysroot).
(init_standard_includes): Handle add_sysroot. Do not
add unrelocated copies of relocated directories.
(COMMAND_LINE_OPTIONS): Add -isysroot.
(cpp_handle_option): Handle -isysroot.
* cpplib.h (struct cpp_options): Add sysroot member.
* gcc.c (The Specs Language): Update description of %I.
(target_system_root_changed): New variable.
(process_command): Conditionalize make_relative_prefix call
on !VMS and TARGET_SYSTEM_ROOT_RELOCATABLE. Set
target_system_root_changed.
(do_spec_1): Add -isysroot to %I.
* doc/invoke.texi (Spec Files): Update description of %I.
* doc/install.texi (--with-sysroot): Update comment about
relocation.
2003-02-13 Kazu Hirata <kazu@cs.umass.edu>
* config/h8300/h8300.md (a peephole2): New.

View File

@ -2260,7 +2260,8 @@ PREPROCESSOR_DEFINES = \
-DGPLUSPLUS_BACKWARD_INCLUDE_DIR=\"$(gcc_gxx_include_dir)/backward\" \
-DLOCAL_INCLUDE_DIR=\"$(local_includedir)\" \
-DCROSS_INCLUDE_DIR=\"$(CROSS_SYSTEM_HEADER_DIR)\" \
-DTOOL_INCLUDE_DIR=\"$(gcc_tooldir)/include\"
-DTOOL_INCLUDE_DIR=\"$(gcc_tooldir)/include\" \
@TARGET_SYSTEM_ROOT_DEFINE@
LIBCPP_OBJS = cpplib.o cpplex.o cppmacro.o cppexp.o cppfiles.o cpptrad.o \
cpphash.o cpperror.o cppinit.o cppdefault.o cppmain.o \

529
gcc/configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -496,6 +496,22 @@ AC_ARG_WITH(sysroot,
TARGET_SYSTEM_ROOT_DEFINE='-DTARGET_SYSTEM_ROOT=\"$(TARGET_SYSTEM_ROOT)\"'
CROSS_SYSTEM_HEADER_DIR='$(TARGET_SYSTEM_ROOT)$(NATIVE_SYSTEM_HEADER_DIR)'
if test "x$exec_prefix" = xNONE; then
if test "x$prefix" = xNONE; then
test_prefix=/usr/local
else
test_prefix=$prefix
fi
else
test_prefix=$exec_prefix
fi
case ${TARGET_SYSTEM_ROOT} in
${test_prefix}*)
t="$TARGET_SYSTEM_ROOT_DEFINE -DTARGET_SYSTEM_ROOT_RELOCATABLE"
TARGET_SYSTEM_ROOT_DEFINE="$t"
;;
esac
], [
TARGET_SYSTEM_ROOT=
TARGET_SYSTEM_ROOT_DEFINE='-DTARGET_SYSTEM_ROOT=0'
@ -2410,7 +2426,8 @@ case "$target" in
;;
esac
if test "$prefix" != "/usr" && test "x$prefix" != "x$local_prefix" ; then
if test x$with_sysroot = x && x$host = x$target \
&& test "$prefix" != "/usr" && test "x$prefix" != "x$local_prefix" ; then
AC_DEFINE_UNQUOTED(PREFIX_INCLUDE_DIR, "$prefix/include")
fi

View File

@ -35,44 +35,44 @@ const struct default_include cpp_include_defaults[]
= {
#ifdef GPLUSPLUS_INCLUDE_DIR
/* Pick up GNU C++ generic include files. */
{ GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1 },
{ GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, 0 },
#endif
#ifdef GPLUSPLUS_TOOL_INCLUDE_DIR
/* Pick up GNU C++ target-dependent include files. */
{ GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1 },
{ GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1, 0 },
#endif
#ifdef GPLUSPLUS_BACKWARD_INCLUDE_DIR
/* Pick up GNU C++ backward and deprecated include files. */
{ GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1 },
{ GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1, 0 },
#endif
#ifdef LOCAL_INCLUDE_DIR
/* /usr/local/include comes before the fixincluded header files. */
{ LOCAL_INCLUDE_DIR, 0, 0, 1 },
{ LOCAL_INCLUDE_DIR, 0, 0, 1, 1 },
#endif
#ifdef PREFIX_INCLUDE_DIR
{ PREFIX_INCLUDE_DIR, 0, 0, 1 },
{ PREFIX_INCLUDE_DIR, 0, 0, 1, 0 },
#endif
#ifdef GCC_INCLUDE_DIR
/* This is the dir for fixincludes and for gcc's private headers. */
{ GCC_INCLUDE_DIR, "GCC", 0, 0 },
{ GCC_INCLUDE_DIR, "GCC", 0, 0, 0 },
#endif
#ifdef CROSS_INCLUDE_DIR
/* One place the target system's headers might be. */
{ CROSS_INCLUDE_DIR, "GCC", 0, 0 },
{ CROSS_INCLUDE_DIR, "GCC", 0, 0, 0 },
#endif
#ifdef TOOL_INCLUDE_DIR
/* Another place the target system's headers might be. */
{ TOOL_INCLUDE_DIR, "BINUTILS", 0, 1 },
{ TOOL_INCLUDE_DIR, "BINUTILS", 0, 1, 0 },
#endif
#ifdef SYSTEM_INCLUDE_DIR
/* Some systems have an extra dir of include files. */
{ SYSTEM_INCLUDE_DIR, 0, 0, 0 },
{ SYSTEM_INCLUDE_DIR, 0, 0, 0, 1 },
#endif
#ifdef STANDARD_INCLUDE_DIR
/* /usr/include comes dead last. */
{ STANDARD_INCLUDE_DIR, STANDARD_INCLUDE_COMPONENT, 0, 0 },
{ STANDARD_INCLUDE_DIR, STANDARD_INCLUDE_COMPONENT, 0, 0, 1 },
#endif
{ 0, 0, 0, 0 }
{ 0, 0, 0, 0, 0 }
};
#endif /* no INCLUDE_DEFAULTS */
@ -83,3 +83,9 @@ const size_t cpp_GCC_INCLUDE_DIR_len = sizeof GCC_INCLUDE_DIR - 8;
const char cpp_GCC_INCLUDE_DIR[] = "";
const size_t cpp_GCC_INCLUDE_DIR_len = 0;
#endif
#ifdef TARGET_SYSTEM_ROOT
const char *cpp_SYSROOT = TARGET_SYSTEM_ROOT;
#else
const char *cpp_SYSROOT = "";
#endif

View File

@ -34,12 +34,12 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#define STANDARD_INCLUDE_COMPONENT 0
#endif
#ifdef CROSS_COMPILE
#undef LOCAL_INCLUDE_DIR
#undef SYSTEM_INCLUDE_DIR
#undef STANDARD_INCLUDE_DIR
#if defined (CROSS_COMPILE) && !defined (TARGET_SYSTEM_ROOT)
# undef LOCAL_INCLUDE_DIR
# undef SYSTEM_INCLUDE_DIR
# undef STANDARD_INCLUDE_DIR
#else
#undef CROSS_INCLUDE_DIR
# undef CROSS_INCLUDE_DIR
#endif
/* This is the default list of directories to search for include files.
@ -61,10 +61,14 @@ struct default_include
const int cxx_aware; /* Includes in this directory don't need to
be wrapped in extern "C" when compiling
C++. */
const int add_sysroot; /* FNAME should be prefixed by
cpp_SYSROOT. */
};
extern const struct default_include cpp_include_defaults[];
extern const char cpp_GCC_INCLUDE_DIR[];
extern const size_t cpp_GCC_INCLUDE_DIR_len;
extern const char *cpp_SYSROOT;
#endif /* ! GCC_CPPDEFAULT_H */

View File

@ -529,6 +529,7 @@ cpp_create_reader (lang)
CPP_OPTION (pfile, warn_endif_labels) = 1;
CPP_OPTION (pfile, warn_deprecated) = 1;
CPP_OPTION (pfile, warn_long_long) = !CPP_OPTION (pfile, c99);
CPP_OPTION (pfile, sysroot) = cpp_SYSROOT;
CPP_OPTION (pfile, pending) =
(struct cpp_pending *) xcalloc (1, sizeof (struct cpp_pending));
@ -757,46 +758,26 @@ init_standard_includes (pfile)
{
const struct default_include *p;
const char *specd_prefix = CPP_OPTION (pfile, include_prefix);
int default_len, specd_len;
char *default_prefix;
/* Search "translated" versions of GNU directories.
These have /usr/local/lib/gcc... replaced by specd_prefix. */
default_len = 0;
specd_len = 0;
default_prefix = NULL;
if (specd_prefix != 0 && cpp_GCC_INCLUDE_DIR_len)
{
/* Remove the `include' from /usr/local/lib/gcc.../include.
GCC_INCLUDE_DIR will always end in /include. */
int default_len = cpp_GCC_INCLUDE_DIR_len;
char *default_prefix = (char *) alloca (default_len + 1);
int specd_len = strlen (specd_prefix);
default_len = cpp_GCC_INCLUDE_DIR_len;
default_prefix = (char *) alloca (default_len + 1);
specd_len = strlen (specd_prefix);
memcpy (default_prefix, cpp_GCC_INCLUDE_DIR, default_len);
default_prefix[default_len] = '\0';
for (p = cpp_include_defaults; p->fname; p++)
{
/* Some standard dirs are only for C++. */
if (!p->cplusplus
|| (CPP_OPTION (pfile, cplusplus)
&& !CPP_OPTION (pfile, no_standard_cplusplus_includes)))
{
/* Does this dir start with the prefix? */
if (!strncmp (p->fname, default_prefix, default_len))
{
/* Yes; change prefix and add to search list. */
int flen = strlen (p->fname);
int this_len = specd_len + flen - default_len;
char *str = (char *) xmalloc (this_len + 1);
memcpy (str, specd_prefix, specd_len);
memcpy (str + specd_len,
p->fname + default_len,
flen - default_len + 1);
append_include_chain (pfile, str, SYSTEM, p->cxx_aware);
}
}
}
}
/* Search ordinary names for GNU include directories. */
for (p = cpp_include_defaults; p->fname; p++)
{
/* Some standard dirs are only for C++. */
@ -804,7 +785,30 @@ init_standard_includes (pfile)
|| (CPP_OPTION (pfile, cplusplus)
&& !CPP_OPTION (pfile, no_standard_cplusplus_includes)))
{
char *str = update_path (p->fname, p->component);
char *str;
/* Should this dir start with the sysroot? */
if (p->add_sysroot && CPP_OPTION (pfile, sysroot))
str = concat (CPP_OPTION (pfile, sysroot), p->fname, NULL);
/* Does this dir start with the prefix? */
else if (default_len
&& !strncmp (p->fname, default_prefix, default_len))
{
/* Yes; change prefix and add to search list. */
int flen = strlen (p->fname);
int this_len = specd_len + flen - default_len;
str = (char *) xmalloc (this_len + 1);
memcpy (str, specd_prefix, specd_len);
memcpy (str + specd_len,
p->fname + default_len,
flen - default_len + 1);
}
else
str = update_path (p->fname, p->component);
append_include_chain (pfile, str, SYSTEM, p->cxx_aware);
}
}
@ -1161,6 +1165,7 @@ new_pending_directive (pend, text, handler)
DEF_OPT("imacros", no_fil, OPT_imacros) \
DEF_OPT("include", no_fil, OPT_include) \
DEF_OPT("iprefix", no_pth, OPT_iprefix) \
DEF_OPT("isysroot", no_dir, OPT_isysroot) \
DEF_OPT("isystem", no_dir, OPT_isystem) \
DEF_OPT("iwithprefix", no_dir, OPT_iwithprefix) \
DEF_OPT("iwithprefixbefore", no_dir, OPT_iwithprefixbefore)
@ -1305,6 +1310,10 @@ cpp_handle_option (pfile, argc, argv)
CPP_OPTION (pfile, include_prefix_len) = strlen (arg);
break;
case OPT_isysroot:
CPP_OPTION (pfile, sysroot) = arg;
break;
case OPT_A:
if (arg[0] == '-')
{

View File

@ -237,6 +237,10 @@ struct cpp_options
const char *include_prefix;
unsigned int include_prefix_len;
/* Directory prefix for system include directories in the standard search
path. */
const char *sysroot;
/* The language we're preprocessing. */
enum c_lang lang;

View File

@ -906,16 +906,9 @@ searched in there. The specified directory is not copied into the
install tree, unlike the options @option{--with-headers} and
@option{--with-libs} that this option obsoletes. The default value,
in case @option{--with-sysroot} is not given an argument, is
@option{$@{gcc_tooldir@}/sys-root}. Starting the pathname with
@option{$@{gcc_tooldir@}/}, in such a way that this variable is not
expanded by the shell, but rather by the gcc Makefile, enables the
target sysroot directory to be relocatable along with the entire
install tree, but it will require the gcc tool directory to be created
@emph{before} the build is started. This directory, as well as its
intermediate pathnames, can be easily created by running @command{make
install-gcc-tooldir} the gcc build directory. This is not done
automatically to avoid touching the install tree without explicit
permission.
@option{$@{gcc_tooldir@}/sys-root}. If the specified directory is a
subdirectory of @option{$@{exec_prefix@}}, then it will be found relative to
the GCC binaries if the installation tree is moved.
@item --with-headers
@itemx --with-headers=@var{dir}

View File

@ -5088,7 +5088,10 @@ predefined macro, except for macros that start with @samp{__} or with
C@.
@item %I
Substitute a @option{-iprefix} option made from @env{GCC_EXEC_PREFIX}.
Substitute any of @option{-iprefix} (made from @env{GCC_EXEC_PREFIX}),
@option{-isysroot} (made from @env{TARGET_SYSTEM_ROOT}), and
@option{-isystem} (made from @env{COMPILER_PATH} and @option{-B} options)
as necessary.
@item %s
Current argument is the name of a library or startup file of some sort.

View File

@ -204,6 +204,10 @@ static int report_times;
static const char *target_system_root = TARGET_SYSTEM_ROOT;
/* Nonzero means pass the updated target_system_root to the compiler. */
static int target_system_root_changed;
/* Nonzero means write "temp" files in source directory
and use the source file's name in them, and don't delete them. */
@ -445,7 +449,9 @@ or with constant text in a single argument.
%P like %p, but puts `__' before and after the name of each macro.
(Except macros that already have __.)
This is for ANSI C.
%I Substitute a -iprefix option made from GCC_EXEC_PREFIX.
%I Substitute any of -iprefix (made from GCC_EXEC_PREFIX), -isysroot
(made from TARGET_SYSTEM_ROOT), and -isystem (made from COMPILER_PATH
and -B options) as necessary.
%s current argument is the name of a library or startup file of some sort.
Search for that file in a standard list of directories
and substitute the full name found.
@ -3830,14 +3836,23 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n"
concat (tooldir_prefix, "lib", dir_separator_str, NULL),
"BINUTILS", PREFIX_PRIORITY_LAST, 0, NULL, 1);
#if defined(TARGET_SYSTEM_ROOT_RELOCATABLE) && !defined(VMS)
/* If the normal TARGET_SYSTEM_ROOT is inside of $exec_prefix,
then consider it to relocate with the rest of the GCC installation
if GCC_EXEC_PREFIX is set.
``make_relative_prefix'' is not compiled for VMS, so don't call it. */
if (target_system_root && gcc_exec_prefix)
{
char *tmp_prefix = make_relative_prefix (argv[0],
standard_bindir_prefix,
target_system_root);
if (tmp_prefix && access_check (tmp_prefix, F_OK) == 0)
target_system_root = tmp_prefix;
{
target_system_root = tmp_prefix;
target_system_root_changed = 1;
}
}
#endif
/* More prefixes are enabled in main, after we read the specs file
and determine whether this is cross-compilation or not. */
@ -4746,6 +4761,15 @@ do_spec_1 (spec, inswitch, soft_matched_part)
do_spec_1 (" ", 0, NULL);
}
if (target_system_root_changed)
{
do_spec_1 ("-isysroot", 1, NULL);
/* Make this a separate argument. */
do_spec_1 (" ", 0, NULL);
do_spec_1 (target_system_root, 1, NULL);
do_spec_1 (" ", 0, NULL);
}
for (; pl; pl = pl->next)
{
do_spec_1 ("-isystem", 1, NULL);