On 09/23/2016 12:31 AM, Tadek Kijkowski wrote:
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  <tkijkow...@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
I'd really like to see the documentation here improved.

There's no mention of the second argument's purpose. And one has to parse the ifneq line to understand what it's doing. Those kinds of things should be made clear in a comment.


+
+
 # 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)))\" \
So why the $(filter-out 0, ....)?

I'd really like to avoid being too clever here and write this code in the most straightforward way possible.

Jeff

Reply via email to