[mingw] Add cross-compile support to cwrapper
* libltdl/config/ltmain.m4sh (func_to_host_path):
If present, use winepath to convert from $build to $host
if $host is mingw and $build is neither mingw (msys) nor
cygwin. Also update comments.
(func_to_host_pathlist): Ditto.
---
This is a follow-on to the recent patch dealing with the cwrapper
for mingw and cygwin. This patch adds the ability for cross-compile
setups (where $host=mingw and $build=<not mingw/msys, not cygwin,
but some *nix with wine>) to generate "correct" binary wrappers.
winepath, if found, is used to convert $build (unix) paths to
the appropriate "windows-style" paths /inside/ the wine environment.
If winepath is not found, then the $build path will be used by
the cwrapper (which is the current behavior for cross-compile to
mingw $host). Obviously, the $build path is not correct, so the
cwrapper won't work -- but the build will continue successfully
after printing a warning, so no harm.
However, I can't test this patch directly. The concepts work in
my stripped-down wine-on-linux install, but I don't have a full
mingw environment to test the whole thing in. I *did* verify that
this patch causes no regressions for native cygwin, and native mingw.
Also, I think that, even in the best of cases and everything works
as I expect, you'll either have have the linux binfmt extension
working to actually run the test suite in a cross-compile setup,
because I don't know how you'd convince the testsuite machinery
to prefix every program invocation with '/path/to/wine ...'
Anyway; please /test/.
Chuck
libltdl/config/ltmain.m4sh | 97 +++++++++++++++++++++++++++++--------------
1 files changed, 65 insertions(+), 32 deletions(-)
diff --git a/libltdl/config/ltmain.m4sh b/libltdl/config/ltmain.m4sh
index 0bfae76..197920c 100644
--- a/libltdl/config/ltmain.m4sh
+++ b/libltdl/config/ltmain.m4sh
@@ -2515,12 +2515,19 @@ func_emit_wrapper ()
#
# Convert paths to build format when used with build tools.
# Intended for use with "native" mingw (where libtool itself
-# is running under the msys shell). Ordinarily, the (msys) shell
-# automatically converts such things for non-msys applications
-# it launches, but that isn't available from inside the cwrapper.
-# Similar accommodations are necessary for $host mingw and $build
-# cygwin. Calling this function does no harm on other $build or
-# for other $host.
+# is running under the msys shell), or in the following cross-
+# build environments:
+# $build $host
+# mingw (msys) mingw [e.g. native]
+# cygwin mingw
+# *nix + wine mingw
+# where wine is equipped with the `winepath' executable.
+# In the native mingw case, the (msys) shell automatically
+# converts paths for any non-msys applications it launches,
+# but that facility isn't available from inside the cwrapper.
+# Similar accommodations are necessary for $host mingw and
+# $build cygwin. Calling this function does no harm for other
+# $host/$build combinations not listed above.
#
# ARG is the path (on $build) that should be converted to
# the proper representation for $host. The result is stored
@@ -2546,6 +2553,13 @@ func_to_host_path ()
func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\
$SED -e "$lt_sed_naive_backslashify"`
;;
+ * )
+ if winepath -h >/dev/null 2>&1 ; then
+ func_to_host_path_tmp1=`winepath -w "$1"`
+ func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\
+ $SED -e "$lt_sed_naive_backslashify"`
+ fi
+ ;;
esac
if test -z "$func_to_host_path_result" ; then
func_error "Could not determine host path corresponding to"
@@ -2561,12 +2575,18 @@ func_to_host_path ()
# func_to_host_pathlist arg
#
# Convert pathlists to build format when used with build tools.
-# See func_to_host_path(), above.
+# See func_to_host_path(), above. This function supports the
+# following $build/$host combinations (but does no harm for
+# combinations not listed here):
+# $build $host
+# mingw (msys) mingw [e.g. native]
+# cygwin mingw
+# *nix + wine mingw
#
-# Path separators are also converted from ':' to ';', and if
-# $1 begins or ends with a ':' it is preserved (as ';') on
-# output. This description applies only when $build is mingw
-# (msys) or cygwin, and $host is mingw.
+# Path separators are also converted from $build format to
+# $host format. If ARG begins or ends with a path separator
+# character, it is preserved (but converted to $host format)
+# on output.
#
# ARG is a pathlist (on $build) that should be converted to
# the proper representation on $host. The result is stored
@@ -2578,16 +2598,12 @@ func_to_host_pathlist ()
case $host in
*mingw* )
lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
- case $build in
- *mingw* | *cygwin* )
- # Remove leading and trailing ':' from $1. The behavior of
- # msys is inconsistent here, and cygpath turns them into
- # into '.;' and ';.'
- func_to_host_pathlist_tmp2="$1"
- func_to_host_pathlist_tmp1=`echo "$func_to_host_pathlist_tmp2" |\
- $SED -e 's|^:*||' -e 's|:*$||'`
- ;;
- esac
+ # Remove leading and trailing path separator characters from
+ # ARG. msys behavior is inconsistent here, cygpath turns them
+ # into '.;' and ';.', and winepath ignores them completely.
+ func_to_host_pathlist_tmp2="$1"
+ func_to_host_pathlist_tmp1=`echo "$func_to_host_pathlist_tmp2" |\
+ $SED -e 's|^:*||' -e 's|:*$||'`
case $build in
*mingw* ) # Actually, msys.
# Awkward: cmd appends spaces to result.
@@ -2602,23 +2618,40 @@ func_to_host_pathlist ()
func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp2" |\
$SED -e "$lt_sed_naive_backslashify"`
;;
+ * )
+ # unfortunately, winepath doesn't convert pathlists
+ func_to_host_pathlist_result=""
+ func_to_host_pathlist_oldIFS=$IFS
+ IFS=:
+ for func_to_host_pathlist_f in $func_to_host_pathlist_tmp1 ; do
+ IFS=$func_to_host_pathlist_oldIFS
+ if test -n "$func_to_host_pathlist_f" ; then
+ func_to_host_path "$func_to_host_pathlist_f"
+ if test -n "$func_to_host_path_result" ; then
+ if test -z "$func_to_host_pathlist_result" ; then
+ func_to_host_pathlist_result="$func_to_host_path_result"
+ else
+
func_to_host_pathlist_result="$func_to_host_pathlist_result;$func_to_host_path_result"
+ fi
+ fi
+ fi
+ IFS=:
+ done
+ IFS=$func_to_host_pathlist_oldIFS
+ ;;
esac
if test -z "$func_to_host_pathlist_result" ; then
func_error "Could not determine the host path(s) corresponding to"
func_error " '$1'"
func_error "Continuing, but uninstalled executables may not work."
fi
- case $build in
- *mingw* | *cygwin* )
- # Now, add the leading and trailing ':' back
- case "$1" in
- :* )
func_to_host_pathlist_result=";$func_to_host_pathlist_result"
- ;;
- esac
- case "$1" in
- *: )
func_to_host_pathlist_result="$func_to_host_pathlist_result;"
- ;;
- esac
+ # Now, add the leading and trailing path separators back
+ case "$1" in
+ :* ) func_to_host_pathlist_result=";$func_to_host_pathlist_result"
+ ;;
+ esac
+ case "$1" in
+ *: ) func_to_host_pathlist_result="$func_to_host_pathlist_result;"
;;
esac
;;