Makefile.in (PREPROCESSOR_DEFINES): Add a level of indirection for several include...
authorTadek Kijkowski <tkijkowski@gmail.com>
Fri, 2 Dec 2016 16:34:28 +0000 (16:34 +0000)
committerJeff Law <law@gcc.gnu.org>
Fri, 2 Dec 2016 16:34:28 +0000 (09:34 -0700)
* 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
gcc/Makefile.in
gcc/config/i386/mingw32.h
gcc/config/i386/x-mingw32

index 33fd2ebee06a5d7410650d4879e7178d93a93c7e..c984483211f7d6e8e6076a0a5db157a93b29b60c 100644 (file)
@@ -1,3 +1,14 @@
+2016-12-02  Tadek Kijkowski  <tkijkowski@gmail.com>
+
+       * 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  <jakub@redhat.com>
 
        PR target/70322
index df4f64f7c284539450632ccc4c1993f41216ebc5..c7b1eaf5d625b728da530cdc692635e5d134a5f1 100644 (file)
@@ -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@
index ac4aa0d728b067dc7ff131100256714ca46d135c..258d3cd2ed6a8d36ad333de367b5b7c26742417e 100644 (file)
@@ -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.  */
index 1d28a702a9d6be8b7b80473e271c7dcd0b428c3b..6eb61677a2b8ca7865a6b09990c2d8daa9f3b5c4 100644 (file)
 # along with GCC; see the file COPYING3.  If not see
 # <http://www.gnu.org/licenses/>.
 #
+
+# 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.