From d2c82d98de3100a10731d982bf3fe571dba03e13 Mon Sep 17 00:00:00 2001 From: Tadek Kijkowski Date: Fri, 2 Dec 2016 16:34:28 +0000 Subject: [PATCH] Makefile.in (PREPROCESSOR_DEFINES): Add a level of indirection for several include directories that may be relative... * Makefile.in (PREPROCESSOR_DEFINES): Add a level of indirection for several include directories that may be relative to sysroot. * config/i386/x-mingw32 (gplus_includedir): Define. (gplus_tool_includedir, gplus_backward_include_dir): Likewise. (native_system_includedir): Likewise. * config/i386/mingw32.h (STANDARD_STARTFILE_PREFIX_1): Do not override if TARGET_SYSTEM_ROOT is defined. (NATIVE_SYSTEM_HEADER_DIR): Likewise. From-SVN: r243196 --- gcc/ChangeLog | 11 +++++++++++ gcc/Makefile.in | 17 +++++++++++++---- gcc/config/i386/mingw32.h | 4 ++++ gcc/config/i386/x-mingw32 | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 62 insertions(+), 4 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 33fd2ebee06..c984483211f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,14 @@ +2016-12-02 Tadek Kijkowski + + * Makefile.in (PREPROCESSOR_DEFINES): Add a level of indirection + for several include directories that may be relative to sysroot. + * config/i386/x-mingw32 (gplus_includedir): Define. + (gplus_tool_includedir, gplus_backward_include_dir): Likewise. + (native_system_includedir): Likewise. + * config/i386/mingw32.h (STANDARD_STARTFILE_PREFIX_1): Do not + override if TARGET_SYSTEM_ROOT is defined. + (NATIVE_SYSTEM_HEADER_DIR): Likewise. + 2016-12-02 Jakub Jelinek PR target/70322 diff --git a/gcc/Makefile.in b/gcc/Makefile.in index df4f64f7c28..c7b1eaf5d62 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -675,6 +675,15 @@ objext = .o exeext = @host_exeext@ build_exeext = @build_exeext@ + +# This allows overriding include paths in host specific Makefile +# (config/i386/x-mingw32 overrides those variables and local_includedir). +gplusplus_includedir = $(gcc_gxx_include_dir) +gplusplus_tool_includedir = $(gcc_gxx_include_dir)/$(target_noncanonical) +gplusplus_backward_includedir = $(gcc_gxx_include_dir)/backward +native_system_includedir = $(NATIVE_SYSTEM_HEADER_DIR) + + # Directory in which to put man pages. mandir = @mandir@ man1dir = $(mandir)/man1 @@ -2768,14 +2777,14 @@ CFLAGS-intl.o += -DLOCALEDIR=\"$(localedir)\" PREPROCESSOR_DEFINES = \ -DGCC_INCLUDE_DIR=\"$(libsubdir)/include\" \ -DFIXED_INCLUDE_DIR=\"$(libsubdir)/include-fixed\" \ - -DGPLUSPLUS_INCLUDE_DIR=\"$(gcc_gxx_include_dir)\" \ + -DGPLUSPLUS_INCLUDE_DIR=\"$(gplusplus_includedir)\" \ -DGPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT=$(gcc_gxx_include_dir_add_sysroot) \ - -DGPLUSPLUS_TOOL_INCLUDE_DIR=\"$(gcc_gxx_include_dir)/$(target_noncanonical)\" \ - -DGPLUSPLUS_BACKWARD_INCLUDE_DIR=\"$(gcc_gxx_include_dir)/backward\" \ + -DGPLUSPLUS_TOOL_INCLUDE_DIR=\"$(gplusplus_tool_includedir)\" \ + -DGPLUSPLUS_BACKWARD_INCLUDE_DIR=\"$(gplusplus_backward_includedir)\" \ -DLOCAL_INCLUDE_DIR=\"$(local_includedir)\" \ -DCROSS_INCLUDE_DIR=\"$(CROSS_SYSTEM_HEADER_DIR)\" \ -DTOOL_INCLUDE_DIR=\"$(gcc_tooldir)/include\" \ - -DNATIVE_SYSTEM_HEADER_DIR=\"$(NATIVE_SYSTEM_HEADER_DIR)\" \ + -DNATIVE_SYSTEM_HEADER_DIR=\"$(native_system_includedir)\" \ -DPREFIX=\"$(prefix)/\" \ -DSTANDARD_EXEC_PREFIX=\"$(libdir)/gcc/\" \ @TARGET_SYSTEM_ROOT_DEFINE@ diff --git a/gcc/config/i386/mingw32.h b/gcc/config/i386/mingw32.h index ac4aa0d728b..258d3cd2ed6 100644 --- a/gcc/config/i386/mingw32.h +++ b/gcc/config/i386/mingw32.h @@ -161,6 +161,8 @@ along with GCC; see the file COPYING3. If not see fvtable-verify=std:vtv_end.o%s} \ crtend.o%s" +#if !defined(TARGET_SYSTEM_ROOT) + /* Override startfile prefix defaults. */ #ifndef STANDARD_STARTFILE_PREFIX_1 #define STANDARD_STARTFILE_PREFIX_1 "/mingw/lib/" @@ -174,6 +176,8 @@ along with GCC; see the file COPYING3. If not see #undef NATIVE_SYSTEM_HEADER_DIR #define NATIVE_SYSTEM_HEADER_DIR "/mingw/include" +#endif /* !defined(TARGET_SYSTEM_ROOT) */ + /* Output STRING, a string representing a filename, to FILE. We canonicalize it to be in Unix format (backslashes are replaced forward slashes. */ diff --git a/gcc/config/i386/x-mingw32 b/gcc/config/i386/x-mingw32 index 1d28a702a9d..6eb61677a2b 100644 --- a/gcc/config/i386/x-mingw32 +++ b/gcc/config/i386/x-mingw32 @@ -16,10 +16,44 @@ # along with GCC; see the file COPYING3. If not see # . # + +# MSYS will zealously translate all paths to Windows form, so /usr/include becomes c:/msysX/usr/include. +# This is undesirable when TARGET_SYSTEM_ROOT is specified, so this function converts /usr/include to //usr\include, +# which will become /usr/include again when passed to gcc. + +# This function takes two parameters: first parameter is include directory path, second parameter tells +# if the path is relative to TARGET_SYSTEM_ROOT. +# If TARGET_SYSTEM_ROOT is not configured, or +# this function always expands to the unmodified first parameter +# if TARGET_SYSTEM_ROOT is configured, but second parameter is not 1, +# this function again expands to the unmodified first parameter +# otherwise, +# it expands to a shell expression which will transform the first parameter as described above. +ifneq ($(TARGET_SYSTEM_ROOT),) +sysroot_relative_path = $(if $(filter 1,$(2)),`echo "$(1)" | tr '/' '\\\\' | sed 's|^\\\\|//|'`,$(1)) +else +sysroot_relative_path = $(1) +endif + +ifneq ($(TARGET_SYSTEM_ROOT),) +# +# Make sure that relative the path is not converted to absolute DOS style path +# +local_includedir = $(call sysroot_relative_path,$(local_prefix)/include,1) +else # # Make local_includedir relative to EXEC_PREFIX # local_includedir=$(libsubdir)/$(unlibsubdir)/..`echo $(exec_prefix) | sed -e 's|^$(prefix)||' -e 's|/[^/]*|/..|g'`/include +endif + +# +# Make sure that relative path are not converted to absolute DOS style paths +# +gplusplus_includedir = $(call sysroot_relative_path,$(gcc_gxx_include_dir),$(gcc_gxx_include_dir_add_sysroot)) +gplusplus_tool_includedir = $(call sysroot_relative_path,$(gcc_gxx_include_dir)/$(target_noncanonical),$(gcc_gxx_include_dir_add_sysroot)) +gplusplus_backward_includedir = $(call sysroot_relative_path,$(gcc_gxx_include_dir)/backward,$(gcc_gxx_include_dir_add_sysroot)) +native_system_includedir = $(call sysroot_relative_path,$(NATIVE_SYSTEM_HEADER_DIR),1) # On MinGW, we use "%IA64d" to print 64-bit integers, and the format-checking # code does not handle that, so we have to disable checking here. -- 2.30.2