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