gst-gpac/ltmain.sh
author melunko
Thu Mar 13 16:29:38 2008 +0000 (2008-03-13)
branchtrunk
changeset 942 c93bfa74c71f
permissions -rw-r--r--
[svn r951] gmyth now is 0.8.1. Added methods epg_is_connected() and scheduler_is_connected()
melunko@917
     1
# ltmain.sh - Provide generalized library-building support services.
melunko@917
     2
# NOTE: Changing this file will not affect anything until you rerun configure.
melunko@917
     3
#
melunko@917
     4
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
melunko@917
     5
# 2007  Free Software Foundation, Inc.
melunko@917
     6
# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
melunko@917
     7
#
melunko@917
     8
# This program is free software; you can redistribute it and/or modify
melunko@917
     9
# it under the terms of the GNU General Public License as published by
melunko@917
    10
# the Free Software Foundation; either version 2 of the License, or
melunko@917
    11
# (at your option) any later version.
melunko@917
    12
#
melunko@917
    13
# This program is distributed in the hope that it will be useful, but
melunko@917
    14
# WITHOUT ANY WARRANTY; without even the implied warranty of
melunko@917
    15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
melunko@917
    16
# General Public License for more details.
melunko@917
    17
#
melunko@917
    18
# You should have received a copy of the GNU General Public License
melunko@917
    19
# along with this program; if not, write to the Free Software
melunko@917
    20
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
melunko@917
    21
#
melunko@917
    22
# As a special exception to the GNU General Public License, if you
melunko@917
    23
# distribute this file as part of a program that contains a
melunko@917
    24
# configuration script generated by Autoconf, you may include it under
melunko@917
    25
# the same distribution terms that you use for the rest of that program.
melunko@917
    26
melunko@917
    27
basename="s,^.*/,,g"
melunko@917
    28
melunko@917
    29
# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
melunko@917
    30
# is ksh but when the shell is invoked as "sh" and the current value of
melunko@917
    31
# the _XPG environment variable is not equal to 1 (one), the special
melunko@917
    32
# positional parameter $0, within a function call, is the name of the
melunko@917
    33
# function.
melunko@917
    34
progpath="$0"
melunko@917
    35
melunko@917
    36
# The name of this program:
melunko@917
    37
progname=`echo "$progpath" | $SED $basename`
melunko@917
    38
modename="$progname"
melunko@917
    39
melunko@917
    40
# Global variables:
melunko@917
    41
EXIT_SUCCESS=0
melunko@917
    42
EXIT_FAILURE=1
melunko@917
    43
melunko@917
    44
PROGRAM=ltmain.sh
melunko@917
    45
PACKAGE=libtool
melunko@917
    46
VERSION="1.5.24 Debian 1.5.24-1ubuntu1"
melunko@917
    47
TIMESTAMP=" (1.1220.2.456 2007/06/24 02:25:32)"
melunko@917
    48
melunko@917
    49
# Be Bourne compatible (taken from Autoconf:_AS_BOURNE_COMPATIBLE).
melunko@917
    50
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
melunko@917
    51
  emulate sh
melunko@917
    52
  NULLCMD=:
melunko@917
    53
  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
melunko@917
    54
  # is contrary to our usage.  Disable this feature.
melunko@917
    55
  alias -g '${1+"$@"}'='"$@"'
melunko@917
    56
  setopt NO_GLOB_SUBST
melunko@917
    57
else
melunko@917
    58
  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
melunko@917
    59
fi
melunko@917
    60
BIN_SH=xpg4; export BIN_SH # for Tru64
melunko@917
    61
DUALCASE=1; export DUALCASE # for MKS sh
melunko@917
    62
melunko@917
    63
# Check that we have a working $echo.
melunko@917
    64
if test "X$1" = X--no-reexec; then
melunko@917
    65
  # Discard the --no-reexec flag, and continue.
melunko@917
    66
  shift
melunko@917
    67
elif test "X$1" = X--fallback-echo; then
melunko@917
    68
  # Avoid inline document here, it may be left over
melunko@917
    69
  :
melunko@917
    70
elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then
melunko@917
    71
  # Yippee, $echo works!
melunko@917
    72
  :
melunko@917
    73
else
melunko@917
    74
  # Restart under the correct shell, and then maybe $echo will work.
melunko@917
    75
  exec $SHELL "$progpath" --no-reexec ${1+"$@"}
melunko@917
    76
fi
melunko@917
    77
melunko@917
    78
if test "X$1" = X--fallback-echo; then
melunko@917
    79
  # used as fallback echo
melunko@917
    80
  shift
melunko@917
    81
  cat <<EOF
melunko@917
    82
$*
melunko@917
    83
EOF
melunko@917
    84
  exit $EXIT_SUCCESS
melunko@917
    85
fi
melunko@917
    86
melunko@917
    87
default_mode=
melunko@917
    88
help="Try \`$progname --help' for more information."
melunko@917
    89
magic="%%%MAGIC variable%%%"
melunko@917
    90
mkdir="mkdir"
melunko@917
    91
mv="mv -f"
melunko@917
    92
rm="rm -f"
melunko@917
    93
melunko@917
    94
# Sed substitution that helps us do robust quoting.  It backslashifies
melunko@917
    95
# metacharacters that are still active within double-quoted strings.
melunko@917
    96
Xsed="${SED}"' -e 1s/^X//'
melunko@917
    97
sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'
melunko@917
    98
# test EBCDIC or ASCII
melunko@917
    99
case `echo X|tr X '\101'` in
melunko@917
   100
 A) # ASCII based system
melunko@917
   101
    # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
melunko@917
   102
  SP2NL='tr \040 \012'
melunko@917
   103
  NL2SP='tr \015\012 \040\040'
melunko@917
   104
  ;;
melunko@917
   105
 *) # EBCDIC based system
melunko@917
   106
  SP2NL='tr \100 \n'
melunko@917
   107
  NL2SP='tr \r\n \100\100'
melunko@917
   108
  ;;
melunko@917
   109
esac
melunko@917
   110
melunko@917
   111
# NLS nuisances.
melunko@917
   112
# Only set LANG and LC_ALL to C if already set.
melunko@917
   113
# These must not be set unconditionally because not all systems understand
melunko@917
   114
# e.g. LANG=C (notably SCO).
melunko@917
   115
# We save the old values to restore during execute mode.
melunko@917
   116
for lt_var in LANG LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
melunko@917
   117
do
melunko@917
   118
  eval "if test \"\${$lt_var+set}\" = set; then
melunko@917
   119
	  save_$lt_var=\$$lt_var
melunko@917
   120
	  $lt_var=C
melunko@917
   121
	  export $lt_var
melunko@917
   122
	fi"
melunko@917
   123
done
melunko@917
   124
melunko@917
   125
# Make sure IFS has a sensible default
melunko@917
   126
lt_nl='
melunko@917
   127
'
melunko@917
   128
IFS=" 	$lt_nl"
melunko@917
   129
melunko@917
   130
if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
melunko@917
   131
  $echo "$modename: not configured to build any kind of library" 1>&2
melunko@917
   132
  $echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
melunko@917
   133
  exit $EXIT_FAILURE
melunko@917
   134
fi
melunko@917
   135
melunko@917
   136
# Global variables.
melunko@917
   137
mode=$default_mode
melunko@917
   138
nonopt=
melunko@917
   139
prev=
melunko@917
   140
prevopt=
melunko@917
   141
run=
melunko@917
   142
show="$echo"
melunko@917
   143
show_help=
melunko@917
   144
execute_dlfiles=
melunko@917
   145
duplicate_deps=no
melunko@917
   146
preserve_args=
melunko@917
   147
lo2o="s/\\.lo\$/.${objext}/"
melunko@917
   148
o2lo="s/\\.${objext}\$/.lo/"
melunko@917
   149
extracted_archives=
melunko@917
   150
extracted_serial=0
melunko@917
   151
melunko@917
   152
#####################################
melunko@917
   153
# Shell function definitions:
melunko@917
   154
# This seems to be the best place for them
melunko@917
   155
melunko@917
   156
# func_mktempdir [string]
melunko@917
   157
# Make a temporary directory that won't clash with other running
melunko@917
   158
# libtool processes, and avoids race conditions if possible.  If
melunko@917
   159
# given, STRING is the basename for that directory.
melunko@917
   160
func_mktempdir ()
melunko@917
   161
{
melunko@917
   162
    my_template="${TMPDIR-/tmp}/${1-$progname}"
melunko@917
   163
melunko@917
   164
    if test "$run" = ":"; then
melunko@917
   165
      # Return a directory name, but don't create it in dry-run mode
melunko@917
   166
      my_tmpdir="${my_template}-$$"
melunko@917
   167
    else
melunko@917
   168
melunko@917
   169
      # If mktemp works, use that first and foremost
melunko@917
   170
      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
melunko@917
   171
melunko@917
   172
      if test ! -d "$my_tmpdir"; then
melunko@917
   173
	# Failing that, at least try and use $RANDOM to avoid a race
melunko@917
   174
	my_tmpdir="${my_template}-${RANDOM-0}$$"
melunko@917
   175
melunko@917
   176
	save_mktempdir_umask=`umask`
melunko@917
   177
	umask 0077
melunko@917
   178
	$mkdir "$my_tmpdir"
melunko@917
   179
	umask $save_mktempdir_umask
melunko@917
   180
      fi
melunko@917
   181
melunko@917
   182
      # If we're not in dry-run mode, bomb out on failure
melunko@917
   183
      test -d "$my_tmpdir" || {
melunko@917
   184
        $echo "cannot create temporary directory \`$my_tmpdir'" 1>&2
melunko@917
   185
	exit $EXIT_FAILURE
melunko@917
   186
      }
melunko@917
   187
    fi
melunko@917
   188
melunko@917
   189
    $echo "X$my_tmpdir" | $Xsed
melunko@917
   190
}
melunko@917
   191
melunko@917
   192
melunko@917
   193
# func_win32_libid arg
melunko@917
   194
# return the library type of file 'arg'
melunko@917
   195
#
melunko@917
   196
# Need a lot of goo to handle *both* DLLs and import libs
melunko@917
   197
# Has to be a shell function in order to 'eat' the argument
melunko@917
   198
# that is supplied when $file_magic_command is called.
melunko@917
   199
func_win32_libid ()
melunko@917
   200
{
melunko@917
   201
  win32_libid_type="unknown"
melunko@917
   202
  win32_fileres=`file -L $1 2>/dev/null`
melunko@917
   203
  case $win32_fileres in
melunko@917
   204
  *ar\ archive\ import\ library*) # definitely import
melunko@917
   205
    win32_libid_type="x86 archive import"
melunko@917
   206
    ;;
melunko@917
   207
  *ar\ archive*) # could be an import, or static
melunko@917
   208
    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \
melunko@917
   209
      $EGREP -e 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
melunko@917
   210
      win32_nmres=`eval $NM -f posix -A $1 | \
melunko@917
   211
	$SED -n -e '1,100{
melunko@917
   212
		/ I /{
melunko@917
   213
			s,.*,import,
melunko@917
   214
			p
melunko@917
   215
			q
melunko@917
   216
			}
melunko@917
   217
		}'`
melunko@917
   218
      case $win32_nmres in
melunko@917
   219
      import*)  win32_libid_type="x86 archive import";;
melunko@917
   220
      *)        win32_libid_type="x86 archive static";;
melunko@917
   221
      esac
melunko@917
   222
    fi
melunko@917
   223
    ;;
melunko@917
   224
  *DLL*)
melunko@917
   225
    win32_libid_type="x86 DLL"
melunko@917
   226
    ;;
melunko@917
   227
  *executable*) # but shell scripts are "executable" too...
melunko@917
   228
    case $win32_fileres in
melunko@917
   229
    *MS\ Windows\ PE\ Intel*)
melunko@917
   230
      win32_libid_type="x86 DLL"
melunko@917
   231
      ;;
melunko@917
   232
    esac
melunko@917
   233
    ;;
melunko@917
   234
  esac
melunko@917
   235
  $echo $win32_libid_type
melunko@917
   236
}
melunko@917
   237
melunko@917
   238
melunko@917
   239
# func_infer_tag arg
melunko@917
   240
# Infer tagged configuration to use if any are available and
melunko@917
   241
# if one wasn't chosen via the "--tag" command line option.
melunko@917
   242
# Only attempt this if the compiler in the base compile
melunko@917
   243
# command doesn't match the default compiler.
melunko@917
   244
# arg is usually of the form 'gcc ...'
melunko@917
   245
func_infer_tag ()
melunko@917
   246
{
melunko@917
   247
    if test -n "$available_tags" && test -z "$tagname"; then
melunko@917
   248
      CC_quoted=
melunko@917
   249
      for arg in $CC; do
melunko@917
   250
	case $arg in
melunko@917
   251
	  *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
melunko@917
   252
	  arg="\"$arg\""
melunko@917
   253
	  ;;
melunko@917
   254
	esac
melunko@917
   255
	CC_quoted="$CC_quoted $arg"
melunko@917
   256
      done
melunko@917
   257
      case $@ in
melunko@917
   258
      # Blanks in the command may have been stripped by the calling shell,
melunko@917
   259
      # but not from the CC environment variable when configure was run.
melunko@917
   260
      " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) ;;
melunko@917
   261
      # Blanks at the start of $base_compile will cause this to fail
melunko@917
   262
      # if we don't check for them as well.
melunko@917
   263
      *)
melunko@917
   264
	for z in $available_tags; do
melunko@917
   265
	  if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
melunko@917
   266
	    # Evaluate the configuration.
melunko@917
   267
	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
melunko@917
   268
	    CC_quoted=
melunko@917
   269
	    for arg in $CC; do
melunko@917
   270
	    # Double-quote args containing other shell metacharacters.
melunko@917
   271
	    case $arg in
melunko@917
   272
	      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
melunko@917
   273
	      arg="\"$arg\""
melunko@917
   274
	      ;;
melunko@917
   275
	    esac
melunko@917
   276
	    CC_quoted="$CC_quoted $arg"
melunko@917
   277
	  done
melunko@917
   278
	    case "$@ " in
melunko@917
   279
	      " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*)
melunko@917
   280
	      # The compiler in the base compile command matches
melunko@917
   281
	      # the one in the tagged configuration.
melunko@917
   282
	      # Assume this is the tagged configuration we want.
melunko@917
   283
	      tagname=$z
melunko@917
   284
	      break
melunko@917
   285
	      ;;
melunko@917
   286
	    esac
melunko@917
   287
	  fi
melunko@917
   288
	done
melunko@917
   289
	# If $tagname still isn't set, then no tagged configuration
melunko@917
   290
	# was found and let the user know that the "--tag" command
melunko@917
   291
	# line option must be used.
melunko@917
   292
	if test -z "$tagname"; then
melunko@917
   293
	  $echo "$modename: unable to infer tagged configuration"
melunko@917
   294
	  $echo "$modename: specify a tag with \`--tag'" 1>&2
melunko@917
   295
	  exit $EXIT_FAILURE
melunko@917
   296
#        else
melunko@917
   297
#          $echo "$modename: using $tagname tagged configuration"
melunko@917
   298
	fi
melunko@917
   299
	;;
melunko@917
   300
      esac
melunko@917
   301
    fi
melunko@917
   302
}
melunko@917
   303
melunko@917
   304
melunko@917
   305
# func_extract_an_archive dir oldlib
melunko@917
   306
func_extract_an_archive ()
melunko@917
   307
{
melunko@917
   308
    f_ex_an_ar_dir="$1"; shift
melunko@917
   309
    f_ex_an_ar_oldlib="$1"
melunko@917
   310
melunko@917
   311
    $show "(cd $f_ex_an_ar_dir && $AR x $f_ex_an_ar_oldlib)"
melunko@917
   312
    $run eval "(cd \$f_ex_an_ar_dir && $AR x \$f_ex_an_ar_oldlib)" || exit $?
melunko@917
   313
    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
melunko@917
   314
     :
melunko@917
   315
    else
melunko@917
   316
      $echo "$modename: ERROR: object name conflicts: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 1>&2
melunko@917
   317
      exit $EXIT_FAILURE
melunko@917
   318
    fi
melunko@917
   319
}
melunko@917
   320
melunko@917
   321
# func_extract_archives gentop oldlib ...
melunko@917
   322
func_extract_archives ()
melunko@917
   323
{
melunko@917
   324
    my_gentop="$1"; shift
melunko@917
   325
    my_oldlibs=${1+"$@"}
melunko@917
   326
    my_oldobjs=""
melunko@917
   327
    my_xlib=""
melunko@917
   328
    my_xabs=""
melunko@917
   329
    my_xdir=""
melunko@917
   330
    my_status=""
melunko@917
   331
melunko@917
   332
    $show "${rm}r $my_gentop"
melunko@917
   333
    $run ${rm}r "$my_gentop"
melunko@917
   334
    $show "$mkdir $my_gentop"
melunko@917
   335
    $run $mkdir "$my_gentop"
melunko@917
   336
    my_status=$?
melunko@917
   337
    if test "$my_status" -ne 0 && test ! -d "$my_gentop"; then
melunko@917
   338
      exit $my_status
melunko@917
   339
    fi
melunko@917
   340
melunko@917
   341
    for my_xlib in $my_oldlibs; do
melunko@917
   342
      # Extract the objects.
melunko@917
   343
      case $my_xlib in
melunko@917
   344
	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
melunko@917
   345
	*) my_xabs=`pwd`"/$my_xlib" ;;
melunko@917
   346
      esac
melunko@917
   347
      my_xlib=`$echo "X$my_xlib" | $Xsed -e 's%^.*/%%'`
melunko@917
   348
      my_xlib_u=$my_xlib
melunko@917
   349
      while :; do
melunko@917
   350
        case " $extracted_archives " in
melunko@917
   351
	*" $my_xlib_u "*)
melunko@917
   352
	  extracted_serial=`expr $extracted_serial + 1`
melunko@917
   353
	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
melunko@917
   354
	*) break ;;
melunko@917
   355
	esac
melunko@917
   356
      done
melunko@917
   357
      extracted_archives="$extracted_archives $my_xlib_u"
melunko@917
   358
      my_xdir="$my_gentop/$my_xlib_u"
melunko@917
   359
melunko@917
   360
      $show "${rm}r $my_xdir"
melunko@917
   361
      $run ${rm}r "$my_xdir"
melunko@917
   362
      $show "$mkdir $my_xdir"
melunko@917
   363
      $run $mkdir "$my_xdir"
melunko@917
   364
      exit_status=$?
melunko@917
   365
      if test "$exit_status" -ne 0 && test ! -d "$my_xdir"; then
melunko@917
   366
	exit $exit_status
melunko@917
   367
      fi
melunko@917
   368
      case $host in
melunko@917
   369
      *-darwin*)
melunko@917
   370
	$show "Extracting $my_xabs"
melunko@917
   371
	# Do not bother doing anything if just a dry run
melunko@917
   372
	if test -z "$run"; then
melunko@917
   373
	  darwin_orig_dir=`pwd`
melunko@917
   374
	  cd $my_xdir || exit $?
melunko@917
   375
	  darwin_archive=$my_xabs
melunko@917
   376
	  darwin_curdir=`pwd`
melunko@917
   377
	  darwin_base_archive=`$echo "X$darwin_archive" | $Xsed -e 's%^.*/%%'`
melunko@917
   378
	  darwin_arches=`lipo -info "$darwin_archive" 2>/dev/null | $EGREP Architectures 2>/dev/null`
melunko@917
   379
	  if test -n "$darwin_arches"; then 
melunko@917
   380
	    darwin_arches=`echo "$darwin_arches" | $SED -e 's/.*are://'`
melunko@917
   381
	    darwin_arch=
melunko@917
   382
	    $show "$darwin_base_archive has multiple architectures $darwin_arches"
melunko@917
   383
	    for darwin_arch in  $darwin_arches ; do
melunko@917
   384
	      mkdir -p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
melunko@917
   385
	      lipo -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
melunko@917
   386
	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
melunko@917
   387
	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
melunko@917
   388
	      cd "$darwin_curdir"
melunko@917
   389
	      $rm "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
melunko@917
   390
	    done # $darwin_arches
melunko@917
   391
      ## Okay now we have a bunch of thin objects, gotta fatten them up :)
melunko@917
   392
	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print| xargs basename | sort -u | $NL2SP`
melunko@917
   393
	    darwin_file=
melunko@917
   394
	    darwin_files=
melunko@917
   395
	    for darwin_file in $darwin_filelist; do
melunko@917
   396
	      darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
melunko@917
   397
	      lipo -create -output "$darwin_file" $darwin_files
melunko@917
   398
	    done # $darwin_filelist
melunko@917
   399
	    ${rm}r unfat-$$
melunko@917
   400
	    cd "$darwin_orig_dir"
melunko@917
   401
	  else
melunko@917
   402
	    cd "$darwin_orig_dir"
melunko@917
   403
 	    func_extract_an_archive "$my_xdir" "$my_xabs"
melunko@917
   404
	  fi # $darwin_arches
melunko@917
   405
	fi # $run
melunko@917
   406
	;;
melunko@917
   407
      *)
melunko@917
   408
        func_extract_an_archive "$my_xdir" "$my_xabs"
melunko@917
   409
        ;;
melunko@917
   410
      esac
melunko@917
   411
      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
melunko@917
   412
    done
melunko@917
   413
    func_extract_archives_result="$my_oldobjs"
melunko@917
   414
}
melunko@917
   415
# End of Shell function definitions
melunko@917
   416
#####################################
melunko@917
   417
melunko@917
   418
# Darwin sucks
melunko@917
   419
eval std_shrext=\"$shrext_cmds\"
melunko@917
   420
melunko@917
   421
disable_libs=no
melunko@917
   422
melunko@917
   423
# Parse our command line options once, thoroughly.
melunko@917
   424
while test "$#" -gt 0
melunko@917
   425
do
melunko@917
   426
  arg="$1"
melunko@917
   427
  shift
melunko@917
   428
melunko@917
   429
  case $arg in
melunko@917
   430
  -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;;
melunko@917
   431
  *) optarg= ;;
melunko@917
   432
  esac
melunko@917
   433
melunko@917
   434
  # If the previous option needs an argument, assign it.
melunko@917
   435
  if test -n "$prev"; then
melunko@917
   436
    case $prev in
melunko@917
   437
    execute_dlfiles)
melunko@917
   438
      execute_dlfiles="$execute_dlfiles $arg"
melunko@917
   439
      ;;
melunko@917
   440
    tag)
melunko@917
   441
      tagname="$arg"
melunko@917
   442
      preserve_args="${preserve_args}=$arg"
melunko@917
   443
melunko@917
   444
      # Check whether tagname contains only valid characters
melunko@917
   445
      case $tagname in
melunko@917
   446
      *[!-_A-Za-z0-9,/]*)
melunko@917
   447
	$echo "$progname: invalid tag name: $tagname" 1>&2
melunko@917
   448
	exit $EXIT_FAILURE
melunko@917
   449
	;;
melunko@917
   450
      esac
melunko@917
   451
melunko@917
   452
      case $tagname in
melunko@917
   453
      CC)
melunko@917
   454
	# Don't test for the "default" C tag, as we know, it's there, but
melunko@917
   455
	# not specially marked.
melunko@917
   456
	;;
melunko@917
   457
      *)
melunko@917
   458
	if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "$progpath" > /dev/null; then
melunko@917
   459
	  taglist="$taglist $tagname"
melunko@917
   460
	  # Evaluate the configuration.
melunko@917
   461
	  eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$tagname'$/,/^# ### END LIBTOOL TAG CONFIG: '$tagname'$/p' < $progpath`"
melunko@917
   462
	else
melunko@917
   463
	  $echo "$progname: ignoring unknown tag $tagname" 1>&2
melunko@917
   464
	fi
melunko@917
   465
	;;
melunko@917
   466
      esac
melunko@917
   467
      ;;
melunko@917
   468
    *)
melunko@917
   469
      eval "$prev=\$arg"
melunko@917
   470
      ;;
melunko@917
   471
    esac
melunko@917
   472
melunko@917
   473
    prev=
melunko@917
   474
    prevopt=
melunko@917
   475
    continue
melunko@917
   476
  fi
melunko@917
   477
melunko@917
   478
  # Have we seen a non-optional argument yet?
melunko@917
   479
  case $arg in
melunko@917
   480
  --help)
melunko@917
   481
    show_help=yes
melunko@917
   482
    ;;
melunko@917
   483
melunko@917
   484
  --version)
melunko@917
   485
    echo "\
melunko@917
   486
$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP
melunko@917
   487
melunko@917
   488
Copyright (C) 2007  Free Software Foundation, Inc.
melunko@917
   489
This is free software; see the source for copying conditions.  There is NO
melunko@917
   490
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
melunko@917
   491
    exit $?
melunko@917
   492
    ;;
melunko@917
   493
melunko@917
   494
  --config)
melunko@917
   495
    ${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $progpath
melunko@917
   496
    # Now print the configurations for the tags.
melunko@917
   497
    for tagname in $taglist; do
melunko@917
   498
      ${SED} -n -e "/^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$/,/^# ### END LIBTOOL TAG CONFIG: $tagname$/p" < "$progpath"
melunko@917
   499
    done
melunko@917
   500
    exit $?
melunko@917
   501
    ;;
melunko@917
   502
melunko@917
   503
  --debug)
melunko@917
   504
    $echo "$progname: enabling shell trace mode"
melunko@917
   505
    set -x
melunko@917
   506
    preserve_args="$preserve_args $arg"
melunko@917
   507
    ;;
melunko@917
   508
melunko@917
   509
  --dry-run | -n)
melunko@917
   510
    run=:
melunko@917
   511
    ;;
melunko@917
   512
melunko@917
   513
  --features)
melunko@917
   514
    $echo "host: $host"
melunko@917
   515
    if test "$build_libtool_libs" = yes; then
melunko@917
   516
      $echo "enable shared libraries"
melunko@917
   517
    else
melunko@917
   518
      $echo "disable shared libraries"
melunko@917
   519
    fi
melunko@917
   520
    if test "$build_old_libs" = yes; then
melunko@917
   521
      $echo "enable static libraries"
melunko@917
   522
    else
melunko@917
   523
      $echo "disable static libraries"
melunko@917
   524
    fi
melunko@917
   525
    exit $?
melunko@917
   526
    ;;
melunko@917
   527
melunko@917
   528
  --finish) mode="finish" ;;
melunko@917
   529
melunko@917
   530
  --mode) prevopt="--mode" prev=mode ;;
melunko@917
   531
  --mode=*) mode="$optarg" ;;
melunko@917
   532
melunko@917
   533
  --preserve-dup-deps) duplicate_deps="yes" ;;
melunko@917
   534
melunko@917
   535
  --quiet | --silent)
melunko@917
   536
    show=:
melunko@917
   537
    preserve_args="$preserve_args $arg"
melunko@917
   538
    ;;
melunko@917
   539
melunko@917
   540
  --tag)
melunko@917
   541
    prevopt="--tag"
melunko@917
   542
    prev=tag
melunko@917
   543
    preserve_args="$preserve_args --tag"
melunko@917
   544
    ;;
melunko@917
   545
  --tag=*)
melunko@917
   546
    set tag "$optarg" ${1+"$@"}
melunko@917
   547
    shift
melunko@917
   548
    prev=tag
melunko@917
   549
    preserve_args="$preserve_args --tag"
melunko@917
   550
    ;;
melunko@917
   551
melunko@917
   552
  -dlopen)
melunko@917
   553
    prevopt="-dlopen"
melunko@917
   554
    prev=execute_dlfiles
melunko@917
   555
    ;;
melunko@917
   556
melunko@917
   557
  -*)
melunko@917
   558
    $echo "$modename: unrecognized option \`$arg'" 1>&2
melunko@917
   559
    $echo "$help" 1>&2
melunko@917
   560
    exit $EXIT_FAILURE
melunko@917
   561
    ;;
melunko@917
   562
melunko@917
   563
  *)
melunko@917
   564
    nonopt="$arg"
melunko@917
   565
    break
melunko@917
   566
    ;;
melunko@917
   567
  esac
melunko@917
   568
done
melunko@917
   569
melunko@917
   570
if test -n "$prevopt"; then
melunko@917
   571
  $echo "$modename: option \`$prevopt' requires an argument" 1>&2
melunko@917
   572
  $echo "$help" 1>&2
melunko@917
   573
  exit $EXIT_FAILURE
melunko@917
   574
fi
melunko@917
   575
melunko@917
   576
case $disable_libs in
melunko@917
   577
no) 
melunko@917
   578
  ;;
melunko@917
   579
shared)
melunko@917
   580
  build_libtool_libs=no
melunko@917
   581
  build_old_libs=yes
melunko@917
   582
  ;;
melunko@917
   583
static)
melunko@917
   584
  build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
melunko@917
   585
  ;;
melunko@917
   586
esac
melunko@917
   587
melunko@917
   588
# If this variable is set in any of the actions, the command in it
melunko@917
   589
# will be execed at the end.  This prevents here-documents from being
melunko@917
   590
# left over by shells.
melunko@917
   591
exec_cmd=
melunko@917
   592
melunko@917
   593
if test -z "$show_help"; then
melunko@917
   594
melunko@917
   595
  # Infer the operation mode.
melunko@917
   596
  if test -z "$mode"; then
melunko@917
   597
    $echo "*** Warning: inferring the mode of operation is deprecated." 1>&2
melunko@917
   598
    $echo "*** Future versions of Libtool will require --mode=MODE be specified." 1>&2
melunko@917
   599
    case $nonopt in
melunko@917
   600
    *cc | cc* | *++ | gcc* | *-gcc* | g++* | xlc*)
melunko@917
   601
      mode=link
melunko@917
   602
      for arg
melunko@917
   603
      do
melunko@917
   604
	case $arg in
melunko@917
   605
	-c)
melunko@917
   606
	   mode=compile
melunko@917
   607
	   break
melunko@917
   608
	   ;;
melunko@917
   609
	esac
melunko@917
   610
      done
melunko@917
   611
      ;;
melunko@917
   612
    *db | *dbx | *strace | *truss)
melunko@917
   613
      mode=execute
melunko@917
   614
      ;;
melunko@917
   615
    *install*|cp|mv)
melunko@917
   616
      mode=install
melunko@917
   617
      ;;
melunko@917
   618
    *rm)
melunko@917
   619
      mode=uninstall
melunko@917
   620
      ;;
melunko@917
   621
    *)
melunko@917
   622
      # If we have no mode, but dlfiles were specified, then do execute mode.
melunko@917
   623
      test -n "$execute_dlfiles" && mode=execute
melunko@917
   624
melunko@917
   625
      # Just use the default operation mode.
melunko@917
   626
      if test -z "$mode"; then
melunko@917
   627
	if test -n "$nonopt"; then
melunko@917
   628
	  $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2
melunko@917
   629
	else
melunko@917
   630
	  $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2
melunko@917
   631
	fi
melunko@917
   632
      fi
melunko@917
   633
      ;;
melunko@917
   634
    esac
melunko@917
   635
  fi
melunko@917
   636
melunko@917
   637
  # Only execute mode is allowed to have -dlopen flags.
melunko@917
   638
  if test -n "$execute_dlfiles" && test "$mode" != execute; then
melunko@917
   639
    $echo "$modename: unrecognized option \`-dlopen'" 1>&2
melunko@917
   640
    $echo "$help" 1>&2
melunko@917
   641
    exit $EXIT_FAILURE
melunko@917
   642
  fi
melunko@917
   643
melunko@917
   644
  # Change the help message to a mode-specific one.
melunko@917
   645
  generic_help="$help"
melunko@917
   646
  help="Try \`$modename --help --mode=$mode' for more information."
melunko@917
   647
melunko@917
   648
  # These modes are in order of execution frequency so that they run quickly.
melunko@917
   649
  case $mode in
melunko@917
   650
  # libtool compile mode
melunko@917
   651
  compile)
melunko@917
   652
    modename="$modename: compile"
melunko@917
   653
    # Get the compilation command and the source file.
melunko@917
   654
    base_compile=
melunko@917
   655
    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
melunko@917
   656
    suppress_opt=yes
melunko@917
   657
    suppress_output=
melunko@917
   658
    arg_mode=normal
melunko@917
   659
    libobj=
melunko@917
   660
    later=
melunko@917
   661
melunko@917
   662
    for arg
melunko@917
   663
    do
melunko@917
   664
      case $arg_mode in
melunko@917
   665
      arg  )
melunko@917
   666
	# do not "continue".  Instead, add this to base_compile
melunko@917
   667
	lastarg="$arg"
melunko@917
   668
	arg_mode=normal
melunko@917
   669
	;;
melunko@917
   670
melunko@917
   671
      target )
melunko@917
   672
	libobj="$arg"
melunko@917
   673
	arg_mode=normal
melunko@917
   674
	continue
melunko@917
   675
	;;
melunko@917
   676
melunko@917
   677
      normal )
melunko@917
   678
	# Accept any command-line options.
melunko@917
   679
	case $arg in
melunko@917
   680
	-o)
melunko@917
   681
	  if test -n "$libobj" ; then
melunko@917
   682
	    $echo "$modename: you cannot specify \`-o' more than once" 1>&2
melunko@917
   683
	    exit $EXIT_FAILURE
melunko@917
   684
	  fi
melunko@917
   685
	  arg_mode=target
melunko@917
   686
	  continue
melunko@917
   687
	  ;;
melunko@917
   688
melunko@917
   689
	-static | -prefer-pic | -prefer-non-pic)
melunko@917
   690
	  later="$later $arg"
melunko@917
   691
	  continue
melunko@917
   692
	  ;;
melunko@917
   693
melunko@917
   694
	-no-suppress)
melunko@917
   695
	  suppress_opt=no
melunko@917
   696
	  continue
melunko@917
   697
	  ;;
melunko@917
   698
melunko@917
   699
	-Xcompiler)
melunko@917
   700
	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
melunko@917
   701
	  continue      #  The current "srcfile" will either be retained or
melunko@917
   702
	  ;;            #  replaced later.  I would guess that would be a bug.
melunko@917
   703
melunko@917
   704
	-Wc,*)
melunko@917
   705
	  args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"`
melunko@917
   706
	  lastarg=
melunko@917
   707
	  save_ifs="$IFS"; IFS=','
melunko@917
   708
 	  for arg in $args; do
melunko@917
   709
	    IFS="$save_ifs"
melunko@917
   710
melunko@917
   711
	    # Double-quote args containing other shell metacharacters.
melunko@917
   712
	    # Many Bourne shells cannot handle close brackets correctly
melunko@917
   713
	    # in scan sets, so we specify it separately.
melunko@917
   714
	    case $arg in
melunko@917
   715
	      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
melunko@917
   716
	      arg="\"$arg\""
melunko@917
   717
	      ;;
melunko@917
   718
	    esac
melunko@917
   719
	    lastarg="$lastarg $arg"
melunko@917
   720
	  done
melunko@917
   721
	  IFS="$save_ifs"
melunko@917
   722
	  lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"`
melunko@917
   723
melunko@917
   724
	  # Add the arguments to base_compile.
melunko@917
   725
	  base_compile="$base_compile $lastarg"
melunko@917
   726
	  continue
melunko@917
   727
	  ;;
melunko@917
   728
melunko@917
   729
	* )
melunko@917
   730
	  # Accept the current argument as the source file.
melunko@917
   731
	  # The previous "srcfile" becomes the current argument.
melunko@917
   732
	  #
melunko@917
   733
	  lastarg="$srcfile"
melunko@917
   734
	  srcfile="$arg"
melunko@917
   735
	  ;;
melunko@917
   736
	esac  #  case $arg
melunko@917
   737
	;;
melunko@917
   738
      esac    #  case $arg_mode
melunko@917
   739
melunko@917
   740
      # Aesthetically quote the previous argument.
melunko@917
   741
      lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"`
melunko@917
   742
melunko@917
   743
      case $lastarg in
melunko@917
   744
      # Double-quote args containing other shell metacharacters.
melunko@917
   745
      # Many Bourne shells cannot handle close brackets correctly
melunko@917
   746
      # in scan sets, and some SunOS ksh mistreat backslash-escaping
melunko@917
   747
      # in scan sets (worked around with variable expansion),
melunko@917
   748
      # and furthermore cannot handle '|' '&' '(' ')' in scan sets 
melunko@917
   749
      # at all, so we specify them separately.
melunko@917
   750
      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
melunko@917
   751
	lastarg="\"$lastarg\""
melunko@917
   752
	;;
melunko@917
   753
      esac
melunko@917
   754
melunko@917
   755
      base_compile="$base_compile $lastarg"
melunko@917
   756
    done # for arg
melunko@917
   757
melunko@917
   758
    case $arg_mode in
melunko@917
   759
    arg)
melunko@917
   760
      $echo "$modename: you must specify an argument for -Xcompile"
melunko@917
   761
      exit $EXIT_FAILURE
melunko@917
   762
      ;;
melunko@917
   763
    target)
melunko@917
   764
      $echo "$modename: you must specify a target with \`-o'" 1>&2
melunko@917
   765
      exit $EXIT_FAILURE
melunko@917
   766
      ;;
melunko@917
   767
    *)
melunko@917
   768
      # Get the name of the library object.
melunko@917
   769
      [ -z "$libobj" ] && libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'`
melunko@917
   770
      ;;
melunko@917
   771
    esac
melunko@917
   772
melunko@917
   773
    # Recognize several different file suffixes.
melunko@917
   774
    # If the user specifies -o file.o, it is replaced with file.lo
melunko@917
   775
    xform='[cCFSifmso]'
melunko@917
   776
    case $libobj in
melunko@917
   777
    *.ada) xform=ada ;;
melunko@917
   778
    *.adb) xform=adb ;;
melunko@917
   779
    *.ads) xform=ads ;;
melunko@917
   780
    *.asm) xform=asm ;;
melunko@917
   781
    *.c++) xform=c++ ;;
melunko@917
   782
    *.cc) xform=cc ;;
melunko@917
   783
    *.ii) xform=ii ;;
melunko@917
   784
    *.class) xform=class ;;
melunko@917
   785
    *.cpp) xform=cpp ;;
melunko@917
   786
    *.cxx) xform=cxx ;;
melunko@917
   787
    *.[fF][09]?) xform=[fF][09]. ;;
melunko@917
   788
    *.for) xform=for ;;
melunko@917
   789
    *.java) xform=java ;;
melunko@917
   790
    *.obj) xform=obj ;;
melunko@917
   791
    esac
melunko@917
   792
melunko@917
   793
    libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"`
melunko@917
   794
melunko@917
   795
    case $libobj in
melunko@917
   796
    *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;;
melunko@917
   797
    *)
melunko@917
   798
      $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2
melunko@917
   799
      exit $EXIT_FAILURE
melunko@917
   800
      ;;
melunko@917
   801
    esac
melunko@917
   802
melunko@917
   803
    func_infer_tag $base_compile
melunko@917
   804
melunko@917
   805
    for arg in $later; do
melunko@917
   806
      case $arg in
melunko@917
   807
      -static)
melunko@917
   808
	build_old_libs=yes
melunko@917
   809
	continue
melunko@917
   810
	;;
melunko@917
   811
melunko@917
   812
      -prefer-pic)
melunko@917
   813
	pic_mode=yes
melunko@917
   814
	continue
melunko@917
   815
	;;
melunko@917
   816
melunko@917
   817
      -prefer-non-pic)
melunko@917
   818
	pic_mode=no
melunko@917
   819
	continue
melunko@917
   820
	;;
melunko@917
   821
      esac
melunko@917
   822
    done
melunko@917
   823
melunko@917
   824
    qlibobj=`$echo "X$libobj" | $Xsed -e "$sed_quote_subst"`
melunko@917
   825
    case $qlibobj in
melunko@917
   826
      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
melunko@917
   827
	qlibobj="\"$qlibobj\"" ;;
melunko@917
   828
    esac
melunko@917
   829
    test "X$libobj" != "X$qlibobj" \
melunko@917
   830
	&& $echo "X$libobj" | grep '[]~#^*{};<>?"'"'"' 	&()|`$[]' \
melunko@917
   831
	&& $echo "$modename: libobj name \`$libobj' may not contain shell special characters."
melunko@917
   832
    objname=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
melunko@917
   833
    xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'`
melunko@917
   834
    if test "X$xdir" = "X$obj"; then
melunko@917
   835
      xdir=
melunko@917
   836
    else
melunko@917
   837
      xdir=$xdir/
melunko@917
   838
    fi
melunko@917
   839
    lobj=${xdir}$objdir/$objname
melunko@917
   840
melunko@917
   841
    if test -z "$base_compile"; then
melunko@917
   842
      $echo "$modename: you must specify a compilation command" 1>&2
melunko@917
   843
      $echo "$help" 1>&2
melunko@917
   844
      exit $EXIT_FAILURE
melunko@917
   845
    fi
melunko@917
   846
melunko@917
   847
    # Delete any leftover library objects.
melunko@917
   848
    if test "$build_old_libs" = yes; then
melunko@917
   849
      removelist="$obj $lobj $libobj ${libobj}T"
melunko@917
   850
    else
melunko@917
   851
      removelist="$lobj $libobj ${libobj}T"
melunko@917
   852
    fi
melunko@917
   853
melunko@917
   854
    $run $rm $removelist
melunko@917
   855
    trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
melunko@917
   856
melunko@917
   857
    # On Cygwin there's no "real" PIC flag so we must build both object types
melunko@917
   858
    case $host_os in
melunko@917
   859
    cygwin* | mingw* | pw32* | os2*)
melunko@917
   860
      pic_mode=default
melunko@917
   861
      ;;
melunko@917
   862
    esac
melunko@917
   863
    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
melunko@917
   864
      # non-PIC code in shared libraries is not supported
melunko@917
   865
      pic_mode=default
melunko@917
   866
    fi
melunko@917
   867
melunko@917
   868
    # Calculate the filename of the output object if compiler does
melunko@917
   869
    # not support -o with -c
melunko@917
   870
    if test "$compiler_c_o" = no; then
melunko@917
   871
      output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}
melunko@917
   872
      lockfile="$output_obj.lock"
melunko@917
   873
      removelist="$removelist $output_obj $lockfile"
melunko@917
   874
      trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
melunko@917
   875
    else
melunko@917
   876
      output_obj=
melunko@917
   877
      need_locks=no
melunko@917
   878
      lockfile=
melunko@917
   879
    fi
melunko@917
   880
melunko@917
   881
    # Lock this critical section if it is needed
melunko@917
   882
    # We use this script file to make the link, it avoids creating a new file
melunko@917
   883
    if test "$need_locks" = yes; then
melunko@917
   884
      until $run ln "$progpath" "$lockfile" 2>/dev/null; do
melunko@917
   885
	$show "Waiting for $lockfile to be removed"
melunko@917
   886
	sleep 2
melunko@917
   887
      done
melunko@917
   888
    elif test "$need_locks" = warn; then
melunko@917
   889
      if test -f "$lockfile"; then
melunko@917
   890
	$echo "\
melunko@917
   891
*** ERROR, $lockfile exists and contains:
melunko@917
   892
`cat $lockfile 2>/dev/null`
melunko@917
   893
melunko@917
   894
This indicates that another process is trying to use the same
melunko@917
   895
temporary object file, and libtool could not work around it because
melunko@917
   896
your compiler does not support \`-c' and \`-o' together.  If you
melunko@917
   897
repeat this compilation, it may succeed, by chance, but you had better
melunko@917
   898
avoid parallel builds (make -j) in this platform, or get a better
melunko@917
   899
compiler."
melunko@917
   900
melunko@917
   901
	$run $rm $removelist
melunko@917
   902
	exit $EXIT_FAILURE
melunko@917
   903
      fi
melunko@917
   904
      $echo "$srcfile" > "$lockfile"
melunko@917
   905
    fi
melunko@917
   906
melunko@917
   907
    if test -n "$fix_srcfile_path"; then
melunko@917
   908
      eval srcfile=\"$fix_srcfile_path\"
melunko@917
   909
    fi
melunko@917
   910
    qsrcfile=`$echo "X$srcfile" | $Xsed -e "$sed_quote_subst"`
melunko@917
   911
    case $qsrcfile in
melunko@917
   912
      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
melunko@917
   913
      qsrcfile="\"$qsrcfile\"" ;;
melunko@917
   914
    esac
melunko@917
   915
melunko@917
   916
    $run $rm "$libobj" "${libobj}T"
melunko@917
   917
melunko@917
   918
    # Create a libtool object file (analogous to a ".la" file),
melunko@917
   919
    # but don't create it if we're doing a dry run.
melunko@917
   920
    test -z "$run" && cat > ${libobj}T <<EOF
melunko@917
   921
# $libobj - a libtool object file
melunko@917
   922
# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
melunko@917
   923
#
melunko@917
   924
# Please DO NOT delete this file!
melunko@917
   925
# It is necessary for linking the library.
melunko@917
   926
melunko@917
   927
# Name of the PIC object.
melunko@917
   928
EOF
melunko@917
   929
melunko@917
   930
    # Only build a PIC object if we are building libtool libraries.
melunko@917
   931
    if test "$build_libtool_libs" = yes; then
melunko@917
   932
      # Without this assignment, base_compile gets emptied.
melunko@917
   933
      fbsd_hideous_sh_bug=$base_compile
melunko@917
   934
melunko@917
   935
      if test "$pic_mode" != no; then
melunko@917
   936
	command="$base_compile $qsrcfile $pic_flag"
melunko@917
   937
      else
melunko@917
   938
	# Don't build PIC code
melunko@917
   939
	command="$base_compile $qsrcfile"
melunko@917
   940
      fi
melunko@917
   941
melunko@917
   942
      if test ! -d "${xdir}$objdir"; then
melunko@917
   943
	$show "$mkdir ${xdir}$objdir"
melunko@917
   944
	$run $mkdir ${xdir}$objdir
melunko@917
   945
	exit_status=$?
melunko@917
   946
	if test "$exit_status" -ne 0 && test ! -d "${xdir}$objdir"; then
melunko@917
   947
	  exit $exit_status
melunko@917
   948
	fi
melunko@917
   949
      fi
melunko@917
   950
melunko@917
   951
      if test -z "$output_obj"; then
melunko@917
   952
	# Place PIC objects in $objdir
melunko@917
   953
	command="$command -o $lobj"
melunko@917
   954
      fi
melunko@917
   955
melunko@917
   956
      $run $rm "$lobj" "$output_obj"
melunko@917
   957
melunko@917
   958
      $show "$command"
melunko@917
   959
      if $run eval "$command"; then :
melunko@917
   960
      else
melunko@917
   961
	test -n "$output_obj" && $run $rm $removelist
melunko@917
   962
	exit $EXIT_FAILURE
melunko@917
   963
      fi
melunko@917
   964
melunko@917
   965
      if test "$need_locks" = warn &&
melunko@917
   966
	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
melunko@917
   967
	$echo "\
melunko@917
   968
*** ERROR, $lockfile contains:
melunko@917
   969
`cat $lockfile 2>/dev/null`
melunko@917
   970
melunko@917
   971
but it should contain:
melunko@917
   972
$srcfile
melunko@917
   973
melunko@917
   974
This indicates that another process is trying to use the same
melunko@917
   975
temporary object file, and libtool could not work around it because
melunko@917
   976
your compiler does not support \`-c' and \`-o' together.  If you
melunko@917
   977
repeat this compilation, it may succeed, by chance, but you had better
melunko@917
   978
avoid parallel builds (make -j) in this platform, or get a better
melunko@917
   979
compiler."
melunko@917
   980
melunko@917
   981
	$run $rm $removelist
melunko@917
   982
	exit $EXIT_FAILURE
melunko@917
   983
      fi
melunko@917
   984
melunko@917
   985
      # Just move the object if needed, then go on to compile the next one
melunko@917
   986
      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
melunko@917
   987
	$show "$mv $output_obj $lobj"
melunko@917
   988
	if $run $mv $output_obj $lobj; then :
melunko@917
   989
	else
melunko@917
   990
	  error=$?
melunko@917
   991
	  $run $rm $removelist
melunko@917
   992
	  exit $error
melunko@917
   993
	fi
melunko@917
   994
      fi
melunko@917
   995
melunko@917
   996
      # Append the name of the PIC object to the libtool object file.
melunko@917
   997
      test -z "$run" && cat >> ${libobj}T <<EOF
melunko@917
   998
pic_object='$objdir/$objname'
melunko@917
   999
melunko@917
  1000
EOF
melunko@917
  1001
melunko@917
  1002
      # Allow error messages only from the first compilation.
melunko@917
  1003
      if test "$suppress_opt" = yes; then
melunko@917
  1004
        suppress_output=' >/dev/null 2>&1'
melunko@917
  1005
      fi
melunko@917
  1006
    else
melunko@917
  1007
      # No PIC object so indicate it doesn't exist in the libtool
melunko@917
  1008
      # object file.
melunko@917
  1009
      test -z "$run" && cat >> ${libobj}T <<EOF
melunko@917
  1010
pic_object=none
melunko@917
  1011
melunko@917
  1012
EOF
melunko@917
  1013
    fi
melunko@917
  1014
melunko@917
  1015
    # Only build a position-dependent object if we build old libraries.
melunko@917
  1016
    if test "$build_old_libs" = yes; then
melunko@917
  1017
      if test "$pic_mode" != yes; then
melunko@917
  1018
	# Don't build PIC code
melunko@917
  1019
	command="$base_compile $qsrcfile"
melunko@917
  1020
      else
melunko@917
  1021
	command="$base_compile $qsrcfile $pic_flag"
melunko@917
  1022
      fi
melunko@917
  1023
      if test "$compiler_c_o" = yes; then
melunko@917
  1024
	command="$command -o $obj"
melunko@917
  1025
      fi
melunko@917
  1026
melunko@917
  1027
      # Suppress compiler output if we already did a PIC compilation.
melunko@917
  1028
      command="$command$suppress_output"
melunko@917
  1029
      $run $rm "$obj" "$output_obj"
melunko@917
  1030
      $show "$command"
melunko@917
  1031
      if $run eval "$command"; then :
melunko@917
  1032
      else
melunko@917
  1033
	$run $rm $removelist
melunko@917
  1034
	exit $EXIT_FAILURE
melunko@917
  1035
      fi
melunko@917
  1036
melunko@917
  1037
      if test "$need_locks" = warn &&
melunko@917
  1038
	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
melunko@917
  1039
	$echo "\
melunko@917
  1040
*** ERROR, $lockfile contains:
melunko@917
  1041
`cat $lockfile 2>/dev/null`
melunko@917
  1042
melunko@917
  1043
but it should contain:
melunko@917
  1044
$srcfile
melunko@917
  1045
melunko@917
  1046
This indicates that another process is trying to use the same
melunko@917
  1047
temporary object file, and libtool could not work around it because
melunko@917
  1048
your compiler does not support \`-c' and \`-o' together.  If you
melunko@917
  1049
repeat this compilation, it may succeed, by chance, but you had better
melunko@917
  1050
avoid parallel builds (make -j) in this platform, or get a better
melunko@917
  1051
compiler."
melunko@917
  1052
melunko@917
  1053
	$run $rm $removelist
melunko@917
  1054
	exit $EXIT_FAILURE
melunko@917
  1055
      fi
melunko@917
  1056
melunko@917
  1057
      # Just move the object if needed
melunko@917
  1058
      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
melunko@917
  1059
	$show "$mv $output_obj $obj"
melunko@917
  1060
	if $run $mv $output_obj $obj; then :
melunko@917
  1061
	else
melunko@917
  1062
	  error=$?
melunko@917
  1063
	  $run $rm $removelist
melunko@917
  1064
	  exit $error
melunko@917
  1065
	fi
melunko@917
  1066
      fi
melunko@917
  1067
melunko@917
  1068
      # Append the name of the non-PIC object the libtool object file.
melunko@917
  1069
      # Only append if the libtool object file exists.
melunko@917
  1070
      test -z "$run" && cat >> ${libobj}T <<EOF
melunko@917
  1071
# Name of the non-PIC object.
melunko@917
  1072
non_pic_object='$objname'
melunko@917
  1073
melunko@917
  1074
EOF
melunko@917
  1075
    else
melunko@917
  1076
      # Append the name of the non-PIC object the libtool object file.
melunko@917
  1077
      # Only append if the libtool object file exists.
melunko@917
  1078
      test -z "$run" && cat >> ${libobj}T <<EOF
melunko@917
  1079
# Name of the non-PIC object.
melunko@917
  1080
non_pic_object=none
melunko@917
  1081
melunko@917
  1082
EOF
melunko@917
  1083
    fi
melunko@917
  1084
melunko@917
  1085
    $run $mv "${libobj}T" "${libobj}"
melunko@917
  1086
melunko@917
  1087
    # Unlock the critical section if it was locked
melunko@917
  1088
    if test "$need_locks" != no; then
melunko@917
  1089
      $run $rm "$lockfile"
melunko@917
  1090
    fi
melunko@917
  1091
melunko@917
  1092
    exit $EXIT_SUCCESS
melunko@917
  1093
    ;;
melunko@917
  1094
melunko@917
  1095
  # libtool link mode
melunko@917
  1096
  link | relink)
melunko@917
  1097
    modename="$modename: link"
melunko@917
  1098
    case $host in
melunko@917
  1099
    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
melunko@917
  1100
      # It is impossible to link a dll without this setting, and
melunko@917
  1101
      # we shouldn't force the makefile maintainer to figure out
melunko@917
  1102
      # which system we are compiling for in order to pass an extra
melunko@917
  1103
      # flag for every libtool invocation.
melunko@917
  1104
      # allow_undefined=no
melunko@917
  1105
melunko@917
  1106
      # FIXME: Unfortunately, there are problems with the above when trying
melunko@917
  1107
      # to make a dll which has undefined symbols, in which case not
melunko@917
  1108
      # even a static library is built.  For now, we need to specify
melunko@917
  1109
      # -no-undefined on the libtool link line when we can be certain
melunko@917
  1110
      # that all symbols are satisfied, otherwise we get a static library.
melunko@917
  1111
      allow_undefined=yes
melunko@917
  1112
      ;;
melunko@917
  1113
    *)
melunko@917
  1114
      allow_undefined=yes
melunko@917
  1115
      ;;
melunko@917
  1116
    esac
melunko@917
  1117
    libtool_args="$nonopt"
melunko@917
  1118
    base_compile="$nonopt $@"
melunko@917
  1119
    compile_command="$nonopt"
melunko@917
  1120
    finalize_command="$nonopt"
melunko@917
  1121
melunko@917
  1122
    compile_rpath=
melunko@917
  1123
    finalize_rpath=
melunko@917
  1124
    compile_shlibpath=
melunko@917
  1125
    finalize_shlibpath=
melunko@917
  1126
    convenience=
melunko@917
  1127
    old_convenience=
melunko@917
  1128
    deplibs=
melunko@917
  1129
    old_deplibs=
melunko@917
  1130
    compiler_flags=
melunko@917
  1131
    linker_flags=
melunko@917
  1132
    dllsearchpath=
melunko@917
  1133
    lib_search_path=`pwd`
melunko@917
  1134
    inst_prefix_dir=
melunko@917
  1135
melunko@917
  1136
    avoid_version=no
melunko@917
  1137
    dlfiles=
melunko@917
  1138
    dlprefiles=
melunko@917
  1139
    dlself=no
melunko@917
  1140
    export_dynamic=no
melunko@917
  1141
    export_symbols=
melunko@917
  1142
    export_symbols_regex=
melunko@917
  1143
    generated=
melunko@917
  1144
    libobjs=
melunko@917
  1145
    ltlibs=
melunko@917
  1146
    module=no
melunko@917
  1147
    no_install=no
melunko@917
  1148
    objs=
melunko@917
  1149
    non_pic_objects=
melunko@917
  1150
    notinst_path= # paths that contain not-installed libtool libraries
melunko@917
  1151
    precious_files_regex=
melunko@917
  1152
    prefer_static_libs=no
melunko@917
  1153
    preload=no
melunko@917
  1154
    prev=
melunko@917
  1155
    prevarg=
melunko@917
  1156
    release=
melunko@917
  1157
    rpath=
melunko@917
  1158
    xrpath=
melunko@917
  1159
    perm_rpath=
melunko@917
  1160
    temp_rpath=
melunko@917
  1161
    thread_safe=no
melunko@917
  1162
    vinfo=
melunko@917
  1163
    vinfo_number=no
melunko@917
  1164
melunko@917
  1165
    func_infer_tag $base_compile
melunko@917
  1166
melunko@917
  1167
    # We need to know -static, to get the right output filenames.
melunko@917
  1168
    for arg
melunko@917
  1169
    do
melunko@917
  1170
      case $arg in
melunko@917
  1171
      -all-static | -static | -static-libtool-libs)
melunko@917
  1172
	case $arg in
melunko@917
  1173
	-all-static)
melunko@917
  1174
	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
melunko@917
  1175
	    $echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2
melunko@917
  1176
	  fi
melunko@917
  1177
	  if test -n "$link_static_flag"; then
melunko@917
  1178
	    dlopen_self=$dlopen_self_static
melunko@917
  1179
	  fi
melunko@917
  1180
	  prefer_static_libs=yes
melunko@917
  1181
	  ;;
melunko@917
  1182
	-static)
melunko@917
  1183
	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
melunko@917
  1184
	    dlopen_self=$dlopen_self_static
melunko@917
  1185
	  fi
melunko@917
  1186
	  prefer_static_libs=built
melunko@917
  1187
	  ;;
melunko@917
  1188
	-static-libtool-libs)
melunko@917
  1189
	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
melunko@917
  1190
	    dlopen_self=$dlopen_self_static
melunko@917
  1191
	  fi
melunko@917
  1192
	  prefer_static_libs=yes
melunko@917
  1193
	  ;;
melunko@917
  1194
	esac
melunko@917
  1195
	build_libtool_libs=no
melunko@917
  1196
	build_old_libs=yes
melunko@917
  1197
	break
melunko@917
  1198
	;;
melunko@917
  1199
      esac
melunko@917
  1200
    done
melunko@917
  1201
melunko@917
  1202
    # See if our shared archives depend on static archives.
melunko@917
  1203
    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
melunko@917
  1204
melunko@917
  1205
    # Go through the arguments, transforming them on the way.
melunko@917
  1206
    while test "$#" -gt 0; do
melunko@917
  1207
      arg="$1"
melunko@917
  1208
      shift
melunko@917
  1209
      case $arg in
melunko@917
  1210
      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
melunko@917
  1211
	qarg=\"`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`\" ### testsuite: skip nested quoting test
melunko@917
  1212
	;;
melunko@917
  1213
      *) qarg=$arg ;;
melunko@917
  1214
      esac
melunko@917
  1215
      libtool_args="$libtool_args $qarg"
melunko@917
  1216
melunko@917
  1217
      # If the previous option needs an argument, assign it.
melunko@917
  1218
      if test -n "$prev"; then
melunko@917
  1219
	case $prev in
melunko@917
  1220
	output)
melunko@917
  1221
	  compile_command="$compile_command @OUTPUT@"
melunko@917
  1222
	  finalize_command="$finalize_command @OUTPUT@"
melunko@917
  1223
	  ;;
melunko@917
  1224
	esac
melunko@917
  1225
melunko@917
  1226
	case $prev in
melunko@917
  1227
	dlfiles|dlprefiles)
melunko@917
  1228
	  if test "$preload" = no; then
melunko@917
  1229
	    # Add the symbol object into the linking commands.
melunko@917
  1230
	    compile_command="$compile_command @SYMFILE@"
melunko@917
  1231
	    finalize_command="$finalize_command @SYMFILE@"
melunko@917
  1232
	    preload=yes
melunko@917
  1233
	  fi
melunko@917
  1234
	  case $arg in
melunko@917
  1235
	  *.la | *.lo) ;;  # We handle these cases below.
melunko@917
  1236
	  force)
melunko@917
  1237
	    if test "$dlself" = no; then
melunko@917
  1238
	      dlself=needless
melunko@917
  1239
	      export_dynamic=yes
melunko@917
  1240
	    fi
melunko@917
  1241
	    prev=
melunko@917
  1242
	    continue
melunko@917
  1243
	    ;;
melunko@917
  1244
	  self)
melunko@917
  1245
	    if test "$prev" = dlprefiles; then
melunko@917
  1246
	      dlself=yes
melunko@917
  1247
	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
melunko@917
  1248
	      dlself=yes
melunko@917
  1249
	    else
melunko@917
  1250
	      dlself=needless
melunko@917
  1251
	      export_dynamic=yes
melunko@917
  1252
	    fi
melunko@917
  1253
	    prev=
melunko@917
  1254
	    continue
melunko@917
  1255
	    ;;
melunko@917
  1256
	  *)
melunko@917
  1257
	    if test "$prev" = dlfiles; then
melunko@917
  1258
	      dlfiles="$dlfiles $arg"
melunko@917
  1259
	    else
melunko@917
  1260
	      dlprefiles="$dlprefiles $arg"
melunko@917
  1261
	    fi
melunko@917
  1262
	    prev=
melunko@917
  1263
	    continue
melunko@917
  1264
	    ;;
melunko@917
  1265
	  esac
melunko@917
  1266
	  ;;
melunko@917
  1267
	expsyms)
melunko@917
  1268
	  export_symbols="$arg"
melunko@917
  1269
	  if test ! -f "$arg"; then
melunko@917
  1270
	    $echo "$modename: symbol file \`$arg' does not exist"
melunko@917
  1271
	    exit $EXIT_FAILURE
melunko@917
  1272
	  fi
melunko@917
  1273
	  prev=
melunko@917
  1274
	  continue
melunko@917
  1275
	  ;;
melunko@917
  1276
	expsyms_regex)
melunko@917
  1277
	  export_symbols_regex="$arg"
melunko@917
  1278
	  prev=
melunko@917
  1279
	  continue
melunko@917
  1280
	  ;;
melunko@917
  1281
	inst_prefix)
melunko@917
  1282
	  inst_prefix_dir="$arg"
melunko@917
  1283
	  prev=
melunko@917
  1284
	  continue
melunko@917
  1285
	  ;;
melunko@917
  1286
	precious_regex)
melunko@917
  1287
	  precious_files_regex="$arg"
melunko@917
  1288
	  prev=
melunko@917
  1289
	  continue
melunko@917
  1290
	  ;;
melunko@917
  1291
	release)
melunko@917
  1292
	  release="-$arg"
melunko@917
  1293
	  prev=
melunko@917
  1294
	  continue
melunko@917
  1295
	  ;;
melunko@917
  1296
	objectlist)
melunko@917
  1297
	  if test -f "$arg"; then
melunko@917
  1298
	    save_arg=$arg
melunko@917
  1299
	    moreargs=
melunko@917
  1300
	    for fil in `cat $save_arg`
melunko@917
  1301
	    do
melunko@917
  1302
#	      moreargs="$moreargs $fil"
melunko@917
  1303
	      arg=$fil
melunko@917
  1304
	      # A libtool-controlled object.
melunko@917
  1305
melunko@917
  1306
	      # Check to see that this really is a libtool object.
melunko@917
  1307
	      if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
melunko@917
  1308
		pic_object=
melunko@917
  1309
		non_pic_object=
melunko@917
  1310
melunko@917
  1311
		# Read the .lo file
melunko@917
  1312
		# If there is no directory component, then add one.
melunko@917
  1313
		case $arg in
melunko@917
  1314
		*/* | *\\*) . $arg ;;
melunko@917
  1315
		*) . ./$arg ;;
melunko@917
  1316
		esac
melunko@917
  1317
melunko@917
  1318
		if test -z "$pic_object" || \
melunko@917
  1319
		   test -z "$non_pic_object" ||
melunko@917
  1320
		   test "$pic_object" = none && \
melunko@917
  1321
		   test "$non_pic_object" = none; then
melunko@917
  1322
		  $echo "$modename: cannot find name of object for \`$arg'" 1>&2
melunko@917
  1323
		  exit $EXIT_FAILURE
melunko@917
  1324
		fi
melunko@917
  1325
melunko@917
  1326
		# Extract subdirectory from the argument.
melunko@917
  1327
		xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
melunko@917
  1328
		if test "X$xdir" = "X$arg"; then
melunko@917
  1329
		  xdir=
melunko@917
  1330
		else
melunko@917
  1331
		  xdir="$xdir/"
melunko@917
  1332
		fi
melunko@917
  1333
melunko@917
  1334
		if test "$pic_object" != none; then
melunko@917
  1335
		  # Prepend the subdirectory the object is found in.
melunko@917
  1336
		  pic_object="$xdir$pic_object"
melunko@917
  1337
melunko@917
  1338
		  if test "$prev" = dlfiles; then
melunko@917
  1339
		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
melunko@917
  1340
		      dlfiles="$dlfiles $pic_object"
melunko@917
  1341
		      prev=
melunko@917
  1342
		      continue
melunko@917
  1343
		    else
melunko@917
  1344
		      # If libtool objects are unsupported, then we need to preload.
melunko@917
  1345
		      prev=dlprefiles
melunko@917
  1346
		    fi
melunko@917
  1347
		  fi
melunko@917
  1348
melunko@917
  1349
		  # CHECK ME:  I think I busted this.  -Ossama
melunko@917
  1350
		  if test "$prev" = dlprefiles; then
melunko@917
  1351
		    # Preload the old-style object.
melunko@917
  1352
		    dlprefiles="$dlprefiles $pic_object"
melunko@917
  1353
		    prev=
melunko@917
  1354
		  fi
melunko@917
  1355
melunko@917
  1356
		  # A PIC object.
melunko@917
  1357
		  libobjs="$libobjs $pic_object"
melunko@917
  1358
		  arg="$pic_object"
melunko@917
  1359
		fi
melunko@917
  1360
melunko@917
  1361
		# Non-PIC object.
melunko@917
  1362
		if test "$non_pic_object" != none; then
melunko@917
  1363
		  # Prepend the subdirectory the object is found in.
melunko@917
  1364
		  non_pic_object="$xdir$non_pic_object"
melunko@917
  1365
melunko@917
  1366
		  # A standard non-PIC object
melunko@917
  1367
		  non_pic_objects="$non_pic_objects $non_pic_object"
melunko@917
  1368
		  if test -z "$pic_object" || test "$pic_object" = none ; then
melunko@917
  1369
		    arg="$non_pic_object"
melunko@917
  1370
		  fi
melunko@917
  1371
		else
melunko@917
  1372
		  # If the PIC object exists, use it instead.
melunko@917
  1373
		  # $xdir was prepended to $pic_object above.
melunko@917
  1374
		  non_pic_object="$pic_object"
melunko@917
  1375
		  non_pic_objects="$non_pic_objects $non_pic_object"
melunko@917
  1376
		fi
melunko@917
  1377
	      else
melunko@917
  1378
		# Only an error if not doing a dry-run.
melunko@917
  1379
		if test -z "$run"; then
melunko@917
  1380
		  $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
melunko@917
  1381
		  exit $EXIT_FAILURE
melunko@917
  1382
		else
melunko@917
  1383
		  # Dry-run case.
melunko@917
  1384
melunko@917
  1385
		  # Extract subdirectory from the argument.
melunko@917
  1386
		  xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
melunko@917
  1387
		  if test "X$xdir" = "X$arg"; then
melunko@917
  1388
		    xdir=
melunko@917
  1389
		  else
melunko@917
  1390
		    xdir="$xdir/"
melunko@917
  1391
		  fi
melunko@917
  1392
melunko@917
  1393
		  pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
melunko@917
  1394
		  non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
melunko@917
  1395
		  libobjs="$libobjs $pic_object"
melunko@917
  1396
		  non_pic_objects="$non_pic_objects $non_pic_object"
melunko@917
  1397
		fi
melunko@917
  1398
	      fi
melunko@917
  1399
	    done
melunko@917
  1400
	  else
melunko@917
  1401
	    $echo "$modename: link input file \`$save_arg' does not exist"
melunko@917
  1402
	    exit $EXIT_FAILURE
melunko@917
  1403
	  fi
melunko@917
  1404
	  arg=$save_arg
melunko@917
  1405
	  prev=
melunko@917
  1406
	  continue
melunko@917
  1407
	  ;;
melunko@917
  1408
	rpath | xrpath)
melunko@917
  1409
	  # We need an absolute path.
melunko@917
  1410
	  case $arg in
melunko@917
  1411
	  [\\/]* | [A-Za-z]:[\\/]*) ;;
melunko@917
  1412
	  *)
melunko@917
  1413
	    $echo "$modename: only absolute run-paths are allowed" 1>&2
melunko@917
  1414
	    exit $EXIT_FAILURE
melunko@917
  1415
	    ;;
melunko@917
  1416
	  esac
melunko@917
  1417
	  if test "$prev" = rpath; then
melunko@917
  1418
	    case "$rpath " in
melunko@917
  1419
	    *" $arg "*) ;;
melunko@917
  1420
	    *) rpath="$rpath $arg" ;;
melunko@917
  1421
	    esac
melunko@917
  1422
	  else
melunko@917
  1423
	    case "$xrpath " in
melunko@917
  1424
	    *" $arg "*) ;;
melunko@917
  1425
	    *) xrpath="$xrpath $arg" ;;
melunko@917
  1426
	    esac
melunko@917
  1427
	  fi
melunko@917
  1428
	  prev=
melunko@917
  1429
	  continue
melunko@917
  1430
	  ;;
melunko@917
  1431
	xcompiler)
melunko@917
  1432
	  compiler_flags="$compiler_flags $qarg"
melunko@917
  1433
	  prev=
melunko@917
  1434
	  compile_command="$compile_command $qarg"
melunko@917
  1435
	  finalize_command="$finalize_command $qarg"
melunko@917
  1436
	  continue
melunko@917
  1437
	  ;;
melunko@917
  1438
	xlinker)
melunko@917
  1439
	  linker_flags="$linker_flags $qarg"
melunko@917
  1440
	  compiler_flags="$compiler_flags $wl$qarg"
melunko@917
  1441
	  prev=
melunko@917
  1442
	  compile_command="$compile_command $wl$qarg"
melunko@917
  1443
	  finalize_command="$finalize_command $wl$qarg"
melunko@917
  1444
	  continue
melunko@917
  1445
	  ;;
melunko@917
  1446
	xcclinker)
melunko@917
  1447
	  linker_flags="$linker_flags $qarg"
melunko@917
  1448
	  compiler_flags="$compiler_flags $qarg"
melunko@917
  1449
	  prev=
melunko@917
  1450
	  compile_command="$compile_command $qarg"
melunko@917
  1451
	  finalize_command="$finalize_command $qarg"
melunko@917
  1452
	  continue
melunko@917
  1453
	  ;;
melunko@917
  1454
	shrext)
melunko@917
  1455
  	  shrext_cmds="$arg"
melunko@917
  1456
	  prev=
melunko@917
  1457
	  continue
melunko@917
  1458
	  ;;
melunko@917
  1459
	darwin_framework|darwin_framework_skip)
melunko@917
  1460
	  test "$prev" = "darwin_framework" && compiler_flags="$compiler_flags $arg"
melunko@917
  1461
	  compile_command="$compile_command $arg"
melunko@917
  1462
	  finalize_command="$finalize_command $arg"
melunko@917
  1463
	  prev=
melunko@917
  1464
	  continue
melunko@917
  1465
	  ;;
melunko@917
  1466
	*)
melunko@917
  1467
	  eval "$prev=\"\$arg\""
melunko@917
  1468
	  prev=
melunko@917
  1469
	  continue
melunko@917
  1470
	  ;;
melunko@917
  1471
	esac
melunko@917
  1472
      fi # test -n "$prev"
melunko@917
  1473
melunko@917
  1474
      prevarg="$arg"
melunko@917
  1475
melunko@917
  1476
      case $arg in
melunko@917
  1477
      -all-static)
melunko@917
  1478
	if test -n "$link_static_flag"; then
melunko@917
  1479
	  compile_command="$compile_command $link_static_flag"
melunko@917
  1480
	  finalize_command="$finalize_command $link_static_flag"
melunko@917
  1481
	fi
melunko@917
  1482
	continue
melunko@917
  1483
	;;
melunko@917
  1484
melunko@917
  1485
      -allow-undefined)
melunko@917
  1486
	# FIXME: remove this flag sometime in the future.
melunko@917
  1487
	$echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2
melunko@917
  1488
	continue
melunko@917
  1489
	;;
melunko@917
  1490
melunko@917
  1491
      -avoid-version)
melunko@917
  1492
	avoid_version=yes
melunko@917
  1493
	continue
melunko@917
  1494
	;;
melunko@917
  1495
melunko@917
  1496
      -dlopen)
melunko@917
  1497
	prev=dlfiles
melunko@917
  1498
	continue
melunko@917
  1499
	;;
melunko@917
  1500
melunko@917
  1501
      -dlpreopen)
melunko@917
  1502
	prev=dlprefiles
melunko@917
  1503
	continue
melunko@917
  1504
	;;
melunko@917
  1505
melunko@917
  1506
      -export-dynamic)
melunko@917
  1507
	export_dynamic=yes
melunko@917
  1508
	continue
melunko@917
  1509
	;;
melunko@917
  1510
melunko@917
  1511
      -export-symbols | -export-symbols-regex)
melunko@917
  1512
	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
melunko@917
  1513
	  $echo "$modename: more than one -exported-symbols argument is not allowed"
melunko@917
  1514
	  exit $EXIT_FAILURE
melunko@917
  1515
	fi
melunko@917
  1516
	if test "X$arg" = "X-export-symbols"; then
melunko@917
  1517
	  prev=expsyms
melunko@917
  1518
	else
melunko@917
  1519
	  prev=expsyms_regex
melunko@917
  1520
	fi
melunko@917
  1521
	continue
melunko@917
  1522
	;;
melunko@917
  1523
melunko@917
  1524
      -framework|-arch|-isysroot)
melunko@917
  1525
	case " $CC " in
melunko@917
  1526
	  *" ${arg} ${1} "* | *" ${arg}	${1} "*) 
melunko@917
  1527
		prev=darwin_framework_skip ;;
melunko@917
  1528
	  *) compiler_flags="$compiler_flags $arg"
melunko@917
  1529
	     prev=darwin_framework ;;
melunko@917
  1530
	esac
melunko@917
  1531
	compile_command="$compile_command $arg"
melunko@917
  1532
	finalize_command="$finalize_command $arg"
melunko@917
  1533
	continue
melunko@917
  1534
	;;
melunko@917
  1535
melunko@917
  1536
      -inst-prefix-dir)
melunko@917
  1537
	prev=inst_prefix
melunko@917
  1538
	continue
melunko@917
  1539
	;;
melunko@917
  1540
melunko@917
  1541
      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
melunko@917
  1542
      # so, if we see these flags be careful not to treat them like -L
melunko@917
  1543
      -L[A-Z][A-Z]*:*)
melunko@917
  1544
	case $with_gcc/$host in
melunko@917
  1545
	no/*-*-irix* | /*-*-irix*)
melunko@917
  1546
	  compile_command="$compile_command $arg"
melunko@917
  1547
	  finalize_command="$finalize_command $arg"
melunko@917
  1548
	  ;;
melunko@917
  1549
	esac
melunko@917
  1550
	continue
melunko@917
  1551
	;;
melunko@917
  1552
melunko@917
  1553
      -L*)
melunko@917
  1554
	dir=`$echo "X$arg" | $Xsed -e 's/^-L//'`
melunko@917
  1555
	# We need an absolute path.
melunko@917
  1556
	case $dir in
melunko@917
  1557
	[\\/]* | [A-Za-z]:[\\/]*) ;;
melunko@917
  1558
	*)
melunko@917
  1559
	  absdir=`cd "$dir" && pwd`
melunko@917
  1560
	  if test -z "$absdir"; then
melunko@917
  1561
	    $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2
melunko@917
  1562
	    absdir="$dir"
melunko@917
  1563
	    notinst_path="$notinst_path $dir"
melunko@917
  1564
	  fi
melunko@917
  1565
	  dir="$absdir"
melunko@917
  1566
	  ;;
melunko@917
  1567
	esac
melunko@917
  1568
	case "$deplibs " in
melunko@917
  1569
	*" -L$dir "*) ;;
melunko@917
  1570
	*)
melunko@917
  1571
	  deplibs="$deplibs -L$dir"
melunko@917
  1572
	  lib_search_path="$lib_search_path $dir"
melunko@917
  1573
	  ;;
melunko@917
  1574
	esac
melunko@917
  1575
	case $host in
melunko@917
  1576
	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
melunko@917
  1577
	  testbindir=`$echo "X$dir" | $Xsed -e 's*/lib$*/bin*'`
melunko@917
  1578
	  case :$dllsearchpath: in
melunko@917
  1579
	  *":$dir:"*) ;;
melunko@917
  1580
	  *) dllsearchpath="$dllsearchpath:$dir";;
melunko@917
  1581
	  esac
melunko@917
  1582
	  case :$dllsearchpath: in
melunko@917
  1583
	  *":$testbindir:"*) ;;
melunko@917
  1584
	  *) dllsearchpath="$dllsearchpath:$testbindir";;
melunko@917
  1585
	  esac
melunko@917
  1586
	  ;;
melunko@917
  1587
	esac
melunko@917
  1588
	continue
melunko@917
  1589
	;;
melunko@917
  1590
melunko@917
  1591
      -l*)
melunko@917
  1592
	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
melunko@917
  1593
	  case $host in
melunko@917
  1594
	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos*)
melunko@917
  1595
	    # These systems don't actually have a C or math library (as such)
melunko@917
  1596
	    continue
melunko@917
  1597
	    ;;
melunko@917
  1598
	  *-*-os2*)
melunko@917
  1599
	    # These systems don't actually have a C library (as such)
melunko@917
  1600
	    test "X$arg" = "X-lc" && continue
melunko@917
  1601
	    ;;
melunko@917
  1602
	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
melunko@917
  1603
	    # Do not include libc due to us having libc/libc_r.
melunko@917
  1604
	    test "X$arg" = "X-lc" && continue
melunko@917
  1605
	    ;;
melunko@917
  1606
	  *-*-rhapsody* | *-*-darwin1.[012])
melunko@917
  1607
	    # Rhapsody C and math libraries are in the System framework
melunko@917
  1608
	    deplibs="$deplibs -framework System"
melunko@917
  1609
	    continue
melunko@917
  1610
	    ;;
melunko@917
  1611
	  *-*-sco3.2v5* | *-*-sco5v6*)
melunko@917
  1612
	    # Causes problems with __ctype
melunko@917
  1613
	    test "X$arg" = "X-lc" && continue
melunko@917
  1614
	    ;;
melunko@917
  1615
	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
melunko@917
  1616
	    # Compiler inserts libc in the correct place for threads to work
melunko@917
  1617
	    test "X$arg" = "X-lc" && continue
melunko@917
  1618
	    ;;
melunko@917
  1619
	  esac
melunko@917
  1620
	elif test "X$arg" = "X-lc_r"; then
melunko@917
  1621
	 case $host in
melunko@917
  1622
	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
melunko@917
  1623
	   # Do not include libc_r directly, use -pthread flag.
melunko@917
  1624
	   continue
melunko@917
  1625
	   ;;
melunko@917
  1626
	 esac
melunko@917
  1627
	fi
melunko@917
  1628
	deplibs="$deplibs $arg"
melunko@917
  1629
	continue
melunko@917
  1630
	;;
melunko@917
  1631
melunko@917
  1632
      # Tru64 UNIX uses -model [arg] to determine the layout of C++
melunko@917
  1633
      # classes, name mangling, and exception handling.
melunko@917
  1634
      -model)
melunko@917
  1635
	compile_command="$compile_command $arg"
melunko@917
  1636
	compiler_flags="$compiler_flags $arg"
melunko@917
  1637
	finalize_command="$finalize_command $arg"
melunko@917
  1638
	prev=xcompiler
melunko@917
  1639
	continue
melunko@917
  1640
	;;
melunko@917
  1641
melunko@917
  1642
     -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
melunko@917
  1643
	compiler_flags="$compiler_flags $arg"
melunko@917
  1644
	compile_command="$compile_command $arg"
melunko@917
  1645
	finalize_command="$finalize_command $arg"
melunko@917
  1646
	continue
melunko@917
  1647
	;;
melunko@917
  1648
melunko@917
  1649
      -module)
melunko@917
  1650
	module=yes
melunko@917
  1651
	continue
melunko@917
  1652
	;;
melunko@917
  1653
melunko@917
  1654
      # -64, -mips[0-9] enable 64-bit mode on the SGI compiler
melunko@917
  1655
      # -r[0-9][0-9]* specifies the processor on the SGI compiler
melunko@917
  1656
      # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler
melunko@917
  1657
      # +DA*, +DD* enable 64-bit mode on the HP compiler
melunko@917
  1658
      # -q* pass through compiler args for the IBM compiler
melunko@917
  1659
      # -m* pass through architecture-specific compiler args for GCC
melunko@917
  1660
      # -m*, -t[45]*, -txscale* pass through architecture-specific
melunko@917
  1661
      # compiler args for GCC
melunko@917
  1662
      # -p, -pg, --coverage, -fprofile-* pass through profiling flag for GCC
melunko@917
  1663
      # -F/path gives path to uninstalled frameworks, gcc on darwin
melunko@917
  1664
      # @file GCC response files
melunko@917
  1665
      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
melunko@917
  1666
      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*)
melunko@917
  1667
melunko@917
  1668
	# Unknown arguments in both finalize_command and compile_command need
melunko@917
  1669
	# to be aesthetically quoted because they are evaled later.
melunko@917
  1670
	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
melunko@917
  1671
	case $arg in
melunko@917
  1672
	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
melunko@917
  1673
	  arg="\"$arg\""
melunko@917
  1674
	  ;;
melunko@917
  1675
	esac
melunko@917
  1676
        compile_command="$compile_command $arg"
melunko@917
  1677
        finalize_command="$finalize_command $arg"
melunko@917
  1678
        compiler_flags="$compiler_flags $arg"
melunko@917
  1679
        continue
melunko@917
  1680
        ;;
melunko@917
  1681
melunko@917
  1682
      -shrext)
melunko@917
  1683
	prev=shrext
melunko@917
  1684
	continue
melunko@917
  1685
	;;
melunko@917
  1686
melunko@917
  1687
      -no-fast-install)
melunko@917
  1688
	fast_install=no
melunko@917
  1689
	continue
melunko@917
  1690
	;;
melunko@917
  1691
melunko@917
  1692
      -no-install)
melunko@917
  1693
	case $host in
melunko@917
  1694
	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin*)
melunko@917
  1695
	  # The PATH hackery in wrapper scripts is required on Windows
melunko@917
  1696
	  # and Darwin in order for the loader to find any dlls it needs.
melunko@917
  1697
	  $echo "$modename: warning: \`-no-install' is ignored for $host" 1>&2
melunko@917
  1698
	  $echo "$modename: warning: assuming \`-no-fast-install' instead" 1>&2
melunko@917
  1699
	  fast_install=no
melunko@917
  1700
	  ;;
melunko@917
  1701
	*) no_install=yes ;;
melunko@917
  1702
	esac
melunko@917
  1703
	continue
melunko@917
  1704
	;;
melunko@917
  1705
melunko@917
  1706
      -no-undefined)
melunko@917
  1707
	allow_undefined=no
melunko@917
  1708
	continue
melunko@917
  1709
	;;
melunko@917
  1710
melunko@917
  1711
      -objectlist)
melunko@917
  1712
	prev=objectlist
melunko@917
  1713
	continue
melunko@917
  1714
	;;
melunko@917
  1715
melunko@917
  1716
      -o) prev=output ;;
melunko@917
  1717
melunko@917
  1718
      -precious-files-regex)
melunko@917
  1719
	prev=precious_regex
melunko@917
  1720
	continue
melunko@917
  1721
	;;
melunko@917
  1722
melunko@917
  1723
      -release)
melunko@917
  1724
	prev=release
melunko@917
  1725
	continue
melunko@917
  1726
	;;
melunko@917
  1727
melunko@917
  1728
      -rpath)
melunko@917
  1729
	prev=rpath
melunko@917
  1730
	continue
melunko@917
  1731
	;;
melunko@917
  1732
melunko@917
  1733
      -R)
melunko@917
  1734
	prev=xrpath
melunko@917
  1735
	continue
melunko@917
  1736
	;;
melunko@917
  1737
melunko@917
  1738
      -R*)
melunko@917
  1739
	dir=`$echo "X$arg" | $Xsed -e 's/^-R//'`
melunko@917
  1740
	# We need an absolute path.
melunko@917
  1741
	case $dir in
melunko@917
  1742
	[\\/]* | [A-Za-z]:[\\/]*) ;;
melunko@917
  1743
	*)
melunko@917
  1744
	  $echo "$modename: only absolute run-paths are allowed" 1>&2
melunko@917
  1745
	  exit $EXIT_FAILURE
melunko@917
  1746
	  ;;
melunko@917
  1747
	esac
melunko@917
  1748
	case "$xrpath " in
melunko@917
  1749
	*" $dir "*) ;;
melunko@917
  1750
	*) xrpath="$xrpath $dir" ;;
melunko@917
  1751
	esac
melunko@917
  1752
	continue
melunko@917
  1753
	;;
melunko@917
  1754
melunko@917
  1755
      -static | -static-libtool-libs)
melunko@917
  1756
	# The effects of -static are defined in a previous loop.
melunko@917
  1757
	# We used to do the same as -all-static on platforms that
melunko@917
  1758
	# didn't have a PIC flag, but the assumption that the effects
melunko@917
  1759
	# would be equivalent was wrong.  It would break on at least
melunko@917
  1760
	# Digital Unix and AIX.
melunko@917
  1761
	continue
melunko@917
  1762
	;;
melunko@917
  1763
melunko@917
  1764
      -thread-safe)
melunko@917
  1765
	thread_safe=yes
melunko@917
  1766
	continue
melunko@917
  1767
	;;
melunko@917
  1768
melunko@917
  1769
      -version-info)
melunko@917
  1770
	prev=vinfo
melunko@917
  1771
	continue
melunko@917
  1772
	;;
melunko@917
  1773
      -version-number)
melunko@917
  1774
	prev=vinfo
melunko@917
  1775
	vinfo_number=yes
melunko@917
  1776
	continue
melunko@917
  1777
	;;
melunko@917
  1778
melunko@917
  1779
      -Wc,*)
melunko@917
  1780
	args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wc,//'`
melunko@917
  1781
	arg=
melunko@917
  1782
	save_ifs="$IFS"; IFS=','
melunko@917
  1783
	for flag in $args; do
melunko@917
  1784
	  IFS="$save_ifs"
melunko@917
  1785
	  case $flag in
melunko@917
  1786
	    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
melunko@917
  1787
	    flag="\"$flag\""
melunko@917
  1788
	    ;;
melunko@917
  1789
	  esac
melunko@917
  1790
	  arg="$arg $wl$flag"
melunko@917
  1791
	  compiler_flags="$compiler_flags $flag"
melunko@917
  1792
	done
melunko@917
  1793
	IFS="$save_ifs"
melunko@917
  1794
	arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
melunko@917
  1795
	;;
melunko@917
  1796
melunko@917
  1797
      -Wl,*)
melunko@917
  1798
	args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wl,//'`
melunko@917
  1799
	arg=
melunko@917
  1800
	save_ifs="$IFS"; IFS=','
melunko@917
  1801
	for flag in $args; do
melunko@917
  1802
	  IFS="$save_ifs"
melunko@917
  1803
	  case $flag in
melunko@917
  1804
	    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
melunko@917
  1805
	    flag="\"$flag\""
melunko@917
  1806
	    ;;
melunko@917
  1807
	  esac
melunko@917
  1808
	  arg="$arg $wl$flag"
melunko@917
  1809
	  compiler_flags="$compiler_flags $wl$flag"
melunko@917
  1810
	  linker_flags="$linker_flags $flag"
melunko@917
  1811
	done
melunko@917
  1812
	IFS="$save_ifs"
melunko@917
  1813
	arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
melunko@917
  1814
	;;
melunko@917
  1815
melunko@917
  1816
      -Xcompiler)
melunko@917
  1817
	prev=xcompiler
melunko@917
  1818
	continue
melunko@917
  1819
	;;
melunko@917
  1820
melunko@917
  1821
      -Xlinker)
melunko@917
  1822
	prev=xlinker
melunko@917
  1823
	continue
melunko@917
  1824
	;;
melunko@917
  1825
melunko@917
  1826
      -XCClinker)
melunko@917
  1827
	prev=xcclinker
melunko@917
  1828
	continue
melunko@917
  1829
	;;
melunko@917
  1830
melunko@917
  1831
      # Some other compiler flag.
melunko@917
  1832
      -* | +*)
melunko@917
  1833
	# Unknown arguments in both finalize_command and compile_command need
melunko@917
  1834
	# to be aesthetically quoted because they are evaled later.
melunko@917
  1835
	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
melunko@917
  1836
	case $arg in
melunko@917
  1837
	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
melunko@917
  1838
	  arg="\"$arg\""
melunko@917
  1839
	  ;;
melunko@917
  1840
	esac
melunko@917
  1841
	;;
melunko@917
  1842
melunko@917
  1843
      *.$objext)
melunko@917
  1844
	# A standard object.
melunko@917
  1845
	objs="$objs $arg"
melunko@917
  1846
	;;
melunko@917
  1847
melunko@917
  1848
      *.lo)
melunko@917
  1849
	# A libtool-controlled object.
melunko@917
  1850
melunko@917
  1851
	# Check to see that this really is a libtool object.
melunko@917
  1852
	if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
melunko@917
  1853
	  pic_object=
melunko@917
  1854
	  non_pic_object=
melunko@917
  1855
melunko@917
  1856
	  # Read the .lo file
melunko@917
  1857
	  # If there is no directory component, then add one.
melunko@917
  1858
	  case $arg in
melunko@917
  1859
	  */* | *\\*) . $arg ;;
melunko@917
  1860
	  *) . ./$arg ;;
melunko@917
  1861
	  esac
melunko@917
  1862
melunko@917
  1863
	  if test -z "$pic_object" || \
melunko@917
  1864
	     test -z "$non_pic_object" ||
melunko@917
  1865
	     test "$pic_object" = none && \
melunko@917
  1866
	     test "$non_pic_object" = none; then
melunko@917
  1867
	    $echo "$modename: cannot find name of object for \`$arg'" 1>&2
melunko@917
  1868
	    exit $EXIT_FAILURE
melunko@917
  1869
	  fi
melunko@917
  1870
melunko@917
  1871
	  # Extract subdirectory from the argument.
melunko@917
  1872
	  xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
melunko@917
  1873
	  if test "X$xdir" = "X$arg"; then
melunko@917
  1874
	    xdir=
melunko@917
  1875
 	  else
melunko@917
  1876
	    xdir="$xdir/"
melunko@917
  1877
	  fi
melunko@917
  1878
melunko@917
  1879
	  if test "$pic_object" != none; then
melunko@917
  1880
	    # Prepend the subdirectory the object is found in.
melunko@917
  1881
	    pic_object="$xdir$pic_object"
melunko@917
  1882
melunko@917
  1883
	    if test "$prev" = dlfiles; then
melunko@917
  1884
	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
melunko@917
  1885
		dlfiles="$dlfiles $pic_object"
melunko@917
  1886
		prev=
melunko@917
  1887
		continue
melunko@917
  1888
	      else
melunko@917
  1889
		# If libtool objects are unsupported, then we need to preload.
melunko@917
  1890
		prev=dlprefiles
melunko@917
  1891
	      fi
melunko@917
  1892
	    fi
melunko@917
  1893
melunko@917
  1894
	    # CHECK ME:  I think I busted this.  -Ossama
melunko@917
  1895
	    if test "$prev" = dlprefiles; then
melunko@917
  1896
	      # Preload the old-style object.
melunko@917
  1897
	      dlprefiles="$dlprefiles $pic_object"
melunko@917
  1898
	      prev=
melunko@917
  1899
	    fi
melunko@917
  1900
melunko@917
  1901
	    # A PIC object.
melunko@917
  1902
	    libobjs="$libobjs $pic_object"
melunko@917
  1903
	    arg="$pic_object"
melunko@917
  1904
	  fi
melunko@917
  1905
melunko@917
  1906
	  # Non-PIC object.
melunko@917
  1907
	  if test "$non_pic_object" != none; then
melunko@917
  1908
	    # Prepend the subdirectory the object is found in.
melunko@917
  1909
	    non_pic_object="$xdir$non_pic_object"
melunko@917
  1910
melunko@917
  1911
	    # A standard non-PIC object
melunko@917
  1912
	    non_pic_objects="$non_pic_objects $non_pic_object"
melunko@917
  1913
	    if test -z "$pic_object" || test "$pic_object" = none ; then
melunko@917
  1914
	      arg="$non_pic_object"
melunko@917
  1915
	    fi
melunko@917
  1916
	  else
melunko@917
  1917
	    # If the PIC object exists, use it instead.
melunko@917
  1918
	    # $xdir was prepended to $pic_object above.
melunko@917
  1919
	    non_pic_object="$pic_object"
melunko@917
  1920
	    non_pic_objects="$non_pic_objects $non_pic_object"
melunko@917
  1921
	  fi
melunko@917
  1922
	else
melunko@917
  1923
	  # Only an error if not doing a dry-run.
melunko@917
  1924
	  if test -z "$run"; then
melunko@917
  1925
	    $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
melunko@917
  1926
	    exit $EXIT_FAILURE
melunko@917
  1927
	  else
melunko@917
  1928
	    # Dry-run case.
melunko@917
  1929
melunko@917
  1930
	    # Extract subdirectory from the argument.
melunko@917
  1931
	    xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
melunko@917
  1932
	    if test "X$xdir" = "X$arg"; then
melunko@917
  1933
	      xdir=
melunko@917
  1934
	    else
melunko@917
  1935
	      xdir="$xdir/"
melunko@917
  1936
	    fi
melunko@917
  1937
melunko@917
  1938
	    pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
melunko@917
  1939
	    non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
melunko@917
  1940
	    libobjs="$libobjs $pic_object"
melunko@917
  1941
	    non_pic_objects="$non_pic_objects $non_pic_object"
melunko@917
  1942
	  fi
melunko@917
  1943
	fi
melunko@917
  1944
	;;
melunko@917
  1945
melunko@917
  1946
      *.$libext)
melunko@917
  1947
	# An archive.
melunko@917
  1948
	deplibs="$deplibs $arg"
melunko@917
  1949
	old_deplibs="$old_deplibs $arg"
melunko@917
  1950
	continue
melunko@917
  1951
	;;
melunko@917
  1952
melunko@917
  1953
      *.la)
melunko@917
  1954
	# A libtool-controlled library.
melunko@917
  1955
melunko@917
  1956
	if test "$prev" = dlfiles; then
melunko@917
  1957
	  # This library was specified with -dlopen.
melunko@917
  1958
	  dlfiles="$dlfiles $arg"
melunko@917
  1959
	  prev=
melunko@917
  1960
	elif test "$prev" = dlprefiles; then
melunko@917
  1961
	  # The library was specified with -dlpreopen.
melunko@917
  1962
	  dlprefiles="$dlprefiles $arg"
melunko@917
  1963
	  prev=
melunko@917
  1964
	else
melunko@917
  1965
	  deplibs="$deplibs $arg"
melunko@917
  1966
	fi
melunko@917
  1967
	continue
melunko@917
  1968
	;;
melunko@917
  1969
melunko@917
  1970
      # Some other compiler argument.
melunko@917
  1971
      *)
melunko@917
  1972
	# Unknown arguments in both finalize_command and compile_command need
melunko@917
  1973
	# to be aesthetically quoted because they are evaled later.
melunko@917
  1974
	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
melunko@917
  1975
	case $arg in
melunko@917
  1976
	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
melunko@917
  1977
	  arg="\"$arg\""
melunko@917
  1978
	  ;;
melunko@917
  1979
	esac
melunko@917
  1980
	;;
melunko@917
  1981
      esac # arg
melunko@917
  1982
melunko@917
  1983
      # Now actually substitute the argument into the commands.
melunko@917
  1984
      if test -n "$arg"; then
melunko@917
  1985
	compile_command="$compile_command $arg"
melunko@917
  1986
	finalize_command="$finalize_command $arg"
melunko@917
  1987
      fi
melunko@917
  1988
    done # argument parsing loop
melunko@917
  1989
melunko@917
  1990
    if test -n "$prev"; then
melunko@917
  1991
      $echo "$modename: the \`$prevarg' option requires an argument" 1>&2
melunko@917
  1992
      $echo "$help" 1>&2
melunko@917
  1993
      exit $EXIT_FAILURE
melunko@917
  1994
    fi
melunko@917
  1995
melunko@917
  1996
    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
melunko@917
  1997
      eval arg=\"$export_dynamic_flag_spec\"
melunko@917
  1998
      compile_command="$compile_command $arg"
melunko@917
  1999
      finalize_command="$finalize_command $arg"
melunko@917
  2000
    fi
melunko@917
  2001
melunko@917
  2002
    oldlibs=
melunko@917
  2003
    # calculate the name of the file, without its directory
melunko@917
  2004
    outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'`
melunko@917
  2005
    libobjs_save="$libobjs"
melunko@917
  2006
melunko@917
  2007
    if test -n "$shlibpath_var"; then
melunko@917
  2008
      # get the directories listed in $shlibpath_var
melunko@917
  2009
      eval shlib_search_path=\`\$echo \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\`
melunko@917
  2010
    else
melunko@917
  2011
      shlib_search_path=
melunko@917
  2012
    fi
melunko@917
  2013
    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
melunko@917
  2014
    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
melunko@917
  2015
melunko@917
  2016
    output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'`
melunko@917
  2017
    if test "X$output_objdir" = "X$output"; then
melunko@917
  2018
      output_objdir="$objdir"
melunko@917
  2019
    else
melunko@917
  2020
      output_objdir="$output_objdir/$objdir"
melunko@917
  2021
    fi
melunko@917
  2022
    # Create the object directory.
melunko@917
  2023
    if test ! -d "$output_objdir"; then
melunko@917
  2024
      $show "$mkdir $output_objdir"
melunko@917
  2025
      $run $mkdir $output_objdir
melunko@917
  2026
      exit_status=$?
melunko@917
  2027
      if test "$exit_status" -ne 0 && test ! -d "$output_objdir"; then
melunko@917
  2028
	exit $exit_status
melunko@917
  2029
      fi
melunko@917
  2030
    fi
melunko@917
  2031
melunko@917
  2032
    # Determine the type of output
melunko@917
  2033
    case $output in
melunko@917
  2034
    "")
melunko@917
  2035
      $echo "$modename: you must specify an output file" 1>&2
melunko@917
  2036
      $echo "$help" 1>&2
melunko@917
  2037
      exit $EXIT_FAILURE
melunko@917
  2038
      ;;
melunko@917
  2039
    *.$libext) linkmode=oldlib ;;
melunko@917
  2040
    *.lo | *.$objext) linkmode=obj ;;
melunko@917
  2041
    *.la) linkmode=lib ;;
melunko@917
  2042
    *) linkmode=prog ;; # Anything else should be a program.
melunko@917
  2043
    esac
melunko@917
  2044
melunko@917
  2045
    case $host in
melunko@917
  2046
    *cygwin* | *mingw* | *pw32*)
melunko@917
  2047
      # don't eliminate duplications in $postdeps and $predeps
melunko@917
  2048
      duplicate_compiler_generated_deps=yes
melunko@917
  2049
      ;;
melunko@917
  2050
    *)
melunko@917
  2051
      duplicate_compiler_generated_deps=$duplicate_deps
melunko@917
  2052
      ;;
melunko@917
  2053
    esac
melunko@917
  2054
    specialdeplibs=
melunko@917
  2055
melunko@917
  2056
    libs=
melunko@917
  2057
    # Find all interdependent deplibs by searching for libraries
melunko@917
  2058
    # that are linked more than once (e.g. -la -lb -la)
melunko@917
  2059
    for deplib in $deplibs; do
melunko@917
  2060
      if test "X$duplicate_deps" = "Xyes" ; then
melunko@917
  2061
	case "$libs " in
melunko@917
  2062
	*" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
melunko@917
  2063
	esac
melunko@917
  2064
      fi
melunko@917
  2065
      libs="$libs $deplib"
melunko@917
  2066
    done
melunko@917
  2067
melunko@917
  2068
    if test "$linkmode" = lib; then
melunko@917
  2069
      libs="$predeps $libs $compiler_lib_search_path $postdeps"
melunko@917
  2070
melunko@917
  2071
      # Compute libraries that are listed more than once in $predeps
melunko@917
  2072
      # $postdeps and mark them as special (i.e., whose duplicates are
melunko@917
  2073
      # not to be eliminated).
melunko@917
  2074
      pre_post_deps=
melunko@917
  2075
      if test "X$duplicate_compiler_generated_deps" = "Xyes" ; then
melunko@917
  2076
	for pre_post_dep in $predeps $postdeps; do
melunko@917
  2077
	  case "$pre_post_deps " in
melunko@917
  2078
	  *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
melunko@917
  2079
	  esac
melunko@917
  2080
	  pre_post_deps="$pre_post_deps $pre_post_dep"
melunko@917
  2081
	done
melunko@917
  2082
      fi
melunko@917
  2083
      pre_post_deps=
melunko@917
  2084
    fi
melunko@917
  2085
melunko@917
  2086
    deplibs=
melunko@917
  2087
    newdependency_libs=
melunko@917
  2088
    newlib_search_path=
melunko@917
  2089
    need_relink=no # whether we're linking any uninstalled libtool libraries
melunko@917
  2090
    notinst_deplibs= # not-installed libtool libraries
melunko@917
  2091
    case $linkmode in
melunko@917
  2092
    lib)
melunko@917
  2093
	passes="conv link"
melunko@917
  2094
	for file in $dlfiles $dlprefiles; do
melunko@917
  2095
	  case $file in
melunko@917
  2096
	  *.la) ;;
melunko@917
  2097
	  *)
melunko@917
  2098
	    $echo "$modename: libraries can \`-dlopen' only libtool libraries: $file" 1>&2
melunko@917
  2099
	    exit $EXIT_FAILURE
melunko@917
  2100
	    ;;
melunko@917
  2101
	  esac
melunko@917
  2102
	done
melunko@917
  2103
	;;
melunko@917
  2104
    prog)
melunko@917
  2105
	compile_deplibs=
melunko@917
  2106
	finalize_deplibs=
melunko@917
  2107
	alldeplibs=no
melunko@917
  2108
	newdlfiles=
melunko@917
  2109
	newdlprefiles=
melunko@917
  2110
	passes="conv scan dlopen dlpreopen link"
melunko@917
  2111
	;;
melunko@917
  2112
    *)  passes="conv"
melunko@917
  2113
	;;
melunko@917
  2114
    esac
melunko@917
  2115
    for pass in $passes; do
melunko@917
  2116
      if test "$linkmode,$pass" = "lib,link" ||
melunko@917
  2117
	 test "$linkmode,$pass" = "prog,scan"; then
melunko@917
  2118
	libs="$deplibs"
melunko@917
  2119
	deplibs=
melunko@917
  2120
      fi
melunko@917
  2121
      if test "$linkmode" = prog; then
melunko@917
  2122
	case $pass in
melunko@917
  2123
	dlopen) libs="$dlfiles" ;;
melunko@917
  2124
	dlpreopen) libs="$dlprefiles" ;;
melunko@917
  2125
	link)
melunko@917
  2126
	  libs="$deplibs %DEPLIBS%"
melunko@917
  2127
	  test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs"
melunko@917
  2128
	  ;;
melunko@917
  2129
	esac
melunko@917
  2130
      fi
melunko@917
  2131
      if test "$pass" = dlopen; then
melunko@917
  2132
	# Collect dlpreopened libraries
melunko@917
  2133
	save_deplibs="$deplibs"
melunko@917
  2134
	deplibs=
melunko@917
  2135
      fi
melunko@917
  2136
      for deplib in $libs; do
melunko@917
  2137
	lib=
melunko@917
  2138
	found=no
melunko@917
  2139
	case $deplib in
melunko@917
  2140
	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
melunko@917
  2141
	  if test "$linkmode,$pass" = "prog,link"; then
melunko@917
  2142
	    compile_deplibs="$deplib $compile_deplibs"
melunko@917
  2143
	    finalize_deplibs="$deplib $finalize_deplibs"
melunko@917
  2144
	  else
melunko@917
  2145
	    compiler_flags="$compiler_flags $deplib"
melunko@917
  2146
	  fi
melunko@917
  2147
	  continue
melunko@917
  2148
	  ;;
melunko@917
  2149
	-l*)
melunko@917
  2150
	  if test "$linkmode" != lib && test "$linkmode" != prog; then
melunko@917
  2151
	    $echo "$modename: warning: \`-l' is ignored for archives/objects" 1>&2
melunko@917
  2152
	    continue
melunko@917
  2153
	  fi
melunko@917
  2154
	  name=`$echo "X$deplib" | $Xsed -e 's/^-l//'`
melunko@917
  2155
	  for searchdir in $newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path; do
melunko@917
  2156
	    for search_ext in .la $std_shrext .so .a; do
melunko@917
  2157
	      # Search the libtool library
melunko@917
  2158
	      lib="$searchdir/lib${name}${search_ext}"
melunko@917
  2159
	      if test -f "$lib"; then
melunko@917
  2160
		if test "$search_ext" = ".la"; then
melunko@917
  2161
		  found=yes
melunko@917
  2162
		else
melunko@917
  2163
		  found=no
melunko@917
  2164
		fi
melunko@917
  2165
		break 2
melunko@917
  2166
	      fi
melunko@917
  2167
	    done
melunko@917
  2168
	  done
melunko@917
  2169
	  if test "$found" != yes; then
melunko@917
  2170
	    # deplib doesn't seem to be a libtool library
melunko@917
  2171
	    if test "$linkmode,$pass" = "prog,link"; then
melunko@917
  2172
	      compile_deplibs="$deplib $compile_deplibs"
melunko@917
  2173
	      finalize_deplibs="$deplib $finalize_deplibs"
melunko@917
  2174
	    else
melunko@917
  2175
	      deplibs="$deplib $deplibs"
melunko@917
  2176
	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
melunko@917
  2177
	    fi
melunko@917
  2178
	    continue
melunko@917
  2179
	  else # deplib is a libtool library
melunko@917
  2180
	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
melunko@917
  2181
	    # We need to do some special things here, and not later.
melunko@917
  2182
	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
melunko@917
  2183
	      case " $predeps $postdeps " in
melunko@917
  2184
	      *" $deplib "*)
melunko@917
  2185
		if (${SED} -e '2q' $lib |
melunko@917
  2186
                    grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
melunko@917
  2187
		  library_names=
melunko@917
  2188
		  old_library=
melunko@917
  2189
		  case $lib in
melunko@917
  2190
		  */* | *\\*) . $lib ;;
melunko@917
  2191
		  *) . ./$lib ;;
melunko@917
  2192
		  esac
melunko@917
  2193
		  for l in $old_library $library_names; do
melunko@917
  2194
		    ll="$l"
melunko@917
  2195
		  done
melunko@917
  2196
		  if test "X$ll" = "X$old_library" ; then # only static version available
melunko@917
  2197
		    found=no
melunko@917
  2198
		    ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
melunko@917
  2199
		    test "X$ladir" = "X$lib" && ladir="."
melunko@917
  2200
		    lib=$ladir/$old_library
melunko@917
  2201
		    if test "$linkmode,$pass" = "prog,link"; then
melunko@917
  2202
		      compile_deplibs="$deplib $compile_deplibs"
melunko@917
  2203
		      finalize_deplibs="$deplib $finalize_deplibs"
melunko@917
  2204
		    else
melunko@917
  2205
		      deplibs="$deplib $deplibs"
melunko@917
  2206
		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
melunko@917
  2207
		    fi
melunko@917
  2208
		    continue
melunko@917
  2209
		  fi
melunko@917
  2210
		fi
melunko@917
  2211
	        ;;
melunko@917
  2212
	      *) ;;
melunko@917
  2213
	      esac
melunko@917
  2214
	    fi
melunko@917
  2215
	  fi
melunko@917
  2216
	  ;; # -l
melunko@917
  2217
	-L*)
melunko@917
  2218
	  case $linkmode in
melunko@917
  2219
	  lib)
melunko@917
  2220
	    deplibs="$deplib $deplibs"
melunko@917
  2221
	    test "$pass" = conv && continue
melunko@917
  2222
	    newdependency_libs="$deplib $newdependency_libs"
melunko@917
  2223
	    newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
melunko@917
  2224
	    ;;
melunko@917
  2225
	  prog)
melunko@917
  2226
	    if test "$pass" = conv; then
melunko@917
  2227
	      deplibs="$deplib $deplibs"
melunko@917
  2228
	      continue
melunko@917
  2229
	    fi
melunko@917
  2230
	    if test "$pass" = scan; then
melunko@917
  2231
	      deplibs="$deplib $deplibs"
melunko@917
  2232
	    else
melunko@917
  2233
	      compile_deplibs="$deplib $compile_deplibs"
melunko@917
  2234
	      finalize_deplibs="$deplib $finalize_deplibs"
melunko@917
  2235
	    fi
melunko@917
  2236
	    newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
melunko@917
  2237
	    ;;
melunko@917
  2238
	  *)
melunko@917
  2239
	    $echo "$modename: warning: \`-L' is ignored for archives/objects" 1>&2
melunko@917
  2240
	    ;;
melunko@917
  2241
	  esac # linkmode
melunko@917
  2242
	  continue
melunko@917
  2243
	  ;; # -L
melunko@917
  2244
	-R*)
melunko@917
  2245
	  if test "$pass" = link; then
melunko@917
  2246
	    dir=`$echo "X$deplib" | $Xsed -e 's/^-R//'`
melunko@917
  2247
	    # Make sure the xrpath contains only unique directories.
melunko@917
  2248
	    case "$xrpath " in
melunko@917
  2249
	    *" $dir "*) ;;
melunko@917
  2250
	    *) xrpath="$xrpath $dir" ;;
melunko@917
  2251
	    esac
melunko@917
  2252
	  fi
melunko@917
  2253
	  deplibs="$deplib $deplibs"
melunko@917
  2254
	  continue
melunko@917
  2255
	  ;;
melunko@917
  2256
	*.la) lib="$deplib" ;;
melunko@917
  2257
	*.$libext)
melunko@917
  2258
	  if test "$pass" = conv; then
melunko@917
  2259
	    deplibs="$deplib $deplibs"
melunko@917
  2260
	    continue
melunko@917
  2261
	  fi
melunko@917
  2262
	  case $linkmode in
melunko@917
  2263
	  lib)
melunko@917
  2264
	    valid_a_lib=no
melunko@917
  2265
	    case $deplibs_check_method in
melunko@917
  2266
	      match_pattern*)
melunko@917
  2267
		set dummy $deplibs_check_method
melunko@917
  2268
	        match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
melunko@917
  2269
		if eval $echo \"$deplib\" 2>/dev/null \
melunko@917
  2270
		    | $SED 10q \
melunko@917
  2271
		    | $EGREP "$match_pattern_regex" > /dev/null; then
melunko@917
  2272
		  valid_a_lib=yes
melunko@917
  2273
		fi
melunko@917
  2274
		;;
melunko@917
  2275
	      pass_all)
melunko@917
  2276
		valid_a_lib=yes
melunko@917
  2277
		;;
melunko@917
  2278
            esac
melunko@917
  2279
	    if test "$valid_a_lib" != yes; then
melunko@917
  2280
	      $echo
melunko@917
  2281
	      $echo "*** Warning: Trying to link with static lib archive $deplib."
melunko@917
  2282
	      $echo "*** I have the capability to make that library automatically link in when"
melunko@917
  2283
	      $echo "*** you link to this library.  But I can only do this if you have a"
melunko@917
  2284
	      $echo "*** shared version of the library, which you do not appear to have"
melunko@917
  2285
	      $echo "*** because the file extensions .$libext of this argument makes me believe"
melunko@917
  2286
	      $echo "*** that it is just a static archive that I should not used here."
melunko@917
  2287
	    else
melunko@917
  2288
	      $echo
melunko@917
  2289
	      $echo "*** Warning: Linking the shared library $output against the"
melunko@917
  2290
	      $echo "*** static library $deplib is not portable!"
melunko@917
  2291
	      deplibs="$deplib $deplibs"
melunko@917
  2292
	    fi
melunko@917
  2293
	    continue
melunko@917
  2294
	    ;;
melunko@917
  2295
	  prog)
melunko@917
  2296
	    if test "$pass" != link; then
melunko@917
  2297
	      deplibs="$deplib $deplibs"
melunko@917
  2298
	    else
melunko@917
  2299
	      compile_deplibs="$deplib $compile_deplibs"
melunko@917
  2300
	      finalize_deplibs="$deplib $finalize_deplibs"
melunko@917
  2301
	    fi
melunko@917
  2302
	    continue
melunko@917
  2303
	    ;;
melunko@917
  2304
	  esac # linkmode
melunko@917
  2305
	  ;; # *.$libext
melunko@917
  2306
	*.lo | *.$objext)
melunko@917
  2307
	  if test "$pass" = conv; then
melunko@917
  2308
	    deplibs="$deplib $deplibs"
melunko@917
  2309
	  elif test "$linkmode" = prog; then
melunko@917
  2310
	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
melunko@917
  2311
	      # If there is no dlopen support or we're linking statically,
melunko@917
  2312
	      # we need to preload.
melunko@917
  2313
	      newdlprefiles="$newdlprefiles $deplib"
melunko@917
  2314
	      compile_deplibs="$deplib $compile_deplibs"
melunko@917
  2315
	      finalize_deplibs="$deplib $finalize_deplibs"
melunko@917
  2316
	    else
melunko@917
  2317
	      newdlfiles="$newdlfiles $deplib"
melunko@917
  2318
	    fi
melunko@917
  2319
	  fi
melunko@917
  2320
	  continue
melunko@917
  2321
	  ;;
melunko@917
  2322
	%DEPLIBS%)
melunko@917
  2323
	  alldeplibs=yes
melunko@917
  2324
	  continue
melunko@917
  2325
	  ;;
melunko@917
  2326
	esac # case $deplib
melunko@917
  2327
	if test "$found" = yes || test -f "$lib"; then :
melunko@917
  2328
	else
melunko@917
  2329
	  $echo "$modename: cannot find the library \`$lib' or unhandled argument \`$deplib'" 1>&2
melunko@917
  2330
	  exit $EXIT_FAILURE
melunko@917
  2331
	fi
melunko@917
  2332
melunko@917
  2333
	# Check to see that this really is a libtool archive.
melunko@917
  2334
	if (${SED} -e '2q' $lib | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
melunko@917
  2335
	else
melunko@917
  2336
	  $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
melunko@917
  2337
	  exit $EXIT_FAILURE
melunko@917
  2338
	fi
melunko@917
  2339
melunko@917
  2340
	ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
melunko@917
  2341
	test "X$ladir" = "X$lib" && ladir="."
melunko@917
  2342
melunko@917
  2343
	dlname=
melunko@917
  2344
	dlopen=
melunko@917
  2345
	dlpreopen=
melunko@917
  2346
	libdir=
melunko@917
  2347
	library_names=
melunko@917
  2348
	old_library=
melunko@917
  2349
	# If the library was installed with an old release of libtool,
melunko@917
  2350
	# it will not redefine variables installed, or shouldnotlink
melunko@917
  2351
	installed=yes
melunko@917
  2352
	shouldnotlink=no
melunko@917
  2353
	avoidtemprpath=
melunko@917
  2354
melunko@917
  2355
melunko@917
  2356
	# Read the .la file
melunko@917
  2357
	case $lib in
melunko@917
  2358
	*/* | *\\*) . $lib ;;
melunko@917
  2359
	*) . ./$lib ;;
melunko@917
  2360
	esac
melunko@917
  2361
melunko@917
  2362
	if test "$linkmode,$pass" = "lib,link" ||
melunko@917
  2363
	   test "$linkmode,$pass" = "prog,scan" ||
melunko@917
  2364
	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
melunko@917
  2365
	  test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
melunko@917
  2366
	  test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
melunko@917
  2367
	fi
melunko@917
  2368
melunko@917
  2369
	if test "$pass" = conv; then
melunko@917
  2370
	  # Only check for convenience libraries
melunko@917
  2371
	  deplibs="$lib $deplibs"
melunko@917
  2372
	  if test -z "$libdir"; then
melunko@917
  2373
	    if test -z "$old_library"; then
melunko@917
  2374
	      $echo "$modename: cannot find name of link library for \`$lib'" 1>&2
melunko@917
  2375
	      exit $EXIT_FAILURE
melunko@917
  2376
	    fi
melunko@917
  2377
	    # It is a libtool convenience library, so add in its objects.
melunko@917
  2378
	    convenience="$convenience $ladir/$objdir/$old_library"
melunko@917
  2379
	    old_convenience="$old_convenience $ladir/$objdir/$old_library"
melunko@917
  2380
	    tmp_libs=
melunko@917
  2381
	    for deplib in $dependency_libs; do
melunko@917
  2382
	      deplibs="$deplib $deplibs"
melunko@917
  2383
              if test "X$duplicate_deps" = "Xyes" ; then
melunko@917
  2384
	        case "$tmp_libs " in
melunko@917
  2385
	        *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
melunko@917
  2386
	        esac
melunko@917
  2387
              fi
melunko@917
  2388
	      tmp_libs="$tmp_libs $deplib"
melunko@917
  2389
	    done
melunko@917
  2390
	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
melunko@917
  2391
	    $echo "$modename: \`$lib' is not a convenience library" 1>&2
melunko@917
  2392
	    exit $EXIT_FAILURE
melunko@917
  2393
	  fi
melunko@917
  2394
	  continue
melunko@917
  2395
	fi # $pass = conv
melunko@917
  2396
melunko@917
  2397
melunko@917
  2398
	# Get the name of the library we link against.
melunko@917
  2399
	linklib=
melunko@917
  2400
	for l in $old_library $library_names; do
melunko@917
  2401
	  linklib="$l"
melunko@917
  2402
	done
melunko@917
  2403
	if test -z "$linklib"; then
melunko@917
  2404
	  $echo "$modename: cannot find name of link library for \`$lib'" 1>&2
melunko@917
  2405
	  exit $EXIT_FAILURE
melunko@917
  2406
	fi
melunko@917
  2407
melunko@917
  2408
	# This library was specified with -dlopen.
melunko@917
  2409
	if test "$pass" = dlopen; then
melunko@917
  2410
	  if test -z "$libdir"; then
melunko@917
  2411
	    $echo "$modename: cannot -dlopen a convenience library: \`$lib'" 1>&2
melunko@917
  2412
	    exit $EXIT_FAILURE
melunko@917
  2413
	  fi
melunko@917
  2414
	  if test -z "$dlname" ||
melunko@917
  2415
	     test "$dlopen_support" != yes ||
melunko@917
  2416
	     test "$build_libtool_libs" = no; then
melunko@917
  2417
	    # If there is no dlname, no dlopen support or we're linking
melunko@917
  2418
	    # statically, we need to preload.  We also need to preload any
melunko@917
  2419
	    # dependent libraries so libltdl's deplib preloader doesn't
melunko@917
  2420
	    # bomb out in the load deplibs phase.
melunko@917
  2421
	    dlprefiles="$dlprefiles $lib $dependency_libs"
melunko@917
  2422
	  else
melunko@917
  2423
	    newdlfiles="$newdlfiles $lib"
melunko@917
  2424
	  fi
melunko@917
  2425
	  continue
melunko@917
  2426
	fi # $pass = dlopen
melunko@917
  2427
melunko@917
  2428
	# We need an absolute path.
melunko@917
  2429
	case $ladir in
melunko@917
  2430
	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
melunko@917
  2431
	*)
melunko@917
  2432
	  abs_ladir=`cd "$ladir" && pwd`
melunko@917
  2433
	  if test -z "$abs_ladir"; then
melunko@917
  2434
	    $echo "$modename: warning: cannot determine absolute directory name of \`$ladir'" 1>&2
melunko@917
  2435
	    $echo "$modename: passing it literally to the linker, although it might fail" 1>&2
melunko@917
  2436
	    abs_ladir="$ladir"
melunko@917
  2437
	  fi
melunko@917
  2438
	  ;;
melunko@917
  2439
	esac
melunko@917
  2440
	laname=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
melunko@917
  2441
melunko@917
  2442
	# Find the relevant object directory and library name.
melunko@917
  2443
	if test "X$installed" = Xyes; then
melunko@917
  2444
	  if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
melunko@917
  2445
	    $echo "$modename: warning: library \`$lib' was moved." 1>&2
melunko@917
  2446
	    dir="$ladir"
melunko@917
  2447
	    absdir="$abs_ladir"
melunko@917
  2448
	    libdir="$abs_ladir"
melunko@917
  2449
	  else
melunko@917
  2450
	    dir="$libdir"
melunko@917
  2451
	    absdir="$libdir"
melunko@917
  2452
	  fi
melunko@917
  2453
	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
melunko@917
  2454
	else
melunko@917
  2455
	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
melunko@917
  2456
	    dir="$ladir"
melunko@917
  2457
	    absdir="$abs_ladir"
melunko@917
  2458
	    # Remove this search path later
melunko@917
  2459
	    notinst_path="$notinst_path $abs_ladir"
melunko@917
  2460
	  else
melunko@917
  2461
	    dir="$ladir/$objdir"
melunko@917
  2462
	    absdir="$abs_ladir/$objdir"
melunko@917
  2463
	    # Remove this search path later
melunko@917
  2464
	    notinst_path="$notinst_path $abs_ladir"
melunko@917
  2465
	  fi
melunko@917
  2466
	fi # $installed = yes
melunko@917
  2467
	name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
melunko@917
  2468
melunko@917
  2469
	# This library was specified with -dlpreopen.
melunko@917
  2470
	if test "$pass" = dlpreopen; then
melunko@917
  2471
	  if test -z "$libdir"; then
melunko@917
  2472
	    $echo "$modename: cannot -dlpreopen a convenience library: \`$lib'" 1>&2
melunko@917
  2473
	    exit $EXIT_FAILURE
melunko@917
  2474
	  fi
melunko@917
  2475
	  # Prefer using a static library (so that no silly _DYNAMIC symbols
melunko@917
  2476
	  # are required to link).
melunko@917
  2477
	  if test -n "$old_library"; then
melunko@917
  2478
	    newdlprefiles="$newdlprefiles $dir/$old_library"
melunko@917
  2479
	  # Otherwise, use the dlname, so that lt_dlopen finds it.
melunko@917
  2480
	  elif test -n "$dlname"; then
melunko@917
  2481
	    newdlprefiles="$newdlprefiles $dir/$dlname"
melunko@917
  2482
	  else
melunko@917
  2483
	    newdlprefiles="$newdlprefiles $dir/$linklib"
melunko@917
  2484
	  fi
melunko@917
  2485
	fi # $pass = dlpreopen
melunko@917
  2486
melunko@917
  2487
	if test -z "$libdir"; then
melunko@917
  2488
	  # Link the convenience library
melunko@917
  2489
	  if test "$linkmode" = lib; then
melunko@917
  2490
	    deplibs="$dir/$old_library $deplibs"
melunko@917
  2491
	  elif test "$linkmode,$pass" = "prog,link"; then
melunko@917
  2492
	    compile_deplibs="$dir/$old_library $compile_deplibs"
melunko@917
  2493
	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
melunko@917
  2494
	  else
melunko@917
  2495
	    deplibs="$lib $deplibs" # used for prog,scan pass
melunko@917
  2496
	  fi
melunko@917
  2497
	  continue
melunko@917
  2498
	fi
melunko@917
  2499
melunko@917
  2500
melunko@917
  2501
	if test "$linkmode" = prog && test "$pass" != link; then
melunko@917
  2502
	  newlib_search_path="$newlib_search_path $ladir"
melunko@917
  2503
	  deplibs="$lib $deplibs"
melunko@917
  2504
melunko@917
  2505
	  linkalldeplibs=no
melunko@917
  2506
	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
melunko@917
  2507
	     test "$build_libtool_libs" = no; then
melunko@917
  2508
	    linkalldeplibs=yes
melunko@917
  2509
	  fi
melunko@917
  2510
melunko@917
  2511
	  tmp_libs=
melunko@917
  2512
	  for deplib in $dependency_libs; do
melunko@917
  2513
	    case $deplib in
melunko@917
  2514
	    -L*) newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`;; ### testsuite: skip nested quoting test
melunko@917
  2515
	    esac
melunko@917
  2516
	    # Need to link against all dependency_libs?
melunko@917
  2517
	    if test "$linkalldeplibs" = yes; then
melunko@917
  2518
	      deplibs="$deplib $deplibs"
melunko@917
  2519
	    else
melunko@917
  2520
	      # Need to hardcode shared library paths
melunko@917
  2521
	      # or/and link against static libraries
melunko@917
  2522
	      newdependency_libs="$deplib $newdependency_libs"
melunko@917
  2523
	    fi
melunko@917
  2524
	    if test "X$duplicate_deps" = "Xyes" ; then
melunko@917
  2525
	      case "$tmp_libs " in
melunko@917
  2526
	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
melunko@917
  2527
	      esac
melunko@917
  2528
	    fi
melunko@917
  2529
	    tmp_libs="$tmp_libs $deplib"
melunko@917
  2530
	  done # for deplib
melunko@917
  2531
	  continue
melunko@917
  2532
	fi # $linkmode = prog...
melunko@917
  2533
melunko@917
  2534
	if test "$linkmode,$pass" = "prog,link"; then
melunko@917
  2535
	  if test -n "$library_names" &&
melunko@917
  2536
	     { { test "$prefer_static_libs" = no ||
melunko@917
  2537
		 test "$prefer_static_libs,$installed" = "built,yes"; } ||
melunko@917
  2538
	       test -z "$old_library"; }; then
melunko@917
  2539
	    # We need to hardcode the library path
melunko@917
  2540
	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
melunko@917
  2541
	      # Make sure the rpath contains only unique directories.
melunko@917
  2542
	      case "$temp_rpath " in
melunko@917
  2543
	      *" $dir "*) ;;
melunko@917
  2544
	      *" $absdir "*) ;;
melunko@917
  2545
	      *) temp_rpath="$temp_rpath $absdir" ;;
melunko@917
  2546
	      esac
melunko@917
  2547
	    fi
melunko@917
  2548
melunko@917
  2549
	    # Hardcode the library path.
melunko@917
  2550
	    # Skip directories that are in the system default run-time
melunko@917
  2551
	    # search path.
melunko@917
  2552
	    case " $sys_lib_dlsearch_path " in
melunko@917
  2553
	    *" $absdir "*) ;;
melunko@917
  2554
	    *)
melunko@917
  2555
	      case "$compile_rpath " in
melunko@917
  2556
	      *" $absdir "*) ;;
melunko@917
  2557
	      *) compile_rpath="$compile_rpath $absdir"
melunko@917
  2558
	      esac
melunko@917
  2559
	      ;;
melunko@917
  2560
	    esac
melunko@917
  2561
	    case " $sys_lib_dlsearch_path " in
melunko@917
  2562
	    *" $libdir "*) ;;
melunko@917
  2563
	    *)
melunko@917
  2564
	      case "$finalize_rpath " in
melunko@917
  2565
	      *" $libdir "*) ;;
melunko@917
  2566
	      *) finalize_rpath="$finalize_rpath $libdir"
melunko@917
  2567
	      esac
melunko@917
  2568
	      ;;
melunko@917
  2569
	    esac
melunko@917
  2570
	  fi # $linkmode,$pass = prog,link...
melunko@917
  2571
melunko@917
  2572
	  if test "$alldeplibs" = yes &&
melunko@917
  2573
	     { test "$deplibs_check_method" = pass_all ||
melunko@917
  2574
	       { test "$build_libtool_libs" = yes &&
melunko@917
  2575
		 test -n "$library_names"; }; }; then
melunko@917
  2576
	    # We only need to search for static libraries
melunko@917
  2577
	    continue
melunko@917
  2578
	  fi
melunko@917
  2579
	fi
melunko@917
  2580
melunko@917
  2581
	link_static=no # Whether the deplib will be linked statically
melunko@917
  2582
	use_static_libs=$prefer_static_libs
melunko@917
  2583
	if test "$use_static_libs" = built && test "$installed" = yes ; then
melunko@917
  2584
	  use_static_libs=no
melunko@917
  2585
	fi
melunko@917
  2586
	if test -n "$library_names" &&
melunko@917
  2587
	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
melunko@917
  2588
	  if test "$installed" = no; then
melunko@917
  2589
	    notinst_deplibs="$notinst_deplibs $lib"
melunko@917
  2590
	    need_relink=yes
melunko@917
  2591
	  fi
melunko@917
  2592
	  # This is a shared library
melunko@917
  2593
melunko@917
  2594
	  # Warn about portability, can't link against -module's on
melunko@917
  2595
	  # some systems (darwin)
melunko@917
  2596
	  if test "$shouldnotlink" = yes && test "$pass" = link ; then
melunko@917
  2597
	    $echo
melunko@917
  2598
	    if test "$linkmode" = prog; then
melunko@917
  2599
	      $echo "*** Warning: Linking the executable $output against the loadable module"
melunko@917
  2600
	    else
melunko@917
  2601
	      $echo "*** Warning: Linking the shared library $output against the loadable module"
melunko@917
  2602
	    fi
melunko@917
  2603
	    $echo "*** $linklib is not portable!"
melunko@917
  2604
	  fi
melunko@917
  2605
	  if test "$linkmode" = lib &&
melunko@917
  2606
	     test "$hardcode_into_libs" = yes; then
melunko@917
  2607
	    # Hardcode the library path.
melunko@917
  2608
	    # Skip directories that are in the system default run-time
melunko@917
  2609
	    # search path.
melunko@917
  2610
	    case " $sys_lib_dlsearch_path " in
melunko@917
  2611
	    *" $absdir "*) ;;
melunko@917
  2612
	    *)
melunko@917
  2613
	      case "$compile_rpath " in
melunko@917
  2614
	      *" $absdir "*) ;;
melunko@917
  2615
	      *) compile_rpath="$compile_rpath $absdir"
melunko@917
  2616
	      esac
melunko@917
  2617
	      ;;
melunko@917
  2618
	    esac
melunko@917
  2619
	    case " $sys_lib_dlsearch_path " in
melunko@917
  2620
	    *" $libdir "*) ;;
melunko@917
  2621
	    *)
melunko@917
  2622
	      case "$finalize_rpath " in
melunko@917
  2623
	      *" $libdir "*) ;;
melunko@917
  2624
	      *) finalize_rpath="$finalize_rpath $libdir"
melunko@917
  2625
	      esac
melunko@917
  2626
	      ;;
melunko@917
  2627
	    esac
melunko@917
  2628
	  fi
melunko@917
  2629
melunko@917
  2630
	  if test -n "$old_archive_from_expsyms_cmds"; then
melunko@917
  2631
	    # figure out the soname
melunko@917
  2632
	    set dummy $library_names
melunko@917
  2633
	    realname="$2"
melunko@917
  2634
	    shift; shift
melunko@917
  2635
	    libname=`eval \\$echo \"$libname_spec\"`
melunko@917
  2636
	    # use dlname if we got it. it's perfectly good, no?
melunko@917
  2637
	    if test -n "$dlname"; then
melunko@917
  2638
	      soname="$dlname"
melunko@917
  2639
	    elif test -n "$soname_spec"; then
melunko@917
  2640
	      # bleh windows
melunko@917
  2641
	      case $host in
melunko@917
  2642
	      *cygwin* | mingw*)
melunko@917
  2643
		major=`expr $current - $age`
melunko@917
  2644
		versuffix="-$major"
melunko@917
  2645
		;;
melunko@917
  2646
	      esac
melunko@917
  2647
	      eval soname=\"$soname_spec\"
melunko@917
  2648
	    else
melunko@917
  2649
	      soname="$realname"
melunko@917
  2650
	    fi
melunko@917
  2651
melunko@917
  2652
	    # Make a new name for the extract_expsyms_cmds to use
melunko@917
  2653
	    soroot="$soname"
melunko@917
  2654
	    soname=`$echo $soroot | ${SED} -e 's/^.*\///'`
melunko@917
  2655
	    newlib="libimp-`$echo $soname | ${SED} 's/^lib//;s/\.dll$//'`.a"
melunko@917
  2656
melunko@917
  2657
	    # If the library has no export list, then create one now
melunko@917
  2658
	    if test -f "$output_objdir/$soname-def"; then :
melunko@917
  2659
	    else
melunko@917
  2660
	      $show "extracting exported symbol list from \`$soname'"
melunko@917
  2661
	      save_ifs="$IFS"; IFS='~'
melunko@917
  2662
	      cmds=$extract_expsyms_cmds
melunko@917
  2663
	      for cmd in $cmds; do
melunko@917
  2664
		IFS="$save_ifs"
melunko@917
  2665
		eval cmd=\"$cmd\"
melunko@917
  2666
		$show "$cmd"
melunko@917
  2667
		$run eval "$cmd" || exit $?
melunko@917
  2668
	      done
melunko@917
  2669
	      IFS="$save_ifs"
melunko@917
  2670
	    fi
melunko@917
  2671
melunko@917
  2672
	    # Create $newlib
melunko@917
  2673
	    if test -f "$output_objdir/$newlib"; then :; else
melunko@917
  2674
	      $show "generating import library for \`$soname'"
melunko@917
  2675
	      save_ifs="$IFS"; IFS='~'
melunko@917
  2676
	      cmds=$old_archive_from_expsyms_cmds
melunko@917
  2677
	      for cmd in $cmds; do
melunko@917
  2678
		IFS="$save_ifs"
melunko@917
  2679
		eval cmd=\"$cmd\"
melunko@917
  2680
		$show "$cmd"
melunko@917
  2681
		$run eval "$cmd" || exit $?
melunko@917
  2682
	      done
melunko@917
  2683
	      IFS="$save_ifs"
melunko@917
  2684
	    fi
melunko@917
  2685
	    # make sure the library variables are pointing to the new library
melunko@917
  2686
	    dir=$output_objdir
melunko@917
  2687
	    linklib=$newlib
melunko@917
  2688
	  fi # test -n "$old_archive_from_expsyms_cmds"
melunko@917
  2689
melunko@917
  2690
	  if test "$linkmode" = prog || test "$mode" != relink; then
melunko@917
  2691
	    add_shlibpath=
melunko@917
  2692
	    add_dir=
melunko@917
  2693
	    add=
melunko@917
  2694
	    lib_linked=yes
melunko@917
  2695
	    case $hardcode_action in
melunko@917
  2696
	    immediate | unsupported)
melunko@917
  2697
	      if test "$hardcode_direct" = no; then
melunko@917
  2698
		add="$dir/$linklib"
melunko@917
  2699
		case $host in
melunko@917
  2700
		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
melunko@917
  2701
		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
melunko@917
  2702
		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
melunko@917
  2703
		    *-*-unixware7*) add_dir="-L$dir" ;;
melunko@917
  2704
		  *-*-darwin* )
melunko@917
  2705
		    # if the lib is a module then we can not link against
melunko@917
  2706
		    # it, someone is ignoring the new warnings I added
melunko@917
  2707
		    if /usr/bin/file -L $add 2> /dev/null |
melunko@917
  2708
                      $EGREP ": [^:]* bundle" >/dev/null ; then
melunko@917
  2709
		      $echo "** Warning, lib $linklib is a module, not a shared library"
melunko@917
  2710
		      if test -z "$old_library" ; then
melunko@917
  2711
		        $echo
melunko@917
  2712
		        $echo "** And there doesn't seem to be a static archive available"
melunko@917
  2713
		        $echo "** The link will probably fail, sorry"
melunko@917
  2714
		      else
melunko@917
  2715
		        add="$dir/$old_library"
melunko@917
  2716
		      fi
melunko@917
  2717
		    fi
melunko@917
  2718
		esac
melunko@917
  2719
	      elif test "$hardcode_minus_L" = no; then
melunko@917
  2720
		case $host in
melunko@917
  2721
		*-*-sunos*) add_shlibpath="$dir" ;;
melunko@917
  2722
		esac
melunko@917
  2723
		add_dir="-L$dir"
melunko@917
  2724
		add="-l$name"
melunko@917
  2725
	      elif test "$hardcode_shlibpath_var" = no; then
melunko@917
  2726
		add_shlibpath="$dir"
melunko@917
  2727
		add="-l$name"
melunko@917
  2728
	      else
melunko@917
  2729
		lib_linked=no
melunko@917
  2730
	      fi
melunko@917
  2731
	      ;;
melunko@917
  2732
	    relink)
melunko@917
  2733
	      if test "$hardcode_direct" = yes; then
melunko@917
  2734
		add="$dir/$linklib"
melunko@917
  2735
	      elif test "$hardcode_minus_L" = yes; then
melunko@917
  2736
		add_dir="-L$dir"
melunko@917
  2737
		# Try looking first in the location we're being installed to.
melunko@917
  2738
		if test -n "$inst_prefix_dir"; then
melunko@917
  2739
		  case $libdir in
melunko@917
  2740
		    [\\/]*)
melunko@917
  2741
		      add_dir="$add_dir -L$inst_prefix_dir$libdir"
melunko@917
  2742
		      ;;
melunko@917
  2743
		  esac
melunko@917
  2744
		fi
melunko@917
  2745
		add="-l$name"
melunko@917
  2746
	      elif test "$hardcode_shlibpath_var" = yes; then
melunko@917
  2747
		add_shlibpath="$dir"
melunko@917
  2748
		add="-l$name"
melunko@917
  2749
	      else
melunko@917
  2750
		lib_linked=no
melunko@917
  2751
	      fi
melunko@917
  2752
	      ;;
melunko@917
  2753
	    *) lib_linked=no ;;
melunko@917
  2754
	    esac
melunko@917
  2755
melunko@917
  2756
	    if test "$lib_linked" != yes; then
melunko@917
  2757
	      $echo "$modename: configuration error: unsupported hardcode properties"
melunko@917
  2758
	      exit $EXIT_FAILURE
melunko@917
  2759
	    fi
melunko@917
  2760
melunko@917
  2761
	    if test -n "$add_shlibpath"; then
melunko@917
  2762
	      case :$compile_shlibpath: in
melunko@917
  2763
	      *":$add_shlibpath:"*) ;;
melunko@917
  2764
	      *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
melunko@917
  2765
	      esac
melunko@917
  2766
	    fi
melunko@917
  2767
	    if test "$linkmode" = prog; then
melunko@917
  2768
	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
melunko@917
  2769
	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
melunko@917
  2770
	    else
melunko@917
  2771
	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
melunko@917
  2772
	      test -n "$add" && deplibs="$add $deplibs"
melunko@917
  2773
	      if test "$hardcode_direct" != yes && \
melunko@917
  2774
		 test "$hardcode_minus_L" != yes && \
melunko@917
  2775
		 test "$hardcode_shlibpath_var" = yes; then
melunko@917
  2776
		case :$finalize_shlibpath: in
melunko@917
  2777
		*":$libdir:"*) ;;
melunko@917
  2778
		*) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
melunko@917
  2779
		esac
melunko@917
  2780
	      fi
melunko@917
  2781
	    fi
melunko@917
  2782
	  fi
melunko@917
  2783
melunko@917
  2784
	  if test "$linkmode" = prog || test "$mode" = relink; then
melunko@917
  2785
	    add_shlibpath=
melunko@917
  2786
	    add_dir=
melunko@917
  2787
	    add=
melunko@917
  2788
	    # Finalize command for both is simple: just hardcode it.
melunko@917
  2789
	    if test "$hardcode_direct" = yes; then
melunko@917
  2790
	      add="$libdir/$linklib"
melunko@917
  2791
	    elif test "$hardcode_minus_L" = yes; then
melunko@917
  2792
	      add_dir="-L$libdir"
melunko@917
  2793
	      add="-l$name"
melunko@917
  2794
	    elif test "$hardcode_shlibpath_var" = yes; then
melunko@917
  2795
	      case :$finalize_shlibpath: in
melunko@917
  2796
	      *":$libdir:"*) ;;
melunko@917
  2797
	      *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
melunko@917
  2798
	      esac
melunko@917
  2799
	      add="-l$name"
melunko@917
  2800
	    elif test "$hardcode_automatic" = yes; then
melunko@917
  2801
	      if test -n "$inst_prefix_dir" &&
melunko@917
  2802
		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
melunko@917
  2803
	        add="$inst_prefix_dir$libdir/$linklib"
melunko@917
  2804
	      else
melunko@917
  2805
	        add="$libdir/$linklib"
melunko@917
  2806
	      fi
melunko@917
  2807
	    else
melunko@917
  2808
	      # We cannot seem to hardcode it, guess we'll fake it.
melunko@917
  2809
	      add_dir="-L$libdir"
melunko@917
  2810
	      # Try looking first in the location we're being installed to.
melunko@917
  2811
	      if test -n "$inst_prefix_dir"; then
melunko@917
  2812
		case $libdir in
melunko@917
  2813
		  [\\/]*)
melunko@917
  2814
		    add_dir="$add_dir -L$inst_prefix_dir$libdir"
melunko@917
  2815
		    ;;
melunko@917
  2816
		esac
melunko@917
  2817
	      fi
melunko@917
  2818
	      add="-l$name"
melunko@917
  2819
	    fi
melunko@917
  2820
melunko@917
  2821
	    if test "$linkmode" = prog; then
melunko@917
  2822
	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
melunko@917
  2823
	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
melunko@917
  2824
	    else
melunko@917
  2825
	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
melunko@917
  2826
	      test -n "$add" && deplibs="$add $deplibs"
melunko@917
  2827
	    fi
melunko@917
  2828
	  fi
melunko@917
  2829
	elif test "$linkmode" = prog; then
melunko@917
  2830
	  # Here we assume that one of hardcode_direct or hardcode_minus_L
melunko@917
  2831
	  # is not unsupported.  This is valid on all known static and
melunko@917
  2832
	  # shared platforms.
melunko@917
  2833
	  if test "$hardcode_direct" != unsupported; then
melunko@917
  2834
	    test -n "$old_library" && linklib="$old_library"
melunko@917
  2835
	    compile_deplibs="$dir/$linklib $compile_deplibs"
melunko@917
  2836
	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
melunko@917
  2837
	  else
melunko@917
  2838
	    compile_deplibs="-l$name -L$dir $compile_deplibs"
melunko@917
  2839
	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
melunko@917
  2840
	  fi
melunko@917
  2841
	elif test "$build_libtool_libs" = yes; then
melunko@917
  2842
	  # Not a shared library
melunko@917
  2843
	  if test "$deplibs_check_method" != pass_all; then
melunko@917
  2844
	    # We're trying link a shared library against a static one
melunko@917
  2845
	    # but the system doesn't support it.
melunko@917
  2846
melunko@917
  2847
	    # Just print a warning and add the library to dependency_libs so
melunko@917
  2848
	    # that the program can be linked against the static library.
melunko@917
  2849
	    $echo
melunko@917
  2850
	    $echo "*** Warning: This system can not link to static lib archive $lib."
melunko@917
  2851
	    $echo "*** I have the capability to make that library automatically link in when"
melunko@917
  2852
	    $echo "*** you link to this library.  But I can only do this if you have a"
melunko@917
  2853
	    $echo "*** shared version of the library, which you do not appear to have."
melunko@917
  2854
	    if test "$module" = yes; then
melunko@917
  2855
	      $echo "*** But as you try to build a module library, libtool will still create "
melunko@917
  2856
	      $echo "*** a static module, that should work as long as the dlopening application"
melunko@917
  2857
	      $echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
melunko@917
  2858
	      if test -z "$global_symbol_pipe"; then
melunko@917
  2859
		$echo
melunko@917
  2860
		$echo "*** However, this would only work if libtool was able to extract symbol"
melunko@917
  2861
		$echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
melunko@917
  2862
		$echo "*** not find such a program.  So, this module is probably useless."
melunko@917
  2863
		$echo "*** \`nm' from GNU binutils and a full rebuild may help."
melunko@917
  2864
	      fi
melunko@917
  2865
	      if test "$build_old_libs" = no; then
melunko@917
  2866
		build_libtool_libs=module
melunko@917
  2867
		build_old_libs=yes
melunko@917
  2868
	      else
melunko@917
  2869
		build_libtool_libs=no
melunko@917
  2870
	      fi
melunko@917
  2871
	    fi
melunko@917
  2872
	  else
melunko@917
  2873
	    deplibs="$dir/$old_library $deplibs"
melunko@917
  2874
	    link_static=yes
melunko@917
  2875
	  fi
melunko@917
  2876
	fi # link shared/static library?
melunko@917
  2877
melunko@917
  2878
	if test "$linkmode" = lib; then
melunko@917
  2879
	  if test -n "$dependency_libs" &&
melunko@917
  2880
	     { test "$hardcode_into_libs" != yes ||
melunko@917
  2881
	       test "$build_old_libs" = yes ||
melunko@917
  2882
	       test "$link_static" = yes; }; then
melunko@917
  2883
	    # Extract -R from dependency_libs
melunko@917
  2884
	    temp_deplibs=
melunko@917
  2885
	    for libdir in $dependency_libs; do
melunko@917
  2886
	      case $libdir in
melunko@917
  2887
	      -R*) temp_xrpath=`$echo "X$libdir" | $Xsed -e 's/^-R//'`
melunko@917
  2888
		   case " $xrpath " in
melunko@917
  2889
		   *" $temp_xrpath "*) ;;
melunko@917
  2890
		   *) xrpath="$xrpath $temp_xrpath";;
melunko@917
  2891
		   esac;;
melunko@917
  2892
	      *) temp_deplibs="$temp_deplibs $libdir";;
melunko@917
  2893
	      esac
melunko@917
  2894
	    done
melunko@917
  2895
	    dependency_libs="$temp_deplibs"
melunko@917
  2896
	  fi
melunko@917
  2897
melunko@917
  2898
	  newlib_search_path="$newlib_search_path $absdir"
melunko@917
  2899
	  # Link against this library
melunko@917
  2900
	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
melunko@917
  2901
	  # ... and its dependency_libs
melunko@917
  2902
	  tmp_libs=
melunko@917
  2903
	  for deplib in $dependency_libs; do
melunko@917
  2904
	    newdependency_libs="$deplib $newdependency_libs"
melunko@917
  2905
	    if test "X$duplicate_deps" = "Xyes" ; then
melunko@917
  2906
	      case "$tmp_libs " in
melunko@917
  2907
	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
melunko@917
  2908
	      esac
melunko@917
  2909
	    fi
melunko@917
  2910
	    tmp_libs="$tmp_libs $deplib"
melunko@917
  2911
	  done
melunko@917
  2912
melunko@917
  2913
	  if test "$link_all_deplibs" != no; then
melunko@917
  2914
	    # Add the search paths of all dependency libraries
melunko@917
  2915
	    for deplib in $dependency_libs; do
melunko@917
  2916
	      case $deplib in
melunko@917
  2917
	      -L*) path="$deplib" ;;
melunko@917
  2918
	      *.la)
melunko@917
  2919
		dir=`$echo "X$deplib" | $Xsed -e 's%/[^/]*$%%'`
melunko@917
  2920
		test "X$dir" = "X$deplib" && dir="."
melunko@917
  2921
		# We need an absolute path.
melunko@917
  2922
		case $dir in
melunko@917
  2923
		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
melunko@917
  2924
		*)
melunko@917
  2925
		  absdir=`cd "$dir" && pwd`
melunko@917
  2926
		  if test -z "$absdir"; then
melunko@917
  2927
		    $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2
melunko@917
  2928
		    absdir="$dir"
melunko@917
  2929
		  fi
melunko@917
  2930
		  ;;
melunko@917
  2931
		esac
melunko@917
  2932
		if grep "^installed=no" $deplib > /dev/null; then
melunko@917
  2933
		  path="$absdir/$objdir"
melunko@917
  2934
		else
melunko@917
  2935
		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
melunko@917
  2936
		  if test -z "$libdir"; then
melunko@917
  2937
		    $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
melunko@917
  2938
		    exit $EXIT_FAILURE
melunko@917
  2939
		  fi
melunko@917
  2940
		  if test "$absdir" != "$libdir"; then
melunko@917
  2941
		    $echo "$modename: warning: \`$deplib' seems to be moved" 1>&2
melunko@917
  2942
		  fi
melunko@917
  2943
		  path="$absdir"
melunko@917
  2944
		fi
melunko@917
  2945
		depdepl=
melunko@917
  2946
		case $host in
melunko@917
  2947
		*-*-darwin*)
melunko@917
  2948
		  # we do not want to link against static libs,
melunko@917
  2949
		  # but need to link against shared
melunko@917
  2950
		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
melunko@917
  2951
		  if test -n "$deplibrary_names" ; then
melunko@917
  2952
		    for tmp in $deplibrary_names ; do
melunko@917
  2953
		      depdepl=$tmp
melunko@917
  2954
		    done
melunko@917
  2955
		    if test -f "$path/$depdepl" ; then
melunko@917
  2956
		      depdepl="$path/$depdepl"
melunko@917
  2957
		    fi
melunko@917
  2958
		    # do not add paths which are already there
melunko@917
  2959
		    case " $newlib_search_path " in
melunko@917
  2960
		    *" $path "*) ;;
melunko@917
  2961
		    *) newlib_search_path="$newlib_search_path $path";;
melunko@917
  2962
		    esac
melunko@917
  2963
		  fi
melunko@917
  2964
		  path=""
melunko@917
  2965
		  ;;
melunko@917
  2966
		*)
melunko@917
  2967
		  path="-L$path"
melunko@917
  2968
		  ;;
melunko@917
  2969
		esac
melunko@917
  2970
		;;
melunko@917
  2971
	      -l*)
melunko@917
  2972
		case $host in
melunko@917
  2973
		*-*-darwin*)
melunko@917
  2974
		  # Again, we only want to link against shared libraries
melunko@917
  2975
		  eval tmp_libs=`$echo "X$deplib" | $Xsed -e "s,^\-l,,"`
melunko@917
  2976
		  for tmp in $newlib_search_path ; do
melunko@917
  2977
		    if test -f "$tmp/lib$tmp_libs.dylib" ; then
melunko@917
  2978
		      eval depdepl="$tmp/lib$tmp_libs.dylib"
melunko@917
  2979
		      break
melunko@917
  2980
		    fi
melunko@917
  2981
		  done
melunko@917
  2982
		  path=""
melunko@917
  2983
		  ;;
melunko@917
  2984
		*) continue ;;
melunko@917
  2985
		esac
melunko@917
  2986
		;;
melunko@917
  2987
	      *) continue ;;
melunko@917
  2988
	      esac
melunko@917
  2989
	      case " $deplibs " in
melunko@917
  2990
	      *" $path "*) ;;
melunko@917
  2991
	      *) deplibs="$path $deplibs" ;;
melunko@917
  2992
	      esac
melunko@917
  2993
	      case " $deplibs " in
melunko@917
  2994
	      *" $depdepl "*) ;;
melunko@917
  2995
	      *) deplibs="$depdepl $deplibs" ;;
melunko@917
  2996
	      esac
melunko@917
  2997
	    done
melunko@917
  2998
	  fi # link_all_deplibs != no
melunko@917
  2999
	fi # linkmode = lib
melunko@917
  3000
      done # for deplib in $libs
melunko@917
  3001
      dependency_libs="$newdependency_libs"
melunko@917
  3002
      if test "$pass" = dlpreopen; then
melunko@917
  3003
	# Link the dlpreopened libraries before other libraries
melunko@917
  3004
	for deplib in $save_deplibs; do
melunko@917
  3005
	  deplibs="$deplib $deplibs"
melunko@917
  3006
	done
melunko@917
  3007
      fi
melunko@917
  3008
      if test "$pass" != dlopen; then
melunko@917
  3009
	if test "$pass" != conv; then
melunko@917
  3010
	  # Make sure lib_search_path contains only unique directories.
melunko@917
  3011
	  lib_search_path=
melunko@917
  3012
	  for dir in $newlib_search_path; do
melunko@917
  3013
	    case "$lib_search_path " in
melunko@917
  3014
	    *" $dir "*) ;;
melunko@917
  3015
	    *) lib_search_path="$lib_search_path $dir" ;;
melunko@917
  3016
	    esac
melunko@917
  3017
	  done
melunko@917
  3018
	  newlib_search_path=
melunko@917
  3019
	fi
melunko@917
  3020
melunko@917
  3021
	if test "$linkmode,$pass" != "prog,link"; then
melunko@917
  3022
	  vars="deplibs"
melunko@917
  3023
	else
melunko@917
  3024
	  vars="compile_deplibs finalize_deplibs"
melunko@917
  3025
	fi
melunko@917
  3026
	for var in $vars dependency_libs; do
melunko@917
  3027
	  # Add libraries to $var in reverse order
melunko@917
  3028
	  eval tmp_libs=\"\$$var\"
melunko@917
  3029
	  new_libs=
melunko@917
  3030
	  for deplib in $tmp_libs; do
melunko@917
  3031
	    # FIXME: Pedantically, this is the right thing to do, so
melunko@917
  3032
	    #        that some nasty dependency loop isn't accidentally
melunko@917
  3033
	    #        broken:
melunko@917
  3034
	    #new_libs="$deplib $new_libs"
melunko@917
  3035
	    # Pragmatically, this seems to cause very few problems in
melunko@917
  3036
	    # practice:
melunko@917
  3037
	    case $deplib in
melunko@917
  3038
	    -L*) new_libs="$deplib $new_libs" ;;
melunko@917
  3039
	    -R*) ;;
melunko@917
  3040
	    *)
melunko@917
  3041
	      # And here is the reason: when a library appears more
melunko@917
  3042
	      # than once as an explicit dependence of a library, or
melunko@917
  3043
	      # is implicitly linked in more than once by the
melunko@917
  3044
	      # compiler, it is considered special, and multiple
melunko@917
  3045
	      # occurrences thereof are not removed.  Compare this
melunko@917
  3046
	      # with having the same library being listed as a
melunko@917
  3047
	      # dependency of multiple other libraries: in this case,
melunko@917
  3048
	      # we know (pedantically, we assume) the library does not
melunko@917
  3049
	      # need to be listed more than once, so we keep only the
melunko@917
  3050
	      # last copy.  This is not always right, but it is rare
melunko@917
  3051
	      # enough that we require users that really mean to play
melunko@917
  3052
	      # such unportable linking tricks to link the library
melunko@917
  3053
	      # using -Wl,-lname, so that libtool does not consider it
melunko@917
  3054
	      # for duplicate removal.
melunko@917
  3055
	      case " $specialdeplibs " in
melunko@917
  3056
	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
melunko@917
  3057
	      *)
melunko@917
  3058
		case " $new_libs " in
melunko@917
  3059
		*" $deplib "*) ;;
melunko@917
  3060
		*) new_libs="$deplib $new_libs" ;;
melunko@917
  3061
		esac
melunko@917
  3062
		;;
melunko@917
  3063
	      esac
melunko@917
  3064
	      ;;
melunko@917
  3065
	    esac
melunko@917
  3066
	  done
melunko@917
  3067
	  tmp_libs=
melunko@917
  3068
	  for deplib in $new_libs; do
melunko@917
  3069
	    case $deplib in
melunko@917
  3070
	    -L*)
melunko@917
  3071
	      case " $tmp_libs " in
melunko@917
  3072
	      *" $deplib "*) ;;
melunko@917
  3073
	      *) tmp_libs="$tmp_libs $deplib" ;;
melunko@917
  3074
	      esac
melunko@917
  3075
	      ;;
melunko@917
  3076
	    *) tmp_libs="$tmp_libs $deplib" ;;
melunko@917
  3077
	    esac
melunko@917
  3078
	  done
melunko@917
  3079
	  eval $var=\"$tmp_libs\"
melunko@917
  3080
	done # for var
melunko@917
  3081
      fi
melunko@917
  3082
      # Last step: remove runtime libs from dependency_libs
melunko@917
  3083
      # (they stay in deplibs)
melunko@917
  3084
      tmp_libs=
melunko@917
  3085
      for i in $dependency_libs ; do
melunko@917
  3086
	case " $predeps $postdeps $compiler_lib_search_path " in
melunko@917
  3087
	*" $i "*)
melunko@917
  3088
	  i=""
melunko@917
  3089
	  ;;
melunko@917
  3090
	esac
melunko@917
  3091
	if test -n "$i" ; then
melunko@917
  3092
	  tmp_libs="$tmp_libs $i"
melunko@917
  3093
	fi
melunko@917
  3094
      done
melunko@917
  3095
      dependency_libs=$tmp_libs
melunko@917
  3096
    done # for pass
melunko@917
  3097
    if test "$linkmode" = prog; then
melunko@917
  3098
      dlfiles="$newdlfiles"
melunko@917
  3099
      dlprefiles="$newdlprefiles"
melunko@917
  3100
    fi
melunko@917
  3101
melunko@917
  3102
    case $linkmode in
melunko@917
  3103
    oldlib)
melunko@917
  3104
      if test -n "$deplibs"; then
melunko@917
  3105
	$echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2
melunko@917
  3106
      fi
melunko@917
  3107
melunko@917
  3108
      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
melunko@917
  3109
	$echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2
melunko@917
  3110
      fi
melunko@917
  3111
melunko@917
  3112
      if test -n "$rpath"; then
melunko@917
  3113
	$echo "$modename: warning: \`-rpath' is ignored for archives" 1>&2
melunko@917
  3114
      fi
melunko@917
  3115
melunko@917
  3116
      if test -n "$xrpath"; then
melunko@917
  3117
	$echo "$modename: warning: \`-R' is ignored for archives" 1>&2
melunko@917
  3118
      fi
melunko@917
  3119
melunko@917
  3120
      if test -n "$vinfo"; then
melunko@917
  3121
	$echo "$modename: warning: \`-version-info/-version-number' is ignored for archives" 1>&2
melunko@917
  3122
      fi
melunko@917
  3123
melunko@917
  3124
      if test -n "$release"; then
melunko@917
  3125
	$echo "$modename: warning: \`-release' is ignored for archives" 1>&2
melunko@917
  3126
      fi
melunko@917
  3127
melunko@917
  3128
      if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
melunko@917
  3129
	$echo "$modename: warning: \`-export-symbols' is ignored for archives" 1>&2
melunko@917
  3130
      fi
melunko@917
  3131
melunko@917
  3132
      # Now set the variables for building old libraries.
melunko@917
  3133
      build_libtool_libs=no
melunko@917
  3134
      oldlibs="$output"
melunko@917
  3135
      objs="$objs$old_deplibs"
melunko@917
  3136
      ;;
melunko@917
  3137
melunko@917
  3138
    lib)
melunko@917
  3139
      # Make sure we only generate libraries of the form `libNAME.la'.
melunko@917
  3140
      case $outputname in
melunko@917
  3141
      lib*)
melunko@917
  3142
	name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
melunko@917
  3143
	eval shared_ext=\"$shrext_cmds\"
melunko@917
  3144
	eval libname=\"$libname_spec\"
melunko@917
  3145
	;;
melunko@917
  3146
      *)
melunko@917
  3147
	if test "$module" = no; then
melunko@917
  3148
	  $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2
melunko@917
  3149
	  $echo "$help" 1>&2
melunko@917
  3150
	  exit $EXIT_FAILURE
melunko@917
  3151
	fi
melunko@917
  3152
	if test "$need_lib_prefix" != no; then
melunko@917
  3153
	  # Add the "lib" prefix for modules if required
melunko@917
  3154
	  name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
melunko@917
  3155
	  eval shared_ext=\"$shrext_cmds\"
melunko@917
  3156
	  eval libname=\"$libname_spec\"
melunko@917
  3157
	else
melunko@917
  3158
	  libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
melunko@917
  3159
	fi
melunko@917
  3160
	;;
melunko@917
  3161
      esac
melunko@917
  3162
melunko@917
  3163
      if test -n "$objs"; then
melunko@917
  3164
	if test "$deplibs_check_method" != pass_all; then
melunko@917
  3165
	  $echo "$modename: cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 2>&1
melunko@917
  3166
	  exit $EXIT_FAILURE
melunko@917
  3167
	else
melunko@917
  3168
	  $echo
melunko@917
  3169
	  $echo "*** Warning: Linking the shared library $output against the non-libtool"
melunko@917
  3170
	  $echo "*** objects $objs is not portable!"
melunko@917
  3171
	  libobjs="$libobjs $objs"
melunko@917
  3172
	fi
melunko@917
  3173
      fi
melunko@917
  3174
melunko@917
  3175
      if test "$dlself" != no; then
melunko@917
  3176
	$echo "$modename: warning: \`-dlopen self' is ignored for libtool libraries" 1>&2
melunko@917
  3177
      fi
melunko@917
  3178
melunko@917
  3179
      set dummy $rpath
melunko@917
  3180
      if test "$#" -gt 2; then
melunko@917
  3181
	$echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2
melunko@917
  3182
      fi
melunko@917
  3183
      install_libdir="$2"
melunko@917
  3184
melunko@917
  3185
      oldlibs=
melunko@917
  3186
      if test -z "$rpath"; then
melunko@917
  3187
	if test "$build_libtool_libs" = yes; then
melunko@917
  3188
	  # Building a libtool convenience library.
melunko@917
  3189
	  # Some compilers have problems with a `.al' extension so
melunko@917
  3190
	  # convenience libraries should have the same extension an
melunko@917
  3191
	  # archive normally would.
melunko@917
  3192
	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
melunko@917
  3193
	  build_libtool_libs=convenience
melunko@917
  3194
	  build_old_libs=yes
melunko@917
  3195
	fi
melunko@917
  3196
melunko@917
  3197
	if test -n "$vinfo"; then
melunko@917
  3198
	  $echo "$modename: warning: \`-version-info/-version-number' is ignored for convenience libraries" 1>&2
melunko@917
  3199
	fi
melunko@917
  3200
melunko@917
  3201
	if test -n "$release"; then
melunko@917
  3202
	  $echo "$modename: warning: \`-release' is ignored for convenience libraries" 1>&2
melunko@917
  3203
	fi
melunko@917
  3204
      else
melunko@917
  3205
melunko@917
  3206
	# Parse the version information argument.
melunko@917
  3207
	save_ifs="$IFS"; IFS=':'
melunko@917
  3208
	set dummy $vinfo 0 0 0
melunko@917
  3209
	IFS="$save_ifs"
melunko@917
  3210
melunko@917
  3211
	if test -n "$8"; then
melunko@917
  3212
	  $echo "$modename: too many parameters to \`-version-info'" 1>&2
melunko@917
  3213
	  $echo "$help" 1>&2
melunko@917
  3214
	  exit $EXIT_FAILURE
melunko@917
  3215
	fi
melunko@917
  3216
melunko@917
  3217
	# convert absolute version numbers to libtool ages
melunko@917
  3218
	# this retains compatibility with .la files and attempts
melunko@917
  3219
	# to make the code below a bit more comprehensible
melunko@917
  3220
melunko@917
  3221
	case $vinfo_number in
melunko@917
  3222
	yes)
melunko@917
  3223
	  number_major="$2"
melunko@917
  3224
	  number_minor="$3"
melunko@917
  3225
	  number_revision="$4"
melunko@917
  3226
	  #
melunko@917
  3227
	  # There are really only two kinds -- those that
melunko@917
  3228
	  # use the current revision as the major version
melunko@917
  3229
	  # and those that subtract age and use age as
melunko@917
  3230
	  # a minor version.  But, then there is irix
melunko@917
  3231
	  # which has an extra 1 added just for fun
melunko@917
  3232
	  #
melunko@917
  3233
	  case $version_type in
melunko@917
  3234
	  darwin|linux|osf|windows|none)
melunko@917
  3235
	    current=`expr $number_major + $number_minor`
melunko@917
  3236
	    age="$number_minor"
melunko@917
  3237
	    revision="$number_revision"
melunko@917
  3238
	    ;;
melunko@917
  3239
	  freebsd-aout|freebsd-elf|sunos)
melunko@917
  3240
	    current="$number_major"
melunko@917
  3241
	    revision="$number_minor"
melunko@917
  3242
	    age="0"
melunko@917
  3243
	    ;;
melunko@917
  3244
	  irix|nonstopux)
melunko@917
  3245
	    current=`expr $number_major + $number_minor`
melunko@917
  3246
	    age="$number_minor"
melunko@917
  3247
	    revision="$number_minor"
melunko@917
  3248
	    lt_irix_increment=no
melunko@917
  3249
	    ;;
melunko@917
  3250
	  *)
melunko@917
  3251
	    $echo "$modename: unknown library version type \`$version_type'" 1>&2
melunko@917
  3252
	    $echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
melunko@917
  3253
	    exit $EXIT_FAILURE
melunko@917
  3254
	    ;;
melunko@917
  3255
	  esac
melunko@917
  3256
	  ;;
melunko@917
  3257
	no)
melunko@917
  3258
	  current="$2"
melunko@917
  3259
	  revision="$3"
melunko@917
  3260
	  age="$4"
melunko@917
  3261
	  ;;
melunko@917
  3262
	esac
melunko@917
  3263
melunko@917
  3264
	# Check that each of the things are valid numbers.
melunko@917
  3265
	case $current in
melunko@917
  3266
	0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
melunko@917
  3267
	*)
melunko@917
  3268
	  $echo "$modename: CURRENT \`$current' must be a nonnegative integer" 1>&2
melunko@917
  3269
	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
melunko@917
  3270
	  exit $EXIT_FAILURE
melunko@917
  3271
	  ;;
melunko@917
  3272
	esac
melunko@917
  3273
melunko@917
  3274
	case $revision in
melunko@917
  3275
	0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
melunko@917
  3276
	*)
melunko@917
  3277
	  $echo "$modename: REVISION \`$revision' must be a nonnegative integer" 1>&2
melunko@917
  3278
	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
melunko@917
  3279
	  exit $EXIT_FAILURE
melunko@917
  3280
	  ;;
melunko@917
  3281
	esac
melunko@917
  3282
melunko@917
  3283
	case $age in
melunko@917
  3284
	0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
melunko@917
  3285
	*)
melunko@917
  3286
	  $echo "$modename: AGE \`$age' must be a nonnegative integer" 1>&2
melunko@917
  3287
	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
melunko@917
  3288
	  exit $EXIT_FAILURE
melunko@917
  3289
	  ;;
melunko@917
  3290
	esac
melunko@917
  3291
melunko@917
  3292
	if test "$age" -gt "$current"; then
melunko@917
  3293
	  $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2
melunko@917
  3294
	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
melunko@917
  3295
	  exit $EXIT_FAILURE
melunko@917
  3296
	fi
melunko@917
  3297
melunko@917
  3298
	# Calculate the version variables.
melunko@917
  3299
	major=
melunko@917
  3300
	versuffix=
melunko@917
  3301
	verstring=
melunko@917
  3302
	case $version_type in
melunko@917
  3303
	none) ;;
melunko@917
  3304
melunko@917
  3305
	darwin)
melunko@917
  3306
	  # Like Linux, but with the current version available in
melunko@917
  3307
	  # verstring for coding it into the library header
melunko@917
  3308
	  major=.`expr $current - $age`
melunko@917
  3309
	  versuffix="$major.$age.$revision"
melunko@917
  3310
	  # Darwin ld doesn't like 0 for these options...
melunko@917
  3311
	  minor_current=`expr $current + 1`
melunko@917
  3312
	  xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
melunko@917
  3313
	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
melunko@917
  3314
	  ;;
melunko@917
  3315
melunko@917
  3316
	freebsd-aout)
melunko@917
  3317
	  major=".$current"
melunko@917
  3318
	  versuffix=".$current.$revision";
melunko@917
  3319
	  ;;
melunko@917
  3320
melunko@917
  3321
	freebsd-elf)
melunko@917
  3322
	  major=".$current"
melunko@917
  3323
	  versuffix=".$current";
melunko@917
  3324
	  ;;
melunko@917
  3325
melunko@917
  3326
	irix | nonstopux)
melunko@917
  3327
	  if test "X$lt_irix_increment" = "Xno"; then
melunko@917
  3328
	    major=`expr $current - $age`
melunko@917
  3329
	  else
melunko@917
  3330
	    major=`expr $current - $age + 1`
melunko@917
  3331
	  fi
melunko@917
  3332
	  case $version_type in
melunko@917
  3333
	    nonstopux) verstring_prefix=nonstopux ;;
melunko@917
  3334
	    *)         verstring_prefix=sgi ;;
melunko@917
  3335
	  esac
melunko@917
  3336
	  verstring="$verstring_prefix$major.$revision"
melunko@917
  3337
melunko@917
  3338
	  # Add in all the interfaces that we are compatible with.
melunko@917
  3339
	  loop=$revision
melunko@917
  3340
	  while test "$loop" -ne 0; do
melunko@917
  3341
	    iface=`expr $revision - $loop`
melunko@917
  3342
	    loop=`expr $loop - 1`
melunko@917
  3343
	    verstring="$verstring_prefix$major.$iface:$verstring"
melunko@917
  3344
	  done
melunko@917
  3345
melunko@917
  3346
	  # Before this point, $major must not contain `.'.
melunko@917
  3347
	  major=.$major
melunko@917
  3348
	  versuffix="$major.$revision"
melunko@917
  3349
	  ;;
melunko@917
  3350
melunko@917
  3351
	linux)
melunko@917
  3352
	  major=.`expr $current - $age`
melunko@917
  3353
	  versuffix="$major.$age.$revision"
melunko@917
  3354
	  ;;
melunko@917
  3355
melunko@917
  3356
	osf)
melunko@917
  3357
	  major=.`expr $current - $age`
melunko@917
  3358
	  versuffix=".$current.$age.$revision"
melunko@917
  3359
	  verstring="$current.$age.$revision"
melunko@917
  3360
melunko@917
  3361
	  # Add in all the interfaces that we are compatible with.
melunko@917
  3362
	  loop=$age
melunko@917
  3363
	  while test "$loop" -ne 0; do
melunko@917
  3364
	    iface=`expr $current - $loop`
melunko@917
  3365
	    loop=`expr $loop - 1`
melunko@917
  3366
	    verstring="$verstring:${iface}.0"
melunko@917
  3367
	  done
melunko@917
  3368
melunko@917
  3369
	  # Make executables depend on our current version.
melunko@917
  3370
	  verstring="$verstring:${current}.0"
melunko@917
  3371
	  ;;
melunko@917
  3372
melunko@917
  3373
	sunos)
melunko@917
  3374
	  major=".$current"
melunko@917
  3375
	  versuffix=".$current.$revision"
melunko@917
  3376
	  ;;
melunko@917
  3377
melunko@917
  3378
	windows)
melunko@917
  3379
	  # Use '-' rather than '.', since we only want one
melunko@917
  3380
	  # extension on DOS 8.3 filesystems.
melunko@917
  3381
	  major=`expr $current - $age`
melunko@917
  3382
	  versuffix="-$major"
melunko@917
  3383
	  ;;
melunko@917
  3384
melunko@917
  3385
	*)
melunko@917
  3386
	  $echo "$modename: unknown library version type \`$version_type'" 1>&2
melunko@917
  3387
	  $echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
melunko@917
  3388
	  exit $EXIT_FAILURE
melunko@917
  3389
	  ;;
melunko@917
  3390
	esac
melunko@917
  3391
melunko@917
  3392
	# Clear the version info if we defaulted, and they specified a release.
melunko@917
  3393
	if test -z "$vinfo" && test -n "$release"; then
melunko@917
  3394
	  major=
melunko@917
  3395
	  case $version_type in
melunko@917
  3396
	  darwin)
melunko@917
  3397
	    # we can't check for "0.0" in archive_cmds due to quoting
melunko@917
  3398
	    # problems, so we reset it completely
melunko@917
  3399
	    verstring=
melunko@917
  3400
	    ;;
melunko@917
  3401
	  *)
melunko@917
  3402
	    verstring="0.0"
melunko@917
  3403
	    ;;
melunko@917
  3404
	  esac
melunko@917
  3405
	  if test "$need_version" = no; then
melunko@917
  3406
	    versuffix=
melunko@917
  3407
	  else
melunko@917
  3408
	    versuffix=".0.0"
melunko@917
  3409
	  fi
melunko@917
  3410
	fi
melunko@917
  3411
melunko@917
  3412
	# Remove version info from name if versioning should be avoided
melunko@917
  3413
	if test "$avoid_version" = yes && test "$need_version" = no; then
melunko@917
  3414
	  major=
melunko@917
  3415
	  versuffix=
melunko@917
  3416
	  verstring=""
melunko@917
  3417
	fi
melunko@917
  3418
melunko@917
  3419
	# Check to see if the archive will have undefined symbols.
melunko@917
  3420
	if test "$allow_undefined" = yes; then
melunko@917
  3421
	  if test "$allow_undefined_flag" = unsupported; then
melunko@917
  3422
	    $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2
melunko@917
  3423
	    build_libtool_libs=no
melunko@917
  3424
	    build_old_libs=yes
melunko@917
  3425
	  fi
melunko@917
  3426
	else
melunko@917
  3427
	  # Don't allow undefined symbols.
melunko@917
  3428
	  allow_undefined_flag="$no_undefined_flag"
melunko@917
  3429
	fi
melunko@917
  3430
      fi
melunko@917
  3431
melunko@917
  3432
      if test "$mode" != relink; then
melunko@917
  3433
	# Remove our outputs, but don't remove object files since they
melunko@917
  3434
	# may have been created when compiling PIC objects.
melunko@917
  3435
	removelist=
melunko@917
  3436
	tempremovelist=`$echo "$output_objdir/*"`
melunko@917
  3437
	for p in $tempremovelist; do
melunko@917
  3438
	  case $p in
melunko@917
  3439
	    *.$objext)
melunko@917
  3440
	       ;;
melunko@917
  3441
	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
melunko@917
  3442
	       if test "X$precious_files_regex" != "X"; then
melunko@917
  3443
	         if echo $p | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
melunko@917
  3444
	         then
melunko@917
  3445
		   continue
melunko@917
  3446
		 fi
melunko@917
  3447
	       fi
melunko@917
  3448
	       removelist="$removelist $p"
melunko@917
  3449
	       ;;
melunko@917
  3450
	    *) ;;
melunko@917
  3451
	  esac
melunko@917
  3452
	done
melunko@917
  3453
	if test -n "$removelist"; then
melunko@917
  3454
	  $show "${rm}r $removelist"
melunko@917
  3455
	  $run ${rm}r $removelist
melunko@917
  3456
	fi
melunko@917
  3457
      fi
melunko@917
  3458
melunko@917
  3459
      # Now set the variables for building old libraries.
melunko@917
  3460
      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
melunko@917
  3461
	oldlibs="$oldlibs $output_objdir/$libname.$libext"
melunko@917
  3462
melunko@917
  3463
	# Transform .lo files to .o files.
melunko@917
  3464
	oldobjs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP`
melunko@917
  3465
      fi
melunko@917
  3466
melunko@917
  3467
      # Eliminate all temporary directories.
melunko@917
  3468
      #for path in $notinst_path; do
melunko@917
  3469
      #	lib_search_path=`$echo "$lib_search_path " | ${SED} -e "s% $path % %g"`
melunko@917
  3470
      #	deplibs=`$echo "$deplibs " | ${SED} -e "s% -L$path % %g"`
melunko@917
  3471
      #	dependency_libs=`$echo "$dependency_libs " | ${SED} -e "s% -L$path % %g"`
melunko@917
  3472
      #done
melunko@917
  3473
melunko@917
  3474
      if test -n "$xrpath"; then
melunko@917
  3475
	# If the user specified any rpath flags, then add them.
melunko@917
  3476
	temp_xrpath=
melunko@917
  3477
	for libdir in $xrpath; do
melunko@917
  3478
	  temp_xrpath="$temp_xrpath -R$libdir"
melunko@917
  3479
	  case "$finalize_rpath " in
melunko@917
  3480
	  *" $libdir "*) ;;
melunko@917
  3481
	  *) finalize_rpath="$finalize_rpath $libdir" ;;
melunko@917
  3482
	  esac
melunko@917
  3483
	done
melunko@917
  3484
	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
melunko@917
  3485
	  dependency_libs="$temp_xrpath $dependency_libs"
melunko@917
  3486
	fi
melunko@917
  3487
      fi
melunko@917
  3488
melunko@917
  3489
      # Make sure dlfiles contains only unique files that won't be dlpreopened
melunko@917
  3490
      old_dlfiles="$dlfiles"
melunko@917
  3491
      dlfiles=
melunko@917
  3492
      for lib in $old_dlfiles; do
melunko@917
  3493
	case " $dlprefiles $dlfiles " in
melunko@917
  3494
	*" $lib "*) ;;
melunko@917
  3495
	*) dlfiles="$dlfiles $lib" ;;
melunko@917
  3496
	esac
melunko@917
  3497
      done
melunko@917
  3498
melunko@917
  3499
      # Make sure dlprefiles contains only unique files
melunko@917
  3500
      old_dlprefiles="$dlprefiles"
melunko@917
  3501
      dlprefiles=
melunko@917
  3502
      for lib in $old_dlprefiles; do
melunko@917
  3503
	case "$dlprefiles " in
melunko@917
  3504
	*" $lib "*) ;;
melunko@917
  3505
	*) dlprefiles="$dlprefiles $lib" ;;
melunko@917
  3506
	esac
melunko@917
  3507
      done
melunko@917
  3508
melunko@917
  3509
      if test "$build_libtool_libs" = yes; then
melunko@917
  3510
	if test -n "$rpath"; then
melunko@917
  3511
	  case $host in
melunko@917
  3512
	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos*)
melunko@917
  3513
	    # these systems don't actually have a c library (as such)!
melunko@917
  3514
	    ;;
melunko@917
  3515
	  *-*-rhapsody* | *-*-darwin1.[012])
melunko@917
  3516
	    # Rhapsody C library is in the System framework
melunko@917
  3517
	    deplibs="$deplibs -framework System"
melunko@917
  3518
	    ;;
melunko@917
  3519
	  *-*-netbsd*)
melunko@917
  3520
	    # Don't link with libc until the a.out ld.so is fixed.
melunko@917
  3521
	    ;;
melunko@917
  3522
	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
melunko@917
  3523
	    # Do not include libc due to us having libc/libc_r.
melunko@917
  3524
	    ;;
melunko@917
  3525
	  *-*-sco3.2v5* | *-*-sco5v6*)
melunko@917
  3526
	    # Causes problems with __ctype
melunko@917
  3527
	    ;;
melunko@917
  3528
	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
melunko@917
  3529
	    # Compiler inserts libc in the correct place for threads to work
melunko@917
  3530
	    ;;
melunko@917
  3531
 	  *)
melunko@917
  3532
	    # Add libc to deplibs on all other systems if necessary.
melunko@917
  3533
	    if test "$build_libtool_need_lc" = "yes"; then
melunko@917
  3534
	      deplibs="$deplibs -lc"
melunko@917
  3535
	    fi
melunko@917
  3536
	    ;;
melunko@917
  3537
	  esac
melunko@917
  3538
	fi
melunko@917
  3539
melunko@917
  3540
	# Transform deplibs into only deplibs that can be linked in shared.
melunko@917
  3541
	name_save=$name
melunko@917
  3542
	libname_save=$libname
melunko@917
  3543
	release_save=$release
melunko@917
  3544
	versuffix_save=$versuffix
melunko@917
  3545
	major_save=$major
melunko@917
  3546
	# I'm not sure if I'm treating the release correctly.  I think
melunko@917
  3547
	# release should show up in the -l (ie -lgmp5) so we don't want to
melunko@917
  3548
	# add it in twice.  Is that correct?
melunko@917
  3549
	release=""
melunko@917
  3550
	versuffix=""
melunko@917
  3551
	major=""
melunko@917
  3552
	newdeplibs=
melunko@917
  3553
	droppeddeps=no
melunko@917
  3554
	case $deplibs_check_method in
melunko@917
  3555
	pass_all)
melunko@917
  3556
	  # Don't check for shared/static.  Everything works.
melunko@917
  3557
	  # This might be a little naive.  We might want to check
melunko@917
  3558
	  # whether the library exists or not.  But this is on
melunko@917
  3559
	  # osf3 & osf4 and I'm not really sure... Just
melunko@917
  3560
	  # implementing what was already the behavior.
melunko@917
  3561
	  newdeplibs=$deplibs
melunko@917
  3562
	  ;;
melunko@917
  3563
	test_compile)
melunko@917
  3564
	  # This code stresses the "libraries are programs" paradigm to its
melunko@917
  3565
	  # limits. Maybe even breaks it.  We compile a program, linking it
melunko@917
  3566
	  # against the deplibs as a proxy for the library.  Then we can check
melunko@917
  3567
	  # whether they linked in statically or dynamically with ldd.
melunko@917
  3568
	  $rm conftest.c
melunko@917
  3569
	  cat > conftest.c <<EOF
melunko@917
  3570
	  int main() { return 0; }
melunko@917
  3571
EOF
melunko@917
  3572
	  $rm conftest
melunko@917
  3573
	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
melunko@917
  3574
	    ldd_output=`ldd conftest`
melunko@917
  3575
	    for i in $deplibs; do
melunko@917
  3576
	      name=`expr $i : '-l\(.*\)'`
melunko@917
  3577
	      # If $name is empty we are operating on a -L argument.
melunko@917
  3578
              if test "$name" != "" && test "$name" != "0"; then
melunko@917
  3579
		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
melunko@917
  3580
		  case " $predeps $postdeps " in
melunko@917
  3581
		  *" $i "*)
melunko@917
  3582
		    newdeplibs="$newdeplibs $i"
melunko@917
  3583
		    i=""
melunko@917
  3584
		    ;;
melunko@917
  3585
		  esac
melunko@917
  3586
	        fi
melunko@917
  3587
		if test -n "$i" ; then
melunko@917
  3588
		  libname=`eval \\$echo \"$libname_spec\"`
melunko@917
  3589
		  deplib_matches=`eval \\$echo \"$library_names_spec\"`
melunko@917
  3590
		  set dummy $deplib_matches
melunko@917
  3591
		  deplib_match=$2
melunko@917
  3592
		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
melunko@917
  3593
		    newdeplibs="$newdeplibs $i"
melunko@917
  3594
		  else
melunko@917
  3595
		    droppeddeps=yes
melunko@917
  3596
		    $echo
melunko@917
  3597
		    $echo "*** Warning: dynamic linker does not accept needed library $i."
melunko@917
  3598
		    $echo "*** I have the capability to make that library automatically link in when"
melunko@917
  3599
		    $echo "*** you link to this library.  But I can only do this if you have a"
melunko@917
  3600
		    $echo "*** shared version of the library, which I believe you do not have"
melunko@917
  3601
		    $echo "*** because a test_compile did reveal that the linker did not use it for"
melunko@917
  3602
		    $echo "*** its dynamic dependency list that programs get resolved with at runtime."
melunko@917
  3603
		  fi
melunko@917
  3604
		fi
melunko@917
  3605
	      else
melunko@917
  3606
		newdeplibs="$newdeplibs $i"
melunko@917
  3607
	      fi
melunko@917
  3608
	    done
melunko@917
  3609
	  else
melunko@917
  3610
	    # Error occurred in the first compile.  Let's try to salvage
melunko@917
  3611
	    # the situation: Compile a separate program for each library.
melunko@917
  3612
	    for i in $deplibs; do
melunko@917
  3613
	      name=`expr $i : '-l\(.*\)'`
melunko@917
  3614
	      # If $name is empty we are operating on a -L argument.
melunko@917
  3615
              if test "$name" != "" && test "$name" != "0"; then
melunko@917
  3616
		$rm conftest
melunko@917
  3617
		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
melunko@917
  3618
		  ldd_output=`ldd conftest`
melunko@917
  3619
		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
melunko@917
  3620
		    case " $predeps $postdeps " in
melunko@917
  3621
		    *" $i "*)
melunko@917
  3622
		      newdeplibs="$newdeplibs $i"
melunko@917
  3623
		      i=""
melunko@917
  3624
		      ;;
melunko@917
  3625
		    esac
melunko@917
  3626
		  fi
melunko@917
  3627
		  if test -n "$i" ; then
melunko@917
  3628
		    libname=`eval \\$echo \"$libname_spec\"`
melunko@917
  3629
		    deplib_matches=`eval \\$echo \"$library_names_spec\"`
melunko@917
  3630
		    set dummy $deplib_matches
melunko@917
  3631
		    deplib_match=$2
melunko@917
  3632
		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
melunko@917
  3633
		      newdeplibs="$newdeplibs $i"
melunko@917
  3634
		    else
melunko@917
  3635
		      droppeddeps=yes
melunko@917
  3636
		      $echo
melunko@917
  3637
		      $echo "*** Warning: dynamic linker does not accept needed library $i."
melunko@917
  3638
		      $echo "*** I have the capability to make that library automatically link in when"
melunko@917
  3639
		      $echo "*** you link to this library.  But I can only do this if you have a"
melunko@917
  3640
		      $echo "*** shared version of the library, which you do not appear to have"
melunko@917
  3641
		      $echo "*** because a test_compile did reveal that the linker did not use this one"
melunko@917
  3642
		      $echo "*** as a dynamic dependency that programs can get resolved with at runtime."
melunko@917
  3643
		    fi
melunko@917
  3644
		  fi
melunko@917
  3645
		else
melunko@917
  3646
		  droppeddeps=yes
melunko@917
  3647
		  $echo
melunko@917
  3648
		  $echo "*** Warning!  Library $i is needed by this library but I was not able to"
melunko@917
  3649
		  $echo "*** make it link in!  You will probably need to install it or some"
melunko@917
  3650
		  $echo "*** library that it depends on before this library will be fully"
melunko@917
  3651
		  $echo "*** functional.  Installing it before continuing would be even better."
melunko@917
  3652
		fi
melunko@917
  3653
	      else
melunko@917
  3654
		newdeplibs="$newdeplibs $i"
melunko@917
  3655
	      fi
melunko@917
  3656
	    done
melunko@917
  3657
	  fi
melunko@917
  3658
	  ;;
melunko@917
  3659
	file_magic*)
melunko@917
  3660
	  set dummy $deplibs_check_method
melunko@917
  3661
	  file_magic_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
melunko@917
  3662
	  for a_deplib in $deplibs; do
melunko@917
  3663
	    name=`expr $a_deplib : '-l\(.*\)'`
melunko@917
  3664
	    # If $name is empty we are operating on a -L argument.
melunko@917
  3665
            if test "$name" != "" && test  "$name" != "0"; then
melunko@917
  3666
	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
melunko@917
  3667
		case " $predeps $postdeps " in
melunko@917
  3668
		*" $a_deplib "*)
melunko@917
  3669
		  newdeplibs="$newdeplibs $a_deplib"
melunko@917
  3670
		  a_deplib=""
melunko@917
  3671
		  ;;
melunko@917
  3672
		esac
melunko@917
  3673
	      fi
melunko@917
  3674
	      if test -n "$a_deplib" ; then
melunko@917
  3675
		libname=`eval \\$echo \"$libname_spec\"`
melunko@917
  3676
		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
melunko@917
  3677
		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
melunko@917
  3678
		  for potent_lib in $potential_libs; do
melunko@917
  3679
		      # Follow soft links.
melunko@917
  3680
		      if ls -lLd "$potent_lib" 2>/dev/null \
melunko@917
  3681
			 | grep " -> " >/dev/null; then
melunko@917
  3682
			continue
melunko@917
  3683
		      fi
melunko@917
  3684
		      # The statement above tries to avoid entering an
melunko@917
  3685
		      # endless loop below, in case of cyclic links.
melunko@917
  3686
		      # We might still enter an endless loop, since a link
melunko@917
  3687
		      # loop can be closed while we follow links,
melunko@917
  3688
		      # but so what?
melunko@917
  3689
		      potlib="$potent_lib"
melunko@917
  3690
		      while test -h "$potlib" 2>/dev/null; do
melunko@917
  3691
			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
melunko@917
  3692
			case $potliblink in
melunko@917
  3693
			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
melunko@917
  3694
			*) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
melunko@917
  3695
			esac
melunko@917
  3696
		      done
melunko@917
  3697
		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \
melunko@917
  3698
			 | ${SED} 10q \
melunko@917
  3699
			 | $EGREP "$file_magic_regex" > /dev/null; then
melunko@917
  3700
			newdeplibs="$newdeplibs $a_deplib"
melunko@917
  3701
			a_deplib=""
melunko@917
  3702
			break 2
melunko@917
  3703
		      fi
melunko@917
  3704
		  done
melunko@917
  3705
		done
melunko@917
  3706
	      fi
melunko@917
  3707
	      if test -n "$a_deplib" ; then
melunko@917
  3708
		droppeddeps=yes
melunko@917
  3709
		$echo
melunko@917
  3710
		$echo "*** Warning: linker path does not have real file for library $a_deplib."
melunko@917
  3711
		$echo "*** I have the capability to make that library automatically link in when"
melunko@917
  3712
		$echo "*** you link to this library.  But I can only do this if you have a"
melunko@917
  3713
		$echo "*** shared version of the library, which you do not appear to have"
melunko@917
  3714
		$echo "*** because I did check the linker path looking for a file starting"
melunko@917
  3715
		if test -z "$potlib" ; then
melunko@917
  3716
		  $echo "*** with $libname but no candidates were found. (...for file magic test)"
melunko@917
  3717
		else
melunko@917
  3718
		  $echo "*** with $libname and none of the candidates passed a file format test"
melunko@917
  3719
		  $echo "*** using a file magic. Last file checked: $potlib"
melunko@917
  3720
		fi
melunko@917
  3721
	      fi
melunko@917
  3722
	    else
melunko@917
  3723
	      # Add a -L argument.
melunko@917
  3724
	      newdeplibs="$newdeplibs $a_deplib"
melunko@917
  3725
	    fi
melunko@917
  3726
	  done # Gone through all deplibs.
melunko@917
  3727
	  ;;
melunko@917
  3728
	match_pattern*)
melunko@917
  3729
	  set dummy $deplibs_check_method
melunko@917
  3730
	  match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
melunko@917
  3731
	  for a_deplib in $deplibs; do
melunko@917
  3732
	    name=`expr $a_deplib : '-l\(.*\)'`
melunko@917
  3733
	    # If $name is empty we are operating on a -L argument.
melunko@917
  3734
	    if test -n "$name" && test "$name" != "0"; then
melunko@917
  3735
	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
melunko@917
  3736
		case " $predeps $postdeps " in
melunko@917
  3737
		*" $a_deplib "*)
melunko@917
  3738
		  newdeplibs="$newdeplibs $a_deplib"
melunko@917
  3739
		  a_deplib=""
melunko@917
  3740
		  ;;
melunko@917
  3741
		esac
melunko@917
  3742
	      fi
melunko@917
  3743
	      if test -n "$a_deplib" ; then
melunko@917
  3744
		libname=`eval \\$echo \"$libname_spec\"`
melunko@917
  3745
		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
melunko@917
  3746
		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
melunko@917
  3747
		  for potent_lib in $potential_libs; do
melunko@917
  3748
		    potlib="$potent_lib" # see symlink-check above in file_magic test
melunko@917
  3749
		    if eval $echo \"$potent_lib\" 2>/dev/null \
melunko@917
  3750
		        | ${SED} 10q \
melunko@917
  3751
		        | $EGREP "$match_pattern_regex" > /dev/null; then
melunko@917
  3752
		      newdeplibs="$newdeplibs $a_deplib"
melunko@917
  3753
		      a_deplib=""
melunko@917
  3754
		      break 2
melunko@917
  3755
		    fi
melunko@917
  3756
		  done
melunko@917
  3757
		done
melunko@917
  3758
	      fi
melunko@917
  3759
	      if test -n "$a_deplib" ; then
melunko@917
  3760
		droppeddeps=yes
melunko@917
  3761
		$echo
melunko@917
  3762
		$echo "*** Warning: linker path does not have real file for library $a_deplib."
melunko@917
  3763
		$echo "*** I have the capability to make that library automatically link in when"
melunko@917
  3764
		$echo "*** you link to this library.  But I can only do this if you have a"
melunko@917
  3765
		$echo "*** shared version of the library, which you do not appear to have"
melunko@917
  3766
		$echo "*** because I did check the linker path looking for a file starting"
melunko@917
  3767
		if test -z "$potlib" ; then
melunko@917
  3768
		  $echo "*** with $libname but no candidates were found. (...for regex pattern test)"
melunko@917
  3769
		else
melunko@917
  3770
		  $echo "*** with $libname and none of the candidates passed a file format test"
melunko@917
  3771
		  $echo "*** using a regex pattern. Last file checked: $potlib"
melunko@917
  3772
		fi
melunko@917
  3773
	      fi
melunko@917
  3774
	    else
melunko@917
  3775
	      # Add a -L argument.
melunko@917
  3776
	      newdeplibs="$newdeplibs $a_deplib"
melunko@917
  3777
	    fi
melunko@917
  3778
	  done # Gone through all deplibs.
melunko@917
  3779
	  ;;
melunko@917
  3780
	none | unknown | *)
melunko@917
  3781
	  newdeplibs=""
melunko@917
  3782
	  tmp_deplibs=`$echo "X $deplibs" | $Xsed -e 's/ -lc$//' \
melunko@917
  3783
	    -e 's/ -[LR][^ ]*//g'`
melunko@917
  3784
	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
melunko@917
  3785
	    for i in $predeps $postdeps ; do
melunko@917
  3786
	      # can't use Xsed below, because $i might contain '/'
melunko@917
  3787
	      tmp_deplibs=`$echo "X $tmp_deplibs" | ${SED} -e "1s,^X,," -e "s,$i,,"`
melunko@917
  3788
	    done
melunko@917
  3789
	  fi
melunko@917
  3790
	  if $echo "X $tmp_deplibs" | $Xsed -e 's/[ 	]//g' \
melunko@917
  3791
	    | grep . >/dev/null; then
melunko@917
  3792
	    $echo
melunko@917
  3793
	    if test "X$deplibs_check_method" = "Xnone"; then
melunko@917
  3794
	      $echo "*** Warning: inter-library dependencies are not supported in this platform."
melunko@917
  3795
	    else
melunko@917
  3796
	      $echo "*** Warning: inter-library dependencies are not known to be supported."
melunko@917
  3797
	    fi
melunko@917
  3798
	    $echo "*** All declared inter-library dependencies are being dropped."
melunko@917
  3799
	    droppeddeps=yes
melunko@917
  3800
	  fi
melunko@917
  3801
	  ;;
melunko@917
  3802
	esac
melunko@917
  3803
	versuffix=$versuffix_save
melunko@917
  3804
	major=$major_save
melunko@917
  3805
	release=$release_save
melunko@917
  3806
	libname=$libname_save
melunko@917
  3807
	name=$name_save
melunko@917
  3808
melunko@917
  3809
	case $host in
melunko@917
  3810
	*-*-rhapsody* | *-*-darwin1.[012])
melunko@917
  3811
	  # On Rhapsody replace the C library is the System framework
melunko@917
  3812
	  newdeplibs=`$echo "X $newdeplibs" | $Xsed -e 's/ -lc / -framework System /'`
melunko@917
  3813
	  ;;
melunko@917
  3814
	esac
melunko@917
  3815
melunko@917
  3816
	if test "$droppeddeps" = yes; then
melunko@917
  3817
	  if test "$module" = yes; then
melunko@917
  3818
	    $echo
melunko@917
  3819
	    $echo "*** Warning: libtool could not satisfy all declared inter-library"
melunko@917
  3820
	    $echo "*** dependencies of module $libname.  Therefore, libtool will create"
melunko@917
  3821
	    $echo "*** a static module, that should work as long as the dlopening"
melunko@917
  3822
	    $echo "*** application is linked with the -dlopen flag."
melunko@917
  3823
	    if test -z "$global_symbol_pipe"; then
melunko@917
  3824
	      $echo
melunko@917
  3825
	      $echo "*** However, this would only work if libtool was able to extract symbol"
melunko@917
  3826
	      $echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
melunko@917
  3827
	      $echo "*** not find such a program.  So, this module is probably useless."
melunko@917
  3828
	      $echo "*** \`nm' from GNU binutils and a full rebuild may help."
melunko@917
  3829
	    fi
melunko@917
  3830
	    if test "$build_old_libs" = no; then
melunko@917
  3831
	      oldlibs="$output_objdir/$libname.$libext"
melunko@917
  3832
	      build_libtool_libs=module
melunko@917
  3833
	      build_old_libs=yes
melunko@917
  3834
	    else
melunko@917
  3835
	      build_libtool_libs=no
melunko@917
  3836
	    fi
melunko@917
  3837
	  else
melunko@917
  3838
	    $echo "*** The inter-library dependencies that have been dropped here will be"
melunko@917
  3839
	    $echo "*** automatically added whenever a program is linked with this library"
melunko@917
  3840
	    $echo "*** or is declared to -dlopen it."
melunko@917
  3841
melunko@917
  3842
	    if test "$allow_undefined" = no; then
melunko@917
  3843
	      $echo
melunko@917
  3844
	      $echo "*** Since this library must not contain undefined symbols,"
melunko@917
  3845
	      $echo "*** because either the platform does not support them or"
melunko@917
  3846
	      $echo "*** it was explicitly requested with -no-undefined,"
melunko@917
  3847
	      $echo "*** libtool will only create a static version of it."
melunko@917
  3848
	      if test "$build_old_libs" = no; then
melunko@917
  3849
		oldlibs="$output_objdir/$libname.$libext"
melunko@917
  3850
		build_libtool_libs=module
melunko@917
  3851
		build_old_libs=yes
melunko@917
  3852
	      else
melunko@917
  3853
		build_libtool_libs=no
melunko@917
  3854
	      fi
melunko@917
  3855
	    fi
melunko@917
  3856
	  fi
melunko@917
  3857
	fi
melunko@917
  3858
	# Done checking deplibs!
melunko@917
  3859
	deplibs=$newdeplibs
melunko@917
  3860
      fi
melunko@917
  3861
melunko@917
  3862
melunko@917
  3863
      # move library search paths that coincide with paths to not yet
melunko@917
  3864
      # installed libraries to the beginning of the library search list
melunko@917
  3865
      new_libs=
melunko@917
  3866
      for path in $notinst_path; do
melunko@917
  3867
	case " $new_libs " in
melunko@917
  3868
	*" -L$path/$objdir "*) ;;
melunko@917
  3869
	*)
melunko@917
  3870
	  case " $deplibs " in
melunko@917
  3871
	  *" -L$path/$objdir "*)
melunko@917
  3872
	    new_libs="$new_libs -L$path/$objdir" ;;
melunko@917
  3873
	  esac
melunko@917
  3874
	  ;;
melunko@917
  3875
	esac
melunko@917
  3876
      done
melunko@917
  3877
      for deplib in $deplibs; do
melunko@917
  3878
	case $deplib in
melunko@917
  3879
	-L*)
melunko@917
  3880
	  case " $new_libs " in
melunko@917
  3881
	  *" $deplib "*) ;;
melunko@917
  3882
	  *) new_libs="$new_libs $deplib" ;;
melunko@917
  3883
	  esac
melunko@917
  3884
	  ;;
melunko@917
  3885
	*) new_libs="$new_libs $deplib" ;;
melunko@917
  3886
	esac
melunko@917
  3887
      done
melunko@917
  3888
      deplibs="$new_libs"
melunko@917
  3889
melunko@917
  3890
melunko@917
  3891
      # All the library-specific variables (install_libdir is set above).
melunko@917
  3892
      library_names=
melunko@917
  3893
      old_library=
melunko@917
  3894
      dlname=
melunko@917
  3895
melunko@917
  3896
      # Test again, we may have decided not to build it any more
melunko@917
  3897
      if test "$build_libtool_libs" = yes; then
melunko@917
  3898
	if test "$hardcode_into_libs" = yes; then
melunko@917
  3899
	  # Hardcode the library paths
melunko@917
  3900
	  hardcode_libdirs=
melunko@917
  3901
	  dep_rpath=
melunko@917
  3902
	  rpath="$finalize_rpath"
melunko@917
  3903
	  test "$mode" != relink && rpath="$compile_rpath$rpath"
melunko@917
  3904
	  for libdir in $rpath; do
melunko@917
  3905
	    if test -n "$hardcode_libdir_flag_spec"; then
melunko@917
  3906
	      if test -n "$hardcode_libdir_separator"; then
melunko@917
  3907
		if test -z "$hardcode_libdirs"; then
melunko@917
  3908
		  hardcode_libdirs="$libdir"
melunko@917
  3909
		else
melunko@917
  3910
		  # Just accumulate the unique libdirs.
melunko@917
  3911
		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
melunko@917
  3912
		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
melunko@917
  3913
		    ;;
melunko@917
  3914
		  *)
melunko@917
  3915
		    hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
melunko@917
  3916
		    ;;
melunko@917
  3917
		  esac
melunko@917
  3918
		fi
melunko@917
  3919
	      else
melunko@917
  3920
		eval flag=\"$hardcode_libdir_flag_spec\"
melunko@917
  3921
		dep_rpath="$dep_rpath $flag"
melunko@917
  3922
	      fi
melunko@917
  3923
	    elif test -n "$runpath_var"; then
melunko@917
  3924
	      case "$perm_rpath " in
melunko@917
  3925
	      *" $libdir "*) ;;
melunko@917
  3926
	      *) perm_rpath="$perm_rpath $libdir" ;;
melunko@917
  3927
	      esac
melunko@917
  3928
	    fi
melunko@917
  3929
	  done
melunko@917
  3930
	  # Substitute the hardcoded libdirs into the rpath.
melunko@917
  3931
	  if test -n "$hardcode_libdir_separator" &&
melunko@917
  3932
	     test -n "$hardcode_libdirs"; then
melunko@917
  3933
	    libdir="$hardcode_libdirs"
melunko@917
  3934
	    if test -n "$hardcode_libdir_flag_spec_ld"; then
melunko@917
  3935
	      case $archive_cmds in
melunko@917
  3936
	      *\$LD*) eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\" ;;
melunko@917
  3937
	      *)      eval dep_rpath=\"$hardcode_libdir_flag_spec\" ;;
melunko@917
  3938
	      esac
melunko@917
  3939
	    else
melunko@917
  3940
	      eval dep_rpath=\"$hardcode_libdir_flag_spec\"
melunko@917
  3941
	    fi
melunko@917
  3942
	  fi
melunko@917
  3943
	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
melunko@917
  3944
	    # We should set the runpath_var.
melunko@917
  3945
	    rpath=
melunko@917
  3946
	    for dir in $perm_rpath; do
melunko@917
  3947
	      rpath="$rpath$dir:"
melunko@917
  3948
	    done
melunko@917
  3949
	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
melunko@917
  3950
	  fi
melunko@917
  3951
	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
melunko@917
  3952
	fi
melunko@917
  3953
melunko@917
  3954
	shlibpath="$finalize_shlibpath"
melunko@917
  3955
	test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
melunko@917
  3956
	if test -n "$shlibpath"; then
melunko@917
  3957
	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
melunko@917
  3958
	fi
melunko@917
  3959
melunko@917
  3960
	# Get the real and link names of the library.
melunko@917
  3961
	eval shared_ext=\"$shrext_cmds\"
melunko@917
  3962
	eval library_names=\"$library_names_spec\"
melunko@917
  3963
	set dummy $library_names
melunko@917
  3964
	realname="$2"
melunko@917
  3965
	shift; shift
melunko@917
  3966
melunko@917
  3967
	if test -n "$soname_spec"; then
melunko@917
  3968
	  eval soname=\"$soname_spec\"
melunko@917
  3969
	else
melunko@917
  3970
	  soname="$realname"
melunko@917
  3971
	fi
melunko@917
  3972
	if test -z "$dlname"; then
melunko@917
  3973
	  dlname=$soname
melunko@917
  3974
	fi
melunko@917
  3975
melunko@917
  3976
	lib="$output_objdir/$realname"
melunko@917
  3977
	linknames=
melunko@917
  3978
	for link
melunko@917
  3979
	do
melunko@917
  3980
	  linknames="$linknames $link"
melunko@917
  3981
	done
melunko@917
  3982
melunko@917
  3983
	# Use standard objects if they are pic
melunko@917
  3984
	test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
melunko@917
  3985
melunko@917
  3986
	# Prepare the list of exported symbols
melunko@917
  3987
	if test -z "$export_symbols"; then
melunko@917
  3988
	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
melunko@917
  3989
	    $show "generating symbol list for \`$libname.la'"
melunko@917
  3990
	    export_symbols="$output_objdir/$libname.exp"
melunko@917
  3991
	    $run $rm $export_symbols
melunko@917
  3992
	    cmds=$export_symbols_cmds
melunko@917
  3993
	    save_ifs="$IFS"; IFS='~'
melunko@917
  3994
	    for cmd in $cmds; do
melunko@917
  3995
	      IFS="$save_ifs"
melunko@917
  3996
	      eval cmd=\"$cmd\"
melunko@917
  3997
	      if len=`expr "X$cmd" : ".*"` &&
melunko@917
  3998
	       test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
melunko@917
  3999
	        $show "$cmd"
melunko@917
  4000
	        $run eval "$cmd" || exit $?
melunko@917
  4001
	        skipped_export=false
melunko@917
  4002
	      else
melunko@917
  4003
	        # The command line is too long to execute in one step.
melunko@917
  4004
	        $show "using reloadable object file for export list..."
melunko@917
  4005
	        skipped_export=:
melunko@917
  4006
		# Break out early, otherwise skipped_export may be
melunko@917
  4007
		# set to false by a later but shorter cmd.
melunko@917
  4008
		break
melunko@917
  4009
	      fi
melunko@917
  4010
	    done
melunko@917
  4011
	    IFS="$save_ifs"
melunko@917
  4012
	    if test -n "$export_symbols_regex"; then
melunko@917
  4013
	      $show "$EGREP -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\""
melunko@917
  4014
	      $run eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
melunko@917
  4015
	      $show "$mv \"${export_symbols}T\" \"$export_symbols\""
melunko@917
  4016
	      $run eval '$mv "${export_symbols}T" "$export_symbols"'
melunko@917
  4017
	    fi
melunko@917
  4018
	  fi
melunko@917
  4019
	fi
melunko@917
  4020
melunko@917
  4021
	if test -n "$export_symbols" && test -n "$include_expsyms"; then
melunko@917
  4022
	  $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"'
melunko@917
  4023
	fi
melunko@917
  4024
melunko@917
  4025
	tmp_deplibs=
melunko@917
  4026
	for test_deplib in $deplibs; do
melunko@917
  4027
		case " $convenience " in
melunko@917
  4028
		*" $test_deplib "*) ;;
melunko@917
  4029
		*)
melunko@917
  4030
			tmp_deplibs="$tmp_deplibs $test_deplib"
melunko@917
  4031
			;;
melunko@917
  4032
		esac
melunko@917
  4033
	done
melunko@917
  4034
	deplibs="$tmp_deplibs"
melunko@917
  4035
melunko@917
  4036
	if test -n "$convenience"; then
melunko@917
  4037
	  if test -n "$whole_archive_flag_spec"; then
melunko@917
  4038
	    save_libobjs=$libobjs
melunko@917
  4039
	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
melunko@917
  4040
	  else
melunko@917
  4041
	    gentop="$output_objdir/${outputname}x"
melunko@917
  4042
	    generated="$generated $gentop"
melunko@917
  4043
melunko@917
  4044
	    func_extract_archives $gentop $convenience
melunko@917
  4045
	    libobjs="$libobjs $func_extract_archives_result"
melunko@917
  4046
	  fi
melunko@917
  4047
	fi
melunko@917
  4048
	
melunko@917
  4049
	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
melunko@917
  4050
	  eval flag=\"$thread_safe_flag_spec\"
melunko@917
  4051
	  linker_flags="$linker_flags $flag"
melunko@917
  4052
	fi
melunko@917
  4053
melunko@917
  4054
	# Make a backup of the uninstalled library when relinking
melunko@917
  4055
	if test "$mode" = relink; then
melunko@917
  4056
	  $run eval '(cd $output_objdir && $rm ${realname}U && $mv $realname ${realname}U)' || exit $?
melunko@917
  4057
	fi
melunko@917
  4058
melunko@917
  4059
	# Do each of the archive commands.
melunko@917
  4060
	if test "$module" = yes && test -n "$module_cmds" ; then
melunko@917
  4061
	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
melunko@917
  4062
	    eval test_cmds=\"$module_expsym_cmds\"
melunko@917
  4063
	    cmds=$module_expsym_cmds
melunko@917
  4064
	  else
melunko@917
  4065
	    eval test_cmds=\"$module_cmds\"
melunko@917
  4066
	    cmds=$module_cmds
melunko@917
  4067
	  fi
melunko@917
  4068
	else
melunko@917
  4069
	if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
melunko@917
  4070
	  eval test_cmds=\"$archive_expsym_cmds\"
melunko@917
  4071
	  cmds=$archive_expsym_cmds
melunko@917
  4072
	else
melunko@917
  4073
	  eval test_cmds=\"$archive_cmds\"
melunko@917
  4074
	  cmds=$archive_cmds
melunko@917
  4075
	  fi
melunko@917
  4076
	fi
melunko@917
  4077
melunko@917
  4078
	if test "X$skipped_export" != "X:" &&
melunko@917
  4079
	   len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
melunko@917
  4080
	   test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
melunko@917
  4081
	  :
melunko@917
  4082
	else
melunko@917
  4083
	  # The command line is too long to link in one step, link piecewise.
melunko@917
  4084
	  $echo "creating reloadable object files..."
melunko@917
  4085
melunko@917
  4086
	  # Save the value of $output and $libobjs because we want to
melunko@917
  4087
	  # use them later.  If we have whole_archive_flag_spec, we
melunko@917
  4088
	  # want to use save_libobjs as it was before
melunko@917
  4089
	  # whole_archive_flag_spec was expanded, because we can't
melunko@917
  4090
	  # assume the linker understands whole_archive_flag_spec.
melunko@917
  4091
	  # This may have to be revisited, in case too many
melunko@917
  4092
	  # convenience libraries get linked in and end up exceeding
melunko@917
  4093
	  # the spec.
melunko@917
  4094
	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
melunko@917
  4095
	    save_libobjs=$libobjs
melunko@917
  4096
	  fi
melunko@917
  4097
	  save_output=$output
melunko@917
  4098
	  output_la=`$echo "X$output" | $Xsed -e "$basename"`
melunko@917
  4099
melunko@917
  4100
	  # Clear the reloadable object creation command queue and
melunko@917
  4101
	  # initialize k to one.
melunko@917
  4102
	  test_cmds=
melunko@917
  4103
	  concat_cmds=
melunko@917
  4104
	  objlist=
melunko@917
  4105
	  delfiles=
melunko@917
  4106
	  last_robj=
melunko@917
  4107
	  k=1
melunko@917
  4108
	  output=$output_objdir/$output_la-${k}.$objext
melunko@917
  4109
	  # Loop over the list of objects to be linked.
melunko@917
  4110
	  for obj in $save_libobjs
melunko@917
  4111
	  do
melunko@917
  4112
	    eval test_cmds=\"$reload_cmds $objlist $last_robj\"
melunko@917
  4113
	    if test "X$objlist" = X ||
melunko@917
  4114
	       { len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
melunko@917
  4115
		 test "$len" -le "$max_cmd_len"; }; then
melunko@917
  4116
	      objlist="$objlist $obj"
melunko@917
  4117
	    else
melunko@917
  4118
	      # The command $test_cmds is almost too long, add a
melunko@917
  4119
	      # command to the queue.
melunko@917
  4120
	      if test "$k" -eq 1 ; then
melunko@917
  4121
		# The first file doesn't have a previous command to add.
melunko@917
  4122
		eval concat_cmds=\"$reload_cmds $objlist $last_robj\"
melunko@917
  4123
	      else
melunko@917
  4124
		# All subsequent reloadable object files will link in
melunko@917
  4125
		# the last one created.
melunko@917
  4126
		eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj\"
melunko@917
  4127
	      fi
melunko@917
  4128
	      last_robj=$output_objdir/$output_la-${k}.$objext
melunko@917
  4129
	      k=`expr $k + 1`
melunko@917
  4130
	      output=$output_objdir/$output_la-${k}.$objext
melunko@917
  4131
	      objlist=$obj
melunko@917
  4132
	      len=1
melunko@917
  4133
	    fi
melunko@917
  4134
	  done
melunko@917
  4135
	  # Handle the remaining objects by creating one last
melunko@917
  4136
	  # reloadable object file.  All subsequent reloadable object
melunko@917
  4137
	  # files will link in the last one created.
melunko@917
  4138
	  test -z "$concat_cmds" || concat_cmds=$concat_cmds~
melunko@917
  4139
	  eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\"
melunko@917
  4140
melunko@917
  4141
	  if ${skipped_export-false}; then
melunko@917
  4142
	    $show "generating symbol list for \`$libname.la'"
melunko@917
  4143
	    export_symbols="$output_objdir/$libname.exp"
melunko@917
  4144
	    $run $rm $export_symbols
melunko@917
  4145
	    libobjs=$output
melunko@917
  4146
	    # Append the command to create the export file.
melunko@917
  4147
	    eval concat_cmds=\"\$concat_cmds~$export_symbols_cmds\"
melunko@917
  4148
          fi
melunko@917
  4149
melunko@917
  4150
	  # Set up a command to remove the reloadable object files
melunko@917
  4151
	  # after they are used.
melunko@917
  4152
	  i=0
melunko@917
  4153
	  while test "$i" -lt "$k"
melunko@917
  4154
	  do
melunko@917
  4155
	    i=`expr $i + 1`
melunko@917
  4156
	    delfiles="$delfiles $output_objdir/$output_la-${i}.$objext"
melunko@917
  4157
	  done
melunko@917
  4158
melunko@917
  4159
	  $echo "creating a temporary reloadable object file: $output"
melunko@917
  4160
melunko@917
  4161
	  # Loop through the commands generated above and execute them.
melunko@917
  4162
	  save_ifs="$IFS"; IFS='~'
melunko@917
  4163
	  for cmd in $concat_cmds; do
melunko@917
  4164
	    IFS="$save_ifs"
melunko@917
  4165
	    $show "$cmd"
melunko@917
  4166
	    $run eval "$cmd" || exit $?
melunko@917
  4167
	  done
melunko@917
  4168
	  IFS="$save_ifs"
melunko@917
  4169
melunko@917
  4170
	  libobjs=$output
melunko@917
  4171
	  # Restore the value of output.
melunko@917
  4172
	  output=$save_output
melunko@917
  4173
melunko@917
  4174
	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
melunko@917
  4175
	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
melunko@917
  4176
	  fi
melunko@917
  4177
	  # Expand the library linking commands again to reset the
melunko@917
  4178
	  # value of $libobjs for piecewise linking.
melunko@917
  4179
melunko@917
  4180
	  # Do each of the archive commands.
melunko@917
  4181
	  if test "$module" = yes && test -n "$module_cmds" ; then
melunko@917
  4182
	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
melunko@917
  4183
	      cmds=$module_expsym_cmds
melunko@917
  4184
	    else
melunko@917
  4185
	      cmds=$module_cmds
melunko@917
  4186
	    fi
melunko@917
  4187
	  else
melunko@917
  4188
	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
melunko@917
  4189
	    cmds=$archive_expsym_cmds
melunko@917
  4190
	  else
melunko@917
  4191
	    cmds=$archive_cmds
melunko@917
  4192
	    fi
melunko@917
  4193
	  fi
melunko@917
  4194
melunko@917
  4195
	  # Append the command to remove the reloadable object files
melunko@917
  4196
	  # to the just-reset $cmds.
melunko@917
  4197
	  eval cmds=\"\$cmds~\$rm $delfiles\"
melunko@917
  4198
	fi
melunko@917
  4199
	save_ifs="$IFS"; IFS='~'
melunko@917
  4200
	for cmd in $cmds; do
melunko@917
  4201
	  IFS="$save_ifs"
melunko@917
  4202
	  eval cmd=\"$cmd\"
melunko@917
  4203
	  $show "$cmd"
melunko@917
  4204
	  $run eval "$cmd" || {
melunko@917
  4205
	    lt_exit=$?
melunko@917
  4206
melunko@917
  4207
	    # Restore the uninstalled library and exit
melunko@917
  4208
	    if test "$mode" = relink; then
melunko@917
  4209
	      $run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)'
melunko@917
  4210
	    fi
melunko@917
  4211
melunko@917
  4212
	    exit $lt_exit
melunko@917
  4213
	  }
melunko@917
  4214
	done
melunko@917
  4215
	IFS="$save_ifs"
melunko@917
  4216
melunko@917
  4217
	# Restore the uninstalled library and exit
melunko@917
  4218
	if test "$mode" = relink; then
melunko@917
  4219
	  $run eval '(cd $output_objdir && $rm ${realname}T && $mv $realname ${realname}T && $mv "$realname"U $realname)' || exit $?
melunko@917
  4220
melunko@917
  4221
	  if test -n "$convenience"; then
melunko@917
  4222
	    if test -z "$whole_archive_flag_spec"; then
melunko@917
  4223
	      $show "${rm}r $gentop"
melunko@917
  4224
	      $run ${rm}r "$gentop"
melunko@917
  4225
	    fi
melunko@917
  4226
	  fi
melunko@917
  4227
melunko@917
  4228
	  exit $EXIT_SUCCESS
melunko@917
  4229
	fi
melunko@917
  4230
melunko@917
  4231
	# Create links to the real library.
melunko@917
  4232
	for linkname in $linknames; do
melunko@917
  4233
	  if test "$realname" != "$linkname"; then
melunko@917
  4234
	    $show "(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)"
melunko@917
  4235
	    $run eval '(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)' || exit $?
melunko@917
  4236
	  fi
melunko@917
  4237
	done
melunko@917
  4238
melunko@917
  4239
	# If -module or -export-dynamic was specified, set the dlname.
melunko@917
  4240
	if test "$module" = yes || test "$export_dynamic" = yes; then
melunko@917
  4241
	  # On all known operating systems, these are identical.
melunko@917
  4242
	  dlname="$soname"
melunko@917
  4243
	fi
melunko@917
  4244
      fi
melunko@917
  4245
      ;;
melunko@917
  4246
melunko@917
  4247
    obj)
melunko@917
  4248
      if test -n "$deplibs"; then
melunko@917
  4249
	$echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2
melunko@917
  4250
      fi
melunko@917
  4251
melunko@917
  4252
      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
melunko@917
  4253
	$echo "$modename: warning: \`-dlopen' is ignored for objects" 1>&2
melunko@917
  4254
      fi
melunko@917
  4255
melunko@917
  4256
      if test -n "$rpath"; then
melunko@917
  4257
	$echo "$modename: warning: \`-rpath' is ignored for objects" 1>&2
melunko@917
  4258
      fi
melunko@917
  4259
melunko@917
  4260
      if test -n "$xrpath"; then
melunko@917
  4261
	$echo "$modename: warning: \`-R' is ignored for objects" 1>&2
melunko@917
  4262
      fi
melunko@917
  4263
melunko@917
  4264
      if test -n "$vinfo"; then
melunko@917
  4265
	$echo "$modename: warning: \`-version-info' is ignored for objects" 1>&2
melunko@917
  4266
      fi
melunko@917
  4267
melunko@917
  4268
      if test -n "$release"; then
melunko@917
  4269
	$echo "$modename: warning: \`-release' is ignored for objects" 1>&2
melunko@917
  4270
      fi
melunko@917
  4271
melunko@917
  4272
      case $output in
melunko@917
  4273
      *.lo)
melunko@917
  4274
	if test -n "$objs$old_deplibs"; then
melunko@917
  4275
	  $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2
melunko@917
  4276
	  exit $EXIT_FAILURE
melunko@917
  4277
	fi
melunko@917
  4278
	libobj="$output"
melunko@917
  4279
	obj=`$echo "X$output" | $Xsed -e "$lo2o"`
melunko@917
  4280
	;;
melunko@917
  4281
      *)
melunko@917
  4282
	libobj=
melunko@917
  4283
	obj="$output"
melunko@917
  4284
	;;
melunko@917
  4285
      esac
melunko@917
  4286
melunko@917
  4287
      # Delete the old objects.
melunko@917
  4288
      $run $rm $obj $libobj
melunko@917
  4289
melunko@917
  4290
      # Objects from convenience libraries.  This assumes
melunko@917
  4291
      # single-version convenience libraries.  Whenever we create
melunko@917
  4292
      # different ones for PIC/non-PIC, this we'll have to duplicate
melunko@917
  4293
      # the extraction.
melunko@917
  4294
      reload_conv_objs=
melunko@917
  4295
      gentop=
melunko@917
  4296
      # reload_cmds runs $LD directly, so let us get rid of
melunko@917
  4297
      # -Wl from whole_archive_flag_spec and hope we can get by with
melunko@917
  4298
      # turning comma into space..
melunko@917
  4299
      wl=
melunko@917
  4300
melunko@917
  4301
      if test -n "$convenience"; then
melunko@917
  4302
	if test -n "$whole_archive_flag_spec"; then
melunko@917
  4303
	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
melunko@917
  4304
	  reload_conv_objs=$reload_objs\ `$echo "X$tmp_whole_archive_flags" | $Xsed -e 's|,| |g'`
melunko@917
  4305
	else
melunko@917
  4306
	  gentop="$output_objdir/${obj}x"
melunko@917
  4307
	  generated="$generated $gentop"
melunko@917
  4308
melunko@917
  4309
	  func_extract_archives $gentop $convenience
melunko@917
  4310
	  reload_conv_objs="$reload_objs $func_extract_archives_result"
melunko@917
  4311
	fi
melunko@917
  4312
      fi
melunko@917
  4313
melunko@917
  4314
      # Create the old-style object.
melunko@917
  4315
      reload_objs="$objs$old_deplibs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
melunko@917
  4316
melunko@917
  4317
      output="$obj"
melunko@917
  4318
      cmds=$reload_cmds
melunko@917
  4319
      save_ifs="$IFS"; IFS='~'
melunko@917
  4320
      for cmd in $cmds; do
melunko@917
  4321
	IFS="$save_ifs"
melunko@917
  4322
	eval cmd=\"$cmd\"
melunko@917
  4323
	$show "$cmd"
melunko@917
  4324
	$run eval "$cmd" || exit $?
melunko@917
  4325
      done
melunko@917
  4326
      IFS="$save_ifs"
melunko@917
  4327
melunko@917
  4328
      # Exit if we aren't doing a library object file.
melunko@917
  4329
      if test -z "$libobj"; then
melunko@917
  4330
	if test -n "$gentop"; then
melunko@917
  4331
	  $show "${rm}r $gentop"
melunko@917
  4332
	  $run ${rm}r $gentop
melunko@917
  4333
	fi
melunko@917
  4334
melunko@917
  4335
	exit $EXIT_SUCCESS
melunko@917
  4336
      fi
melunko@917
  4337
melunko@917
  4338
      if test "$build_libtool_libs" != yes; then
melunko@917
  4339
	if test -n "$gentop"; then
melunko@917
  4340
	  $show "${rm}r $gentop"
melunko@917
  4341
	  $run ${rm}r $gentop
melunko@917
  4342
	fi
melunko@917
  4343
melunko@917
  4344
	# Create an invalid libtool object if no PIC, so that we don't
melunko@917
  4345
	# accidentally link it into a program.
melunko@917
  4346
	# $show "echo timestamp > $libobj"
melunko@917
  4347
	# $run eval "echo timestamp > $libobj" || exit $?
melunko@917
  4348
	exit $EXIT_SUCCESS
melunko@917
  4349
      fi
melunko@917
  4350
melunko@917
  4351
      if test -n "$pic_flag" || test "$pic_mode" != default; then
melunko@917
  4352
	# Only do commands if we really have different PIC objects.
melunko@917
  4353
	reload_objs="$libobjs $reload_conv_objs"
melunko@917
  4354
	output="$libobj"
melunko@917
  4355
	cmds=$reload_cmds
melunko@917
  4356
	save_ifs="$IFS"; IFS='~'
melunko@917
  4357
	for cmd in $cmds; do
melunko@917
  4358
	  IFS="$save_ifs"
melunko@917
  4359
	  eval cmd=\"$cmd\"
melunko@917
  4360
	  $show "$cmd"
melunko@917
  4361
	  $run eval "$cmd" || exit $?
melunko@917
  4362
	done
melunko@917
  4363
	IFS="$save_ifs"
melunko@917
  4364
      fi
melunko@917
  4365
melunko@917
  4366
      if test -n "$gentop"; then
melunko@917
  4367
	$show "${rm}r $gentop"
melunko@917
  4368
	$run ${rm}r $gentop
melunko@917
  4369
      fi
melunko@917
  4370
melunko@917
  4371
      exit $EXIT_SUCCESS
melunko@917
  4372
      ;;
melunko@917
  4373
melunko@917
  4374
    prog)
melunko@917
  4375
      case $host in
melunko@917
  4376
	*cygwin*) output=`$echo $output | ${SED} -e 's,.exe$,,;s,$,.exe,'` ;;
melunko@917
  4377
      esac
melunko@917
  4378
      if test -n "$vinfo"; then
melunko@917
  4379
	$echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2
melunko@917
  4380
      fi
melunko@917
  4381
melunko@917
  4382
      if test -n "$release"; then
melunko@917
  4383
	$echo "$modename: warning: \`-release' is ignored for programs" 1>&2
melunko@917
  4384
      fi
melunko@917
  4385
melunko@917
  4386
      if test "$preload" = yes; then
melunko@917
  4387
	if test "$dlopen_support" = unknown && test "$dlopen_self" = unknown &&
melunko@917
  4388
	   test "$dlopen_self_static" = unknown; then
melunko@917
  4389
	  $echo "$modename: warning: \`AC_LIBTOOL_DLOPEN' not used. Assuming no dlopen support."
melunko@917
  4390
	fi
melunko@917
  4391
      fi
melunko@917
  4392
melunko@917
  4393
      case $host in
melunko@917
  4394
      *-*-rhapsody* | *-*-darwin1.[012])
melunko@917
  4395
	# On Rhapsody replace the C library is the System framework
melunko@917
  4396
	compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
melunko@917
  4397
	finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
melunko@917
  4398
	;;
melunko@917
  4399
      esac
melunko@917
  4400
melunko@917
  4401
      case $host in
melunko@917
  4402
      *darwin*)
melunko@917
  4403
        # Don't allow lazy linking, it breaks C++ global constructors
melunko@917
  4404
        if test "$tagname" = CXX ; then
melunko@917
  4405
        compile_command="$compile_command ${wl}-bind_at_load"
melunko@917
  4406
        finalize_command="$finalize_command ${wl}-bind_at_load"
melunko@917
  4407
        fi
melunko@917
  4408
        ;;
melunko@917
  4409
      esac
melunko@917
  4410
melunko@917
  4411
melunko@917
  4412
      # move library search paths that coincide with paths to not yet
melunko@917
  4413
      # installed libraries to the beginning of the library search list
melunko@917
  4414
      new_libs=
melunko@917
  4415
      for path in $notinst_path; do
melunko@917
  4416
	case " $new_libs " in
melunko@917
  4417
	*" -L$path/$objdir "*) ;;
melunko@917
  4418
	*)
melunko@917
  4419
	  case " $compile_deplibs " in
melunko@917
  4420
	  *" -L$path/$objdir "*)
melunko@917
  4421
	    new_libs="$new_libs -L$path/$objdir" ;;
melunko@917
  4422
	  esac
melunko@917
  4423
	  ;;
melunko@917
  4424
	esac
melunko@917
  4425
      done
melunko@917
  4426
      for deplib in $compile_deplibs; do
melunko@917
  4427
	case $deplib in
melunko@917
  4428
	-L*)
melunko@917
  4429
	  case " $new_libs " in
melunko@917
  4430
	  *" $deplib "*) ;;
melunko@917
  4431
	  *) new_libs="$new_libs $deplib" ;;
melunko@917
  4432
	  esac
melunko@917
  4433
	  ;;
melunko@917
  4434
	*) new_libs="$new_libs $deplib" ;;
melunko@917
  4435
	esac
melunko@917
  4436
      done
melunko@917
  4437
      compile_deplibs="$new_libs"
melunko@917
  4438
melunko@917
  4439
melunko@917
  4440
      compile_command="$compile_command $compile_deplibs"
melunko@917
  4441
      finalize_command="$finalize_command $finalize_deplibs"
melunko@917
  4442
melunko@917
  4443
      if test -n "$rpath$xrpath"; then
melunko@917
  4444
	# If the user specified any rpath flags, then add them.
melunko@917
  4445
	for libdir in $rpath $xrpath; do
melunko@917
  4446
	  # This is the magic to use -rpath.
melunko@917
  4447
	  case "$finalize_rpath " in
melunko@917
  4448
	  *" $libdir "*) ;;
melunko@917
  4449
	  *) finalize_rpath="$finalize_rpath $libdir" ;;
melunko@917
  4450
	  esac
melunko@917
  4451
	done
melunko@917
  4452
      fi
melunko@917
  4453
melunko@917
  4454
      # Now hardcode the library paths
melunko@917
  4455
      rpath=
melunko@917
  4456
      hardcode_libdirs=
melunko@917
  4457
      for libdir in $compile_rpath $finalize_rpath; do
melunko@917
  4458
	if test -n "$hardcode_libdir_flag_spec"; then
melunko@917
  4459
	  if test -n "$hardcode_libdir_separator"; then
melunko@917
  4460
	    if test -z "$hardcode_libdirs"; then
melunko@917
  4461
	      hardcode_libdirs="$libdir"
melunko@917
  4462
	    else
melunko@917
  4463
	      # Just accumulate the unique libdirs.
melunko@917
  4464
	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
melunko@917
  4465
	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
melunko@917
  4466
		;;
melunko@917
  4467
	      *)
melunko@917
  4468
		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
melunko@917
  4469
		;;
melunko@917
  4470
	      esac
melunko@917
  4471
	    fi
melunko@917
  4472
	  else
melunko@917
  4473
	    eval flag=\"$hardcode_libdir_flag_spec\"
melunko@917
  4474
	    rpath="$rpath $flag"
melunko@917
  4475
	  fi
melunko@917
  4476
	elif test -n "$runpath_var"; then
melunko@917
  4477
	  case "$perm_rpath " in
melunko@917
  4478
	  *" $libdir "*) ;;
melunko@917
  4479
	  *) perm_rpath="$perm_rpath $libdir" ;;
melunko@917
  4480
	  esac
melunko@917
  4481
	fi
melunko@917
  4482
	case $host in
melunko@917
  4483
	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
melunko@917
  4484
	  testbindir=`$echo "X$libdir" | $Xsed -e 's*/lib$*/bin*'`
melunko@917
  4485
	  case :$dllsearchpath: in
melunko@917
  4486
	  *":$libdir:"*) ;;
melunko@917
  4487
	  *) dllsearchpath="$dllsearchpath:$libdir";;
melunko@917
  4488
	  esac
melunko@917
  4489
	  case :$dllsearchpath: in
melunko@917
  4490
	  *":$testbindir:"*) ;;
melunko@917
  4491
	  *) dllsearchpath="$dllsearchpath:$testbindir";;
melunko@917
  4492
	  esac
melunko@917
  4493
	  ;;
melunko@917
  4494
	esac
melunko@917
  4495
      done
melunko@917
  4496
      # Substitute the hardcoded libdirs into the rpath.
melunko@917
  4497
      if test -n "$hardcode_libdir_separator" &&
melunko@917
  4498
	 test -n "$hardcode_libdirs"; then
melunko@917
  4499
	libdir="$hardcode_libdirs"
melunko@917
  4500
	eval rpath=\" $hardcode_libdir_flag_spec\"
melunko@917
  4501
      fi
melunko@917
  4502
      compile_rpath="$rpath"
melunko@917
  4503
melunko@917
  4504
      rpath=
melunko@917
  4505
      hardcode_libdirs=
melunko@917
  4506
      for libdir in $finalize_rpath; do
melunko@917
  4507
	if test -n "$hardcode_libdir_flag_spec"; then
melunko@917
  4508
	  if test -n "$hardcode_libdir_separator"; then
melunko@917
  4509
	    if test -z "$hardcode_libdirs"; then
melunko@917
  4510
	      hardcode_libdirs="$libdir"
melunko@917
  4511
	    else
melunko@917
  4512
	      # Just accumulate the unique libdirs.
melunko@917
  4513
	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
melunko@917
  4514
	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
melunko@917
  4515
		;;
melunko@917
  4516
	      *)
melunko@917
  4517
		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
melunko@917
  4518
		;;
melunko@917
  4519
	      esac
melunko@917
  4520
	    fi
melunko@917
  4521
	  else
melunko@917
  4522
	    eval flag=\"$hardcode_libdir_flag_spec\"
melunko@917
  4523
	    rpath="$rpath $flag"
melunko@917
  4524
	  fi
melunko@917
  4525
	elif test -n "$runpath_var"; then
melunko@917
  4526
	  case "$finalize_perm_rpath " in
melunko@917
  4527
	  *" $libdir "*) ;;
melunko@917
  4528
	  *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
melunko@917
  4529
	  esac
melunko@917
  4530
	fi
melunko@917
  4531
      done
melunko@917
  4532
      # Substitute the hardcoded libdirs into the rpath.
melunko@917
  4533
      if test -n "$hardcode_libdir_separator" &&
melunko@917
  4534
	 test -n "$hardcode_libdirs"; then
melunko@917
  4535
	libdir="$hardcode_libdirs"
melunko@917
  4536
	eval rpath=\" $hardcode_libdir_flag_spec\"
melunko@917
  4537
      fi
melunko@917
  4538
      finalize_rpath="$rpath"
melunko@917
  4539
melunko@917
  4540
      if test -n "$libobjs" && test "$build_old_libs" = yes; then
melunko@917
  4541
	# Transform all the library objects into standard objects.
melunko@917
  4542
	compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
melunko@917
  4543
	finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
melunko@917
  4544
      fi
melunko@917
  4545
melunko@917
  4546
      dlsyms=
melunko@917
  4547
      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
melunko@917
  4548
	if test -n "$NM" && test -n "$global_symbol_pipe"; then
melunko@917
  4549
	  dlsyms="${outputname}S.c"
melunko@917
  4550
	else
melunko@917
  4551
	  $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2
melunko@917
  4552
	fi
melunko@917
  4553
      fi
melunko@917
  4554
melunko@917
  4555
      if test -n "$dlsyms"; then
melunko@917
  4556
	case $dlsyms in
melunko@917
  4557
	"") ;;
melunko@917
  4558
	*.c)
melunko@917
  4559
	  # Discover the nlist of each of the dlfiles.
melunko@917
  4560
	  nlist="$output_objdir/${outputname}.nm"
melunko@917
  4561
melunko@917
  4562
	  $show "$rm $nlist ${nlist}S ${nlist}T"
melunko@917
  4563
	  $run $rm "$nlist" "${nlist}S" "${nlist}T"
melunko@917
  4564
melunko@917
  4565
	  # Parse the name list into a source file.
melunko@917
  4566
	  $show "creating $output_objdir/$dlsyms"
melunko@917
  4567
melunko@917
  4568
	  test -z "$run" && $echo > "$output_objdir/$dlsyms" "\
melunko@917
  4569
/* $dlsyms - symbol resolution table for \`$outputname' dlsym emulation. */
melunko@917
  4570
/* Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP */
melunko@917
  4571
melunko@917
  4572
#ifdef __cplusplus
melunko@917
  4573
extern \"C\" {
melunko@917
  4574
#endif
melunko@917
  4575
melunko@917
  4576
/* Prevent the only kind of declaration conflicts we can make. */
melunko@917
  4577
#define lt_preloaded_symbols some_other_symbol
melunko@917
  4578
melunko@917
  4579
/* External symbol declarations for the compiler. */\
melunko@917
  4580
"
melunko@917
  4581
melunko@917
  4582
	  if test "$dlself" = yes; then
melunko@917
  4583
	    $show "generating symbol list for \`$output'"
melunko@917
  4584
melunko@917
  4585
	    test -z "$run" && $echo ': @PROGRAM@ ' > "$nlist"
melunko@917
  4586
melunko@917
  4587
	    # Add our own program objects to the symbol list.
melunko@917
  4588
	    progfiles=`$echo "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
melunko@917
  4589
	    for arg in $progfiles; do
melunko@917
  4590
	      $show "extracting global C symbols from \`$arg'"
melunko@917
  4591
	      $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
melunko@917
  4592
	    done
melunko@917
  4593
melunko@917
  4594
	    if test -n "$exclude_expsyms"; then
melunko@917
  4595
	      $run eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
melunko@917
  4596
	      $run eval '$mv "$nlist"T "$nlist"'
melunko@917
  4597
	    fi
melunko@917
  4598
melunko@917
  4599
	    if test -n "$export_symbols_regex"; then
melunko@917
  4600
	      $run eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
melunko@917
  4601
	      $run eval '$mv "$nlist"T "$nlist"'
melunko@917
  4602
	    fi
melunko@917
  4603
melunko@917
  4604
	    # Prepare the list of exported symbols
melunko@917
  4605
	    if test -z "$export_symbols"; then
melunko@917
  4606
	      export_symbols="$output_objdir/$outputname.exp"
melunko@917
  4607
	      $run $rm $export_symbols
melunko@917
  4608
	      $run eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
melunko@917
  4609
              case $host in
melunko@917
  4610
              *cygwin* | *mingw* )
melunko@917
  4611
	        $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
melunko@917
  4612
		$run eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
melunko@917
  4613
                ;;
melunko@917
  4614
              esac
melunko@917
  4615
	    else
melunko@917
  4616
	      $run eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
melunko@917
  4617
	      $run eval 'grep -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
melunko@917
  4618
	      $run eval 'mv "$nlist"T "$nlist"'
melunko@917
  4619
              case $host in
melunko@917
  4620
              *cygwin* | *mingw* )
melunko@917
  4621
	        $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
melunko@917
  4622
		$run eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
melunko@917
  4623
                ;;
melunko@917
  4624
              esac
melunko@917
  4625
	    fi
melunko@917
  4626
	  fi
melunko@917
  4627
melunko@917
  4628
	  for arg in $dlprefiles; do
melunko@917
  4629
	    $show "extracting global C symbols from \`$arg'"
melunko@917
  4630
	    name=`$echo "$arg" | ${SED} -e 's%^.*/%%'`
melunko@917
  4631
	    $run eval '$echo ": $name " >> "$nlist"'
melunko@917
  4632
	    $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
melunko@917
  4633
	  done
melunko@917
  4634
melunko@917
  4635
	  if test -z "$run"; then
melunko@917
  4636
	    # Make sure we have at least an empty file.
melunko@917
  4637
	    test -f "$nlist" || : > "$nlist"
melunko@917
  4638
melunko@917
  4639
	    if test -n "$exclude_expsyms"; then
melunko@917
  4640
	      $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
melunko@917
  4641
	      $mv "$nlist"T "$nlist"
melunko@917
  4642
	    fi
melunko@917
  4643
melunko@917
  4644
	    # Try sorting and uniquifying the output.
melunko@917
  4645
	    if grep -v "^: " < "$nlist" |
melunko@917
  4646
		if sort -k 3 </dev/null >/dev/null 2>&1; then
melunko@917
  4647
		  sort -k 3
melunko@917
  4648
		else
melunko@917
  4649
		  sort +2
melunko@917
  4650
		fi |
melunko@917
  4651
		uniq > "$nlist"S; then
melunko@917
  4652
	      :
melunko@917
  4653
	    else
melunko@917
  4654
	      grep -v "^: " < "$nlist" > "$nlist"S
melunko@917
  4655
	    fi
melunko@917
  4656
melunko@917
  4657
	    if test -f "$nlist"S; then
melunko@917
  4658
	      eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$dlsyms"'
melunko@917
  4659
	    else
melunko@917
  4660
	      $echo '/* NONE */' >> "$output_objdir/$dlsyms"
melunko@917
  4661
	    fi
melunko@917
  4662
melunko@917
  4663
	    $echo >> "$output_objdir/$dlsyms" "\
melunko@917
  4664
melunko@917
  4665
#undef lt_preloaded_symbols
melunko@917
  4666
melunko@917
  4667
#if defined (__STDC__) && __STDC__
melunko@917
  4668
# define lt_ptr void *
melunko@917
  4669
#else
melunko@917
  4670
# define lt_ptr char *
melunko@917
  4671
# define const
melunko@917
  4672
#endif
melunko@917
  4673
melunko@917
  4674
/* The mapping between symbol names and symbols. */
melunko@917
  4675
"
melunko@917
  4676
melunko@917
  4677
	    case $host in
melunko@917
  4678
	    *cygwin* | *mingw* )
melunko@917
  4679
	  $echo >> "$output_objdir/$dlsyms" "\
melunko@917
  4680
/* DATA imports from DLLs on WIN32 can't be const, because
melunko@917
  4681
   runtime relocations are performed -- see ld's documentation
melunko@917
  4682
   on pseudo-relocs */
melunko@917
  4683
struct {
melunko@917
  4684
"
melunko@917
  4685
	      ;;
melunko@917
  4686
	    * )
melunko@917
  4687
	  $echo >> "$output_objdir/$dlsyms" "\
melunko@917
  4688
const struct {
melunko@917
  4689
"
melunko@917
  4690
	      ;;
melunko@917
  4691
	    esac
melunko@917
  4692
melunko@917
  4693
melunko@917
  4694
	  $echo >> "$output_objdir/$dlsyms" "\
melunko@917
  4695
  const char *name;
melunko@917
  4696
  lt_ptr address;
melunko@917
  4697
}
melunko@917
  4698
lt_preloaded_symbols[] =
melunko@917
  4699
{\
melunko@917
  4700
"
melunko@917
  4701
melunko@917
  4702
	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$dlsyms"
melunko@917
  4703
melunko@917
  4704
	    $echo >> "$output_objdir/$dlsyms" "\
melunko@917
  4705
  {0, (lt_ptr) 0}
melunko@917
  4706
};
melunko@917
  4707
melunko@917
  4708
/* This works around a problem in FreeBSD linker */
melunko@917
  4709
#ifdef FREEBSD_WORKAROUND
melunko@917
  4710
static const void *lt_preloaded_setup() {
melunko@917
  4711
  return lt_preloaded_symbols;
melunko@917
  4712
}
melunko@917
  4713
#endif
melunko@917
  4714
melunko@917
  4715
#ifdef __cplusplus
melunko@917
  4716
}
melunko@917
  4717
#endif\
melunko@917
  4718
"
melunko@917
  4719
	  fi
melunko@917
  4720
melunko@917
  4721
	  pic_flag_for_symtable=
melunko@917
  4722
	  case $host in
melunko@917
  4723
	  # compiling the symbol table file with pic_flag works around
melunko@917
  4724
	  # a FreeBSD bug that causes programs to crash when -lm is
melunko@917
  4725
	  # linked before any other PIC object.  But we must not use
melunko@917
  4726
	  # pic_flag when linking with -static.  The problem exists in
melunko@917
  4727
	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
melunko@917
  4728
	  *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
melunko@917
  4729
	    case "$compile_command " in
melunko@917
  4730
	    *" -static "*) ;;
melunko@917
  4731
	    *) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND";;
melunko@917
  4732
	    esac;;
melunko@917
  4733
	  *-*-hpux*)
melunko@917
  4734
	    case "$compile_command " in
melunko@917
  4735
	    *" -static "*) ;;
melunko@917
  4736
	    *) pic_flag_for_symtable=" $pic_flag";;
melunko@917
  4737
	    esac
melunko@917
  4738
	  esac
melunko@917
  4739
melunko@917
  4740
	  # Now compile the dynamic symbol file.
melunko@917
  4741
	  $show "(cd $output_objdir && $LTCC  $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")"
melunko@917
  4742
	  $run eval '(cd $output_objdir && $LTCC  $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $?
melunko@917
  4743
melunko@917
  4744
	  # Clean up the generated files.
melunko@917
  4745
	  $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T"
melunko@917
  4746
	  $run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T"
melunko@917
  4747
melunko@917
  4748
	  # Transform the symbol file into the correct name.
melunko@917
  4749
          case $host in
melunko@917
  4750
          *cygwin* | *mingw* )
melunko@917
  4751
            if test -f "$output_objdir/${outputname}.def" ; then
melunko@917
  4752
              compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%" | $NL2SP`
melunko@917
  4753
              finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%" | $NL2SP`
melunko@917
  4754
            else
melunko@917
  4755
              compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP`
melunko@917
  4756
              finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP`
melunko@917
  4757
             fi
melunko@917
  4758
            ;;
melunko@917
  4759
          * )
melunko@917
  4760
            compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP`
melunko@917
  4761
            finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP`
melunko@917
  4762
            ;;
melunko@917
  4763
          esac
melunko@917
  4764
	  ;;
melunko@917
  4765
	*)
melunko@917
  4766
	  $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2
melunko@917
  4767
	  exit $EXIT_FAILURE
melunko@917
  4768
	  ;;
melunko@917
  4769
	esac
melunko@917
  4770
      else
melunko@917
  4771
	# We keep going just in case the user didn't refer to
melunko@917
  4772
	# lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
melunko@917
  4773
	# really was required.
melunko@917
  4774
melunko@917
  4775
	# Nullify the symbol file.
melunko@917
  4776
	compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s% @SYMFILE@%%" | $NL2SP`
melunko@917
  4777
	finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s% @SYMFILE@%%" | $NL2SP`
melunko@917
  4778
      fi
melunko@917
  4779
melunko@917
  4780
      if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
melunko@917
  4781
	# Replace the output file specification.
melunko@917
  4782
	compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e 's%@OUTPUT@%'"$output"'%g' | $NL2SP`
melunko@917
  4783
	link_command="$compile_command$compile_rpath"
melunko@917
  4784
melunko@917
  4785
	# We have no uninstalled library dependencies, so finalize right now.
melunko@917
  4786
	$show "$link_command"
melunko@917
  4787
	$run eval "$link_command"
melunko@917
  4788
	exit_status=$?
melunko@917
  4789
melunko@917
  4790
	# Delete the generated files.
melunko@917
  4791
	if test -n "$dlsyms"; then
melunko@917
  4792
	  $show "$rm $output_objdir/${outputname}S.${objext}"
melunko@917
  4793
	  $run $rm "$output_objdir/${outputname}S.${objext}"
melunko@917
  4794
	fi
melunko@917
  4795
melunko@917
  4796
	exit $exit_status
melunko@917
  4797
      fi
melunko@917
  4798
melunko@917
  4799
      if test -n "$shlibpath_var"; then
melunko@917
  4800
	# We should set the shlibpath_var
melunko@917
  4801
	rpath=
melunko@917
  4802
	for dir in $temp_rpath; do
melunko@917
  4803
	  case $dir in
melunko@917
  4804
	  [\\/]* | [A-Za-z]:[\\/]*)
melunko@917
  4805
	    # Absolute path.
melunko@917
  4806
	    rpath="$rpath$dir:"
melunko@917
  4807
	    ;;
melunko@917
  4808
	  *)
melunko@917
  4809
	    # Relative path: add a thisdir entry.
melunko@917
  4810
	    rpath="$rpath\$thisdir/$dir:"
melunko@917
  4811
	    ;;
melunko@917
  4812
	  esac
melunko@917
  4813
	done
melunko@917
  4814
	temp_rpath="$rpath"
melunko@917
  4815
      fi
melunko@917
  4816
melunko@917
  4817
      if test -n "$compile_shlibpath$finalize_shlibpath"; then
melunko@917
  4818
	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
melunko@917
  4819
      fi
melunko@917
  4820
      if test -n "$finalize_shlibpath"; then
melunko@917
  4821
	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
melunko@917
  4822
      fi
melunko@917
  4823
melunko@917
  4824
      compile_var=
melunko@917
  4825
      finalize_var=
melunko@917
  4826
      if test -n "$runpath_var"; then
melunko@917
  4827
	if test -n "$perm_rpath"; then
melunko@917
  4828
	  # We should set the runpath_var.
melunko@917
  4829
	  rpath=
melunko@917
  4830
	  for dir in $perm_rpath; do
melunko@917
  4831
	    rpath="$rpath$dir:"
melunko@917
  4832
	  done
melunko@917
  4833
	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
melunko@917
  4834
	fi
melunko@917
  4835
	if test -n "$finalize_perm_rpath"; then
melunko@917
  4836
	  # We should set the runpath_var.
melunko@917
  4837
	  rpath=
melunko@917
  4838
	  for dir in $finalize_perm_rpath; do
melunko@917
  4839
	    rpath="$rpath$dir:"
melunko@917
  4840
	  done
melunko@917
  4841
	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
melunko@917
  4842
	fi
melunko@917
  4843
      fi
melunko@917
  4844
melunko@917
  4845
      if test "$no_install" = yes; then
melunko@917
  4846
	# We don't need to create a wrapper script.
melunko@917
  4847
	link_command="$compile_var$compile_command$compile_rpath"
melunko@917
  4848
	# Replace the output file specification.
melunko@917
  4849
	link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
melunko@917
  4850
	# Delete the old output file.
melunko@917
  4851
	$run $rm $output
melunko@917
  4852
	# Link the executable and exit
melunko@917
  4853
	$show "$link_command"
melunko@917
  4854
	$run eval "$link_command" || exit $?
melunko@917
  4855
	exit $EXIT_SUCCESS
melunko@917
  4856
      fi
melunko@917
  4857
melunko@917
  4858
      if test "$hardcode_action" = relink; then
melunko@917
  4859
	# Fast installation is not supported
melunko@917
  4860
	link_command="$compile_var$compile_command$compile_rpath"
melunko@917
  4861
	relink_command="$finalize_var$finalize_command$finalize_rpath"
melunko@917
  4862
melunko@917
  4863
	$echo "$modename: warning: this platform does not like uninstalled shared libraries" 1>&2
melunko@917
  4864
	$echo "$modename: \`$output' will be relinked during installation" 1>&2
melunko@917
  4865
      else
melunko@917
  4866
	if test "$fast_install" != no; then
melunko@917
  4867
	  link_command="$finalize_var$compile_command$finalize_rpath"
melunko@917
  4868
	  if test "$fast_install" = yes; then
melunko@917
  4869
	    relink_command=`$echo "X$compile_var$compile_command$compile_rpath" | $SP2NL | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g' | $NL2SP`
melunko@917
  4870
	  else
melunko@917
  4871
	    # fast_install is set to needless
melunko@917
  4872
	    relink_command=
melunko@917
  4873
	  fi
melunko@917
  4874
	else
melunko@917
  4875
	  link_command="$compile_var$compile_command$compile_rpath"
melunko@917
  4876
	  relink_command="$finalize_var$finalize_command$finalize_rpath"
melunko@917
  4877
	fi
melunko@917
  4878
      fi
melunko@917
  4879
melunko@917
  4880
      # Replace the output file specification.
melunko@917
  4881
      link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
melunko@917
  4882
melunko@917
  4883
      # Delete the old output files.
melunko@917
  4884
      $run $rm $output $output_objdir/$outputname $output_objdir/lt-$outputname
melunko@917
  4885
melunko@917
  4886
      $show "$link_command"
melunko@917
  4887
      $run eval "$link_command" || exit $?
melunko@917
  4888
melunko@917
  4889
      # Now create the wrapper script.
melunko@917
  4890
      $show "creating $output"
melunko@917
  4891
melunko@917
  4892
      # Quote the relink command for shipping.
melunko@917
  4893
      if test -n "$relink_command"; then
melunko@917
  4894
	# Preserve any variables that may affect compiler behavior
melunko@917
  4895
	for var in $variables_saved_for_relink; do
melunko@917
  4896
	  if eval test -z \"\${$var+set}\"; then
melunko@917
  4897
	    relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command"
melunko@917
  4898
	  elif eval var_value=\$$var; test -z "$var_value"; then
melunko@917
  4899
	    relink_command="$var=; export $var; $relink_command"
melunko@917
  4900
	  else
melunko@917
  4901
	    var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"`
melunko@917
  4902
	    relink_command="$var=\"$var_value\"; export $var; $relink_command"
melunko@917
  4903
	  fi
melunko@917
  4904
	done
melunko@917
  4905
	relink_command="(cd `pwd`; $relink_command)"
melunko@917
  4906
	relink_command=`$echo "X$relink_command" | $SP2NL | $Xsed -e "$sed_quote_subst" | $NL2SP`
melunko@917
  4907
      fi
melunko@917
  4908
melunko@917
  4909
      # Quote $echo for shipping.
melunko@917
  4910
      if test "X$echo" = "X$SHELL $progpath --fallback-echo"; then
melunko@917
  4911
	case $progpath in
melunko@917
  4912
	[\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";;
melunko@917
  4913
	*) qecho="$SHELL `pwd`/$progpath --fallback-echo";;
melunko@917
  4914
	esac
melunko@917
  4915
	qecho=`$echo "X$qecho" | $Xsed -e "$sed_quote_subst"`
melunko@917
  4916
      else
melunko@917
  4917
	qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"`
melunko@917
  4918
      fi
melunko@917
  4919
melunko@917
  4920
      # Only actually do things if our run command is non-null.
melunko@917
  4921
      if test -z "$run"; then
melunko@917
  4922
	# win32 will think the script is a binary if it has
melunko@917
  4923
	# a .exe suffix, so we strip it off here.
melunko@917
  4924
	case $output in
melunko@917
  4925
	  *.exe) output=`$echo $output|${SED} 's,.exe$,,'` ;;
melunko@917
  4926
	esac
melunko@917
  4927
	# test for cygwin because mv fails w/o .exe extensions
melunko@917
  4928
	case $host in
melunko@917
  4929
	  *cygwin*)
melunko@917
  4930
	    exeext=.exe
melunko@917
  4931
	    outputname=`$echo $outputname|${SED} 's,.exe$,,'` ;;
melunko@917
  4932
	  *) exeext= ;;
melunko@917
  4933
	esac
melunko@917
  4934
	case $host in
melunko@917
  4935
	  *cygwin* | *mingw* )
melunko@917
  4936
            output_name=`basename $output`
melunko@917
  4937
            output_path=`dirname $output`
melunko@917
  4938
            cwrappersource="$output_path/$objdir/lt-$output_name.c"
melunko@917
  4939
            cwrapper="$output_path/$output_name.exe"
melunko@917
  4940
            $rm $cwrappersource $cwrapper
melunko@917
  4941
            trap "$rm $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
melunko@917
  4942
melunko@917
  4943
	    cat > $cwrappersource <<EOF
melunko@917
  4944
melunko@917
  4945
/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
melunko@917
  4946
   Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
melunko@917
  4947
melunko@917
  4948
   The $output program cannot be directly executed until all the libtool
melunko@917
  4949
   libraries that it depends on are installed.
melunko@917
  4950
melunko@917
  4951
   This wrapper executable should never be moved out of the build directory.
melunko@917
  4952
   If it is, it will not operate correctly.
melunko@917
  4953
melunko@917
  4954
   Currently, it simply execs the wrapper *script* "/bin/sh $output",
melunko@917
  4955
   but could eventually absorb all of the scripts functionality and
melunko@917
  4956
   exec $objdir/$outputname directly.
melunko@917
  4957
*/
melunko@917
  4958
EOF
melunko@917
  4959
	    cat >> $cwrappersource<<"EOF"
melunko@917
  4960
#include <stdio.h>
melunko@917
  4961
#include <stdlib.h>
melunko@917
  4962
#include <unistd.h>
melunko@917
  4963
#include <malloc.h>
melunko@917
  4964
#include <stdarg.h>
melunko@917
  4965
#include <assert.h>
melunko@917
  4966
#include <string.h>
melunko@917
  4967
#include <ctype.h>
melunko@917
  4968
#include <sys/stat.h>
melunko@917
  4969
melunko@917
  4970
#if defined(PATH_MAX)
melunko@917
  4971
# define LT_PATHMAX PATH_MAX
melunko@917
  4972
#elif defined(MAXPATHLEN)
melunko@917
  4973
# define LT_PATHMAX MAXPATHLEN
melunko@917
  4974
#else
melunko@917
  4975
# define LT_PATHMAX 1024
melunko@917
  4976
#endif
melunko@917
  4977
melunko@917
  4978
#ifndef DIR_SEPARATOR
melunko@917
  4979
# define DIR_SEPARATOR '/'
melunko@917
  4980
# define PATH_SEPARATOR ':'
melunko@917
  4981
#endif
melunko@917
  4982
melunko@917
  4983
#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
melunko@917
  4984
  defined (__OS2__)
melunko@917
  4985
# define HAVE_DOS_BASED_FILE_SYSTEM
melunko@917
  4986
# ifndef DIR_SEPARATOR_2
melunko@917
  4987
#  define DIR_SEPARATOR_2 '\\'
melunko@917
  4988
# endif
melunko@917
  4989
# ifndef PATH_SEPARATOR_2
melunko@917
  4990
#  define PATH_SEPARATOR_2 ';'
melunko@917
  4991
# endif
melunko@917
  4992
#endif
melunko@917
  4993
melunko@917
  4994
#ifndef DIR_SEPARATOR_2
melunko@917
  4995
# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
melunko@917
  4996
#else /* DIR_SEPARATOR_2 */
melunko@917
  4997
# define IS_DIR_SEPARATOR(ch) \
melunko@917
  4998
        (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
melunko@917
  4999
#endif /* DIR_SEPARATOR_2 */
melunko@917
  5000
melunko@917
  5001
#ifndef PATH_SEPARATOR_2
melunko@917
  5002
# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
melunko@917
  5003
#else /* PATH_SEPARATOR_2 */
melunko@917
  5004
# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
melunko@917
  5005
#endif /* PATH_SEPARATOR_2 */
melunko@917
  5006
melunko@917
  5007
#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
melunko@917
  5008
#define XFREE(stale) do { \
melunko@917
  5009
  if (stale) { free ((void *) stale); stale = 0; } \
melunko@917
  5010
} while (0)
melunko@917
  5011
melunko@917
  5012
/* -DDEBUG is fairly common in CFLAGS.  */
melunko@917
  5013
#undef DEBUG
melunko@917
  5014
#if defined DEBUGWRAPPER
melunko@917
  5015
# define DEBUG(format, ...) fprintf(stderr, format, __VA_ARGS__)
melunko@917
  5016
#else
melunko@917
  5017
# define DEBUG(format, ...)
melunko@917
  5018
#endif
melunko@917
  5019
melunko@917
  5020
const char *program_name = NULL;
melunko@917
  5021
melunko@917
  5022
void * xmalloc (size_t num);
melunko@917
  5023
char * xstrdup (const char *string);
melunko@917
  5024
const char * base_name (const char *name);
melunko@917
  5025
char * find_executable(const char *wrapper);
melunko@917
  5026
int    check_executable(const char *path);
melunko@917
  5027
char * strendzap(char *str, const char *pat);
melunko@917
  5028
void lt_fatal (const char *message, ...);
melunko@917
  5029
melunko@917
  5030
int
melunko@917
  5031
main (int argc, char *argv[])
melunko@917
  5032
{
melunko@917
  5033
  char **newargz;
melunko@917
  5034
  int i;
melunko@917
  5035
melunko@917
  5036
  program_name = (char *) xstrdup (base_name (argv[0]));
melunko@917
  5037
  DEBUG("(main) argv[0]      : %s\n",argv[0]);
melunko@917
  5038
  DEBUG("(main) program_name : %s\n",program_name);
melunko@917
  5039
  newargz = XMALLOC(char *, argc+2);
melunko@917
  5040
EOF
melunko@917
  5041
melunko@917
  5042
            cat >> $cwrappersource <<EOF
melunko@917
  5043
  newargz[0] = (char *) xstrdup("$SHELL");
melunko@917
  5044
EOF
melunko@917
  5045
melunko@917
  5046
            cat >> $cwrappersource <<"EOF"
melunko@917
  5047
  newargz[1] = find_executable(argv[0]);
melunko@917
  5048
  if (newargz[1] == NULL)
melunko@917
  5049
    lt_fatal("Couldn't find %s", argv[0]);
melunko@917
  5050
  DEBUG("(main) found exe at : %s\n",newargz[1]);
melunko@917
  5051
  /* we know the script has the same name, without the .exe */
melunko@917
  5052
  /* so make sure newargz[1] doesn't end in .exe */
melunko@917
  5053
  strendzap(newargz[1],".exe");
melunko@917
  5054
  for (i = 1; i < argc; i++)
melunko@917
  5055
    newargz[i+1] = xstrdup(argv[i]);
melunko@917
  5056
  newargz[argc+1] = NULL;
melunko@917
  5057
melunko@917
  5058
  for (i=0; i<argc+1; i++)
melunko@917
  5059
  {
melunko@917
  5060
    DEBUG("(main) newargz[%d]   : %s\n",i,newargz[i]);
melunko@917
  5061
    ;
melunko@917
  5062
  }
melunko@917
  5063
melunko@917
  5064
EOF
melunko@917
  5065
melunko@917
  5066
            case $host_os in
melunko@917
  5067
              mingw*)
melunko@917
  5068
                cat >> $cwrappersource <<EOF
melunko@917
  5069
  execv("$SHELL",(char const **)newargz);
melunko@917
  5070
EOF
melunko@917
  5071
              ;;
melunko@917
  5072
              *)
melunko@917
  5073
                cat >> $cwrappersource <<EOF
melunko@917
  5074
  execv("$SHELL",newargz);
melunko@917
  5075
EOF
melunko@917
  5076
              ;;
melunko@917
  5077
            esac
melunko@917
  5078
melunko@917
  5079
            cat >> $cwrappersource <<"EOF"
melunko@917
  5080
  return 127;
melunko@917
  5081
}
melunko@917
  5082
melunko@917
  5083
void *
melunko@917
  5084
xmalloc (size_t num)
melunko@917
  5085
{
melunko@917
  5086
  void * p = (void *) malloc (num);
melunko@917
  5087
  if (!p)
melunko@917
  5088
    lt_fatal ("Memory exhausted");
melunko@917
  5089
melunko@917
  5090
  return p;
melunko@917
  5091
}
melunko@917
  5092
melunko@917
  5093
char *
melunko@917
  5094
xstrdup (const char *string)
melunko@917
  5095
{
melunko@917
  5096
  return string ? strcpy ((char *) xmalloc (strlen (string) + 1), string) : NULL
melunko@917
  5097
;
melunko@917
  5098
}
melunko@917
  5099
melunko@917
  5100
const char *
melunko@917
  5101
base_name (const char *name)
melunko@917
  5102
{
melunko@917
  5103
  const char *base;
melunko@917
  5104
melunko@917
  5105
#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
melunko@917
  5106
  /* Skip over the disk name in MSDOS pathnames. */
melunko@917
  5107
  if (isalpha ((unsigned char)name[0]) && name[1] == ':')
melunko@917
  5108
    name += 2;
melunko@917
  5109
#endif
melunko@917
  5110
melunko@917
  5111
  for (base = name; *name; name++)
melunko@917
  5112
    if (IS_DIR_SEPARATOR (*name))
melunko@917
  5113
      base = name + 1;
melunko@917
  5114
  return base;
melunko@917
  5115
}
melunko@917
  5116
melunko@917
  5117
int
melunko@917
  5118
check_executable(const char * path)
melunko@917
  5119
{
melunko@917
  5120
  struct stat st;
melunko@917
  5121
melunko@917
  5122
  DEBUG("(check_executable)  : %s\n", path ? (*path ? path : "EMPTY!") : "NULL!");
melunko@917
  5123
  if ((!path) || (!*path))
melunko@917
  5124
    return 0;
melunko@917
  5125
melunko@917
  5126
  if ((stat (path, &st) >= 0) &&
melunko@917
  5127
      (
melunko@917
  5128
        /* MinGW & native WIN32 do not support S_IXOTH or S_IXGRP */
melunko@917
  5129
#if defined (S_IXOTH)
melunko@917
  5130
       ((st.st_mode & S_IXOTH) == S_IXOTH) ||
melunko@917
  5131
#endif
melunko@917
  5132
#if defined (S_IXGRP)
melunko@917
  5133
       ((st.st_mode & S_IXGRP) == S_IXGRP) ||
melunko@917
  5134
#endif
melunko@917
  5135
       ((st.st_mode & S_IXUSR) == S_IXUSR))
melunko@917
  5136
      )
melunko@917
  5137
    return 1;
melunko@917
  5138
  else
melunko@917
  5139
    return 0;
melunko@917
  5140
}
melunko@917
  5141
melunko@917
  5142
/* Searches for the full path of the wrapper.  Returns
melunko@917
  5143
   newly allocated full path name if found, NULL otherwise */
melunko@917
  5144
char *
melunko@917
  5145
find_executable (const char* wrapper)
melunko@917
  5146
{
melunko@917
  5147
  int has_slash = 0;
melunko@917
  5148
  const char* p;
melunko@917
  5149
  const char* p_next;
melunko@917
  5150
  /* static buffer for getcwd */
melunko@917
  5151
  char tmp[LT_PATHMAX + 1];
melunko@917
  5152
  int tmp_len;
melunko@917
  5153
  char* concat_name;
melunko@917
  5154
melunko@917
  5155
  DEBUG("(find_executable)  : %s\n", wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!");
melunko@917
  5156
melunko@917
  5157
  if ((wrapper == NULL) || (*wrapper == '\0'))
melunko@917
  5158
    return NULL;
melunko@917
  5159
melunko@917
  5160
  /* Absolute path? */
melunko@917
  5161
#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
melunko@917
  5162
  if (isalpha ((unsigned char)wrapper[0]) && wrapper[1] == ':')
melunko@917
  5163
  {
melunko@917
  5164
    concat_name = xstrdup (wrapper);
melunko@917
  5165
    if (check_executable(concat_name))
melunko@917
  5166
      return concat_name;
melunko@917
  5167
    XFREE(concat_name);
melunko@917
  5168
  }
melunko@917
  5169
  else
melunko@917
  5170
  {
melunko@917
  5171
#endif
melunko@917
  5172
    if (IS_DIR_SEPARATOR (wrapper[0]))
melunko@917
  5173
    {
melunko@917
  5174
      concat_name = xstrdup (wrapper);
melunko@917
  5175
      if (check_executable(concat_name))
melunko@917
  5176
        return concat_name;
melunko@917
  5177
      XFREE(concat_name);
melunko@917
  5178
    }
melunko@917
  5179
#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
melunko@917
  5180
  }
melunko@917
  5181
#endif
melunko@917
  5182
melunko@917
  5183
  for (p = wrapper; *p; p++)
melunko@917
  5184
    if (*p == '/')
melunko@917
  5185
    {
melunko@917
  5186
      has_slash = 1;
melunko@917
  5187
      break;
melunko@917
  5188
    }
melunko@917
  5189
  if (!has_slash)
melunko@917
  5190
  {
melunko@917
  5191
    /* no slashes; search PATH */
melunko@917
  5192
    const char* path = getenv ("PATH");
melunko@917
  5193
    if (path != NULL)
melunko@917
  5194
    {
melunko@917
  5195
      for (p = path; *p; p = p_next)
melunko@917
  5196
      {
melunko@917
  5197
        const char* q;
melunko@917
  5198
        size_t p_len;
melunko@917
  5199
        for (q = p; *q; q++)
melunko@917
  5200
          if (IS_PATH_SEPARATOR(*q))
melunko@917
  5201
            break;
melunko@917
  5202
        p_len = q - p;
melunko@917
  5203
        p_next = (*q == '\0' ? q : q + 1);
melunko@917
  5204
        if (p_len == 0)
melunko@917
  5205
        {
melunko@917
  5206
          /* empty path: current directory */
melunko@917
  5207
          if (getcwd (tmp, LT_PATHMAX) == NULL)
melunko@917
  5208
            lt_fatal ("getcwd failed");
melunko@917
  5209
          tmp_len = strlen(tmp);
melunko@917
  5210
          concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
melunko@917
  5211
          memcpy (concat_name, tmp, tmp_len);
melunko@917
  5212
          concat_name[tmp_len] = '/';
melunko@917
  5213
          strcpy (concat_name + tmp_len + 1, wrapper);
melunko@917
  5214
        }
melunko@917
  5215
        else
melunko@917
  5216
        {
melunko@917
  5217
          concat_name = XMALLOC(char, p_len + 1 + strlen(wrapper) + 1);
melunko@917
  5218
          memcpy (concat_name, p, p_len);
melunko@917
  5219
          concat_name[p_len] = '/';
melunko@917
  5220
          strcpy (concat_name + p_len + 1, wrapper);
melunko@917
  5221
        }
melunko@917
  5222
        if (check_executable(concat_name))
melunko@917
  5223
          return concat_name;
melunko@917
  5224
        XFREE(concat_name);
melunko@917
  5225
      }
melunko@917
  5226
    }
melunko@917
  5227
    /* not found in PATH; assume curdir */
melunko@917
  5228
  }
melunko@917
  5229
  /* Relative path | not found in path: prepend cwd */
melunko@917
  5230
  if (getcwd (tmp, LT_PATHMAX) == NULL)
melunko@917
  5231
    lt_fatal ("getcwd failed");
melunko@917
  5232
  tmp_len = strlen(tmp);
melunko@917
  5233
  concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
melunko@917
  5234
  memcpy (concat_name, tmp, tmp_len);
melunko@917
  5235
  concat_name[tmp_len] = '/';
melunko@917
  5236
  strcpy (concat_name + tmp_len + 1, wrapper);
melunko@917
  5237
melunko@917
  5238
  if (check_executable(concat_name))
melunko@917
  5239
    return concat_name;
melunko@917
  5240
  XFREE(concat_name);
melunko@917
  5241
  return NULL;
melunko@917
  5242
}
melunko@917
  5243
melunko@917
  5244
char *
melunko@917
  5245
strendzap(char *str, const char *pat)
melunko@917
  5246
{
melunko@917
  5247
  size_t len, patlen;
melunko@917
  5248
melunko@917
  5249
  assert(str != NULL);
melunko@917
  5250
  assert(pat != NULL);
melunko@917
  5251
melunko@917
  5252
  len = strlen(str);
melunko@917
  5253
  patlen = strlen(pat);
melunko@917
  5254
melunko@917
  5255
  if (patlen <= len)
melunko@917
  5256
  {
melunko@917
  5257
    str += len - patlen;
melunko@917
  5258
    if (strcmp(str, pat) == 0)
melunko@917
  5259
      *str = '\0';
melunko@917
  5260
  }
melunko@917
  5261
  return str;
melunko@917
  5262
}
melunko@917
  5263
melunko@917
  5264
static void
melunko@917
  5265
lt_error_core (int exit_status, const char * mode,
melunko@917
  5266
          const char * message, va_list ap)
melunko@917
  5267
{
melunko@917
  5268
  fprintf (stderr, "%s: %s: ", program_name, mode);
melunko@917
  5269
  vfprintf (stderr, message, ap);
melunko@917
  5270
  fprintf (stderr, ".\n");
melunko@917
  5271
melunko@917
  5272
  if (exit_status >= 0)
melunko@917
  5273
    exit (exit_status);
melunko@917
  5274
}
melunko@917
  5275
melunko@917
  5276
void
melunko@917
  5277
lt_fatal (const char *message, ...)
melunko@917
  5278
{
melunko@917
  5279
  va_list ap;
melunko@917
  5280
  va_start (ap, message);
melunko@917
  5281
  lt_error_core (EXIT_FAILURE, "FATAL", message, ap);
melunko@917
  5282
  va_end (ap);
melunko@917
  5283
}
melunko@917
  5284
EOF
melunko@917
  5285
          # we should really use a build-platform specific compiler
melunko@917
  5286
          # here, but OTOH, the wrappers (shell script and this C one)
melunko@917
  5287
          # are only useful if you want to execute the "real" binary.
melunko@917
  5288
          # Since the "real" binary is built for $host, then this
melunko@917
  5289
          # wrapper might as well be built for $host, too.
melunko@917
  5290
          $run $LTCC $LTCFLAGS -s -o $cwrapper $cwrappersource
melunko@917
  5291
          ;;
melunko@917
  5292
        esac
melunko@917
  5293
        $rm $output
melunko@917
  5294
        trap "$rm $output; exit $EXIT_FAILURE" 1 2 15
melunko@917
  5295
melunko@917
  5296
	$echo > $output "\
melunko@917
  5297
#! $SHELL
melunko@917
  5298
melunko@917
  5299
# $output - temporary wrapper script for $objdir/$outputname
melunko@917
  5300
# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
melunko@917
  5301
#
melunko@917
  5302
# The $output program cannot be directly executed until all the libtool
melunko@917
  5303
# libraries that it depends on are installed.
melunko@917
  5304
#
melunko@917
  5305
# This wrapper script should never be moved out of the build directory.
melunko@917
  5306
# If it is, it will not operate correctly.
melunko@917
  5307
melunko@917
  5308
# Sed substitution that helps us do robust quoting.  It backslashifies
melunko@917
  5309
# metacharacters that are still active within double-quoted strings.
melunko@917
  5310
Xsed='${SED} -e 1s/^X//'
melunko@917
  5311
sed_quote_subst='$sed_quote_subst'
melunko@917
  5312
melunko@917
  5313
# Be Bourne compatible (taken from Autoconf:_AS_BOURNE_COMPATIBLE).
melunko@917
  5314
if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
melunko@917
  5315
  emulate sh
melunko@917
  5316
  NULLCMD=:
melunko@917
  5317
  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
melunko@917
  5318
  # is contrary to our usage.  Disable this feature.
melunko@917
  5319
  alias -g '\${1+\"\$@\"}'='\"\$@\"'
melunko@917
  5320
  setopt NO_GLOB_SUBST
melunko@917
  5321
else
melunko@917
  5322
  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
melunko@917
  5323
fi
melunko@917
  5324
BIN_SH=xpg4; export BIN_SH # for Tru64
melunko@917
  5325
DUALCASE=1; export DUALCASE # for MKS sh
melunko@917
  5326
melunko@917
  5327
# The HP-UX ksh and POSIX shell print the target directory to stdout
melunko@917
  5328
# if CDPATH is set.
melunko@917
  5329
(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
melunko@917
  5330
melunko@917
  5331
relink_command=\"$relink_command\"
melunko@917
  5332
melunko@917
  5333
# This environment variable determines our operation mode.
melunko@917
  5334
if test \"\$libtool_install_magic\" = \"$magic\"; then
melunko@917
  5335
  # install mode needs the following variable:
melunko@917
  5336
  notinst_deplibs='$notinst_deplibs'
melunko@917
  5337
else
melunko@917
  5338
  # When we are sourced in execute mode, \$file and \$echo are already set.
melunko@917
  5339
  if test \"\$libtool_execute_magic\" != \"$magic\"; then
melunko@917
  5340
    echo=\"$qecho\"
melunko@917
  5341
    file=\"\$0\"
melunko@917
  5342
    # Make sure echo works.
melunko@917
  5343
    if test \"X\$1\" = X--no-reexec; then
melunko@917
  5344
      # Discard the --no-reexec flag, and continue.
melunko@917
  5345
      shift
melunko@917
  5346
    elif test \"X\`(\$echo '\t') 2>/dev/null\`\" = 'X\t'; then
melunko@917
  5347
      # Yippee, \$echo works!
melunko@917
  5348
      :
melunko@917
  5349
    else
melunko@917
  5350
      # Restart under the correct shell, and then maybe \$echo will work.
melunko@917
  5351
      exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"}
melunko@917
  5352
    fi
melunko@917
  5353
  fi\
melunko@917
  5354
"
melunko@917
  5355
	$echo >> $output "\
melunko@917
  5356
melunko@917
  5357
  # Find the directory that this script lives in.
melunko@917
  5358
  thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\`
melunko@917
  5359
  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
melunko@917
  5360
melunko@917
  5361
  # Follow symbolic links until we get to the real thisdir.
melunko@917
  5362
  file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\`
melunko@917
  5363
  while test -n \"\$file\"; do
melunko@917
  5364
    destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\`
melunko@917
  5365
melunko@917
  5366
    # If there was a directory component, then change thisdir.
melunko@917
  5367
    if test \"x\$destdir\" != \"x\$file\"; then
melunko@917
  5368
      case \"\$destdir\" in
melunko@917
  5369
      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
melunko@917
  5370
      *) thisdir=\"\$thisdir/\$destdir\" ;;
melunko@917
  5371
      esac
melunko@917
  5372
    fi
melunko@917
  5373
melunko@917
  5374
    file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\`
melunko@917
  5375
    file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\`
melunko@917
  5376
  done
melunko@917
  5377
melunko@917
  5378
  # Try to get the absolute directory name.
melunko@917
  5379
  absdir=\`cd \"\$thisdir\" && pwd\`
melunko@917
  5380
  test -n \"\$absdir\" && thisdir=\"\$absdir\"
melunko@917
  5381
"
melunko@917
  5382
melunko@917
  5383
	if test "$fast_install" = yes; then
melunko@917
  5384
	  $echo >> $output "\
melunko@917
  5385
  program=lt-'$outputname'$exeext
melunko@917
  5386
  progdir=\"\$thisdir/$objdir\"
melunko@917
  5387
melunko@917
  5388
  if test ! -f \"\$progdir/\$program\" || \\
melunko@917
  5389
     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
melunko@917
  5390
       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
melunko@917
  5391
melunko@917
  5392
    file=\"\$\$-\$program\"
melunko@917
  5393
melunko@917
  5394
    if test ! -d \"\$progdir\"; then
melunko@917
  5395
      $mkdir \"\$progdir\"
melunko@917
  5396
    else
melunko@917
  5397
      $rm \"\$progdir/\$file\"
melunko@917
  5398
    fi"
melunko@917
  5399
melunko@917
  5400
	  $echo >> $output "\
melunko@917
  5401
melunko@917
  5402
    # relink executable if necessary
melunko@917
  5403
    if test -n \"\$relink_command\"; then
melunko@917
  5404
      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
melunko@917
  5405
      else
melunko@917
  5406
	$echo \"\$relink_command_output\" >&2
melunko@917
  5407
	$rm \"\$progdir/\$file\"
melunko@917
  5408
	exit $EXIT_FAILURE
melunko@917
  5409
      fi
melunko@917
  5410
    fi
melunko@917
  5411
melunko@917
  5412
    $mv \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
melunko@917
  5413
    { $rm \"\$progdir/\$program\";
melunko@917
  5414
      $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; }
melunko@917
  5415
    $rm \"\$progdir/\$file\"
melunko@917
  5416
  fi"
melunko@917
  5417
	else
melunko@917
  5418
	  $echo >> $output "\
melunko@917
  5419
  program='$outputname'
melunko@917
  5420
  progdir=\"\$thisdir/$objdir\"
melunko@917
  5421
"
melunko@917
  5422
	fi
melunko@917
  5423
melunko@917
  5424
	$echo >> $output "\
melunko@917
  5425
melunko@917
  5426
  if test -f \"\$progdir/\$program\"; then"
melunko@917
  5427
melunko@917
  5428
	# Export our shlibpath_var if we have one.
melunko@917
  5429
	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
melunko@917
  5430
	  $echo >> $output "\
melunko@917
  5431
    # Add our own library path to $shlibpath_var
melunko@917
  5432
    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
melunko@917
  5433
melunko@917
  5434
    # Some systems cannot cope with colon-terminated $shlibpath_var
melunko@917
  5435
    # The second colon is a workaround for a bug in BeOS R4 sed
melunko@917
  5436
    $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\`
melunko@917
  5437
melunko@917
  5438
    export $shlibpath_var
melunko@917
  5439
"
melunko@917
  5440
	fi
melunko@917
  5441
melunko@917
  5442
	# fixup the dll searchpath if we need to.
melunko@917
  5443
	if test -n "$dllsearchpath"; then
melunko@917
  5444
	  $echo >> $output "\
melunko@917
  5445
    # Add the dll search path components to the executable PATH
melunko@917
  5446
    PATH=$dllsearchpath:\$PATH
melunko@917
  5447
"
melunko@917
  5448
	fi
melunko@917
  5449
melunko@917
  5450
	$echo >> $output "\
melunko@917
  5451
    if test \"\$libtool_execute_magic\" != \"$magic\"; then
melunko@917
  5452
      # Run the actual program with our arguments.
melunko@917
  5453
"
melunko@917
  5454
	case $host in
melunko@917
  5455
	# Backslashes separate directories on plain windows
melunko@917
  5456
	*-*-mingw | *-*-os2*)
melunko@917
  5457
	  $echo >> $output "\
melunko@917
  5458
      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
melunko@917
  5459
"
melunko@917
  5460
	  ;;
melunko@917
  5461
melunko@917
  5462
	*)
melunko@917
  5463
	  $echo >> $output "\
melunko@917
  5464
      exec \"\$progdir/\$program\" \${1+\"\$@\"}
melunko@917
  5465
"
melunko@917
  5466
	  ;;
melunko@917
  5467
	esac
melunko@917
  5468
	$echo >> $output "\
melunko@917
  5469
      \$echo \"\$0: cannot exec \$program \$*\"
melunko@917
  5470
      exit $EXIT_FAILURE
melunko@917
  5471
    fi
melunko@917
  5472
  else
melunko@917
  5473
    # The program doesn't exist.
melunko@917
  5474
    \$echo \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
melunko@917
  5475
    \$echo \"This script is just a wrapper for \$program.\" 1>&2
melunko@917
  5476
    $echo \"See the $PACKAGE documentation for more information.\" 1>&2
melunko@917
  5477
    exit $EXIT_FAILURE
melunko@917
  5478
  fi
melunko@917
  5479
fi\
melunko@917
  5480
"
melunko@917
  5481
	chmod +x $output
melunko@917
  5482
      fi
melunko@917
  5483
      exit $EXIT_SUCCESS
melunko@917
  5484
      ;;
melunko@917
  5485
    esac
melunko@917
  5486
melunko@917
  5487
    # See if we need to build an old-fashioned archive.
melunko@917
  5488
    for oldlib in $oldlibs; do
melunko@917
  5489
melunko@917
  5490
      if test "$build_libtool_libs" = convenience; then
melunko@917
  5491
	oldobjs="$libobjs_save"
melunko@917
  5492
	addlibs="$convenience"
melunko@917
  5493
	build_libtool_libs=no
melunko@917
  5494
      else
melunko@917
  5495
	if test "$build_libtool_libs" = module; then
melunko@917
  5496
	  oldobjs="$libobjs_save"
melunko@917
  5497
	  build_libtool_libs=no
melunko@917
  5498
	else
melunko@917
  5499
	  oldobjs="$old_deplibs $non_pic_objects"
melunko@917
  5500
	fi
melunko@917
  5501
	addlibs="$old_convenience"
melunko@917
  5502
      fi
melunko@917
  5503
melunko@917
  5504
      if test -n "$addlibs"; then
melunko@917
  5505
	gentop="$output_objdir/${outputname}x"
melunko@917
  5506
	generated="$generated $gentop"
melunko@917
  5507
melunko@917
  5508
	func_extract_archives $gentop $addlibs
melunko@917
  5509
	oldobjs="$oldobjs $func_extract_archives_result"
melunko@917
  5510
      fi
melunko@917
  5511
melunko@917
  5512
      # Do each command in the archive commands.
melunko@917
  5513
      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
melunko@917
  5514
       cmds=$old_archive_from_new_cmds
melunko@917
  5515
      else
melunko@917
  5516
	# POSIX demands no paths to be encoded in archives.  We have
melunko@917
  5517
	# to avoid creating archives with duplicate basenames if we
melunko@917
  5518
	# might have to extract them afterwards, e.g., when creating a
melunko@917
  5519
	# static archive out of a convenience library, or when linking
melunko@917
  5520
	# the entirety of a libtool archive into another (currently
melunko@917
  5521
	# not supported by libtool).
melunko@917
  5522
	if (for obj in $oldobjs
melunko@917
  5523
	    do
melunko@917
  5524
	      $echo "X$obj" | $Xsed -e 's%^.*/%%'
melunko@917
  5525
	    done | sort | sort -uc >/dev/null 2>&1); then
melunko@917
  5526
	  :
melunko@917
  5527
	else
melunko@917
  5528
	  $echo "copying selected object files to avoid basename conflicts..."
melunko@917
  5529
melunko@917
  5530
	  if test -z "$gentop"; then
melunko@917
  5531
	    gentop="$output_objdir/${outputname}x"
melunko@917
  5532
	    generated="$generated $gentop"
melunko@917
  5533
melunko@917
  5534
	    $show "${rm}r $gentop"
melunko@917
  5535
	    $run ${rm}r "$gentop"
melunko@917
  5536
	    $show "$mkdir $gentop"
melunko@917
  5537
	    $run $mkdir "$gentop"
melunko@917
  5538
	    exit_status=$?
melunko@917
  5539
	    if test "$exit_status" -ne 0 && test ! -d "$gentop"; then
melunko@917
  5540
	      exit $exit_status
melunko@917
  5541
	    fi
melunko@917
  5542
	  fi
melunko@917
  5543
melunko@917
  5544
	  save_oldobjs=$oldobjs
melunko@917
  5545
	  oldobjs=
melunko@917
  5546
	  counter=1
melunko@917
  5547
	  for obj in $save_oldobjs
melunko@917
  5548
	  do
melunko@917
  5549
	    objbase=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
melunko@917
  5550
	    case " $oldobjs " in
melunko@917
  5551
	    " ") oldobjs=$obj ;;
melunko@917
  5552
	    *[\ /]"$objbase "*)
melunko@917
  5553
	      while :; do
melunko@917
  5554
		# Make sure we don't pick an alternate name that also
melunko@917
  5555
		# overlaps.
melunko@917
  5556
		newobj=lt$counter-$objbase
melunko@917
  5557
		counter=`expr $counter + 1`
melunko@917
  5558
		case " $oldobjs " in
melunko@917
  5559
		*[\ /]"$newobj "*) ;;
melunko@917
  5560
		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
melunko@917
  5561
		esac
melunko@917
  5562
	      done
melunko@917
  5563
	      $show "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
melunko@917
  5564
	      $run ln "$obj" "$gentop/$newobj" ||
melunko@917
  5565
	      $run cp "$obj" "$gentop/$newobj"
melunko@917
  5566
	      oldobjs="$oldobjs $gentop/$newobj"
melunko@917
  5567
	      ;;
melunko@917
  5568
	    *) oldobjs="$oldobjs $obj" ;;
melunko@917
  5569
	    esac
melunko@917
  5570
	  done
melunko@917
  5571
	fi
melunko@917
  5572
melunko@917
  5573
	eval cmds=\"$old_archive_cmds\"
melunko@917
  5574
melunko@917
  5575
	if len=`expr "X$cmds" : ".*"` &&
melunko@917
  5576
	     test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
melunko@917
  5577
	  cmds=$old_archive_cmds
melunko@917
  5578
	else
melunko@917
  5579
	  # the command line is too long to link in one step, link in parts
melunko@917
  5580
	  $echo "using piecewise archive linking..."
melunko@917
  5581
	  save_RANLIB=$RANLIB
melunko@917
  5582
	  RANLIB=:
melunko@917
  5583
	  objlist=
melunko@917
  5584
	  concat_cmds=
melunko@917
  5585
	  save_oldobjs=$oldobjs
melunko@917
  5586
melunko@917
  5587
	  # Is there a better way of finding the last object in the list?
melunko@917
  5588
	  for obj in $save_oldobjs
melunko@917
  5589
	  do
melunko@917
  5590
	    last_oldobj=$obj
melunko@917
  5591
	  done
melunko@917
  5592
	  for obj in $save_oldobjs
melunko@917
  5593
	  do
melunko@917
  5594
	    oldobjs="$objlist $obj"
melunko@917
  5595
	    objlist="$objlist $obj"
melunko@917
  5596
	    eval test_cmds=\"$old_archive_cmds\"
melunko@917
  5597
	    if len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
melunko@917
  5598
	       test "$len" -le "$max_cmd_len"; then
melunko@917
  5599
	      :
melunko@917
  5600
	    else
melunko@917
  5601
	      # the above command should be used before it gets too long
melunko@917
  5602
	      oldobjs=$objlist
melunko@917
  5603
	      if test "$obj" = "$last_oldobj" ; then
melunko@917
  5604
	        RANLIB=$save_RANLIB
melunko@917
  5605
	      fi
melunko@917
  5606
	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
melunko@917
  5607
	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
melunko@917
  5608
	      objlist=
melunko@917
  5609
	    fi
melunko@917
  5610
	  done
melunko@917
  5611
	  RANLIB=$save_RANLIB
melunko@917
  5612
	  oldobjs=$objlist
melunko@917
  5613
	  if test "X$oldobjs" = "X" ; then
melunko@917
  5614
	    eval cmds=\"\$concat_cmds\"
melunko@917
  5615
	  else
melunko@917
  5616
	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
melunko@917
  5617
	  fi
melunko@917
  5618
	fi
melunko@917
  5619
      fi
melunko@917
  5620
      save_ifs="$IFS"; IFS='~'
melunko@917
  5621
      for cmd in $cmds; do
melunko@917
  5622
        eval cmd=\"$cmd\"
melunko@917
  5623
	IFS="$save_ifs"
melunko@917
  5624
	$show "$cmd"
melunko@917
  5625
	$run eval "$cmd" || exit $?
melunko@917
  5626
      done
melunko@917
  5627
      IFS="$save_ifs"
melunko@917
  5628
    done
melunko@917
  5629
melunko@917
  5630
    if test -n "$generated"; then
melunko@917
  5631
      $show "${rm}r$generated"
melunko@917
  5632
      $run ${rm}r$generated
melunko@917
  5633
    fi
melunko@917
  5634
melunko@917
  5635
    # Now create the libtool archive.
melunko@917
  5636
    case $output in
melunko@917
  5637
    *.la)
melunko@917
  5638
      old_library=
melunko@917
  5639
      test "$build_old_libs" = yes && old_library="$libname.$libext"
melunko@917
  5640
      $show "creating $output"
melunko@917
  5641
melunko@917
  5642
      # Preserve any variables that may affect compiler behavior
melunko@917
  5643
      for var in $variables_saved_for_relink; do
melunko@917
  5644
	if eval test -z \"\${$var+set}\"; then
melunko@917
  5645
	  relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command"
melunko@917
  5646
	elif eval var_value=\$$var; test -z "$var_value"; then
melunko@917
  5647
	  relink_command="$var=; export $var; $relink_command"
melunko@917
  5648
	else
melunko@917
  5649
	  var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"`
melunko@917
  5650
	  relink_command="$var=\"$var_value\"; export $var; $relink_command"
melunko@917
  5651
	fi
melunko@917
  5652
      done
melunko@917
  5653
      # Quote the link command for shipping.
melunko@917
  5654
      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
melunko@917
  5655
      relink_command=`$echo "X$relink_command" | $SP2NL | $Xsed -e "$sed_quote_subst" | $NL2SP`
melunko@917
  5656
      if test "$hardcode_automatic" = yes ; then
melunko@917
  5657
	relink_command=
melunko@917
  5658
      fi
melunko@917
  5659
melunko@917
  5660
melunko@917
  5661
      # Only create the output if not a dry run.
melunko@917
  5662
      if test -z "$run"; then
melunko@917
  5663
	for installed in no yes; do
melunko@917
  5664
	  if test "$installed" = yes; then
melunko@917
  5665
	    if test -z "$install_libdir"; then
melunko@917
  5666
	      break
melunko@917
  5667
	    fi
melunko@917
  5668
	    output="$output_objdir/$outputname"i
melunko@917
  5669
	    # Replace all uninstalled libtool libraries with the installed ones
melunko@917
  5670
	    newdependency_libs=
melunko@917
  5671
	    for deplib in $dependency_libs; do
melunko@917
  5672
	      case $deplib in
melunko@917
  5673
	      *.la)
melunko@917
  5674
		name=`$echo "X$deplib" | $Xsed -e 's%^.*/%%'`
melunko@917
  5675
		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
melunko@917
  5676
		if test -z "$libdir"; then
melunko@917
  5677
		  $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
melunko@917
  5678
		  exit $EXIT_FAILURE
melunko@917
  5679
		fi
melunko@917
  5680
		newdependency_libs="$newdependency_libs $libdir/$name"
melunko@917
  5681
		;;
melunko@917
  5682
	      *) newdependency_libs="$newdependency_libs $deplib" ;;
melunko@917
  5683
	      esac
melunko@917
  5684
	    done
melunko@917
  5685
	    dependency_libs="$newdependency_libs"
melunko@917
  5686
	    newdlfiles=
melunko@917
  5687
	    for lib in $dlfiles; do
melunko@917
  5688
	      name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
melunko@917
  5689
	      eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
melunko@917
  5690
	      if test -z "$libdir"; then
melunko@917
  5691
		$echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
melunko@917
  5692
		exit $EXIT_FAILURE
melunko@917
  5693
	      fi
melunko@917
  5694
	      newdlfiles="$newdlfiles $libdir/$name"
melunko@917
  5695
	    done
melunko@917
  5696
	    dlfiles="$newdlfiles"
melunko@917
  5697
	    newdlprefiles=
melunko@917
  5698
	    for lib in $dlprefiles; do
melunko@917
  5699
	      name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
melunko@917
  5700
	      eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
melunko@917
  5701
	      if test -z "$libdir"; then
melunko@917
  5702
		$echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
melunko@917
  5703
		exit $EXIT_FAILURE
melunko@917
  5704
	      fi
melunko@917
  5705
	      newdlprefiles="$newdlprefiles $libdir/$name"
melunko@917
  5706
	    done
melunko@917
  5707
	    dlprefiles="$newdlprefiles"
melunko@917
  5708
	  else
melunko@917
  5709
	    newdlfiles=
melunko@917
  5710
	    for lib in $dlfiles; do
melunko@917
  5711
	      case $lib in
melunko@917
  5712
		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
melunko@917
  5713
		*) abs=`pwd`"/$lib" ;;
melunko@917
  5714
	      esac
melunko@917
  5715
	      newdlfiles="$newdlfiles $abs"
melunko@917
  5716
	    done
melunko@917
  5717
	    dlfiles="$newdlfiles"
melunko@917
  5718
	    newdlprefiles=
melunko@917
  5719
	    for lib in $dlprefiles; do
melunko@917
  5720
	      case $lib in
melunko@917
  5721
		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
melunko@917
  5722
		*) abs=`pwd`"/$lib" ;;
melunko@917
  5723
	      esac
melunko@917
  5724
	      newdlprefiles="$newdlprefiles $abs"
melunko@917
  5725
	    done
melunko@917
  5726
	    dlprefiles="$newdlprefiles"
melunko@917
  5727
	  fi
melunko@917
  5728
	  $rm $output
melunko@917
  5729
	  # place dlname in correct position for cygwin
melunko@917
  5730
	  tdlname=$dlname
melunko@917
  5731
	  case $host,$output,$installed,$module,$dlname in
melunko@917
  5732
	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;;
melunko@917
  5733
	  esac
melunko@917
  5734
	  $echo > $output "\
melunko@917
  5735
# $outputname - a libtool library file
melunko@917
  5736
# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
melunko@917
  5737
#
melunko@917
  5738
# Please DO NOT delete this file!
melunko@917
  5739
# It is necessary for linking the library.
melunko@917
  5740
melunko@917
  5741
# The name that we can dlopen(3).
melunko@917
  5742
dlname='$tdlname'
melunko@917
  5743
melunko@917
  5744
# Names of this library.
melunko@917
  5745
library_names='$library_names'
melunko@917
  5746
melunko@917
  5747
# The name of the static archive.
melunko@917
  5748
old_library='$old_library'
melunko@917
  5749
melunko@917
  5750
# Libraries that this one depends upon.
melunko@917
  5751
dependency_libs='$dependency_libs'
melunko@917
  5752
melunko@917
  5753
# Version information for $libname.
melunko@917
  5754
current=$current
melunko@917
  5755
age=$age
melunko@917
  5756
revision=$revision
melunko@917
  5757
melunko@917
  5758
# Is this an already installed library?
melunko@917
  5759
installed=$installed
melunko@917
  5760
melunko@917
  5761
# Should we warn about portability when linking against -modules?
melunko@917
  5762
shouldnotlink=$module
melunko@917
  5763
melunko@917
  5764
# Files to dlopen/dlpreopen
melunko@917
  5765
dlopen='$dlfiles'
melunko@917
  5766
dlpreopen='$dlprefiles'
melunko@917
  5767
melunko@917
  5768
# Directory that this library needs to be installed in:
melunko@917
  5769
libdir='$install_libdir'"
melunko@917
  5770
	  if test "$installed" = no && test "$need_relink" = yes; then
melunko@917
  5771
	    $echo >> $output "\
melunko@917
  5772
relink_command=\"$relink_command\""
melunko@917
  5773
	  fi
melunko@917
  5774
	done
melunko@917
  5775
      fi
melunko@917
  5776
melunko@917
  5777
      # Do a symbolic link so that the libtool archive can be found in
melunko@917
  5778
      # LD_LIBRARY_PATH before the program is installed.
melunko@917
  5779
      $show "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)"
melunko@917
  5780
      $run eval '(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)' || exit $?
melunko@917
  5781
      ;;
melunko@917
  5782
    esac
melunko@917
  5783
    exit $EXIT_SUCCESS
melunko@917
  5784
    ;;
melunko@917
  5785
melunko@917
  5786
  # libtool install mode
melunko@917
  5787
  install)
melunko@917
  5788
    modename="$modename: install"
melunko@917
  5789
melunko@917
  5790
    # There may be an optional sh(1) argument at the beginning of
melunko@917
  5791
    # install_prog (especially on Windows NT).
melunko@917
  5792
    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
melunko@917
  5793
       # Allow the use of GNU shtool's install command.
melunko@917
  5794
       $echo "X$nonopt" | grep shtool > /dev/null; then
melunko@917
  5795
      # Aesthetically quote it.
melunko@917
  5796
      arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"`
melunko@917
  5797
      case $arg in
melunko@917
  5798
      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
melunko@917
  5799
	arg="\"$arg\""
melunko@917
  5800
	;;
melunko@917
  5801
      esac
melunko@917
  5802
      install_prog="$arg "
melunko@917
  5803
      arg="$1"
melunko@917
  5804
      shift
melunko@917
  5805
    else
melunko@917
  5806
      install_prog=
melunko@917
  5807
      arg=$nonopt
melunko@917
  5808
    fi
melunko@917
  5809
melunko@917
  5810
    # The real first argument should be the name of the installation program.
melunko@917
  5811
    # Aesthetically quote it.
melunko@917
  5812
    arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
melunko@917
  5813
    case $arg in
melunko@917
  5814
    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
melunko@917
  5815
      arg="\"$arg\""
melunko@917
  5816
      ;;
melunko@917
  5817
    esac
melunko@917
  5818
    install_prog="$install_prog$arg"
melunko@917
  5819
melunko@917
  5820
    # We need to accept at least all the BSD install flags.
melunko@917
  5821
    dest=
melunko@917
  5822
    files=
melunko@917
  5823
    opts=
melunko@917
  5824
    prev=
melunko@917
  5825
    install_type=
melunko@917
  5826
    isdir=no
melunko@917
  5827
    stripme=
melunko@917
  5828
    for arg
melunko@917
  5829
    do
melunko@917
  5830
      if test -n "$dest"; then
melunko@917
  5831
	files="$files $dest"
melunko@917
  5832
	dest=$arg
melunko@917
  5833
	continue
melunko@917
  5834
      fi
melunko@917
  5835
melunko@917
  5836
      case $arg in
melunko@917
  5837
      -d) isdir=yes ;;
melunko@917
  5838
      -f) 
melunko@917
  5839
      	case " $install_prog " in
melunko@917
  5840
	*[\\\ /]cp\ *) ;;
melunko@917
  5841
	*) prev=$arg ;;
melunko@917
  5842
	esac
melunko@917
  5843
	;;
melunko@917
  5844
      -g | -m | -o) prev=$arg ;;
melunko@917
  5845
      -s)
melunko@917
  5846
	stripme=" -s"
melunko@917
  5847
	continue
melunko@917
  5848
	;;
melunko@917
  5849
      -*)
melunko@917
  5850
	;;
melunko@917
  5851
      *)
melunko@917
  5852
	# If the previous option needed an argument, then skip it.
melunko@917
  5853
	if test -n "$prev"; then
melunko@917
  5854
	  prev=
melunko@917
  5855
	else
melunko@917
  5856
	  dest=$arg
melunko@917
  5857
	  continue
melunko@917
  5858
	fi
melunko@917
  5859
	;;
melunko@917
  5860
      esac
melunko@917
  5861
melunko@917
  5862
      # Aesthetically quote the argument.
melunko@917
  5863
      arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
melunko@917
  5864
      case $arg in
melunko@917
  5865
      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
melunko@917
  5866
	arg="\"$arg\""
melunko@917
  5867
	;;
melunko@917
  5868
      esac
melunko@917
  5869
      install_prog="$install_prog $arg"
melunko@917
  5870
    done
melunko@917
  5871
melunko@917
  5872
    if test -z "$install_prog"; then
melunko@917
  5873
      $echo "$modename: you must specify an install program" 1>&2
melunko@917
  5874
      $echo "$help" 1>&2
melunko@917
  5875
      exit $EXIT_FAILURE
melunko@917
  5876
    fi
melunko@917
  5877
melunko@917
  5878
    if test -n "$prev"; then
melunko@917
  5879
      $echo "$modename: the \`$prev' option requires an argument" 1>&2
melunko@917
  5880
      $echo "$help" 1>&2
melunko@917
  5881
      exit $EXIT_FAILURE
melunko@917
  5882
    fi
melunko@917
  5883
melunko@917
  5884
    if test -z "$files"; then
melunko@917
  5885
      if test -z "$dest"; then
melunko@917
  5886
	$echo "$modename: no file or destination specified" 1>&2
melunko@917
  5887
      else
melunko@917
  5888
	$echo "$modename: you must specify a destination" 1>&2
melunko@917
  5889
      fi
melunko@917
  5890
      $echo "$help" 1>&2
melunko@917
  5891
      exit $EXIT_FAILURE
melunko@917
  5892
    fi
melunko@917
  5893
melunko@917
  5894
    # Strip any trailing slash from the destination.
melunko@917
  5895
    dest=`$echo "X$dest" | $Xsed -e 's%/$%%'`
melunko@917
  5896
melunko@917
  5897
    # Check to see that the destination is a directory.
melunko@917
  5898
    test -d "$dest" && isdir=yes
melunko@917
  5899
    if test "$isdir" = yes; then
melunko@917
  5900
      destdir="$dest"
melunko@917
  5901
      destname=
melunko@917
  5902
    else
melunko@917
  5903
      destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'`
melunko@917
  5904
      test "X$destdir" = "X$dest" && destdir=.
melunko@917
  5905
      destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'`
melunko@917
  5906
melunko@917
  5907
      # Not a directory, so check to see that there is only one file specified.
melunko@917
  5908
      set dummy $files
melunko@917
  5909
      if test "$#" -gt 2; then
melunko@917
  5910
	$echo "$modename: \`$dest' is not a directory" 1>&2
melunko@917
  5911
	$echo "$help" 1>&2
melunko@917
  5912
	exit $EXIT_FAILURE
melunko@917
  5913
      fi
melunko@917
  5914
    fi
melunko@917
  5915
    case $destdir in
melunko@917
  5916
    [\\/]* | [A-Za-z]:[\\/]*) ;;
melunko@917
  5917
    *)
melunko@917
  5918
      for file in $files; do
melunko@917
  5919
	case $file in
melunko@917
  5920
	*.lo) ;;
melunko@917
  5921
	*)
melunko@917
  5922
	  $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2
melunko@917
  5923
	  $echo "$help" 1>&2
melunko@917
  5924
	  exit $EXIT_FAILURE
melunko@917
  5925
	  ;;
melunko@917
  5926
	esac
melunko@917
  5927
      done
melunko@917
  5928
      ;;
melunko@917
  5929
    esac
melunko@917
  5930
melunko@917
  5931
    # This variable tells wrapper scripts just to set variables rather
melunko@917
  5932
    # than running their programs.
melunko@917
  5933
    libtool_install_magic="$magic"
melunko@917
  5934
melunko@917
  5935
    staticlibs=
melunko@917
  5936
    future_libdirs=
melunko@917
  5937
    current_libdirs=
melunko@917
  5938
    for file in $files; do
melunko@917
  5939
melunko@917
  5940
      # Do each installation.
melunko@917
  5941
      case $file in
melunko@917
  5942
      *.$libext)
melunko@917
  5943
	# Do the static libraries later.
melunko@917
  5944
	staticlibs="$staticlibs $file"
melunko@917
  5945
	;;
melunko@917
  5946
melunko@917
  5947
      *.la)
melunko@917
  5948
	# Check to see that this really is a libtool archive.
melunko@917
  5949
	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
melunko@917
  5950
	else
melunko@917
  5951
	  $echo "$modename: \`$file' is not a valid libtool archive" 1>&2
melunko@917
  5952
	  $echo "$help" 1>&2
melunko@917
  5953
	  exit $EXIT_FAILURE
melunko@917
  5954
	fi
melunko@917
  5955
melunko@917
  5956
	library_names=
melunko@917
  5957
	old_library=
melunko@917
  5958
	relink_command=
melunko@917
  5959
	# If there is no directory component, then add one.
melunko@917
  5960
	case $file in
melunko@917
  5961
	*/* | *\\*) . $file ;;
melunko@917
  5962
	*) . ./$file ;;
melunko@917
  5963
	esac
melunko@917
  5964
melunko@917
  5965
	# Add the libdir to current_libdirs if it is the destination.
melunko@917
  5966
	if test "X$destdir" = "X$libdir"; then
melunko@917
  5967
	  case "$current_libdirs " in
melunko@917
  5968
	  *" $libdir "*) ;;
melunko@917
  5969
	  *) current_libdirs="$current_libdirs $libdir" ;;
melunko@917
  5970
	  esac
melunko@917
  5971
	else
melunko@917
  5972
	  # Note the libdir as a future libdir.
melunko@917
  5973
	  case "$future_libdirs " in
melunko@917
  5974
	  *" $libdir "*) ;;
melunko@917
  5975
	  *) future_libdirs="$future_libdirs $libdir" ;;
melunko@917
  5976
	  esac
melunko@917
  5977
	fi
melunko@917
  5978
melunko@917
  5979
	dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/
melunko@917
  5980
	test "X$dir" = "X$file/" && dir=
melunko@917
  5981
	dir="$dir$objdir"
melunko@917
  5982
melunko@917
  5983
	if test -n "$relink_command"; then
melunko@917
  5984
	  # Determine the prefix the user has applied to our future dir.
melunko@917
  5985
	  inst_prefix_dir=`$echo "$destdir" | $SED "s%$libdir\$%%"`
melunko@917
  5986
melunko@917
  5987
	  # Don't allow the user to place us outside of our expected
melunko@917
  5988
	  # location b/c this prevents finding dependent libraries that
melunko@917
  5989
	  # are installed to the same prefix.
melunko@917
  5990
	  # At present, this check doesn't affect windows .dll's that
melunko@917
  5991
	  # are installed into $libdir/../bin (currently, that works fine)
melunko@917
  5992
	  # but it's something to keep an eye on.
melunko@917
  5993
	  if test "$inst_prefix_dir" = "$destdir"; then
melunko@917
  5994
	    $echo "$modename: error: cannot install \`$file' to a directory not ending in $libdir" 1>&2
melunko@917
  5995
	    exit $EXIT_FAILURE
melunko@917
  5996
	  fi
melunko@917
  5997
melunko@917
  5998
	  if test -n "$inst_prefix_dir"; then
melunko@917
  5999
	    # Stick the inst_prefix_dir data into the link command.
melunko@917
  6000
	    relink_command=`$echo "$relink_command" | $SP2NL | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%" | $NL2SP`
melunko@917
  6001
	  else
melunko@917
  6002
	    relink_command=`$echo "$relink_command" | $SP2NL | $SED "s%@inst_prefix_dir@%%" | $NL2SP`
melunko@917
  6003
	  fi
melunko@917
  6004
melunko@917
  6005
	  $echo "$modename: warning: relinking \`$file'" 1>&2
melunko@917
  6006
	  $show "$relink_command"
melunko@917
  6007
	  if $run eval "$relink_command"; then :
melunko@917
  6008
	  else
melunko@917
  6009
	    $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
melunko@917
  6010
	    exit $EXIT_FAILURE
melunko@917
  6011
	  fi
melunko@917
  6012
	fi
melunko@917
  6013
melunko@917
  6014
	# See the names of the shared library.
melunko@917
  6015
	set dummy $library_names
melunko@917
  6016
	if test -n "$2"; then
melunko@917
  6017
	  realname="$2"
melunko@917
  6018
	  shift
melunko@917
  6019
	  shift
melunko@917
  6020
melunko@917
  6021
	  srcname="$realname"
melunko@917
  6022
	  test -n "$relink_command" && srcname="$realname"T
melunko@917
  6023
melunko@917
  6024
	  # Install the shared library and build the symlinks.
melunko@917
  6025
	  $show "$install_prog $dir/$srcname $destdir/$realname"
melunko@917
  6026
	  $run eval "$install_prog $dir/$srcname $destdir/$realname" || exit $?
melunko@917
  6027
	  if test -n "$stripme" && test -n "$striplib"; then
melunko@917
  6028
	    $show "$striplib $destdir/$realname"
melunko@917
  6029
	    $run eval "$striplib $destdir/$realname" || exit $?
melunko@917
  6030
	  fi
melunko@917
  6031
melunko@917
  6032
	  if test "$#" -gt 0; then
melunko@917
  6033
	    # Delete the old symlinks, and create new ones.
melunko@917
  6034
	    # Try `ln -sf' first, because the `ln' binary might depend on
melunko@917
  6035
	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
melunko@917
  6036
	    # so we also need to try rm && ln -s.
melunko@917
  6037
	    for linkname
melunko@917
  6038
	    do
melunko@917
  6039
	      if test "$linkname" != "$realname"; then
melunko@917
  6040
                $show "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })"
melunko@917
  6041
                $run eval "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })"
melunko@917
  6042
	      fi
melunko@917
  6043
	    done
melunko@917
  6044
	  fi
melunko@917
  6045
melunko@917
  6046
	  # Do each command in the postinstall commands.
melunko@917
  6047
	  lib="$destdir/$realname"
melunko@917
  6048
	  cmds=$postinstall_cmds
melunko@917
  6049
	  save_ifs="$IFS"; IFS='~'
melunko@917
  6050
	  for cmd in $cmds; do
melunko@917
  6051
	    IFS="$save_ifs"
melunko@917
  6052
	    eval cmd=\"$cmd\"
melunko@917
  6053
	    $show "$cmd"
melunko@917
  6054
	    $run eval "$cmd" || {
melunko@917
  6055
	      lt_exit=$?
melunko@917
  6056
melunko@917
  6057
	      # Restore the uninstalled library and exit
melunko@917
  6058
	      if test "$mode" = relink; then
melunko@917
  6059
		$run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)'
melunko@917
  6060
	      fi
melunko@917
  6061
melunko@917
  6062
	      exit $lt_exit
melunko@917
  6063
	    }
melunko@917
  6064
	  done
melunko@917
  6065
	  IFS="$save_ifs"
melunko@917
  6066
	fi
melunko@917
  6067
melunko@917
  6068
	# Install the pseudo-library for information purposes.
melunko@917
  6069
	name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
melunko@917
  6070
	instname="$dir/$name"i
melunko@917
  6071
	$show "$install_prog $instname $destdir/$name"
melunko@917
  6072
	$run eval "$install_prog $instname $destdir/$name" || exit $?
melunko@917
  6073
melunko@917
  6074
	# Maybe install the static library, too.
melunko@917
  6075
	test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
melunko@917
  6076
	;;
melunko@917
  6077
melunko@917
  6078
      *.lo)
melunko@917
  6079
	# Install (i.e. copy) a libtool object.
melunko@917
  6080
melunko@917
  6081
	# Figure out destination file name, if it wasn't already specified.
melunko@917
  6082
	if test -n "$destname"; then
melunko@917
  6083
	  destfile="$destdir/$destname"
melunko@917
  6084
	else
melunko@917
  6085
	  destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
melunko@917
  6086
	  destfile="$destdir/$destfile"
melunko@917
  6087
	fi
melunko@917
  6088
melunko@917
  6089
	# Deduce the name of the destination old-style object file.
melunko@917
  6090
	case $destfile in
melunko@917
  6091
	*.lo)
melunko@917
  6092
	  staticdest=`$echo "X$destfile" | $Xsed -e "$lo2o"`
melunko@917
  6093
	  ;;
melunko@917
  6094
	*.$objext)
melunko@917
  6095
	  staticdest="$destfile"
melunko@917
  6096
	  destfile=
melunko@917
  6097
	  ;;
melunko@917
  6098
	*)
melunko@917
  6099
	  $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2
melunko@917
  6100
	  $echo "$help" 1>&2
melunko@917
  6101
	  exit $EXIT_FAILURE
melunko@917
  6102
	  ;;
melunko@917
  6103
	esac
melunko@917
  6104
melunko@917
  6105
	# Install the libtool object if requested.
melunko@917
  6106
	if test -n "$destfile"; then
melunko@917
  6107
	  $show "$install_prog $file $destfile"
melunko@917
  6108
	  $run eval "$install_prog $file $destfile" || exit $?
melunko@917
  6109
	fi
melunko@917
  6110
melunko@917
  6111
	# Install the old object if enabled.
melunko@917
  6112
	if test "$build_old_libs" = yes; then
melunko@917
  6113
	  # Deduce the name of the old-style object file.
melunko@917
  6114
	  staticobj=`$echo "X$file" | $Xsed -e "$lo2o"`
melunko@917
  6115
melunko@917
  6116
	  $show "$install_prog $staticobj $staticdest"
melunko@917
  6117
	  $run eval "$install_prog \$staticobj \$staticdest" || exit $?
melunko@917
  6118
	fi
melunko@917
  6119
	exit $EXIT_SUCCESS
melunko@917
  6120
	;;
melunko@917
  6121
melunko@917
  6122
      *)
melunko@917
  6123
	# Figure out destination file name, if it wasn't already specified.
melunko@917
  6124
	if test -n "$destname"; then
melunko@917
  6125
	  destfile="$destdir/$destname"
melunko@917
  6126
	else
melunko@917
  6127
	  destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
melunko@917
  6128
	  destfile="$destdir/$destfile"
melunko@917
  6129
	fi
melunko@917
  6130
melunko@917
  6131
	# If the file is missing, and there is a .exe on the end, strip it
melunko@917
  6132
	# because it is most likely a libtool script we actually want to
melunko@917
  6133
	# install
melunko@917
  6134
	stripped_ext=""
melunko@917
  6135
	case $file in
melunko@917
  6136
	  *.exe)
melunko@917
  6137
	    if test ! -f "$file"; then
melunko@917
  6138
	      file=`$echo $file|${SED} 's,.exe$,,'`
melunko@917
  6139
	      stripped_ext=".exe"
melunko@917
  6140
	    fi
melunko@917
  6141
	    ;;
melunko@917
  6142
	esac
melunko@917
  6143
melunko@917
  6144
	# Do a test to see if this is really a libtool program.
melunko@917
  6145
	case $host in
melunko@917
  6146
	*cygwin*|*mingw*)
melunko@917
  6147
	    wrapper=`$echo $file | ${SED} -e 's,.exe$,,'`
melunko@917
  6148
	    ;;
melunko@917
  6149
	*)
melunko@917
  6150
	    wrapper=$file
melunko@917
  6151
	    ;;
melunko@917
  6152
	esac
melunko@917
  6153
	if (${SED} -e '4q' $wrapper | grep "^# Generated by .*$PACKAGE")>/dev/null 2>&1; then
melunko@917
  6154
	  notinst_deplibs=
melunko@917
  6155
	  relink_command=
melunko@917
  6156
melunko@917
  6157
	  # Note that it is not necessary on cygwin/mingw to append a dot to
melunko@917
  6158
	  # foo even if both foo and FILE.exe exist: automatic-append-.exe
melunko@917
  6159
	  # behavior happens only for exec(3), not for open(2)!  Also, sourcing
melunko@917
  6160
	  # `FILE.' does not work on cygwin managed mounts.
melunko@917
  6161
	  #
melunko@917
  6162
	  # If there is no directory component, then add one.
melunko@917
  6163
	  case $wrapper in
melunko@917
  6164
	  */* | *\\*) . ${wrapper} ;;
melunko@917
  6165
	  *) . ./${wrapper} ;;
melunko@917
  6166
	  esac
melunko@917
  6167
melunko@917
  6168
	  # Check the variables that should have been set.
melunko@917
  6169
	  if test -z "$notinst_deplibs"; then
melunko@917
  6170
	    $echo "$modename: invalid libtool wrapper script \`$wrapper'" 1>&2
melunko@917
  6171
	    exit $EXIT_FAILURE
melunko@917
  6172
	  fi
melunko@917
  6173
melunko@917
  6174
	  finalize=yes
melunko@917
  6175
	  for lib in $notinst_deplibs; do
melunko@917
  6176
	    # Check to see that each library is installed.
melunko@917
  6177
	    libdir=
melunko@917
  6178
	    if test -f "$lib"; then
melunko@917
  6179
	      # If there is no directory component, then add one.
melunko@917
  6180
	      case $lib in
melunko@917
  6181
	      */* | *\\*) . $lib ;;
melunko@917
  6182
	      *) . ./$lib ;;
melunko@917
  6183
	      esac
melunko@917
  6184
	    fi
melunko@917
  6185
	    libfile="$libdir/"`$echo "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test
melunko@917
  6186
	    if test -n "$libdir" && test ! -f "$libfile"; then
melunko@917
  6187
	      $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2
melunko@917
  6188
	      finalize=no
melunko@917
  6189
	    fi
melunko@917
  6190
	  done
melunko@917
  6191
melunko@917
  6192
	  relink_command=
melunko@917
  6193
	  # Note that it is not necessary on cygwin/mingw to append a dot to
melunko@917
  6194
	  # foo even if both foo and FILE.exe exist: automatic-append-.exe
melunko@917
  6195
	  # behavior happens only for exec(3), not for open(2)!  Also, sourcing
melunko@917
  6196
	  # `FILE.' does not work on cygwin managed mounts.
melunko@917
  6197
	  #
melunko@917
  6198
	  # If there is no directory component, then add one.
melunko@917
  6199
	  case $wrapper in
melunko@917
  6200
	  */* | *\\*) . ${wrapper} ;;
melunko@917
  6201
	  *) . ./${wrapper} ;;
melunko@917
  6202
	  esac
melunko@917
  6203
melunko@917
  6204
	  outputname=
melunko@917
  6205
	  if test "$fast_install" = no && test -n "$relink_command"; then
melunko@917
  6206
	    if test "$finalize" = yes && test -z "$run"; then
melunko@917
  6207
	      tmpdir=`func_mktempdir`
melunko@917
  6208
	      file=`$echo "X$file$stripped_ext" | $Xsed -e 's%^.*/%%'`
melunko@917
  6209
	      outputname="$tmpdir/$file"
melunko@917
  6210
	      # Replace the output file specification.
melunko@917
  6211
	      relink_command=`$echo "X$relink_command" | $SP2NL | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g' | $NL2SP`
melunko@917
  6212
melunko@917
  6213
	      $show "$relink_command"
melunko@917
  6214
	      if $run eval "$relink_command"; then :
melunko@917
  6215
	      else
melunko@917
  6216
		$echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
melunko@917
  6217
		${rm}r "$tmpdir"
melunko@917
  6218
		continue
melunko@917
  6219
	      fi
melunko@917
  6220
	      file="$outputname"
melunko@917
  6221
	    else
melunko@917
  6222
	      $echo "$modename: warning: cannot relink \`$file'" 1>&2
melunko@917
  6223
	    fi
melunko@917
  6224
	  else
melunko@917
  6225
	    # Install the binary that we compiled earlier.
melunko@917
  6226
	    file=`$echo "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"`
melunko@917
  6227
	  fi
melunko@917
  6228
	fi
melunko@917
  6229
melunko@917
  6230
	# remove .exe since cygwin /usr/bin/install will append another
melunko@917
  6231
	# one anyway 
melunko@917
  6232
	case $install_prog,$host in
melunko@917
  6233
	*/usr/bin/install*,*cygwin*)
melunko@917
  6234
	  case $file:$destfile in
melunko@917
  6235
	  *.exe:*.exe)
melunko@917
  6236
	    # this is ok
melunko@917
  6237
	    ;;
melunko@917
  6238
	  *.exe:*)
melunko@917
  6239
	    destfile=$destfile.exe
melunko@917
  6240
	    ;;
melunko@917
  6241
	  *:*.exe)
melunko@917
  6242
	    destfile=`$echo $destfile | ${SED} -e 's,.exe$,,'`
melunko@917
  6243
	    ;;
melunko@917
  6244
	  esac
melunko@917
  6245
	  ;;
melunko@917
  6246
	esac
melunko@917
  6247
	$show "$install_prog$stripme $file $destfile"
melunko@917
  6248
	$run eval "$install_prog\$stripme \$file \$destfile" || exit $?
melunko@917
  6249
	test -n "$outputname" && ${rm}r "$tmpdir"
melunko@917
  6250
	;;
melunko@917
  6251
      esac
melunko@917
  6252
    done
melunko@917
  6253
melunko@917
  6254
    for file in $staticlibs; do
melunko@917
  6255
      name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
melunko@917
  6256
melunko@917
  6257
      # Set up the ranlib parameters.
melunko@917
  6258
      oldlib="$destdir/$name"
melunko@917
  6259
melunko@917
  6260
      $show "$install_prog $file $oldlib"
melunko@917
  6261
      $run eval "$install_prog \$file \$oldlib" || exit $?
melunko@917
  6262
melunko@917
  6263
      if test -n "$stripme" && test -n "$old_striplib"; then
melunko@917
  6264
	$show "$old_striplib $oldlib"
melunko@917
  6265
	$run eval "$old_striplib $oldlib" || exit $?
melunko@917
  6266
      fi
melunko@917
  6267
melunko@917
  6268
      # Do each command in the postinstall commands.
melunko@917
  6269
      cmds=$old_postinstall_cmds
melunko@917
  6270
      save_ifs="$IFS"; IFS='~'
melunko@917
  6271
      for cmd in $cmds; do
melunko@917
  6272
	IFS="$save_ifs"
melunko@917
  6273
	eval cmd=\"$cmd\"
melunko@917
  6274
	$show "$cmd"
melunko@917
  6275
	$run eval "$cmd" || exit $?
melunko@917
  6276
      done
melunko@917
  6277
      IFS="$save_ifs"
melunko@917
  6278
    done
melunko@917
  6279
melunko@917
  6280
    if test -n "$future_libdirs"; then
melunko@917
  6281
      $echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2
melunko@917
  6282
    fi
melunko@917
  6283
melunko@917
  6284
    if test -n "$current_libdirs"; then
melunko@917
  6285
      # Maybe just do a dry run.
melunko@917
  6286
      test -n "$run" && current_libdirs=" -n$current_libdirs"
melunko@917
  6287
      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
melunko@917
  6288
    else
melunko@917
  6289
      exit $EXIT_SUCCESS
melunko@917
  6290
    fi
melunko@917
  6291
    ;;
melunko@917
  6292
melunko@917
  6293
  # libtool finish mode
melunko@917
  6294
  finish)
melunko@917
  6295
    modename="$modename: finish"
melunko@917
  6296
    libdirs="$nonopt"
melunko@917
  6297
    admincmds=
melunko@917
  6298
melunko@917
  6299
    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
melunko@917
  6300
      for dir
melunko@917
  6301
      do
melunko@917
  6302
	libdirs="$libdirs $dir"
melunko@917
  6303
      done
melunko@917
  6304
melunko@917
  6305
      for libdir in $libdirs; do
melunko@917
  6306
	if test -n "$finish_cmds"; then
melunko@917
  6307
	  # Do each command in the finish commands.
melunko@917
  6308
	  cmds=$finish_cmds
melunko@917
  6309
	  save_ifs="$IFS"; IFS='~'
melunko@917
  6310
	  for cmd in $cmds; do
melunko@917
  6311
	    IFS="$save_ifs"
melunko@917
  6312
	    eval cmd=\"$cmd\"
melunko@917
  6313
	    $show "$cmd"
melunko@917
  6314
	    $run eval "$cmd" || admincmds="$admincmds
melunko@917
  6315
       $cmd"
melunko@917
  6316
	  done
melunko@917
  6317
	  IFS="$save_ifs"
melunko@917
  6318
	fi
melunko@917
  6319
	if test -n "$finish_eval"; then
melunko@917
  6320
	  # Do the single finish_eval.
melunko@917
  6321
	  eval cmds=\"$finish_eval\"
melunko@917
  6322
	  $run eval "$cmds" || admincmds="$admincmds
melunko@917
  6323
       $cmds"
melunko@917
  6324
	fi
melunko@917
  6325
      done
melunko@917
  6326
    fi
melunko@917
  6327
melunko@917
  6328
    # Exit here if they wanted silent mode.
melunko@917
  6329
    test "$show" = : && exit $EXIT_SUCCESS
melunko@917
  6330
melunko@917
  6331
    $echo "X----------------------------------------------------------------------" | $Xsed
melunko@917
  6332
    $echo "Libraries have been installed in:"
melunko@917
  6333
    for libdir in $libdirs; do
melunko@917
  6334
      $echo "   $libdir"
melunko@917
  6335
    done
melunko@917
  6336
    $echo
melunko@917
  6337
    $echo "If you ever happen to want to link against installed libraries"
melunko@917
  6338
    $echo "in a given directory, LIBDIR, you must either use libtool, and"
melunko@917
  6339
    $echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
melunko@917
  6340
    $echo "flag during linking and do at least one of the following:"
melunko@917
  6341
    if test -n "$shlibpath_var"; then
melunko@917
  6342
      $echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
melunko@917
  6343
      $echo "     during execution"
melunko@917
  6344
    fi
melunko@917
  6345
    if test -n "$runpath_var"; then
melunko@917
  6346
      $echo "   - add LIBDIR to the \`$runpath_var' environment variable"
melunko@917
  6347
      $echo "     during linking"
melunko@917
  6348
    fi
melunko@917
  6349
    if test -n "$hardcode_libdir_flag_spec"; then
melunko@917
  6350
      libdir=LIBDIR
melunko@917
  6351
      eval flag=\"$hardcode_libdir_flag_spec\"
melunko@917
  6352
melunko@917
  6353
      $echo "   - use the \`$flag' linker flag"
melunko@917
  6354
    fi
melunko@917
  6355
    if test -n "$admincmds"; then
melunko@917
  6356
      $echo "   - have your system administrator run these commands:$admincmds"
melunko@917
  6357
    fi
melunko@917
  6358
    if test -f /etc/ld.so.conf; then
melunko@917
  6359
      $echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
melunko@917
  6360
    fi
melunko@917
  6361
    $echo
melunko@917
  6362
    $echo "See any operating system documentation about shared libraries for"
melunko@917
  6363
    $echo "more information, such as the ld(1) and ld.so(8) manual pages."
melunko@917
  6364
    $echo "X----------------------------------------------------------------------" | $Xsed
melunko@917
  6365
    exit $EXIT_SUCCESS
melunko@917
  6366
    ;;
melunko@917
  6367
melunko@917
  6368
  # libtool execute mode
melunko@917
  6369
  execute)
melunko@917
  6370
    modename="$modename: execute"
melunko@917
  6371
melunko@917
  6372
    # The first argument is the command name.
melunko@917
  6373
    cmd="$nonopt"
melunko@917
  6374
    if test -z "$cmd"; then
melunko@917
  6375
      $echo "$modename: you must specify a COMMAND" 1>&2
melunko@917
  6376
      $echo "$help"
melunko@917
  6377
      exit $EXIT_FAILURE
melunko@917
  6378
    fi
melunko@917
  6379
melunko@917
  6380
    # Handle -dlopen flags immediately.
melunko@917
  6381
    for file in $execute_dlfiles; do
melunko@917
  6382
      if test ! -f "$file"; then
melunko@917
  6383
	$echo "$modename: \`$file' is not a file" 1>&2
melunko@917
  6384
	$echo "$help" 1>&2
melunko@917
  6385
	exit $EXIT_FAILURE
melunko@917
  6386
      fi
melunko@917
  6387
melunko@917
  6388
      dir=
melunko@917
  6389
      case $file in
melunko@917
  6390
      *.la)
melunko@917
  6391
	# Check to see that this really is a libtool archive.
melunko@917
  6392
	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
melunko@917
  6393
	else
melunko@917
  6394
	  $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
melunko@917
  6395
	  $echo "$help" 1>&2
melunko@917
  6396
	  exit $EXIT_FAILURE
melunko@917
  6397
	fi
melunko@917
  6398
melunko@917
  6399
	# Read the libtool library.
melunko@917
  6400
	dlname=
melunko@917
  6401
	library_names=
melunko@917
  6402
melunko@917
  6403
	# If there is no directory component, then add one.
melunko@917
  6404
	case $file in
melunko@917
  6405
	*/* | *\\*) . $file ;;
melunko@917
  6406
	*) . ./$file ;;
melunko@917
  6407
	esac
melunko@917
  6408
melunko@917
  6409
	# Skip this library if it cannot be dlopened.
melunko@917
  6410
	if test -z "$dlname"; then
melunko@917
  6411
	  # Warn if it was a shared library.
melunko@917
  6412
	  test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'"
melunko@917
  6413
	  continue
melunko@917
  6414
	fi
melunko@917
  6415
melunko@917
  6416
	dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
melunko@917
  6417
	test "X$dir" = "X$file" && dir=.
melunko@917
  6418
melunko@917
  6419
	if test -f "$dir/$objdir/$dlname"; then
melunko@917
  6420
	  dir="$dir/$objdir"
melunko@917
  6421
	else
melunko@917
  6422
	  if test ! -f "$dir/$dlname"; then
melunko@917
  6423
	    $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2
melunko@917
  6424
	    exit $EXIT_FAILURE
melunko@917
  6425
	  fi
melunko@917
  6426
	fi
melunko@917
  6427
	;;
melunko@917
  6428
melunko@917
  6429
      *.lo)
melunko@917
  6430
	# Just add the directory containing the .lo file.
melunko@917
  6431
	dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
melunko@917
  6432
	test "X$dir" = "X$file" && dir=.
melunko@917
  6433
	;;
melunko@917
  6434
melunko@917
  6435
      *)
melunko@917
  6436
	$echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2
melunko@917
  6437
	continue
melunko@917
  6438
	;;
melunko@917
  6439
      esac
melunko@917
  6440
melunko@917
  6441
      # Get the absolute pathname.
melunko@917
  6442
      absdir=`cd "$dir" && pwd`
melunko@917
  6443
      test -n "$absdir" && dir="$absdir"
melunko@917
  6444
melunko@917
  6445
      # Now add the directory to shlibpath_var.
melunko@917
  6446
      if eval "test -z \"\$$shlibpath_var\""; then
melunko@917
  6447
	eval "$shlibpath_var=\"\$dir\""
melunko@917
  6448
      else
melunko@917
  6449
	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
melunko@917
  6450
      fi
melunko@917
  6451
    done
melunko@917
  6452
melunko@917
  6453
    # This variable tells wrapper scripts just to set shlibpath_var
melunko@917
  6454
    # rather than running their programs.
melunko@917
  6455
    libtool_execute_magic="$magic"
melunko@917
  6456
melunko@917
  6457
    # Check if any of the arguments is a wrapper script.
melunko@917
  6458
    args=
melunko@917
  6459
    for file
melunko@917
  6460
    do
melunko@917
  6461
      case $file in
melunko@917
  6462
      -*) ;;
melunko@917
  6463
      *)
melunko@917
  6464
	# Do a test to see if this is really a libtool program.
melunko@917
  6465
	if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
melunko@917
  6466
	  # If there is no directory component, then add one.
melunko@917
  6467
	  case $file in
melunko@917
  6468
	  */* | *\\*) . $file ;;
melunko@917
  6469
	  *) . ./$file ;;
melunko@917
  6470
	  esac
melunko@917
  6471
melunko@917
  6472
	  # Transform arg to wrapped name.
melunko@917
  6473
	  file="$progdir/$program"
melunko@917
  6474
	fi
melunko@917
  6475
	;;
melunko@917
  6476
      esac
melunko@917
  6477
      # Quote arguments (to preserve shell metacharacters).
melunko@917
  6478
      file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"`
melunko@917
  6479
      args="$args \"$file\""
melunko@917
  6480
    done
melunko@917
  6481
melunko@917
  6482
    if test -z "$run"; then
melunko@917
  6483
      if test -n "$shlibpath_var"; then
melunko@917
  6484
	# Export the shlibpath_var.
melunko@917
  6485
	eval "export $shlibpath_var"
melunko@917
  6486
      fi
melunko@917
  6487
melunko@917
  6488
      # Restore saved environment variables
melunko@917
  6489
      for lt_var in LANG LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
melunko@917
  6490
      do
melunko@917
  6491
	eval "if test \"\${save_$lt_var+set}\" = set; then
melunko@917
  6492
		$lt_var=\$save_$lt_var; export $lt_var
melunko@917
  6493
	      fi"
melunko@917
  6494
      done
melunko@917
  6495
melunko@917
  6496
      # Now prepare to actually exec the command.
melunko@917
  6497
      exec_cmd="\$cmd$args"
melunko@917
  6498
    else
melunko@917
  6499
      # Display what would be done.
melunko@917
  6500
      if test -n "$shlibpath_var"; then
melunko@917
  6501
	eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\""
melunko@917
  6502
	$echo "export $shlibpath_var"
melunko@917
  6503
      fi
melunko@917
  6504
      $echo "$cmd$args"
melunko@917
  6505
      exit $EXIT_SUCCESS
melunko@917
  6506
    fi
melunko@917
  6507
    ;;
melunko@917
  6508
melunko@917
  6509
  # libtool clean and uninstall mode
melunko@917
  6510
  clean | uninstall)
melunko@917
  6511
    modename="$modename: $mode"
melunko@917
  6512
    rm="$nonopt"
melunko@917
  6513
    files=
melunko@917
  6514
    rmforce=
melunko@917
  6515
    exit_status=0
melunko@917
  6516
melunko@917
  6517
    # This variable tells wrapper scripts just to set variables rather
melunko@917
  6518
    # than running their programs.
melunko@917
  6519
    libtool_install_magic="$magic"
melunko@917
  6520
melunko@917
  6521
    for arg
melunko@917
  6522
    do
melunko@917
  6523
      case $arg in
melunko@917
  6524
      -f) rm="$rm $arg"; rmforce=yes ;;
melunko@917
  6525
      -*) rm="$rm $arg" ;;
melunko@917
  6526
      *) files="$files $arg" ;;
melunko@917
  6527
      esac
melunko@917
  6528
    done
melunko@917
  6529
melunko@917
  6530
    if test -z "$rm"; then
melunko@917
  6531
      $echo "$modename: you must specify an RM program" 1>&2
melunko@917
  6532
      $echo "$help" 1>&2
melunko@917
  6533
      exit $EXIT_FAILURE
melunko@917
  6534
    fi
melunko@917
  6535
melunko@917
  6536
    rmdirs=
melunko@917
  6537
melunko@917
  6538
    origobjdir="$objdir"
melunko@917
  6539
    for file in $files; do
melunko@917
  6540
      dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
melunko@917
  6541
      if test "X$dir" = "X$file"; then
melunko@917
  6542
	dir=.
melunko@917
  6543
	objdir="$origobjdir"
melunko@917
  6544
      else
melunko@917
  6545
	objdir="$dir/$origobjdir"
melunko@917
  6546
      fi
melunko@917
  6547
      name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
melunko@917
  6548
      test "$mode" = uninstall && objdir="$dir"
melunko@917
  6549
melunko@917
  6550
      # Remember objdir for removal later, being careful to avoid duplicates
melunko@917
  6551
      if test "$mode" = clean; then
melunko@917
  6552
	case " $rmdirs " in
melunko@917
  6553
	  *" $objdir "*) ;;
melunko@917
  6554
	  *) rmdirs="$rmdirs $objdir" ;;
melunko@917
  6555
	esac
melunko@917
  6556
      fi
melunko@917
  6557
melunko@917
  6558
      # Don't error if the file doesn't exist and rm -f was used.
melunko@917
  6559
      if (test -L "$file") >/dev/null 2>&1 \
melunko@917
  6560
	|| (test -h "$file") >/dev/null 2>&1 \
melunko@917
  6561
	|| test -f "$file"; then
melunko@917
  6562
	:
melunko@917
  6563
      elif test -d "$file"; then
melunko@917
  6564
	exit_status=1
melunko@917
  6565
	continue
melunko@917
  6566
      elif test "$rmforce" = yes; then
melunko@917
  6567
	continue
melunko@917
  6568
      fi
melunko@917
  6569
melunko@917
  6570
      rmfiles="$file"
melunko@917
  6571
melunko@917
  6572
      case $name in
melunko@917
  6573
      *.la)
melunko@917
  6574
	# Possibly a libtool archive, so verify it.
melunko@917
  6575
	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
melunko@917
  6576
	  . $dir/$name
melunko@917
  6577
melunko@917
  6578
	  # Delete the libtool libraries and symlinks.
melunko@917
  6579
	  for n in $library_names; do
melunko@917
  6580
	    rmfiles="$rmfiles $objdir/$n"
melunko@917
  6581
	  done
melunko@917
  6582
	  test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
melunko@917
  6583
melunko@917
  6584
	  case "$mode" in
melunko@917
  6585
	  clean)
melunko@917
  6586
	    case "  $library_names " in
melunko@917
  6587
	    # "  " in the beginning catches empty $dlname
melunko@917
  6588
	    *" $dlname "*) ;;
melunko@917
  6589
	    *) rmfiles="$rmfiles $objdir/$dlname" ;;
melunko@917
  6590
	    esac
melunko@917
  6591
	     test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
melunko@917
  6592
	    ;;
melunko@917
  6593
	  uninstall)
melunko@917
  6594
	    if test -n "$library_names"; then
melunko@917
  6595
	      # Do each command in the postuninstall commands.
melunko@917
  6596
	      cmds=$postuninstall_cmds
melunko@917
  6597
	      save_ifs="$IFS"; IFS='~'
melunko@917
  6598
	      for cmd in $cmds; do
melunko@917
  6599
		IFS="$save_ifs"
melunko@917
  6600
		eval cmd=\"$cmd\"
melunko@917
  6601
		$show "$cmd"
melunko@917
  6602
		$run eval "$cmd"
melunko@917
  6603
		if test "$?" -ne 0 && test "$rmforce" != yes; then
melunko@917
  6604
		  exit_status=1
melunko@917
  6605
		fi
melunko@917
  6606
	      done
melunko@917
  6607
	      IFS="$save_ifs"
melunko@917
  6608
	    fi
melunko@917
  6609
melunko@917
  6610
	    if test -n "$old_library"; then
melunko@917
  6611
	      # Do each command in the old_postuninstall commands.
melunko@917
  6612
	      cmds=$old_postuninstall_cmds
melunko@917
  6613
	      save_ifs="$IFS"; IFS='~'
melunko@917
  6614
	      for cmd in $cmds; do
melunko@917
  6615
		IFS="$save_ifs"
melunko@917
  6616
		eval cmd=\"$cmd\"
melunko@917
  6617
		$show "$cmd"
melunko@917
  6618
		$run eval "$cmd"
melunko@917
  6619
		if test "$?" -ne 0 && test "$rmforce" != yes; then
melunko@917
  6620
		  exit_status=1
melunko@917
  6621
		fi
melunko@917
  6622
	      done
melunko@917
  6623
	      IFS="$save_ifs"
melunko@917
  6624
	    fi
melunko@917
  6625
	    # FIXME: should reinstall the best remaining shared library.
melunko@917
  6626
	    ;;
melunko@917
  6627
	  esac
melunko@917
  6628
	fi
melunko@917
  6629
	;;
melunko@917
  6630
melunko@917
  6631
      *.lo)
melunko@917
  6632
	# Possibly a libtool object, so verify it.
melunko@917
  6633
	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
melunko@917
  6634
melunko@917
  6635
	  # Read the .lo file
melunko@917
  6636
	  . $dir/$name
melunko@917
  6637
melunko@917
  6638
	  # Add PIC object to the list of files to remove.
melunko@917
  6639
	  if test -n "$pic_object" \
melunko@917
  6640
	     && test "$pic_object" != none; then
melunko@917
  6641
	    rmfiles="$rmfiles $dir/$pic_object"
melunko@917
  6642
	  fi
melunko@917
  6643
melunko@917
  6644
	  # Add non-PIC object to the list of files to remove.
melunko@917
  6645
	  if test -n "$non_pic_object" \
melunko@917
  6646
	     && test "$non_pic_object" != none; then
melunko@917
  6647
	    rmfiles="$rmfiles $dir/$non_pic_object"
melunko@917
  6648
	  fi
melunko@917
  6649
	fi
melunko@917
  6650
	;;
melunko@917
  6651
melunko@917
  6652
      *)
melunko@917
  6653
	if test "$mode" = clean ; then
melunko@917
  6654
	  noexename=$name
melunko@917
  6655
	  case $file in
melunko@917
  6656
	  *.exe)
melunko@917
  6657
	    file=`$echo $file|${SED} 's,.exe$,,'`
melunko@917
  6658
	    noexename=`$echo $name|${SED} 's,.exe$,,'`
melunko@917
  6659
	    # $file with .exe has already been added to rmfiles,
melunko@917
  6660
	    # add $file without .exe
melunko@917
  6661
	    rmfiles="$rmfiles $file"
melunko@917
  6662
	    ;;
melunko@917
  6663
	  esac
melunko@917
  6664
	  # Do a test to see if this is a libtool program.
melunko@917
  6665
	  if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
melunko@917
  6666
	    relink_command=
melunko@917
  6667
	    . $dir/$noexename
melunko@917
  6668
melunko@917
  6669
	    # note $name still contains .exe if it was in $file originally
melunko@917
  6670
	    # as does the version of $file that was added into $rmfiles
melunko@917
  6671
	    rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}"
melunko@917
  6672
	    if test "$fast_install" = yes && test -n "$relink_command"; then
melunko@917
  6673
	      rmfiles="$rmfiles $objdir/lt-$name"
melunko@917
  6674
	    fi
melunko@917
  6675
	    if test "X$noexename" != "X$name" ; then
melunko@917
  6676
	      rmfiles="$rmfiles $objdir/lt-${noexename}.c"
melunko@917
  6677
	    fi
melunko@917
  6678
	  fi
melunko@917
  6679
	fi
melunko@917
  6680
	;;
melunko@917
  6681
      esac
melunko@917
  6682
      $show "$rm $rmfiles"
melunko@917
  6683
      $run $rm $rmfiles || exit_status=1
melunko@917
  6684
    done
melunko@917
  6685
    objdir="$origobjdir"
melunko@917
  6686
melunko@917
  6687
    # Try to remove the ${objdir}s in the directories where we deleted files
melunko@917
  6688
    for dir in $rmdirs; do
melunko@917
  6689
      if test -d "$dir"; then
melunko@917
  6690
	$show "rmdir $dir"
melunko@917
  6691
	$run rmdir $dir >/dev/null 2>&1
melunko@917
  6692
      fi
melunko@917
  6693
    done
melunko@917
  6694
melunko@917
  6695
    exit $exit_status
melunko@917
  6696
    ;;
melunko@917
  6697
melunko@917
  6698
  "")
melunko@917
  6699
    $echo "$modename: you must specify a MODE" 1>&2
melunko@917
  6700
    $echo "$generic_help" 1>&2
melunko@917
  6701
    exit $EXIT_FAILURE
melunko@917
  6702
    ;;
melunko@917
  6703
  esac
melunko@917
  6704
melunko@917
  6705
  if test -z "$exec_cmd"; then
melunko@917
  6706
    $echo "$modename: invalid operation mode \`$mode'" 1>&2
melunko@917
  6707
    $echo "$generic_help" 1>&2
melunko@917
  6708
    exit $EXIT_FAILURE
melunko@917
  6709
  fi
melunko@917
  6710
fi # test -z "$show_help"
melunko@917
  6711
melunko@917
  6712
if test -n "$exec_cmd"; then
melunko@917
  6713
  eval exec $exec_cmd
melunko@917
  6714
  exit $EXIT_FAILURE
melunko@917
  6715
fi
melunko@917
  6716
melunko@917
  6717
# We need to display help for each of the modes.
melunko@917
  6718
case $mode in
melunko@917
  6719
"") $echo \
melunko@917
  6720
"Usage: $modename [OPTION]... [MODE-ARG]...
melunko@917
  6721
melunko@917
  6722
Provide generalized library-building support services.
melunko@917
  6723
melunko@917
  6724
    --config          show all configuration variables
melunko@917
  6725
    --debug           enable verbose shell tracing
melunko@917
  6726
-n, --dry-run         display commands without modifying any files
melunko@917
  6727
    --features        display basic configuration information and exit
melunko@917
  6728
    --finish          same as \`--mode=finish'
melunko@917
  6729
    --help            display this help message and exit
melunko@917
  6730
    --mode=MODE       use operation mode MODE [default=inferred from MODE-ARGS]
melunko@917
  6731
    --quiet           same as \`--silent'
melunko@917
  6732
    --silent          don't print informational messages
melunko@917
  6733
    --tag=TAG         use configuration variables from tag TAG
melunko@917
  6734
    --version         print version information
melunko@917
  6735
melunko@917
  6736
MODE must be one of the following:
melunko@917
  6737
melunko@917
  6738
      clean           remove files from the build directory
melunko@917
  6739
      compile         compile a source file into a libtool object
melunko@917
  6740
      execute         automatically set library path, then run a program
melunko@917
  6741
      finish          complete the installation of libtool libraries
melunko@917
  6742
      install         install libraries or executables
melunko@917
  6743
      link            create a library or an executable
melunko@917
  6744
      uninstall       remove libraries from an installed directory
melunko@917
  6745
melunko@917
  6746
MODE-ARGS vary depending on the MODE.  Try \`$modename --help --mode=MODE' for
melunko@917
  6747
a more detailed description of MODE.
melunko@917
  6748
melunko@917
  6749
Report bugs to <bug-libtool@gnu.org>."
melunko@917
  6750
  exit $EXIT_SUCCESS
melunko@917
  6751
  ;;
melunko@917
  6752
melunko@917
  6753
clean)
melunko@917
  6754
  $echo \
melunko@917
  6755
"Usage: $modename [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
melunko@917
  6756
melunko@917
  6757
Remove files from the build directory.
melunko@917
  6758
melunko@917
  6759
RM is the name of the program to use to delete files associated with each FILE
melunko@917
  6760
(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
melunko@917
  6761
to RM.
melunko@917
  6762
melunko@917
  6763
If FILE is a libtool library, object or program, all the files associated
melunko@917
  6764
with it are deleted. Otherwise, only FILE itself is deleted using RM."
melunko@917
  6765
  ;;
melunko@917
  6766
melunko@917
  6767
compile)
melunko@917
  6768
  $echo \
melunko@917
  6769
"Usage: $modename [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
melunko@917
  6770
melunko@917
  6771
Compile a source file into a libtool library object.
melunko@917
  6772
melunko@917
  6773
This mode accepts the following additional options:
melunko@917
  6774
melunko@917
  6775
  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
melunko@917
  6776
  -prefer-pic       try to building PIC objects only
melunko@917
  6777
  -prefer-non-pic   try to building non-PIC objects only
melunko@917
  6778
  -static           always build a \`.o' file suitable for static linking
melunko@917
  6779
melunko@917
  6780
COMPILE-COMMAND is a command to be used in creating a \`standard' object file
melunko@917
  6781
from the given SOURCEFILE.
melunko@917
  6782
melunko@917
  6783
The output file name is determined by removing the directory component from
melunko@917
  6784
SOURCEFILE, then substituting the C source code suffix \`.c' with the
melunko@917
  6785
library object suffix, \`.lo'."
melunko@917
  6786
  ;;
melunko@917
  6787
melunko@917
  6788
execute)
melunko@917
  6789
  $echo \
melunko@917
  6790
"Usage: $modename [OPTION]... --mode=execute COMMAND [ARGS]...
melunko@917
  6791
melunko@917
  6792
Automatically set library path, then run a program.
melunko@917
  6793
melunko@917
  6794
This mode accepts the following additional options:
melunko@917
  6795
melunko@917
  6796
  -dlopen FILE      add the directory containing FILE to the library path
melunko@917
  6797
melunko@917
  6798
This mode sets the library path environment variable according to \`-dlopen'
melunko@917
  6799
flags.
melunko@917
  6800
melunko@917
  6801
If any of the ARGS are libtool executable wrappers, then they are translated
melunko@917
  6802
into their corresponding uninstalled binary, and any of their required library
melunko@917
  6803
directories are added to the library path.
melunko@917
  6804
melunko@917
  6805
Then, COMMAND is executed, with ARGS as arguments."
melunko@917
  6806
  ;;
melunko@917
  6807
melunko@917
  6808
finish)
melunko@917
  6809
  $echo \
melunko@917
  6810
"Usage: $modename [OPTION]... --mode=finish [LIBDIR]...
melunko@917
  6811
melunko@917
  6812
Complete the installation of libtool libraries.
melunko@917
  6813
melunko@917
  6814
Each LIBDIR is a directory that contains libtool libraries.
melunko@917
  6815
melunko@917
  6816
The commands that this mode executes may require superuser privileges.  Use
melunko@917
  6817
the \`--dry-run' option if you just want to see what would be executed."
melunko@917
  6818
  ;;
melunko@917
  6819
melunko@917
  6820
install)
melunko@917
  6821
  $echo \
melunko@917
  6822
"Usage: $modename [OPTION]... --mode=install INSTALL-COMMAND...
melunko@917
  6823
melunko@917
  6824
Install executables or libraries.
melunko@917
  6825
melunko@917
  6826
INSTALL-COMMAND is the installation command.  The first component should be
melunko@917
  6827
either the \`install' or \`cp' program.
melunko@917
  6828
melunko@917
  6829
The rest of the components are interpreted as arguments to that command (only
melunko@917
  6830
BSD-compatible install options are recognized)."
melunko@917
  6831
  ;;
melunko@917
  6832
melunko@917
  6833
link)
melunko@917
  6834
  $echo \
melunko@917
  6835
"Usage: $modename [OPTION]... --mode=link LINK-COMMAND...
melunko@917
  6836
melunko@917
  6837
Link object files or libraries together to form another library, or to
melunko@917
  6838
create an executable program.
melunko@917
  6839
melunko@917
  6840
LINK-COMMAND is a command using the C compiler that you would use to create
melunko@917
  6841
a program from several object files.
melunko@917
  6842
melunko@917
  6843
The following components of LINK-COMMAND are treated specially:
melunko@917
  6844
melunko@917
  6845
  -all-static       do not do any dynamic linking at all
melunko@917
  6846
  -avoid-version    do not add a version suffix if possible
melunko@917
  6847
  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
melunko@917
  6848
  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
melunko@917
  6849
  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
melunko@917
  6850
  -export-symbols SYMFILE
melunko@917
  6851
                    try to export only the symbols listed in SYMFILE
melunko@917
  6852
  -export-symbols-regex REGEX
melunko@917
  6853
                    try to export only the symbols matching REGEX
melunko@917
  6854
  -LLIBDIR          search LIBDIR for required installed libraries
melunko@917
  6855
  -lNAME            OUTPUT-FILE requires the installed library libNAME
melunko@917
  6856
  -module           build a library that can dlopened
melunko@917
  6857
  -no-fast-install  disable the fast-install mode
melunko@917
  6858
  -no-install       link a not-installable executable
melunko@917
  6859
  -no-undefined     declare that a library does not refer to external symbols
melunko@917
  6860
  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
melunko@917
  6861
  -objectlist FILE  Use a list of object files found in FILE to specify objects
melunko@917
  6862
  -precious-files-regex REGEX
melunko@917
  6863
                    don't remove output files matching REGEX
melunko@917
  6864
  -release RELEASE  specify package release information
melunko@917
  6865
  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
melunko@917
  6866
  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
melunko@917
  6867
  -static           do not do any dynamic linking of uninstalled libtool libraries
melunko@917
  6868
  -static-libtool-libs
melunko@917
  6869
                    do not do any dynamic linking of libtool libraries
melunko@917
  6870
  -version-info CURRENT[:REVISION[:AGE]]
melunko@917
  6871
                    specify library version info [each variable defaults to 0]
melunko@917
  6872
melunko@917
  6873
All other options (arguments beginning with \`-') are ignored.
melunko@917
  6874
melunko@917
  6875
Every other argument is treated as a filename.  Files ending in \`.la' are
melunko@917
  6876
treated as uninstalled libtool libraries, other files are standard or library
melunko@917
  6877
object files.
melunko@917
  6878
melunko@917
  6879
If the OUTPUT-FILE ends in \`.la', then a libtool library is created,
melunko@917
  6880
only library objects (\`.lo' files) may be specified, and \`-rpath' is
melunko@917
  6881
required, except when creating a convenience library.
melunko@917
  6882
melunko@917
  6883
If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
melunko@917
  6884
using \`ar' and \`ranlib', or on Windows using \`lib'.
melunko@917
  6885
melunko@917
  6886
If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
melunko@917
  6887
is created, otherwise an executable program is created."
melunko@917
  6888
  ;;
melunko@917
  6889
melunko@917
  6890
uninstall)
melunko@917
  6891
  $echo \
melunko@917
  6892
"Usage: $modename [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
melunko@917
  6893
melunko@917
  6894
Remove libraries from an installation directory.
melunko@917
  6895
melunko@917
  6896
RM is the name of the program to use to delete files associated with each FILE
melunko@917
  6897
(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
melunko@917
  6898
to RM.
melunko@917
  6899
melunko@917
  6900
If FILE is a libtool library, all the files associated with it are deleted.
melunko@917
  6901
Otherwise, only FILE itself is deleted using RM."
melunko@917
  6902
  ;;
melunko@917
  6903
melunko@917
  6904
*)
melunko@917
  6905
  $echo "$modename: invalid operation mode \`$mode'" 1>&2
melunko@917
  6906
  $echo "$help" 1>&2
melunko@917
  6907
  exit $EXIT_FAILURE
melunko@917
  6908
  ;;
melunko@917
  6909
esac
melunko@917
  6910
melunko@917
  6911
$echo
melunko@917
  6912
$echo "Try \`$modename --help' for more information about other modes."
melunko@917
  6913
melunko@917
  6914
exit $?
melunko@917
  6915
melunko@917
  6916
# The TAGs below are defined such that we never get into a situation
melunko@917
  6917
# in which we disable both kinds of libraries.  Given conflicting
melunko@917
  6918
# choices, we go for a static library, that is the most portable,
melunko@917
  6919
# since we can't tell whether shared libraries were disabled because
melunko@917
  6920
# the user asked for that or because the platform doesn't support
melunko@917
  6921
# them.  This is particularly important on AIX, because we don't
melunko@917
  6922
# support having both static and shared libraries enabled at the same
melunko@917
  6923
# time on that platform, so we default to a shared-only configuration.
melunko@917
  6924
# If a disable-shared tag is given, we'll fallback to a static-only
melunko@917
  6925
# configuration.  But we'll never go from static-only to shared-only.
melunko@917
  6926
melunko@917
  6927
# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
melunko@917
  6928
disable_libs=shared
melunko@917
  6929
# ### END LIBTOOL TAG CONFIG: disable-shared
melunko@917
  6930
melunko@917
  6931
# ### BEGIN LIBTOOL TAG CONFIG: disable-static
melunko@917
  6932
disable_libs=static
melunko@917
  6933
# ### END LIBTOOL TAG CONFIG: disable-static
melunko@917
  6934
melunko@917
  6935
# Local Variables:
melunko@917
  6936
# mode:shell-script
melunko@917
  6937
# sh-indentation:2
melunko@917
  6938
# End: