build-scripts/ltmain.sh
author Sam Lantinga <slouken@libsdl.org>
Wed, 05 Jun 2013 22:33:10 -0700
changeset 7286 04087a99e3f4
parent 7235 80fefd4af771
child 11720 9cbb45a5874f
permissions -rwxr-xr-x
Added testautomation to the Visual Studio 2008 project.
slouken@6446
     1
slouken@6446
     2
# libtool (GNU libtool) 2.4.2
slouken@6446
     3
# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
slouken@6446
     4
slouken@6446
     5
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
slouken@6446
     6
# 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
slouken@6446
     7
# This is free software; see the source for copying conditions.  There is NO
slouken@6446
     8
# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
slouken@6446
     9
slouken@6446
    10
# GNU Libtool is free software; you can redistribute it and/or modify
slouken@6446
    11
# it under the terms of the GNU General Public License as published by
slouken@6446
    12
# the Free Software Foundation; either version 2 of the License, or
slouken@6446
    13
# (at your option) any later version.
slouken@6446
    14
#
slouken@6446
    15
# As a special exception to the GNU General Public License,
slouken@6446
    16
# if you distribute this file as part of a program or library that
slouken@6446
    17
# is built using GNU Libtool, you may include this file under the
slouken@6446
    18
# same distribution terms that you use for the rest of that program.
slouken@6446
    19
#
slouken@6446
    20
# GNU Libtool is distributed in the hope that it will be useful, but
slouken@6446
    21
# WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@6446
    22
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
slouken@6446
    23
# General Public License for more details.
slouken@6446
    24
#
slouken@6446
    25
# You should have received a copy of the GNU General Public License
slouken@6446
    26
# along with GNU Libtool; see the file COPYING.  If not, a copy
slouken@6446
    27
# can be downloaded from http://www.gnu.org/licenses/gpl.html,
slouken@6446
    28
# or obtained by writing to the Free Software Foundation, Inc.,
slouken@6446
    29
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
slouken@6446
    30
slouken@6446
    31
# Usage: $progname [OPTION]... [MODE-ARG]...
slouken@6446
    32
#
slouken@6446
    33
# Provide generalized library-building support services.
slouken@6446
    34
#
slouken@6446
    35
#       --config             show all configuration variables
slouken@6446
    36
#       --debug              enable verbose shell tracing
slouken@6446
    37
#   -n, --dry-run            display commands without modifying any files
slouken@6446
    38
#       --features           display basic configuration information and exit
slouken@6446
    39
#       --mode=MODE          use operation mode MODE
slouken@6446
    40
#       --preserve-dup-deps  don't remove duplicate dependency libraries
slouken@6446
    41
#       --quiet, --silent    don't print informational messages
slouken@6446
    42
#       --no-quiet, --no-silent
slouken@6446
    43
#                            print informational messages (default)
slouken@6446
    44
#       --no-warn            don't display warning messages
slouken@6446
    45
#       --tag=TAG            use configuration variables from tag TAG
slouken@6446
    46
#   -v, --verbose            print more informational messages than default
slouken@6446
    47
#       --no-verbose         don't print the extra informational messages
slouken@6446
    48
#       --version            print version information
slouken@6446
    49
#   -h, --help, --help-all   print short, long, or detailed help message
slouken@6446
    50
#
slouken@6446
    51
# MODE must be one of the following:
slouken@6446
    52
#
slouken@6446
    53
#         clean              remove files from the build directory
slouken@6446
    54
#         compile            compile a source file into a libtool object
slouken@6446
    55
#         execute            automatically set library path, then run a program
slouken@6446
    56
#         finish             complete the installation of libtool libraries
slouken@6446
    57
#         install            install libraries or executables
slouken@6446
    58
#         link               create a library or an executable
slouken@6446
    59
#         uninstall          remove libraries from an installed directory
slouken@6446
    60
#
slouken@6446
    61
# MODE-ARGS vary depending on the MODE.  When passed as first option,
slouken@6446
    62
# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that.
slouken@6446
    63
# Try `$progname --help --mode=MODE' for a more detailed description of MODE.
slouken@6446
    64
#
slouken@6446
    65
# When reporting a bug, please describe a test case to reproduce it and
slouken@6446
    66
# include the following information:
slouken@6446
    67
#
slouken@6446
    68
#         host-triplet:	$host
slouken@6446
    69
#         shell:		$SHELL
slouken@6446
    70
#         compiler:		$LTCC
slouken@6446
    71
#         compiler flags:		$LTCFLAGS
slouken@6446
    72
#         linker:		$LD (gnu? $with_gnu_ld)
slouken@6446
    73
#         $progname:	(GNU libtool) 2.4.2
slouken@6446
    74
#         automake:	$automake_version
slouken@6446
    75
#         autoconf:	$autoconf_version
slouken@6446
    76
#
slouken@6446
    77
# Report bugs to <bug-libtool@gnu.org>.
slouken@6446
    78
# GNU libtool home page: <http://www.gnu.org/software/libtool/>.
slouken@6446
    79
# General help using GNU software: <http://www.gnu.org/gethelp/>.
slouken@6446
    80
slouken@6446
    81
PROGRAM=libtool
slouken@6446
    82
PACKAGE=libtool
slouken@6446
    83
VERSION=2.4.2
slouken@6446
    84
TIMESTAMP=""
slouken@6446
    85
package_revision=1.3337
slouken@6446
    86
slouken@6446
    87
# Be Bourne compatible
slouken@6446
    88
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
slouken@6446
    89
  emulate sh
slouken@6446
    90
  NULLCMD=:
slouken@6446
    91
  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
slouken@6446
    92
  # is contrary to our usage.  Disable this feature.
slouken@6446
    93
  alias -g '${1+"$@"}'='"$@"'
slouken@6446
    94
  setopt NO_GLOB_SUBST
slouken@6446
    95
else
slouken@6446
    96
  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
slouken@6446
    97
fi
slouken@6446
    98
BIN_SH=xpg4; export BIN_SH # for Tru64
slouken@6446
    99
DUALCASE=1; export DUALCASE # for MKS sh
slouken@6446
   100
slouken@6446
   101
# A function that is used when there is no print builtin or printf.
slouken@6446
   102
func_fallback_echo ()
slouken@6446
   103
{
slouken@6446
   104
  eval 'cat <<_LTECHO_EOF
slouken@6446
   105
$1
slouken@6446
   106
_LTECHO_EOF'
slouken@6446
   107
}
slouken@6446
   108
slouken@6446
   109
# NLS nuisances: We save the old values to restore during execute mode.
slouken@6446
   110
lt_user_locale=
slouken@6446
   111
lt_safe_locale=
slouken@6446
   112
for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
slouken@6446
   113
do
slouken@6446
   114
  eval "if test \"\${$lt_var+set}\" = set; then
slouken@6446
   115
          save_$lt_var=\$$lt_var
slouken@6446
   116
          $lt_var=C
slouken@6446
   117
	  export $lt_var
slouken@6446
   118
	  lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
slouken@6446
   119
	  lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
slouken@6446
   120
	fi"
slouken@6446
   121
done
slouken@6446
   122
LC_ALL=C
slouken@6446
   123
LANGUAGE=C
slouken@6446
   124
export LANGUAGE LC_ALL
slouken@6446
   125
slouken@6446
   126
$lt_unset CDPATH
slouken@6446
   127
slouken@6446
   128
slouken@6446
   129
# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
slouken@6446
   130
# is ksh but when the shell is invoked as "sh" and the current value of
slouken@6446
   131
# the _XPG environment variable is not equal to 1 (one), the special
slouken@6446
   132
# positional parameter $0, within a function call, is the name of the
slouken@6446
   133
# function.
slouken@6446
   134
progpath="$0"
slouken@6446
   135
slouken@6446
   136
slouken@6446
   137
slouken@6446
   138
: ${CP="cp -f"}
slouken@6446
   139
test "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'}
slouken@6446
   140
: ${MAKE="make"}
slouken@6446
   141
: ${MKDIR="mkdir"}
slouken@6446
   142
: ${MV="mv -f"}
slouken@6446
   143
: ${RM="rm -f"}
slouken@6446
   144
: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
slouken@6446
   145
: ${Xsed="$SED -e 1s/^X//"}
slouken@6446
   146
slouken@6446
   147
# Global variables:
slouken@6446
   148
EXIT_SUCCESS=0
slouken@6446
   149
EXIT_FAILURE=1
slouken@6446
   150
EXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
slouken@6446
   151
EXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
slouken@6446
   152
slouken@6446
   153
exit_status=$EXIT_SUCCESS
slouken@6446
   154
slouken@6446
   155
# Make sure IFS has a sensible default
slouken@6446
   156
lt_nl='
slouken@6446
   157
'
slouken@6446
   158
IFS=" 	$lt_nl"
slouken@6446
   159
slouken@6446
   160
dirname="s,/[^/]*$,,"
slouken@6446
   161
basename="s,^.*/,,"
slouken@6446
   162
slouken@6446
   163
# func_dirname file append nondir_replacement
slouken@6446
   164
# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
slouken@6446
   165
# otherwise set result to NONDIR_REPLACEMENT.
slouken@6446
   166
func_dirname ()
slouken@6446
   167
{
slouken@6446
   168
    func_dirname_result=`$ECHO "${1}" | $SED "$dirname"`
slouken@6446
   169
    if test "X$func_dirname_result" = "X${1}"; then
slouken@6446
   170
      func_dirname_result="${3}"
slouken@6446
   171
    else
slouken@6446
   172
      func_dirname_result="$func_dirname_result${2}"
slouken@6446
   173
    fi
slouken@6446
   174
} # func_dirname may be replaced by extended shell implementation
slouken@6446
   175
slouken@6446
   176
slouken@6446
   177
# func_basename file
slouken@6446
   178
func_basename ()
slouken@6446
   179
{
slouken@6446
   180
    func_basename_result=`$ECHO "${1}" | $SED "$basename"`
slouken@6446
   181
} # func_basename may be replaced by extended shell implementation
slouken@6446
   182
slouken@6446
   183
slouken@6446
   184
# func_dirname_and_basename file append nondir_replacement
slouken@6446
   185
# perform func_basename and func_dirname in a single function
slouken@6446
   186
# call:
slouken@6446
   187
#   dirname:  Compute the dirname of FILE.  If nonempty,
slouken@6446
   188
#             add APPEND to the result, otherwise set result
slouken@6446
   189
#             to NONDIR_REPLACEMENT.
slouken@6446
   190
#             value returned in "$func_dirname_result"
slouken@6446
   191
#   basename: Compute filename of FILE.
slouken@6446
   192
#             value retuned in "$func_basename_result"
slouken@6446
   193
# Implementation must be kept synchronized with func_dirname
slouken@6446
   194
# and func_basename. For efficiency, we do not delegate to
slouken@6446
   195
# those functions but instead duplicate the functionality here.
slouken@6446
   196
func_dirname_and_basename ()
slouken@6446
   197
{
slouken@6446
   198
    # Extract subdirectory from the argument.
slouken@6446
   199
    func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"`
slouken@6446
   200
    if test "X$func_dirname_result" = "X${1}"; then
slouken@6446
   201
      func_dirname_result="${3}"
slouken@6446
   202
    else
slouken@6446
   203
      func_dirname_result="$func_dirname_result${2}"
slouken@6446
   204
    fi
slouken@6446
   205
    func_basename_result=`$ECHO "${1}" | $SED -e "$basename"`
slouken@6446
   206
} # func_dirname_and_basename may be replaced by extended shell implementation
slouken@6446
   207
slouken@6446
   208
slouken@6446
   209
# func_stripname prefix suffix name
slouken@6446
   210
# strip PREFIX and SUFFIX off of NAME.
slouken@6446
   211
# PREFIX and SUFFIX must not contain globbing or regex special
slouken@6446
   212
# characters, hashes, percent signs, but SUFFIX may contain a leading
slouken@6446
   213
# dot (in which case that matches only a dot).
slouken@6446
   214
# func_strip_suffix prefix name
slouken@6446
   215
func_stripname ()
slouken@6446
   216
{
slouken@6446
   217
    case ${2} in
slouken@6446
   218
      .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
slouken@6446
   219
      *)  func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
slouken@6446
   220
    esac
slouken@6446
   221
} # func_stripname may be replaced by extended shell implementation
slouken@6446
   222
slouken@6446
   223
slouken@6446
   224
# These SED scripts presuppose an absolute path with a trailing slash.
slouken@6446
   225
pathcar='s,^/\([^/]*\).*$,\1,'
slouken@6446
   226
pathcdr='s,^/[^/]*,,'
slouken@6446
   227
removedotparts=':dotsl
slouken@6446
   228
		s@/\./@/@g
slouken@6446
   229
		t dotsl
slouken@6446
   230
		s,/\.$,/,'
slouken@6446
   231
collapseslashes='s@/\{1,\}@/@g'
slouken@6446
   232
finalslash='s,/*$,/,'
slouken@6446
   233
slouken@6446
   234
# func_normal_abspath PATH
slouken@6446
   235
# Remove doubled-up and trailing slashes, "." path components,
slouken@6446
   236
# and cancel out any ".." path components in PATH after making
slouken@6446
   237
# it an absolute path.
slouken@6446
   238
#             value returned in "$func_normal_abspath_result"
slouken@6446
   239
func_normal_abspath ()
slouken@6446
   240
{
slouken@6446
   241
  # Start from root dir and reassemble the path.
slouken@6446
   242
  func_normal_abspath_result=
slouken@6446
   243
  func_normal_abspath_tpath=$1
slouken@6446
   244
  func_normal_abspath_altnamespace=
slouken@6446
   245
  case $func_normal_abspath_tpath in
slouken@6446
   246
    "")
slouken@6446
   247
      # Empty path, that just means $cwd.
slouken@6446
   248
      func_stripname '' '/' "`pwd`"
slouken@6446
   249
      func_normal_abspath_result=$func_stripname_result
slouken@6446
   250
      return
slouken@6446
   251
    ;;
slouken@6446
   252
    # The next three entries are used to spot a run of precisely
slouken@6446
   253
    # two leading slashes without using negated character classes;
slouken@6446
   254
    # we take advantage of case's first-match behaviour.
slouken@6446
   255
    ///*)
slouken@6446
   256
      # Unusual form of absolute path, do nothing.
slouken@6446
   257
    ;;
slouken@6446
   258
    //*)
slouken@6446
   259
      # Not necessarily an ordinary path; POSIX reserves leading '//'
slouken@6446
   260
      # and for example Cygwin uses it to access remote file shares
slouken@6446
   261
      # over CIFS/SMB, so we conserve a leading double slash if found.
slouken@6446
   262
      func_normal_abspath_altnamespace=/
slouken@6446
   263
    ;;
slouken@6446
   264
    /*)
slouken@6446
   265
      # Absolute path, do nothing.
slouken@6446
   266
    ;;
slouken@6446
   267
    *)
slouken@6446
   268
      # Relative path, prepend $cwd.
slouken@6446
   269
      func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
slouken@6446
   270
    ;;
slouken@6446
   271
  esac
slouken@6446
   272
  # Cancel out all the simple stuff to save iterations.  We also want
slouken@6446
   273
  # the path to end with a slash for ease of parsing, so make sure
slouken@6446
   274
  # there is one (and only one) here.
slouken@6446
   275
  func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
slouken@6446
   276
        -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"`
slouken@6446
   277
  while :; do
slouken@6446
   278
    # Processed it all yet?
slouken@6446
   279
    if test "$func_normal_abspath_tpath" = / ; then
slouken@6446
   280
      # If we ascended to the root using ".." the result may be empty now.
slouken@6446
   281
      if test -z "$func_normal_abspath_result" ; then
slouken@6446
   282
        func_normal_abspath_result=/
slouken@6446
   283
      fi
slouken@6446
   284
      break
slouken@6446
   285
    fi
slouken@6446
   286
    func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
slouken@6446
   287
        -e "$pathcar"`
slouken@6446
   288
    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
slouken@6446
   289
        -e "$pathcdr"`
slouken@6446
   290
    # Figure out what to do with it
slouken@6446
   291
    case $func_normal_abspath_tcomponent in
slouken@6446
   292
      "")
slouken@6446
   293
        # Trailing empty path component, ignore it.
slouken@6446
   294
      ;;
slouken@6446
   295
      ..)
slouken@6446
   296
        # Parent dir; strip last assembled component from result.
slouken@6446
   297
        func_dirname "$func_normal_abspath_result"
slouken@6446
   298
        func_normal_abspath_result=$func_dirname_result
slouken@6446
   299
      ;;
slouken@6446
   300
      *)
slouken@6446
   301
        # Actual path component, append it.
slouken@6446
   302
        func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent
slouken@6446
   303
      ;;
slouken@6446
   304
    esac
slouken@6446
   305
  done
slouken@6446
   306
  # Restore leading double-slash if one was found on entry.
slouken@6446
   307
  func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
slouken@6446
   308
}
slouken@6446
   309
slouken@6446
   310
# func_relative_path SRCDIR DSTDIR
slouken@6446
   311
# generates a relative path from SRCDIR to DSTDIR, with a trailing
slouken@6446
   312
# slash if non-empty, suitable for immediately appending a filename
slouken@6446
   313
# without needing to append a separator.
slouken@6446
   314
#             value returned in "$func_relative_path_result"
slouken@6446
   315
func_relative_path ()
slouken@6446
   316
{
slouken@6446
   317
  func_relative_path_result=
slouken@6446
   318
  func_normal_abspath "$1"
slouken@6446
   319
  func_relative_path_tlibdir=$func_normal_abspath_result
slouken@6446
   320
  func_normal_abspath "$2"
slouken@6446
   321
  func_relative_path_tbindir=$func_normal_abspath_result
slouken@6446
   322
slouken@6446
   323
  # Ascend the tree starting from libdir
slouken@6446
   324
  while :; do
slouken@6446
   325
    # check if we have found a prefix of bindir
slouken@6446
   326
    case $func_relative_path_tbindir in
slouken@6446
   327
      $func_relative_path_tlibdir)
slouken@6446
   328
        # found an exact match
slouken@6446
   329
        func_relative_path_tcancelled=
slouken@6446
   330
        break
slouken@6446
   331
        ;;
slouken@6446
   332
      $func_relative_path_tlibdir*)
slouken@6446
   333
        # found a matching prefix
slouken@6446
   334
        func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
slouken@6446
   335
        func_relative_path_tcancelled=$func_stripname_result
slouken@6446
   336
        if test -z "$func_relative_path_result"; then
slouken@6446
   337
          func_relative_path_result=.
slouken@6446
   338
        fi
slouken@6446
   339
        break
slouken@6446
   340
        ;;
slouken@6446
   341
      *)
slouken@6446
   342
        func_dirname $func_relative_path_tlibdir
slouken@6446
   343
        func_relative_path_tlibdir=${func_dirname_result}
slouken@6446
   344
        if test "x$func_relative_path_tlibdir" = x ; then
slouken@6446
   345
          # Have to descend all the way to the root!
slouken@6446
   346
          func_relative_path_result=../$func_relative_path_result
slouken@6446
   347
          func_relative_path_tcancelled=$func_relative_path_tbindir
slouken@6446
   348
          break
slouken@6446
   349
        fi
slouken@6446
   350
        func_relative_path_result=../$func_relative_path_result
slouken@6446
   351
        ;;
slouken@6446
   352
    esac
slouken@6446
   353
  done
slouken@6446
   354
slouken@6446
   355
  # Now calculate path; take care to avoid doubling-up slashes.
slouken@6446
   356
  func_stripname '' '/' "$func_relative_path_result"
slouken@6446
   357
  func_relative_path_result=$func_stripname_result
slouken@6446
   358
  func_stripname '/' '/' "$func_relative_path_tcancelled"
slouken@6446
   359
  if test "x$func_stripname_result" != x ; then
slouken@6446
   360
    func_relative_path_result=${func_relative_path_result}/${func_stripname_result}
slouken@6446
   361
  fi
slouken@6446
   362
slouken@6446
   363
  # Normalisation. If bindir is libdir, return empty string,
slouken@6446
   364
  # else relative path ending with a slash; either way, target
slouken@6446
   365
  # file name can be directly appended.
slouken@6446
   366
  if test ! -z "$func_relative_path_result"; then
slouken@6446
   367
    func_stripname './' '' "$func_relative_path_result/"
slouken@6446
   368
    func_relative_path_result=$func_stripname_result
slouken@6446
   369
  fi
slouken@6446
   370
}
slouken@6446
   371
slouken@6446
   372
# The name of this program:
slouken@6446
   373
func_dirname_and_basename "$progpath"
slouken@6446
   374
progname=$func_basename_result
slouken@6446
   375
slouken@6446
   376
# Make sure we have an absolute path for reexecution:
slouken@6446
   377
case $progpath in
slouken@6446
   378
  [\\/]*|[A-Za-z]:\\*) ;;
slouken@6446
   379
  *[\\/]*)
slouken@6446
   380
     progdir=$func_dirname_result
slouken@6446
   381
     progdir=`cd "$progdir" && pwd`
slouken@6446
   382
     progpath="$progdir/$progname"
slouken@6446
   383
     ;;
slouken@6446
   384
  *)
slouken@6446
   385
     save_IFS="$IFS"
slouken@6446
   386
     IFS=${PATH_SEPARATOR-:}
slouken@6446
   387
     for progdir in $PATH; do
slouken@6446
   388
       IFS="$save_IFS"
slouken@6446
   389
       test -x "$progdir/$progname" && break
slouken@6446
   390
     done
slouken@6446
   391
     IFS="$save_IFS"
slouken@6446
   392
     test -n "$progdir" || progdir=`pwd`
slouken@6446
   393
     progpath="$progdir/$progname"
slouken@6446
   394
     ;;
slouken@6446
   395
esac
slouken@6446
   396
slouken@6446
   397
# Sed substitution that helps us do robust quoting.  It backslashifies
slouken@6446
   398
# metacharacters that are still active within double-quoted strings.
slouken@6446
   399
Xsed="${SED}"' -e 1s/^X//'
slouken@6446
   400
sed_quote_subst='s/\([`"$\\]\)/\\\1/g'
slouken@6446
   401
slouken@6446
   402
# Same as above, but do not quote variable references.
slouken@6446
   403
double_quote_subst='s/\(["`\\]\)/\\\1/g'
slouken@6446
   404
slouken@6446
   405
# Sed substitution that turns a string into a regex matching for the
slouken@6446
   406
# string literally.
slouken@6446
   407
sed_make_literal_regex='s,[].[^$\\*\/],\\&,g'
slouken@6446
   408
slouken@6446
   409
# Sed substitution that converts a w32 file name or path
slouken@6446
   410
# which contains forward slashes, into one that contains
slouken@6446
   411
# (escaped) backslashes.  A very naive implementation.
slouken@6446
   412
lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
slouken@6446
   413
slouken@6446
   414
# Re-`\' parameter expansions in output of double_quote_subst that were
slouken@6446
   415
# `\'-ed in input to the same.  If an odd number of `\' preceded a '$'
slouken@6446
   416
# in input to double_quote_subst, that '$' was protected from expansion.
slouken@6446
   417
# Since each input `\' is now two `\'s, look for any number of runs of
slouken@6446
   418
# four `\'s followed by two `\'s and then a '$'.  `\' that '$'.
slouken@6446
   419
bs='\\'
slouken@6446
   420
bs2='\\\\'
slouken@6446
   421
bs4='\\\\\\\\'
slouken@6446
   422
dollar='\$'
slouken@6446
   423
sed_double_backslash="\
slouken@6446
   424
  s/$bs4/&\\
slouken@6446
   425
/g
slouken@6446
   426
  s/^$bs2$dollar/$bs&/
slouken@6446
   427
  s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
slouken@6446
   428
  s/\n//g"
slouken@6446
   429
slouken@6446
   430
# Standard options:
slouken@6446
   431
opt_dry_run=false
slouken@6446
   432
opt_help=false
slouken@6446
   433
opt_quiet=false
slouken@6446
   434
opt_verbose=false
slouken@6446
   435
opt_warning=:
slouken@6446
   436
slouken@6446
   437
# func_echo arg...
slouken@6446
   438
# Echo program name prefixed message, along with the current mode
slouken@6446
   439
# name if it has been set yet.
slouken@6446
   440
func_echo ()
slouken@6446
   441
{
slouken@6446
   442
    $ECHO "$progname: ${opt_mode+$opt_mode: }$*"
slouken@6446
   443
}
slouken@6446
   444
slouken@6446
   445
# func_verbose arg...
slouken@6446
   446
# Echo program name prefixed message in verbose mode only.
slouken@6446
   447
func_verbose ()
slouken@6446
   448
{
slouken@6446
   449
    $opt_verbose && func_echo ${1+"$@"}
slouken@6446
   450
slouken@6446
   451
    # A bug in bash halts the script if the last line of a function
slouken@6446
   452
    # fails when set -e is in force, so we need another command to
slouken@6446
   453
    # work around that:
slouken@6446
   454
    :
slouken@6446
   455
}
slouken@6446
   456
slouken@6446
   457
# func_echo_all arg...
slouken@6446
   458
# Invoke $ECHO with all args, space-separated.
slouken@6446
   459
func_echo_all ()
slouken@6446
   460
{
slouken@6446
   461
    $ECHO "$*"
slouken@6446
   462
}
slouken@6446
   463
slouken@6446
   464
# func_error arg...
slouken@6446
   465
# Echo program name prefixed message to standard error.
slouken@6446
   466
func_error ()
slouken@6446
   467
{
slouken@6446
   468
    $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2
slouken@6446
   469
}
slouken@6446
   470
slouken@6446
   471
# func_warning arg...
slouken@6446
   472
# Echo program name prefixed warning message to standard error.
slouken@6446
   473
func_warning ()
slouken@6446
   474
{
slouken@6446
   475
    $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2
slouken@6446
   476
slouken@6446
   477
    # bash bug again:
slouken@6446
   478
    :
slouken@6446
   479
}
slouken@6446
   480
slouken@6446
   481
# func_fatal_error arg...
slouken@6446
   482
# Echo program name prefixed message to standard error, and exit.
slouken@6446
   483
func_fatal_error ()
slouken@6446
   484
{
slouken@6446
   485
    func_error ${1+"$@"}
slouken@6446
   486
    exit $EXIT_FAILURE
slouken@6446
   487
}
slouken@6446
   488
slouken@6446
   489
# func_fatal_help arg...
slouken@6446
   490
# Echo program name prefixed message to standard error, followed by
slouken@6446
   491
# a help hint, and exit.
slouken@6446
   492
func_fatal_help ()
slouken@6446
   493
{
slouken@6446
   494
    func_error ${1+"$@"}
slouken@6446
   495
    func_fatal_error "$help"
slouken@6446
   496
}
slouken@6446
   497
help="Try \`$progname --help' for more information."  ## default
slouken@6446
   498
slouken@6446
   499
slouken@6446
   500
# func_grep expression filename
slouken@6446
   501
# Check whether EXPRESSION matches any line of FILENAME, without output.
slouken@6446
   502
func_grep ()
slouken@6446
   503
{
slouken@6446
   504
    $GREP "$1" "$2" >/dev/null 2>&1
slouken@6446
   505
}
slouken@6446
   506
slouken@6446
   507
slouken@6446
   508
# func_mkdir_p directory-path
slouken@6446
   509
# Make sure the entire path to DIRECTORY-PATH is available.
slouken@6446
   510
func_mkdir_p ()
slouken@6446
   511
{
slouken@6446
   512
    my_directory_path="$1"
slouken@6446
   513
    my_dir_list=
slouken@6446
   514
slouken@6446
   515
    if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
slouken@6446
   516
slouken@6446
   517
      # Protect directory names starting with `-'
slouken@6446
   518
      case $my_directory_path in
slouken@6446
   519
        -*) my_directory_path="./$my_directory_path" ;;
slouken@6446
   520
      esac
slouken@6446
   521
slouken@6446
   522
      # While some portion of DIR does not yet exist...
slouken@6446
   523
      while test ! -d "$my_directory_path"; do
slouken@6446
   524
        # ...make a list in topmost first order.  Use a colon delimited
slouken@6446
   525
	# list incase some portion of path contains whitespace.
slouken@6446
   526
        my_dir_list="$my_directory_path:$my_dir_list"
slouken@6446
   527
slouken@6446
   528
        # If the last portion added has no slash in it, the list is done
slouken@6446
   529
        case $my_directory_path in */*) ;; *) break ;; esac
slouken@6446
   530
slouken@6446
   531
        # ...otherwise throw away the child directory and loop
slouken@6446
   532
        my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"`
slouken@6446
   533
      done
slouken@6446
   534
      my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'`
slouken@6446
   535
slouken@6446
   536
      save_mkdir_p_IFS="$IFS"; IFS=':'
slouken@6446
   537
      for my_dir in $my_dir_list; do
slouken@6446
   538
	IFS="$save_mkdir_p_IFS"
slouken@6446
   539
        # mkdir can fail with a `File exist' error if two processes
slouken@6446
   540
        # try to create one of the directories concurrently.  Don't
slouken@6446
   541
        # stop in that case!
slouken@6446
   542
        $MKDIR "$my_dir" 2>/dev/null || :
slouken@6446
   543
      done
slouken@6446
   544
      IFS="$save_mkdir_p_IFS"
slouken@6446
   545
slouken@6446
   546
      # Bail out if we (or some other process) failed to create a directory.
slouken@6446
   547
      test -d "$my_directory_path" || \
slouken@6446
   548
        func_fatal_error "Failed to create \`$1'"
slouken@6446
   549
    fi
slouken@6446
   550
}
slouken@6446
   551
slouken@6446
   552
slouken@6446
   553
# func_mktempdir [string]
slouken@6446
   554
# Make a temporary directory that won't clash with other running
slouken@6446
   555
# libtool processes, and avoids race conditions if possible.  If
slouken@6446
   556
# given, STRING is the basename for that directory.
slouken@6446
   557
func_mktempdir ()
slouken@6446
   558
{
slouken@6446
   559
    my_template="${TMPDIR-/tmp}/${1-$progname}"
slouken@6446
   560
slouken@6446
   561
    if test "$opt_dry_run" = ":"; then
slouken@6446
   562
      # Return a directory name, but don't create it in dry-run mode
slouken@6446
   563
      my_tmpdir="${my_template}-$$"
slouken@6446
   564
    else
slouken@6446
   565
slouken@6446
   566
      # If mktemp works, use that first and foremost
slouken@6446
   567
      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
slouken@6446
   568
slouken@6446
   569
      if test ! -d "$my_tmpdir"; then
slouken@6446
   570
        # Failing that, at least try and use $RANDOM to avoid a race
slouken@6446
   571
        my_tmpdir="${my_template}-${RANDOM-0}$$"
slouken@6446
   572
slouken@6446
   573
        save_mktempdir_umask=`umask`
slouken@6446
   574
        umask 0077
slouken@6446
   575
        $MKDIR "$my_tmpdir"
slouken@6446
   576
        umask $save_mktempdir_umask
slouken@6446
   577
      fi
slouken@6446
   578
slouken@6446
   579
      # If we're not in dry-run mode, bomb out on failure
slouken@6446
   580
      test -d "$my_tmpdir" || \
slouken@6446
   581
        func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
slouken@6446
   582
    fi
slouken@6446
   583
slouken@6446
   584
    $ECHO "$my_tmpdir"
slouken@6446
   585
}
slouken@6446
   586
slouken@6446
   587
slouken@6446
   588
# func_quote_for_eval arg
slouken@6446
   589
# Aesthetically quote ARG to be evaled later.
slouken@6446
   590
# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
slouken@6446
   591
# is double-quoted, suitable for a subsequent eval, whereas
slouken@6446
   592
# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
slouken@6446
   593
# which are still active within double quotes backslashified.
slouken@6446
   594
func_quote_for_eval ()
slouken@6446
   595
{
slouken@6446
   596
    case $1 in
slouken@6446
   597
      *[\\\`\"\$]*)
slouken@6446
   598
	func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;;
slouken@6446
   599
      *)
slouken@6446
   600
        func_quote_for_eval_unquoted_result="$1" ;;
slouken@6446
   601
    esac
slouken@6446
   602
slouken@6446
   603
    case $func_quote_for_eval_unquoted_result in
slouken@6446
   604
      # Double-quote args containing shell metacharacters to delay
slouken@6446
   605
      # word splitting, command substitution and and variable
slouken@6446
   606
      # expansion for a subsequent eval.
slouken@6446
   607
      # Many Bourne shells cannot handle close brackets correctly
slouken@6446
   608
      # in scan sets, so we specify it separately.
slouken@6446
   609
      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
slouken@6446
   610
        func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
slouken@6446
   611
        ;;
slouken@6446
   612
      *)
slouken@6446
   613
        func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
slouken@6446
   614
    esac
slouken@6446
   615
}
slouken@6446
   616
slouken@6446
   617
slouken@6446
   618
# func_quote_for_expand arg
slouken@6446
   619
# Aesthetically quote ARG to be evaled later; same as above,
slouken@6446
   620
# but do not quote variable references.
slouken@6446
   621
func_quote_for_expand ()
slouken@6446
   622
{
slouken@6446
   623
    case $1 in
slouken@6446
   624
      *[\\\`\"]*)
slouken@6446
   625
	my_arg=`$ECHO "$1" | $SED \
slouken@6446
   626
	    -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
slouken@6446
   627
      *)
slouken@6446
   628
        my_arg="$1" ;;
slouken@6446
   629
    esac
slouken@6446
   630
slouken@6446
   631
    case $my_arg in
slouken@6446
   632
      # Double-quote args containing shell metacharacters to delay
slouken@6446
   633
      # word splitting and command substitution for a subsequent eval.
slouken@6446
   634
      # Many Bourne shells cannot handle close brackets correctly
slouken@6446
   635
      # in scan sets, so we specify it separately.
slouken@6446
   636
      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
slouken@6446
   637
        my_arg="\"$my_arg\""
slouken@6446
   638
        ;;
slouken@6446
   639
    esac
slouken@6446
   640
slouken@6446
   641
    func_quote_for_expand_result="$my_arg"
slouken@6446
   642
}
slouken@6446
   643
slouken@6446
   644
slouken@6446
   645
# func_show_eval cmd [fail_exp]
slouken@6446
   646
# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
slouken@6446
   647
# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
slouken@6446
   648
# is given, then evaluate it.
slouken@6446
   649
func_show_eval ()
slouken@6446
   650
{
slouken@6446
   651
    my_cmd="$1"
slouken@6446
   652
    my_fail_exp="${2-:}"
slouken@6446
   653
slouken@6446
   654
    ${opt_silent-false} || {
slouken@6446
   655
      func_quote_for_expand "$my_cmd"
slouken@6446
   656
      eval "func_echo $func_quote_for_expand_result"
slouken@6446
   657
    }
slouken@6446
   658
slouken@6446
   659
    if ${opt_dry_run-false}; then :; else
slouken@6446
   660
      eval "$my_cmd"
slouken@6446
   661
      my_status=$?
slouken@6446
   662
      if test "$my_status" -eq 0; then :; else
slouken@6446
   663
	eval "(exit $my_status); $my_fail_exp"
slouken@6446
   664
      fi
slouken@6446
   665
    fi
slouken@6446
   666
}
slouken@6446
   667
slouken@6446
   668
slouken@6446
   669
# func_show_eval_locale cmd [fail_exp]
slouken@6446
   670
# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
slouken@6446
   671
# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
slouken@6446
   672
# is given, then evaluate it.  Use the saved locale for evaluation.
slouken@6446
   673
func_show_eval_locale ()
slouken@6446
   674
{
slouken@6446
   675
    my_cmd="$1"
slouken@6446
   676
    my_fail_exp="${2-:}"
slouken@6446
   677
slouken@6446
   678
    ${opt_silent-false} || {
slouken@6446
   679
      func_quote_for_expand "$my_cmd"
slouken@6446
   680
      eval "func_echo $func_quote_for_expand_result"
slouken@6446
   681
    }
slouken@6446
   682
slouken@6446
   683
    if ${opt_dry_run-false}; then :; else
slouken@6446
   684
      eval "$lt_user_locale
slouken@6446
   685
	    $my_cmd"
slouken@6446
   686
      my_status=$?
slouken@6446
   687
      eval "$lt_safe_locale"
slouken@6446
   688
      if test "$my_status" -eq 0; then :; else
slouken@6446
   689
	eval "(exit $my_status); $my_fail_exp"
slouken@6446
   690
      fi
slouken@6446
   691
    fi
slouken@6446
   692
}
slouken@6446
   693
slouken@6446
   694
# func_tr_sh
slouken@6446
   695
# Turn $1 into a string suitable for a shell variable name.
slouken@6446
   696
# Result is stored in $func_tr_sh_result.  All characters
slouken@6446
   697
# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
slouken@6446
   698
# if $1 begins with a digit, a '_' is prepended as well.
slouken@6446
   699
func_tr_sh ()
slouken@6446
   700
{
slouken@6446
   701
  case $1 in
slouken@6446
   702
  [0-9]* | *[!a-zA-Z0-9_]*)
slouken@6446
   703
    func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'`
slouken@6446
   704
    ;;
slouken@6446
   705
  * )
slouken@6446
   706
    func_tr_sh_result=$1
slouken@6446
   707
    ;;
slouken@6446
   708
  esac
slouken@6446
   709
}
slouken@6446
   710
slouken@6446
   711
slouken@6446
   712
# func_version
slouken@6446
   713
# Echo version message to standard output and exit.
slouken@6446
   714
func_version ()
slouken@6446
   715
{
slouken@6446
   716
    $opt_debug
slouken@6446
   717
slouken@6446
   718
    $SED -n '/(C)/!b go
slouken@6446
   719
	:more
slouken@6446
   720
	/\./!{
slouken@6446
   721
	  N
slouken@6446
   722
	  s/\n# / /
slouken@6446
   723
	  b more
slouken@6446
   724
	}
slouken@6446
   725
	:go
slouken@6446
   726
	/^# '$PROGRAM' (GNU /,/# warranty; / {
slouken@6446
   727
        s/^# //
slouken@6446
   728
	s/^# *$//
slouken@6446
   729
        s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
slouken@6446
   730
        p
slouken@6446
   731
     }' < "$progpath"
slouken@6446
   732
     exit $?
slouken@6446
   733
}
slouken@6446
   734
slouken@6446
   735
# func_usage
slouken@6446
   736
# Echo short help message to standard output and exit.
slouken@6446
   737
func_usage ()
slouken@6446
   738
{
slouken@6446
   739
    $opt_debug
slouken@6446
   740
slouken@6446
   741
    $SED -n '/^# Usage:/,/^#  *.*--help/ {
slouken@6446
   742
        s/^# //
slouken@6446
   743
	s/^# *$//
slouken@6446
   744
	s/\$progname/'$progname'/
slouken@6446
   745
	p
slouken@6446
   746
    }' < "$progpath"
slouken@6446
   747
    echo
slouken@6446
   748
    $ECHO "run \`$progname --help | more' for full usage"
slouken@6446
   749
    exit $?
slouken@6446
   750
}
slouken@6446
   751
slouken@6446
   752
# func_help [NOEXIT]
slouken@6446
   753
# Echo long help message to standard output and exit,
slouken@6446
   754
# unless 'noexit' is passed as argument.
slouken@6446
   755
func_help ()
slouken@6446
   756
{
slouken@6446
   757
    $opt_debug
slouken@6446
   758
slouken@6446
   759
    $SED -n '/^# Usage:/,/# Report bugs to/ {
slouken@6446
   760
	:print
slouken@6446
   761
        s/^# //
slouken@6446
   762
	s/^# *$//
slouken@6446
   763
	s*\$progname*'$progname'*
slouken@6446
   764
	s*\$host*'"$host"'*
slouken@6446
   765
	s*\$SHELL*'"$SHELL"'*
slouken@6446
   766
	s*\$LTCC*'"$LTCC"'*
slouken@6446
   767
	s*\$LTCFLAGS*'"$LTCFLAGS"'*
slouken@6446
   768
	s*\$LD*'"$LD"'*
slouken@6446
   769
	s/\$with_gnu_ld/'"$with_gnu_ld"'/
slouken@6446
   770
	s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/
slouken@6446
   771
	s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/
slouken@6446
   772
	p
slouken@6446
   773
	d
slouken@6446
   774
     }
slouken@6446
   775
     /^# .* home page:/b print
slouken@6446
   776
     /^# General help using/b print
slouken@6446
   777
     ' < "$progpath"
slouken@6446
   778
    ret=$?
slouken@6446
   779
    if test -z "$1"; then
slouken@6446
   780
      exit $ret
slouken@6446
   781
    fi
slouken@6446
   782
}
slouken@6446
   783
slouken@6446
   784
# func_missing_arg argname
slouken@6446
   785
# Echo program name prefixed message to standard error and set global
slouken@6446
   786
# exit_cmd.
slouken@6446
   787
func_missing_arg ()
slouken@6446
   788
{
slouken@6446
   789
    $opt_debug
slouken@6446
   790
slouken@6446
   791
    func_error "missing argument for $1."
slouken@6446
   792
    exit_cmd=exit
slouken@6446
   793
}
slouken@6446
   794
slouken@6446
   795
slouken@6446
   796
# func_split_short_opt shortopt
slouken@6446
   797
# Set func_split_short_opt_name and func_split_short_opt_arg shell
slouken@6446
   798
# variables after splitting SHORTOPT after the 2nd character.
slouken@6446
   799
func_split_short_opt ()
slouken@6446
   800
{
slouken@6446
   801
    my_sed_short_opt='1s/^\(..\).*$/\1/;q'
slouken@6446
   802
    my_sed_short_rest='1s/^..\(.*\)$/\1/;q'
slouken@6446
   803
slouken@6446
   804
    func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"`
slouken@6446
   805
    func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"`
slouken@6446
   806
} # func_split_short_opt may be replaced by extended shell implementation
slouken@6446
   807
slouken@6446
   808
slouken@6446
   809
# func_split_long_opt longopt
slouken@6446
   810
# Set func_split_long_opt_name and func_split_long_opt_arg shell
slouken@6446
   811
# variables after splitting LONGOPT at the `=' sign.
slouken@6446
   812
func_split_long_opt ()
slouken@6446
   813
{
slouken@6446
   814
    my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q'
slouken@6446
   815
    my_sed_long_arg='1s/^--[^=]*=//'
slouken@6446
   816
slouken@6446
   817
    func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"`
slouken@6446
   818
    func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"`
slouken@6446
   819
} # func_split_long_opt may be replaced by extended shell implementation
slouken@6446
   820
slouken@6446
   821
exit_cmd=:
slouken@6446
   822
slouken@6446
   823
slouken@6446
   824
slouken@6446
   825
slouken@6446
   826
slouken@6446
   827
magic="%%%MAGIC variable%%%"
slouken@6446
   828
magic_exe="%%%MAGIC EXE variable%%%"
slouken@6446
   829
slouken@6446
   830
# Global variables.
slouken@6446
   831
nonopt=
slouken@6446
   832
preserve_args=
slouken@6446
   833
lo2o="s/\\.lo\$/.${objext}/"
slouken@6446
   834
o2lo="s/\\.${objext}\$/.lo/"
slouken@6446
   835
extracted_archives=
slouken@6446
   836
extracted_serial=0
slouken@6446
   837
slouken@6446
   838
# If this variable is set in any of the actions, the command in it
slouken@6446
   839
# will be execed at the end.  This prevents here-documents from being
slouken@6446
   840
# left over by shells.
slouken@6446
   841
exec_cmd=
slouken@6446
   842
slouken@6446
   843
# func_append var value
slouken@6446
   844
# Append VALUE to the end of shell variable VAR.
slouken@6446
   845
func_append ()
slouken@6446
   846
{
slouken@6446
   847
    eval "${1}=\$${1}\${2}"
slouken@6446
   848
} # func_append may be replaced by extended shell implementation
slouken@6446
   849
slouken@6446
   850
# func_append_quoted var value
slouken@6446
   851
# Quote VALUE and append to the end of shell variable VAR, separated
slouken@6446
   852
# by a space.
slouken@6446
   853
func_append_quoted ()
slouken@6446
   854
{
slouken@6446
   855
    func_quote_for_eval "${2}"
slouken@6446
   856
    eval "${1}=\$${1}\\ \$func_quote_for_eval_result"
slouken@6446
   857
} # func_append_quoted may be replaced by extended shell implementation
slouken@6446
   858
slouken@6446
   859
slouken@6446
   860
# func_arith arithmetic-term...
slouken@6446
   861
func_arith ()
slouken@6446
   862
{
slouken@6446
   863
    func_arith_result=`expr "${@}"`
slouken@6446
   864
} # func_arith may be replaced by extended shell implementation
slouken@6446
   865
slouken@6446
   866
slouken@6446
   867
# func_len string
slouken@6446
   868
# STRING may not start with a hyphen.
slouken@6446
   869
func_len ()
slouken@6446
   870
{
slouken@6446
   871
    func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len`
slouken@6446
   872
} # func_len may be replaced by extended shell implementation
slouken@6446
   873
slouken@6446
   874
slouken@6446
   875
# func_lo2o object
slouken@6446
   876
func_lo2o ()
slouken@6446
   877
{
slouken@6446
   878
    func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"`
slouken@6446
   879
} # func_lo2o may be replaced by extended shell implementation
slouken@6446
   880
slouken@6446
   881
slouken@6446
   882
# func_xform libobj-or-source
slouken@6446
   883
func_xform ()
slouken@6446
   884
{
slouken@6446
   885
    func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'`
slouken@6446
   886
} # func_xform may be replaced by extended shell implementation
slouken@6446
   887
slouken@6446
   888
slouken@6446
   889
# func_fatal_configuration arg...
slouken@6446
   890
# Echo program name prefixed message to standard error, followed by
slouken@6446
   891
# a configuration failure hint, and exit.
slouken@6446
   892
func_fatal_configuration ()
slouken@6446
   893
{
slouken@6446
   894
    func_error ${1+"$@"}
slouken@6446
   895
    func_error "See the $PACKAGE documentation for more information."
slouken@6446
   896
    func_fatal_error "Fatal configuration error."
slouken@6446
   897
}
slouken@6446
   898
slouken@6446
   899
slouken@6446
   900
# func_config
slouken@6446
   901
# Display the configuration for all the tags in this script.
slouken@6446
   902
func_config ()
slouken@6446
   903
{
slouken@6446
   904
    re_begincf='^# ### BEGIN LIBTOOL'
slouken@6446
   905
    re_endcf='^# ### END LIBTOOL'
slouken@6446
   906
slouken@6446
   907
    # Default configuration.
slouken@6446
   908
    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
slouken@6446
   909
slouken@6446
   910
    # Now print the configurations for the tags.
slouken@6446
   911
    for tagname in $taglist; do
slouken@6446
   912
      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
slouken@6446
   913
    done
slouken@6446
   914
slouken@6446
   915
    exit $?
slouken@6446
   916
}
slouken@6446
   917
slouken@6446
   918
# func_features
slouken@6446
   919
# Display the features supported by this script.
slouken@6446
   920
func_features ()
slouken@6446
   921
{
slouken@6446
   922
    echo "host: $host"
slouken@6446
   923
    if test "$build_libtool_libs" = yes; then
slouken@6446
   924
      echo "enable shared libraries"
slouken@6446
   925
    else
slouken@6446
   926
      echo "disable shared libraries"
slouken@6446
   927
    fi
slouken@6446
   928
    if test "$build_old_libs" = yes; then
slouken@6446
   929
      echo "enable static libraries"
slouken@6446
   930
    else
slouken@6446
   931
      echo "disable static libraries"
slouken@6446
   932
    fi
slouken@6446
   933
slouken@6446
   934
    exit $?
slouken@6446
   935
}
slouken@6446
   936
slouken@6446
   937
# func_enable_tag tagname
slouken@6446
   938
# Verify that TAGNAME is valid, and either flag an error and exit, or
slouken@6446
   939
# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
slouken@6446
   940
# variable here.
slouken@6446
   941
func_enable_tag ()
slouken@6446
   942
{
slouken@6446
   943
  # Global variable:
slouken@6446
   944
  tagname="$1"
slouken@6446
   945
slouken@6446
   946
  re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
slouken@6446
   947
  re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
slouken@6446
   948
  sed_extractcf="/$re_begincf/,/$re_endcf/p"
slouken@6446
   949
slouken@6446
   950
  # Validate tagname.
slouken@6446
   951
  case $tagname in
slouken@6446
   952
    *[!-_A-Za-z0-9,/]*)
slouken@6446
   953
      func_fatal_error "invalid tag name: $tagname"
slouken@6446
   954
      ;;
slouken@6446
   955
  esac
slouken@6446
   956
slouken@6446
   957
  # Don't test for the "default" C tag, as we know it's
slouken@6446
   958
  # there but not specially marked.
slouken@6446
   959
  case $tagname in
slouken@6446
   960
    CC) ;;
slouken@6446
   961
    *)
slouken@6446
   962
      if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
slouken@6446
   963
	taglist="$taglist $tagname"
slouken@6446
   964
slouken@6446
   965
	# Evaluate the configuration.  Be careful to quote the path
slouken@6446
   966
	# and the sed script, to avoid splitting on whitespace, but
slouken@6446
   967
	# also don't use non-portable quotes within backquotes within
slouken@6446
   968
	# quotes we have to do it in 2 steps:
slouken@6446
   969
	extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
slouken@6446
   970
	eval "$extractedcf"
slouken@6446
   971
      else
slouken@6446
   972
	func_error "ignoring unknown tag $tagname"
slouken@6446
   973
      fi
slouken@6446
   974
      ;;
slouken@6446
   975
  esac
slouken@6446
   976
}
slouken@6446
   977
slouken@6446
   978
# func_check_version_match
slouken@6446
   979
# Ensure that we are using m4 macros, and libtool script from the same
slouken@6446
   980
# release of libtool.
slouken@6446
   981
func_check_version_match ()
slouken@6446
   982
{
slouken@6446
   983
  if test "$package_revision" != "$macro_revision"; then
slouken@6446
   984
    if test "$VERSION" != "$macro_version"; then
slouken@6446
   985
      if test -z "$macro_version"; then
slouken@6446
   986
        cat >&2 <<_LT_EOF
slouken@6446
   987
$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
slouken@6446
   988
$progname: definition of this LT_INIT comes from an older release.
slouken@6446
   989
$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
slouken@6446
   990
$progname: and run autoconf again.
slouken@6446
   991
_LT_EOF
slouken@6446
   992
      else
slouken@6446
   993
        cat >&2 <<_LT_EOF
slouken@6446
   994
$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
slouken@6446
   995
$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
slouken@6446
   996
$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
slouken@6446
   997
$progname: and run autoconf again.
slouken@6446
   998
_LT_EOF
slouken@6446
   999
      fi
slouken@6446
  1000
    else
slouken@6446
  1001
      cat >&2 <<_LT_EOF
slouken@6446
  1002
$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
slouken@6446
  1003
$progname: but the definition of this LT_INIT comes from revision $macro_revision.
slouken@6446
  1004
$progname: You should recreate aclocal.m4 with macros from revision $package_revision
slouken@6446
  1005
$progname: of $PACKAGE $VERSION and run autoconf again.
slouken@6446
  1006
_LT_EOF
slouken@6446
  1007
    fi
slouken@6446
  1008
slouken@6446
  1009
    exit $EXIT_MISMATCH
slouken@6446
  1010
  fi
slouken@6446
  1011
}
slouken@6446
  1012
slouken@6446
  1013
slouken@6446
  1014
# Shorthand for --mode=foo, only valid as the first argument
slouken@6446
  1015
case $1 in
slouken@6446
  1016
clean|clea|cle|cl)
slouken@6446
  1017
  shift; set dummy --mode clean ${1+"$@"}; shift
slouken@6446
  1018
  ;;
slouken@6446
  1019
compile|compil|compi|comp|com|co|c)
slouken@6446
  1020
  shift; set dummy --mode compile ${1+"$@"}; shift
slouken@6446
  1021
  ;;
slouken@6446
  1022
execute|execut|execu|exec|exe|ex|e)
slouken@6446
  1023
  shift; set dummy --mode execute ${1+"$@"}; shift
slouken@6446
  1024
  ;;
slouken@6446
  1025
finish|finis|fini|fin|fi|f)
slouken@6446
  1026
  shift; set dummy --mode finish ${1+"$@"}; shift
slouken@6446
  1027
  ;;
slouken@6446
  1028
install|instal|insta|inst|ins|in|i)
slouken@6446
  1029
  shift; set dummy --mode install ${1+"$@"}; shift
slouken@6446
  1030
  ;;
slouken@6446
  1031
link|lin|li|l)
slouken@6446
  1032
  shift; set dummy --mode link ${1+"$@"}; shift
slouken@6446
  1033
  ;;
slouken@6446
  1034
uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
slouken@6446
  1035
  shift; set dummy --mode uninstall ${1+"$@"}; shift
slouken@6446
  1036
  ;;
slouken@6446
  1037
esac
slouken@6446
  1038
slouken@6446
  1039
slouken@6446
  1040
slouken@6446
  1041
# Option defaults:
slouken@6446
  1042
opt_debug=:
slouken@6446
  1043
opt_dry_run=false
slouken@6446
  1044
opt_config=false
slouken@6446
  1045
opt_preserve_dup_deps=false
slouken@6446
  1046
opt_features=false
slouken@6446
  1047
opt_finish=false
slouken@6446
  1048
opt_help=false
slouken@6446
  1049
opt_help_all=false
slouken@6446
  1050
opt_silent=:
slouken@6446
  1051
opt_warning=:
slouken@6446
  1052
opt_verbose=:
slouken@6446
  1053
opt_silent=false
slouken@6446
  1054
opt_verbose=false
slouken@6446
  1055
slouken@6446
  1056
slouken@6446
  1057
# Parse options once, thoroughly.  This comes as soon as possible in the
slouken@6446
  1058
# script to make things like `--version' happen as quickly as we can.
slouken@6446
  1059
{
slouken@6446
  1060
  # this just eases exit handling
slouken@6446
  1061
  while test $# -gt 0; do
slouken@6446
  1062
    opt="$1"
slouken@6446
  1063
    shift
slouken@6446
  1064
    case $opt in
slouken@6446
  1065
      --debug|-x)	opt_debug='set -x'
slouken@6446
  1066
			func_echo "enabling shell trace mode"
slouken@6446
  1067
			$opt_debug
slouken@6446
  1068
			;;
slouken@6446
  1069
      --dry-run|--dryrun|-n)
slouken@6446
  1070
			opt_dry_run=:
slouken@6446
  1071
			;;
slouken@6446
  1072
      --config)
slouken@6446
  1073
			opt_config=:
slouken@6446
  1074
func_config
slouken@6446
  1075
			;;
slouken@6446
  1076
      --dlopen|-dlopen)
slouken@6446
  1077
			optarg="$1"
slouken@6446
  1078
			opt_dlopen="${opt_dlopen+$opt_dlopen
slouken@6446
  1079
}$optarg"
slouken@6446
  1080
			shift
slouken@6446
  1081
			;;
slouken@6446
  1082
      --preserve-dup-deps)
slouken@6446
  1083
			opt_preserve_dup_deps=:
slouken@6446
  1084
			;;
slouken@6446
  1085
      --features)
slouken@6446
  1086
			opt_features=:
slouken@6446
  1087
func_features
slouken@6446
  1088
			;;
slouken@6446
  1089
      --finish)
slouken@6446
  1090
			opt_finish=:
slouken@6446
  1091
set dummy --mode finish ${1+"$@"}; shift
slouken@6446
  1092
			;;
slouken@6446
  1093
      --help)
slouken@6446
  1094
			opt_help=:
slouken@6446
  1095
			;;
slouken@6446
  1096
      --help-all)
slouken@6446
  1097
			opt_help_all=:
slouken@6446
  1098
opt_help=': help-all'
slouken@6446
  1099
			;;
slouken@6446
  1100
      --mode)
slouken@6446
  1101
			test $# = 0 && func_missing_arg $opt && break
slouken@6446
  1102
			optarg="$1"
slouken@6446
  1103
			opt_mode="$optarg"
slouken@6446
  1104
case $optarg in
slouken@6446
  1105
  # Valid mode arguments:
slouken@6446
  1106
  clean|compile|execute|finish|install|link|relink|uninstall) ;;
slouken@6446
  1107
slouken@6446
  1108
  # Catch anything else as an error
slouken@6446
  1109
  *) func_error "invalid argument for $opt"
slouken@6446
  1110
     exit_cmd=exit
slouken@6446
  1111
     break
slouken@6446
  1112
     ;;
slouken@6446
  1113
esac
slouken@6446
  1114
			shift
slouken@6446
  1115
			;;
slouken@6446
  1116
      --no-silent|--no-quiet)
slouken@6446
  1117
			opt_silent=false
slouken@6446
  1118
func_append preserve_args " $opt"
slouken@6446
  1119
			;;
slouken@6446
  1120
      --no-warning|--no-warn)
slouken@6446
  1121
			opt_warning=false
slouken@6446
  1122
func_append preserve_args " $opt"
slouken@6446
  1123
			;;
slouken@6446
  1124
      --no-verbose)
slouken@6446
  1125
			opt_verbose=false
slouken@6446
  1126
func_append preserve_args " $opt"
slouken@6446
  1127
			;;
slouken@6446
  1128
      --silent|--quiet)
slouken@6446
  1129
			opt_silent=:
slouken@6446
  1130
func_append preserve_args " $opt"
slouken@6446
  1131
        opt_verbose=false
slouken@6446
  1132
			;;
slouken@6446
  1133
      --verbose|-v)
slouken@6446
  1134
			opt_verbose=:
slouken@6446
  1135
func_append preserve_args " $opt"
slouken@6446
  1136
opt_silent=false
slouken@6446
  1137
			;;
slouken@6446
  1138
      --tag)
slouken@6446
  1139
			test $# = 0 && func_missing_arg $opt && break
slouken@6446
  1140
			optarg="$1"
slouken@6446
  1141
			opt_tag="$optarg"
slouken@6446
  1142
func_append preserve_args " $opt $optarg"
slouken@6446
  1143
func_enable_tag "$optarg"
slouken@6446
  1144
			shift
slouken@6446
  1145
			;;
slouken@6446
  1146
slouken@6446
  1147
      -\?|-h)		func_usage				;;
slouken@6446
  1148
      --help)		func_help				;;
slouken@6446
  1149
      --version)	func_version				;;
slouken@6446
  1150
slouken@6446
  1151
      # Separate optargs to long options:
slouken@6446
  1152
      --*=*)
slouken@6446
  1153
			func_split_long_opt "$opt"
slouken@6446
  1154
			set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"}
slouken@6446
  1155
			shift
slouken@6446
  1156
			;;
slouken@6446
  1157
slouken@6446
  1158
      # Separate non-argument short options:
slouken@6446
  1159
      -\?*|-h*|-n*|-v*)
slouken@6446
  1160
			func_split_short_opt "$opt"
slouken@6446
  1161
			set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"}
slouken@6446
  1162
			shift
slouken@6446
  1163
			;;
slouken@6446
  1164
slouken@6446
  1165
      --)		break					;;
slouken@6446
  1166
      -*)		func_fatal_help "unrecognized option \`$opt'" ;;
slouken@6446
  1167
      *)		set dummy "$opt" ${1+"$@"};	shift; break  ;;
slouken@6446
  1168
    esac
slouken@6446
  1169
  done
slouken@6446
  1170
slouken@6446
  1171
  # Validate options:
slouken@6446
  1172
slouken@6446
  1173
  # save first non-option argument
slouken@6446
  1174
  if test "$#" -gt 0; then
slouken@6446
  1175
    nonopt="$opt"
slouken@6446
  1176
    shift
slouken@6446
  1177
  fi
slouken@6446
  1178
slouken@6446
  1179
  # preserve --debug
slouken@6446
  1180
  test "$opt_debug" = : || func_append preserve_args " --debug"
slouken@6446
  1181
slouken@6446
  1182
  case $host in
slouken@6446
  1183
    *cygwin* | *mingw* | *pw32* | *cegcc*)
slouken@6446
  1184
      # don't eliminate duplications in $postdeps and $predeps
slouken@6446
  1185
      opt_duplicate_compiler_generated_deps=:
slouken@6446
  1186
      ;;
slouken@6446
  1187
    *)
slouken@6446
  1188
      opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
slouken@6446
  1189
      ;;
slouken@6446
  1190
  esac
slouken@6446
  1191
slouken@6446
  1192
  $opt_help || {
slouken@6446
  1193
    # Sanity checks first:
slouken@6446
  1194
    func_check_version_match
slouken@6446
  1195
slouken@6446
  1196
    if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
slouken@6446
  1197
      func_fatal_configuration "not configured to build any kind of library"
slouken@6446
  1198
    fi
slouken@6446
  1199
slouken@6446
  1200
    # Darwin sucks
slouken@6446
  1201
    eval std_shrext=\"$shrext_cmds\"
slouken@6446
  1202
slouken@6446
  1203
    # Only execute mode is allowed to have -dlopen flags.
slouken@6446
  1204
    if test -n "$opt_dlopen" && test "$opt_mode" != execute; then
slouken@6446
  1205
      func_error "unrecognized option \`-dlopen'"
slouken@6446
  1206
      $ECHO "$help" 1>&2
slouken@6446
  1207
      exit $EXIT_FAILURE
slouken@6446
  1208
    fi
slouken@6446
  1209
slouken@6446
  1210
    # Change the help message to a mode-specific one.
slouken@6446
  1211
    generic_help="$help"
slouken@6446
  1212
    help="Try \`$progname --help --mode=$opt_mode' for more information."
slouken@6446
  1213
  }
slouken@6446
  1214
slouken@6446
  1215
slouken@6446
  1216
  # Bail if the options were screwed
slouken@6446
  1217
  $exit_cmd $EXIT_FAILURE
slouken@6446
  1218
}
slouken@6446
  1219
slouken@6446
  1220
slouken@6446
  1221
slouken@6446
  1222
slouken@6446
  1223
## ----------- ##
slouken@6446
  1224
##    Main.    ##
slouken@6446
  1225
## ----------- ##
slouken@6446
  1226
slouken@6446
  1227
# func_lalib_p file
slouken@6446
  1228
# True iff FILE is a libtool `.la' library or `.lo' object file.
slouken@6446
  1229
# This function is only a basic sanity check; it will hardly flush out
slouken@6446
  1230
# determined imposters.
slouken@6446
  1231
func_lalib_p ()
slouken@6446
  1232
{
slouken@6446
  1233
    test -f "$1" &&
slouken@6446
  1234
      $SED -e 4q "$1" 2>/dev/null \
slouken@6446
  1235
        | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
slouken@6446
  1236
}
slouken@6446
  1237
slouken@6446
  1238
# func_lalib_unsafe_p file
slouken@6446
  1239
# True iff FILE is a libtool `.la' library or `.lo' object file.
slouken@6446
  1240
# This function implements the same check as func_lalib_p without
slouken@6446
  1241
# resorting to external programs.  To this end, it redirects stdin and
slouken@6446
  1242
# closes it afterwards, without saving the original file descriptor.
slouken@6446
  1243
# As a safety measure, use it only where a negative result would be
slouken@6446
  1244
# fatal anyway.  Works if `file' does not exist.
slouken@6446
  1245
func_lalib_unsafe_p ()
slouken@6446
  1246
{
slouken@6446
  1247
    lalib_p=no
slouken@6446
  1248
    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
slouken@6446
  1249
	for lalib_p_l in 1 2 3 4
slouken@6446
  1250
	do
slouken@6446
  1251
	    read lalib_p_line
slouken@6446
  1252
	    case "$lalib_p_line" in
slouken@6446
  1253
		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
slouken@6446
  1254
	    esac
slouken@6446
  1255
	done
slouken@6446
  1256
	exec 0<&5 5<&-
slouken@6446
  1257
    fi
slouken@6446
  1258
    test "$lalib_p" = yes
slouken@6446
  1259
}
slouken@6446
  1260
slouken@6446
  1261
# func_ltwrapper_script_p file
slouken@6446
  1262
# True iff FILE is a libtool wrapper script
slouken@6446
  1263
# This function is only a basic sanity check; it will hardly flush out
slouken@6446
  1264
# determined imposters.
slouken@6446
  1265
func_ltwrapper_script_p ()
slouken@6446
  1266
{
slouken@6446
  1267
    func_lalib_p "$1"
slouken@6446
  1268
}
slouken@6446
  1269
slouken@6446
  1270
# func_ltwrapper_executable_p file
slouken@6446
  1271
# True iff FILE is a libtool wrapper executable
slouken@6446
  1272
# This function is only a basic sanity check; it will hardly flush out
slouken@6446
  1273
# determined imposters.
slouken@6446
  1274
func_ltwrapper_executable_p ()
slouken@6446
  1275
{
slouken@6446
  1276
    func_ltwrapper_exec_suffix=
slouken@6446
  1277
    case $1 in
slouken@6446
  1278
    *.exe) ;;
slouken@6446
  1279
    *) func_ltwrapper_exec_suffix=.exe ;;
slouken@6446
  1280
    esac
slouken@6446
  1281
    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
slouken@6446
  1282
}
slouken@6446
  1283
slouken@6446
  1284
# func_ltwrapper_scriptname file
slouken@6446
  1285
# Assumes file is an ltwrapper_executable
slouken@6446
  1286
# uses $file to determine the appropriate filename for a
slouken@6446
  1287
# temporary ltwrapper_script.
slouken@6446
  1288
func_ltwrapper_scriptname ()
slouken@6446
  1289
{
slouken@6446
  1290
    func_dirname_and_basename "$1" "" "."
slouken@6446
  1291
    func_stripname '' '.exe' "$func_basename_result"
slouken@6446
  1292
    func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
slouken@6446
  1293
}
slouken@6446
  1294
slouken@6446
  1295
# func_ltwrapper_p file
slouken@6446
  1296
# True iff FILE is a libtool wrapper script or wrapper executable
slouken@6446
  1297
# This function is only a basic sanity check; it will hardly flush out
slouken@6446
  1298
# determined imposters.
slouken@6446
  1299
func_ltwrapper_p ()
slouken@6446
  1300
{
slouken@6446
  1301
    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
slouken@6446
  1302
}
slouken@6446
  1303
slouken@6446
  1304
slouken@6446
  1305
# func_execute_cmds commands fail_cmd
slouken@6446
  1306
# Execute tilde-delimited COMMANDS.
slouken@6446
  1307
# If FAIL_CMD is given, eval that upon failure.
slouken@6446
  1308
# FAIL_CMD may read-access the current command in variable CMD!
slouken@6446
  1309
func_execute_cmds ()
slouken@6446
  1310
{
slouken@6446
  1311
    $opt_debug
slouken@6446
  1312
    save_ifs=$IFS; IFS='~'
slouken@6446
  1313
    for cmd in $1; do
slouken@6446
  1314
      IFS=$save_ifs
slouken@6446
  1315
      eval cmd=\"$cmd\"
slouken@6446
  1316
      func_show_eval "$cmd" "${2-:}"
slouken@6446
  1317
    done
slouken@6446
  1318
    IFS=$save_ifs
slouken@6446
  1319
}
slouken@6446
  1320
slouken@6446
  1321
slouken@6446
  1322
# func_source file
slouken@6446
  1323
# Source FILE, adding directory component if necessary.
slouken@6446
  1324
# Note that it is not necessary on cygwin/mingw to append a dot to
slouken@6446
  1325
# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
slouken@6446
  1326
# behavior happens only for exec(3), not for open(2)!  Also, sourcing
slouken@6446
  1327
# `FILE.' does not work on cygwin managed mounts.
slouken@6446
  1328
func_source ()
slouken@6446
  1329
{
slouken@6446
  1330
    $opt_debug
slouken@6446
  1331
    case $1 in
slouken@6446
  1332
    */* | *\\*)	. "$1" ;;
slouken@6446
  1333
    *)		. "./$1" ;;
slouken@6446
  1334
    esac
slouken@6446
  1335
}
slouken@6446
  1336
slouken@6446
  1337
slouken@6446
  1338
# func_resolve_sysroot PATH
slouken@6446
  1339
# Replace a leading = in PATH with a sysroot.  Store the result into
slouken@6446
  1340
# func_resolve_sysroot_result
slouken@6446
  1341
func_resolve_sysroot ()
slouken@6446
  1342
{
slouken@6446
  1343
  func_resolve_sysroot_result=$1
slouken@6446
  1344
  case $func_resolve_sysroot_result in
slouken@6446
  1345
  =*)
slouken@6446
  1346
    func_stripname '=' '' "$func_resolve_sysroot_result"
slouken@6446
  1347
    func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
slouken@6446
  1348
    ;;
slouken@6446
  1349
  esac
slouken@6446
  1350
}
slouken@6446
  1351
slouken@6446
  1352
# func_replace_sysroot PATH
slouken@6446
  1353
# If PATH begins with the sysroot, replace it with = and
slouken@6446
  1354
# store the result into func_replace_sysroot_result.
slouken@6446
  1355
func_replace_sysroot ()
slouken@6446
  1356
{
slouken@6446
  1357
  case "$lt_sysroot:$1" in
slouken@6446
  1358
  ?*:"$lt_sysroot"*)
slouken@6446
  1359
    func_stripname "$lt_sysroot" '' "$1"
slouken@6446
  1360
    func_replace_sysroot_result="=$func_stripname_result"
slouken@6446
  1361
    ;;
slouken@6446
  1362
  *)
slouken@6446
  1363
    # Including no sysroot.
slouken@6446
  1364
    func_replace_sysroot_result=$1
slouken@6446
  1365
    ;;
slouken@6446
  1366
  esac
slouken@6446
  1367
}
slouken@6446
  1368
slouken@6446
  1369
# func_infer_tag arg
slouken@6446
  1370
# Infer tagged configuration to use if any are available and
slouken@6446
  1371
# if one wasn't chosen via the "--tag" command line option.
slouken@6446
  1372
# Only attempt this if the compiler in the base compile
slouken@6446
  1373
# command doesn't match the default compiler.
slouken@6446
  1374
# arg is usually of the form 'gcc ...'
slouken@6446
  1375
func_infer_tag ()
slouken@6446
  1376
{
slouken@6446
  1377
    $opt_debug
slouken@6446
  1378
    if test -n "$available_tags" && test -z "$tagname"; then
slouken@6446
  1379
      CC_quoted=
slouken@6446
  1380
      for arg in $CC; do
slouken@6446
  1381
	func_append_quoted CC_quoted "$arg"
slouken@6446
  1382
      done
slouken@6446
  1383
      CC_expanded=`func_echo_all $CC`
slouken@6446
  1384
      CC_quoted_expanded=`func_echo_all $CC_quoted`
slouken@6446
  1385
      case $@ in
slouken@6446
  1386
      # Blanks in the command may have been stripped by the calling shell,
slouken@6446
  1387
      # but not from the CC environment variable when configure was run.
slouken@6446
  1388
      " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
slouken@6446
  1389
      " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
slouken@6446
  1390
      # Blanks at the start of $base_compile will cause this to fail
slouken@6446
  1391
      # if we don't check for them as well.
slouken@6446
  1392
      *)
slouken@6446
  1393
	for z in $available_tags; do
slouken@6446
  1394
	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
slouken@6446
  1395
	    # Evaluate the configuration.
slouken@6446
  1396
	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
slouken@6446
  1397
	    CC_quoted=
slouken@6446
  1398
	    for arg in $CC; do
slouken@6446
  1399
	      # Double-quote args containing other shell metacharacters.
slouken@6446
  1400
	      func_append_quoted CC_quoted "$arg"
slouken@6446
  1401
	    done
slouken@6446
  1402
	    CC_expanded=`func_echo_all $CC`
slouken@6446
  1403
	    CC_quoted_expanded=`func_echo_all $CC_quoted`
slouken@6446
  1404
	    case "$@ " in
slouken@6446
  1405
	    " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
slouken@6446
  1406
	    " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
slouken@6446
  1407
	      # The compiler in the base compile command matches
slouken@6446
  1408
	      # the one in the tagged configuration.
slouken@6446
  1409
	      # Assume this is the tagged configuration we want.
slouken@6446
  1410
	      tagname=$z
slouken@6446
  1411
	      break
slouken@6446
  1412
	      ;;
slouken@6446
  1413
	    esac
slouken@6446
  1414
	  fi
slouken@6446
  1415
	done
slouken@6446
  1416
	# If $tagname still isn't set, then no tagged configuration
slouken@6446
  1417
	# was found and let the user know that the "--tag" command
slouken@6446
  1418
	# line option must be used.
slouken@6446
  1419
	if test -z "$tagname"; then
slouken@6446
  1420
	  func_echo "unable to infer tagged configuration"
slouken@6446
  1421
	  func_fatal_error "specify a tag with \`--tag'"
slouken@6446
  1422
#	else
slouken@6446
  1423
#	  func_verbose "using $tagname tagged configuration"
slouken@6446
  1424
	fi
slouken@6446
  1425
	;;
slouken@6446
  1426
      esac
slouken@6446
  1427
    fi
slouken@6446
  1428
}
slouken@6446
  1429
slouken@6446
  1430
slouken@6446
  1431
slouken@6446
  1432
# func_write_libtool_object output_name pic_name nonpic_name
slouken@6446
  1433
# Create a libtool object file (analogous to a ".la" file),
slouken@6446
  1434
# but don't create it if we're doing a dry run.
slouken@6446
  1435
func_write_libtool_object ()
slouken@6446
  1436
{
slouken@6446
  1437
    write_libobj=${1}
slouken@6446
  1438
    if test "$build_libtool_libs" = yes; then
slouken@6446
  1439
      write_lobj=\'${2}\'
slouken@6446
  1440
    else
slouken@6446
  1441
      write_lobj=none
slouken@6446
  1442
    fi
slouken@6446
  1443
slouken@6446
  1444
    if test "$build_old_libs" = yes; then
slouken@6446
  1445
      write_oldobj=\'${3}\'
slouken@6446
  1446
    else
slouken@6446
  1447
      write_oldobj=none
slouken@6446
  1448
    fi
slouken@6446
  1449
slouken@6446
  1450
    $opt_dry_run || {
slouken@6446
  1451
      cat >${write_libobj}T <<EOF
slouken@6446
  1452
# $write_libobj - a libtool object file
slouken@6446
  1453
# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
slouken@6446
  1454
#
slouken@6446
  1455
# Please DO NOT delete this file!
slouken@6446
  1456
# It is necessary for linking the library.
slouken@6446
  1457
slouken@6446
  1458
# Name of the PIC object.
slouken@6446
  1459
pic_object=$write_lobj
slouken@6446
  1460
slouken@6446
  1461
# Name of the non-PIC object
slouken@6446
  1462
non_pic_object=$write_oldobj
slouken@6446
  1463
slouken@6446
  1464
EOF
slouken@6446
  1465
      $MV "${write_libobj}T" "${write_libobj}"
slouken@6446
  1466
    }
slouken@6446
  1467
}
slouken@6446
  1468
slouken@6446
  1469
slouken@6446
  1470
##################################################
slouken@6446
  1471
# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
slouken@6446
  1472
##################################################
slouken@6446
  1473
slouken@6446
  1474
# func_convert_core_file_wine_to_w32 ARG
slouken@6446
  1475
# Helper function used by file name conversion functions when $build is *nix,
slouken@6446
  1476
# and $host is mingw, cygwin, or some other w32 environment. Relies on a
slouken@6446
  1477
# correctly configured wine environment available, with the winepath program
slouken@6446
  1478
# in $build's $PATH.
slouken@6446
  1479
#
slouken@6446
  1480
# ARG is the $build file name to be converted to w32 format.
slouken@6446
  1481
# Result is available in $func_convert_core_file_wine_to_w32_result, and will
slouken@6446
  1482
# be empty on error (or when ARG is empty)
slouken@6446
  1483
func_convert_core_file_wine_to_w32 ()
slouken@6446
  1484
{
slouken@6446
  1485
  $opt_debug
slouken@6446
  1486
  func_convert_core_file_wine_to_w32_result="$1"
slouken@6446
  1487
  if test -n "$1"; then
slouken@6446
  1488
    # Unfortunately, winepath does not exit with a non-zero error code, so we
slouken@6446
  1489
    # are forced to check the contents of stdout. On the other hand, if the
slouken@6446
  1490
    # command is not found, the shell will set an exit code of 127 and print
slouken@6446
  1491
    # *an error message* to stdout. So we must check for both error code of
slouken@6446
  1492
    # zero AND non-empty stdout, which explains the odd construction:
slouken@6446
  1493
    func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
slouken@6446
  1494
    if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then
slouken@6446
  1495
      func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
slouken@6446
  1496
        $SED -e "$lt_sed_naive_backslashify"`
slouken@6446
  1497
    else
slouken@6446
  1498
      func_convert_core_file_wine_to_w32_result=
slouken@6446
  1499
    fi
slouken@6446
  1500
  fi
slouken@6446
  1501
}
slouken@6446
  1502
# end: func_convert_core_file_wine_to_w32
slouken@6446
  1503
slouken@6446
  1504
slouken@6446
  1505
# func_convert_core_path_wine_to_w32 ARG
slouken@6446
  1506
# Helper function used by path conversion functions when $build is *nix, and
slouken@6446
  1507
# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
slouken@6446
  1508
# configured wine environment available, with the winepath program in $build's
slouken@6446
  1509
# $PATH. Assumes ARG has no leading or trailing path separator characters.
slouken@6446
  1510
#
slouken@6446
  1511
# ARG is path to be converted from $build format to win32.
slouken@6446
  1512
# Result is available in $func_convert_core_path_wine_to_w32_result.
slouken@6446
  1513
# Unconvertible file (directory) names in ARG are skipped; if no directory names
slouken@6446
  1514
# are convertible, then the result may be empty.
slouken@6446
  1515
func_convert_core_path_wine_to_w32 ()
slouken@6446
  1516
{
slouken@6446
  1517
  $opt_debug
slouken@6446
  1518
  # unfortunately, winepath doesn't convert paths, only file names
slouken@6446
  1519
  func_convert_core_path_wine_to_w32_result=""
slouken@6446
  1520
  if test -n "$1"; then
slouken@6446
  1521
    oldIFS=$IFS
slouken@6446
  1522
    IFS=:
slouken@6446
  1523
    for func_convert_core_path_wine_to_w32_f in $1; do
slouken@6446
  1524
      IFS=$oldIFS
slouken@6446
  1525
      func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
slouken@6446
  1526
      if test -n "$func_convert_core_file_wine_to_w32_result" ; then
slouken@6446
  1527
        if test -z "$func_convert_core_path_wine_to_w32_result"; then
slouken@6446
  1528
          func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result"
slouken@6446
  1529
        else
slouken@6446
  1530
          func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
slouken@6446
  1531
        fi
slouken@6446
  1532
      fi
slouken@6446
  1533
    done
slouken@6446
  1534
    IFS=$oldIFS
slouken@6446
  1535
  fi
slouken@6446
  1536
}
slouken@6446
  1537
# end: func_convert_core_path_wine_to_w32
slouken@6446
  1538
slouken@6446
  1539
slouken@6446
  1540
# func_cygpath ARGS...
slouken@6446
  1541
# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
slouken@6446
  1542
# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
slouken@6446
  1543
# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
slouken@6446
  1544
# (2), returns the Cygwin file name or path in func_cygpath_result (input
slouken@6446
  1545
# file name or path is assumed to be in w32 format, as previously converted
slouken@6446
  1546
# from $build's *nix or MSYS format). In case (3), returns the w32 file name
slouken@6446
  1547
# or path in func_cygpath_result (input file name or path is assumed to be in
slouken@6446
  1548
# Cygwin format). Returns an empty string on error.
slouken@6446
  1549
#
slouken@6446
  1550
# ARGS are passed to cygpath, with the last one being the file name or path to
slouken@6446
  1551
# be converted.
slouken@6446
  1552
#
slouken@6446
  1553
# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
slouken@6446
  1554
# environment variable; do not put it in $PATH.
slouken@6446
  1555
func_cygpath ()
slouken@6446
  1556
{
slouken@6446
  1557
  $opt_debug
slouken@6446
  1558
  if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
slouken@6446
  1559
    func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
slouken@6446
  1560
    if test "$?" -ne 0; then
slouken@6446
  1561
      # on failure, ensure result is empty
slouken@6446
  1562
      func_cygpath_result=
slouken@6446
  1563
    fi
slouken@6446
  1564
  else
slouken@6446
  1565
    func_cygpath_result=
slouken@6446
  1566
    func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'"
slouken@6446
  1567
  fi
slouken@6446
  1568
}
slouken@6446
  1569
#end: func_cygpath
slouken@6446
  1570
slouken@6446
  1571
slouken@6446
  1572
# func_convert_core_msys_to_w32 ARG
slouken@6446
  1573
# Convert file name or path ARG from MSYS format to w32 format.  Return
slouken@6446
  1574
# result in func_convert_core_msys_to_w32_result.
slouken@6446
  1575
func_convert_core_msys_to_w32 ()
slouken@6446
  1576
{
slouken@6446
  1577
  $opt_debug
slouken@6446
  1578
  # awkward: cmd appends spaces to result
slouken@6446
  1579
  func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
slouken@6446
  1580
    $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"`
slouken@6446
  1581
}
slouken@6446
  1582
#end: func_convert_core_msys_to_w32
slouken@6446
  1583
slouken@6446
  1584
slouken@6446
  1585
# func_convert_file_check ARG1 ARG2
slouken@6446
  1586
# Verify that ARG1 (a file name in $build format) was converted to $host
slouken@6446
  1587
# format in ARG2. Otherwise, emit an error message, but continue (resetting
slouken@6446
  1588
# func_to_host_file_result to ARG1).
slouken@6446
  1589
func_convert_file_check ()
slouken@6446
  1590
{
slouken@6446
  1591
  $opt_debug
slouken@6446
  1592
  if test -z "$2" && test -n "$1" ; then
slouken@6446
  1593
    func_error "Could not determine host file name corresponding to"
slouken@6446
  1594
    func_error "  \`$1'"
slouken@6446
  1595
    func_error "Continuing, but uninstalled executables may not work."
slouken@6446
  1596
    # Fallback:
slouken@6446
  1597
    func_to_host_file_result="$1"
slouken@6446
  1598
  fi
slouken@6446
  1599
}
slouken@6446
  1600
# end func_convert_file_check
slouken@6446
  1601
slouken@6446
  1602
slouken@6446
  1603
# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
slouken@6446
  1604
# Verify that FROM_PATH (a path in $build format) was converted to $host
slouken@6446
  1605
# format in TO_PATH. Otherwise, emit an error message, but continue, resetting
slouken@6446
  1606
# func_to_host_file_result to a simplistic fallback value (see below).
slouken@6446
  1607
func_convert_path_check ()
slouken@6446
  1608
{
slouken@6446
  1609
  $opt_debug
slouken@6446
  1610
  if test -z "$4" && test -n "$3"; then
slouken@6446
  1611
    func_error "Could not determine the host path corresponding to"
slouken@6446
  1612
    func_error "  \`$3'"
slouken@6446
  1613
    func_error "Continuing, but uninstalled executables may not work."
slouken@6446
  1614
    # Fallback.  This is a deliberately simplistic "conversion" and
slouken@6446
  1615
    # should not be "improved".  See libtool.info.
slouken@6446
  1616
    if test "x$1" != "x$2"; then
slouken@6446
  1617
      lt_replace_pathsep_chars="s|$1|$2|g"
slouken@6446
  1618
      func_to_host_path_result=`echo "$3" |
slouken@6446
  1619
        $SED -e "$lt_replace_pathsep_chars"`
slouken@6446
  1620
    else
slouken@6446
  1621
      func_to_host_path_result="$3"
slouken@6446
  1622
    fi
slouken@6446
  1623
  fi
slouken@6446
  1624
}
slouken@6446
  1625
# end func_convert_path_check
slouken@6446
  1626
slouken@6446
  1627
slouken@6446
  1628
# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
slouken@6446
  1629
# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
slouken@6446
  1630
# and appending REPL if ORIG matches BACKPAT.
slouken@6446
  1631
func_convert_path_front_back_pathsep ()
slouken@6446
  1632
{
slouken@6446
  1633
  $opt_debug
slouken@6446
  1634
  case $4 in
slouken@6446
  1635
  $1 ) func_to_host_path_result="$3$func_to_host_path_result"
slouken@6446
  1636
    ;;
slouken@6446
  1637
  esac
slouken@6446
  1638
  case $4 in
slouken@6446
  1639
  $2 ) func_append func_to_host_path_result "$3"
slouken@6446
  1640
    ;;
slouken@6446
  1641
  esac
slouken@6446
  1642
}
slouken@6446
  1643
# end func_convert_path_front_back_pathsep
slouken@6446
  1644
slouken@6446
  1645
slouken@6446
  1646
##################################################
slouken@6446
  1647
# $build to $host FILE NAME CONVERSION FUNCTIONS #
slouken@6446
  1648
##################################################
slouken@6446
  1649
# invoked via `$to_host_file_cmd ARG'
slouken@6446
  1650
#
slouken@6446
  1651
# In each case, ARG is the path to be converted from $build to $host format.
slouken@6446
  1652
# Result will be available in $func_to_host_file_result.
slouken@6446
  1653
slouken@6446
  1654
slouken@6446
  1655
# func_to_host_file ARG
slouken@6446
  1656
# Converts the file name ARG from $build format to $host format. Return result
slouken@6446
  1657
# in func_to_host_file_result.
slouken@6446
  1658
func_to_host_file ()
slouken@6446
  1659
{
slouken@6446
  1660
  $opt_debug
slouken@6446
  1661
  $to_host_file_cmd "$1"
slouken@6446
  1662
}
slouken@6446
  1663
# end func_to_host_file
slouken@6446
  1664
slouken@6446
  1665
slouken@6446
  1666
# func_to_tool_file ARG LAZY
slouken@6446
  1667
# converts the file name ARG from $build format to toolchain format. Return
slouken@6446
  1668
# result in func_to_tool_file_result.  If the conversion in use is listed
slouken@6446
  1669
# in (the comma separated) LAZY, no conversion takes place.
slouken@6446
  1670
func_to_tool_file ()
slouken@6446
  1671
{
slouken@6446
  1672
  $opt_debug
slouken@6446
  1673
  case ,$2, in
slouken@6446
  1674
    *,"$to_tool_file_cmd",*)
slouken@6446
  1675
      func_to_tool_file_result=$1
slouken@6446
  1676
      ;;
slouken@6446
  1677
    *)
slouken@6446
  1678
      $to_tool_file_cmd "$1"
slouken@6446
  1679
      func_to_tool_file_result=$func_to_host_file_result
slouken@6446
  1680
      ;;
slouken@6446
  1681
  esac
slouken@6446
  1682
}
slouken@6446
  1683
# end func_to_tool_file
slouken@6446
  1684
slouken@6446
  1685
slouken@6446
  1686
# func_convert_file_noop ARG
slouken@6446
  1687
# Copy ARG to func_to_host_file_result.
slouken@6446
  1688
func_convert_file_noop ()
slouken@6446
  1689
{
slouken@6446
  1690
  func_to_host_file_result="$1"
slouken@6446
  1691
}
slouken@6446
  1692
# end func_convert_file_noop
slouken@6446
  1693
slouken@6446
  1694
slouken@6446
  1695
# func_convert_file_msys_to_w32 ARG
slouken@6446
  1696
# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
slouken@6446
  1697
# conversion to w32 is not available inside the cwrapper.  Returns result in
slouken@6446
  1698
# func_to_host_file_result.
slouken@6446
  1699
func_convert_file_msys_to_w32 ()
slouken@6446
  1700
{
slouken@6446
  1701
  $opt_debug
slouken@6446
  1702
  func_to_host_file_result="$1"
slouken@6446
  1703
  if test -n "$1"; then
slouken@6446
  1704
    func_convert_core_msys_to_w32 "$1"
slouken@6446
  1705
    func_to_host_file_result="$func_convert_core_msys_to_w32_result"
slouken@6446
  1706
  fi
slouken@6446
  1707
  func_convert_file_check "$1" "$func_to_host_file_result"
slouken@6446
  1708
}
slouken@6446
  1709
# end func_convert_file_msys_to_w32
slouken@6446
  1710
slouken@6446
  1711
slouken@6446
  1712
# func_convert_file_cygwin_to_w32 ARG
slouken@6446
  1713
# Convert file name ARG from Cygwin to w32 format.  Returns result in
slouken@6446
  1714
# func_to_host_file_result.
slouken@6446
  1715
func_convert_file_cygwin_to_w32 ()
slouken@6446
  1716
{
slouken@6446
  1717
  $opt_debug
slouken@6446
  1718
  func_to_host_file_result="$1"
slouken@6446
  1719
  if test -n "$1"; then
slouken@6446
  1720
    # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
slouken@6446
  1721
    # LT_CYGPATH in this case.
slouken@6446
  1722
    func_to_host_file_result=`cygpath -m "$1"`
slouken@6446
  1723
  fi
slouken@6446
  1724
  func_convert_file_check "$1" "$func_to_host_file_result"
slouken@6446
  1725
}
slouken@6446
  1726
# end func_convert_file_cygwin_to_w32
slouken@6446
  1727
slouken@6446
  1728
slouken@6446
  1729
# func_convert_file_nix_to_w32 ARG
slouken@6446
  1730
# Convert file name ARG from *nix to w32 format.  Requires a wine environment
slouken@6446
  1731
# and a working winepath. Returns result in func_to_host_file_result.
slouken@6446
  1732
func_convert_file_nix_to_w32 ()
slouken@6446
  1733
{
slouken@6446
  1734
  $opt_debug
slouken@6446
  1735
  func_to_host_file_result="$1"
slouken@6446
  1736
  if test -n "$1"; then
slouken@6446
  1737
    func_convert_core_file_wine_to_w32 "$1"
slouken@6446
  1738
    func_to_host_file_result="$func_convert_core_file_wine_to_w32_result"
slouken@6446
  1739
  fi
slouken@6446
  1740
  func_convert_file_check "$1" "$func_to_host_file_result"
slouken@6446
  1741
}
slouken@6446
  1742
# end func_convert_file_nix_to_w32
slouken@6446
  1743
slouken@6446
  1744
slouken@6446
  1745
# func_convert_file_msys_to_cygwin ARG
slouken@6446
  1746
# Convert file name ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
slouken@6446
  1747
# Returns result in func_to_host_file_result.
slouken@6446
  1748
func_convert_file_msys_to_cygwin ()
slouken@6446
  1749
{
slouken@6446
  1750
  $opt_debug
slouken@6446
  1751
  func_to_host_file_result="$1"
slouken@6446
  1752
  if test -n "$1"; then
slouken@6446
  1753
    func_convert_core_msys_to_w32 "$1"
slouken@6446
  1754
    func_cygpath -u "$func_convert_core_msys_to_w32_result"
slouken@6446
  1755
    func_to_host_file_result="$func_cygpath_result"
slouken@6446
  1756
  fi
slouken@6446
  1757
  func_convert_file_check "$1" "$func_to_host_file_result"
slouken@6446
  1758
}
slouken@6446
  1759
# end func_convert_file_msys_to_cygwin
slouken@6446
  1760
slouken@6446
  1761
slouken@6446
  1762
# func_convert_file_nix_to_cygwin ARG
slouken@6446
  1763
# Convert file name ARG from *nix to Cygwin format.  Requires Cygwin installed
slouken@6446
  1764
# in a wine environment, working winepath, and LT_CYGPATH set.  Returns result
slouken@6446
  1765
# in func_to_host_file_result.
slouken@6446
  1766
func_convert_file_nix_to_cygwin ()
slouken@6446
  1767
{
slouken@6446
  1768
  $opt_debug
slouken@6446
  1769
  func_to_host_file_result="$1"
slouken@6446
  1770
  if test -n "$1"; then
slouken@6446
  1771
    # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
slouken@6446
  1772
    func_convert_core_file_wine_to_w32 "$1"
slouken@6446
  1773
    func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
slouken@6446
  1774
    func_to_host_file_result="$func_cygpath_result"
slouken@6446
  1775
  fi
slouken@6446
  1776
  func_convert_file_check "$1" "$func_to_host_file_result"
slouken@6446
  1777
}
slouken@6446
  1778
# end func_convert_file_nix_to_cygwin
slouken@6446
  1779
slouken@6446
  1780
slouken@6446
  1781
#############################################
slouken@6446
  1782
# $build to $host PATH CONVERSION FUNCTIONS #
slouken@6446
  1783
#############################################
slouken@6446
  1784
# invoked via `$to_host_path_cmd ARG'
slouken@6446
  1785
#
slouken@6446
  1786
# In each case, ARG is the path to be converted from $build to $host format.
slouken@6446
  1787
# The result will be available in $func_to_host_path_result.
slouken@6446
  1788
#
slouken@6446
  1789
# Path separators are also converted from $build format to $host format.  If
slouken@6446
  1790
# ARG begins or ends with a path separator character, it is preserved (but
slouken@6446
  1791
# converted to $host format) on output.
slouken@6446
  1792
#
slouken@6446
  1793
# All path conversion functions are named using the following convention:
slouken@6446
  1794
#   file name conversion function    : func_convert_file_X_to_Y ()
slouken@6446
  1795
#   path conversion function         : func_convert_path_X_to_Y ()
slouken@6446
  1796
# where, for any given $build/$host combination the 'X_to_Y' value is the
slouken@6446
  1797
# same.  If conversion functions are added for new $build/$host combinations,
slouken@6446
  1798
# the two new functions must follow this pattern, or func_init_to_host_path_cmd
slouken@6446
  1799
# will break.
slouken@6446
  1800
slouken@6446
  1801
slouken@6446
  1802
# func_init_to_host_path_cmd
slouken@6446
  1803
# Ensures that function "pointer" variable $to_host_path_cmd is set to the
slouken@6446
  1804
# appropriate value, based on the value of $to_host_file_cmd.
slouken@6446
  1805
to_host_path_cmd=
slouken@6446
  1806
func_init_to_host_path_cmd ()
slouken@6446
  1807
{
slouken@6446
  1808
  $opt_debug
slouken@6446
  1809
  if test -z "$to_host_path_cmd"; then
slouken@6446
  1810
    func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
slouken@6446
  1811
    to_host_path_cmd="func_convert_path_${func_stripname_result}"
slouken@6446
  1812
  fi
slouken@6446
  1813
}
slouken@6446
  1814
slouken@6446
  1815
slouken@6446
  1816
# func_to_host_path ARG
slouken@6446
  1817
# Converts the path ARG from $build format to $host format. Return result
slouken@6446
  1818
# in func_to_host_path_result.
slouken@6446
  1819
func_to_host_path ()
slouken@6446
  1820
{
slouken@6446
  1821
  $opt_debug
slouken@6446
  1822
  func_init_to_host_path_cmd
slouken@6446
  1823
  $to_host_path_cmd "$1"
slouken@6446
  1824
}
slouken@6446
  1825
# end func_to_host_path
slouken@6446
  1826
slouken@6446
  1827
slouken@6446
  1828
# func_convert_path_noop ARG
slouken@6446
  1829
# Copy ARG to func_to_host_path_result.
slouken@6446
  1830
func_convert_path_noop ()
slouken@6446
  1831
{
slouken@6446
  1832
  func_to_host_path_result="$1"
slouken@6446
  1833
}
slouken@6446
  1834
# end func_convert_path_noop
slouken@6446
  1835
slouken@6446
  1836
slouken@6446
  1837
# func_convert_path_msys_to_w32 ARG
slouken@6446
  1838
# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
slouken@6446
  1839
# conversion to w32 is not available inside the cwrapper.  Returns result in
slouken@6446
  1840
# func_to_host_path_result.
slouken@6446
  1841
func_convert_path_msys_to_w32 ()
slouken@6446
  1842
{
slouken@6446
  1843
  $opt_debug
slouken@6446
  1844
  func_to_host_path_result="$1"
slouken@6446
  1845
  if test -n "$1"; then
slouken@6446
  1846
    # Remove leading and trailing path separator characters from ARG.  MSYS
slouken@6446
  1847
    # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
slouken@6446
  1848
    # and winepath ignores them completely.
slouken@6446
  1849
    func_stripname : : "$1"
slouken@6446
  1850
    func_to_host_path_tmp1=$func_stripname_result
slouken@6446
  1851
    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
slouken@6446
  1852
    func_to_host_path_result="$func_convert_core_msys_to_w32_result"
slouken@6446
  1853
    func_convert_path_check : ";" \
slouken@6446
  1854
      "$func_to_host_path_tmp1" "$func_to_host_path_result"
slouken@6446
  1855
    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
slouken@6446
  1856
  fi
slouken@6446
  1857
}
slouken@6446
  1858
# end func_convert_path_msys_to_w32
slouken@6446
  1859
slouken@6446
  1860
slouken@6446
  1861
# func_convert_path_cygwin_to_w32 ARG
slouken@6446
  1862
# Convert path ARG from Cygwin to w32 format.  Returns result in
slouken@6446
  1863
# func_to_host_file_result.
slouken@6446
  1864
func_convert_path_cygwin_to_w32 ()
slouken@6446
  1865
{
slouken@6446
  1866
  $opt_debug
slouken@6446
  1867
  func_to_host_path_result="$1"
slouken@6446
  1868
  if test -n "$1"; then
slouken@6446
  1869
    # See func_convert_path_msys_to_w32:
slouken@6446
  1870
    func_stripname : : "$1"
slouken@6446
  1871
    func_to_host_path_tmp1=$func_stripname_result
slouken@6446
  1872
    func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
slouken@6446
  1873
    func_convert_path_check : ";" \
slouken@6446
  1874
      "$func_to_host_path_tmp1" "$func_to_host_path_result"
slouken@6446
  1875
    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
slouken@6446
  1876
  fi
slouken@6446
  1877
}
slouken@6446
  1878
# end func_convert_path_cygwin_to_w32
slouken@6446
  1879
slouken@6446
  1880
slouken@6446
  1881
# func_convert_path_nix_to_w32 ARG
slouken@6446
  1882
# Convert path ARG from *nix to w32 format.  Requires a wine environment and
slouken@6446
  1883
# a working winepath.  Returns result in func_to_host_file_result.
slouken@6446
  1884
func_convert_path_nix_to_w32 ()
slouken@6446
  1885
{
slouken@6446
  1886
  $opt_debug
slouken@6446
  1887
  func_to_host_path_result="$1"
slouken@6446
  1888
  if test -n "$1"; then
slouken@6446
  1889
    # See func_convert_path_msys_to_w32:
slouken@6446
  1890
    func_stripname : : "$1"
slouken@6446
  1891
    func_to_host_path_tmp1=$func_stripname_result
slouken@6446
  1892
    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
slouken@6446
  1893
    func_to_host_path_result="$func_convert_core_path_wine_to_w32_result"
slouken@6446
  1894
    func_convert_path_check : ";" \
slouken@6446
  1895
      "$func_to_host_path_tmp1" "$func_to_host_path_result"
slouken@6446
  1896
    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
slouken@6446
  1897
  fi
slouken@6446
  1898
}
slouken@6446
  1899
# end func_convert_path_nix_to_w32
slouken@6446
  1900
slouken@6446
  1901
slouken@6446
  1902
# func_convert_path_msys_to_cygwin ARG
slouken@6446
  1903
# Convert path ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
slouken@6446
  1904
# Returns result in func_to_host_file_result.
slouken@6446
  1905
func_convert_path_msys_to_cygwin ()
slouken@6446
  1906
{
slouken@6446
  1907
  $opt_debug
slouken@6446
  1908
  func_to_host_path_result="$1"
slouken@6446
  1909
  if test -n "$1"; then
slouken@6446
  1910
    # See func_convert_path_msys_to_w32:
slouken@6446
  1911
    func_stripname : : "$1"
slouken@6446
  1912
    func_to_host_path_tmp1=$func_stripname_result
slouken@6446
  1913
    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
slouken@6446
  1914
    func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
slouken@6446
  1915
    func_to_host_path_result="$func_cygpath_result"
slouken@6446
  1916
    func_convert_path_check : : \
slouken@6446
  1917
      "$func_to_host_path_tmp1" "$func_to_host_path_result"
slouken@6446
  1918
    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
slouken@6446
  1919
  fi
slouken@6446
  1920
}
slouken@6446
  1921
# end func_convert_path_msys_to_cygwin
slouken@6446
  1922
slouken@6446
  1923
slouken@6446
  1924
# func_convert_path_nix_to_cygwin ARG
slouken@6446
  1925
# Convert path ARG from *nix to Cygwin format.  Requires Cygwin installed in a
slouken@6446
  1926
# a wine environment, working winepath, and LT_CYGPATH set.  Returns result in
slouken@6446
  1927
# func_to_host_file_result.
slouken@6446
  1928
func_convert_path_nix_to_cygwin ()
slouken@6446
  1929
{
slouken@6446
  1930
  $opt_debug
slouken@6446
  1931
  func_to_host_path_result="$1"
slouken@6446
  1932
  if test -n "$1"; then
slouken@6446
  1933
    # Remove leading and trailing path separator characters from
slouken@6446
  1934
    # ARG. msys behavior is inconsistent here, cygpath turns them
slouken@6446
  1935
    # into '.;' and ';.', and winepath ignores them completely.
slouken@6446
  1936
    func_stripname : : "$1"
slouken@6446
  1937
    func_to_host_path_tmp1=$func_stripname_result
slouken@6446
  1938
    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
slouken@6446
  1939
    func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
slouken@6446
  1940
    func_to_host_path_result="$func_cygpath_result"
slouken@6446
  1941
    func_convert_path_check : : \
slouken@6446
  1942
      "$func_to_host_path_tmp1" "$func_to_host_path_result"
slouken@6446
  1943
    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
slouken@6446
  1944
  fi
slouken@6446
  1945
}
slouken@6446
  1946
# end func_convert_path_nix_to_cygwin
slouken@6446
  1947
slouken@6446
  1948
slouken@6446
  1949
# func_mode_compile arg...
slouken@6446
  1950
func_mode_compile ()
slouken@6446
  1951
{
slouken@6446
  1952
    $opt_debug
slouken@6446
  1953
    # Get the compilation command and the source file.
slouken@6446
  1954
    base_compile=
slouken@6446
  1955
    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
slouken@6446
  1956
    suppress_opt=yes
slouken@6446
  1957
    suppress_output=
slouken@6446
  1958
    arg_mode=normal
slouken@6446
  1959
    libobj=
slouken@6446
  1960
    later=
slouken@6446
  1961
    pie_flag=
slouken@6446
  1962
slouken@6446
  1963
    for arg
slouken@6446
  1964
    do
slouken@6446
  1965
      case $arg_mode in
slouken@6446
  1966
      arg  )
slouken@6446
  1967
	# do not "continue".  Instead, add this to base_compile
slouken@6446
  1968
	lastarg="$arg"
slouken@6446
  1969
	arg_mode=normal
slouken@6446
  1970
	;;
slouken@6446
  1971
slouken@6446
  1972
      target )
slouken@6446
  1973
	libobj="$arg"
slouken@6446
  1974
	arg_mode=normal
slouken@6446
  1975
	continue
slouken@6446
  1976
	;;
slouken@6446
  1977
slouken@6446
  1978
      normal )
slouken@6446
  1979
	# Accept any command-line options.
slouken@6446
  1980
	case $arg in
slouken@6446
  1981
	-o)
slouken@6446
  1982
	  test -n "$libobj" && \
slouken@6446
  1983
	    func_fatal_error "you cannot specify \`-o' more than once"
slouken@6446
  1984
	  arg_mode=target
slouken@6446
  1985
	  continue
slouken@6446
  1986
	  ;;
slouken@6446
  1987
slouken@6446
  1988
	-pie | -fpie | -fPIE)
slouken@6446
  1989
          func_append pie_flag " $arg"
slouken@6446
  1990
	  continue
slouken@6446
  1991
	  ;;
slouken@6446
  1992
slouken@6446
  1993
	-shared | -static | -prefer-pic | -prefer-non-pic)
slouken@6446
  1994
	  func_append later " $arg"
slouken@6446
  1995
	  continue
slouken@6446
  1996
	  ;;
slouken@6446
  1997
slouken@6446
  1998
	-no-suppress)
slouken@6446
  1999
	  suppress_opt=no
slouken@6446
  2000
	  continue
slouken@6446
  2001
	  ;;
slouken@6446
  2002
slouken@6446
  2003
	-Xcompiler)
slouken@6446
  2004
	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
slouken@6446
  2005
	  continue      #  The current "srcfile" will either be retained or
slouken@6446
  2006
	  ;;            #  replaced later.  I would guess that would be a bug.
slouken@6446
  2007
slouken@6446
  2008
	-Wc,*)
slouken@6446
  2009
	  func_stripname '-Wc,' '' "$arg"
slouken@6446
  2010
	  args=$func_stripname_result
slouken@6446
  2011
	  lastarg=
slouken@6446
  2012
	  save_ifs="$IFS"; IFS=','
slouken@6446
  2013
	  for arg in $args; do
slouken@6446
  2014
	    IFS="$save_ifs"
slouken@6446
  2015
	    func_append_quoted lastarg "$arg"
slouken@6446
  2016
	  done
slouken@6446
  2017
	  IFS="$save_ifs"
slouken@6446
  2018
	  func_stripname ' ' '' "$lastarg"
slouken@6446
  2019
	  lastarg=$func_stripname_result
slouken@6446
  2020
slouken@6446
  2021
	  # Add the arguments to base_compile.
slouken@6446
  2022
	  func_append base_compile " $lastarg"
slouken@6446
  2023
	  continue
slouken@6446
  2024
	  ;;
slouken@6446
  2025
slouken@6446
  2026
	*)
slouken@6446
  2027
	  # Accept the current argument as the source file.
slouken@6446
  2028
	  # The previous "srcfile" becomes the current argument.
slouken@6446
  2029
	  #
slouken@6446
  2030
	  lastarg="$srcfile"
slouken@6446
  2031
	  srcfile="$arg"
slouken@6446
  2032
	  ;;
slouken@6446
  2033
	esac  #  case $arg
slouken@6446
  2034
	;;
slouken@6446
  2035
      esac    #  case $arg_mode
slouken@6446
  2036
slouken@6446
  2037
      # Aesthetically quote the previous argument.
slouken@6446
  2038
      func_append_quoted base_compile "$lastarg"
slouken@6446
  2039
    done # for arg
slouken@6446
  2040
slouken@6446
  2041
    case $arg_mode in
slouken@6446
  2042
    arg)
slouken@6446
  2043
      func_fatal_error "you must specify an argument for -Xcompile"
slouken@6446
  2044
      ;;
slouken@6446
  2045
    target)
slouken@6446
  2046
      func_fatal_error "you must specify a target with \`-o'"
slouken@6446
  2047
      ;;
slouken@6446
  2048
    *)
slouken@6446
  2049
      # Get the name of the library object.
slouken@6446
  2050
      test -z "$libobj" && {
slouken@6446
  2051
	func_basename "$srcfile"
slouken@6446
  2052
	libobj="$func_basename_result"
slouken@6446
  2053
      }
slouken@6446
  2054
      ;;
slouken@6446
  2055
    esac
slouken@6446
  2056
slouken@6446
  2057
    # Recognize several different file suffixes.
slouken@6446
  2058
    # If the user specifies -o file.o, it is replaced with file.lo
slouken@6446
  2059
    case $libobj in
slouken@6446
  2060
    *.[cCFSifmso] | \
slouken@6446
  2061
    *.ada | *.adb | *.ads | *.asm | \
slouken@6446
  2062
    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
slouken@6446
  2063
    *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
slouken@6446
  2064
      func_xform "$libobj"
slouken@6446
  2065
      libobj=$func_xform_result
slouken@6446
  2066
      ;;
slouken@6446
  2067
    esac
slouken@6446
  2068
slouken@6446
  2069
    case $libobj in
slouken@6446
  2070
    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
slouken@6446
  2071
    *)
slouken@6446
  2072
      func_fatal_error "cannot determine name of library object from \`$libobj'"
slouken@6446
  2073
      ;;
slouken@6446
  2074
    esac
slouken@6446
  2075
slouken@6446
  2076
    func_infer_tag $base_compile
slouken@6446
  2077
slouken@6446
  2078
    for arg in $later; do
slouken@6446
  2079
      case $arg in
slouken@6446
  2080
      -shared)
slouken@6446
  2081
	test "$build_libtool_libs" != yes && \
slouken@6446
  2082
	  func_fatal_configuration "can not build a shared library"
slouken@6446
  2083
	build_old_libs=no
slouken@6446
  2084
	continue
slouken@6446
  2085
	;;
slouken@6446
  2086
slouken@6446
  2087
      -static)
slouken@6446
  2088
	build_libtool_libs=no
slouken@6446
  2089
	build_old_libs=yes
slouken@6446
  2090
	continue
slouken@6446
  2091
	;;
slouken@6446
  2092
slouken@6446
  2093
      -prefer-pic)
slouken@6446
  2094
	pic_mode=yes
slouken@6446
  2095
	continue
slouken@6446
  2096
	;;
slouken@6446
  2097
slouken@6446
  2098
      -prefer-non-pic)
slouken@6446
  2099
	pic_mode=no
slouken@6446
  2100
	continue
slouken@6446
  2101
	;;
slouken@6446
  2102
      esac
slouken@6446
  2103
    done
slouken@6446
  2104
slouken@6446
  2105
    func_quote_for_eval "$libobj"
slouken@6446
  2106
    test "X$libobj" != "X$func_quote_for_eval_result" \
slouken@6446
  2107
      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
slouken@6446
  2108
      && func_warning "libobj name \`$libobj' may not contain shell special characters."
slouken@6446
  2109
    func_dirname_and_basename "$obj" "/" ""
slouken@6446
  2110
    objname="$func_basename_result"
slouken@6446
  2111
    xdir="$func_dirname_result"
slouken@6446
  2112
    lobj=${xdir}$objdir/$objname
slouken@6446
  2113
slouken@6446
  2114
    test -z "$base_compile" && \
slouken@6446
  2115
      func_fatal_help "you must specify a compilation command"
slouken@6446
  2116
slouken@6446
  2117
    # Delete any leftover library objects.
slouken@6446
  2118
    if test "$build_old_libs" = yes; then
slouken@6446
  2119
      removelist="$obj $lobj $libobj ${libobj}T"
slouken@6446
  2120
    else
slouken@6446
  2121
      removelist="$lobj $libobj ${libobj}T"
slouken@6446
  2122
    fi
slouken@6446
  2123
slouken@6446
  2124
    # On Cygwin there's no "real" PIC flag so we must build both object types
slouken@6446
  2125
    case $host_os in
slouken@6446
  2126
    cygwin* | mingw* | pw32* | os2* | cegcc*)
slouken@6446
  2127
      pic_mode=default
slouken@6446
  2128
      ;;
slouken@6446
  2129
    esac
slouken@6446
  2130
    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
slouken@6446
  2131
      # non-PIC code in shared libraries is not supported
slouken@6446
  2132
      pic_mode=default
slouken@6446
  2133
    fi
slouken@6446
  2134
slouken@6446
  2135
    # Calculate the filename of the output object if compiler does
slouken@6446
  2136
    # not support -o with -c
slouken@6446
  2137
    if test "$compiler_c_o" = no; then
slouken@6446
  2138
      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext}
slouken@6446
  2139
      lockfile="$output_obj.lock"
slouken@6446
  2140
    else
slouken@6446
  2141
      output_obj=
slouken@6446
  2142
      need_locks=no
slouken@6446
  2143
      lockfile=
slouken@6446
  2144
    fi
slouken@6446
  2145
slouken@6446
  2146
    # Lock this critical section if it is needed
slouken@6446
  2147
    # We use this script file to make the link, it avoids creating a new file
slouken@6446
  2148
    if test "$need_locks" = yes; then
slouken@6446
  2149
      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
slouken@6446
  2150
	func_echo "Waiting for $lockfile to be removed"
slouken@6446
  2151
	sleep 2
slouken@6446
  2152
      done
slouken@6446
  2153
    elif test "$need_locks" = warn; then
slouken@6446
  2154
      if test -f "$lockfile"; then
slouken@6446
  2155
	$ECHO "\
slouken@6446
  2156
*** ERROR, $lockfile exists and contains:
slouken@6446
  2157
`cat $lockfile 2>/dev/null`
slouken@6446
  2158
slouken@6446
  2159
This indicates that another process is trying to use the same
slouken@6446
  2160
temporary object file, and libtool could not work around it because
slouken@6446
  2161
your compiler does not support \`-c' and \`-o' together.  If you
slouken@6446
  2162
repeat this compilation, it may succeed, by chance, but you had better
slouken@6446
  2163
avoid parallel builds (make -j) in this platform, or get a better
slouken@6446
  2164
compiler."
slouken@6446
  2165
slouken@6446
  2166
	$opt_dry_run || $RM $removelist
slouken@6446
  2167
	exit $EXIT_FAILURE
slouken@6446
  2168
      fi
slouken@6446
  2169
      func_append removelist " $output_obj"
slouken@6446
  2170
      $ECHO "$srcfile" > "$lockfile"
slouken@6446
  2171
    fi
slouken@6446
  2172
slouken@6446
  2173
    $opt_dry_run || $RM $removelist
slouken@6446
  2174
    func_append removelist " $lockfile"
slouken@6446
  2175
    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
slouken@6446
  2176
slouken@6446
  2177
    func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
slouken@6446
  2178
    srcfile=$func_to_tool_file_result
slouken@6446
  2179
    func_quote_for_eval "$srcfile"
slouken@6446
  2180
    qsrcfile=$func_quote_for_eval_result
slouken@6446
  2181
slouken@6446
  2182
    # Only build a PIC object if we are building libtool libraries.
slouken@6446
  2183
    if test "$build_libtool_libs" = yes; then
slouken@6446
  2184
      # Without this assignment, base_compile gets emptied.
slouken@6446
  2185
      fbsd_hideous_sh_bug=$base_compile
slouken@6446
  2186
slouken@6446
  2187
      if test "$pic_mode" != no; then
slouken@6446
  2188
	command="$base_compile $qsrcfile $pic_flag"
slouken@6446
  2189
      else
slouken@6446
  2190
	# Don't build PIC code
slouken@6446
  2191
	command="$base_compile $qsrcfile"
slouken@6446
  2192
      fi
slouken@6446
  2193
slouken@6446
  2194
      func_mkdir_p "$xdir$objdir"
slouken@6446
  2195
slouken@6446
  2196
      if test -z "$output_obj"; then
slouken@6446
  2197
	# Place PIC objects in $objdir
slouken@6446
  2198
	func_append command " -o $lobj"
slouken@6446
  2199
      fi
slouken@6446
  2200
slouken@6446
  2201
      func_show_eval_locale "$command"	\
slouken@6446
  2202
          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
slouken@6446
  2203
slouken@6446
  2204
      if test "$need_locks" = warn &&
slouken@6446
  2205
	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
slouken@6446
  2206
	$ECHO "\
slouken@6446
  2207
*** ERROR, $lockfile contains:
slouken@6446
  2208
`cat $lockfile 2>/dev/null`
slouken@6446
  2209
slouken@6446
  2210
but it should contain:
slouken@6446
  2211
$srcfile
slouken@6446
  2212
slouken@6446
  2213
This indicates that another process is trying to use the same
slouken@6446
  2214
temporary object file, and libtool could not work around it because
slouken@6446
  2215
your compiler does not support \`-c' and \`-o' together.  If you
slouken@6446
  2216
repeat this compilation, it may succeed, by chance, but you had better
slouken@6446
  2217
avoid parallel builds (make -j) in this platform, or get a better
slouken@6446
  2218
compiler."
slouken@6446
  2219
slouken@6446
  2220
	$opt_dry_run || $RM $removelist
slouken@6446
  2221
	exit $EXIT_FAILURE
slouken@6446
  2222
      fi
slouken@6446
  2223
slouken@6446
  2224
      # Just move the object if needed, then go on to compile the next one
slouken@6446
  2225
      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
slouken@6446
  2226
	func_show_eval '$MV "$output_obj" "$lobj"' \
slouken@6446
  2227
	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
slouken@6446
  2228
      fi
slouken@6446
  2229
slouken@6446
  2230
      # Allow error messages only from the first compilation.
slouken@6446
  2231
      if test "$suppress_opt" = yes; then
slouken@6446
  2232
	suppress_output=' >/dev/null 2>&1'
slouken@6446
  2233
      fi
slouken@6446
  2234
    fi
slouken@6446
  2235
slouken@6446
  2236
    # Only build a position-dependent object if we build old libraries.
slouken@6446
  2237
    if test "$build_old_libs" = yes; then
slouken@6446
  2238
      if test "$pic_mode" != yes; then
slouken@6446
  2239
	# Don't build PIC code
slouken@6446
  2240
	command="$base_compile $qsrcfile$pie_flag"
slouken@6446
  2241
      else
slouken@6446
  2242
	command="$base_compile $qsrcfile $pic_flag"
slouken@6446
  2243
      fi
slouken@6446
  2244
      if test "$compiler_c_o" = yes; then
slouken@6446
  2245
	func_append command " -o $obj"
slouken@6446
  2246
      fi
slouken@6446
  2247
slouken@6446
  2248
      # Suppress compiler output if we already did a PIC compilation.
slouken@6446
  2249
      func_append command "$suppress_output"
slouken@6446
  2250
      func_show_eval_locale "$command" \
slouken@6446
  2251
        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
slouken@6446
  2252
slouken@6446
  2253
      if test "$need_locks" = warn &&
slouken@6446
  2254
	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
slouken@6446
  2255
	$ECHO "\
slouken@6446
  2256
*** ERROR, $lockfile contains:
slouken@6446
  2257
`cat $lockfile 2>/dev/null`
slouken@6446
  2258
slouken@6446
  2259
but it should contain:
slouken@6446
  2260
$srcfile
slouken@6446
  2261
slouken@6446
  2262
This indicates that another process is trying to use the same
slouken@6446
  2263
temporary object file, and libtool could not work around it because
slouken@6446
  2264
your compiler does not support \`-c' and \`-o' together.  If you
slouken@6446
  2265
repeat this compilation, it may succeed, by chance, but you had better
slouken@6446
  2266
avoid parallel builds (make -j) in this platform, or get a better
slouken@6446
  2267
compiler."
slouken@6446
  2268
slouken@6446
  2269
	$opt_dry_run || $RM $removelist
slouken@6446
  2270
	exit $EXIT_FAILURE
slouken@6446
  2271
      fi
slouken@6446
  2272
slouken@6446
  2273
      # Just move the object if needed
slouken@6446
  2274
      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
slouken@6446
  2275
	func_show_eval '$MV "$output_obj" "$obj"' \
slouken@6446
  2276
	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
slouken@6446
  2277
      fi
slouken@6446
  2278
    fi
slouken@6446
  2279
slouken@6446
  2280
    $opt_dry_run || {
slouken@6446
  2281
      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
slouken@6446
  2282
slouken@6446
  2283
      # Unlock the critical section if it was locked
slouken@6446
  2284
      if test "$need_locks" != no; then
slouken@6446
  2285
	removelist=$lockfile
slouken@6446
  2286
        $RM "$lockfile"
slouken@6446
  2287
      fi
slouken@6446
  2288
    }
slouken@6446
  2289
slouken@6446
  2290
    exit $EXIT_SUCCESS
slouken@6446
  2291
}
slouken@6446
  2292
slouken@6446
  2293
$opt_help || {
slouken@6446
  2294
  test "$opt_mode" = compile && func_mode_compile ${1+"$@"}
slouken@6446
  2295
}
slouken@6446
  2296
slouken@6446
  2297
func_mode_help ()
slouken@6446
  2298
{
slouken@6446
  2299
    # We need to display help for each of the modes.
slouken@6446
  2300
    case $opt_mode in
slouken@6446
  2301
      "")
slouken@6446
  2302
        # Generic help is extracted from the usage comments
slouken@6446
  2303
        # at the start of this file.
slouken@6446
  2304
        func_help
slouken@6446
  2305
        ;;
slouken@6446
  2306
slouken@6446
  2307
      clean)
slouken@6446
  2308
        $ECHO \
slouken@6446
  2309
"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
slouken@6446
  2310
slouken@6446
  2311
Remove files from the build directory.
slouken@6446
  2312
slouken@6446
  2313
RM is the name of the program to use to delete files associated with each FILE
slouken@6446
  2314
(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
slouken@6446
  2315
to RM.
slouken@6446
  2316
slouken@6446
  2317
If FILE is a libtool library, object or program, all the files associated
slouken@6446
  2318
with it are deleted. Otherwise, only FILE itself is deleted using RM."
slouken@6446
  2319
        ;;
slouken@6446
  2320
slouken@6446
  2321
      compile)
slouken@6446
  2322
      $ECHO \
slouken@6446
  2323
"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
slouken@6446
  2324
slouken@6446
  2325
Compile a source file into a libtool library object.
slouken@6446
  2326
slouken@6446
  2327
This mode accepts the following additional options:
slouken@6446
  2328
slouken@6446
  2329
  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
slouken@6446
  2330
  -no-suppress      do not suppress compiler output for multiple passes
slouken@6446
  2331
  -prefer-pic       try to build PIC objects only
slouken@6446
  2332
  -prefer-non-pic   try to build non-PIC objects only
slouken@6446
  2333
  -shared           do not build a \`.o' file suitable for static linking
slouken@6446
  2334
  -static           only build a \`.o' file suitable for static linking
slouken@6446
  2335
  -Wc,FLAG          pass FLAG directly to the compiler
slouken@6446
  2336
slouken@6446
  2337
COMPILE-COMMAND is a command to be used in creating a \`standard' object file
slouken@6446
  2338
from the given SOURCEFILE.
slouken@6446
  2339
slouken@6446
  2340
The output file name is determined by removing the directory component from
slouken@6446
  2341
SOURCEFILE, then substituting the C source code suffix \`.c' with the
slouken@6446
  2342
library object suffix, \`.lo'."
slouken@6446
  2343
        ;;
slouken@6446
  2344
slouken@6446
  2345
      execute)
slouken@6446
  2346
        $ECHO \
slouken@6446
  2347
"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
slouken@6446
  2348
slouken@6446
  2349
Automatically set library path, then run a program.
slouken@6446
  2350
slouken@6446
  2351
This mode accepts the following additional options:
slouken@6446
  2352
slouken@6446
  2353
  -dlopen FILE      add the directory containing FILE to the library path
slouken@6446
  2354
slouken@6446
  2355
This mode sets the library path environment variable according to \`-dlopen'
slouken@6446
  2356
flags.
slouken@6446
  2357
slouken@6446
  2358
If any of the ARGS are libtool executable wrappers, then they are translated
slouken@6446
  2359
into their corresponding uninstalled binary, and any of their required library
slouken@6446
  2360
directories are added to the library path.
slouken@6446
  2361
slouken@6446
  2362
Then, COMMAND is executed, with ARGS as arguments."
slouken@6446
  2363
        ;;
slouken@6446
  2364
slouken@6446
  2365
      finish)
slouken@6446
  2366
        $ECHO \
slouken@6446
  2367
"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
slouken@6446
  2368
slouken@6446
  2369
Complete the installation of libtool libraries.
slouken@6446
  2370
slouken@6446
  2371
Each LIBDIR is a directory that contains libtool libraries.
slouken@6446
  2372
slouken@6446
  2373
The commands that this mode executes may require superuser privileges.  Use
slouken@6446
  2374
the \`--dry-run' option if you just want to see what would be executed."
slouken@6446
  2375
        ;;
slouken@6446
  2376
slouken@6446
  2377
      install)
slouken@6446
  2378
        $ECHO \
slouken@6446
  2379
"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
slouken@6446
  2380
slouken@6446
  2381
Install executables or libraries.
slouken@6446
  2382
slouken@6446
  2383
INSTALL-COMMAND is the installation command.  The first component should be
slouken@6446
  2384
either the \`install' or \`cp' program.
slouken@6446
  2385
slouken@6446
  2386
The following components of INSTALL-COMMAND are treated specially:
slouken@6446
  2387
slouken@6446
  2388
  -inst-prefix-dir PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
slouken@6446
  2389
slouken@6446
  2390
The rest of the components are interpreted as arguments to that command (only
slouken@6446
  2391
BSD-compatible install options are recognized)."
slouken@6446
  2392
        ;;
slouken@6446
  2393
slouken@6446
  2394
      link)
slouken@6446
  2395
        $ECHO \
slouken@6446
  2396
"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
slouken@6446
  2397
slouken@6446
  2398
Link object files or libraries together to form another library, or to
slouken@6446
  2399
create an executable program.
slouken@6446
  2400
slouken@6446
  2401
LINK-COMMAND is a command using the C compiler that you would use to create
slouken@6446
  2402
a program from several object files.
slouken@6446
  2403
slouken@6446
  2404
The following components of LINK-COMMAND are treated specially:
slouken@6446
  2405
slouken@6446
  2406
  -all-static       do not do any dynamic linking at all
slouken@6446
  2407
  -avoid-version    do not add a version suffix if possible
slouken@6446
  2408
  -bindir BINDIR    specify path to binaries directory (for systems where
slouken@6446
  2409
                    libraries must be found in the PATH setting at runtime)
slouken@6446
  2410
  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
slouken@6446
  2411
  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
slouken@6446
  2412
  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
slouken@6446
  2413
  -export-symbols SYMFILE
slouken@6446
  2414
                    try to export only the symbols listed in SYMFILE
slouken@6446
  2415
  -export-symbols-regex REGEX
slouken@6446
  2416
                    try to export only the symbols matching REGEX
slouken@6446
  2417
  -LLIBDIR          search LIBDIR for required installed libraries
slouken@6446
  2418
  -lNAME            OUTPUT-FILE requires the installed library libNAME
slouken@6446
  2419
  -module           build a library that can dlopened
slouken@6446
  2420
  -no-fast-install  disable the fast-install mode
slouken@6446
  2421
  -no-install       link a not-installable executable
slouken@6446
  2422
  -no-undefined     declare that a library does not refer to external symbols
slouken@6446
  2423
  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
slouken@6446
  2424
  -objectlist FILE  Use a list of object files found in FILE to specify objects
slouken@6446
  2425
  -precious-files-regex REGEX
slouken@6446
  2426
                    don't remove output files matching REGEX
slouken@6446
  2427
  -release RELEASE  specify package release information
slouken@6446
  2428
  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
slouken@6446
  2429
  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
slouken@6446
  2430
  -shared           only do dynamic linking of libtool libraries
slouken@6446
  2431
  -shrext SUFFIX    override the standard shared library file extension
slouken@6446
  2432
  -static           do not do any dynamic linking of uninstalled libtool libraries
slouken@6446
  2433
  -static-libtool-libs
slouken@6446
  2434
                    do not do any dynamic linking of libtool libraries
slouken@6446
  2435
  -version-info CURRENT[:REVISION[:AGE]]
slouken@6446
  2436
                    specify library version info [each variable defaults to 0]
slouken@6446
  2437
  -weak LIBNAME     declare that the target provides the LIBNAME interface
slouken@6446
  2438
  -Wc,FLAG
slouken@6446
  2439
  -Xcompiler FLAG   pass linker-specific FLAG directly to the compiler
slouken@6446
  2440
  -Wl,FLAG
slouken@6446
  2441
  -Xlinker FLAG     pass linker-specific FLAG directly to the linker
slouken@6446
  2442
  -XCClinker FLAG   pass link-specific FLAG to the compiler driver (CC)
slouken@6446
  2443
slouken@6446
  2444
All other options (arguments beginning with \`-') are ignored.
slouken@6446
  2445
slouken@6446
  2446
Every other argument is treated as a filename.  Files ending in \`.la' are
slouken@6446
  2447
treated as uninstalled libtool libraries, other files are standard or library
slouken@6446
  2448
object files.
slouken@6446
  2449
slouken@6446
  2450
If the OUTPUT-FILE ends in \`.la', then a libtool library is created,
slouken@6446
  2451
only library objects (\`.lo' files) may be specified, and \`-rpath' is
slouken@6446
  2452
required, except when creating a convenience library.
slouken@6446
  2453
slouken@6446
  2454
If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
slouken@6446
  2455
using \`ar' and \`ranlib', or on Windows using \`lib'.
slouken@6446
  2456
slouken@6446
  2457
If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
slouken@6446
  2458
is created, otherwise an executable program is created."
slouken@6446
  2459
        ;;
slouken@6446
  2460
slouken@6446
  2461
      uninstall)
slouken@6446
  2462
        $ECHO \
slouken@6446
  2463
"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
slouken@6446
  2464
slouken@6446
  2465
Remove libraries from an installation directory.
slouken@6446
  2466
slouken@6446
  2467
RM is the name of the program to use to delete files associated with each FILE
slouken@6446
  2468
(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
slouken@6446
  2469
to RM.
slouken@6446
  2470
slouken@6446
  2471
If FILE is a libtool library, all the files associated with it are deleted.
slouken@6446
  2472
Otherwise, only FILE itself is deleted using RM."
slouken@6446
  2473
        ;;
slouken@6446
  2474
slouken@6446
  2475
      *)
slouken@6446
  2476
        func_fatal_help "invalid operation mode \`$opt_mode'"
slouken@6446
  2477
        ;;
slouken@6446
  2478
    esac
slouken@6446
  2479
slouken@6446
  2480
    echo
slouken@6446
  2481
    $ECHO "Try \`$progname --help' for more information about other modes."
slouken@6446
  2482
}
slouken@6446
  2483
slouken@6446
  2484
# Now that we've collected a possible --mode arg, show help if necessary
slouken@6446
  2485
if $opt_help; then
slouken@6446
  2486
  if test "$opt_help" = :; then
slouken@6446
  2487
    func_mode_help
slouken@6446
  2488
  else
slouken@6446
  2489
    {
slouken@6446
  2490
      func_help noexit
slouken@6446
  2491
      for opt_mode in compile link execute install finish uninstall clean; do
slouken@6446
  2492
	func_mode_help
slouken@6446
  2493
      done
slouken@6446
  2494
    } | sed -n '1p; 2,$s/^Usage:/  or: /p'
slouken@6446
  2495
    {
slouken@6446
  2496
      func_help noexit
slouken@6446
  2497
      for opt_mode in compile link execute install finish uninstall clean; do
slouken@6446
  2498
	echo
slouken@6446
  2499
	func_mode_help
slouken@6446
  2500
      done
slouken@6446
  2501
    } |
slouken@6446
  2502
    sed '1d
slouken@6446
  2503
      /^When reporting/,/^Report/{
slouken@6446
  2504
	H
slouken@6446
  2505
	d
slouken@6446
  2506
      }
slouken@6446
  2507
      $x
slouken@6446
  2508
      /information about other modes/d
slouken@6446
  2509
      /more detailed .*MODE/d
slouken@6446
  2510
      s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
slouken@6446
  2511
  fi
slouken@6446
  2512
  exit $?
slouken@6446
  2513
fi
slouken@6446
  2514
slouken@6446
  2515
slouken@6446
  2516
# func_mode_execute arg...
slouken@6446
  2517
func_mode_execute ()
slouken@6446
  2518
{
slouken@6446
  2519
    $opt_debug
slouken@6446
  2520
    # The first argument is the command name.
slouken@6446
  2521
    cmd="$nonopt"
slouken@6446
  2522
    test -z "$cmd" && \
slouken@6446
  2523
      func_fatal_help "you must specify a COMMAND"
slouken@6446
  2524
slouken@6446
  2525
    # Handle -dlopen flags immediately.
slouken@6446
  2526
    for file in $opt_dlopen; do
slouken@6446
  2527
      test -f "$file" \
slouken@6446
  2528
	|| func_fatal_help "\`$file' is not a file"
slouken@6446
  2529
slouken@6446
  2530
      dir=
slouken@6446
  2531
      case $file in
slouken@6446
  2532
      *.la)
slouken@6446
  2533
	func_resolve_sysroot "$file"
slouken@6446
  2534
	file=$func_resolve_sysroot_result
slouken@6446
  2535
slouken@6446
  2536
	# Check to see that this really is a libtool archive.
slouken@6446
  2537
	func_lalib_unsafe_p "$file" \
slouken@6446
  2538
	  || func_fatal_help "\`$lib' is not a valid libtool archive"
slouken@6446
  2539
slouken@6446
  2540
	# Read the libtool library.
slouken@6446
  2541
	dlname=
slouken@6446
  2542
	library_names=
slouken@6446
  2543
	func_source "$file"
slouken@6446
  2544
slouken@6446
  2545
	# Skip this library if it cannot be dlopened.
slouken@6446
  2546
	if test -z "$dlname"; then
slouken@6446
  2547
	  # Warn if it was a shared library.
slouken@6446
  2548
	  test -n "$library_names" && \
slouken@6446
  2549
	    func_warning "\`$file' was not linked with \`-export-dynamic'"
slouken@6446
  2550
	  continue
slouken@6446
  2551
	fi
slouken@6446
  2552
slouken@6446
  2553
	func_dirname "$file" "" "."
slouken@6446
  2554
	dir="$func_dirname_result"
slouken@6446
  2555
slouken@6446
  2556
	if test -f "$dir/$objdir/$dlname"; then
slouken@6446
  2557
	  func_append dir "/$objdir"
slouken@6446
  2558
	else
slouken@6446
  2559
	  if test ! -f "$dir/$dlname"; then
slouken@6446
  2560
	    func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
slouken@6446
  2561
	  fi
slouken@6446
  2562
	fi
slouken@6446
  2563
	;;
slouken@6446
  2564
slouken@6446
  2565
      *.lo)
slouken@6446
  2566
	# Just add the directory containing the .lo file.
slouken@6446
  2567
	func_dirname "$file" "" "."
slouken@6446
  2568
	dir="$func_dirname_result"
slouken@6446
  2569
	;;
slouken@6446
  2570
slouken@6446
  2571
      *)
slouken@6446
  2572
	func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
slouken@6446
  2573
	continue
slouken@6446
  2574
	;;
slouken@6446
  2575
      esac
slouken@6446
  2576
slouken@6446
  2577
      # Get the absolute pathname.
slouken@6446
  2578
      absdir=`cd "$dir" && pwd`
slouken@6446
  2579
      test -n "$absdir" && dir="$absdir"
slouken@6446
  2580
slouken@6446
  2581
      # Now add the directory to shlibpath_var.
slouken@6446
  2582
      if eval "test -z \"\$$shlibpath_var\""; then
slouken@6446
  2583
	eval "$shlibpath_var=\"\$dir\""
slouken@6446
  2584
      else
slouken@6446
  2585
	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
slouken@6446
  2586
      fi
slouken@6446
  2587
    done
slouken@6446
  2588
slouken@6446
  2589
    # This variable tells wrapper scripts just to set shlibpath_var
slouken@6446
  2590
    # rather than running their programs.
slouken@6446
  2591
    libtool_execute_magic="$magic"
slouken@6446
  2592
slouken@6446
  2593
    # Check if any of the arguments is a wrapper script.
slouken@6446
  2594
    args=
slouken@6446
  2595
    for file
slouken@6446
  2596
    do
slouken@6446
  2597
      case $file in
slouken@6446
  2598
      -* | *.la | *.lo ) ;;
slouken@6446
  2599
      *)
slouken@6446
  2600
	# Do a test to see if this is really a libtool program.
slouken@6446
  2601
	if func_ltwrapper_script_p "$file"; then
slouken@6446
  2602
	  func_source "$file"
slouken@6446
  2603
	  # Transform arg to wrapped name.
slouken@6446
  2604
	  file="$progdir/$program"
slouken@6446
  2605
	elif func_ltwrapper_executable_p "$file"; then
slouken@6446
  2606
	  func_ltwrapper_scriptname "$file"
slouken@6446
  2607
	  func_source "$func_ltwrapper_scriptname_result"
slouken@6446
  2608
	  # Transform arg to wrapped name.
slouken@6446
  2609
	  file="$progdir/$program"
slouken@6446
  2610
	fi
slouken@6446
  2611
	;;
slouken@6446
  2612
      esac
slouken@6446
  2613
      # Quote arguments (to preserve shell metacharacters).
slouken@6446
  2614
      func_append_quoted args "$file"
slouken@6446
  2615
    done
slouken@6446
  2616
slouken@6446
  2617
    if test "X$opt_dry_run" = Xfalse; then
slouken@6446
  2618
      if test -n "$shlibpath_var"; then
slouken@6446
  2619
	# Export the shlibpath_var.
slouken@6446
  2620
	eval "export $shlibpath_var"
slouken@6446
  2621
      fi
slouken@6446
  2622
slouken@6446
  2623
      # Restore saved environment variables
slouken@6446
  2624
      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
slouken@6446
  2625
      do
slouken@6446
  2626
	eval "if test \"\${save_$lt_var+set}\" = set; then
slouken@6446
  2627
                $lt_var=\$save_$lt_var; export $lt_var
slouken@6446
  2628
	      else
slouken@6446
  2629
		$lt_unset $lt_var
slouken@6446
  2630
	      fi"
slouken@6446
  2631
      done
slouken@6446
  2632
slouken@6446
  2633
      # Now prepare to actually exec the command.
slouken@6446
  2634
      exec_cmd="\$cmd$args"
slouken@6446
  2635
    else
slouken@6446
  2636
      # Display what would be done.
slouken@6446
  2637
      if test -n "$shlibpath_var"; then
slouken@6446
  2638
	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
slouken@6446
  2639
	echo "export $shlibpath_var"
slouken@6446
  2640
      fi
slouken@6446
  2641
      $ECHO "$cmd$args"
slouken@6446
  2642
      exit $EXIT_SUCCESS
slouken@6446
  2643
    fi
slouken@6446
  2644
}
slouken@6446
  2645
slouken@6446
  2646
test "$opt_mode" = execute && func_mode_execute ${1+"$@"}
slouken@6446
  2647
slouken@6446
  2648
slouken@6446
  2649
# func_mode_finish arg...
slouken@6446
  2650
func_mode_finish ()
slouken@6446
  2651
{
slouken@6446
  2652
    $opt_debug
slouken@6446
  2653
    libs=
slouken@6446
  2654
    libdirs=
slouken@6446
  2655
    admincmds=
slouken@6446
  2656
slouken@6446
  2657
    for opt in "$nonopt" ${1+"$@"}
slouken@6446
  2658
    do
slouken@6446
  2659
      if test -d "$opt"; then
slouken@6446
  2660
	func_append libdirs " $opt"
slouken@6446
  2661
slouken@6446
  2662
      elif test -f "$opt"; then
slouken@6446
  2663
	if func_lalib_unsafe_p "$opt"; then
slouken@6446
  2664
	  func_append libs " $opt"
slouken@6446
  2665
	else
slouken@6446
  2666
	  func_warning "\`$opt' is not a valid libtool archive"
slouken@6446
  2667
	fi
slouken@6446
  2668
slouken@6446
  2669
      else
slouken@6446
  2670
	func_fatal_error "invalid argument \`$opt'"
slouken@6446
  2671
      fi
slouken@6446
  2672
    done
slouken@6446
  2673
slouken@6446
  2674
    if test -n "$libs"; then
slouken@6446
  2675
      if test -n "$lt_sysroot"; then
slouken@6446
  2676
        sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
slouken@6446
  2677
        sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
slouken@6446
  2678
      else
slouken@6446
  2679
        sysroot_cmd=
slouken@6446
  2680
      fi
slouken@6446
  2681
slouken@6446
  2682
      # Remove sysroot references
slouken@6446
  2683
      if $opt_dry_run; then
slouken@6446
  2684
        for lib in $libs; do
slouken@6446
  2685
          echo "removing references to $lt_sysroot and \`=' prefixes from $lib"
slouken@6446
  2686
        done
slouken@6446
  2687
      else
slouken@6446
  2688
        tmpdir=`func_mktempdir`
slouken@6446
  2689
        for lib in $libs; do
slouken@6446
  2690
	  sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
slouken@6446
  2691
	    > $tmpdir/tmp-la
slouken@6446
  2692
	  mv -f $tmpdir/tmp-la $lib