libtool-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] [cygwin]: Add cross-compile support to cwrapper


From: Charles Wilson
Subject: Re: [PATCH] [cygwin]: Add cross-compile support to cwrapper
Date: Sat, 24 Jan 2009 10:47:22 -0500

libltdl/m4/libtool.m4 (_LT_PATH_CONVERSION_FUNCTIONS): New function
sets $to_host_path_cmd and $to_host_pathlist_cmd.
(_LT_SETUP): Require it.
libltdl/config/ltmain.m4sh (func_cygpath): New function.
(func_to_host_path): Refactored to... (now uses eval
$to_host_path_cmd).
(func_wine_to_win32_path): Here. New function.
(func_msys_to_win32): Here. New function.
(func_path_convert_check): Here. New function.
(func_noop_path_convert): Here. New function.
(func_msys_to_mingw_path_convert): Here. New function.
(func_cygwin_to_mingw_path_convert): Here. New function.
(func_nix_to_mingw_path_convert): Here. New function.
(func_msys_to_cygwin_path_convert): New function.
(func_nix_to_cygwin_path_convert): New function.
(func_to_host_pathlist): Refactored to... (now uses eval
$to_host_pathlist_cmd).
(func_pathlist_convert_check): Here. New function.
(func_pathlist_convert_check_mingw): Here. New function.
(func_pathlist_front_back_pathsep): Here. New function.
(func_wine_to_win32_pathlist): Here. New function.
(func_noop_pathlist_convert): Here. New function.
(func_msys_to_mingw_pathlist_convert): Here. New function.
(func_cygwin_to_mingw_pathlist_convert): Here. New function.
(func_nix_to_mingw_pathlist_convert): Here. New function.
(func_msys_to_cygwin_pathlist_convert): New function.
(func_nix_to_cygwin_pathlist_convert): New function.
--
This is a revised version of the original patch. The main difference
is that rather than one giant func_to_host_path or func_to_host_pathlist
function, all of the various host/build combinations have been split
into separate functions, and the appropriate one is used depending on
the value of the configure variables $to_host_path_cmd and
$to_host_pathlist_cmd.  I considered trying something clever (like
the XSI shell functions) where only the functions needed by the 
specific configuration were included in the libtool script, but
I couldn't see how to ensure they were placed at the proper location
in the libtool script. Using the same mechanism as the XSI ones would
put them WAY too early.  Somehow inserting them "just before" func_mode_link
just doesn't seem possible without a lot of infrastructure changes --
more than I want to address in this patch.

Maybe we can look at that later.

One other possible change: The func_to_host_path() function now looks
like this:
func_to_host_path ()
{
  eval '$to_host_path_cmd "$1"'
}
I could instead change every occurence of 'func_to_host_path $somevar'
to eval '$to_host_path_cmd "$somevar"' directly, but I sorta like the
indirection, because it allows possible "decoration" (like $opt_debug).
In fact, maybe I should add $opt_debug to the new func_to_host_path[list]
functions...

cygwin-native testsuite behavior is as expected.
mingw-native (e.g. msys->mingw) testsuite behavior is as expected.
cygwin->mingw testsuite behavior didn't really work, but it does not
appear to be as a result of this patch. [*]

I'd like for somebody to verify that I haven't broken unix->mingw (and post
one of the lt-demo.c files from one of the old tests). Also, if somebody could
verify that the new unix->cygwin support works (ditto lt-demo.c), that'd be
great.

[*] I had to configure as follows:
$ export PATH="/c/MinGW/bin:$PATH"
$ ../libtool/configure --build=i686-pc-cygwin --host=mingw32 
NM=/c/MinGW/bin/nm.exe
because otherwise, cygwin's link.exe got selected as the name lister. I think 
this
is because one (or more) of Peter's fixes has not yet been merged. Also, without
Peter's other fixes, building libltdl (preopen) requires ar to explode 
loadlibrary.a,
but ar is the native mingw one while the path to loadlibrary.a is presented in
cygwin format. Finally -- there's one problem without an obvious fix: cygwin's
make no longer supports dos-style paths (in target rules, which isn't the 
problem
here), nor in .deps files (which IS the problem). The .deps files are generated
by (mingw native) gcc, and therefore contain DOS-style paths.

The MSYS make supports those kind of paths, but you can't really use MSYS exes 
from
a cygwin environment.  Trying to use mingw32-make presents the opposite problem 
in
this cross-build: it only understands DOS paths, but the Makefile rules are
in terms of cygwin (unix-like) paths.  I know that Danny Smith uses 
cygwin->mingw
as his primary environment to build gcc itself; I wonder what make executable
he uses...

==
Chuck

 config/ltmain.m4sh |  660 ++++++++++++++++++++++++++++++++++++++++++-----------
 m4/libtool.m4      |   56 ++++
 2 files changed, 586 insertions(+), 130 deletions(-)

diff --git a/libltdl/config/ltmain.m4sh b/libltdl/config/ltmain.m4sh
index 3f1a30c..3d6d5f6 100644
--- a/libltdl/config/ltmain.m4sh
+++ b/libltdl/config/ltmain.m4sh
@@ -2526,166 +2526,566 @@ fi\
 "
 }
 
+###################################
+# PATH CONVERSION HELPER FUNCTION #
+###################################
+
+# func_wine_to_win32_path ARG
+# Helper function used by path conversion functions
+# when $build is *nix, and $host is mingw, cygwin,
+# or some other win32 environment. Relies on a
+# correctly configured wine environment available,
+# with the winepath program in $build's $PATH.
+#
+# ARG is the $build path to be converted to win32 format.
+# result is available in $func_wine_to_win32_path_result
+# result is empty on error (or when arg is empty)
+func_wine_to_win32_path ()
+{
+  lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
+  func_wine_to_win32_path_result="$1"
+  if test -n "$1"; then
+    # Unfortunately, winepath does not exit with a non-zero
+    # error code, so we are forced to check the contents of
+    # stdout. On the other hand, if the command is not
+    # found, the shell will set an exit code of 127 and print
+    # *an error message* to stdout. So we must check for both
+    # error code of zero AND non-empty stdout, which explains
+    # the odd construction:
+    func_to_host_path_tmp1=`winepath -w "$1" 2>/dev/null`
+    if test "$?" -eq 0 && test -n "${func_wine_to_win32_path_tmp}"; then
+      func_to_host_path_result=`$ECHO "$func_wine_to_win32_path_tmp" |
+        $SED -e "$lt_sed_naive_backslashify"`
+    else
+      func_wine_to_win32_path_result=
+    fi
+  fi
+}
+# end: func_wine_to_win32_path
+
+
+# func_wine_to_win32_pathlist ARG
+# Helper function used by path conversion functions
+# when $build is *nix, and $host is mingw, cygwin,
+# or some other win32 environment. Relies on a
+# correctly configured wine environment available,
+# with the winepath program in $build's $PATH.
+# Assumes ARG has no leading or trailing path separator
+# characters.
+#
+# ARG is pathlist to be converted from $build format to win32.
+# Result is available in $func_wine_to_win32_pathlist_result
+# Unconvertible paths in pathlist are skipped; if no paths
+# are convertible, result may be empty.
+func_wine_to_win32_pathlist ()
+{
+  # unfortunately, winepath doesn't convert pathlists
+  func_wine_to_win32_pathlist_result=""
+  if test -n "$1"; then
+    func_wine_to_win32_pathlist_oldIFS=$IFS
+    IFS=:
+    for func_wine_to_win32_pathlist_f in $1; do
+      IFS=$func_wine_to_win32_pathlist_oldIFS
+      if test -n "$func_wine_to_win32_pathlist_f" ; then
+        func_wine_to_win32_path "$func_wine_to_win32_pathlist_f"
+        if test -n "$func_wine_to_win32_path_result" ; then
+          if test -z "$func_wine_to_win32_pathlist_result"; then
+            
func_wine_to_win32_pathlist_result="$func_wine_to_win32_path_result"
+          else
+            func_append func_wine_to_win32_pathlist_result 
";$func_wine_to_win32_path_result"
+          fi
+        fi
+      fi
+    done
+    IFS=$func_wine_to_win32_pathlist_oldIFS
+  fi
+}
+# end: func_wine_to_win32_pathlist
 
-# func_to_host_path arg
+
+# func_cygpath ARGS...
+# a wrapper around calling the cygpath program via
+# LT_CYGPATH, when $host is *nix and cygwin is
+# hosted via a wine environment (or, rarely, when
+# host is mingw -- that is, msys).
+#
+# Result is available in func_cygpath_result, which
+# may be empty on error. Can accomodate both paths
+# and pathlists (with appropriate options).
 #
-# Convert paths to host format when used with build tools.
-# Intended for use with "native" mingw (where libtool itself
-# is running under the msys shell), or in the following cross-
-# build environments:
+# ARGS are the typical arguments and options for
+# the cygpath program. Usually, the last argument
+# is the path or pathlist to be converted.
+#
+# The full *nix (or msys) path to the cygpath program must be
+# specified in the LT_CYGPATH environment variable. This
+# is because (a) the cygpath program shouldn't be in $PATH,
+# because it usually lives in cygwin's bin/ directory --
+# along with *cygwin* versions of sed, id, cp. If the *nix (or
+# msys) host environment had those programs in its $PATH, many
+# bad things could happen. (b) especially in cygwin-1.7, multiple
+# installations (with separate "mount tables" in
+# <CYGROOT-N>/etc/fstab) can coexist on the same Win32
+# instance. The cygpath.exe for cygwin installation #N in
+# <CYGROOT-N>/bin automatically deduces the appropriate
+# ../etc/fstab file. Therefore, it matters which cygpath.exe
+# is used. LT_CYGPATH may be replaced or supplemented by an
+# LT_INIT-activated configure option in the future.
+func_cygpath ()
+{
+  if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
+    func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
+    if test "$?" -ne 0; then
+      # on failure, ensure result is empty
+      func_cygpath_result=
+    fi
+  else
+    func_cygpath_result=
+    func_error "LT_CYGPATH is empty or specifies non-existant file: 
\`$LT_CYGPATH'"
+  fi
+}
+#end: func_cygpath
+
+
+# func_msys_to_win32 ARG
+# Converts ARG from msys (unix-ish) format to
+# win32 format. Can accomodate both paths and pathlists.
+# Result is available in func_msys_to_win32_result.
+func_msys_to_win32 ()
+{
+  lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
+  # awkward: cmd appends spaces to result
+  func_msys_to_win32_result=`( cmd //c echo "$1" ) 2>/dev/null |
+    $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"`
+}
+#end: func_msys_to_win32
+
+
+# func_path_convert_check ARG1 ARG2
+# Verify that ARG1 (a path in $build format) was
+# converted to $host format in ARG2. Otherwise, emit
+# an error message, but continue (resetting
+# func_to_host_path_result to ARG1).
+func_path_convert_check ()
+{
+  if test -z "$2" && test -n "$1" ; then
+    func_error "Could not determine host path corresponding to"
+    func_error "  \`$1'"
+    func_error "Continuing, but uninstalled executables may not work."
+    # Fallback:
+    func_to_host_path_result="$1"
+  fi
+}
+# end func_path_convert_check
+
+
+# func_pathlist_convert_check ARG1 ARG2
+# Verify that ARG1 (a path in $build format) was
+# converted to $host format in ARG2. Otherwise, emit
+# an error message, but continue (resetting
+# func_to_host_path_result to a simplistic fallback
+# value (see below).
+func_pathlist_convert_check ()
+{
+  if test -z "$2" && test -n "$1"; then
+    func_error "Could not determine the host path(s) corresponding to"
+    func_error "  \`$1'"
+    func_error "Continuing, but uninstalled executables may not work."
+    # Fallback.
+    func_to_host_pathlist_result="$1"
+  fi
+}
+# end func_pathlist_convert_check
+
+
+# func_pathlist_convert_check_mingw ARG1 ARG2
+# Verify that ARG1 (a path in $build format) was
+# converted to $host format in ARG2. Otherwise, emit
+# an error message, but continue (resetting
+# func_to_host_path_result to a simplistic fallback
+# value (see below).
+# This function is specific for mingw $hosts.
+func_pathlist_convert_check_mingw ()
+{
+  if test -z "$2" && test -n "$1"; then
+    func_error "Could not determine the host path(s) corresponding to"
+    func_error "  \`$1'"
+    func_error "Continuing, but uninstalled executables may not work."
+    # Fallback. This may break if $1 contains DOS-style drive
+    # specifications. The fix is not to complicate the expression
+    # below, but for the user to provide a working wine installation
+    # with winepath so that path translation in the cross-to-mingw
+    # case works properly.
+    lt_replace_pathsep_nix_to_dos="s|:|;|g"
+    func_to_host_pathlist_result=`echo "$1" |\
+      $SED -e "$lt_replace_pathsep_nix_to_dos"`
+  fi
+}
+# end func_pathlist_convert_check_mingw
+
+
+# func_pathlist_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
+# Modifies func_to_host_pathlist_result by prepending REPL
+# if ORIG matches FRONTPAT and appending REPL if ORIG matches
+# BACKPAT.
+func_pathlist_front_back_pathsep ()
+{
+  case "$4" in
+  $1 ) func_to_host_pathlist_result="$3$func_to_host_pathlist_result"
+    ;;
+  esac
+  case "$4" in
+  $2 ) func_append func_to_host_pathlist_result "$3"
+    ;;
+  esac
+}
+# end func_pathlist_front_back_pathsep
+
+
+#############################################
+# $build to $host PATH CONVERSION FUNCTIONS #
+#############################################
+# invoked via `eval $to_host_path_cmd ARG'
+#
+# At present, the following path conversions are supported:
 #    $build          $host
 #    mingw (msys)    mingw  [e.g. native]
 #    cygwin          mingw
 #    *nix + wine     mingw
+#    mingw (msys)    cygwin [*] [**]
+#    *nix + wine     cygwin [**]
 # 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
-# in $func_to_host_path_result.
+# [*] available, but not officially supported. See comments with
+#     func_msys_to_cygwin_path_convert.
+# [**] requires environment variable $LT_CYGPATH. See comments
+#      with func_cygpath.
+# In each case, ARG is the path to be converted from $build
+# to $host format. the result will be available in
+# $func_to_host_path_result.
+
+
+# func_to_host_path ARG
+# converts the path ARG from $build format to $host
+# format.
 func_to_host_path ()
 {
+  eval '$to_host_path_cmd "$1"'
+}
+# end func_to_host_path
+
+
+# func_noop_path_convert ARG
+# A no-op path conversion function for use when $build == $host.
+# or when there is no required (or known) conversion function
+# between $build and $host.
+func_noop_path_convert ()
+{
+  func_to_host_path_result="$1"
+}
+# end func_noop_path_convert
+
+
+# func_msys_to_mingw_path_convert ARG
+# A path conversion function for use with "native" mingw
+# builds -- that is, when $host is *mingw*, and $build
+# is *mingw* (which is to say, msys).  In this case, the
+# msys shell automatically converts paths for any non-msys
+# applications it launches, but that facility isn't available
+# from inside the cwrapper.
+#
+# ARG is the path to be converted; the result is available
+# in func_to_host_path_result.
+func_msys_to_mingw_path_convert ()
+{
   func_to_host_path_result="$1"
   if test -n "$1"; then
-    case $host in
-      *mingw* )
-        lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
-        case $build in
-          *mingw* ) # actually, msys
-            # awkward: cmd appends spaces to result
-            func_to_host_path_result=`( cmd //c echo "$1" ) 2>/dev/null |
-              $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"`
-            ;;
-          *cygwin* )
-            func_to_host_path_result=`cygpath -w "$1" |
-             $SED -e "$lt_sed_naive_backslashify"`
-            ;;
-          * )
-            # Unfortunately, winepath does not exit with a non-zero
-            # error code, so we are forced to check the contents of
-            # stdout. On the other hand, if the command is not
-            # found, the shell will set an exit code of 127 and print
-            # *an error message* to stdout. So we must check for both
-            # error code of zero AND non-empty stdout, which explains
-            # the odd construction:
-            func_to_host_path_tmp1=`winepath -w "$1" 2>/dev/null`
-            if test "$?" -eq 0 && test -n "${func_to_host_path_tmp1}"; then
-              func_to_host_path_result=`$ECHO "$func_to_host_path_tmp1" |
-                $SED -e "$lt_sed_naive_backslashify"`
-            else
-              # Allow warning below.
-              func_to_host_path_result=
-            fi
-            ;;
-        esac
-        if test -z "$func_to_host_path_result" ; then
-          func_error "Could not determine host path corresponding to"
-          func_error "  \`$1'"
-          func_error "Continuing, but uninstalled executables may not work."
-          # Fallback:
-          func_to_host_path_result="$1"
-        fi
-        ;;
-    esac
+    func_msys_to_win32 "$1"
+    func_to_host_path_result="$func_msys_to_win32_result"
   fi
+  func_path_convert_check "$1" "$func_to_host_path_result"
 }
-# end: func_to_host_path
+# end func_msys_to_mingw_path_convert
 
-# func_to_host_pathlist arg
+
+# func_cygwin_to_mingw_path_convert ARG
+# A path conversion function for use when $host is *mingw*
+# but $build is *cygwin*. In this case, the cygpath program
+# provided by the $build environment is sufficient for all
+# conversions.
 #
-# Convert pathlists to host format when used with build tools.
-# See func_to_host_path(), above. This function supports the
-# following $build/$host combinations (but does no harm for
-# combinations not listed here):
+# ARG is the path to be converted; the result is available
+# in func_to_host_path_result.
+func_cygwin_to_mingw_path_convert ()
+{
+  func_to_host_path_result="$1"
+  if test -n "$1"; then
+    # because $build is cygwin, we call "the" cygpath
+    # in $PATH; no need to use LT_CYGPATH in this case.
+    func_to_host_path_result=`cygpath -m "$1"`
+  fi
+  func_path_convert_check "$1" "$func_to_host_path_result"
+}
+# end func_cygwin_to_mingw_path_convert
+
+
+# func_nix_to_mingw_path_convert ARG
+# A path conversion function for use when $host is *mingw*
+# but $build is some *nix variant. In this case, we assume
+# that a wine environment with a working winepath executable
+# is available in $build's $PATH.
+#
+# ARG is the path to be converted; the result is available
+# in func_to_host_path_result.
+func_nix_to_mingw_path_convert ()
+{
+  func_to_host_path_result="$1"
+  if test -n "$1"; then
+    func_wine_to_win32_path "$1"
+    func_to_host_path_result="$func_wine_to_win32_path_result"
+  fi
+  func_path_convert_check "$1" "$func_to_host_path_result"
+}
+# end func_nix_to_mingw_path_convert
+
+
+# func_msys_to_cygwin_path_convert ARG
+# A path conversion function for use when $host is *cygwin*
+# but $build is *mingw* (that is, msys). This implies running
+# a cross build from msys to cygwin -- but msys has notorious
+# problems executing cygwin apps, because of conflicts between
+# cygwin1.dll and msys-1.0.dll. However, we'll try it. First,
+# convert from msys to win32, then use func_cygpath to convert
+# from win32 to cygwin. Requires LT_CYGPATH.
+#
+# ARG is the path to be converted; the result is available
+# in func_to_host_path_result.
+func_msys_to_cygwin_path_convert ()
+{
+  func_to_host_path_result="$1"
+  if test -n "$1"; then
+    func_msys_to_win32 "$1"
+    func_cygpath -u "$func_msys_to_win32_result"
+    func_to_host_path_result="$func_cygpath_result"
+  fi
+  func_path_convert_check "$1" "$func_to_host_path_result"
+}
+# end func_msys_to_cygwin_path_convert
+
+# func_nix_to_cygwin_path_convert ARG
+# A path conversion function for use when $host is *cygwin*
+# but $build is some *nix variant. In this case, we assume
+# that a wine environment with a working winepath executable
+# is available in $build's $PATH, and that cygwin is installed
+# within that wine environment. Requires LT_CYGPATH (see
+# func_cygpath).
+#
+# ARG is the path to be converted; the result is available
+# in func_to_host_path_result.
+func_nix_to_cygwin_path_convert ()
+{
+  func_to_host_path_result="$1"
+  if test -n "$1"; then
+    # convert from *nix to win32, then use cygpath to
+    # convert from win32 to cygwin.
+    func_wine_to_win32_path "$1"
+    func_cygpath -u "$func_wine_to_win32_path_result"
+    func_to_host_path_result="$func_cygpath_result"
+  fi
+  func_path_convert_check "$1" "$func_to_host_path_result"
+}
+# end func_nix_to_cygwin_path_convert
+
+
+#################################################
+# $build to $host PATHLIST CONVERSION FUNCTIONS #
+#################################################
+# invoked via `eval $to_host_pathlist_cmd ARG'
+#
+# At present, the following pathlist conversions are supported:
 #    $build          $host
 #    mingw (msys)    mingw  [e.g. native]
 #    cygwin          mingw
 #    *nix + wine     mingw
+#    mingw (msys)    cygwin [*] [**]
+#    *nix + wine     cygwin [**]
+# where wine is equipped with the `winepath' executable.
+# [*] available, but not officially supported. See comments with
+#     func_msys_to_cygwin_pathlist_convert.
+# [**] requires environment variable $LT_CYGPATH. See comments
+#      with func_cygpath.
+# In each case, ARG is the pathlist to be converted from
+# $build to $host format. the result will be available in
+# $func_to_host_pathlist_result.
 #
 # 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
-# in $func_to_host_pathlist_result.
+
+
+# func_to_host_pathlist ARG
+# converts the pathlist ARG from $build format to $host
+# format.
 func_to_host_pathlist ()
 {
+  eval '$to_host_pathlist_cmd "$1"'
+}
+# end func_to_host_pathlist
+
+
+# func_noop_pathlist_convert ARG
+# A no-op pathlist conversion function for use when $build == $host,
+# or when there is no required (or known) conversion function
+# between $build and $host.
+func_noop_pathlist_convert ()
+{
+  func_to_host_pathlist_result="$1"
+}
+# end func_noop_pathlist_convert
+
+
+# func_msys_to_mingw_pathlist_convert ARG
+# A pathlist conversion function for use with "native" mingw
+# builds -- that is, when $host is *mingw*, and $build
+# is *mingw* (which is to say, msys).  In this case, the
+# msys shell automatically converts pathlists for any non-msys
+# applications it launches, but that facility isn't available
+# from inside the cwrapper.
+#
+# ARG is the pathlist to be converted; the result is available
+# in func_to_host_pathlist_result.
+func_msys_to_mingw_pathlist_convert ()
+{
   func_to_host_pathlist_result="$1"
   if test -n "$1"; then
-    case $host in
-      *mingw* )
-        lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
-        # 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_stripname : : "$1"
-        func_to_host_pathlist_tmp1=$func_stripname_result
-        case $build in
-          *mingw* ) # Actually, msys.
-            # Awkward: cmd appends spaces to result.
-            func_to_host_pathlist_result=`
-             ( cmd //c echo "$func_to_host_pathlist_tmp1" ) 2>/dev/null |
-             $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"`
-            ;;
-          *cygwin* )
-            func_to_host_pathlist_result=`cygpath -w -p 
"$func_to_host_pathlist_tmp1" |
-              $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_append func_to_host_pathlist_result 
";$func_to_host_path_result"
-                  fi
-                fi
-              fi
-            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."
-          # Fallback. This may break if $1 contains DOS-style drive
-          # specifications. The fix is not to complicate the expression
-          # below, but for the user to provide a working wine installation
-          # with winepath so that path translation in the cross-to-mingw
-          # case works properly.
-          lt_replace_pathsep_nix_to_dos="s|:|;|g"
-          func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp1" |\
-            $SED -e "$lt_replace_pathsep_nix_to_dos"`
-        fi
-        # 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_append func_to_host_pathlist_result ";"
-            ;;
-        esac
-        ;;
-    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_stripname : : "$1"
+    func_to_host_pathlist_tmp1=$func_stripname_result
+    func_msys_to_win32 "$func_to_host_pathlist_tmp1"
+    func_to_host_pathlist_result="$func_msys_to_win32_result"
+    func_pathlist_convert_check_mingw "$func_to_host_pathlist_tmp1" \
+      "$func_to_host_pathlist_result"
+    func_pathlist_front_back_pathsep ":*" "*:" ";" "$1"
+  fi
+}
+# end func_msys_to_mingw_pathlist_convert
+
+
+# func_cygwin_to_mingw_pathlist_convert ARG
+# A pathlist conversion function for use when $host is *mingw*
+# but $build is *cygwin*. In this case, the cygpath program
+# provided by the $build environment is sufficient for all
+# conversions.
+#
+# ARG is the pathlist to be converted; the result is available
+# in func_to_host_pathlist_result.
+func_cygwin_to_mingw_pathlist_convert ()
+{
+  func_to_host_pathlist_result="$1"
+  if test -n "$1"; then
+    # 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_stripname : : "$1"
+    func_to_host_pathlist_tmp1=$func_stripname_result
+    func_to_host_pathlist_result=`cygpath -m -p "$func_to_host_pathlist_tmp1"`
+    func_pathlist_convert_check_mingw "$func_to_host_pathlist_tmp1" \
+      "$func_to_host_pathlist_result"
+    func_pathlist_front_back_pathsep ":*" "*:" ";" "$1"
+  fi
+}
+# end func_cygwin_to_mingw_pathlist_convert
+
+
+# func_nix_to_mingw_pathlist_convert ARG
+# A pathlist conversion function for use when $host is *mingw*
+# but $build is some *nix variant. In this case, we assume
+# that a wine environment with a working winepath executable
+# is available in $build's $PATH.
+#
+# ARG is the pathlist to be converted; the result is available
+# in func_to_host_pathlist_result.
+func_nix_to_mingw_pathlist_convert ()
+{
+  func_to_host_pathlist_result="$1"
+  if test -n "$1"; then
+    # 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_stripname : : "$1"
+    func_to_host_pathlist_tmp1=$func_stripname_result
+    func_wine_to_win32_pathlist "$func_to_host_pathlist_tmp1"
+    func_to_host_pathlist_result="$func_wine_to_win32_pathlist_result"
+    func_pathlist_convert_check_mingw "$func_to_host_pathlist_tmp1" \
+      "$func_to_host_pathlist_result"
+    func_pathlist_front_back_pathsep ":*" "*:" ";" "$1"
+  fi
+}
+# end func_nix_to_mingw_pathlist_convert
+
+
+# func_msys_to_cygwin_pathlist_convert ARG
+# A pathlist conversion function for use when $host is *cygwin*
+# but $build is *mingw* (that is, msys). This implies running
+# a cross build from msys to cygwin -- but msys has notorious
+# problems executing cygwin apps, because of conflicts between
+# cygwin1.dll and msys-1.0.dll. However, we'll try it. First,
+# convert from msys to win32, then use func_cygpath to convert
+# from win32 to cygwin. Requires LT_CYGPATH.
+#
+# ARG is the pathlist to be converted; the result is available
+# in func_to_host_pathlist_result.
+func_msys_to_cygwin_pathlist_convert ()
+{
+  func_to_host_pathlist_result="$1"
+  if test -n "$1"; then
+    # 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_stripname : : "$1"
+    func_to_host_pathlist_tmp1=$func_stripname_result
+    func_msys_to_win32 "$func_to_host_pathlist_tmp1"
+    func_cygpath -u -p "$func_msys_to_win32_result"
+    func_to_host_pathlist_result="$func_cygpath_result"
+    func_pathlist_convert_check "$func_to_host_pathlist_tmp1" \
+      "$func_to_host_pathlist_result"
+    func_pathlist_front_back_pathsep ":*" "*:" ":" "$1"
   fi
 }
-# end: func_to_host_pathlist
+# end func_msys_to_cygwin_pathlist_convert
+
+
+# func_nix_to_cygwin_pathlist_convert ARG
+# A pathlist conversion function for use when $host is *cygwin*
+# but $build is some *nix variant. In this case, we assume
+# that a wine environment with a working winepath executable
+# is available in $build's $PATH, and that cygwin is installed
+# within that wine environment. Requires LT_CYGPATH (see
+# func_cygpath).
+#
+# ARG is the pathlist to be converted; the result is available
+# in func_to_host_pathlist_result.
+func_nix_to_cygwin_pathlist_convert ()
+{
+  func_to_host_pathlist_result="$1"
+  if test -n "$1"; then
+    # 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_stripname : : "$1"
+    func_to_host_pathlist_tmp1=$func_stripname_result
+    func_wine_to_win32_pathlist "$func_to_host_pathlist_tmp1"
+    func_cygpath -u -p "$func_wine_to_win32_pathlist_result"
+    func_to_host_pathlist_result="$func_cygpath_result"
+    func_pathlist_convert_check "$func_to_host_pathlist_tmp1" \
+      "$func_to_host_pathlist_result"
+    func_pathlist_front_back_pathsep ":*" "*:" ":" "$1"
+  fi
+}
+# end func_nix_to_cygwin_pathlist_convert
+
 
 # func_emit_cwrapperexe_src
 # emit the source code for a wrapper executable on stdout
diff --git a/libltdl/m4/libtool.m4 b/libltdl/m4/libtool.m4
index 20bf078..6761740 100644
--- a/libltdl/m4/libtool.m4
+++ b/libltdl/m4/libtool.m4
@@ -166,6 +166,7 @@ _LT_DECL([], [exeext], [0], [Executable file suffix 
(normally "")])dnl
 dnl
 m4_require([_LT_FILEUTILS_DEFAULTS])dnl
 m4_require([_LT_CHECK_SHELL_FEATURES])dnl
+m4_require([_LT_PATH_CONVERSION_FUNCTIONS])dnl
 m4_require([_LT_CMD_RELOAD])dnl
 m4_require([_LT_CHECK_MAGIC_METHOD])dnl
 m4_require([_LT_CMD_OLD_ARCHIVE])dnl
@@ -7304,3 +7305,58 @@ _LT_EOF
     ;;
   esac
 ])
+
+# _LT_PATH_CONVERSION_FUNCTIONS
+# -----------------------------
+# Determine which path conversion functions should be
+# used by func_to_host_path and func_to_host_pathlist.
+# These are needed for certain cross-compile configurations
+# and "native" mingw (which is actually an msys->mingw
+# cross).
+m4_defun([_LT_PATH_CONVERSION_FUNCTIONS],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_CANONICAL_BUILD])dnl
+case $host in
+  *mingw* )
+    case $build in
+      *mingw* ) # actually msys
+        lt_to_host_path_cmd=func_msys_to_mingw_path_convert
+        lt_to_host_pathlist_cmd=func_msys_to_mingw_pathlist_convert
+        ;;
+      *cygwin* )
+        lt_to_host_path_cmd=func_cygwin_to_mingw_path_convert
+        lt_to_host_pathlist_cmd=func_cygwin_to_mingw_pathlist_convert
+        ;;
+      * ) # otherwise, assume *nix
+        lt_to_host_path_cmd=func_nix_to_mingw_path_convert
+        lt_to_host_pathlist_cmd=func_nix_to_mingw_pathlist_convert
+        ;;
+    esac
+    ;;
+  *cygwin* )
+    case $build in
+      *mingw* ) # actually msys
+        lt_to_host_path_cmd=func_msys_to_cygwin_path_convert
+        lt_to_host_pathlist_cmd=func_msys_to_cygwin_pathlist_convert
+        ;;
+      *cygwin* )
+        lt_to_host_path_cmd=func_noop_path_convert
+        lt_to_host_pathlist_cmd=func_noop_pathlist_convert
+        ;;
+      * ) # otherwise, assume *nix
+        lt_to_host_path_cmd=func_nix_to_cygwin_path_convert
+        lt_to_host_pathlist_cmd=func_nix_to_cygwin_pathlist_convert
+        ;;
+    esac
+    ;;
+  * ) # unhandled hosts (and "normal" native builds)
+    lt_to_host_path_cmd=func_noop_path_convert
+    lt_to_host_pathlist_cmd=func_noop_pathlist_convert
+    ;;
+esac
+_LT_DECL([to_host_path_cmd], [lt_to_host_path_cmd],
+         [0], [convert $build paths to $host format])dnl
+_LT_DECL([to_host_pathlist_cmd], [lt_to_host_pathlist_cmd],
+         [0], [convert $build pathlists to $host format])dnl
+])# _LT_PATH_CONVERSION_FUNCTIONS
+
-- 
1.6.0.4





reply via email to

[Prev in Thread] Current Thread [Next in Thread]