>From c8344d25b28d300bf14124ed0fe36346a462a0f8 Mon Sep 17 00:00:00 2001
From: Peter Rosin
Date: Wed, 25 Aug 2010 08:55:01 +0200
Subject: [PATCH 1/7] Move path conversion functions earlier in the libtool script.
* libltdl/config/ltmain.m4sh (func_wine_to_win32_path)
(func_cygpath, func_msys_to_win32, func_path_convert_check)
(func_to_host_path, func_noop_path_convert)
(func_msys_to_mingw_path_convert)
(func_cygwin_to_mingw_path_convert)
(func_nix_to_mingw_path_convert)
(func_msys_to_cygwin_path_convert)
(func_nix_to_cygwin_path_convert): Move to before
func_mode_compile to make them usable from there.
Signed-off-by: Peter Rosin
---
ChangeLog | 13 +
libltdl/config/ltmain.m4sh | 560 ++++++++++++++++++++++----------------------
2 files changed, 295 insertions(+), 278 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 4f11204..cda261e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2010-08-25 Peter Rosin
+
+ Move path conversion functions earlier in the libtool script.
+ * libltdl/config/ltmain.m4sh (func_wine_to_win32_path)
+ (func_cygpath, func_msys_to_win32, func_path_convert_check)
+ (func_to_host_path, func_noop_path_convert)
+ (func_msys_to_mingw_path_convert)
+ (func_cygwin_to_mingw_path_convert)
+ (func_nix_to_mingw_path_convert)
+ (func_msys_to_cygwin_path_convert)
+ (func_nix_to_cygwin_path_convert): Move to before
+ func_mode_compile to make them usable from there.
+
2010-08-23 Charles Wilson
Fix syntax for cygwin-cross
diff --git a/libltdl/config/ltmain.m4sh b/libltdl/config/ltmain.m4sh
index 72927ba..01fabf8 100644
--- a/libltdl/config/ltmain.m4sh
+++ b/libltdl/config/ltmain.m4sh
@@ -646,6 +646,285 @@ EOF
}
}
+####################################
+# PATH CONVERSION HELPER FUNCTIONS #
+####################################
+
+# 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 ()
+{
+ $opt_debug
+ 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_wine_to_win32_path_tmp=`winepath -w "$1" 2>/dev/null`
+ if test "$?" -eq 0 && test -n "${func_wine_to_win32_path_tmp}"; then
+ func_wine_to_win32_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_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).
+#
+# 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
+# /etc/fstab) can coexist on the same Win32
+# instance. The cygpath.exe for cygwin installation #N in
+# /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 ()
+{
+ $opt_debug
+ 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 ()
+{
+ $opt_debug
+ 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 ()
+{
+ $opt_debug
+ 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
+
+
+#############################################
+# $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.
+# [*] 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 ()
+{
+ $opt_debug
+ 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 ()
+{
+ $opt_debug
+ 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 ()
+{
+ $opt_debug
+ func_to_host_path_result="$1"
+ if test -n "$1"; then
+ 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_msys_to_mingw_path_convert
+
+
+# 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.
+#
+# ARG is the path to be converted; the result is available
+# in func_to_host_path_result.
+func_cygwin_to_mingw_path_convert ()
+{
+ $opt_debug
+ 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 ()
+{
+ $opt_debug
+ 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 ()
+{
+ $opt_debug
+ 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 ()
+{
+ $opt_debug
+ 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
+
+
# func_mode_compile arg...
func_mode_compile ()
{
@@ -2775,44 +3054,9 @@ fi\
"
}
-####################################
-# PATH CONVERSION HELPER FUNCTIONS #
-####################################
-
-# 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 ()
-{
- $opt_debug
- 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_wine_to_win32_path_tmp=`winepath -w "$1" 2>/dev/null`
- if test "$?" -eq 0 && test -n "${func_wine_to_win32_path_tmp}"; then
- func_wine_to_win32_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
-
+########################################
+# PATHLIST CONVERSION HELPER FUNCTIONS #
+########################################
# func_wine_to_win32_pathlist ARG
# Helper function used by path conversion functions
@@ -2854,85 +3098,6 @@ func_wine_to_win32_pathlist ()
# end: func_wine_to_win32_pathlist
-# 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).
-#
-# 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
-# /etc/fstab) can coexist on the same Win32
-# instance. The cygpath.exe for cygwin installation #N in
-# /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 ()
-{
- $opt_debug
- 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 ()
-{
- $opt_debug
- 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 ()
-{
- $opt_debug
- 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 FROM_PATHSEP TO_PATHSEP FROM_PATHLIST TO_PATHLIST
# Verify that FROM_PATHLIST (a path in $build format) was converted
# $host format in TO_PATHLIST. Otherwise, emit an error message, but
@@ -2983,167 +3148,6 @@ func_pathlist_front_back_pathsep ()
# 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.
-# [*] 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 ()
-{
- $opt_debug
- 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 ()
-{
- $opt_debug
- 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 ()
-{
- $opt_debug
- func_to_host_path_result="$1"
- if test -n "$1"; then
- 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_msys_to_mingw_path_convert
-
-
-# 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.
-#
-# ARG is the path to be converted; the result is available
-# in func_to_host_path_result.
-func_cygwin_to_mingw_path_convert ()
-{
- $opt_debug
- 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 ()
-{
- $opt_debug
- 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 ()
-{
- $opt_debug
- 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 ()
-{
- $opt_debug
- 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 #
#################################################
--
1.7.1