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