build-scripts/ltmain.sh
author Sam Lantinga <slouken@libsdl.org>
Wed, 26 Jan 2011 12:23:32 -0800
changeset 5100 cce11d33d5c6
parent 3346 195eb6d42bf0
child 6442 2d3caa191dc4
permissions -rw-r--r--
Ozkan Sezer to slouken

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