Signed-off-by: Jacek Caban <[email protected]>
---

Wine has relocation support in widl now, which conflicts with mingw-w64 relocation patch. Wine uses BIN_TO_INCLUDEDIR macro, which gets computed relative path. Wine has its own makedep, which takes care of computing that, but it would be a bit overkill to port that to mingw-w64. I used autoconf AX_COMPUTE_RELATIVE_PATH macro for that. This allows nice simplification of mingw-w64 - specific code.

 mingw-w64-tools/widl/Makefile.am  | 2 +-
 mingw-w64-tools/widl/configure.ac | 8 +++++++-
 mingw-w64-tools/widl/src/widl.c   | 7 +------
 3 files changed, 9 insertions(+), 8 deletions(-)


diff --git a/mingw-w64-tools/widl/Makefile.am b/mingw-w64-tools/widl/Makefile.am
index bab752e4..dbd00067 100644
--- a/mingw-w64-tools/widl/Makefile.am
+++ b/mingw-w64-tools/widl/Makefile.am
@@ -58,7 +58,7 @@ widl_SOURCES = src/widl.h \
   include/pathtools.h \
   include/winnt.rh
 
-widl_CPPFLAGS = -I$(top_srcdir)/include -DINCLUDEDIR=\""@WIDL_INCLUDEDIR@"\" -DDEFAULT_BINDIR=\""$(bindir)"\"
+widl_CPPFLAGS = -I$(top_srcdir)/include -DINCLUDEDIR=\""@WIDL_INCLUDEDIR@"\" -DBIN_TO_INCLUDEDIR=\""@BIN_TO_INCLUDEDIR@"\"
 widl_CFLAGS = -O3 -g -Wall -Wformat -Wpacked -Wmissing-declarations -Wimplicit-function-declaration -Wmissing-prototypes -Wstrict-aliasing=2
 
 DISTCHECK_CONFIGURE_FLAGS = --host=$(host) --target=$(target)
diff --git a/mingw-w64-tools/widl/configure.ac b/mingw-w64-tools/widl/configure.ac
index ede6c7e0..60309c35 100644
--- a/mingw-w64-tools/widl/configure.ac
+++ b/mingw-w64-tools/widl/configure.ac
@@ -16,16 +16,22 @@ AM_MAINTAINER_MODE
 
 AC_ARG_PROGRAM
 
+install_prefix=$(echo $prefix | sed "s,NONE,$ac_default_prefix,")
+install_bindir=$(echo $bindir | sed "s,\${exec_prefix},$(echo $install_prefix | sed s/,/\\\\,/),")
+
 AC_MSG_CHECKING([for widl includedir])
 AC_ARG_WITH([widl-includedir],
   [AS_HELP_STRING([--with-widl-includedir=DIR],
     [Make widl look for includes in this directory, relative to the bin directory (default: <includedir>/../<target>/include)])],
   [],
-  [with_widl_includedir="\$(includedir)/../\$(target)/include"])
+  [with_widl_includedir="$install_prefix/$target/include"])
 AC_MSG_RESULT([$with_widl_includedir])
 AS_VAR_SET([WIDL_INCLUDEDIR],[$with_widl_includedir])
 AC_SUBST([WIDL_INCLUDEDIR])
 
+AX_COMPUTE_RELATIVE_PATH([install_bindir], [with_widl_includedir], [BIN_TO_INCLUDEDIR])
+AC_SUBST([BIN_TO_INCLUDEDIR])
+
 # Checks for programs.
 AC_PROG_CC
 
diff --git a/mingw-w64-tools/widl/src/widl.c b/mingw-w64-tools/widl/src/widl.c
index 6a5ca69f..35d37d9b 100644
--- a/mingw-w64-tools/widl/src/widl.c
+++ b/mingw-w64-tools/widl/src/widl.c
@@ -752,15 +752,10 @@ int main(int argc,char *argv[])
   {
       char exe_path[PATH_MAX];
       get_executable_path (argv[0], &exe_path[0], sizeof (exe_path) / sizeof (exe_path[0]));
-      char * rel_to_includedir = get_relative_path (DEFAULT_BINDIR, INCLUDEDIR);
       if (strrchr (exe_path, '/') != NULL) {
           strrchr (exe_path, '/')[1] = '\0';
       }
-      char relocated_default_include_dir[PATH_MAX];
-      strcpy (relocated_default_include_dir, exe_path);
-      strcat (relocated_default_include_dir, rel_to_includedir);
-      simplify_path (&relocated_default_include_dir[0]);
-      wpp_add_include_path(relocated_default_include_dir);
+      wpp_add_include_path(strmake("%s%s/%s", sysroot, exe_path, BIN_TO_INCLUDEDIR));
   }
 
   switch (target_cpu)

_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to