This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] gcc: Fix sysroot relative paths for MinGW


Prevent paths relative to sysroot directory from being transformed to
Windows form with MSYS prefix.
See: http://www.mingw.org/wiki/Posix_path_conversion

2016-09-23  Tadek Kijkowski  <tkijkowski@gmail.com>

        * gcc/Makefile.in: Fix sysroot relative paths for MinGW


Index: gcc/Makefile.in
===================================================================
--- gcc/Makefile.in    (revision 240386)
+++ gcc/Makefile.in    (working copy)
@@ -603,6 +603,18 @@
 # UNSORTED
 # --------

+# MSYS will zealously translate all paths to Windows form,
+# so /usr/include becomes c:/msysX/usr/include.
+# If sysroot is specified this is undesirable, so this function converts
+# /usr/include to //usr\include, which will become /usr/include
+# again when passed to gcc.
+ifneq ($(and @TARGET_SYSTEM_ROOT@,$(filter %-mingw32,$(host))),)
+sysroot_relative_path = $(if $(2),$$(echo '$(1)' | tr '/' '\\' | sed
's,^\\,//,'),$(1))
+else
+sysroot_relative_path = $(1)
+endif
+
+
 # Directory in which the compiler finds libraries etc.
 libsubdir = $(libdir)/gcc/$(real_target_noncanonical)/$(version)$(accel_dir_suffix)
 # Directory in which the compiler finds executables
@@ -2751,14 +2763,14 @@
 PREPROCESSOR_DEFINES = \
   -DGCC_INCLUDE_DIR=\"$(libsubdir)/include\" \
   -DFIXED_INCLUDE_DIR=\"$(libsubdir)/include-fixed\" \
-  -DGPLUSPLUS_INCLUDE_DIR=\"$(gcc_gxx_include_dir)\" \
+  -DGPLUSPLUS_INCLUDE_DIR=\"$(call
sysroot_relative_path,$(gcc_gxx_include_dir),$(filter-out
0,$(gcc_gxx_include_dir_add_sysroot)))\" \
   -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=\"$(call
sysroot_relative_path,$(gcc_gxx_include_dir)/$(target_noncanonical),$(filter-out
0,$(gcc_gxx_include_dir_add_sysroot)))\" \
+  -DGPLUSPLUS_BACKWARD_INCLUDE_DIR=\"$(call
sysroot_relative_path,$(gcc_gxx_include_dir)/backward,$(filter-out
0,$(gcc_gxx_include_dir_add_sysroot)))\" \
   -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=\"$(call
sysroot_relative_path,$(NATIVE_SYSTEM_HEADER_DIR),yes)\" \
   -DPREFIX=\"$(prefix)/\" \
   -DSTANDARD_EXEC_PREFIX=\"$(libdir)/gcc/\" \
   @TARGET_SYSTEM_ROOT_DEFINE@


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]