ltmain.sh revision 54b5899c
1c82838c1Smrg#! /usr/bin/env sh
235c4bbdfSmrg## DO NOT EDIT - This file generated from ./build-aux/ltmain.in
3c82838c1Smrg##               by inline-source v2019-02-19.15
44642e01fSmrg
554b5899cSmrg# libtool (GNU libtool) 2.5.4
635c4bbdfSmrg# Provide generalized library-building support services.
74642e01fSmrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
84642e01fSmrg
954b5899cSmrg# Copyright (C) 1996-2019, 2021-2024 Free Software Foundation, Inc.
104642e01fSmrg# This is free software; see the source for copying conditions.  There is NO
114642e01fSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
124642e01fSmrg
134642e01fSmrg# GNU Libtool is free software; you can redistribute it and/or modify
1405b261ecSmrg# it under the terms of the GNU General Public License as published by
1505b261ecSmrg# the Free Software Foundation; either version 2 of the License, or
1605b261ecSmrg# (at your option) any later version.
1705b261ecSmrg#
184642e01fSmrg# As a special exception to the GNU General Public License,
194642e01fSmrg# if you distribute this file as part of a program or library that
204642e01fSmrg# is built using GNU Libtool, you may include this file under the
214642e01fSmrg# same distribution terms that you use for the rest of that program.
224642e01fSmrg#
234642e01fSmrg# GNU Libtool is distributed in the hope that it will be useful, but
2405b261ecSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of
2505b261ecSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
2605b261ecSmrg# General Public License for more details.
2705b261ecSmrg#
2805b261ecSmrg# You should have received a copy of the GNU General Public License
2935c4bbdfSmrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
3005b261ecSmrg
3105b261ecSmrg
326747b715SmrgPROGRAM=libtool
3305b261ecSmrgPACKAGE=libtool
3454b5899cSmrgVERSION=2.5.4
3554b5899cSmrgpackage_revision=2.5.4
3605b261ecSmrg
3735c4bbdfSmrg
3835c4bbdfSmrg## ------ ##
3935c4bbdfSmrg## Usage. ##
4035c4bbdfSmrg## ------ ##
4135c4bbdfSmrg
4235c4bbdfSmrg# Run './libtool --help' for help with using this script from the
4335c4bbdfSmrg# command line.
4435c4bbdfSmrg
4535c4bbdfSmrg
4635c4bbdfSmrg## ------------------------------- ##
4735c4bbdfSmrg## User overridable command paths. ##
4835c4bbdfSmrg## ------------------------------- ##
4935c4bbdfSmrg
5035c4bbdfSmrg# After configure completes, it has a better idea of some of the
5135c4bbdfSmrg# shell tools we need than the defaults used by the functions shared
5235c4bbdfSmrg# with bootstrap, so set those here where they can still be over-
5335c4bbdfSmrg# ridden by the user, but otherwise take precedence.
5435c4bbdfSmrg
5535c4bbdfSmrg: ${AUTOCONF="autoconf"}
5635c4bbdfSmrg: ${AUTOMAKE="automake"}
5735c4bbdfSmrg
5835c4bbdfSmrg
5935c4bbdfSmrg## -------------------------- ##
6035c4bbdfSmrg## Source external libraries. ##
6135c4bbdfSmrg## -------------------------- ##
6235c4bbdfSmrg
6335c4bbdfSmrg# Much of our low-level functionality needs to be sourced from external
6435c4bbdfSmrg# libraries, which are installed to $pkgauxdir.
6535c4bbdfSmrg
6635c4bbdfSmrg# Set a version string for this script.
67c82838c1Smrgscriptversion=2019-02-19.15; # UTC
6835c4bbdfSmrg
6935c4bbdfSmrg# General shell script boiler plate, and helper functions.
7035c4bbdfSmrg# Written by Gary V. Vaughan, 2004
7135c4bbdfSmrg
72c82838c1Smrg# This is free software.  There is NO warranty; not even for
73c82838c1Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
74c82838c1Smrg#
7554b5899cSmrg# Copyright (C) 2004-2019, 2021, 2023-2024 Bootstrap Authors
76c82838c1Smrg#
77c82838c1Smrg# This file is dual licensed under the terms of the MIT license
7854b5899cSmrg# <https://opensource.org/licenses/MIT>, and GPL version 2 or later
7954b5899cSmrg# <https://www.gnu.org/licenses/gpl-2.0.html>.  You must apply one of
80c82838c1Smrg# these licenses when using or redistributing this software or any of
81c82838c1Smrg# the files within it.  See the URLs above, or the file `LICENSE`
82c82838c1Smrg# included in the Bootstrap distribution for the full license texts.
8335c4bbdfSmrg
84c82838c1Smrg# Please report bugs or propose patches to:
85c82838c1Smrg# <https://github.com/gnulib-modules/bootstrap/issues>
8635c4bbdfSmrg
8735c4bbdfSmrg
8835c4bbdfSmrg## ------ ##
8935c4bbdfSmrg## Usage. ##
9035c4bbdfSmrg## ------ ##
9135c4bbdfSmrg
9235c4bbdfSmrg# Evaluate this file near the top of your script to gain access to
9335c4bbdfSmrg# the functions and variables defined here:
9435c4bbdfSmrg#
9535c4bbdfSmrg#   . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh
9635c4bbdfSmrg#
9735c4bbdfSmrg# If you need to override any of the default environment variable
9835c4bbdfSmrg# settings, do that before evaluating this file.
9935c4bbdfSmrg
10035c4bbdfSmrg
10135c4bbdfSmrg## -------------------- ##
10235c4bbdfSmrg## Shell normalisation. ##
10335c4bbdfSmrg## -------------------- ##
10435c4bbdfSmrg
10535c4bbdfSmrg# Some shells need a little help to be as Bourne compatible as possible.
10635c4bbdfSmrg# Before doing anything else, make sure all that help has been provided!
10735c4bbdfSmrg
10835c4bbdfSmrgDUALCASE=1; export DUALCASE # for MKS sh
10935c4bbdfSmrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
11005b261ecSmrg  emulate sh
11105b261ecSmrg  NULLCMD=:
11235c4bbdfSmrg  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
11305b261ecSmrg  # is contrary to our usage.  Disable this feature.
11405b261ecSmrg  alias -g '${1+"$@"}'='"$@"'
11505b261ecSmrg  setopt NO_GLOB_SUBST
11605b261ecSmrgelse
11735c4bbdfSmrg  case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac
11805b261ecSmrgfi
1196747b715Smrg
12035c4bbdfSmrg# NLS nuisances: We save the old values in case they are required later.
12135c4bbdfSmrg_G_user_locale=
12235c4bbdfSmrg_G_safe_locale=
12335c4bbdfSmrgfor _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
12405b261ecSmrgdo
12535c4bbdfSmrg  eval "if test set = \"\${$_G_var+set}\"; then
12635c4bbdfSmrg          save_$_G_var=\$$_G_var
12735c4bbdfSmrg          $_G_var=C
12835c4bbdfSmrg	  export $_G_var
12935c4bbdfSmrg	  _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\"
13035c4bbdfSmrg	  _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\"
13105b261ecSmrg	fi"
13205b261ecSmrgdone
133c82838c1Smrg# These NLS vars are set unconditionally (bootstrap issue #24).  Unset those
134c82838c1Smrg# in case the environment reset is needed later and the $save_* variant is not
135c82838c1Smrg# defined (see the code above).
136c82838c1SmrgLC_ALL=C
137c82838c1SmrgLANGUAGE=C
138c82838c1Smrgexport LANGUAGE LC_ALL
1394642e01fSmrg
14035c4bbdfSmrg# Make sure IFS has a sensible default
14135c4bbdfSmrgsp=' '
14235c4bbdfSmrgnl='
14335c4bbdfSmrg'
14435c4bbdfSmrgIFS="$sp	$nl"
14535c4bbdfSmrg
14654b5899cSmrg# There are apparently some systems that use ';' as a PATH separator!
14735c4bbdfSmrgif test "${PATH_SEPARATOR+set}" != set; then
14835c4bbdfSmrg  PATH_SEPARATOR=:
14935c4bbdfSmrg  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
15035c4bbdfSmrg    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
15135c4bbdfSmrg      PATH_SEPARATOR=';'
15235c4bbdfSmrg  }
15335c4bbdfSmrgfi
1544642e01fSmrg
1554642e01fSmrg
156c82838c1Smrg# func_unset VAR
157c82838c1Smrg# --------------
158c82838c1Smrg# Portably unset VAR.
159c82838c1Smrg# In some shells, an 'unset VAR' statement leaves a non-zero return
160c82838c1Smrg# status if VAR is already unset, which might be problematic if the
161c82838c1Smrg# statement is used at the end of a function (thus poisoning its return
162c82838c1Smrg# value) or when 'set -e' is active (causing even a spurious abort of
163c82838c1Smrg# the script in this case).
164c82838c1Smrgfunc_unset ()
165c82838c1Smrg{
166c82838c1Smrg    { eval $1=; (eval unset $1) >/dev/null 2>&1 && eval unset $1 || : ; }
167c82838c1Smrg}
168c82838c1Smrg
169c82838c1Smrg
170c82838c1Smrg# Make sure CDPATH doesn't cause `cd` commands to output the target dir.
171c82838c1Smrgfunc_unset CDPATH
172c82838c1Smrg
173c82838c1Smrg# Make sure ${,E,F}GREP behave sanely.
174c82838c1Smrgfunc_unset GREP_OPTIONS
175c82838c1Smrg
1764642e01fSmrg
17735c4bbdfSmrg## ------------------------- ##
17835c4bbdfSmrg## Locate command utilities. ##
17935c4bbdfSmrg## ------------------------- ##
18035c4bbdfSmrg
18135c4bbdfSmrg
18235c4bbdfSmrg# func_executable_p FILE
18335c4bbdfSmrg# ----------------------
18435c4bbdfSmrg# Check that FILE is an executable regular file.
18535c4bbdfSmrgfunc_executable_p ()
18635c4bbdfSmrg{
18735c4bbdfSmrg    test -f "$1" && test -x "$1"
18835c4bbdfSmrg}
18935c4bbdfSmrg
19035c4bbdfSmrg
19135c4bbdfSmrg# func_path_progs PROGS_LIST CHECK_FUNC [PATH]
19235c4bbdfSmrg# --------------------------------------------
19335c4bbdfSmrg# Search for either a program that responds to --version with output
19435c4bbdfSmrg# containing "GNU", or else returned by CHECK_FUNC otherwise, by
19535c4bbdfSmrg# trying all the directories in PATH with each of the elements of
19635c4bbdfSmrg# PROGS_LIST.
19735c4bbdfSmrg#
19835c4bbdfSmrg# CHECK_FUNC should accept the path to a candidate program, and
19935c4bbdfSmrg# set $func_check_prog_result if it truncates its output less than
20035c4bbdfSmrg# $_G_path_prog_max characters.
20135c4bbdfSmrgfunc_path_progs ()
20235c4bbdfSmrg{
20335c4bbdfSmrg    _G_progs_list=$1
20435c4bbdfSmrg    _G_check_func=$2
20535c4bbdfSmrg    _G_PATH=${3-"$PATH"}
20635c4bbdfSmrg
20735c4bbdfSmrg    _G_path_prog_max=0
20835c4bbdfSmrg    _G_path_prog_found=false
20935c4bbdfSmrg    _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:}
21035c4bbdfSmrg    for _G_dir in $_G_PATH; do
21135c4bbdfSmrg      IFS=$_G_save_IFS
21235c4bbdfSmrg      test -z "$_G_dir" && _G_dir=.
21335c4bbdfSmrg      for _G_prog_name in $_G_progs_list; do
21435c4bbdfSmrg        for _exeext in '' .EXE; do
21535c4bbdfSmrg          _G_path_prog=$_G_dir/$_G_prog_name$_exeext
21635c4bbdfSmrg          func_executable_p "$_G_path_prog" || continue
21735c4bbdfSmrg          case `"$_G_path_prog" --version 2>&1` in
21835c4bbdfSmrg            *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;;
21935c4bbdfSmrg            *)     $_G_check_func $_G_path_prog
22035c4bbdfSmrg		   func_path_progs_result=$func_check_prog_result
22135c4bbdfSmrg		   ;;
22235c4bbdfSmrg          esac
22335c4bbdfSmrg          $_G_path_prog_found && break 3
22435c4bbdfSmrg        done
22535c4bbdfSmrg      done
22635c4bbdfSmrg    done
22735c4bbdfSmrg    IFS=$_G_save_IFS
22835c4bbdfSmrg    test -z "$func_path_progs_result" && {
22935c4bbdfSmrg      echo "no acceptable sed could be found in \$PATH" >&2
23035c4bbdfSmrg      exit 1
23135c4bbdfSmrg    }
23235c4bbdfSmrg}
23335c4bbdfSmrg
23435c4bbdfSmrg
23535c4bbdfSmrg# We want to be able to use the functions in this file before configure
23635c4bbdfSmrg# has figured out where the best binaries are kept, which means we have
23735c4bbdfSmrg# to search for them ourselves - except when the results are already set
23835c4bbdfSmrg# where we skip the searches.
23935c4bbdfSmrg
24035c4bbdfSmrg# Unless the user overrides by setting SED, search the path for either GNU
24135c4bbdfSmrg# sed, or the sed that truncates its output the least.
24235c4bbdfSmrgtest -z "$SED" && {
24335c4bbdfSmrg  _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
24435c4bbdfSmrg  for _G_i in 1 2 3 4 5 6 7; do
24535c4bbdfSmrg    _G_sed_script=$_G_sed_script$nl$_G_sed_script
24635c4bbdfSmrg  done
24735c4bbdfSmrg  echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed
24835c4bbdfSmrg  _G_sed_script=
24935c4bbdfSmrg
25035c4bbdfSmrg  func_check_prog_sed ()
25135c4bbdfSmrg  {
25235c4bbdfSmrg    _G_path_prog=$1
25335c4bbdfSmrg
25435c4bbdfSmrg    _G_count=0
25535c4bbdfSmrg    printf 0123456789 >conftest.in
25635c4bbdfSmrg    while :
25735c4bbdfSmrg    do
25835c4bbdfSmrg      cat conftest.in conftest.in >conftest.tmp
25935c4bbdfSmrg      mv conftest.tmp conftest.in
26035c4bbdfSmrg      cp conftest.in conftest.nl
26135c4bbdfSmrg      echo '' >> conftest.nl
26235c4bbdfSmrg      "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break
26335c4bbdfSmrg      diff conftest.out conftest.nl >/dev/null 2>&1 || break
26435c4bbdfSmrg      _G_count=`expr $_G_count + 1`
26535c4bbdfSmrg      if test "$_G_count" -gt "$_G_path_prog_max"; then
26635c4bbdfSmrg        # Best one so far, save it but keep looking for a better one
26735c4bbdfSmrg        func_check_prog_result=$_G_path_prog
26835c4bbdfSmrg        _G_path_prog_max=$_G_count
26935c4bbdfSmrg      fi
27035c4bbdfSmrg      # 10*(2^10) chars as input seems more than enough
27135c4bbdfSmrg      test 10 -lt "$_G_count" && break
27235c4bbdfSmrg    done
27335c4bbdfSmrg    rm -f conftest.in conftest.tmp conftest.nl conftest.out
27435c4bbdfSmrg  }
27535c4bbdfSmrg
276c82838c1Smrg  func_path_progs "sed gsed" func_check_prog_sed "$PATH:/usr/xpg4/bin"
27735c4bbdfSmrg  rm -f conftest.sed
27835c4bbdfSmrg  SED=$func_path_progs_result
27935c4bbdfSmrg}
28035c4bbdfSmrg
28135c4bbdfSmrg
28235c4bbdfSmrg# Unless the user overrides by setting GREP, search the path for either GNU
28335c4bbdfSmrg# grep, or the grep that truncates its output the least.
28435c4bbdfSmrgtest -z "$GREP" && {
28535c4bbdfSmrg  func_check_prog_grep ()
28635c4bbdfSmrg  {
28735c4bbdfSmrg    _G_path_prog=$1
28835c4bbdfSmrg
28935c4bbdfSmrg    _G_count=0
29035c4bbdfSmrg    _G_path_prog_max=0
29135c4bbdfSmrg    printf 0123456789 >conftest.in
29235c4bbdfSmrg    while :
29335c4bbdfSmrg    do
29435c4bbdfSmrg      cat conftest.in conftest.in >conftest.tmp
29535c4bbdfSmrg      mv conftest.tmp conftest.in
29635c4bbdfSmrg      cp conftest.in conftest.nl
29735c4bbdfSmrg      echo 'GREP' >> conftest.nl
29835c4bbdfSmrg      "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break
29935c4bbdfSmrg      diff conftest.out conftest.nl >/dev/null 2>&1 || break
30035c4bbdfSmrg      _G_count=`expr $_G_count + 1`
30135c4bbdfSmrg      if test "$_G_count" -gt "$_G_path_prog_max"; then
30235c4bbdfSmrg        # Best one so far, save it but keep looking for a better one
30335c4bbdfSmrg        func_check_prog_result=$_G_path_prog
30435c4bbdfSmrg        _G_path_prog_max=$_G_count
30535c4bbdfSmrg      fi
30635c4bbdfSmrg      # 10*(2^10) chars as input seems more than enough
30735c4bbdfSmrg      test 10 -lt "$_G_count" && break
30835c4bbdfSmrg    done
30935c4bbdfSmrg    rm -f conftest.in conftest.tmp conftest.nl conftest.out
31035c4bbdfSmrg  }
31135c4bbdfSmrg
312c82838c1Smrg  func_path_progs "grep ggrep" func_check_prog_grep "$PATH:/usr/xpg4/bin"
31335c4bbdfSmrg  GREP=$func_path_progs_result
31435c4bbdfSmrg}
31535c4bbdfSmrg
31635c4bbdfSmrg
31735c4bbdfSmrg## ------------------------------- ##
31835c4bbdfSmrg## User overridable command paths. ##
31935c4bbdfSmrg## ------------------------------- ##
32035c4bbdfSmrg
32135c4bbdfSmrg# All uppercase variable names are used for environment variables.  These
32235c4bbdfSmrg# variables can be overridden by the user before calling a script that
32335c4bbdfSmrg# uses them if a suitable command of that name is not already available
32435c4bbdfSmrg# in the command search PATH.
3254642e01fSmrg
3264642e01fSmrg: ${CP="cp -f"}
32735c4bbdfSmrg: ${ECHO="printf %s\n"}
32835c4bbdfSmrg: ${EGREP="$GREP -E"}
32935c4bbdfSmrg: ${FGREP="$GREP -F"}
3304642e01fSmrg: ${LN_S="ln -s"}
3314642e01fSmrg: ${MAKE="make"}
3324642e01fSmrg: ${MKDIR="mkdir"}
3334642e01fSmrg: ${MV="mv -f"}
3344642e01fSmrg: ${RM="rm -f"}
3354642e01fSmrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
3364642e01fSmrg
3374642e01fSmrg
33835c4bbdfSmrg## -------------------- ##
33935c4bbdfSmrg## Useful sed snippets. ##
34035c4bbdfSmrg## -------------------- ##
34105b261ecSmrg
34235c4bbdfSmrgsed_dirname='s|/[^/]*$||'
34335c4bbdfSmrgsed_basename='s|^.*/||'
34405b261ecSmrg
34535c4bbdfSmrg# Sed substitution that helps us do robust quoting.  It backslashifies
34635c4bbdfSmrg# metacharacters that are still active within double-quoted strings.
34735c4bbdfSmrgsed_quote_subst='s|\([`"$\\]\)|\\\1|g'
3484642e01fSmrg
34935c4bbdfSmrg# Same as above, but do not quote variable references.
35035c4bbdfSmrgsed_double_quote_subst='s/\(["`\\]\)/\\\1/g'
35135c4bbdfSmrg
35235c4bbdfSmrg# Sed substitution that turns a string into a regex matching for the
35335c4bbdfSmrg# string literally.
35435c4bbdfSmrgsed_make_literal_regex='s|[].[^$\\*\/]|\\&|g'
35535c4bbdfSmrg
35635c4bbdfSmrg# Sed substitution that converts a w32 file name or path
35735c4bbdfSmrg# that contains forward slashes, into one that contains
35835c4bbdfSmrg# (escaped) backslashes.  A very naive implementation.
35935c4bbdfSmrgsed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
36035c4bbdfSmrg
36135c4bbdfSmrg# Re-'\' parameter expansions in output of sed_double_quote_subst that
36235c4bbdfSmrg# were '\'-ed in input to the same.  If an odd number of '\' preceded a
36335c4bbdfSmrg# '$' in input to sed_double_quote_subst, that '$' was protected from
36435c4bbdfSmrg# expansion.  Since each input '\' is now two '\'s, look for any number
36535c4bbdfSmrg# of runs of four '\'s followed by two '\'s and then a '$'.  '\' that '$'.
36635c4bbdfSmrg_G_bs='\\'
36735c4bbdfSmrg_G_bs2='\\\\'
36835c4bbdfSmrg_G_bs4='\\\\\\\\'
36935c4bbdfSmrg_G_dollar='\$'
37035c4bbdfSmrgsed_double_backslash="\
37135c4bbdfSmrg  s/$_G_bs4/&\\
37235c4bbdfSmrg/g
37335c4bbdfSmrg  s/^$_G_bs2$_G_dollar/$_G_bs&/
37435c4bbdfSmrg  s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g
37535c4bbdfSmrg  s/\n//g"
3766747b715Smrg
377c82838c1Smrg# require_check_ifs_backslash
378c82838c1Smrg# ---------------------------
379c82838c1Smrg# Check if we can use backslash as IFS='\' separator, and set
380c82838c1Smrg# $check_ifs_backshlash_broken to ':' or 'false'.
381c82838c1Smrgrequire_check_ifs_backslash=func_require_check_ifs_backslash
382c82838c1Smrgfunc_require_check_ifs_backslash ()
383c82838c1Smrg{
384c82838c1Smrg  _G_save_IFS=$IFS
385c82838c1Smrg  IFS='\'
386c82838c1Smrg  _G_check_ifs_backshlash='a\\b'
387c82838c1Smrg  for _G_i in $_G_check_ifs_backshlash
388c82838c1Smrg  do
389c82838c1Smrg  case $_G_i in
390c82838c1Smrg  a)
391c82838c1Smrg    check_ifs_backshlash_broken=false
392c82838c1Smrg    ;;
393c82838c1Smrg  '')
394c82838c1Smrg    break
395c82838c1Smrg    ;;
396c82838c1Smrg  *)
397c82838c1Smrg    check_ifs_backshlash_broken=:
398c82838c1Smrg    break
399c82838c1Smrg    ;;
400c82838c1Smrg  esac
401c82838c1Smrg  done
402c82838c1Smrg  IFS=$_G_save_IFS
403c82838c1Smrg  require_check_ifs_backslash=:
404c82838c1Smrg}
405c82838c1Smrg
4066747b715Smrg
40735c4bbdfSmrg## ----------------- ##
40835c4bbdfSmrg## Global variables. ##
40935c4bbdfSmrg## ----------------- ##
4106747b715Smrg
41135c4bbdfSmrg# Except for the global variables explicitly listed below, the following
41235c4bbdfSmrg# functions in the '^func_' namespace, and the '^require_' namespace
41335c4bbdfSmrg# variables initialised in the 'Resource management' section, sourcing
41435c4bbdfSmrg# this file will not pollute your global namespace with anything
41535c4bbdfSmrg# else. There's no portable way to scope variables in Bourne shell
41635c4bbdfSmrg# though, so actually running these functions will sometimes place
41735c4bbdfSmrg# results into a variable named after the function, and often use
41835c4bbdfSmrg# temporary variables in the '^_G_' namespace. If you are careful to
41935c4bbdfSmrg# avoid using those namespaces casually in your sourcing script, things
42035c4bbdfSmrg# should continue to work as you expect. And, of course, you can freely
42135c4bbdfSmrg# overwrite any of the functions or variables defined here before
42235c4bbdfSmrg# calling anything to customize them.
42305b261ecSmrg
42435c4bbdfSmrgEXIT_SUCCESS=0
42535c4bbdfSmrgEXIT_FAILURE=1
42635c4bbdfSmrgEXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
42735c4bbdfSmrgEXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
4284642e01fSmrg
42935c4bbdfSmrg# Allow overriding, eg assuming that you follow the convention of
43035c4bbdfSmrg# putting '$debug_cmd' at the start of all your functions, you can get
43135c4bbdfSmrg# bash to show function call trace with:
43235c4bbdfSmrg#
433c82838c1Smrg#    debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name
43435c4bbdfSmrgdebug_cmd=${debug_cmd-":"}
43535c4bbdfSmrgexit_cmd=:
4366747b715Smrg
43735c4bbdfSmrg# By convention, finish your script with:
43835c4bbdfSmrg#
43935c4bbdfSmrg#    exit $exit_status
44035c4bbdfSmrg#
44135c4bbdfSmrg# so that you can set exit_status to non-zero if you want to indicate
44235c4bbdfSmrg# something went wrong during execution without actually bailing out at
44335c4bbdfSmrg# the point of failure.
44435c4bbdfSmrgexit_status=$EXIT_SUCCESS
44535c4bbdfSmrg
44635c4bbdfSmrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
44735c4bbdfSmrg# is ksh but when the shell is invoked as "sh" and the current value of
44835c4bbdfSmrg# the _XPG environment variable is not equal to 1 (one), the special
44935c4bbdfSmrg# positional parameter $0, within a function call, is the name of the
45035c4bbdfSmrg# function.
45135c4bbdfSmrgprogpath=$0
4524642e01fSmrg
45335c4bbdfSmrg# The name of this program.
45435c4bbdfSmrgprogname=`$ECHO "$progpath" |$SED "$sed_basename"`
4554642e01fSmrg
45635c4bbdfSmrg# Make sure we have an absolute progpath for reexecution:
4574642e01fSmrgcase $progpath in
4584642e01fSmrg  [\\/]*|[A-Za-z]:\\*) ;;
4594642e01fSmrg  *[\\/]*)
46035c4bbdfSmrg     progdir=`$ECHO "$progpath" |$SED "$sed_dirname"`
4614642e01fSmrg     progdir=`cd "$progdir" && pwd`
46235c4bbdfSmrg     progpath=$progdir/$progname
4634642e01fSmrg     ;;
4644642e01fSmrg  *)
46535c4bbdfSmrg     _G_IFS=$IFS
46635c4bbdfSmrg     IFS=${PATH_SEPARATOR-:}
4674642e01fSmrg     for progdir in $PATH; do
46835c4bbdfSmrg       IFS=$_G_IFS
4694642e01fSmrg       test -x "$progdir/$progname" && break
4704642e01fSmrg     done
47135c4bbdfSmrg     IFS=$_G_IFS
4724642e01fSmrg     test -n "$progdir" || progdir=`pwd`
47335c4bbdfSmrg     progpath=$progdir/$progname
4744642e01fSmrg     ;;
4754642e01fSmrgesac
4764642e01fSmrg
4774642e01fSmrg
47835c4bbdfSmrg## ----------------- ##
47935c4bbdfSmrg## Standard options. ##
48035c4bbdfSmrg## ----------------- ##
48135c4bbdfSmrg
48235c4bbdfSmrg# The following options affect the operation of the functions defined
48335c4bbdfSmrg# below, and should be set appropriately depending on run-time para-
48435c4bbdfSmrg# meters passed on the command line.
4854642e01fSmrg
4864642e01fSmrgopt_dry_run=false
4874642e01fSmrgopt_quiet=false
4884642e01fSmrgopt_verbose=false
4894642e01fSmrg
49035c4bbdfSmrg# Categories 'all' and 'none' are always available.  Append any others
49135c4bbdfSmrg# you will pass as the first argument to func_warning from your own
49235c4bbdfSmrg# code.
49335c4bbdfSmrgwarning_categories=
4944642e01fSmrg
49535c4bbdfSmrg# By default, display warnings according to 'opt_warning_types'.  Set
49635c4bbdfSmrg# 'warning_func'  to ':' to elide all warnings, or func_fatal_error to
49735c4bbdfSmrg# treat the next displayed warning as a fatal error.
49835c4bbdfSmrgwarning_func=func_warn_and_continue
4994642e01fSmrg
50035c4bbdfSmrg# Set to 'all' to display all warnings, 'none' to suppress all
50135c4bbdfSmrg# warnings, or a space delimited list of some subset of
50235c4bbdfSmrg# 'warning_categories' to display only the listed warnings.
50335c4bbdfSmrgopt_warning_types=all
5044642e01fSmrg
5056747b715Smrg
50635c4bbdfSmrg## -------------------- ##
50735c4bbdfSmrg## Resource management. ##
50835c4bbdfSmrg## -------------------- ##
5094642e01fSmrg
51035c4bbdfSmrg# This section contains definitions for functions that each ensure a
51135c4bbdfSmrg# particular resource (a file, or a non-empty configuration variable for
51235c4bbdfSmrg# example) is available, and if appropriate to extract default values
51335c4bbdfSmrg# from pertinent package files. Call them using their associated
51435c4bbdfSmrg# 'require_*' variable to ensure that they are executed, at most, once.
51535c4bbdfSmrg#
51635c4bbdfSmrg# It's entirely deliberate that calling these functions can set
51735c4bbdfSmrg# variables that don't obey the namespace limitations obeyed by the rest
51835c4bbdfSmrg# of this file, in order that that they be as useful as possible to
51935c4bbdfSmrg# callers.
5204642e01fSmrg
5214642e01fSmrg
52235c4bbdfSmrg# require_term_colors
52335c4bbdfSmrg# -------------------
52435c4bbdfSmrg# Allow display of bold text on terminals that support it.
52535c4bbdfSmrgrequire_term_colors=func_require_term_colors
52635c4bbdfSmrgfunc_require_term_colors ()
5274642e01fSmrg{
52835c4bbdfSmrg    $debug_cmd
52935c4bbdfSmrg
53035c4bbdfSmrg    test -t 1 && {
53135c4bbdfSmrg      # COLORTERM and USE_ANSI_COLORS environment variables take
53235c4bbdfSmrg      # precedence, because most terminfo databases neglect to describe
53335c4bbdfSmrg      # whether color sequences are supported.
53435c4bbdfSmrg      test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"}
53535c4bbdfSmrg
53635c4bbdfSmrg      if test 1 = "$USE_ANSI_COLORS"; then
53735c4bbdfSmrg        # Standard ANSI escape sequences
53835c4bbdfSmrg        tc_reset='[0m'
53935c4bbdfSmrg        tc_bold='[1m';   tc_standout='[7m'
54035c4bbdfSmrg        tc_red='[31m';   tc_green='[32m'
54135c4bbdfSmrg        tc_blue='[34m';  tc_cyan='[36m'
54235c4bbdfSmrg      else
54335c4bbdfSmrg        # Otherwise trust the terminfo database after all.
54435c4bbdfSmrg        test -n "`tput sgr0 2>/dev/null`" && {
54535c4bbdfSmrg          tc_reset=`tput sgr0`
54635c4bbdfSmrg          test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold`
54735c4bbdfSmrg          tc_standout=$tc_bold
54835c4bbdfSmrg          test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso`
54935c4bbdfSmrg          test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1`
55035c4bbdfSmrg          test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2`
55135c4bbdfSmrg          test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4`
55235c4bbdfSmrg          test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5`
55335c4bbdfSmrg        }
55435c4bbdfSmrg      fi
55535c4bbdfSmrg    }
5564642e01fSmrg
55735c4bbdfSmrg    require_term_colors=:
5584642e01fSmrg}
5594642e01fSmrg
5604642e01fSmrg
56135c4bbdfSmrg## ----------------- ##
56235c4bbdfSmrg## Function library. ##
56335c4bbdfSmrg## ----------------- ##
5644642e01fSmrg
56535c4bbdfSmrg# This section contains a variety of useful functions to call in your
56635c4bbdfSmrg# scripts. Take note of the portable wrappers for features provided by
56735c4bbdfSmrg# some modern shells, which will fall back to slower equivalents on
56835c4bbdfSmrg# less featureful shells.
5694642e01fSmrg
5704642e01fSmrg
57135c4bbdfSmrg# func_append VAR VALUE
57235c4bbdfSmrg# ---------------------
57335c4bbdfSmrg# Append VALUE onto the existing contents of VAR.
5744642e01fSmrg
57535c4bbdfSmrg  # We should try to minimise forks, especially on Windows where they are
57635c4bbdfSmrg  # unreasonably slow, so skip the feature probes when bash or zsh are
57735c4bbdfSmrg  # being used:
57835c4bbdfSmrg  if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then
57935c4bbdfSmrg    : ${_G_HAVE_ARITH_OP="yes"}
58035c4bbdfSmrg    : ${_G_HAVE_XSI_OPS="yes"}
58135c4bbdfSmrg    # The += operator was introduced in bash 3.1
58235c4bbdfSmrg    case $BASH_VERSION in
58335c4bbdfSmrg      [12].* | 3.0 | 3.0*) ;;
58435c4bbdfSmrg      *)
58535c4bbdfSmrg        : ${_G_HAVE_PLUSEQ_OP="yes"}
58635c4bbdfSmrg        ;;
58735c4bbdfSmrg    esac
58835c4bbdfSmrg  fi
5894642e01fSmrg
59035c4bbdfSmrg  # _G_HAVE_PLUSEQ_OP
59135c4bbdfSmrg  # Can be empty, in which case the shell is probed, "yes" if += is
59254b5899cSmrg  # usable or anything else if it does not work.
59335c4bbdfSmrg  test -z "$_G_HAVE_PLUSEQ_OP" \
59435c4bbdfSmrg    && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \
59535c4bbdfSmrg    && _G_HAVE_PLUSEQ_OP=yes
59635c4bbdfSmrg
59735c4bbdfSmrgif test yes = "$_G_HAVE_PLUSEQ_OP"
59835c4bbdfSmrgthen
59935c4bbdfSmrg  # This is an XSI compatible shell, allowing a faster implementation...
60035c4bbdfSmrg  eval 'func_append ()
60135c4bbdfSmrg  {
60235c4bbdfSmrg    $debug_cmd
6034642e01fSmrg
60435c4bbdfSmrg    eval "$1+=\$2"
60535c4bbdfSmrg  }'
60635c4bbdfSmrgelse
60735c4bbdfSmrg  # ...otherwise fall back to using expr, which is often a shell builtin.
60835c4bbdfSmrg  func_append ()
60935c4bbdfSmrg  {
61035c4bbdfSmrg    $debug_cmd
6114642e01fSmrg
61235c4bbdfSmrg    eval "$1=\$$1\$2"
61335c4bbdfSmrg  }
61435c4bbdfSmrgfi
61535c4bbdfSmrg
61635c4bbdfSmrg
61735c4bbdfSmrg# func_append_quoted VAR VALUE
61835c4bbdfSmrg# ----------------------------
61935c4bbdfSmrg# Quote VALUE and append to the end of shell variable VAR, separated
62035c4bbdfSmrg# by a space.
62135c4bbdfSmrgif test yes = "$_G_HAVE_PLUSEQ_OP"; then
62235c4bbdfSmrg  eval 'func_append_quoted ()
62335c4bbdfSmrg  {
62435c4bbdfSmrg    $debug_cmd
62535c4bbdfSmrg
626c82838c1Smrg    func_quote_arg pretty "$2"
627c82838c1Smrg    eval "$1+=\\ \$func_quote_arg_result"
62835c4bbdfSmrg  }'
62935c4bbdfSmrgelse
63035c4bbdfSmrg  func_append_quoted ()
63135c4bbdfSmrg  {
63235c4bbdfSmrg    $debug_cmd
63335c4bbdfSmrg
634c82838c1Smrg    func_quote_arg pretty "$2"
635c82838c1Smrg    eval "$1=\$$1\\ \$func_quote_arg_result"
63635c4bbdfSmrg  }
63735c4bbdfSmrgfi
63835c4bbdfSmrg
63935c4bbdfSmrg
64035c4bbdfSmrg# func_append_uniq VAR VALUE
64135c4bbdfSmrg# --------------------------
64235c4bbdfSmrg# Append unique VALUE onto the existing contents of VAR, assuming
64335c4bbdfSmrg# entries are delimited by the first character of VALUE.  For example:
64435c4bbdfSmrg#
64535c4bbdfSmrg#   func_append_uniq options " --another-option option-argument"
64635c4bbdfSmrg#
64735c4bbdfSmrg# will only append to $options if " --another-option option-argument "
64835c4bbdfSmrg# is not already present somewhere in $options already (note spaces at
64935c4bbdfSmrg# each end implied by leading space in second argument).
65035c4bbdfSmrgfunc_append_uniq ()
65135c4bbdfSmrg{
65235c4bbdfSmrg    $debug_cmd
65335c4bbdfSmrg
65435c4bbdfSmrg    eval _G_current_value='`$ECHO $'$1'`'
65535c4bbdfSmrg    _G_delim=`expr "$2" : '\(.\)'`
65635c4bbdfSmrg
65735c4bbdfSmrg    case $_G_delim$_G_current_value$_G_delim in
65835c4bbdfSmrg      *"$2$_G_delim"*) ;;
65935c4bbdfSmrg      *) func_append "$@" ;;
66035c4bbdfSmrg    esac
66135c4bbdfSmrg}
66235c4bbdfSmrg
66335c4bbdfSmrg
66435c4bbdfSmrg# func_arith TERM...
66535c4bbdfSmrg# ------------------
66635c4bbdfSmrg# Set func_arith_result to the result of evaluating TERMs.
66735c4bbdfSmrg  test -z "$_G_HAVE_ARITH_OP" \
66835c4bbdfSmrg    && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \
66935c4bbdfSmrg    && _G_HAVE_ARITH_OP=yes
67035c4bbdfSmrg
67135c4bbdfSmrgif test yes = "$_G_HAVE_ARITH_OP"; then
67235c4bbdfSmrg  eval 'func_arith ()
67335c4bbdfSmrg  {
67435c4bbdfSmrg    $debug_cmd
67535c4bbdfSmrg
67635c4bbdfSmrg    func_arith_result=$(( $* ))
67735c4bbdfSmrg  }'
67835c4bbdfSmrgelse
67935c4bbdfSmrg  func_arith ()
68035c4bbdfSmrg  {
68135c4bbdfSmrg    $debug_cmd
68235c4bbdfSmrg
68335c4bbdfSmrg    func_arith_result=`expr "$@"`
68435c4bbdfSmrg  }
68535c4bbdfSmrgfi
68635c4bbdfSmrg
68735c4bbdfSmrg
68835c4bbdfSmrg# func_basename FILE
68935c4bbdfSmrg# ------------------
69035c4bbdfSmrg# Set func_basename_result to FILE with everything up to and including
69135c4bbdfSmrg# the last / stripped.
69235c4bbdfSmrgif test yes = "$_G_HAVE_XSI_OPS"; then
69335c4bbdfSmrg  # If this shell supports suffix pattern removal, then use it to avoid
69435c4bbdfSmrg  # forking. Hide the definitions single quotes in case the shell chokes
69535c4bbdfSmrg  # on unsupported syntax...
69635c4bbdfSmrg  _b='func_basename_result=${1##*/}'
69735c4bbdfSmrg  _d='case $1 in
69835c4bbdfSmrg        */*) func_dirname_result=${1%/*}$2 ;;
69935c4bbdfSmrg        *  ) func_dirname_result=$3        ;;
70035c4bbdfSmrg      esac'
70135c4bbdfSmrg
70235c4bbdfSmrgelse
70335c4bbdfSmrg  # ...otherwise fall back to using sed.
70435c4bbdfSmrg  _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`'
70535c4bbdfSmrg  _d='func_dirname_result=`$ECHO "$1"  |$SED "$sed_dirname"`
70635c4bbdfSmrg      if test "X$func_dirname_result" = "X$1"; then
70735c4bbdfSmrg        func_dirname_result=$3
70835c4bbdfSmrg      else
70935c4bbdfSmrg        func_append func_dirname_result "$2"
71035c4bbdfSmrg      fi'
71135c4bbdfSmrgfi
71235c4bbdfSmrg
71335c4bbdfSmrgeval 'func_basename ()
71435c4bbdfSmrg{
71535c4bbdfSmrg    $debug_cmd
71635c4bbdfSmrg
71735c4bbdfSmrg    '"$_b"'
71835c4bbdfSmrg}'
71935c4bbdfSmrg
72035c4bbdfSmrg
72135c4bbdfSmrg# func_dirname FILE APPEND NONDIR_REPLACEMENT
72235c4bbdfSmrg# -------------------------------------------
72335c4bbdfSmrg# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
72435c4bbdfSmrg# otherwise set result to NONDIR_REPLACEMENT.
72535c4bbdfSmrgeval 'func_dirname ()
72635c4bbdfSmrg{
72735c4bbdfSmrg    $debug_cmd
72835c4bbdfSmrg
72935c4bbdfSmrg    '"$_d"'
73035c4bbdfSmrg}'
73135c4bbdfSmrg
73235c4bbdfSmrg
73335c4bbdfSmrg# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT
73435c4bbdfSmrg# --------------------------------------------------------
73535c4bbdfSmrg# Perform func_basename and func_dirname in a single function
73635c4bbdfSmrg# call:
73735c4bbdfSmrg#   dirname:  Compute the dirname of FILE.  If nonempty,
73835c4bbdfSmrg#             add APPEND to the result, otherwise set result
73935c4bbdfSmrg#             to NONDIR_REPLACEMENT.
74035c4bbdfSmrg#             value returned in "$func_dirname_result"
74135c4bbdfSmrg#   basename: Compute filename of FILE.
74254b5899cSmrg#             value returned in "$func_basename_result"
74335c4bbdfSmrg# For efficiency, we do not delegate to the functions above but instead
74435c4bbdfSmrg# duplicate the functionality here.
74535c4bbdfSmrgeval 'func_dirname_and_basename ()
74635c4bbdfSmrg{
74735c4bbdfSmrg    $debug_cmd
74835c4bbdfSmrg
74935c4bbdfSmrg    '"$_b"'
75035c4bbdfSmrg    '"$_d"'
75135c4bbdfSmrg}'
75235c4bbdfSmrg
75335c4bbdfSmrg
75435c4bbdfSmrg# func_echo ARG...
75535c4bbdfSmrg# ----------------
75635c4bbdfSmrg# Echo program name prefixed message.
75735c4bbdfSmrgfunc_echo ()
75835c4bbdfSmrg{
75935c4bbdfSmrg    $debug_cmd
76035c4bbdfSmrg
76135c4bbdfSmrg    _G_message=$*
76235c4bbdfSmrg
76335c4bbdfSmrg    func_echo_IFS=$IFS
76435c4bbdfSmrg    IFS=$nl
76535c4bbdfSmrg    for _G_line in $_G_message; do
76635c4bbdfSmrg      IFS=$func_echo_IFS
76735c4bbdfSmrg      $ECHO "$progname: $_G_line"
76835c4bbdfSmrg    done
76935c4bbdfSmrg    IFS=$func_echo_IFS
77035c4bbdfSmrg}
77135c4bbdfSmrg
77235c4bbdfSmrg
77335c4bbdfSmrg# func_echo_all ARG...
77435c4bbdfSmrg# --------------------
77535c4bbdfSmrg# Invoke $ECHO with all args, space-separated.
77635c4bbdfSmrgfunc_echo_all ()
77735c4bbdfSmrg{
77835c4bbdfSmrg    $ECHO "$*"
77935c4bbdfSmrg}
78035c4bbdfSmrg
78135c4bbdfSmrg
78235c4bbdfSmrg# func_echo_infix_1 INFIX ARG...
78335c4bbdfSmrg# ------------------------------
78435c4bbdfSmrg# Echo program name, followed by INFIX on the first line, with any
78535c4bbdfSmrg# additional lines not showing INFIX.
78635c4bbdfSmrgfunc_echo_infix_1 ()
78735c4bbdfSmrg{
78835c4bbdfSmrg    $debug_cmd
78935c4bbdfSmrg
79035c4bbdfSmrg    $require_term_colors
79135c4bbdfSmrg
79235c4bbdfSmrg    _G_infix=$1; shift
79335c4bbdfSmrg    _G_indent=$_G_infix
79435c4bbdfSmrg    _G_prefix="$progname: $_G_infix: "
79535c4bbdfSmrg    _G_message=$*
79635c4bbdfSmrg
79735c4bbdfSmrg    # Strip color escape sequences before counting printable length
79835c4bbdfSmrg    for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan"
79935c4bbdfSmrg    do
80035c4bbdfSmrg      test -n "$_G_tc" && {
80135c4bbdfSmrg        _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"`
80235c4bbdfSmrg        _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"`
80335c4bbdfSmrg      }
80435c4bbdfSmrg    done
80535c4bbdfSmrg    _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`"  " ## exclude from sc_prohibit_nested_quotes
80635c4bbdfSmrg
80735c4bbdfSmrg    func_echo_infix_1_IFS=$IFS
80835c4bbdfSmrg    IFS=$nl
80935c4bbdfSmrg    for _G_line in $_G_message; do
81035c4bbdfSmrg      IFS=$func_echo_infix_1_IFS
81135c4bbdfSmrg      $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2
81235c4bbdfSmrg      _G_prefix=$_G_indent
81335c4bbdfSmrg    done
81435c4bbdfSmrg    IFS=$func_echo_infix_1_IFS
81535c4bbdfSmrg}
81635c4bbdfSmrg
81735c4bbdfSmrg
81835c4bbdfSmrg# func_error ARG...
81935c4bbdfSmrg# -----------------
82035c4bbdfSmrg# Echo program name prefixed message to standard error.
82135c4bbdfSmrgfunc_error ()
82235c4bbdfSmrg{
82335c4bbdfSmrg    $debug_cmd
82435c4bbdfSmrg
82535c4bbdfSmrg    $require_term_colors
82635c4bbdfSmrg
82735c4bbdfSmrg    func_echo_infix_1 "  $tc_standout${tc_red}error$tc_reset" "$*" >&2
82835c4bbdfSmrg}
82935c4bbdfSmrg
83035c4bbdfSmrg
83135c4bbdfSmrg# func_fatal_error ARG...
83235c4bbdfSmrg# -----------------------
83335c4bbdfSmrg# Echo program name prefixed message to standard error, and exit.
83435c4bbdfSmrgfunc_fatal_error ()
83535c4bbdfSmrg{
83635c4bbdfSmrg    $debug_cmd
83735c4bbdfSmrg
83835c4bbdfSmrg    func_error "$*"
83935c4bbdfSmrg    exit $EXIT_FAILURE
84035c4bbdfSmrg}
84135c4bbdfSmrg
84235c4bbdfSmrg
84335c4bbdfSmrg# func_grep EXPRESSION FILENAME
84435c4bbdfSmrg# -----------------------------
84535c4bbdfSmrg# Check whether EXPRESSION matches any line of FILENAME, without output.
84635c4bbdfSmrgfunc_grep ()
84735c4bbdfSmrg{
84835c4bbdfSmrg    $debug_cmd
84935c4bbdfSmrg
85035c4bbdfSmrg    $GREP "$1" "$2" >/dev/null 2>&1
85135c4bbdfSmrg}
85235c4bbdfSmrg
85335c4bbdfSmrg
85435c4bbdfSmrg# func_len STRING
85535c4bbdfSmrg# ---------------
85635c4bbdfSmrg# Set func_len_result to the length of STRING. STRING may not
85735c4bbdfSmrg# start with a hyphen.
85835c4bbdfSmrg  test -z "$_G_HAVE_XSI_OPS" \
85935c4bbdfSmrg    && (eval 'x=a/b/c;
86035c4bbdfSmrg      test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
86135c4bbdfSmrg    && _G_HAVE_XSI_OPS=yes
86235c4bbdfSmrg
86335c4bbdfSmrgif test yes = "$_G_HAVE_XSI_OPS"; then
86435c4bbdfSmrg  eval 'func_len ()
86535c4bbdfSmrg  {
86635c4bbdfSmrg    $debug_cmd
86735c4bbdfSmrg
86835c4bbdfSmrg    func_len_result=${#1}
86935c4bbdfSmrg  }'
87035c4bbdfSmrgelse
87135c4bbdfSmrg  func_len ()
87235c4bbdfSmrg  {
87335c4bbdfSmrg    $debug_cmd
87435c4bbdfSmrg
87535c4bbdfSmrg    func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len`
87635c4bbdfSmrg  }
87735c4bbdfSmrgfi
87835c4bbdfSmrg
87935c4bbdfSmrg
88035c4bbdfSmrg# func_mkdir_p DIRECTORY-PATH
88135c4bbdfSmrg# ---------------------------
88235c4bbdfSmrg# Make sure the entire path to DIRECTORY-PATH is available.
88335c4bbdfSmrgfunc_mkdir_p ()
88435c4bbdfSmrg{
88535c4bbdfSmrg    $debug_cmd
88635c4bbdfSmrg
88735c4bbdfSmrg    _G_directory_path=$1
88835c4bbdfSmrg    _G_dir_list=
88935c4bbdfSmrg
89035c4bbdfSmrg    if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then
89135c4bbdfSmrg
89235c4bbdfSmrg      # Protect directory names starting with '-'
89335c4bbdfSmrg      case $_G_directory_path in
89435c4bbdfSmrg        -*) _G_directory_path=./$_G_directory_path ;;
89535c4bbdfSmrg      esac
89635c4bbdfSmrg
89735c4bbdfSmrg      # While some portion of DIR does not yet exist...
89835c4bbdfSmrg      while test ! -d "$_G_directory_path"; do
89935c4bbdfSmrg        # ...make a list in topmost first order.  Use a colon delimited
90054b5899cSmrg	# list in case some portion of path contains whitespace.
90135c4bbdfSmrg        _G_dir_list=$_G_directory_path:$_G_dir_list
90235c4bbdfSmrg
90335c4bbdfSmrg        # If the last portion added has no slash in it, the list is done
90435c4bbdfSmrg        case $_G_directory_path in */*) ;; *) break ;; esac
90535c4bbdfSmrg
90635c4bbdfSmrg        # ...otherwise throw away the child directory and loop
90735c4bbdfSmrg        _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"`
90835c4bbdfSmrg      done
90935c4bbdfSmrg      _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'`
9104642e01fSmrg
91135c4bbdfSmrg      func_mkdir_p_IFS=$IFS; IFS=:
91235c4bbdfSmrg      for _G_dir in $_G_dir_list; do
91335c4bbdfSmrg	IFS=$func_mkdir_p_IFS
91435c4bbdfSmrg        # mkdir can fail with a 'File exist' error if two processes
9154642e01fSmrg        # try to create one of the directories concurrently.  Don't
9164642e01fSmrg        # stop in that case!
91735c4bbdfSmrg        $MKDIR "$_G_dir" 2>/dev/null || :
9184642e01fSmrg      done
91935c4bbdfSmrg      IFS=$func_mkdir_p_IFS
9204642e01fSmrg
9214642e01fSmrg      # Bail out if we (or some other process) failed to create a directory.
92235c4bbdfSmrg      test -d "$_G_directory_path" || \
92335c4bbdfSmrg        func_fatal_error "Failed to create '$1'"
9244642e01fSmrg    fi
9254642e01fSmrg}
92605b261ecSmrg
92705b261ecSmrg
92835c4bbdfSmrg# func_mktempdir [BASENAME]
92935c4bbdfSmrg# -------------------------
93005b261ecSmrg# Make a temporary directory that won't clash with other running
93105b261ecSmrg# libtool processes, and avoids race conditions if possible.  If
93235c4bbdfSmrg# given, BASENAME is the basename for that directory.
93305b261ecSmrgfunc_mktempdir ()
93405b261ecSmrg{
93535c4bbdfSmrg    $debug_cmd
93605b261ecSmrg
93735c4bbdfSmrg    _G_template=${TMPDIR-/tmp}/${1-$progname}
93835c4bbdfSmrg
93935c4bbdfSmrg    if test : = "$opt_dry_run"; then
94005b261ecSmrg      # Return a directory name, but don't create it in dry-run mode
94135c4bbdfSmrg      _G_tmpdir=$_G_template-$$
94205b261ecSmrg    else
94305b261ecSmrg
94405b261ecSmrg      # If mktemp works, use that first and foremost
94535c4bbdfSmrg      _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null`
94605b261ecSmrg
94735c4bbdfSmrg      if test ! -d "$_G_tmpdir"; then
9484642e01fSmrg        # Failing that, at least try and use $RANDOM to avoid a race
94935c4bbdfSmrg        _G_tmpdir=$_G_template-${RANDOM-0}$$
95005b261ecSmrg
95135c4bbdfSmrg        func_mktempdir_umask=`umask`
9524642e01fSmrg        umask 0077
95335c4bbdfSmrg        $MKDIR "$_G_tmpdir"
95435c4bbdfSmrg        umask $func_mktempdir_umask
95505b261ecSmrg      fi
95605b261ecSmrg
95705b261ecSmrg      # If we're not in dry-run mode, bomb out on failure
95835c4bbdfSmrg      test -d "$_G_tmpdir" || \
95935c4bbdfSmrg        func_fatal_error "cannot create temporary directory '$_G_tmpdir'"
96005b261ecSmrg    fi
96105b261ecSmrg
96235c4bbdfSmrg    $ECHO "$_G_tmpdir"
96305b261ecSmrg}
96405b261ecSmrg
96505b261ecSmrg
96635c4bbdfSmrg# func_normal_abspath PATH
96735c4bbdfSmrg# ------------------------
96835c4bbdfSmrg# Remove doubled-up and trailing slashes, "." path components,
96935c4bbdfSmrg# and cancel out any ".." path components in PATH after making
97035c4bbdfSmrg# it an absolute path.
97135c4bbdfSmrgfunc_normal_abspath ()
97205b261ecSmrg{
97335c4bbdfSmrg    $debug_cmd
9744642e01fSmrg
97535c4bbdfSmrg    # These SED scripts presuppose an absolute path with a trailing slash.
97635c4bbdfSmrg    _G_pathcar='s|^/\([^/]*\).*$|\1|'
97735c4bbdfSmrg    _G_pathcdr='s|^/[^/]*||'
97835c4bbdfSmrg    _G_removedotparts=':dotsl
97935c4bbdfSmrg		s|/\./|/|g
98035c4bbdfSmrg		t dotsl
98135c4bbdfSmrg		s|/\.$|/|'
98235c4bbdfSmrg    _G_collapseslashes='s|/\{1,\}|/|g'
98335c4bbdfSmrg    _G_finalslash='s|/*$|/|'
98435c4bbdfSmrg
98535c4bbdfSmrg    # Start from root dir and reassemble the path.
98635c4bbdfSmrg    func_normal_abspath_result=
98735c4bbdfSmrg    func_normal_abspath_tpath=$1
98835c4bbdfSmrg    func_normal_abspath_altnamespace=
98935c4bbdfSmrg    case $func_normal_abspath_tpath in
99035c4bbdfSmrg      "")
99135c4bbdfSmrg        # Empty path, that just means $cwd.
99235c4bbdfSmrg        func_stripname '' '/' "`pwd`"
99335c4bbdfSmrg        func_normal_abspath_result=$func_stripname_result
99435c4bbdfSmrg        return
99535c4bbdfSmrg        ;;
99635c4bbdfSmrg      # The next three entries are used to spot a run of precisely
99735c4bbdfSmrg      # two leading slashes without using negated character classes;
99835c4bbdfSmrg      # we take advantage of case's first-match behaviour.
99935c4bbdfSmrg      ///*)
100035c4bbdfSmrg        # Unusual form of absolute path, do nothing.
100135c4bbdfSmrg        ;;
100235c4bbdfSmrg      //*)
100335c4bbdfSmrg        # Not necessarily an ordinary path; POSIX reserves leading '//'
100435c4bbdfSmrg        # and for example Cygwin uses it to access remote file shares
100535c4bbdfSmrg        # over CIFS/SMB, so we conserve a leading double slash if found.
100635c4bbdfSmrg        func_normal_abspath_altnamespace=/
100735c4bbdfSmrg        ;;
100835c4bbdfSmrg      /*)
100935c4bbdfSmrg        # Absolute path, do nothing.
10104642e01fSmrg        ;;
10114642e01fSmrg      *)
101235c4bbdfSmrg        # Relative path, prepend $cwd.
101335c4bbdfSmrg        func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
101435c4bbdfSmrg        ;;
101505b261ecSmrg    esac
101635c4bbdfSmrg
101735c4bbdfSmrg    # Cancel out all the simple stuff to save iterations.  We also want
101835c4bbdfSmrg    # the path to end with a slash for ease of parsing, so make sure
101935c4bbdfSmrg    # there is one (and only one) here.
102035c4bbdfSmrg    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
102135c4bbdfSmrg          -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"`
102235c4bbdfSmrg    while :; do
102335c4bbdfSmrg      # Processed it all yet?
102435c4bbdfSmrg      if test / = "$func_normal_abspath_tpath"; then
102535c4bbdfSmrg        # If we ascended to the root using ".." the result may be empty now.
102635c4bbdfSmrg        if test -z "$func_normal_abspath_result"; then
102735c4bbdfSmrg          func_normal_abspath_result=/
102835c4bbdfSmrg        fi
102935c4bbdfSmrg        break
103035c4bbdfSmrg      fi
103135c4bbdfSmrg      func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
103235c4bbdfSmrg          -e "$_G_pathcar"`
103335c4bbdfSmrg      func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
103435c4bbdfSmrg          -e "$_G_pathcdr"`
103535c4bbdfSmrg      # Figure out what to do with it
103635c4bbdfSmrg      case $func_normal_abspath_tcomponent in
103735c4bbdfSmrg        "")
103835c4bbdfSmrg          # Trailing empty path component, ignore it.
103935c4bbdfSmrg          ;;
104035c4bbdfSmrg        ..)
104135c4bbdfSmrg          # Parent dir; strip last assembled component from result.
104235c4bbdfSmrg          func_dirname "$func_normal_abspath_result"
104335c4bbdfSmrg          func_normal_abspath_result=$func_dirname_result
104435c4bbdfSmrg          ;;
104535c4bbdfSmrg        *)
104635c4bbdfSmrg          # Actual path component, append it.
104735c4bbdfSmrg          func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent"
104835c4bbdfSmrg          ;;
104935c4bbdfSmrg      esac
105035c4bbdfSmrg    done
105135c4bbdfSmrg    # Restore leading double-slash if one was found on entry.
105235c4bbdfSmrg    func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
105335c4bbdfSmrg}
105435c4bbdfSmrg
105535c4bbdfSmrg
105635c4bbdfSmrg# func_notquiet ARG...
105735c4bbdfSmrg# --------------------
105835c4bbdfSmrg# Echo program name prefixed message only when not in quiet mode.
105935c4bbdfSmrgfunc_notquiet ()
106035c4bbdfSmrg{
106135c4bbdfSmrg    $debug_cmd
106235c4bbdfSmrg
106335c4bbdfSmrg    $opt_quiet || func_echo ${1+"$@"}
106435c4bbdfSmrg
106535c4bbdfSmrg    # A bug in bash halts the script if the last line of a function
106635c4bbdfSmrg    # fails when set -e is in force, so we need another command to
106735c4bbdfSmrg    # work around that:
106835c4bbdfSmrg    :
106935c4bbdfSmrg}
107035c4bbdfSmrg
107135c4bbdfSmrg
107235c4bbdfSmrg# func_relative_path SRCDIR DSTDIR
107335c4bbdfSmrg# --------------------------------
107435c4bbdfSmrg# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR.
107535c4bbdfSmrgfunc_relative_path ()
107635c4bbdfSmrg{
107735c4bbdfSmrg    $debug_cmd
107835c4bbdfSmrg
107935c4bbdfSmrg    func_relative_path_result=
108035c4bbdfSmrg    func_normal_abspath "$1"
108135c4bbdfSmrg    func_relative_path_tlibdir=$func_normal_abspath_result
108235c4bbdfSmrg    func_normal_abspath "$2"
108335c4bbdfSmrg    func_relative_path_tbindir=$func_normal_abspath_result
108435c4bbdfSmrg
108535c4bbdfSmrg    # Ascend the tree starting from libdir
108635c4bbdfSmrg    while :; do
108735c4bbdfSmrg      # check if we have found a prefix of bindir
108835c4bbdfSmrg      case $func_relative_path_tbindir in
108935c4bbdfSmrg        $func_relative_path_tlibdir)
109035c4bbdfSmrg          # found an exact match
109135c4bbdfSmrg          func_relative_path_tcancelled=
109235c4bbdfSmrg          break
109335c4bbdfSmrg          ;;
109435c4bbdfSmrg        $func_relative_path_tlibdir*)
109535c4bbdfSmrg          # found a matching prefix
109635c4bbdfSmrg          func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
109735c4bbdfSmrg          func_relative_path_tcancelled=$func_stripname_result
109835c4bbdfSmrg          if test -z "$func_relative_path_result"; then
109935c4bbdfSmrg            func_relative_path_result=.
110035c4bbdfSmrg          fi
110135c4bbdfSmrg          break
110235c4bbdfSmrg          ;;
110335c4bbdfSmrg        *)
110435c4bbdfSmrg          func_dirname $func_relative_path_tlibdir
110535c4bbdfSmrg          func_relative_path_tlibdir=$func_dirname_result
110635c4bbdfSmrg          if test -z "$func_relative_path_tlibdir"; then
110735c4bbdfSmrg            # Have to descend all the way to the root!
110835c4bbdfSmrg            func_relative_path_result=../$func_relative_path_result
110935c4bbdfSmrg            func_relative_path_tcancelled=$func_relative_path_tbindir
111035c4bbdfSmrg            break
111135c4bbdfSmrg          fi
111235c4bbdfSmrg          func_relative_path_result=../$func_relative_path_result
111335c4bbdfSmrg          ;;
111435c4bbdfSmrg      esac
111535c4bbdfSmrg    done
111635c4bbdfSmrg
111735c4bbdfSmrg    # Now calculate path; take care to avoid doubling-up slashes.
111835c4bbdfSmrg    func_stripname '' '/' "$func_relative_path_result"
111935c4bbdfSmrg    func_relative_path_result=$func_stripname_result
112035c4bbdfSmrg    func_stripname '/' '/' "$func_relative_path_tcancelled"
112135c4bbdfSmrg    if test -n "$func_stripname_result"; then
112235c4bbdfSmrg      func_append func_relative_path_result "/$func_stripname_result"
112335c4bbdfSmrg    fi
112435c4bbdfSmrg
112535c4bbdfSmrg    # Normalisation. If bindir is libdir, return '.' else relative path.
112635c4bbdfSmrg    if test -n "$func_relative_path_result"; then
112735c4bbdfSmrg      func_stripname './' '' "$func_relative_path_result"
112835c4bbdfSmrg      func_relative_path_result=$func_stripname_result
112935c4bbdfSmrg    fi
113035c4bbdfSmrg
113135c4bbdfSmrg    test -n "$func_relative_path_result" || func_relative_path_result=.
113235c4bbdfSmrg
113335c4bbdfSmrg    :
113435c4bbdfSmrg}
113535c4bbdfSmrg
113635c4bbdfSmrg
1137c82838c1Smrg# func_quote_portable EVAL ARG
1138c82838c1Smrg# ----------------------------
1139c82838c1Smrg# Internal function to portably implement func_quote_arg.  Note that we still
1140c82838c1Smrg# keep attention to performance here so we as much as possible try to avoid
1141c82838c1Smrg# calling sed binary (so far O(N) complexity as long as func_append is O(1)).
1142c82838c1Smrgfunc_quote_portable ()
114335c4bbdfSmrg{
114435c4bbdfSmrg    $debug_cmd
114535c4bbdfSmrg
1146c82838c1Smrg    $require_check_ifs_backslash
1147c82838c1Smrg
1148c82838c1Smrg    func_quote_portable_result=$2
1149c82838c1Smrg
1150c82838c1Smrg    # one-time-loop (easy break)
1151c82838c1Smrg    while true
1152c82838c1Smrg    do
1153c82838c1Smrg      if $1; then
1154c82838c1Smrg        func_quote_portable_result=`$ECHO "$2" | $SED \
1155c82838c1Smrg          -e "$sed_double_quote_subst" -e "$sed_double_backslash"`
1156c82838c1Smrg        break
115735c4bbdfSmrg      fi
115835c4bbdfSmrg
1159c82838c1Smrg      # Quote for eval.
1160c82838c1Smrg      case $func_quote_portable_result in
1161c82838c1Smrg        *[\\\`\"\$]*)
1162c82838c1Smrg          # Fallback to sed for $func_check_bs_ifs_broken=:, or when the string
1163c82838c1Smrg          # contains the shell wildcard characters.
1164c82838c1Smrg          case $check_ifs_backshlash_broken$func_quote_portable_result in
1165c82838c1Smrg            :*|*[\[\*\?]*)
1166c82838c1Smrg              func_quote_portable_result=`$ECHO "$func_quote_portable_result" \
1167c82838c1Smrg                  | $SED "$sed_quote_subst"`
1168c82838c1Smrg              break
1169c82838c1Smrg              ;;
1170c82838c1Smrg          esac
1171c82838c1Smrg
1172c82838c1Smrg          func_quote_portable_old_IFS=$IFS
1173c82838c1Smrg          for _G_char in '\' '`' '"' '$'
1174c82838c1Smrg          do
1175c82838c1Smrg            # STATE($1) PREV($2) SEPARATOR($3)
1176c82838c1Smrg            set start "" ""
1177c82838c1Smrg            func_quote_portable_result=dummy"$_G_char$func_quote_portable_result$_G_char"dummy
1178c82838c1Smrg            IFS=$_G_char
1179c82838c1Smrg            for _G_part in $func_quote_portable_result
1180c82838c1Smrg            do
1181c82838c1Smrg              case $1 in
1182c82838c1Smrg              quote)
1183c82838c1Smrg                func_append func_quote_portable_result "$3$2"
1184c82838c1Smrg                set quote "$_G_part" "\\$_G_char"
1185c82838c1Smrg                ;;
1186c82838c1Smrg              start)
1187c82838c1Smrg                set first "" ""
1188c82838c1Smrg                func_quote_portable_result=
1189c82838c1Smrg                ;;
1190c82838c1Smrg              first)
1191c82838c1Smrg                set quote "$_G_part" ""
1192c82838c1Smrg                ;;
1193c82838c1Smrg              esac
1194c82838c1Smrg            done
1195c82838c1Smrg          done
1196c82838c1Smrg          IFS=$func_quote_portable_old_IFS
119735c4bbdfSmrg          ;;
1198c82838c1Smrg        *) ;;
119935c4bbdfSmrg      esac
1200c82838c1Smrg      break
120135c4bbdfSmrg    done
1202c82838c1Smrg
1203c82838c1Smrg    func_quote_portable_unquoted_result=$func_quote_portable_result
1204c82838c1Smrg    case $func_quote_portable_result in
1205c82838c1Smrg      # double-quote args containing shell metacharacters to delay
1206c82838c1Smrg      # word splitting, command substitution and variable expansion
1207c82838c1Smrg      # for a subsequent eval.
1208c82838c1Smrg      # many bourne shells cannot handle close brackets correctly
1209c82838c1Smrg      # in scan sets, so we specify it separately.
1210c82838c1Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
1211c82838c1Smrg        func_quote_portable_result=\"$func_quote_portable_result\"
1212c82838c1Smrg        ;;
1213c82838c1Smrg    esac
121405b261ecSmrg}
121505b261ecSmrg
121605b261ecSmrg
1217c82838c1Smrg# func_quotefast_eval ARG
1218c82838c1Smrg# -----------------------
1219c82838c1Smrg# Quote one ARG (internal).  This is equivalent to 'func_quote_arg eval ARG',
1220c82838c1Smrg# but optimized for speed.  Result is stored in $func_quotefast_eval.
1221c82838c1Smrgif test xyes = `(x=; printf -v x %q yes; echo x"$x") 2>/dev/null`; then
1222c82838c1Smrg  printf -v _GL_test_printf_tilde %q '~'
1223c82838c1Smrg  if test '\~' = "$_GL_test_printf_tilde"; then
1224c82838c1Smrg    func_quotefast_eval ()
1225c82838c1Smrg    {
1226c82838c1Smrg      printf -v func_quotefast_eval_result %q "$1"
1227c82838c1Smrg    }
1228c82838c1Smrg  else
1229c82838c1Smrg    # Broken older Bash implementations.  Make those faster too if possible.
1230c82838c1Smrg    func_quotefast_eval ()
1231c82838c1Smrg    {
1232c82838c1Smrg      case $1 in
1233c82838c1Smrg        '~'*)
1234c82838c1Smrg          func_quote_portable false "$1"
1235c82838c1Smrg          func_quotefast_eval_result=$func_quote_portable_result
1236c82838c1Smrg          ;;
1237c82838c1Smrg        *)
1238c82838c1Smrg          printf -v func_quotefast_eval_result %q "$1"
1239c82838c1Smrg          ;;
1240c82838c1Smrg      esac
1241c82838c1Smrg    }
1242c82838c1Smrg  fi
1243c82838c1Smrgelse
1244c82838c1Smrg  func_quotefast_eval ()
1245c82838c1Smrg  {
1246c82838c1Smrg    func_quote_portable false "$1"
1247c82838c1Smrg    func_quotefast_eval_result=$func_quote_portable_result
1248c82838c1Smrg  }
1249c82838c1Smrgfi
125035c4bbdfSmrg
1251c82838c1Smrg
1252c82838c1Smrg# func_quote_arg MODEs ARG
1253c82838c1Smrg# ------------------------
1254c82838c1Smrg# Quote one ARG to be evaled later.  MODEs argument may contain zero or more
1255c82838c1Smrg# specifiers listed below separated by ',' character.  This function returns two
1256c82838c1Smrg# values:
1257c82838c1Smrg#   i) func_quote_arg_result
1258c82838c1Smrg#      double-quoted (when needed), suitable for a subsequent eval
1259c82838c1Smrg#  ii) func_quote_arg_unquoted_result
1260c82838c1Smrg#      has all characters that are still active within double
1261c82838c1Smrg#      quotes backslashified.  Available only if 'unquoted' is specified.
1262c82838c1Smrg#
1263c82838c1Smrg# Available modes:
1264c82838c1Smrg# ----------------
1265c82838c1Smrg# 'eval' (default)
1266c82838c1Smrg#       - escape shell special characters
1267c82838c1Smrg# 'expand'
1268c82838c1Smrg#       - the same as 'eval';  but do not quote variable references
1269c82838c1Smrg# 'pretty'
1270c82838c1Smrg#       - request aesthetic output, i.e. '"a b"' instead of 'a\ b'.  This might
1271c82838c1Smrg#         be used later in func_quote to get output like: 'echo "a b"' instead
1272c82838c1Smrg#         of 'echo a\ b'.  This is slower than default on some shells.
1273c82838c1Smrg# 'unquoted'
1274c82838c1Smrg#       - produce also $func_quote_arg_unquoted_result which does not contain
1275c82838c1Smrg#         wrapping double-quotes.
1276c82838c1Smrg#
1277c82838c1Smrg# Examples for 'func_quote_arg pretty,unquoted string':
1278c82838c1Smrg#
1279c82838c1Smrg#   string      | *_result              | *_unquoted_result
1280c82838c1Smrg#   ------------+-----------------------+-------------------
1281c82838c1Smrg#   "           | \"                    | \"
1282c82838c1Smrg#   a b         | "a b"                 | a b
1283c82838c1Smrg#   "a b"       | "\"a b\""             | \"a b\"
1284c82838c1Smrg#   *           | "*"                   | *
1285c82838c1Smrg#   z="${x-$y}" | "z=\"\${x-\$y}\""     | z=\"\${x-\$y}\"
1286c82838c1Smrg#
1287c82838c1Smrg# Examples for 'func_quote_arg pretty,unquoted,expand string':
1288c82838c1Smrg#
1289c82838c1Smrg#   string        |   *_result          |  *_unquoted_result
1290c82838c1Smrg#   --------------+---------------------+--------------------
1291c82838c1Smrg#   z="${x-$y}"   | "z=\"${x-$y}\""     | z=\"${x-$y}\"
1292c82838c1Smrgfunc_quote_arg ()
1293c82838c1Smrg{
1294c82838c1Smrg    _G_quote_expand=false
1295c82838c1Smrg    case ,$1, in
1296c82838c1Smrg      *,expand,*)
1297c82838c1Smrg        _G_quote_expand=:
1298c82838c1Smrg        ;;
12994642e01fSmrg    esac
13004642e01fSmrg
1301c82838c1Smrg    case ,$1, in
1302c82838c1Smrg      *,pretty,*|*,expand,*|*,unquoted,*)
1303c82838c1Smrg        func_quote_portable $_G_quote_expand "$2"
1304c82838c1Smrg        func_quote_arg_result=$func_quote_portable_result
1305c82838c1Smrg        func_quote_arg_unquoted_result=$func_quote_portable_unquoted_result
1306c82838c1Smrg        ;;
1307c82838c1Smrg      *)
1308c82838c1Smrg        # Faster quote-for-eval for some shells.
1309c82838c1Smrg        func_quotefast_eval "$2"
1310c82838c1Smrg        func_quote_arg_result=$func_quotefast_eval_result
13114642e01fSmrg        ;;
13124642e01fSmrg    esac
1313c82838c1Smrg}
13144642e01fSmrg
1315c82838c1Smrg
1316c82838c1Smrg# func_quote MODEs ARGs...
1317c82838c1Smrg# ------------------------
1318c82838c1Smrg# Quote all ARGs to be evaled later and join them into single command.  See
1319c82838c1Smrg# func_quote_arg's description for more info.
1320c82838c1Smrgfunc_quote ()
1321c82838c1Smrg{
1322c82838c1Smrg    $debug_cmd
1323c82838c1Smrg    _G_func_quote_mode=$1 ; shift
1324c82838c1Smrg    func_quote_result=
1325c82838c1Smrg    while test 0 -lt $#; do
1326c82838c1Smrg      func_quote_arg "$_G_func_quote_mode" "$1"
1327c82838c1Smrg      if test -n "$func_quote_result"; then
1328c82838c1Smrg        func_append func_quote_result " $func_quote_arg_result"
1329c82838c1Smrg      else
1330c82838c1Smrg        func_append func_quote_result "$func_quote_arg_result"
1331c82838c1Smrg      fi
1332c82838c1Smrg      shift
1333c82838c1Smrg    done
133405b261ecSmrg}
133505b261ecSmrg
133605b261ecSmrg
133735c4bbdfSmrg# func_stripname PREFIX SUFFIX NAME
133835c4bbdfSmrg# ---------------------------------
133935c4bbdfSmrg# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result.
134035c4bbdfSmrg# PREFIX and SUFFIX must not contain globbing or regex special
134135c4bbdfSmrg# characters, hashes, percent signs, but SUFFIX may contain a leading
134235c4bbdfSmrg# dot (in which case that matches only a dot).
134335c4bbdfSmrgif test yes = "$_G_HAVE_XSI_OPS"; then
134435c4bbdfSmrg  eval 'func_stripname ()
134535c4bbdfSmrg  {
134635c4bbdfSmrg    $debug_cmd
134735c4bbdfSmrg
134835c4bbdfSmrg    # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
134935c4bbdfSmrg    # positional parameters, so assign one to ordinary variable first.
135035c4bbdfSmrg    func_stripname_result=$3
135135c4bbdfSmrg    func_stripname_result=${func_stripname_result#"$1"}
135235c4bbdfSmrg    func_stripname_result=${func_stripname_result%"$2"}
135335c4bbdfSmrg  }'
135435c4bbdfSmrgelse
135535c4bbdfSmrg  func_stripname ()
135635c4bbdfSmrg  {
135735c4bbdfSmrg    $debug_cmd
135835c4bbdfSmrg
135935c4bbdfSmrg    case $2 in
136035c4bbdfSmrg      .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;;
136135c4bbdfSmrg      *)  func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;;
136235c4bbdfSmrg    esac
136335c4bbdfSmrg  }
136435c4bbdfSmrgfi
136535c4bbdfSmrg
136635c4bbdfSmrg
136735c4bbdfSmrg# func_show_eval CMD [FAIL_EXP]
136835c4bbdfSmrg# -----------------------------
136935c4bbdfSmrg# Unless opt_quiet is true, then output CMD.  Then, if opt_dryrun is
13704642e01fSmrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
13714642e01fSmrg# is given, then evaluate it.
13724642e01fSmrgfunc_show_eval ()
137305b261ecSmrg{
137435c4bbdfSmrg    $debug_cmd
137505b261ecSmrg
137635c4bbdfSmrg    _G_cmd=$1
137735c4bbdfSmrg    _G_fail_exp=${2-':'}
13784642e01fSmrg
1379c82838c1Smrg    func_quote_arg pretty,expand "$_G_cmd"
1380c82838c1Smrg    eval "func_notquiet $func_quote_arg_result"
138135c4bbdfSmrg
138235c4bbdfSmrg    $opt_dry_run || {
138335c4bbdfSmrg      eval "$_G_cmd"
138435c4bbdfSmrg      _G_status=$?
138535c4bbdfSmrg      if test 0 -ne "$_G_status"; then
138635c4bbdfSmrg	eval "(exit $_G_status); $_G_fail_exp"
13874642e01fSmrg      fi
138835c4bbdfSmrg    }
138905b261ecSmrg}
139005b261ecSmrg
13914642e01fSmrg
139235c4bbdfSmrg# func_show_eval_locale CMD [FAIL_EXP]
139335c4bbdfSmrg# ------------------------------------
139435c4bbdfSmrg# Unless opt_quiet is true, then output CMD.  Then, if opt_dryrun is
13954642e01fSmrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
13964642e01fSmrg# is given, then evaluate it.  Use the saved locale for evaluation.
13974642e01fSmrgfunc_show_eval_locale ()
139805b261ecSmrg{
139935c4bbdfSmrg    $debug_cmd
14004642e01fSmrg
140135c4bbdfSmrg    _G_cmd=$1
140235c4bbdfSmrg    _G_fail_exp=${2-':'}
140335c4bbdfSmrg
140435c4bbdfSmrg    $opt_quiet || {
1405c82838c1Smrg      func_quote_arg expand,pretty "$_G_cmd"
1406c82838c1Smrg      eval "func_echo $func_quote_arg_result"
14074642e01fSmrg    }
14084642e01fSmrg
140935c4bbdfSmrg    $opt_dry_run || {
141035c4bbdfSmrg      eval "$_G_user_locale
141135c4bbdfSmrg	    $_G_cmd"
141235c4bbdfSmrg      _G_status=$?
141335c4bbdfSmrg      eval "$_G_safe_locale"
141435c4bbdfSmrg      if test 0 -ne "$_G_status"; then
141535c4bbdfSmrg	eval "(exit $_G_status); $_G_fail_exp"
14164642e01fSmrg      fi
141735c4bbdfSmrg    }
14184642e01fSmrg}
141905b261ecSmrg
14204642e01fSmrg
142135c4bbdfSmrg# func_tr_sh
142235c4bbdfSmrg# ----------
142335c4bbdfSmrg# Turn $1 into a string suitable for a shell variable name.
142435c4bbdfSmrg# Result is stored in $func_tr_sh_result.  All characters
142535c4bbdfSmrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
142635c4bbdfSmrg# if $1 begins with a digit, a '_' is prepended as well.
142735c4bbdfSmrgfunc_tr_sh ()
14284642e01fSmrg{
142935c4bbdfSmrg    $debug_cmd
14304642e01fSmrg
143135c4bbdfSmrg    case $1 in
143235c4bbdfSmrg    [0-9]* | *[!a-zA-Z0-9_]*)
143335c4bbdfSmrg      func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'`
143435c4bbdfSmrg      ;;
143535c4bbdfSmrg    * )
143635c4bbdfSmrg      func_tr_sh_result=$1
143735c4bbdfSmrg      ;;
143835c4bbdfSmrg    esac
14394642e01fSmrg}
14404642e01fSmrg
14414642e01fSmrg
144235c4bbdfSmrg# func_verbose ARG...
144335c4bbdfSmrg# -------------------
144435c4bbdfSmrg# Echo program name prefixed message in verbose mode only.
144535c4bbdfSmrgfunc_verbose ()
14464642e01fSmrg{
144735c4bbdfSmrg    $debug_cmd
144805b261ecSmrg
144935c4bbdfSmrg    $opt_verbose && func_echo "$*"
14506747b715Smrg
145135c4bbdfSmrg    :
145235c4bbdfSmrg}
14534642e01fSmrg
14544642e01fSmrg
145535c4bbdfSmrg# func_warn_and_continue ARG...
145635c4bbdfSmrg# -----------------------------
145735c4bbdfSmrg# Echo program name prefixed warning message to standard error.
145835c4bbdfSmrgfunc_warn_and_continue ()
145935c4bbdfSmrg{
146035c4bbdfSmrg    $debug_cmd
146105b261ecSmrg
146235c4bbdfSmrg    $require_term_colors
146305b261ecSmrg
146435c4bbdfSmrg    func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2
146535c4bbdfSmrg}
1466475c125cSmrg
146735c4bbdfSmrg
146835c4bbdfSmrg# func_warning CATEGORY ARG...
146935c4bbdfSmrg# ----------------------------
147035c4bbdfSmrg# Echo program name prefixed warning message to standard error. Warning
147135c4bbdfSmrg# messages can be filtered according to CATEGORY, where this function
147235c4bbdfSmrg# elides messages where CATEGORY is not listed in the global variable
147335c4bbdfSmrg# 'opt_warning_types'.
147435c4bbdfSmrgfunc_warning ()
147535c4bbdfSmrg{
147635c4bbdfSmrg    $debug_cmd
147735c4bbdfSmrg
147835c4bbdfSmrg    # CATEGORY must be in the warning_categories list!
147935c4bbdfSmrg    case " $warning_categories " in
148035c4bbdfSmrg      *" $1 "*) ;;
148135c4bbdfSmrg      *) func_internal_error "invalid warning category '$1'" ;;
148235c4bbdfSmrg    esac
148335c4bbdfSmrg
148435c4bbdfSmrg    _G_category=$1
148535c4bbdfSmrg    shift
148635c4bbdfSmrg
148735c4bbdfSmrg    case " $opt_warning_types " in
148835c4bbdfSmrg      *" $_G_category "*) $warning_func ${1+"$@"} ;;
148935c4bbdfSmrg    esac
149035c4bbdfSmrg}
149135c4bbdfSmrg
149235c4bbdfSmrg
149335c4bbdfSmrg# func_sort_ver VER1 VER2
149435c4bbdfSmrg# -----------------------
149535c4bbdfSmrg# 'sort -V' is not generally available.
149635c4bbdfSmrg# Note this deviates from the version comparison in automake
149735c4bbdfSmrg# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a
149835c4bbdfSmrg# but this should suffice as we won't be specifying old
149935c4bbdfSmrg# version formats or redundant trailing .0 in bootstrap.conf.
150035c4bbdfSmrg# If we did want full compatibility then we should probably
150135c4bbdfSmrg# use m4_version_compare from autoconf.
150235c4bbdfSmrgfunc_sort_ver ()
150335c4bbdfSmrg{
150435c4bbdfSmrg    $debug_cmd
150535c4bbdfSmrg
150635c4bbdfSmrg    printf '%s\n%s\n' "$1" "$2" \
150735c4bbdfSmrg      | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n -k 5,5n -k 6,6n -k 7,7n -k 8,8n -k 9,9n
150835c4bbdfSmrg}
150935c4bbdfSmrg
151035c4bbdfSmrg# func_lt_ver PREV CURR
151135c4bbdfSmrg# ---------------------
151235c4bbdfSmrg# Return true if PREV and CURR are in the correct order according to
151335c4bbdfSmrg# func_sort_ver, otherwise false.  Use it like this:
151435c4bbdfSmrg#
151535c4bbdfSmrg#  func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..."
151635c4bbdfSmrgfunc_lt_ver ()
151735c4bbdfSmrg{
151835c4bbdfSmrg    $debug_cmd
151935c4bbdfSmrg
152035c4bbdfSmrg    test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q`
152135c4bbdfSmrg}
152235c4bbdfSmrg
152335c4bbdfSmrg
152435c4bbdfSmrg# Local variables:
152535c4bbdfSmrg# mode: shell-script
152635c4bbdfSmrg# sh-indentation: 2
152735c4bbdfSmrg# eval: (add-hook 'before-save-hook 'time-stamp)
152835c4bbdfSmrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
152935c4bbdfSmrg# time-stamp-time-zone: "UTC"
153035c4bbdfSmrg# End:
153135c4bbdfSmrg#! /bin/sh
153235c4bbdfSmrg
153335c4bbdfSmrg# A portable, pluggable option parser for Bourne shell.
153435c4bbdfSmrg# Written by Gary V. Vaughan, 2010
153535c4bbdfSmrg
1536c82838c1Smrg# This is free software.  There is NO warranty; not even for
1537c82838c1Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1538c82838c1Smrg#
153954b5899cSmrg# Copyright (C) 2010-2019, 2021, 2023-2024 Bootstrap Authors
1540c82838c1Smrg#
1541c82838c1Smrg# This file is dual licensed under the terms of the MIT license
154254b5899cSmrg# <https://opensource.org/licenses/MIT>, and GPL version 2 or later
154354b5899cSmrg# <https://www.gnu.org/licenses/gpl-2.0.html>.  You must apply one of
1544c82838c1Smrg# these licenses when using or redistributing this software or any of
1545c82838c1Smrg# the files within it.  See the URLs above, or the file `LICENSE`
1546c82838c1Smrg# included in the Bootstrap distribution for the full license texts.
154735c4bbdfSmrg
1548c82838c1Smrg# Please report bugs or propose patches to:
1549c82838c1Smrg# <https://github.com/gnulib-modules/bootstrap/issues>
155035c4bbdfSmrg
1551c82838c1Smrg# Set a version string for this script.
1552c82838c1Smrgscriptversion=2019-02-19.15; # UTC
155335c4bbdfSmrg
155435c4bbdfSmrg
155535c4bbdfSmrg## ------ ##
155635c4bbdfSmrg## Usage. ##
155735c4bbdfSmrg## ------ ##
155835c4bbdfSmrg
155935c4bbdfSmrg# This file is a library for parsing options in your shell scripts along
156035c4bbdfSmrg# with assorted other useful supporting features that you can make use
156135c4bbdfSmrg# of too.
156235c4bbdfSmrg#
156335c4bbdfSmrg# For the simplest scripts you might need only:
156435c4bbdfSmrg#
156535c4bbdfSmrg#   #!/bin/sh
156635c4bbdfSmrg#   . relative/path/to/funclib.sh
156735c4bbdfSmrg#   . relative/path/to/options-parser
156835c4bbdfSmrg#   scriptversion=1.0
156935c4bbdfSmrg#   func_options ${1+"$@"}
157035c4bbdfSmrg#   eval set dummy "$func_options_result"; shift
157135c4bbdfSmrg#   ...rest of your script...
157235c4bbdfSmrg#
157335c4bbdfSmrg# In order for the '--version' option to work, you will need to have a
157435c4bbdfSmrg# suitably formatted comment like the one at the top of this file
1575c82838c1Smrg# starting with '# Written by ' and ending with '# Copyright'.
157635c4bbdfSmrg#
157735c4bbdfSmrg# For '-h' and '--help' to work, you will also need a one line
157835c4bbdfSmrg# description of your script's purpose in a comment directly above the
157935c4bbdfSmrg# '# Written by ' line, like the one at the top of this file.
158035c4bbdfSmrg#
158135c4bbdfSmrg# The default options also support '--debug', which will turn on shell
158235c4bbdfSmrg# execution tracing (see the comment above debug_cmd below for another
158335c4bbdfSmrg# use), and '--verbose' and the func_verbose function to allow your script
158435c4bbdfSmrg# to display verbose messages only when your user has specified
158535c4bbdfSmrg# '--verbose'.
158635c4bbdfSmrg#
1587c82838c1Smrg# After sourcing this file, you can plug in processing for additional
158835c4bbdfSmrg# options by amending the variables from the 'Configuration' section
158935c4bbdfSmrg# below, and following the instructions in the 'Option parsing'
159035c4bbdfSmrg# section further down.
159135c4bbdfSmrg
159235c4bbdfSmrg## -------------- ##
159335c4bbdfSmrg## Configuration. ##
159435c4bbdfSmrg## -------------- ##
159535c4bbdfSmrg
159635c4bbdfSmrg# You should override these variables in your script after sourcing this
159735c4bbdfSmrg# file so that they reflect the customisations you have added to the
159835c4bbdfSmrg# option parser.
159935c4bbdfSmrg
160035c4bbdfSmrg# The usage line for option parsing errors and the start of '-h' and
160135c4bbdfSmrg# '--help' output messages. You can embed shell variables for delayed
160235c4bbdfSmrg# expansion at the time the message is displayed, but you will need to
160335c4bbdfSmrg# quote other shell meta-characters carefully to prevent them being
160435c4bbdfSmrg# expanded when the contents are evaled.
160535c4bbdfSmrgusage='$progpath [OPTION]...'
160635c4bbdfSmrg
160735c4bbdfSmrg# Short help message in response to '-h' and '--help'.  Add to this or
160835c4bbdfSmrg# override it after sourcing this library to reflect the full set of
160935c4bbdfSmrg# options your script accepts.
161035c4bbdfSmrgusage_message="\
161135c4bbdfSmrg       --debug        enable verbose shell tracing
161235c4bbdfSmrg   -W, --warnings=CATEGORY
161335c4bbdfSmrg                      report the warnings falling in CATEGORY [all]
161435c4bbdfSmrg   -v, --verbose      verbosely report processing
161535c4bbdfSmrg       --version      print version information and exit
161635c4bbdfSmrg   -h, --help         print short or long help message and exit
161735c4bbdfSmrg"
161835c4bbdfSmrg
161935c4bbdfSmrg# Additional text appended to 'usage_message' in response to '--help'.
162035c4bbdfSmrglong_help_message="
162135c4bbdfSmrgWarning categories include:
162235c4bbdfSmrg       'all'          show all warnings
162335c4bbdfSmrg       'none'         turn off all the warnings
162435c4bbdfSmrg       'error'        warnings are treated as fatal errors"
162535c4bbdfSmrg
162635c4bbdfSmrg# Help message printed before fatal option parsing errors.
162735c4bbdfSmrgfatal_help="Try '\$progname --help' for more information."
162835c4bbdfSmrg
162935c4bbdfSmrg
163035c4bbdfSmrg
163135c4bbdfSmrg## ------------------------- ##
163235c4bbdfSmrg## Hook function management. ##
163335c4bbdfSmrg## ------------------------- ##
163435c4bbdfSmrg
163535c4bbdfSmrg# This section contains functions for adding, removing, and running hooks
1636c82838c1Smrg# in the main code.  A hook is just a list of function names that can be
1637c82838c1Smrg# run in order later on.
163835c4bbdfSmrg
163935c4bbdfSmrg# func_hookable FUNC_NAME
164035c4bbdfSmrg# -----------------------
164135c4bbdfSmrg# Declare that FUNC_NAME will run hooks added with
164235c4bbdfSmrg# 'func_add_hook FUNC_NAME ...'.
164335c4bbdfSmrgfunc_hookable ()
164435c4bbdfSmrg{
164535c4bbdfSmrg    $debug_cmd
164635c4bbdfSmrg
164735c4bbdfSmrg    func_append hookable_fns " $1"
164835c4bbdfSmrg}
164935c4bbdfSmrg
165035c4bbdfSmrg
165135c4bbdfSmrg# func_add_hook FUNC_NAME HOOK_FUNC
165235c4bbdfSmrg# ---------------------------------
165335c4bbdfSmrg# Request that FUNC_NAME call HOOK_FUNC before it returns.  FUNC_NAME must
165435c4bbdfSmrg# first have been declared "hookable" by a call to 'func_hookable'.
165535c4bbdfSmrgfunc_add_hook ()
165635c4bbdfSmrg{
165735c4bbdfSmrg    $debug_cmd
165835c4bbdfSmrg
165935c4bbdfSmrg    case " $hookable_fns " in
166035c4bbdfSmrg      *" $1 "*) ;;
166135c4bbdfSmrg      *) func_fatal_error "'$1' does not accept hook functions." ;;
166235c4bbdfSmrg    esac
166335c4bbdfSmrg
166435c4bbdfSmrg    eval func_append ${1}_hooks '" $2"'
166535c4bbdfSmrg}
166635c4bbdfSmrg
166735c4bbdfSmrg
166835c4bbdfSmrg# func_remove_hook FUNC_NAME HOOK_FUNC
166935c4bbdfSmrg# ------------------------------------
1670c82838c1Smrg# Remove HOOK_FUNC from the list of hook functions to be called by
1671c82838c1Smrg# FUNC_NAME.
167235c4bbdfSmrgfunc_remove_hook ()
167335c4bbdfSmrg{
167435c4bbdfSmrg    $debug_cmd
167535c4bbdfSmrg
167635c4bbdfSmrg    eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`'
167735c4bbdfSmrg}
167835c4bbdfSmrg
167935c4bbdfSmrg
1680c82838c1Smrg# func_propagate_result FUNC_NAME_A FUNC_NAME_B
1681c82838c1Smrg# ---------------------------------------------
1682c82838c1Smrg# If the *_result variable of FUNC_NAME_A _is set_, assign its value to
1683c82838c1Smrg# *_result variable of FUNC_NAME_B.
1684c82838c1Smrgfunc_propagate_result ()
1685c82838c1Smrg{
1686c82838c1Smrg    $debug_cmd
1687c82838c1Smrg
1688c82838c1Smrg    func_propagate_result_result=:
1689c82838c1Smrg    if eval "test \"\${${1}_result+set}\" = set"
1690c82838c1Smrg    then
1691c82838c1Smrg      eval "${2}_result=\$${1}_result"
1692c82838c1Smrg    else
1693c82838c1Smrg      func_propagate_result_result=false
1694c82838c1Smrg    fi
1695c82838c1Smrg}
1696c82838c1Smrg
1697c82838c1Smrg
169835c4bbdfSmrg# func_run_hooks FUNC_NAME [ARG]...
169935c4bbdfSmrg# ---------------------------------
170035c4bbdfSmrg# Run all hook functions registered to FUNC_NAME.
1701c82838c1Smrg# It's assumed that the list of hook functions contains nothing more
170235c4bbdfSmrg# than a whitespace-delimited list of legal shell function names, and
170335c4bbdfSmrg# no effort is wasted trying to catch shell meta-characters or preserve
170435c4bbdfSmrg# whitespace.
170535c4bbdfSmrgfunc_run_hooks ()
170635c4bbdfSmrg{
170735c4bbdfSmrg    $debug_cmd
170835c4bbdfSmrg
170935c4bbdfSmrg    case " $hookable_fns " in
171035c4bbdfSmrg      *" $1 "*) ;;
1711c82838c1Smrg      *) func_fatal_error "'$1' does not support hook functions." ;;
171235c4bbdfSmrg    esac
171335c4bbdfSmrg
171435c4bbdfSmrg    eval _G_hook_fns=\$$1_hooks; shift
171535c4bbdfSmrg
171635c4bbdfSmrg    for _G_hook in $_G_hook_fns; do
1717c82838c1Smrg      func_unset "${_G_hook}_result"
1718c82838c1Smrg      eval $_G_hook '${1+"$@"}'
1719c82838c1Smrg      func_propagate_result $_G_hook func_run_hooks
1720c82838c1Smrg      if $func_propagate_result_result; then
1721c82838c1Smrg        eval set dummy "$func_run_hooks_result"; shift
1722ed6184dfSmrg      fi
172335c4bbdfSmrg    done
172435c4bbdfSmrg}
172535c4bbdfSmrg
172635c4bbdfSmrg
172735c4bbdfSmrg
172835c4bbdfSmrg## --------------- ##
172935c4bbdfSmrg## Option parsing. ##
173035c4bbdfSmrg## --------------- ##
173135c4bbdfSmrg
173235c4bbdfSmrg# In order to add your own option parsing hooks, you must accept the
1733c82838c1Smrg# full positional parameter list from your hook function.  You may remove
1734c82838c1Smrg# or edit any options that you action, and then pass back the remaining
1735c82838c1Smrg# unprocessed options in '<hooked_function_name>_result', escaped
1736c82838c1Smrg# suitably for 'eval'.
1737c82838c1Smrg#
1738c82838c1Smrg# The '<hooked_function_name>_result' variable is automatically unset
1739c82838c1Smrg# before your hook gets called; for best performance, only set the
1740c82838c1Smrg# *_result variable when necessary (i.e. don't call the 'func_quote'
1741c82838c1Smrg# function unnecessarily because it can be an expensive operation on some
1742c82838c1Smrg# machines).
1743ed6184dfSmrg#
1744ed6184dfSmrg# Like this:
174535c4bbdfSmrg#
174635c4bbdfSmrg#    my_options_prep ()
174735c4bbdfSmrg#    {
174835c4bbdfSmrg#        $debug_cmd
174935c4bbdfSmrg#
175035c4bbdfSmrg#        # Extend the existing usage message.
175135c4bbdfSmrg#        usage_message=$usage_message'
175235c4bbdfSmrg#      -s, --silent       don'\''t print informational messages
175335c4bbdfSmrg#    '
1754c82838c1Smrg#        # No change in '$@' (ignored completely by this hook).  Leave
1755c82838c1Smrg#        # my_options_prep_result variable intact.
175635c4bbdfSmrg#    }
175735c4bbdfSmrg#    func_add_hook func_options_prep my_options_prep
175835c4bbdfSmrg#
175935c4bbdfSmrg#
176035c4bbdfSmrg#    my_silent_option ()
176135c4bbdfSmrg#    {
176235c4bbdfSmrg#        $debug_cmd
176335c4bbdfSmrg#
1764ed6184dfSmrg#        args_changed=false
1765ed6184dfSmrg#
1766c82838c1Smrg#        # Note that, for efficiency, we parse as many options as we can
176735c4bbdfSmrg#        # recognise in a loop before passing the remainder back to the
176835c4bbdfSmrg#        # caller on the first unrecognised argument we encounter.
176935c4bbdfSmrg#        while test $# -gt 0; do
177035c4bbdfSmrg#          opt=$1; shift
177135c4bbdfSmrg#          case $opt in
1772ed6184dfSmrg#            --silent|-s) opt_silent=:
1773ed6184dfSmrg#                         args_changed=:
1774ed6184dfSmrg#                         ;;
177535c4bbdfSmrg#            # Separate non-argument short options:
177635c4bbdfSmrg#            -s*)         func_split_short_opt "$_G_opt"
177735c4bbdfSmrg#                         set dummy "$func_split_short_opt_name" \
177835c4bbdfSmrg#                             "-$func_split_short_opt_arg" ${1+"$@"}
177935c4bbdfSmrg#                         shift
1780ed6184dfSmrg#                         args_changed=:
178135c4bbdfSmrg#                         ;;
1782ed6184dfSmrg#            *)           # Make sure the first unrecognised option "$_G_opt"
1783c82838c1Smrg#                         # is added back to "$@" in case we need it later,
1784c82838c1Smrg#                         # if $args_changed was set to 'true'.
1785ed6184dfSmrg#                         set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
178635c4bbdfSmrg#          esac
178735c4bbdfSmrg#        done
178835c4bbdfSmrg#
1789c82838c1Smrg#        # Only call 'func_quote' here if we processed at least one argument.
1790ed6184dfSmrg#        if $args_changed; then
1791c82838c1Smrg#          func_quote eval ${1+"$@"}
1792c82838c1Smrg#          my_silent_option_result=$func_quote_result
1793ed6184dfSmrg#        fi
179435c4bbdfSmrg#    }
179535c4bbdfSmrg#    func_add_hook func_parse_options my_silent_option
179635c4bbdfSmrg#
179735c4bbdfSmrg#
179835c4bbdfSmrg#    my_option_validation ()
179935c4bbdfSmrg#    {
180035c4bbdfSmrg#        $debug_cmd
180135c4bbdfSmrg#
180235c4bbdfSmrg#        $opt_silent && $opt_verbose && func_fatal_help "\
180335c4bbdfSmrg#    '--silent' and '--verbose' options are mutually exclusive."
180435c4bbdfSmrg#    }
180535c4bbdfSmrg#    func_add_hook func_validate_options my_option_validation
180635c4bbdfSmrg#
1807ed6184dfSmrg# You'll also need to manually amend $usage_message to reflect the extra
180835c4bbdfSmrg# options you parse.  It's preferable to append if you can, so that
180935c4bbdfSmrg# multiple option parsing hooks can be added safely.
181035c4bbdfSmrg
181135c4bbdfSmrg
1812ed6184dfSmrg# func_options_finish [ARG]...
1813ed6184dfSmrg# ----------------------------
1814ed6184dfSmrg# Finishing the option parse loop (call 'func_options' hooks ATM).
1815ed6184dfSmrgfunc_options_finish ()
1816ed6184dfSmrg{
1817ed6184dfSmrg    $debug_cmd
1818ed6184dfSmrg
1819c82838c1Smrg    func_run_hooks func_options ${1+"$@"}
1820c82838c1Smrg    func_propagate_result func_run_hooks func_options_finish
1821ed6184dfSmrg}
1822ed6184dfSmrg
1823ed6184dfSmrg
182435c4bbdfSmrg# func_options [ARG]...
182535c4bbdfSmrg# ---------------------
182635c4bbdfSmrg# All the functions called inside func_options are hookable. See the
182735c4bbdfSmrg# individual implementations for details.
182835c4bbdfSmrgfunc_hookable func_options
182935c4bbdfSmrgfunc_options ()
183035c4bbdfSmrg{
183135c4bbdfSmrg    $debug_cmd
183235c4bbdfSmrg
1833c82838c1Smrg    _G_options_quoted=false
1834ed6184dfSmrg
1835ed6184dfSmrg    for my_func in options_prep parse_options validate_options options_finish
1836ed6184dfSmrg    do
1837c82838c1Smrg      func_unset func_${my_func}_result
1838c82838c1Smrg      func_unset func_run_hooks_result
1839c82838c1Smrg      eval func_$my_func '${1+"$@"}'
1840c82838c1Smrg      func_propagate_result func_$my_func func_options
1841c82838c1Smrg      if $func_propagate_result_result; then
1842c82838c1Smrg        eval set dummy "$func_options_result"; shift
1843c82838c1Smrg        _G_options_quoted=:
1844ed6184dfSmrg      fi
1845ed6184dfSmrg    done
184635c4bbdfSmrg
1847c82838c1Smrg    $_G_options_quoted || {
1848c82838c1Smrg      # As we (func_options) are top-level options-parser function and
1849c82838c1Smrg      # nobody quoted "$@" for us yet, we need to do it explicitly for
1850c82838c1Smrg      # caller.
1851c82838c1Smrg      func_quote eval ${1+"$@"}
1852c82838c1Smrg      func_options_result=$func_quote_result
1853c82838c1Smrg    }
185435c4bbdfSmrg}
185535c4bbdfSmrg
185635c4bbdfSmrg
185735c4bbdfSmrg# func_options_prep [ARG]...
185835c4bbdfSmrg# --------------------------
185935c4bbdfSmrg# All initialisations required before starting the option parse loop.
186035c4bbdfSmrg# Note that when calling hook functions, we pass through the list of
186135c4bbdfSmrg# positional parameters.  If a hook function modifies that list, and
1862ed6184dfSmrg# needs to propagate that back to rest of this script, then the complete
1863c82838c1Smrg# modified list must be put in 'func_run_hooks_result' before returning.
186435c4bbdfSmrgfunc_hookable func_options_prep
186535c4bbdfSmrgfunc_options_prep ()
186635c4bbdfSmrg{
186735c4bbdfSmrg    $debug_cmd
186835c4bbdfSmrg
186935c4bbdfSmrg    # Option defaults:
187035c4bbdfSmrg    opt_verbose=false
187135c4bbdfSmrg    opt_warning_types=
187235c4bbdfSmrg
1873c82838c1Smrg    func_run_hooks func_options_prep ${1+"$@"}
1874c82838c1Smrg    func_propagate_result func_run_hooks func_options_prep
187535c4bbdfSmrg}
187635c4bbdfSmrg
187735c4bbdfSmrg
187835c4bbdfSmrg# func_parse_options [ARG]...
187935c4bbdfSmrg# ---------------------------
188035c4bbdfSmrg# The main option parsing loop.
188135c4bbdfSmrgfunc_hookable func_parse_options
188235c4bbdfSmrgfunc_parse_options ()
188335c4bbdfSmrg{
188435c4bbdfSmrg    $debug_cmd
188535c4bbdfSmrg
1886c82838c1Smrg    _G_parse_options_requote=false
188735c4bbdfSmrg    # this just eases exit handling
188835c4bbdfSmrg    while test $# -gt 0; do
188935c4bbdfSmrg      # Defer to hook functions for initial option parsing, so they
189035c4bbdfSmrg      # get priority in the event of reusing an option name.
1891c82838c1Smrg      func_run_hooks func_parse_options ${1+"$@"}
1892c82838c1Smrg      func_propagate_result func_run_hooks func_parse_options
1893c82838c1Smrg      if $func_propagate_result_result; then
1894c82838c1Smrg        eval set dummy "$func_parse_options_result"; shift
1895c82838c1Smrg        # Even though we may have changed "$@", we passed the "$@" array
1896c82838c1Smrg        # down into the hook and it quoted it for us (because we are in
1897c82838c1Smrg        # this if-branch).  No need to quote it again.
1898c82838c1Smrg        _G_parse_options_requote=false
1899ed6184dfSmrg      fi
190035c4bbdfSmrg
190135c4bbdfSmrg      # Break out of the loop if we already parsed every option.
190235c4bbdfSmrg      test $# -gt 0 || break
190335c4bbdfSmrg
1904c82838c1Smrg      # We expect that one of the options parsed in this function matches
1905c82838c1Smrg      # and thus we remove _G_opt from "$@" and need to re-quote.
1906ed6184dfSmrg      _G_match_parse_options=:
190735c4bbdfSmrg      _G_opt=$1
190835c4bbdfSmrg      shift
190935c4bbdfSmrg      case $_G_opt in
191035c4bbdfSmrg        --debug|-x)   debug_cmd='set -x'
1911c82838c1Smrg                      func_echo "enabling shell trace mode" >&2
191235c4bbdfSmrg                      $debug_cmd
191335c4bbdfSmrg                      ;;
191435c4bbdfSmrg
191535c4bbdfSmrg        --no-warnings|--no-warning|--no-warn)
191635c4bbdfSmrg                      set dummy --warnings none ${1+"$@"}
191735c4bbdfSmrg                      shift
191835c4bbdfSmrg		      ;;
191935c4bbdfSmrg
192035c4bbdfSmrg        --warnings|--warning|-W)
1921ed6184dfSmrg                      if test $# = 0 && func_missing_arg $_G_opt; then
1922c82838c1Smrg                        _G_parse_options_requote=:
1923ed6184dfSmrg                        break
1924ed6184dfSmrg                      fi
192535c4bbdfSmrg                      case " $warning_categories $1" in
192635c4bbdfSmrg                        *" $1 "*)
192735c4bbdfSmrg                          # trailing space prevents matching last $1 above
192835c4bbdfSmrg                          func_append_uniq opt_warning_types " $1"
192935c4bbdfSmrg                          ;;
193035c4bbdfSmrg                        *all)
193135c4bbdfSmrg                          opt_warning_types=$warning_categories
193235c4bbdfSmrg                          ;;
193335c4bbdfSmrg                        *none)
193435c4bbdfSmrg                          opt_warning_types=none
193535c4bbdfSmrg                          warning_func=:
193635c4bbdfSmrg                          ;;
193735c4bbdfSmrg                        *error)
193835c4bbdfSmrg                          opt_warning_types=$warning_categories
193935c4bbdfSmrg                          warning_func=func_fatal_error
194035c4bbdfSmrg                          ;;
194135c4bbdfSmrg                        *)
194235c4bbdfSmrg                          func_fatal_error \
194335c4bbdfSmrg                             "unsupported warning category: '$1'"
194435c4bbdfSmrg                          ;;
194535c4bbdfSmrg                      esac
194635c4bbdfSmrg                      shift
194735c4bbdfSmrg                      ;;
194835c4bbdfSmrg
194935c4bbdfSmrg        --verbose|-v) opt_verbose=: ;;
195035c4bbdfSmrg        --version)    func_version ;;
195135c4bbdfSmrg        -\?|-h)       func_usage ;;
195235c4bbdfSmrg        --help)       func_help ;;
195335c4bbdfSmrg
195435c4bbdfSmrg	# Separate optargs to long options (plugins may need this):
195535c4bbdfSmrg	--*=*)        func_split_equals "$_G_opt"
195635c4bbdfSmrg	              set dummy "$func_split_equals_lhs" \
195735c4bbdfSmrg                          "$func_split_equals_rhs" ${1+"$@"}
195835c4bbdfSmrg                      shift
195935c4bbdfSmrg                      ;;
196035c4bbdfSmrg
196135c4bbdfSmrg       # Separate optargs to short options:
196235c4bbdfSmrg        -W*)
196335c4bbdfSmrg                      func_split_short_opt "$_G_opt"
196435c4bbdfSmrg                      set dummy "$func_split_short_opt_name" \
196535c4bbdfSmrg                          "$func_split_short_opt_arg" ${1+"$@"}
196635c4bbdfSmrg                      shift
196735c4bbdfSmrg                      ;;
196835c4bbdfSmrg
196935c4bbdfSmrg        # Separate non-argument short options:
197035c4bbdfSmrg        -\?*|-h*|-v*|-x*)
197135c4bbdfSmrg                      func_split_short_opt "$_G_opt"
197235c4bbdfSmrg                      set dummy "$func_split_short_opt_name" \
197335c4bbdfSmrg                          "-$func_split_short_opt_arg" ${1+"$@"}
197435c4bbdfSmrg                      shift
197535c4bbdfSmrg                      ;;
197635c4bbdfSmrg
1977c82838c1Smrg        --)           _G_parse_options_requote=: ; break ;;
197835c4bbdfSmrg        -*)           func_fatal_help "unrecognised option: '$_G_opt'" ;;
1979ed6184dfSmrg        *)            set dummy "$_G_opt" ${1+"$@"}; shift
1980ed6184dfSmrg                      _G_match_parse_options=false
1981ed6184dfSmrg                      break
1982ed6184dfSmrg                      ;;
198335c4bbdfSmrg      esac
1984ed6184dfSmrg
1985c82838c1Smrg      if $_G_match_parse_options; then
1986c82838c1Smrg        _G_parse_options_requote=:
1987c82838c1Smrg      fi
198835c4bbdfSmrg    done
198935c4bbdfSmrg
1990c82838c1Smrg    if $_G_parse_options_requote; then
1991ed6184dfSmrg      # save modified positional parameters for caller
1992c82838c1Smrg      func_quote eval ${1+"$@"}
1993c82838c1Smrg      func_parse_options_result=$func_quote_result
1994ed6184dfSmrg    fi
199535c4bbdfSmrg}
199635c4bbdfSmrg
199735c4bbdfSmrg
199835c4bbdfSmrg# func_validate_options [ARG]...
199935c4bbdfSmrg# ------------------------------
200035c4bbdfSmrg# Perform any sanity checks on option settings and/or unconsumed
200135c4bbdfSmrg# arguments.
200235c4bbdfSmrgfunc_hookable func_validate_options
200335c4bbdfSmrgfunc_validate_options ()
200435c4bbdfSmrg{
200535c4bbdfSmrg    $debug_cmd
200635c4bbdfSmrg
200735c4bbdfSmrg    # Display all warnings if -W was not given.
200835c4bbdfSmrg    test -n "$opt_warning_types" || opt_warning_types=" $warning_categories"
200935c4bbdfSmrg
2010c82838c1Smrg    func_run_hooks func_validate_options ${1+"$@"}
2011c82838c1Smrg    func_propagate_result func_run_hooks func_validate_options
201235c4bbdfSmrg
201335c4bbdfSmrg    # Bail if the options were screwed!
201435c4bbdfSmrg    $exit_cmd $EXIT_FAILURE
201535c4bbdfSmrg}
201635c4bbdfSmrg
201735c4bbdfSmrg
201835c4bbdfSmrg
201935c4bbdfSmrg## ----------------- ##
202035c4bbdfSmrg## Helper functions. ##
202135c4bbdfSmrg## ----------------- ##
202235c4bbdfSmrg
202335c4bbdfSmrg# This section contains the helper functions used by the rest of the
202435c4bbdfSmrg# hookable option parser framework in ascii-betical order.
202535c4bbdfSmrg
202635c4bbdfSmrg
202735c4bbdfSmrg# func_fatal_help ARG...
202835c4bbdfSmrg# ----------------------
202935c4bbdfSmrg# Echo program name prefixed message to standard error, followed by
203035c4bbdfSmrg# a help hint, and exit.
203135c4bbdfSmrgfunc_fatal_help ()
203235c4bbdfSmrg{
203335c4bbdfSmrg    $debug_cmd
203435c4bbdfSmrg
203535c4bbdfSmrg    eval \$ECHO \""Usage: $usage"\"
203635c4bbdfSmrg    eval \$ECHO \""$fatal_help"\"
203735c4bbdfSmrg    func_error ${1+"$@"}
203835c4bbdfSmrg    exit $EXIT_FAILURE
203935c4bbdfSmrg}
204035c4bbdfSmrg
204135c4bbdfSmrg
204235c4bbdfSmrg# func_help
204335c4bbdfSmrg# ---------
204435c4bbdfSmrg# Echo long help message to standard output and exit.
204535c4bbdfSmrgfunc_help ()
204635c4bbdfSmrg{
204735c4bbdfSmrg    $debug_cmd
204835c4bbdfSmrg
204935c4bbdfSmrg    func_usage_message
205035c4bbdfSmrg    $ECHO "$long_help_message"
205135c4bbdfSmrg    exit 0
205235c4bbdfSmrg}
205335c4bbdfSmrg
205435c4bbdfSmrg
205535c4bbdfSmrg# func_missing_arg ARGNAME
205635c4bbdfSmrg# ------------------------
205735c4bbdfSmrg# Echo program name prefixed message to standard error and set global
205835c4bbdfSmrg# exit_cmd.
205935c4bbdfSmrgfunc_missing_arg ()
206035c4bbdfSmrg{
206135c4bbdfSmrg    $debug_cmd
206235c4bbdfSmrg
206335c4bbdfSmrg    func_error "Missing argument for '$1'."
206435c4bbdfSmrg    exit_cmd=exit
206535c4bbdfSmrg}
206635c4bbdfSmrg
206735c4bbdfSmrg
206835c4bbdfSmrg# func_split_equals STRING
206935c4bbdfSmrg# ------------------------
2070c82838c1Smrg# Set func_split_equals_lhs and func_split_equals_rhs shell variables
2071c82838c1Smrg# after splitting STRING at the '=' sign.
207235c4bbdfSmrgtest -z "$_G_HAVE_XSI_OPS" \
207335c4bbdfSmrg    && (eval 'x=a/b/c;
207435c4bbdfSmrg      test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
207535c4bbdfSmrg    && _G_HAVE_XSI_OPS=yes
207635c4bbdfSmrg
207735c4bbdfSmrgif test yes = "$_G_HAVE_XSI_OPS"
207835c4bbdfSmrgthen
207935c4bbdfSmrg  # This is an XSI compatible shell, allowing a faster implementation...
208035c4bbdfSmrg  eval 'func_split_equals ()
208135c4bbdfSmrg  {
208235c4bbdfSmrg      $debug_cmd
208335c4bbdfSmrg
208435c4bbdfSmrg      func_split_equals_lhs=${1%%=*}
208535c4bbdfSmrg      func_split_equals_rhs=${1#*=}
2086c82838c1Smrg      if test "x$func_split_equals_lhs" = "x$1"; then
2087c82838c1Smrg        func_split_equals_rhs=
2088c82838c1Smrg      fi
208935c4bbdfSmrg  }'
209035c4bbdfSmrgelse
209135c4bbdfSmrg  # ...otherwise fall back to using expr, which is often a shell builtin.
209235c4bbdfSmrg  func_split_equals ()
209335c4bbdfSmrg  {
209435c4bbdfSmrg      $debug_cmd
209535c4bbdfSmrg
209635c4bbdfSmrg      func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'`
209735c4bbdfSmrg      func_split_equals_rhs=
2098c82838c1Smrg      test "x$func_split_equals_lhs=" = "x$1" \
209935c4bbdfSmrg        || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'`
210035c4bbdfSmrg  }
210135c4bbdfSmrgfi #func_split_equals
210235c4bbdfSmrg
210335c4bbdfSmrg
210435c4bbdfSmrg# func_split_short_opt SHORTOPT
210535c4bbdfSmrg# -----------------------------
210635c4bbdfSmrg# Set func_split_short_opt_name and func_split_short_opt_arg shell
210735c4bbdfSmrg# variables after splitting SHORTOPT after the 2nd character.
210835c4bbdfSmrgif test yes = "$_G_HAVE_XSI_OPS"
210935c4bbdfSmrgthen
211035c4bbdfSmrg  # This is an XSI compatible shell, allowing a faster implementation...
211135c4bbdfSmrg  eval 'func_split_short_opt ()
211235c4bbdfSmrg  {
211335c4bbdfSmrg      $debug_cmd
211435c4bbdfSmrg
211535c4bbdfSmrg      func_split_short_opt_arg=${1#??}
211635c4bbdfSmrg      func_split_short_opt_name=${1%"$func_split_short_opt_arg"}
211735c4bbdfSmrg  }'
211835c4bbdfSmrgelse
211935c4bbdfSmrg  # ...otherwise fall back to using expr, which is often a shell builtin.
212035c4bbdfSmrg  func_split_short_opt ()
212135c4bbdfSmrg  {
212235c4bbdfSmrg      $debug_cmd
212335c4bbdfSmrg
2124c82838c1Smrg      func_split_short_opt_name=`expr "x$1" : 'x\(-.\)'`
212535c4bbdfSmrg      func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'`
212635c4bbdfSmrg  }
212735c4bbdfSmrgfi #func_split_short_opt
212835c4bbdfSmrg
212935c4bbdfSmrg
213035c4bbdfSmrg# func_usage
213135c4bbdfSmrg# ----------
213235c4bbdfSmrg# Echo short help message to standard output and exit.
213335c4bbdfSmrgfunc_usage ()
213435c4bbdfSmrg{
213535c4bbdfSmrg    $debug_cmd
213635c4bbdfSmrg
213735c4bbdfSmrg    func_usage_message
213835c4bbdfSmrg    $ECHO "Run '$progname --help |${PAGER-more}' for full usage"
213935c4bbdfSmrg    exit 0
214035c4bbdfSmrg}
214135c4bbdfSmrg
214235c4bbdfSmrg
214335c4bbdfSmrg# func_usage_message
214435c4bbdfSmrg# ------------------
214535c4bbdfSmrg# Echo short help message to standard output.
214635c4bbdfSmrgfunc_usage_message ()
214735c4bbdfSmrg{
214835c4bbdfSmrg    $debug_cmd
214935c4bbdfSmrg
215035c4bbdfSmrg    eval \$ECHO \""Usage: $usage"\"
215135c4bbdfSmrg    echo
215235c4bbdfSmrg    $SED -n 's|^# ||
215335c4bbdfSmrg        /^Written by/{
215435c4bbdfSmrg          x;p;x
215535c4bbdfSmrg        }
215635c4bbdfSmrg	h
215735c4bbdfSmrg	/^Written by/q' < "$progpath"
215835c4bbdfSmrg    echo
215935c4bbdfSmrg    eval \$ECHO \""$usage_message"\"
216035c4bbdfSmrg}
216135c4bbdfSmrg
216235c4bbdfSmrg
216335c4bbdfSmrg# func_version
216435c4bbdfSmrg# ------------
216535c4bbdfSmrg# Echo version message to standard output and exit.
2166c82838c1Smrg# The version message is extracted from the calling file's header
2167c82838c1Smrg# comments, with leading '# ' stripped:
2168c82838c1Smrg#   1. First display the progname and version
2169c82838c1Smrg#   2. Followed by the header comment line matching  /^# Written by /
2170c82838c1Smrg#   3. Then a blank line followed by the first following line matching
2171c82838c1Smrg#      /^# Copyright /
2172c82838c1Smrg#   4. Immediately followed by any lines between the previous matches,
2173c82838c1Smrg#      except lines preceding the intervening completely blank line.
2174c82838c1Smrg# For example, see the header comments of this file.
217535c4bbdfSmrgfunc_version ()
217635c4bbdfSmrg{
217735c4bbdfSmrg    $debug_cmd
217835c4bbdfSmrg
217935c4bbdfSmrg    printf '%s\n' "$progname $scriptversion"
218035c4bbdfSmrg    $SED -n '
2181c82838c1Smrg        /^# Written by /!b
2182c82838c1Smrg        s|^# ||; p; n
2183c82838c1Smrg
2184c82838c1Smrg        :fwd2blnk
2185c82838c1Smrg        /./ {
2186c82838c1Smrg          n
2187c82838c1Smrg          b fwd2blnk
218835c4bbdfSmrg        }
2189c82838c1Smrg        p; n
2190c82838c1Smrg
2191c82838c1Smrg        :holdwrnt
2192c82838c1Smrg        s|^# ||
2193c82838c1Smrg        s|^# *$||
2194c82838c1Smrg        /^Copyright /!{
2195c82838c1Smrg          /./H
2196c82838c1Smrg          n
2197c82838c1Smrg          b holdwrnt
219835c4bbdfSmrg        }
2199c82838c1Smrg
2200c82838c1Smrg        s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2|
2201c82838c1Smrg        G
2202c82838c1Smrg        s|\(\n\)\n*|\1|g
2203c82838c1Smrg        p; q' < "$progpath"
220435c4bbdfSmrg
220535c4bbdfSmrg    exit $?
220635c4bbdfSmrg}
220735c4bbdfSmrg
220835c4bbdfSmrg
220935c4bbdfSmrg# Local variables:
221035c4bbdfSmrg# mode: shell-script
221135c4bbdfSmrg# sh-indentation: 2
221235c4bbdfSmrg# eval: (add-hook 'before-save-hook 'time-stamp)
2213c82838c1Smrg# time-stamp-pattern: "30/scriptversion=%:y-%02m-%02d.%02H; # UTC"
221435c4bbdfSmrg# time-stamp-time-zone: "UTC"
221535c4bbdfSmrg# End:
221635c4bbdfSmrg
221735c4bbdfSmrg# Set a version string.
221854b5899cSmrgscriptversion='(GNU libtool) 2.5.4'
221954b5899cSmrg
222054b5899cSmrg# func_version
222154b5899cSmrg# ------------
222254b5899cSmrg# Echo version message to standard output and exit.
222354b5899cSmrgfunc_version ()
222454b5899cSmrg{
222554b5899cSmrg    $debug_cmd
222654b5899cSmrg
222754b5899cSmrg	year=`date +%Y`
222854b5899cSmrg
222954b5899cSmrg	cat <<EOF
223054b5899cSmrg$progname $scriptversion
223154b5899cSmrgCopyright (C) $year Free Software Foundation, Inc.
223254b5899cSmrgLicense GPLv2+: GNU GPL version 2 or later <https://gnu.org/licenses/gpl.html>
223354b5899cSmrgThis is free software: you are free to change and redistribute it.
223454b5899cSmrgThere is NO WARRANTY, to the extent permitted by law.
223554b5899cSmrg
223654b5899cSmrgOriginally written by Gordon Matzigkeit, 1996
223754b5899cSmrg(See AUTHORS for complete contributor listing)
223854b5899cSmrgEOF
223954b5899cSmrg
224054b5899cSmrg    exit $?
224154b5899cSmrg}
224235c4bbdfSmrg
224335c4bbdfSmrg
224435c4bbdfSmrg# func_echo ARG...
224535c4bbdfSmrg# ----------------
224635c4bbdfSmrg# Libtool also displays the current mode in messages, so override
224735c4bbdfSmrg# funclib.sh func_echo with this custom definition.
224835c4bbdfSmrgfunc_echo ()
224935c4bbdfSmrg{
225035c4bbdfSmrg    $debug_cmd
225135c4bbdfSmrg
225235c4bbdfSmrg    _G_message=$*
225335c4bbdfSmrg
225435c4bbdfSmrg    func_echo_IFS=$IFS
225535c4bbdfSmrg    IFS=$nl
225635c4bbdfSmrg    for _G_line in $_G_message; do
225735c4bbdfSmrg      IFS=$func_echo_IFS
225835c4bbdfSmrg      $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line"
225935c4bbdfSmrg    done
226035c4bbdfSmrg    IFS=$func_echo_IFS
226135c4bbdfSmrg}
226235c4bbdfSmrg
226335c4bbdfSmrg
226435c4bbdfSmrg## ---------------- ##
226535c4bbdfSmrg## Options parsing. ##
226635c4bbdfSmrg## ---------------- ##
226735c4bbdfSmrg
226835c4bbdfSmrg# Hook in the functions to make sure our own options are parsed during
226935c4bbdfSmrg# the option parsing loop.
227035c4bbdfSmrg
227135c4bbdfSmrgusage='$progpath [OPTION]... [MODE-ARG]...'
227235c4bbdfSmrg
227335c4bbdfSmrg# Short help message in response to '-h'.
227435c4bbdfSmrgusage_message="Options:
227554b5899cSmrg       --config                 show all configuration variables
227654b5899cSmrg       --debug                  enable verbose shell tracing
227754b5899cSmrg   -n, --dry-run                display commands without modifying any files
227854b5899cSmrg       --features               display basic configuration information
227954b5899cSmrg       --finish                 use operation '--mode=finish'
228054b5899cSmrg       --mode=MODE              use operation mode MODE
228154b5899cSmrg       --no-finish              don't update shared library cache
228254b5899cSmrg       --no-quiet, --no-silent  print default informational messages
228354b5899cSmrg       --no-warnings            equivalent to '-Wnone'
228454b5899cSmrg       --preserve-dup-deps      don't remove duplicate dependency libraries
228554b5899cSmrg       --quiet, --silent        don't print informational messages
228654b5899cSmrg       --reorder-cache=DIRS     reorder shared library cache for preferred DIRS
228754b5899cSmrg       --tag=TAG                use configuration variables from tag TAG
228854b5899cSmrg   -v, --verbose                print more informational messages than default
228954b5899cSmrg       --version                print version information
229054b5899cSmrg   -W, --warnings=CATEGORY      report the warnings falling in CATEGORY [all]
229154b5899cSmrg   -h, --help, --help-all       print short, long, or detailed help message
229235c4bbdfSmrg"
229335c4bbdfSmrg
229435c4bbdfSmrg# Additional text appended to 'usage_message' in response to '--help'.
229535c4bbdfSmrgfunc_help ()
229635c4bbdfSmrg{
229735c4bbdfSmrg    $debug_cmd
229835c4bbdfSmrg
229935c4bbdfSmrg    func_usage_message
230035c4bbdfSmrg    $ECHO "$long_help_message
230135c4bbdfSmrg
230235c4bbdfSmrgMODE must be one of the following:
230335c4bbdfSmrg
230435c4bbdfSmrg       clean           remove files from the build directory
230535c4bbdfSmrg       compile         compile a source file into a libtool object
230635c4bbdfSmrg       execute         automatically set library path, then run a program
230735c4bbdfSmrg       finish          complete the installation of libtool libraries
230835c4bbdfSmrg       install         install libraries or executables
230935c4bbdfSmrg       link            create a library or an executable
231035c4bbdfSmrg       uninstall       remove libraries from an installed directory
231135c4bbdfSmrg
231235c4bbdfSmrgMODE-ARGS vary depending on the MODE.  When passed as first option,
231335c4bbdfSmrg'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that.
231435c4bbdfSmrgTry '$progname --help --mode=MODE' for a more detailed description of MODE.
231535c4bbdfSmrg
231635c4bbdfSmrgWhen reporting a bug, please describe a test case to reproduce it and
231735c4bbdfSmrginclude the following information:
231835c4bbdfSmrg
231935c4bbdfSmrg       host-triplet:   $host
232035c4bbdfSmrg       shell:          $SHELL
232135c4bbdfSmrg       compiler:       $LTCC
232235c4bbdfSmrg       compiler flags: $LTCFLAGS
232335c4bbdfSmrg       linker:         $LD (gnu? $with_gnu_ld)
232454b5899cSmrg       version:        $progname $scriptversion
232535c4bbdfSmrg       automake:       `($AUTOMAKE --version) 2>/dev/null |$SED 1q`
232635c4bbdfSmrg       autoconf:       `($AUTOCONF --version) 2>/dev/null |$SED 1q`
232735c4bbdfSmrg
232835c4bbdfSmrgReport bugs to <bug-libtool@gnu.org>.
232954b5899cSmrgGNU libtool home page: <https://www.gnu.org/software/libtool/>.
233054b5899cSmrgGeneral help using GNU software: <https://www.gnu.org/gethelp/>."
233135c4bbdfSmrg    exit 0
233235c4bbdfSmrg}
233335c4bbdfSmrg
233435c4bbdfSmrg
233535c4bbdfSmrg# func_lo2o OBJECT-NAME
233635c4bbdfSmrg# ---------------------
233735c4bbdfSmrg# Transform OBJECT-NAME from a '.lo' suffix to the platform specific
233835c4bbdfSmrg# object suffix.
233935c4bbdfSmrg
234035c4bbdfSmrglo2o=s/\\.lo\$/.$objext/
234135c4bbdfSmrgo2lo=s/\\.$objext\$/.lo/
234235c4bbdfSmrg
234335c4bbdfSmrgif test yes = "$_G_HAVE_XSI_OPS"; then
234435c4bbdfSmrg  eval 'func_lo2o ()
234535c4bbdfSmrg  {
234635c4bbdfSmrg    case $1 in
234735c4bbdfSmrg      *.lo) func_lo2o_result=${1%.lo}.$objext ;;
234835c4bbdfSmrg      *   ) func_lo2o_result=$1               ;;
234935c4bbdfSmrg    esac
235035c4bbdfSmrg  }'
235135c4bbdfSmrg
235235c4bbdfSmrg  # func_xform LIBOBJ-OR-SOURCE
235335c4bbdfSmrg  # ---------------------------
235435c4bbdfSmrg  # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise)
235535c4bbdfSmrg  # suffix to a '.lo' libtool-object suffix.
235635c4bbdfSmrg  eval 'func_xform ()
235735c4bbdfSmrg  {
235835c4bbdfSmrg    func_xform_result=${1%.*}.lo
235935c4bbdfSmrg  }'
236035c4bbdfSmrgelse
236135c4bbdfSmrg  # ...otherwise fall back to using sed.
236235c4bbdfSmrg  func_lo2o ()
236335c4bbdfSmrg  {
236435c4bbdfSmrg    func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"`
236535c4bbdfSmrg  }
236635c4bbdfSmrg
236735c4bbdfSmrg  func_xform ()
236835c4bbdfSmrg  {
236935c4bbdfSmrg    func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'`
237035c4bbdfSmrg  }
237135c4bbdfSmrgfi
237235c4bbdfSmrg
237335c4bbdfSmrg
237435c4bbdfSmrg# func_fatal_configuration ARG...
237535c4bbdfSmrg# -------------------------------
237635c4bbdfSmrg# Echo program name prefixed message to standard error, followed by
237735c4bbdfSmrg# a configuration failure hint, and exit.
237835c4bbdfSmrgfunc_fatal_configuration ()
237935c4bbdfSmrg{
2380c82838c1Smrg    func_fatal_error ${1+"$@"} \
238135c4bbdfSmrg      "See the $PACKAGE documentation for more information." \
238235c4bbdfSmrg      "Fatal configuration error."
238335c4bbdfSmrg}
238435c4bbdfSmrg
238535c4bbdfSmrg
238635c4bbdfSmrg# func_config
238735c4bbdfSmrg# -----------
238835c4bbdfSmrg# Display the configuration for all the tags in this script.
238935c4bbdfSmrgfunc_config ()
239035c4bbdfSmrg{
239135c4bbdfSmrg    re_begincf='^# ### BEGIN LIBTOOL'
239235c4bbdfSmrg    re_endcf='^# ### END LIBTOOL'
239335c4bbdfSmrg
239435c4bbdfSmrg    # Default configuration.
239535c4bbdfSmrg    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
239635c4bbdfSmrg
239735c4bbdfSmrg    # Now print the configurations for the tags.
239835c4bbdfSmrg    for tagname in $taglist; do
239935c4bbdfSmrg      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
240035c4bbdfSmrg    done
240135c4bbdfSmrg
240235c4bbdfSmrg    exit $?
240335c4bbdfSmrg}
240435c4bbdfSmrg
240535c4bbdfSmrg
240635c4bbdfSmrg# func_features
240735c4bbdfSmrg# -------------
240835c4bbdfSmrg# Display the features supported by this script.
240935c4bbdfSmrgfunc_features ()
241035c4bbdfSmrg{
241135c4bbdfSmrg    echo "host: $host"
241235c4bbdfSmrg    if test yes = "$build_libtool_libs"; then
241335c4bbdfSmrg      echo "enable shared libraries"
241435c4bbdfSmrg    else
241535c4bbdfSmrg      echo "disable shared libraries"
241635c4bbdfSmrg    fi
241735c4bbdfSmrg    if test yes = "$build_old_libs"; then
241835c4bbdfSmrg      echo "enable static libraries"
241935c4bbdfSmrg    else
242035c4bbdfSmrg      echo "disable static libraries"
242135c4bbdfSmrg    fi
242235c4bbdfSmrg
242335c4bbdfSmrg    exit $?
242435c4bbdfSmrg}
242535c4bbdfSmrg
242635c4bbdfSmrg
242735c4bbdfSmrg# func_enable_tag TAGNAME
242835c4bbdfSmrg# -----------------------
242935c4bbdfSmrg# Verify that TAGNAME is valid, and either flag an error and exit, or
243035c4bbdfSmrg# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
243135c4bbdfSmrg# variable here.
243235c4bbdfSmrgfunc_enable_tag ()
243335c4bbdfSmrg{
243435c4bbdfSmrg    # Global variable:
243535c4bbdfSmrg    tagname=$1
243635c4bbdfSmrg
243735c4bbdfSmrg    re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
243835c4bbdfSmrg    re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
243935c4bbdfSmrg    sed_extractcf=/$re_begincf/,/$re_endcf/p
244035c4bbdfSmrg
244135c4bbdfSmrg    # Validate tagname.
244235c4bbdfSmrg    case $tagname in
244335c4bbdfSmrg      *[!-_A-Za-z0-9,/]*)
244435c4bbdfSmrg        func_fatal_error "invalid tag name: $tagname"
244535c4bbdfSmrg        ;;
244635c4bbdfSmrg    esac
244735c4bbdfSmrg
244835c4bbdfSmrg    # Don't test for the "default" C tag, as we know it's
244935c4bbdfSmrg    # there but not specially marked.
245035c4bbdfSmrg    case $tagname in
245135c4bbdfSmrg        CC) ;;
245235c4bbdfSmrg    *)
245335c4bbdfSmrg        if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
245435c4bbdfSmrg	  taglist="$taglist $tagname"
245535c4bbdfSmrg
245635c4bbdfSmrg	  # Evaluate the configuration.  Be careful to quote the path
245735c4bbdfSmrg	  # and the sed script, to avoid splitting on whitespace, but
245835c4bbdfSmrg	  # also don't use non-portable quotes within backquotes within
245935c4bbdfSmrg	  # quotes we have to do it in 2 steps:
246035c4bbdfSmrg	  extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
246135c4bbdfSmrg	  eval "$extractedcf"
246235c4bbdfSmrg        else
246335c4bbdfSmrg	  func_error "ignoring unknown tag $tagname"
246435c4bbdfSmrg        fi
246535c4bbdfSmrg        ;;
246635c4bbdfSmrg    esac
246735c4bbdfSmrg}
246835c4bbdfSmrg
246935c4bbdfSmrg
247035c4bbdfSmrg# func_check_version_match
247135c4bbdfSmrg# ------------------------
247235c4bbdfSmrg# Ensure that we are using m4 macros, and libtool script from the same
247335c4bbdfSmrg# release of libtool.
247435c4bbdfSmrgfunc_check_version_match ()
247535c4bbdfSmrg{
247635c4bbdfSmrg    if test "$package_revision" != "$macro_revision"; then
247735c4bbdfSmrg      if test "$VERSION" != "$macro_version"; then
247835c4bbdfSmrg        if test -z "$macro_version"; then
247935c4bbdfSmrg          cat >&2 <<_LT_EOF
248035c4bbdfSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
248135c4bbdfSmrg$progname: definition of this LT_INIT comes from an older release.
248235c4bbdfSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
248335c4bbdfSmrg$progname: and run autoconf again.
248435c4bbdfSmrg_LT_EOF
248535c4bbdfSmrg        else
248635c4bbdfSmrg          cat >&2 <<_LT_EOF
248735c4bbdfSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
248835c4bbdfSmrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
248935c4bbdfSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
249035c4bbdfSmrg$progname: and run autoconf again.
249135c4bbdfSmrg_LT_EOF
249235c4bbdfSmrg        fi
249335c4bbdfSmrg      else
249435c4bbdfSmrg        cat >&2 <<_LT_EOF
249535c4bbdfSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
249635c4bbdfSmrg$progname: but the definition of this LT_INIT comes from revision $macro_revision.
249735c4bbdfSmrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision
249835c4bbdfSmrg$progname: of $PACKAGE $VERSION and run autoconf again.
249935c4bbdfSmrg_LT_EOF
250035c4bbdfSmrg      fi
250135c4bbdfSmrg
250235c4bbdfSmrg      exit $EXIT_MISMATCH
250335c4bbdfSmrg    fi
250435c4bbdfSmrg}
250535c4bbdfSmrg
250635c4bbdfSmrg
250735c4bbdfSmrg# libtool_options_prep [ARG]...
250835c4bbdfSmrg# -----------------------------
250935c4bbdfSmrg# Preparation for options parsed by libtool.
251035c4bbdfSmrglibtool_options_prep ()
251135c4bbdfSmrg{
251235c4bbdfSmrg    $debug_mode
251335c4bbdfSmrg
251435c4bbdfSmrg    # Option defaults:
251535c4bbdfSmrg    opt_config=false
251635c4bbdfSmrg    opt_dlopen=
251735c4bbdfSmrg    opt_dry_run=false
251835c4bbdfSmrg    opt_help=false
251935c4bbdfSmrg    opt_mode=
252054b5899cSmrg    opt_reorder_cache=false
252135c4bbdfSmrg    opt_preserve_dup_deps=false
252235c4bbdfSmrg    opt_quiet=false
252354b5899cSmrg    opt_finishing=true
252454b5899cSmrg    opt_warning=
252535c4bbdfSmrg
252635c4bbdfSmrg    nonopt=
252735c4bbdfSmrg    preserve_args=
252835c4bbdfSmrg
2529ed6184dfSmrg    _G_rc_lt_options_prep=:
2530ed6184dfSmrg
253135c4bbdfSmrg    # Shorthand for --mode=foo, only valid as the first argument
253235c4bbdfSmrg    case $1 in
253335c4bbdfSmrg    clean|clea|cle|cl)
253435c4bbdfSmrg      shift; set dummy --mode clean ${1+"$@"}; shift
253535c4bbdfSmrg      ;;
253635c4bbdfSmrg    compile|compil|compi|comp|com|co|c)
253735c4bbdfSmrg      shift; set dummy --mode compile ${1+"$@"}; shift
253835c4bbdfSmrg      ;;
253935c4bbdfSmrg    execute|execut|execu|exec|exe|ex|e)
254035c4bbdfSmrg      shift; set dummy --mode execute ${1+"$@"}; shift
254135c4bbdfSmrg      ;;
254235c4bbdfSmrg    finish|finis|fini|fin|fi|f)
254335c4bbdfSmrg      shift; set dummy --mode finish ${1+"$@"}; shift
254435c4bbdfSmrg      ;;
254535c4bbdfSmrg    install|instal|insta|inst|ins|in|i)
254635c4bbdfSmrg      shift; set dummy --mode install ${1+"$@"}; shift
254735c4bbdfSmrg      ;;
254835c4bbdfSmrg    link|lin|li|l)
254935c4bbdfSmrg      shift; set dummy --mode link ${1+"$@"}; shift
255035c4bbdfSmrg      ;;
255135c4bbdfSmrg    uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
255235c4bbdfSmrg      shift; set dummy --mode uninstall ${1+"$@"}; shift
255335c4bbdfSmrg      ;;
2554ed6184dfSmrg    *)
2555ed6184dfSmrg      _G_rc_lt_options_prep=false
2556ed6184dfSmrg      ;;
255735c4bbdfSmrg    esac
255835c4bbdfSmrg
2559ed6184dfSmrg    if $_G_rc_lt_options_prep; then
2560ed6184dfSmrg      # Pass back the list of options.
2561c82838c1Smrg      func_quote eval ${1+"$@"}
2562c82838c1Smrg      libtool_options_prep_result=$func_quote_result
2563ed6184dfSmrg    fi
256435c4bbdfSmrg}
256535c4bbdfSmrgfunc_add_hook func_options_prep libtool_options_prep
256635c4bbdfSmrg
256735c4bbdfSmrg
256835c4bbdfSmrg# libtool_parse_options [ARG]...
256935c4bbdfSmrg# ---------------------------------
257035c4bbdfSmrg# Provide handling for libtool specific options.
257135c4bbdfSmrglibtool_parse_options ()
257235c4bbdfSmrg{
257335c4bbdfSmrg    $debug_cmd
257435c4bbdfSmrg
2575ed6184dfSmrg    _G_rc_lt_parse_options=false
2576ed6184dfSmrg
257735c4bbdfSmrg    # Perform our own loop to consume as many options as possible in
257835c4bbdfSmrg    # each iteration.
257935c4bbdfSmrg    while test $# -gt 0; do
2580ed6184dfSmrg      _G_match_lt_parse_options=:
258135c4bbdfSmrg      _G_opt=$1
258235c4bbdfSmrg      shift
258335c4bbdfSmrg      case $_G_opt in
258435c4bbdfSmrg        --dry-run|--dryrun|-n)
258535c4bbdfSmrg                        opt_dry_run=:
258635c4bbdfSmrg                        ;;
258735c4bbdfSmrg
258835c4bbdfSmrg        --config)       func_config ;;
258935c4bbdfSmrg
259035c4bbdfSmrg        --dlopen|-dlopen)
259135c4bbdfSmrg                        opt_dlopen="${opt_dlopen+$opt_dlopen
259235c4bbdfSmrg}$1"
259335c4bbdfSmrg                        shift
259435c4bbdfSmrg                        ;;
259535c4bbdfSmrg
259635c4bbdfSmrg        --preserve-dup-deps)
259735c4bbdfSmrg                        opt_preserve_dup_deps=: ;;
259835c4bbdfSmrg
259935c4bbdfSmrg        --features)     func_features ;;
260035c4bbdfSmrg
260135c4bbdfSmrg        --finish)       set dummy --mode finish ${1+"$@"}; shift ;;
260235c4bbdfSmrg
260335c4bbdfSmrg        --help)         opt_help=: ;;
260435c4bbdfSmrg
260535c4bbdfSmrg        --help-all)     opt_help=': help-all' ;;
260635c4bbdfSmrg
260735c4bbdfSmrg        --mode)         test $# = 0 && func_missing_arg $_G_opt && break
260835c4bbdfSmrg                        opt_mode=$1
260935c4bbdfSmrg                        case $1 in
261035c4bbdfSmrg                          # Valid mode arguments:
261135c4bbdfSmrg                          clean|compile|execute|finish|install|link|relink|uninstall) ;;
261235c4bbdfSmrg
261335c4bbdfSmrg                          # Catch anything else as an error
261454b5899cSmrg                          *) func_error "invalid argument '$1' for $_G_opt"
261535c4bbdfSmrg                             exit_cmd=exit
261635c4bbdfSmrg                             ;;
261735c4bbdfSmrg                        esac
261835c4bbdfSmrg                        shift
261935c4bbdfSmrg                        ;;
262035c4bbdfSmrg
262154b5899cSmrg        --no-finish)
262254b5899cSmrg                        opt_finishing=false
262354b5899cSmrg                        func_append preserve_args " $_G_opt"
262454b5899cSmrg                        ;;
262554b5899cSmrg
262635c4bbdfSmrg        --no-silent|--no-quiet)
262735c4bbdfSmrg                        opt_quiet=false
262835c4bbdfSmrg                        func_append preserve_args " $_G_opt"
262935c4bbdfSmrg                        ;;
263035c4bbdfSmrg
263135c4bbdfSmrg        --no-warnings|--no-warning|--no-warn)
263235c4bbdfSmrg                        opt_warning=false
263335c4bbdfSmrg                        func_append preserve_args " $_G_opt"
263435c4bbdfSmrg                        ;;
263535c4bbdfSmrg
263635c4bbdfSmrg        --no-verbose)
263735c4bbdfSmrg                        opt_verbose=false
263835c4bbdfSmrg                        func_append preserve_args " $_G_opt"
263935c4bbdfSmrg                        ;;
264035c4bbdfSmrg
264154b5899cSmrg        --reorder-cache)
264254b5899cSmrg                        opt_reorder_cache=true
264354b5899cSmrg                        shared_lib_dirs=$1
264454b5899cSmrg                        if test -n "$shared_lib_dirs"; then
264554b5899cSmrg                          case $1 in
264654b5899cSmrg                            # Must begin with /:
264754b5899cSmrg                            /*) ;;
264854b5899cSmrg
264954b5899cSmrg                            # Catch anything else as an error (relative paths)
265054b5899cSmrg                            *) func_error "invalid argument '$1' for $_G_opt"
265154b5899cSmrg                               func_error "absolute paths are required for $_G_opt"
265254b5899cSmrg                               exit_cmd=exit
265354b5899cSmrg                               ;;
265454b5899cSmrg                          esac
265554b5899cSmrg                        fi
265654b5899cSmrg                        shift
265754b5899cSmrg                        ;;
265854b5899cSmrg
265935c4bbdfSmrg        --silent|--quiet)
266035c4bbdfSmrg                        opt_quiet=:
266135c4bbdfSmrg                        opt_verbose=false
266235c4bbdfSmrg                        func_append preserve_args " $_G_opt"
266335c4bbdfSmrg                        ;;
266435c4bbdfSmrg
266535c4bbdfSmrg        --tag)          test $# = 0 && func_missing_arg $_G_opt && break
266635c4bbdfSmrg                        opt_tag=$1
266735c4bbdfSmrg                        func_append preserve_args " $_G_opt $1"
266835c4bbdfSmrg                        func_enable_tag "$1"
266935c4bbdfSmrg                        shift
267035c4bbdfSmrg                        ;;
267135c4bbdfSmrg
267235c4bbdfSmrg        --verbose|-v)   opt_quiet=false
267335c4bbdfSmrg                        opt_verbose=:
267435c4bbdfSmrg                        func_append preserve_args " $_G_opt"
267535c4bbdfSmrg                        ;;
267635c4bbdfSmrg
2677ed6184dfSmrg        # An option not handled by this hook function:
2678ed6184dfSmrg        *)              set dummy "$_G_opt" ${1+"$@"} ; shift
2679ed6184dfSmrg                        _G_match_lt_parse_options=false
2680ed6184dfSmrg                        break
2681ed6184dfSmrg                        ;;
268235c4bbdfSmrg      esac
2683ed6184dfSmrg      $_G_match_lt_parse_options && _G_rc_lt_parse_options=:
268435c4bbdfSmrg    done
268535c4bbdfSmrg
2686ed6184dfSmrg    if $_G_rc_lt_parse_options; then
2687ed6184dfSmrg      # save modified positional parameters for caller
2688c82838c1Smrg      func_quote eval ${1+"$@"}
2689c82838c1Smrg      libtool_parse_options_result=$func_quote_result
2690ed6184dfSmrg    fi
269135c4bbdfSmrg}
269235c4bbdfSmrgfunc_add_hook func_parse_options libtool_parse_options
269335c4bbdfSmrg
269435c4bbdfSmrg
269554b5899cSmrg# func_warning ARG...
269654b5899cSmrg# -------------------
269754b5899cSmrg# Libtool warnings are not categorized, so override funclib.sh
269854b5899cSmrg# func_warning with this simpler definition.
269954b5899cSmrgfunc_warning ()
270054b5899cSmrg{
270154b5899cSmrg    if $opt_warning; then
270254b5899cSmrg        $debug_cmd
270354b5899cSmrg        $warning_func ${1+"$@"}
270454b5899cSmrg    fi
270554b5899cSmrg}
270654b5899cSmrg
270735c4bbdfSmrg
270835c4bbdfSmrg# libtool_validate_options [ARG]...
270935c4bbdfSmrg# ---------------------------------
271035c4bbdfSmrg# Perform any sanity checks on option settings and/or unconsumed
271135c4bbdfSmrg# arguments.
271235c4bbdfSmrglibtool_validate_options ()
271335c4bbdfSmrg{
271435c4bbdfSmrg    # save first non-option argument
271535c4bbdfSmrg    if test 0 -lt $#; then
271635c4bbdfSmrg      nonopt=$1
271735c4bbdfSmrg      shift
271835c4bbdfSmrg    fi
271935c4bbdfSmrg
272035c4bbdfSmrg    # preserve --debug
272135c4bbdfSmrg    test : = "$debug_cmd" || func_append preserve_args " --debug"
272235c4bbdfSmrg
272358cf2af7Smrg    # Keeping compiler generated duplicates in $postdeps and $predeps is not
272458cf2af7Smrg    # harmful, and is necessary in a majority of systems that use it to satisfy
272558cf2af7Smrg    # symbol dependencies.
272658cf2af7Smrg    opt_duplicate_compiler_generated_deps=:
272735c4bbdfSmrg
272835c4bbdfSmrg    $opt_help || {
272935c4bbdfSmrg      # Sanity checks first:
273035c4bbdfSmrg      func_check_version_match
273135c4bbdfSmrg
273235c4bbdfSmrg      test yes != "$build_libtool_libs" \
273335c4bbdfSmrg        && test yes != "$build_old_libs" \
273435c4bbdfSmrg        && func_fatal_configuration "not configured to build any kind of library"
273535c4bbdfSmrg
273635c4bbdfSmrg      # Darwin sucks
273735c4bbdfSmrg      eval std_shrext=\"$shrext_cmds\"
273835c4bbdfSmrg
273935c4bbdfSmrg      # Only execute mode is allowed to have -dlopen flags.
274035c4bbdfSmrg      if test -n "$opt_dlopen" && test execute != "$opt_mode"; then
274135c4bbdfSmrg        func_error "unrecognized option '-dlopen'"
274235c4bbdfSmrg        $ECHO "$help" 1>&2
274335c4bbdfSmrg        exit $EXIT_FAILURE
274435c4bbdfSmrg      fi
274535c4bbdfSmrg
274635c4bbdfSmrg      # Change the help message to a mode-specific one.
274735c4bbdfSmrg      generic_help=$help
274835c4bbdfSmrg      help="Try '$progname --help --mode=$opt_mode' for more information."
274935c4bbdfSmrg    }
275035c4bbdfSmrg
275135c4bbdfSmrg    # Pass back the unparsed argument list
2752c82838c1Smrg    func_quote eval ${1+"$@"}
2753c82838c1Smrg    libtool_validate_options_result=$func_quote_result
275435c4bbdfSmrg}
275535c4bbdfSmrgfunc_add_hook func_validate_options libtool_validate_options
275635c4bbdfSmrg
275735c4bbdfSmrg
275835c4bbdfSmrg# Process options as early as possible so that --help and --version
275935c4bbdfSmrg# can return quickly.
276035c4bbdfSmrgfunc_options ${1+"$@"}
276135c4bbdfSmrgeval set dummy "$func_options_result"; shift
276235c4bbdfSmrg
276335c4bbdfSmrg
276435c4bbdfSmrg
276535c4bbdfSmrg## ----------- ##
276635c4bbdfSmrg##    Main.    ##
276735c4bbdfSmrg## ----------- ##
276835c4bbdfSmrg
276935c4bbdfSmrgmagic='%%%MAGIC variable%%%'
277035c4bbdfSmrgmagic_exe='%%%MAGIC EXE variable%%%'
277105b261ecSmrg
27724642e01fSmrg# Global variables.
27734642e01fSmrgextracted_archives=
27744642e01fSmrgextracted_serial=0
277505b261ecSmrg
277635c4bbdfSmrg# If this variable is set in any of the actions, the command in it
277735c4bbdfSmrg# will be execed at the end.  This prevents here-documents from being
277835c4bbdfSmrg# left over by shells.
277935c4bbdfSmrgexec_cmd=
278035c4bbdfSmrg
278135c4bbdfSmrg
278235c4bbdfSmrg# A function that is used when there is no print builtin or printf.
278335c4bbdfSmrgfunc_fallback_echo ()
278435c4bbdfSmrg{
278535c4bbdfSmrg  eval 'cat <<_LTECHO_EOF
278635c4bbdfSmrg$1
278735c4bbdfSmrg_LTECHO_EOF'
278835c4bbdfSmrg}
278935c4bbdfSmrg
279035c4bbdfSmrg# func_generated_by_libtool
279135c4bbdfSmrg# True iff stdin has been generated by Libtool. This function is only
279235c4bbdfSmrg# a basic sanity check; it will hardly flush out determined imposters.
279335c4bbdfSmrgfunc_generated_by_libtool_p ()
279435c4bbdfSmrg{
279535c4bbdfSmrg  $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
279635c4bbdfSmrg}
279735c4bbdfSmrg
279835c4bbdfSmrg# func_lalib_p file
279935c4bbdfSmrg# True iff FILE is a libtool '.la' library or '.lo' object file.
280035c4bbdfSmrg# This function is only a basic sanity check; it will hardly flush out
280135c4bbdfSmrg# determined imposters.
280235c4bbdfSmrgfunc_lalib_p ()
280335c4bbdfSmrg{
280435c4bbdfSmrg    test -f "$1" &&
280535c4bbdfSmrg      $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p
280635c4bbdfSmrg}
280735c4bbdfSmrg
280835c4bbdfSmrg# func_lalib_unsafe_p file
280935c4bbdfSmrg# True iff FILE is a libtool '.la' library or '.lo' object file.
281035c4bbdfSmrg# This function implements the same check as func_lalib_p without
281135c4bbdfSmrg# resorting to external programs.  To this end, it redirects stdin and
281235c4bbdfSmrg# closes it afterwards, without saving the original file descriptor.
281335c4bbdfSmrg# As a safety measure, use it only where a negative result would be
281435c4bbdfSmrg# fatal anyway.  Works if 'file' does not exist.
281535c4bbdfSmrgfunc_lalib_unsafe_p ()
281635c4bbdfSmrg{
281735c4bbdfSmrg    lalib_p=no
281835c4bbdfSmrg    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
281935c4bbdfSmrg	for lalib_p_l in 1 2 3 4
282035c4bbdfSmrg	do
282135c4bbdfSmrg	    read lalib_p_line
282235c4bbdfSmrg	    case $lalib_p_line in
282335c4bbdfSmrg		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
282435c4bbdfSmrg	    esac
282535c4bbdfSmrg	done
282635c4bbdfSmrg	exec 0<&5 5<&-
282735c4bbdfSmrg    fi
282835c4bbdfSmrg    test yes = "$lalib_p"
282935c4bbdfSmrg}
283035c4bbdfSmrg
283135c4bbdfSmrg# func_ltwrapper_script_p file
283235c4bbdfSmrg# True iff FILE is a libtool wrapper script
283335c4bbdfSmrg# This function is only a basic sanity check; it will hardly flush out
283435c4bbdfSmrg# determined imposters.
283535c4bbdfSmrgfunc_ltwrapper_script_p ()
283635c4bbdfSmrg{
283735c4bbdfSmrg    test -f "$1" &&
283835c4bbdfSmrg      $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p
283935c4bbdfSmrg}
284035c4bbdfSmrg
284135c4bbdfSmrg# func_ltwrapper_executable_p file
284235c4bbdfSmrg# True iff FILE is a libtool wrapper executable
284335c4bbdfSmrg# This function is only a basic sanity check; it will hardly flush out
284435c4bbdfSmrg# determined imposters.
284535c4bbdfSmrgfunc_ltwrapper_executable_p ()
284635c4bbdfSmrg{
284735c4bbdfSmrg    func_ltwrapper_exec_suffix=
284835c4bbdfSmrg    case $1 in
284935c4bbdfSmrg    *.exe) ;;
285035c4bbdfSmrg    *) func_ltwrapper_exec_suffix=.exe ;;
285135c4bbdfSmrg    esac
285235c4bbdfSmrg    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
285335c4bbdfSmrg}
285435c4bbdfSmrg
285535c4bbdfSmrg# func_ltwrapper_scriptname file
285635c4bbdfSmrg# Assumes file is an ltwrapper_executable
285735c4bbdfSmrg# uses $file to determine the appropriate filename for a
285835c4bbdfSmrg# temporary ltwrapper_script.
285935c4bbdfSmrgfunc_ltwrapper_scriptname ()
286035c4bbdfSmrg{
286135c4bbdfSmrg    func_dirname_and_basename "$1" "" "."
286235c4bbdfSmrg    func_stripname '' '.exe' "$func_basename_result"
286335c4bbdfSmrg    func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper
286435c4bbdfSmrg}
286535c4bbdfSmrg
286635c4bbdfSmrg# func_ltwrapper_p file
286735c4bbdfSmrg# True iff FILE is a libtool wrapper script or wrapper executable
286835c4bbdfSmrg# This function is only a basic sanity check; it will hardly flush out
286935c4bbdfSmrg# determined imposters.
287035c4bbdfSmrgfunc_ltwrapper_p ()
287135c4bbdfSmrg{
287235c4bbdfSmrg    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
287335c4bbdfSmrg}
287435c4bbdfSmrg
287535c4bbdfSmrg
287635c4bbdfSmrg# func_execute_cmds commands fail_cmd
287735c4bbdfSmrg# Execute tilde-delimited COMMANDS.
287835c4bbdfSmrg# If FAIL_CMD is given, eval that upon failure.
287935c4bbdfSmrg# FAIL_CMD may read-access the current command in variable CMD!
288035c4bbdfSmrgfunc_execute_cmds ()
288135c4bbdfSmrg{
288235c4bbdfSmrg    $debug_cmd
288335c4bbdfSmrg
288435c4bbdfSmrg    save_ifs=$IFS; IFS='~'
288535c4bbdfSmrg    for cmd in $1; do
288635c4bbdfSmrg      IFS=$sp$nl
288735c4bbdfSmrg      eval cmd=\"$cmd\"
288835c4bbdfSmrg      IFS=$save_ifs
288935c4bbdfSmrg      func_show_eval "$cmd" "${2-:}"
289035c4bbdfSmrg    done
289135c4bbdfSmrg    IFS=$save_ifs
289235c4bbdfSmrg}
289335c4bbdfSmrg
289435c4bbdfSmrg
289535c4bbdfSmrg# func_source file
289635c4bbdfSmrg# Source FILE, adding directory component if necessary.
289735c4bbdfSmrg# Note that it is not necessary on cygwin/mingw to append a dot to
289835c4bbdfSmrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
289935c4bbdfSmrg# behavior happens only for exec(3), not for open(2)!  Also, sourcing
290035c4bbdfSmrg# 'FILE.' does not work on cygwin managed mounts.
290135c4bbdfSmrgfunc_source ()
290235c4bbdfSmrg{
290335c4bbdfSmrg    $debug_cmd
290435c4bbdfSmrg
290535c4bbdfSmrg    case $1 in
290635c4bbdfSmrg    */* | *\\*)	. "$1" ;;
290735c4bbdfSmrg    *)		. "./$1" ;;
290835c4bbdfSmrg    esac
290935c4bbdfSmrg}
291035c4bbdfSmrg
291135c4bbdfSmrg
291235c4bbdfSmrg# func_resolve_sysroot PATH
291335c4bbdfSmrg# Replace a leading = in PATH with a sysroot.  Store the result into
291435c4bbdfSmrg# func_resolve_sysroot_result
291535c4bbdfSmrgfunc_resolve_sysroot ()
291635c4bbdfSmrg{
291735c4bbdfSmrg  func_resolve_sysroot_result=$1
291835c4bbdfSmrg  case $func_resolve_sysroot_result in
291935c4bbdfSmrg  =*)
292035c4bbdfSmrg    func_stripname '=' '' "$func_resolve_sysroot_result"
292135c4bbdfSmrg    func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
292235c4bbdfSmrg    ;;
292335c4bbdfSmrg  esac
292435c4bbdfSmrg}
292535c4bbdfSmrg
292635c4bbdfSmrg# func_replace_sysroot PATH
292735c4bbdfSmrg# If PATH begins with the sysroot, replace it with = and
292835c4bbdfSmrg# store the result into func_replace_sysroot_result.
292935c4bbdfSmrgfunc_replace_sysroot ()
293035c4bbdfSmrg{
293135c4bbdfSmrg  case $lt_sysroot:$1 in
293235c4bbdfSmrg  ?*:"$lt_sysroot"*)
293335c4bbdfSmrg    func_stripname "$lt_sysroot" '' "$1"
293435c4bbdfSmrg    func_replace_sysroot_result='='$func_stripname_result
293535c4bbdfSmrg    ;;
293635c4bbdfSmrg  *)
293735c4bbdfSmrg    # Including no sysroot.
293835c4bbdfSmrg    func_replace_sysroot_result=$1
293935c4bbdfSmrg    ;;
294035c4bbdfSmrg  esac
294135c4bbdfSmrg}
294235c4bbdfSmrg
294335c4bbdfSmrg# func_infer_tag arg
294435c4bbdfSmrg# Infer tagged configuration to use if any are available and
294535c4bbdfSmrg# if one wasn't chosen via the "--tag" command line option.
294635c4bbdfSmrg# Only attempt this if the compiler in the base compile
294735c4bbdfSmrg# command doesn't match the default compiler.
294835c4bbdfSmrg# arg is usually of the form 'gcc ...'
294935c4bbdfSmrgfunc_infer_tag ()
295035c4bbdfSmrg{
295135c4bbdfSmrg    $debug_cmd
295235c4bbdfSmrg
295335c4bbdfSmrg    if test -n "$available_tags" && test -z "$tagname"; then
295435c4bbdfSmrg      CC_quoted=
295535c4bbdfSmrg      for arg in $CC; do
295635c4bbdfSmrg	func_append_quoted CC_quoted "$arg"
295735c4bbdfSmrg      done
295835c4bbdfSmrg      CC_expanded=`func_echo_all $CC`
295935c4bbdfSmrg      CC_quoted_expanded=`func_echo_all $CC_quoted`
296035c4bbdfSmrg      case $@ in
296135c4bbdfSmrg      # Blanks in the command may have been stripped by the calling shell,
296235c4bbdfSmrg      # but not from the CC environment variable when configure was run.
296335c4bbdfSmrg      " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
296435c4bbdfSmrg      " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
296535c4bbdfSmrg      # Blanks at the start of $base_compile will cause this to fail
296635c4bbdfSmrg      # if we don't check for them as well.
296735c4bbdfSmrg      *)
296835c4bbdfSmrg	for z in $available_tags; do
296935c4bbdfSmrg	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
297035c4bbdfSmrg	    # Evaluate the configuration.
297135c4bbdfSmrg	    eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
297235c4bbdfSmrg	    CC_quoted=
297335c4bbdfSmrg	    for arg in $CC; do
297435c4bbdfSmrg	      # Double-quote args containing other shell metacharacters.
297535c4bbdfSmrg	      func_append_quoted CC_quoted "$arg"
297635c4bbdfSmrg	    done
297735c4bbdfSmrg	    CC_expanded=`func_echo_all $CC`
297835c4bbdfSmrg	    CC_quoted_expanded=`func_echo_all $CC_quoted`
297935c4bbdfSmrg	    case "$@ " in
298035c4bbdfSmrg	    " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
298135c4bbdfSmrg	    " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
298235c4bbdfSmrg	      # The compiler in the base compile command matches
298335c4bbdfSmrg	      # the one in the tagged configuration.
298435c4bbdfSmrg	      # Assume this is the tagged configuration we want.
298535c4bbdfSmrg	      tagname=$z
298635c4bbdfSmrg	      break
298735c4bbdfSmrg	      ;;
298835c4bbdfSmrg	    esac
298935c4bbdfSmrg	  fi
299035c4bbdfSmrg	done
299135c4bbdfSmrg	# If $tagname still isn't set, then no tagged configuration
299235c4bbdfSmrg	# was found and let the user know that the "--tag" command
299335c4bbdfSmrg	# line option must be used.
299435c4bbdfSmrg	if test -z "$tagname"; then
299535c4bbdfSmrg	  func_echo "unable to infer tagged configuration"
299635c4bbdfSmrg	  func_fatal_error "specify a tag with '--tag'"
299735c4bbdfSmrg#	else
299835c4bbdfSmrg#	  func_verbose "using $tagname tagged configuration"
299935c4bbdfSmrg	fi
300035c4bbdfSmrg	;;
300135c4bbdfSmrg      esac
300235c4bbdfSmrg    fi
300335c4bbdfSmrg}
300435c4bbdfSmrg
3005475c125cSmrg
30064642e01fSmrg
300735c4bbdfSmrg# func_write_libtool_object output_name pic_name nonpic_name
300835c4bbdfSmrg# Create a libtool object file (analogous to a ".la" file),
300935c4bbdfSmrg# but don't create it if we're doing a dry run.
301035c4bbdfSmrgfunc_write_libtool_object ()
30114642e01fSmrg{
301235c4bbdfSmrg    write_libobj=$1
301335c4bbdfSmrg    if test yes = "$build_libtool_libs"; then
301435c4bbdfSmrg      write_lobj=\'$2\'
301535c4bbdfSmrg    else
301635c4bbdfSmrg      write_lobj=none
301735c4bbdfSmrg    fi
301805b261ecSmrg
301935c4bbdfSmrg    if test yes = "$build_old_libs"; then
302035c4bbdfSmrg      write_oldobj=\'$3\'
302135c4bbdfSmrg    else
302235c4bbdfSmrg      write_oldobj=none
302335c4bbdfSmrg    fi
302405b261ecSmrg
302535c4bbdfSmrg    $opt_dry_run || {
302635c4bbdfSmrg      cat >${write_libobj}T <<EOF
302735c4bbdfSmrg# $write_libobj - a libtool object file
302835c4bbdfSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
302935c4bbdfSmrg#
303035c4bbdfSmrg# Please DO NOT delete this file!
303135c4bbdfSmrg# It is necessary for linking the library.
30324642e01fSmrg
303335c4bbdfSmrg# Name of the PIC object.
303435c4bbdfSmrgpic_object=$write_lobj
303505b261ecSmrg
303635c4bbdfSmrg# Name of the non-PIC object
303735c4bbdfSmrgnon_pic_object=$write_oldobj
303805b261ecSmrg
303935c4bbdfSmrgEOF
304035c4bbdfSmrg      $MV "${write_libobj}T" "$write_libobj"
304135c4bbdfSmrg    }
30424642e01fSmrg}
304305b261ecSmrg
304435c4bbdfSmrg
304535c4bbdfSmrg##################################################
304635c4bbdfSmrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
304735c4bbdfSmrg##################################################
304835c4bbdfSmrg
304935c4bbdfSmrg# func_convert_core_file_wine_to_w32 ARG
305035c4bbdfSmrg# Helper function used by file name conversion functions when $build is *nix,
305154b5899cSmrg# and $host is mingw, windows, cygwin, or some other w32 environment. Relies on a
305235c4bbdfSmrg# correctly configured wine environment available, with the winepath program
305335c4bbdfSmrg# in $build's $PATH.
305435c4bbdfSmrg#
305535c4bbdfSmrg# ARG is the $build file name to be converted to w32 format.
305635c4bbdfSmrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will
305735c4bbdfSmrg# be empty on error (or when ARG is empty)
305835c4bbdfSmrgfunc_convert_core_file_wine_to_w32 ()
30594642e01fSmrg{
306035c4bbdfSmrg  $debug_cmd
306135c4bbdfSmrg
306235c4bbdfSmrg  func_convert_core_file_wine_to_w32_result=$1
306335c4bbdfSmrg  if test -n "$1"; then
306435c4bbdfSmrg    # Unfortunately, winepath does not exit with a non-zero error code, so we
306535c4bbdfSmrg    # are forced to check the contents of stdout. On the other hand, if the
306635c4bbdfSmrg    # command is not found, the shell will set an exit code of 127 and print
306735c4bbdfSmrg    # *an error message* to stdout. So we must check for both error code of
306835c4bbdfSmrg    # zero AND non-empty stdout, which explains the odd construction:
306935c4bbdfSmrg    func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
307035c4bbdfSmrg    if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then
307135c4bbdfSmrg      func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
307235c4bbdfSmrg        $SED -e "$sed_naive_backslashify"`
307305b261ecSmrg    else
307435c4bbdfSmrg      func_convert_core_file_wine_to_w32_result=
307505b261ecSmrg    fi
307635c4bbdfSmrg  fi
307735c4bbdfSmrg}
307835c4bbdfSmrg# end: func_convert_core_file_wine_to_w32
30794642e01fSmrg
308035c4bbdfSmrg
308135c4bbdfSmrg# func_convert_core_path_wine_to_w32 ARG
308235c4bbdfSmrg# Helper function used by path conversion functions when $build is *nix, and
308354b5899cSmrg# $host is mingw, windows, cygwin, or some other w32 environment. Relies on a
308454b5899cSmrg# correctly configured wine environment available, with the winepath program
308554b5899cSmrg# in $build's $PATH. Assumes ARG has no leading or trailing path separator
308654b5899cSmrg# characters.
308735c4bbdfSmrg#
308835c4bbdfSmrg# ARG is path to be converted from $build format to win32.
308935c4bbdfSmrg# Result is available in $func_convert_core_path_wine_to_w32_result.
309035c4bbdfSmrg# Unconvertible file (directory) names in ARG are skipped; if no directory names
309135c4bbdfSmrg# are convertible, then the result may be empty.
309235c4bbdfSmrgfunc_convert_core_path_wine_to_w32 ()
309335c4bbdfSmrg{
309435c4bbdfSmrg  $debug_cmd
309535c4bbdfSmrg
309635c4bbdfSmrg  # unfortunately, winepath doesn't convert paths, only file names
309735c4bbdfSmrg  func_convert_core_path_wine_to_w32_result=
309835c4bbdfSmrg  if test -n "$1"; then
309935c4bbdfSmrg    oldIFS=$IFS
310035c4bbdfSmrg    IFS=:
310135c4bbdfSmrg    for func_convert_core_path_wine_to_w32_f in $1; do
310235c4bbdfSmrg      IFS=$oldIFS
310335c4bbdfSmrg      func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
310435c4bbdfSmrg      if test -n "$func_convert_core_file_wine_to_w32_result"; then
310535c4bbdfSmrg        if test -z "$func_convert_core_path_wine_to_w32_result"; then
310635c4bbdfSmrg          func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result
310735c4bbdfSmrg        else
310835c4bbdfSmrg          func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
310935c4bbdfSmrg        fi
311035c4bbdfSmrg      fi
311135c4bbdfSmrg    done
311235c4bbdfSmrg    IFS=$oldIFS
311335c4bbdfSmrg  fi
31144642e01fSmrg}
311535c4bbdfSmrg# end: func_convert_core_path_wine_to_w32
311635c4bbdfSmrg
311735c4bbdfSmrg
311835c4bbdfSmrg# func_cygpath ARGS...
311935c4bbdfSmrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
312035c4bbdfSmrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
312135c4bbdfSmrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
312235c4bbdfSmrg# (2), returns the Cygwin file name or path in func_cygpath_result (input
312335c4bbdfSmrg# file name or path is assumed to be in w32 format, as previously converted
312435c4bbdfSmrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name
312535c4bbdfSmrg# or path in func_cygpath_result (input file name or path is assumed to be in
312635c4bbdfSmrg# Cygwin format). Returns an empty string on error.
312735c4bbdfSmrg#
312835c4bbdfSmrg# ARGS are passed to cygpath, with the last one being the file name or path to
312935c4bbdfSmrg# be converted.
313035c4bbdfSmrg#
313135c4bbdfSmrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
313235c4bbdfSmrg# environment variable; do not put it in $PATH.
313335c4bbdfSmrgfunc_cygpath ()
313435c4bbdfSmrg{
313535c4bbdfSmrg  $debug_cmd
313605b261ecSmrg
313735c4bbdfSmrg  if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
313835c4bbdfSmrg    func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
313935c4bbdfSmrg    if test "$?" -ne 0; then
314035c4bbdfSmrg      # on failure, ensure result is empty
314135c4bbdfSmrg      func_cygpath_result=
314235c4bbdfSmrg    fi
314335c4bbdfSmrg  else
314435c4bbdfSmrg    func_cygpath_result=
314535c4bbdfSmrg    func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'"
314635c4bbdfSmrg  fi
314735c4bbdfSmrg}
314835c4bbdfSmrg#end: func_cygpath
314935c4bbdfSmrg
315035c4bbdfSmrg
315135c4bbdfSmrg# func_convert_core_msys_to_w32 ARG
315235c4bbdfSmrg# Convert file name or path ARG from MSYS format to w32 format.  Return
315335c4bbdfSmrg# result in func_convert_core_msys_to_w32_result.
315435c4bbdfSmrgfunc_convert_core_msys_to_w32 ()
31554642e01fSmrg{
315635c4bbdfSmrg  $debug_cmd
315705b261ecSmrg
315835c4bbdfSmrg  # awkward: cmd appends spaces to result
315935c4bbdfSmrg  func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
316035c4bbdfSmrg    $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"`
316135c4bbdfSmrg}
316235c4bbdfSmrg#end: func_convert_core_msys_to_w32
316305b261ecSmrg
316405b261ecSmrg
316535c4bbdfSmrg# func_convert_file_check ARG1 ARG2
316635c4bbdfSmrg# Verify that ARG1 (a file name in $build format) was converted to $host
316735c4bbdfSmrg# format in ARG2. Otherwise, emit an error message, but continue (resetting
316835c4bbdfSmrg# func_to_host_file_result to ARG1).
316935c4bbdfSmrgfunc_convert_file_check ()
317035c4bbdfSmrg{
317135c4bbdfSmrg  $debug_cmd
317235c4bbdfSmrg
317335c4bbdfSmrg  if test -z "$2" && test -n "$1"; then
317435c4bbdfSmrg    func_error "Could not determine host file name corresponding to"
317535c4bbdfSmrg    func_error "  '$1'"
317635c4bbdfSmrg    func_error "Continuing, but uninstalled executables may not work."
317735c4bbdfSmrg    # Fallback:
317835c4bbdfSmrg    func_to_host_file_result=$1
317935c4bbdfSmrg  fi
31804642e01fSmrg}
318135c4bbdfSmrg# end func_convert_file_check
31824642e01fSmrg
318335c4bbdfSmrg
318435c4bbdfSmrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
318535c4bbdfSmrg# Verify that FROM_PATH (a path in $build format) was converted to $host
318635c4bbdfSmrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting
318735c4bbdfSmrg# func_to_host_file_result to a simplistic fallback value (see below).
318835c4bbdfSmrgfunc_convert_path_check ()
31894642e01fSmrg{
319035c4bbdfSmrg  $debug_cmd
319135c4bbdfSmrg
319235c4bbdfSmrg  if test -z "$4" && test -n "$3"; then
319335c4bbdfSmrg    func_error "Could not determine the host path corresponding to"
319435c4bbdfSmrg    func_error "  '$3'"
319535c4bbdfSmrg    func_error "Continuing, but uninstalled executables may not work."
319635c4bbdfSmrg    # Fallback.  This is a deliberately simplistic "conversion" and
319735c4bbdfSmrg    # should not be "improved".  See libtool.info.
319835c4bbdfSmrg    if test "x$1" != "x$2"; then
319935c4bbdfSmrg      lt_replace_pathsep_chars="s|$1|$2|g"
320035c4bbdfSmrg      func_to_host_path_result=`echo "$3" |
320135c4bbdfSmrg        $SED -e "$lt_replace_pathsep_chars"`
320235c4bbdfSmrg    else
320335c4bbdfSmrg      func_to_host_path_result=$3
320435c4bbdfSmrg    fi
320535c4bbdfSmrg  fi
320635c4bbdfSmrg}
320735c4bbdfSmrg# end func_convert_path_check
32086747b715Smrg
320935c4bbdfSmrg
321035c4bbdfSmrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
321135c4bbdfSmrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
321235c4bbdfSmrg# and appending REPL if ORIG matches BACKPAT.
321335c4bbdfSmrgfunc_convert_path_front_back_pathsep ()
321435c4bbdfSmrg{
321535c4bbdfSmrg  $debug_cmd
321635c4bbdfSmrg
321735c4bbdfSmrg  case $4 in
321835c4bbdfSmrg  $1 ) func_to_host_path_result=$3$func_to_host_path_result
3219475c125cSmrg    ;;
322035c4bbdfSmrg  esac
322135c4bbdfSmrg  case $4 in
322235c4bbdfSmrg  $2 ) func_append func_to_host_path_result "$3"
3223475c125cSmrg    ;;
3224475c125cSmrg  esac
322535c4bbdfSmrg}
322635c4bbdfSmrg# end func_convert_path_front_back_pathsep
32276747b715Smrg
3228475c125cSmrg
322954b5899cSmrg# func_convert_delimited_path PATH ORIG_DELIMITER NEW_DELIMITER
323054b5899cSmrg# Replaces a delimiter for a given path.
323154b5899cSmrgfunc_convert_delimited_path ()
323254b5899cSmrg{
323354b5899cSmrg	converted_path=`$ECHO "$1" | $SED "s#$2#$3#g"`
323454b5899cSmrg}
323554b5899cSmrg# end func_convert_delimited_path
323654b5899cSmrg
323754b5899cSmrg
323835c4bbdfSmrg##################################################
323935c4bbdfSmrg# $build to $host FILE NAME CONVERSION FUNCTIONS #
324035c4bbdfSmrg##################################################
324135c4bbdfSmrg# invoked via '$to_host_file_cmd ARG'
324235c4bbdfSmrg#
324335c4bbdfSmrg# In each case, ARG is the path to be converted from $build to $host format.
324435c4bbdfSmrg# Result will be available in $func_to_host_file_result.
32454642e01fSmrg
32464642e01fSmrg
324735c4bbdfSmrg# func_to_host_file ARG
324835c4bbdfSmrg# Converts the file name ARG from $build format to $host format. Return result
324935c4bbdfSmrg# in func_to_host_file_result.
325035c4bbdfSmrgfunc_to_host_file ()
325135c4bbdfSmrg{
325235c4bbdfSmrg  $debug_cmd
325335c4bbdfSmrg
325435c4bbdfSmrg  $to_host_file_cmd "$1"
325535c4bbdfSmrg}
325635c4bbdfSmrg# end func_to_host_file
325735c4bbdfSmrg
325835c4bbdfSmrg
325935c4bbdfSmrg# func_to_tool_file ARG LAZY
326035c4bbdfSmrg# converts the file name ARG from $build format to toolchain format. Return
326135c4bbdfSmrg# result in func_to_tool_file_result.  If the conversion in use is listed
326235c4bbdfSmrg# in (the comma separated) LAZY, no conversion takes place.
326335c4bbdfSmrgfunc_to_tool_file ()
326435c4bbdfSmrg{
326535c4bbdfSmrg  $debug_cmd
326635c4bbdfSmrg
326735c4bbdfSmrg  case ,$2, in
326835c4bbdfSmrg    *,"$to_tool_file_cmd",*)
326935c4bbdfSmrg      func_to_tool_file_result=$1
327005b261ecSmrg      ;;
327105b261ecSmrg    *)
327235c4bbdfSmrg      $to_tool_file_cmd "$1"
327335c4bbdfSmrg      func_to_tool_file_result=$func_to_host_file_result
32744642e01fSmrg      ;;
32754642e01fSmrg  esac
327635c4bbdfSmrg}
327735c4bbdfSmrg# end func_to_tool_file
327805b261ecSmrg
327935c4bbdfSmrg
328035c4bbdfSmrg# func_convert_file_noop ARG
328135c4bbdfSmrg# Copy ARG to func_to_host_file_result.
328235c4bbdfSmrgfunc_convert_file_noop ()
328335c4bbdfSmrg{
328435c4bbdfSmrg  func_to_host_file_result=$1
3285475c125cSmrg}
328635c4bbdfSmrg# end func_convert_file_noop
32874642e01fSmrg
328835c4bbdfSmrg
328935c4bbdfSmrg# func_convert_file_msys_to_w32 ARG
329035c4bbdfSmrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
329135c4bbdfSmrg# conversion to w32 is not available inside the cwrapper.  Returns result in
329235c4bbdfSmrg# func_to_host_file_result.
329335c4bbdfSmrgfunc_convert_file_msys_to_w32 ()
3294475c125cSmrg{
329535c4bbdfSmrg  $debug_cmd
32964642e01fSmrg
329735c4bbdfSmrg  func_to_host_file_result=$1
329835c4bbdfSmrg  if test -n "$1"; then
329935c4bbdfSmrg    func_convert_core_msys_to_w32 "$1"
330035c4bbdfSmrg    func_to_host_file_result=$func_convert_core_msys_to_w32_result
3301475c125cSmrg  fi
330235c4bbdfSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
3303475c125cSmrg}
330435c4bbdfSmrg# end func_convert_file_msys_to_w32
33054642e01fSmrg
330605b261ecSmrg
330735c4bbdfSmrg# func_convert_file_cygwin_to_w32 ARG
330835c4bbdfSmrg# Convert file name ARG from Cygwin to w32 format.  Returns result in
330935c4bbdfSmrg# func_to_host_file_result.
331035c4bbdfSmrgfunc_convert_file_cygwin_to_w32 ()
331135c4bbdfSmrg{
331235c4bbdfSmrg  $debug_cmd
33134642e01fSmrg
331435c4bbdfSmrg  func_to_host_file_result=$1
331535c4bbdfSmrg  if test -n "$1"; then
331635c4bbdfSmrg    # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
331735c4bbdfSmrg    # LT_CYGPATH in this case.
331835c4bbdfSmrg    func_to_host_file_result=`cygpath -m "$1"`
3319475c125cSmrg  fi
332035c4bbdfSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
332135c4bbdfSmrg}
332235c4bbdfSmrg# end func_convert_file_cygwin_to_w32
33234642e01fSmrg
3324475c125cSmrg
332535c4bbdfSmrg# func_convert_file_nix_to_w32 ARG
332635c4bbdfSmrg# Convert file name ARG from *nix to w32 format.  Requires a wine environment
332735c4bbdfSmrg# and a working winepath. Returns result in func_to_host_file_result.
332835c4bbdfSmrgfunc_convert_file_nix_to_w32 ()
332935c4bbdfSmrg{
333035c4bbdfSmrg  $debug_cmd
3331475c125cSmrg
333235c4bbdfSmrg  func_to_host_file_result=$1
333335c4bbdfSmrg  if test -n "$1"; then
333435c4bbdfSmrg    func_convert_core_file_wine_to_w32 "$1"
333535c4bbdfSmrg    func_to_host_file_result=$func_convert_core_file_wine_to_w32_result
3336475c125cSmrg  fi
333735c4bbdfSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
3338475c125cSmrg}
333935c4bbdfSmrg# end func_convert_file_nix_to_w32
334005b261ecSmrg
334105b261ecSmrg
334235c4bbdfSmrg# func_convert_file_msys_to_cygwin ARG
334335c4bbdfSmrg# Convert file name ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
334435c4bbdfSmrg# Returns result in func_to_host_file_result.
334535c4bbdfSmrgfunc_convert_file_msys_to_cygwin ()
33464642e01fSmrg{
334735c4bbdfSmrg  $debug_cmd
334805b261ecSmrg
334935c4bbdfSmrg  func_to_host_file_result=$1
335035c4bbdfSmrg  if test -n "$1"; then
335135c4bbdfSmrg    func_convert_core_msys_to_w32 "$1"
335235c4bbdfSmrg    func_cygpath -u "$func_convert_core_msys_to_w32_result"
335335c4bbdfSmrg    func_to_host_file_result=$func_cygpath_result
335435c4bbdfSmrg  fi
335535c4bbdfSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
33564642e01fSmrg}
335735c4bbdfSmrg# end func_convert_file_msys_to_cygwin
335805b261ecSmrg
335905b261ecSmrg
336035c4bbdfSmrg# func_convert_file_nix_to_cygwin ARG
336135c4bbdfSmrg# Convert file name ARG from *nix to Cygwin format.  Requires Cygwin installed
336235c4bbdfSmrg# in a wine environment, working winepath, and LT_CYGPATH set.  Returns result
336335c4bbdfSmrg# in func_to_host_file_result.
336435c4bbdfSmrgfunc_convert_file_nix_to_cygwin ()
33654642e01fSmrg{
336635c4bbdfSmrg  $debug_cmd
336735c4bbdfSmrg
336835c4bbdfSmrg  func_to_host_file_result=$1
336935c4bbdfSmrg  if test -n "$1"; then
337035c4bbdfSmrg    # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
337135c4bbdfSmrg    func_convert_core_file_wine_to_w32 "$1"
337235c4bbdfSmrg    func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
337335c4bbdfSmrg    func_to_host_file_result=$func_cygpath_result
337435c4bbdfSmrg  fi
337535c4bbdfSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
33764642e01fSmrg}
337735c4bbdfSmrg# end func_convert_file_nix_to_cygwin
337805b261ecSmrg
337935c4bbdfSmrg
338035c4bbdfSmrg#############################################
338135c4bbdfSmrg# $build to $host PATH CONVERSION FUNCTIONS #
338235c4bbdfSmrg#############################################
338335c4bbdfSmrg# invoked via '$to_host_path_cmd ARG'
338435c4bbdfSmrg#
338535c4bbdfSmrg# In each case, ARG is the path to be converted from $build to $host format.
338635c4bbdfSmrg# The result will be available in $func_to_host_path_result.
338735c4bbdfSmrg#
338835c4bbdfSmrg# Path separators are also converted from $build format to $host format.  If
338935c4bbdfSmrg# ARG begins or ends with a path separator character, it is preserved (but
339035c4bbdfSmrg# converted to $host format) on output.
339135c4bbdfSmrg#
339235c4bbdfSmrg# All path conversion functions are named using the following convention:
339335c4bbdfSmrg#   file name conversion function    : func_convert_file_X_to_Y ()
339435c4bbdfSmrg#   path conversion function         : func_convert_path_X_to_Y ()
339535c4bbdfSmrg# where, for any given $build/$host combination the 'X_to_Y' value is the
339635c4bbdfSmrg# same.  If conversion functions are added for new $build/$host combinations,
339735c4bbdfSmrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd
339835c4bbdfSmrg# will break.
339935c4bbdfSmrg
340035c4bbdfSmrg
340135c4bbdfSmrg# func_init_to_host_path_cmd
340235c4bbdfSmrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the
340335c4bbdfSmrg# appropriate value, based on the value of $to_host_file_cmd.
340435c4bbdfSmrgto_host_path_cmd=
340535c4bbdfSmrgfunc_init_to_host_path_cmd ()
34064642e01fSmrg{
340735c4bbdfSmrg  $debug_cmd
340835c4bbdfSmrg
340935c4bbdfSmrg  if test -z "$to_host_path_cmd"; then
341035c4bbdfSmrg    func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
341135c4bbdfSmrg    to_host_path_cmd=func_convert_path_$func_stripname_result
341235c4bbdfSmrg  fi
34134642e01fSmrg}
34144642e01fSmrg
341535c4bbdfSmrg
341635c4bbdfSmrg# func_to_host_path ARG
341735c4bbdfSmrg# Converts the path ARG from $build format to $host format. Return result
341835c4bbdfSmrg# in func_to_host_path_result.
341935c4bbdfSmrgfunc_to_host_path ()
34204642e01fSmrg{
342135c4bbdfSmrg  $debug_cmd
342235c4bbdfSmrg
342335c4bbdfSmrg  func_init_to_host_path_cmd
342435c4bbdfSmrg  $to_host_path_cmd "$1"
34254642e01fSmrg}
342635c4bbdfSmrg# end func_to_host_path
34274642e01fSmrg
34284642e01fSmrg
342935c4bbdfSmrg# func_convert_path_noop ARG
343035c4bbdfSmrg# Copy ARG to func_to_host_path_result.
343135c4bbdfSmrgfunc_convert_path_noop ()
34324642e01fSmrg{
343335c4bbdfSmrg  func_to_host_path_result=$1
34344642e01fSmrg}
343535c4bbdfSmrg# end func_convert_path_noop
34364642e01fSmrg
34374642e01fSmrg
343835c4bbdfSmrg# func_convert_path_msys_to_w32 ARG
343935c4bbdfSmrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
344035c4bbdfSmrg# conversion to w32 is not available inside the cwrapper.  Returns result in
344135c4bbdfSmrg# func_to_host_path_result.
344235c4bbdfSmrgfunc_convert_path_msys_to_w32 ()
34434642e01fSmrg{
344435c4bbdfSmrg  $debug_cmd
344535c4bbdfSmrg
344635c4bbdfSmrg  func_to_host_path_result=$1
344735c4bbdfSmrg  if test -n "$1"; then
344835c4bbdfSmrg    # Remove leading and trailing path separator characters from ARG.  MSYS
344935c4bbdfSmrg    # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
345035c4bbdfSmrg    # and winepath ignores them completely.
345135c4bbdfSmrg    func_stripname : : "$1"
345235c4bbdfSmrg    func_to_host_path_tmp1=$func_stripname_result
345335c4bbdfSmrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
345435c4bbdfSmrg    func_to_host_path_result=$func_convert_core_msys_to_w32_result
345535c4bbdfSmrg    func_convert_path_check : ";" \
345635c4bbdfSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
345735c4bbdfSmrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
345835c4bbdfSmrg  fi
34594642e01fSmrg}
346035c4bbdfSmrg# end func_convert_path_msys_to_w32
34614642e01fSmrg
34624642e01fSmrg
346335c4bbdfSmrg# func_convert_path_cygwin_to_w32 ARG
346435c4bbdfSmrg# Convert path ARG from Cygwin to w32 format.  Returns result in
346535c4bbdfSmrg# func_to_host_file_result.
346635c4bbdfSmrgfunc_convert_path_cygwin_to_w32 ()
34674642e01fSmrg{
346835c4bbdfSmrg  $debug_cmd
346935c4bbdfSmrg
347035c4bbdfSmrg  func_to_host_path_result=$1
347135c4bbdfSmrg  if test -n "$1"; then
347235c4bbdfSmrg    # See func_convert_path_msys_to_w32:
347335c4bbdfSmrg    func_stripname : : "$1"
347435c4bbdfSmrg    func_to_host_path_tmp1=$func_stripname_result
347535c4bbdfSmrg    func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
347635c4bbdfSmrg    func_convert_path_check : ";" \
347735c4bbdfSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
347835c4bbdfSmrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
347935c4bbdfSmrg  fi
34806747b715Smrg}
348135c4bbdfSmrg# end func_convert_path_cygwin_to_w32
34826747b715Smrg
34836747b715Smrg
348435c4bbdfSmrg# func_convert_path_nix_to_w32 ARG
348535c4bbdfSmrg# Convert path ARG from *nix to w32 format.  Requires a wine environment and
348635c4bbdfSmrg# a working winepath.  Returns result in func_to_host_file_result.
348735c4bbdfSmrgfunc_convert_path_nix_to_w32 ()
348835c4bbdfSmrg{
348935c4bbdfSmrg  $debug_cmd
34906747b715Smrg
349135c4bbdfSmrg  func_to_host_path_result=$1
349235c4bbdfSmrg  if test -n "$1"; then
349335c4bbdfSmrg    # See func_convert_path_msys_to_w32:
349435c4bbdfSmrg    func_stripname : : "$1"
349535c4bbdfSmrg    func_to_host_path_tmp1=$func_stripname_result
349635c4bbdfSmrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
349735c4bbdfSmrg    func_to_host_path_result=$func_convert_core_path_wine_to_w32_result
349835c4bbdfSmrg    func_convert_path_check : ";" \
349935c4bbdfSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
350035c4bbdfSmrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
350135c4bbdfSmrg  fi
350235c4bbdfSmrg}
350335c4bbdfSmrg# end func_convert_path_nix_to_w32
350435c4bbdfSmrg
350535c4bbdfSmrg
350635c4bbdfSmrg# func_convert_path_msys_to_cygwin ARG
350735c4bbdfSmrg# Convert path ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
350835c4bbdfSmrg# Returns result in func_to_host_file_result.
350935c4bbdfSmrgfunc_convert_path_msys_to_cygwin ()
35106747b715Smrg{
351135c4bbdfSmrg  $debug_cmd
35126747b715Smrg
351335c4bbdfSmrg  func_to_host_path_result=$1
351435c4bbdfSmrg  if test -n "$1"; then
351535c4bbdfSmrg    # See func_convert_path_msys_to_w32:
351635c4bbdfSmrg    func_stripname : : "$1"
351735c4bbdfSmrg    func_to_host_path_tmp1=$func_stripname_result
351835c4bbdfSmrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
351935c4bbdfSmrg    func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
352035c4bbdfSmrg    func_to_host_path_result=$func_cygpath_result
352135c4bbdfSmrg    func_convert_path_check : : \
352235c4bbdfSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
352335c4bbdfSmrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
352435c4bbdfSmrg  fi
352535c4bbdfSmrg}
352635c4bbdfSmrg# end func_convert_path_msys_to_cygwin
35276747b715Smrg
35286747b715Smrg
352935c4bbdfSmrg# func_convert_path_nix_to_cygwin ARG
353035c4bbdfSmrg# Convert path ARG from *nix to Cygwin format.  Requires Cygwin installed in a
353135c4bbdfSmrg# a wine environment, working winepath, and LT_CYGPATH set.  Returns result in
353235c4bbdfSmrg# func_to_host_file_result.
353335c4bbdfSmrgfunc_convert_path_nix_to_cygwin ()
353435c4bbdfSmrg{
353535c4bbdfSmrg  $debug_cmd
35366747b715Smrg
353735c4bbdfSmrg  func_to_host_path_result=$1
353835c4bbdfSmrg  if test -n "$1"; then
353935c4bbdfSmrg    # Remove leading and trailing path separator characters from
354035c4bbdfSmrg    # ARG. msys behavior is inconsistent here, cygpath turns them
354135c4bbdfSmrg    # into '.;' and ';.', and winepath ignores them completely.
354235c4bbdfSmrg    func_stripname : : "$1"
354335c4bbdfSmrg    func_to_host_path_tmp1=$func_stripname_result
354435c4bbdfSmrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
354535c4bbdfSmrg    func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
354635c4bbdfSmrg    func_to_host_path_result=$func_cygpath_result
354735c4bbdfSmrg    func_convert_path_check : : \
354835c4bbdfSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
354935c4bbdfSmrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
355035c4bbdfSmrg  fi
355135c4bbdfSmrg}
355235c4bbdfSmrg# end func_convert_path_nix_to_cygwin
35536747b715Smrg
355435c4bbdfSmrg
355535c4bbdfSmrg# func_dll_def_p FILE
355635c4bbdfSmrg# True iff FILE is a Windows DLL '.def' file.
355735c4bbdfSmrg# Keep in sync with _LT_DLL_DEF_P in libtool.m4
355835c4bbdfSmrgfunc_dll_def_p ()
355935c4bbdfSmrg{
356035c4bbdfSmrg  $debug_cmd
356135c4bbdfSmrg
356235c4bbdfSmrg  func_dll_def_p_tmp=`$SED -n \
356335c4bbdfSmrg    -e 's/^[	 ]*//' \
356435c4bbdfSmrg    -e '/^\(;.*\)*$/d' \
356535c4bbdfSmrg    -e 's/^\(EXPORTS\|LIBRARY\)\([	 ].*\)*$/DEF/p' \
356635c4bbdfSmrg    -e q \
356735c4bbdfSmrg    "$1"`
356835c4bbdfSmrg  test DEF = "$func_dll_def_p_tmp"
35696747b715Smrg}
35706747b715Smrg
357135c4bbdfSmrg
357254b5899cSmrg# func_reorder_shared_lib_cache DIRS
357354b5899cSmrg# Reorder the shared library cache by unconfiguring previous shared library cache
357454b5899cSmrg# and configuring preferred search directories before previous search directories.
357554b5899cSmrg# Previous shared library cache: /usr/lib /usr/local/lib
357654b5899cSmrg# Preferred search directories: /tmp/testing
357754b5899cSmrg# Reordered shared library cache: /tmp/testing /usr/lib /usr/local/lib
357854b5899cSmrgfunc_reorder_shared_lib_cache ()
357954b5899cSmrg{
358054b5899cSmrg	$debug_cmd
358154b5899cSmrg
358254b5899cSmrg	case $host_os in
358354b5899cSmrg	  openbsd*)
358454b5899cSmrg	    get_search_directories=`PATH="$PATH:/sbin" ldconfig -r | $GREP "search directories" | $SED "s#.*search directories:\ ##g"`
358554b5899cSmrg	    func_convert_delimited_path "$get_search_directories" ':' '\ '
358654b5899cSmrg	    save_search_directories=$converted_path
358754b5899cSmrg	    func_convert_delimited_path "$1" ':' '\ '
358854b5899cSmrg
358954b5899cSmrg	    # Ensure directories exist
359054b5899cSmrg	    for dir in $converted_path; do
359154b5899cSmrg	      # Ensure each directory is an absolute path
359254b5899cSmrg	      case $dir in
359354b5899cSmrg	        /*) ;;
359454b5899cSmrg	        *) func_error "Directory '$dir' is not an absolute path"
359554b5899cSmrg	           exit $EXIT_FAILURE ;;
359654b5899cSmrg	      esac
359754b5899cSmrg	      # Ensure no trailing slashes
359854b5899cSmrg	      func_stripname '' '/' "$dir"
359954b5899cSmrg	      dir=$func_stripname_result
360054b5899cSmrg	      if test -d "$dir"; then
360154b5899cSmrg	        if test -n "$preferred_search_directories"; then
360254b5899cSmrg	          preferred_search_directories="$preferred_search_directories $dir"
360354b5899cSmrg	        else
360454b5899cSmrg	          preferred_search_directories=$dir
360554b5899cSmrg	        fi
360654b5899cSmrg	      else
360754b5899cSmrg	        func_error "Directory '$dir' does not exist"
360854b5899cSmrg	        exit $EXIT_FAILURE
360954b5899cSmrg	      fi
361054b5899cSmrg	    done
361154b5899cSmrg
361254b5899cSmrg	    PATH="$PATH:/sbin" ldconfig -U $save_search_directories
361354b5899cSmrg	    PATH="$PATH:/sbin" ldconfig -m $preferred_search_directories $save_search_directories
361454b5899cSmrg	    get_search_directories=`PATH="$PATH:/sbin" ldconfig -r | $GREP "search directories" | $SED "s#.*search directories:\ ##g"`
361554b5899cSmrg	    func_convert_delimited_path "$get_search_directories" ':' '\ '
361654b5899cSmrg	    reordered_search_directories=$converted_path
361754b5899cSmrg
361854b5899cSmrg	    $ECHO "Original: $save_search_directories"
361954b5899cSmrg	    $ECHO "Reordered: $reordered_search_directories"
362054b5899cSmrg	    exit $EXIT_SUCCESS
362154b5899cSmrg	  ;;
362254b5899cSmrg	  *)
362354b5899cSmrg	    func_error "--reorder-cache is not supported for host_os=$host_os."
362454b5899cSmrg	    exit $EXIT_FAILURE
362554b5899cSmrg	  ;;
362654b5899cSmrg	esac
362754b5899cSmrg}
362854b5899cSmrg# end func_reorder_shared_lib_cache
362954b5899cSmrg
363054b5899cSmrg
36314642e01fSmrg# func_mode_compile arg...
36324642e01fSmrgfunc_mode_compile ()
36334642e01fSmrg{
363435c4bbdfSmrg    $debug_cmd
363535c4bbdfSmrg
36364642e01fSmrg    # Get the compilation command and the source file.
36374642e01fSmrg    base_compile=
363835c4bbdfSmrg    srcfile=$nonopt  #  always keep a non-empty value in "srcfile"
36394642e01fSmrg    suppress_opt=yes
36404642e01fSmrg    suppress_output=
36414642e01fSmrg    arg_mode=normal
36424642e01fSmrg    libobj=
36434642e01fSmrg    later=
36444642e01fSmrg    pie_flag=
36454642e01fSmrg
36464642e01fSmrg    for arg
36474642e01fSmrg    do
36484642e01fSmrg      case $arg_mode in
36494642e01fSmrg      arg  )
36504642e01fSmrg	# do not "continue".  Instead, add this to base_compile
365135c4bbdfSmrg	lastarg=$arg
36524642e01fSmrg	arg_mode=normal
36534642e01fSmrg	;;
36544642e01fSmrg
36554642e01fSmrg      target )
365635c4bbdfSmrg	libobj=$arg
36574642e01fSmrg	arg_mode=normal
36584642e01fSmrg	continue
36594642e01fSmrg	;;
36604642e01fSmrg
36614642e01fSmrg      normal )
36624642e01fSmrg	# Accept any command-line options.
36634642e01fSmrg	case $arg in
36644642e01fSmrg	-o)
36654642e01fSmrg	  test -n "$libobj" && \
366635c4bbdfSmrg	    func_fatal_error "you cannot specify '-o' more than once"
36674642e01fSmrg	  arg_mode=target
36684642e01fSmrg	  continue
36694642e01fSmrg	  ;;
36704642e01fSmrg
36714642e01fSmrg	-pie | -fpie | -fPIE)
367235c4bbdfSmrg          func_append pie_flag " $arg"
36734642e01fSmrg	  continue
36744642e01fSmrg	  ;;
36754642e01fSmrg
36764642e01fSmrg	-shared | -static | -prefer-pic | -prefer-non-pic)
367735c4bbdfSmrg	  func_append later " $arg"
36784642e01fSmrg	  continue
36794642e01fSmrg	  ;;
36804642e01fSmrg
36814642e01fSmrg	-no-suppress)
368205b261ecSmrg	  suppress_opt=no
368305b261ecSmrg	  continue
368405b261ecSmrg	  ;;
368505b261ecSmrg
368605b261ecSmrg	-Xcompiler)
368705b261ecSmrg	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
368805b261ecSmrg	  continue      #  The current "srcfile" will either be retained or
368905b261ecSmrg	  ;;            #  replaced later.  I would guess that would be a bug.
369005b261ecSmrg
369105b261ecSmrg	-Wc,*)
36924642e01fSmrg	  func_stripname '-Wc,' '' "$arg"
36934642e01fSmrg	  args=$func_stripname_result
369405b261ecSmrg	  lastarg=
369535c4bbdfSmrg	  save_ifs=$IFS; IFS=,
36964642e01fSmrg	  for arg in $args; do
369735c4bbdfSmrg	    IFS=$save_ifs
369835c4bbdfSmrg	    func_append_quoted lastarg "$arg"
369905b261ecSmrg	  done
370035c4bbdfSmrg	  IFS=$save_ifs
37014642e01fSmrg	  func_stripname ' ' '' "$lastarg"
37024642e01fSmrg	  lastarg=$func_stripname_result
370305b261ecSmrg
370405b261ecSmrg	  # Add the arguments to base_compile.
370535c4bbdfSmrg	  func_append base_compile " $lastarg"
370605b261ecSmrg	  continue
370705b261ecSmrg	  ;;
370805b261ecSmrg
37094642e01fSmrg	*)
371005b261ecSmrg	  # Accept the current argument as the source file.
371105b261ecSmrg	  # The previous "srcfile" becomes the current argument.
371205b261ecSmrg	  #
371335c4bbdfSmrg	  lastarg=$srcfile
371435c4bbdfSmrg	  srcfile=$arg
371505b261ecSmrg	  ;;
371605b261ecSmrg	esac  #  case $arg
371705b261ecSmrg	;;
371805b261ecSmrg      esac    #  case $arg_mode
371905b261ecSmrg
372005b261ecSmrg      # Aesthetically quote the previous argument.
372135c4bbdfSmrg      func_append_quoted base_compile "$lastarg"
372205b261ecSmrg    done # for arg
372305b261ecSmrg
372405b261ecSmrg    case $arg_mode in
372505b261ecSmrg    arg)
37264642e01fSmrg      func_fatal_error "you must specify an argument for -Xcompile"
372705b261ecSmrg      ;;
372805b261ecSmrg    target)
372935c4bbdfSmrg      func_fatal_error "you must specify a target with '-o'"
373005b261ecSmrg      ;;
373105b261ecSmrg    *)
373205b261ecSmrg      # Get the name of the library object.
37334642e01fSmrg      test -z "$libobj" && {
37344642e01fSmrg	func_basename "$srcfile"
373535c4bbdfSmrg	libobj=$func_basename_result
37364642e01fSmrg      }
373705b261ecSmrg      ;;
373805b261ecSmrg    esac
373905b261ecSmrg
374005b261ecSmrg    # Recognize several different file suffixes.
374105b261ecSmrg    # If the user specifies -o file.o, it is replaced with file.lo
374205b261ecSmrg    case $libobj in
37434642e01fSmrg    *.[cCFSifmso] | \
37444642e01fSmrg    *.ada | *.adb | *.ads | *.asm | \
37454642e01fSmrg    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
374635c4bbdfSmrg    *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
37474642e01fSmrg      func_xform "$libobj"
37484642e01fSmrg      libobj=$func_xform_result
37494642e01fSmrg      ;;
375005b261ecSmrg    esac
375105b261ecSmrg
375205b261ecSmrg    case $libobj in
37534642e01fSmrg    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
375405b261ecSmrg    *)
375535c4bbdfSmrg      func_fatal_error "cannot determine name of library object from '$libobj'"
375605b261ecSmrg      ;;
375705b261ecSmrg    esac
375805b261ecSmrg
375905b261ecSmrg    func_infer_tag $base_compile
376005b261ecSmrg
376105b261ecSmrg    for arg in $later; do
376205b261ecSmrg      case $arg in
37634642e01fSmrg      -shared)
376435c4bbdfSmrg	test yes = "$build_libtool_libs" \
376535c4bbdfSmrg	  || func_fatal_configuration "cannot build a shared library"
37664642e01fSmrg	build_old_libs=no
37674642e01fSmrg	continue
37684642e01fSmrg	;;
37694642e01fSmrg
377005b261ecSmrg      -static)
37714642e01fSmrg	build_libtool_libs=no
377205b261ecSmrg	build_old_libs=yes
377305b261ecSmrg	continue
377405b261ecSmrg	;;
377505b261ecSmrg
377605b261ecSmrg      -prefer-pic)
377705b261ecSmrg	pic_mode=yes
377805b261ecSmrg	continue
377905b261ecSmrg	;;
378005b261ecSmrg
378105b261ecSmrg      -prefer-non-pic)
378205b261ecSmrg	pic_mode=no
378305b261ecSmrg	continue
378405b261ecSmrg	;;
378505b261ecSmrg      esac
378605b261ecSmrg    done
378705b261ecSmrg
3788c82838c1Smrg    func_quote_arg pretty "$libobj"
3789c82838c1Smrg    test "X$libobj" != "X$func_quote_arg_result" \
37904642e01fSmrg      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
379135c4bbdfSmrg      && func_warning "libobj name '$libobj' may not contain shell special characters."
37924642e01fSmrg    func_dirname_and_basename "$obj" "/" ""
379335c4bbdfSmrg    objname=$func_basename_result
379435c4bbdfSmrg    xdir=$func_dirname_result
379535c4bbdfSmrg    lobj=$xdir$objdir/$objname
379605b261ecSmrg
37974642e01fSmrg    test -z "$base_compile" && \
37984642e01fSmrg      func_fatal_help "you must specify a compilation command"
379905b261ecSmrg
380005b261ecSmrg    # Delete any leftover library objects.
380135c4bbdfSmrg    if test yes = "$build_old_libs"; then
380205b261ecSmrg      removelist="$obj $lobj $libobj ${libobj}T"
380305b261ecSmrg    else
380405b261ecSmrg      removelist="$lobj $libobj ${libobj}T"
380505b261ecSmrg    fi
380605b261ecSmrg
380705b261ecSmrg    # On Cygwin there's no "real" PIC flag so we must build both object types
380805b261ecSmrg    case $host_os in
380954b5899cSmrg    cygwin* | mingw* | windows* | pw32* | os2* | cegcc*)
381005b261ecSmrg      pic_mode=default
381105b261ecSmrg      ;;
381205b261ecSmrg    esac
381335c4bbdfSmrg    if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then
381405b261ecSmrg      # non-PIC code in shared libraries is not supported
381505b261ecSmrg      pic_mode=default
381605b261ecSmrg    fi
381705b261ecSmrg
381805b261ecSmrg    # Calculate the filename of the output object if compiler does
381905b261ecSmrg    # not support -o with -c
382035c4bbdfSmrg    if test no = "$compiler_c_o"; then
382135c4bbdfSmrg      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext
382235c4bbdfSmrg      lockfile=$output_obj.lock
382305b261ecSmrg    else
382405b261ecSmrg      output_obj=
382505b261ecSmrg      need_locks=no
382605b261ecSmrg      lockfile=
382705b261ecSmrg    fi
382805b261ecSmrg
382905b261ecSmrg    # Lock this critical section if it is needed
383005b261ecSmrg    # We use this script file to make the link, it avoids creating a new file
383135c4bbdfSmrg    if test yes = "$need_locks"; then
38324642e01fSmrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
38334642e01fSmrg	func_echo "Waiting for $lockfile to be removed"
383405b261ecSmrg	sleep 2
383505b261ecSmrg      done
383635c4bbdfSmrg    elif test warn = "$need_locks"; then
383705b261ecSmrg      if test -f "$lockfile"; then
38384642e01fSmrg	$ECHO "\
383905b261ecSmrg*** ERROR, $lockfile exists and contains:
384005b261ecSmrg`cat $lockfile 2>/dev/null`
384105b261ecSmrg
384205b261ecSmrgThis indicates that another process is trying to use the same
384305b261ecSmrgtemporary object file, and libtool could not work around it because
384435c4bbdfSmrgyour compiler does not support '-c' and '-o' together.  If you
384505b261ecSmrgrepeat this compilation, it may succeed, by chance, but you had better
384605b261ecSmrgavoid parallel builds (make -j) in this platform, or get a better
384705b261ecSmrgcompiler."
384805b261ecSmrg
38494642e01fSmrg	$opt_dry_run || $RM $removelist
385005b261ecSmrg	exit $EXIT_FAILURE
385105b261ecSmrg      fi
385235c4bbdfSmrg      func_append removelist " $output_obj"
38534642e01fSmrg      $ECHO "$srcfile" > "$lockfile"
385405b261ecSmrg    fi
385505b261ecSmrg
38564642e01fSmrg    $opt_dry_run || $RM $removelist
385735c4bbdfSmrg    func_append removelist " $lockfile"
38584642e01fSmrg    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
38594642e01fSmrg
386035c4bbdfSmrg    func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
386135c4bbdfSmrg    srcfile=$func_to_tool_file_result
3862c82838c1Smrg    func_quote_arg pretty "$srcfile"
3863c82838c1Smrg    qsrcfile=$func_quote_arg_result
386405b261ecSmrg
386505b261ecSmrg    # Only build a PIC object if we are building libtool libraries.
386635c4bbdfSmrg    if test yes = "$build_libtool_libs"; then
386705b261ecSmrg      # Without this assignment, base_compile gets emptied.
386805b261ecSmrg      fbsd_hideous_sh_bug=$base_compile
386905b261ecSmrg
387035c4bbdfSmrg      if test no != "$pic_mode"; then
387105b261ecSmrg	command="$base_compile $qsrcfile $pic_flag"
387205b261ecSmrg      else
387305b261ecSmrg	# Don't build PIC code
387405b261ecSmrg	command="$base_compile $qsrcfile"
387505b261ecSmrg      fi
387605b261ecSmrg
38774642e01fSmrg      func_mkdir_p "$xdir$objdir"
387805b261ecSmrg
387905b261ecSmrg      if test -z "$output_obj"; then
388005b261ecSmrg	# Place PIC objects in $objdir
388135c4bbdfSmrg	func_append command " -o $lobj"
388205b261ecSmrg      fi
388305b261ecSmrg
38844642e01fSmrg      func_show_eval_locale "$command"	\
38854642e01fSmrg          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
388605b261ecSmrg
388735c4bbdfSmrg      if test warn = "$need_locks" &&
388805b261ecSmrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
38894642e01fSmrg	$ECHO "\
389005b261ecSmrg*** ERROR, $lockfile contains:
389105b261ecSmrg`cat $lockfile 2>/dev/null`
389205b261ecSmrg
389305b261ecSmrgbut it should contain:
389405b261ecSmrg$srcfile
389505b261ecSmrg
389605b261ecSmrgThis indicates that another process is trying to use the same
389705b261ecSmrgtemporary object file, and libtool could not work around it because
389835c4bbdfSmrgyour compiler does not support '-c' and '-o' together.  If you
389905b261ecSmrgrepeat this compilation, it may succeed, by chance, but you had better
390005b261ecSmrgavoid parallel builds (make -j) in this platform, or get a better
390105b261ecSmrgcompiler."
390205b261ecSmrg
39034642e01fSmrg	$opt_dry_run || $RM $removelist
390405b261ecSmrg	exit $EXIT_FAILURE
390505b261ecSmrg      fi
390605b261ecSmrg
390705b261ecSmrg      # Just move the object if needed, then go on to compile the next one
390805b261ecSmrg      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
39094642e01fSmrg	func_show_eval '$MV "$output_obj" "$lobj"' \
39104642e01fSmrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
391105b261ecSmrg      fi
391205b261ecSmrg
391305b261ecSmrg      # Allow error messages only from the first compilation.
391435c4bbdfSmrg      if test yes = "$suppress_opt"; then
39154642e01fSmrg	suppress_output=' >/dev/null 2>&1'
391605b261ecSmrg      fi
391705b261ecSmrg    fi
391805b261ecSmrg
391905b261ecSmrg    # Only build a position-dependent object if we build old libraries.
392035c4bbdfSmrg    if test yes = "$build_old_libs"; then
392135c4bbdfSmrg      if test yes != "$pic_mode"; then
392205b261ecSmrg	# Don't build PIC code
39234642e01fSmrg	command="$base_compile $qsrcfile$pie_flag"
392405b261ecSmrg      else
392505b261ecSmrg	command="$base_compile $qsrcfile $pic_flag"
392605b261ecSmrg      fi
392735c4bbdfSmrg      if test yes = "$compiler_c_o"; then
392835c4bbdfSmrg	func_append command " -o $obj"
392905b261ecSmrg      fi
393005b261ecSmrg
393105b261ecSmrg      # Suppress compiler output if we already did a PIC compilation.
393235c4bbdfSmrg      func_append command "$suppress_output"
39334642e01fSmrg      func_show_eval_locale "$command" \
39344642e01fSmrg        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
393505b261ecSmrg
393635c4bbdfSmrg      if test warn = "$need_locks" &&
393705b261ecSmrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
39384642e01fSmrg	$ECHO "\
393905b261ecSmrg*** ERROR, $lockfile contains:
394005b261ecSmrg`cat $lockfile 2>/dev/null`
394105b261ecSmrg
394205b261ecSmrgbut it should contain:
394305b261ecSmrg$srcfile
394405b261ecSmrg
394505b261ecSmrgThis indicates that another process is trying to use the same
394605b261ecSmrgtemporary object file, and libtool could not work around it because
394735c4bbdfSmrgyour compiler does not support '-c' and '-o' together.  If you
394805b261ecSmrgrepeat this compilation, it may succeed, by chance, but you had better
394905b261ecSmrgavoid parallel builds (make -j) in this platform, or get a better
395005b261ecSmrgcompiler."
395105b261ecSmrg
39524642e01fSmrg	$opt_dry_run || $RM $removelist
395305b261ecSmrg	exit $EXIT_FAILURE
395405b261ecSmrg      fi
395505b261ecSmrg
395605b261ecSmrg      # Just move the object if needed
395705b261ecSmrg      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
39584642e01fSmrg	func_show_eval '$MV "$output_obj" "$obj"' \
39594642e01fSmrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
396005b261ecSmrg      fi
396105b261ecSmrg    fi
396205b261ecSmrg
39634642e01fSmrg    $opt_dry_run || {
39644642e01fSmrg      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
396505b261ecSmrg
39664642e01fSmrg      # Unlock the critical section if it was locked
396735c4bbdfSmrg      if test no != "$need_locks"; then
39684642e01fSmrg	removelist=$lockfile
39694642e01fSmrg        $RM "$lockfile"
39704642e01fSmrg      fi
39714642e01fSmrg    }
397205b261ecSmrg
397305b261ecSmrg    exit $EXIT_SUCCESS
39744642e01fSmrg}
397505b261ecSmrg
39764642e01fSmrg$opt_help || {
397735c4bbdfSmrg  test compile = "$opt_mode" && func_mode_compile ${1+"$@"}
39784642e01fSmrg}
397905b261ecSmrg
39804642e01fSmrgfunc_mode_help ()
39814642e01fSmrg{
39824642e01fSmrg    # We need to display help for each of the modes.
398335c4bbdfSmrg    case $opt_mode in
39844642e01fSmrg      "")
39854642e01fSmrg        # Generic help is extracted from the usage comments
39864642e01fSmrg        # at the start of this file.
39874642e01fSmrg        func_help
39884642e01fSmrg        ;;
398905b261ecSmrg
39904642e01fSmrg      clean)
39914642e01fSmrg        $ECHO \
39924642e01fSmrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
399305b261ecSmrg
39944642e01fSmrgRemove files from the build directory.
399505b261ecSmrg
39964642e01fSmrgRM is the name of the program to use to delete files associated with each FILE
399735c4bbdfSmrg(typically '/bin/rm').  RM-OPTIONS are options (such as '-f') to be passed
39984642e01fSmrgto RM.
399905b261ecSmrg
40004642e01fSmrgIf FILE is a libtool library, object or program, all the files associated
40014642e01fSmrgwith it are deleted. Otherwise, only FILE itself is deleted using RM."
40024642e01fSmrg        ;;
400305b261ecSmrg
40044642e01fSmrg      compile)
40054642e01fSmrg      $ECHO \
40064642e01fSmrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
400705b261ecSmrg
40084642e01fSmrgCompile a source file into a libtool library object.
400905b261ecSmrg
40104642e01fSmrgThis mode accepts the following additional options:
401105b261ecSmrg
40124642e01fSmrg  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
40134642e01fSmrg  -no-suppress      do not suppress compiler output for multiple passes
40146747b715Smrg  -prefer-pic       try to build PIC objects only
40156747b715Smrg  -prefer-non-pic   try to build non-PIC objects only
401635c4bbdfSmrg  -shared           do not build a '.o' file suitable for static linking
401735c4bbdfSmrg  -static           only build a '.o' file suitable for static linking
4018c82838c1Smrg  -Wc,FLAG
4019c82838c1Smrg  -Xcompiler FLAG   pass FLAG directly to the compiler
402005b261ecSmrg
402135c4bbdfSmrgCOMPILE-COMMAND is a command to be used in creating a 'standard' object file
40224642e01fSmrgfrom the given SOURCEFILE.
402305b261ecSmrg
40244642e01fSmrgThe output file name is determined by removing the directory component from
402535c4bbdfSmrgSOURCEFILE, then substituting the C source code suffix '.c' with the
402635c4bbdfSmrglibrary object suffix, '.lo'."
40274642e01fSmrg        ;;
402805b261ecSmrg
40294642e01fSmrg      execute)
40304642e01fSmrg        $ECHO \
40314642e01fSmrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
403205b261ecSmrg
40334642e01fSmrgAutomatically set library path, then run a program.
403405b261ecSmrg
40354642e01fSmrgThis mode accepts the following additional options:
403605b261ecSmrg
40374642e01fSmrg  -dlopen FILE      add the directory containing FILE to the library path
403805b261ecSmrg
403935c4bbdfSmrgThis mode sets the library path environment variable according to '-dlopen'
40404642e01fSmrgflags.
404105b261ecSmrg
40424642e01fSmrgIf any of the ARGS are libtool executable wrappers, then they are translated
40434642e01fSmrginto their corresponding uninstalled binary, and any of their required library
40444642e01fSmrgdirectories are added to the library path.
404505b261ecSmrg
40464642e01fSmrgThen, COMMAND is executed, with ARGS as arguments."
40474642e01fSmrg        ;;
404805b261ecSmrg
40494642e01fSmrg      finish)
40504642e01fSmrg        $ECHO \
40514642e01fSmrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
405205b261ecSmrg
40534642e01fSmrgComplete the installation of libtool libraries.
405405b261ecSmrg
40554642e01fSmrgEach LIBDIR is a directory that contains libtool libraries.
405605b261ecSmrg
40574642e01fSmrgThe commands that this mode executes may require superuser privileges.  Use
405835c4bbdfSmrgthe '--dry-run' option if you just want to see what would be executed."
40594642e01fSmrg        ;;
406005b261ecSmrg
40614642e01fSmrg      install)
40624642e01fSmrg        $ECHO \
40634642e01fSmrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
406405b261ecSmrg
40654642e01fSmrgInstall executables or libraries.
406605b261ecSmrg
40674642e01fSmrgINSTALL-COMMAND is the installation command.  The first component should be
406835c4bbdfSmrgeither the 'install' or 'cp' program.
406905b261ecSmrg
40704642e01fSmrgThe following components of INSTALL-COMMAND are treated specially:
407105b261ecSmrg
40726747b715Smrg  -inst-prefix-dir PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
407305b261ecSmrg
40744642e01fSmrgThe rest of the components are interpreted as arguments to that command (only
40754642e01fSmrgBSD-compatible install options are recognized)."
40764642e01fSmrg        ;;
407705b261ecSmrg
40784642e01fSmrg      link)
40794642e01fSmrg        $ECHO \
40804642e01fSmrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
408105b261ecSmrg
40824642e01fSmrgLink object files or libraries together to form another library, or to
40834642e01fSmrgcreate an executable program.
408405b261ecSmrg
40854642e01fSmrgLINK-COMMAND is a command using the C compiler that you would use to create
40864642e01fSmrga program from several object files.
408705b261ecSmrg
40884642e01fSmrgThe following components of LINK-COMMAND are treated specially:
408905b261ecSmrg
40904642e01fSmrg  -all-static       do not do any dynamic linking at all
40914642e01fSmrg  -avoid-version    do not add a version suffix if possible
40926747b715Smrg  -bindir BINDIR    specify path to binaries directory (for systems where
40936747b715Smrg                    libraries must be found in the PATH setting at runtime)
409435c4bbdfSmrg  -dlopen FILE      '-dlpreopen' FILE if it cannot be dlopened at runtime
40954642e01fSmrg  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
40964642e01fSmrg  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
40974642e01fSmrg  -export-symbols SYMFILE
40984642e01fSmrg                    try to export only the symbols listed in SYMFILE
40994642e01fSmrg  -export-symbols-regex REGEX
41004642e01fSmrg                    try to export only the symbols matching REGEX
41014642e01fSmrg  -LLIBDIR          search LIBDIR for required installed libraries
41024642e01fSmrg  -lNAME            OUTPUT-FILE requires the installed library libNAME
41034642e01fSmrg  -module           build a library that can dlopened
41044642e01fSmrg  -no-fast-install  disable the fast-install mode
41054642e01fSmrg  -no-install       link a not-installable executable
41064642e01fSmrg  -no-undefined     declare that a library does not refer to external symbols
41074642e01fSmrg  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
410835c4bbdfSmrg  -objectlist FILE  use a list of object files found in FILE to specify objects
410935c4bbdfSmrg  -os2dllname NAME  force a short DLL name on OS/2 (no effect on other OSes)
41104642e01fSmrg  -precious-files-regex REGEX
41114642e01fSmrg                    don't remove output files matching REGEX
41124642e01fSmrg  -release RELEASE  specify package release information
41134642e01fSmrg  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
41144642e01fSmrg  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
41154642e01fSmrg  -shared           only do dynamic linking of libtool libraries
41164642e01fSmrg  -shrext SUFFIX    override the standard shared library file extension
41174642e01fSmrg  -static           do not do any dynamic linking of uninstalled libtool libraries
41184642e01fSmrg  -static-libtool-libs
41194642e01fSmrg                    do not do any dynamic linking of libtool libraries
41204642e01fSmrg  -version-info CURRENT[:REVISION[:AGE]]
41214642e01fSmrg                    specify library version info [each variable defaults to 0]
41224642e01fSmrg  -weak LIBNAME     declare that the target provides the LIBNAME interface
41236747b715Smrg  -Wc,FLAG
41246747b715Smrg  -Xcompiler FLAG   pass linker-specific FLAG directly to the compiler
4125c82838c1Smrg  -Wa,FLAG
4126c82838c1Smrg  -Xassembler FLAG  pass linker-specific FLAG directly to the assembler
41276747b715Smrg  -Wl,FLAG
41286747b715Smrg  -Xlinker FLAG     pass linker-specific FLAG directly to the linker
41296747b715Smrg  -XCClinker FLAG   pass link-specific FLAG to the compiler driver (CC)
413005b261ecSmrg
413135c4bbdfSmrgAll other options (arguments beginning with '-') are ignored.
413205b261ecSmrg
413335c4bbdfSmrgEvery other argument is treated as a filename.  Files ending in '.la' are
41344642e01fSmrgtreated as uninstalled libtool libraries, other files are standard or library
41354642e01fSmrgobject files.
413605b261ecSmrg
413735c4bbdfSmrgIf the OUTPUT-FILE ends in '.la', then a libtool library is created,
413835c4bbdfSmrgonly library objects ('.lo' files) may be specified, and '-rpath' is
41394642e01fSmrgrequired, except when creating a convenience library.
414005b261ecSmrg
414135c4bbdfSmrgIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created
414235c4bbdfSmrgusing 'ar' and 'ranlib', or on Windows using 'lib'.
414305b261ecSmrg
414435c4bbdfSmrgIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file
41454642e01fSmrgis created, otherwise an executable program is created."
414605b261ecSmrg        ;;
414705b261ecSmrg
41484642e01fSmrg      uninstall)
41494642e01fSmrg        $ECHO \
41504642e01fSmrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
415105b261ecSmrg
41524642e01fSmrgRemove libraries from an installation directory.
415305b261ecSmrg
41544642e01fSmrgRM is the name of the program to use to delete files associated with each FILE
415535c4bbdfSmrg(typically '/bin/rm').  RM-OPTIONS are options (such as '-f') to be passed
41564642e01fSmrgto RM.
415705b261ecSmrg
41584642e01fSmrgIf FILE is a libtool library, all the files associated with it are deleted.
41594642e01fSmrgOtherwise, only FILE itself is deleted using RM."
41604642e01fSmrg        ;;
416105b261ecSmrg
41624642e01fSmrg      *)
416335c4bbdfSmrg        func_fatal_help "invalid operation mode '$opt_mode'"
41644642e01fSmrg        ;;
41654642e01fSmrg    esac
416605b261ecSmrg
41676747b715Smrg    echo
416835c4bbdfSmrg    $ECHO "Try '$progname --help' for more information about other modes."
41694642e01fSmrg}
417005b261ecSmrg
41716747b715Smrg# Now that we've collected a possible --mode arg, show help if necessary
41726747b715Smrgif $opt_help; then
417335c4bbdfSmrg  if test : = "$opt_help"; then
41746747b715Smrg    func_mode_help
41756747b715Smrg  else
41766747b715Smrg    {
41776747b715Smrg      func_help noexit
417835c4bbdfSmrg      for opt_mode in compile link execute install finish uninstall clean; do
41796747b715Smrg	func_mode_help
41806747b715Smrg      done
418135c4bbdfSmrg    } | $SED -n '1p; 2,$s/^Usage:/  or: /p'
41826747b715Smrg    {
41836747b715Smrg      func_help noexit
418435c4bbdfSmrg      for opt_mode in compile link execute install finish uninstall clean; do
41856747b715Smrg	echo
41866747b715Smrg	func_mode_help
41876747b715Smrg      done
41886747b715Smrg    } |
418935c4bbdfSmrg    $SED '1d
41906747b715Smrg      /^When reporting/,/^Report/{
41916747b715Smrg	H
41926747b715Smrg	d
41936747b715Smrg      }
41946747b715Smrg      $x
41956747b715Smrg      /information about other modes/d
41966747b715Smrg      /more detailed .*MODE/d
41976747b715Smrg      s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
41986747b715Smrg  fi
41996747b715Smrg  exit $?
42006747b715Smrgfi
420105b261ecSmrg
420205b261ecSmrg
420354b5899cSmrg# If option '--reorder-cache', reorder the shared library cache and exit.
420454b5899cSmrgif $opt_reorder_cache; then
420554b5899cSmrg    func_reorder_shared_lib_cache $shared_lib_dirs
420654b5899cSmrgfi
420754b5899cSmrg
420854b5899cSmrg
42094642e01fSmrg# func_mode_execute arg...
42104642e01fSmrgfunc_mode_execute ()
42114642e01fSmrg{
421235c4bbdfSmrg    $debug_cmd
421335c4bbdfSmrg
42144642e01fSmrg    # The first argument is the command name.
421535c4bbdfSmrg    cmd=$nonopt
42164642e01fSmrg    test -z "$cmd" && \
42174642e01fSmrg      func_fatal_help "you must specify a COMMAND"
421805b261ecSmrg
42194642e01fSmrg    # Handle -dlopen flags immediately.
422035c4bbdfSmrg    for file in $opt_dlopen; do
42214642e01fSmrg      test -f "$file" \
422235c4bbdfSmrg	|| func_fatal_help "'$file' is not a file"
422305b261ecSmrg
42244642e01fSmrg      dir=
42254642e01fSmrg      case $file in
42264642e01fSmrg      *.la)
422735c4bbdfSmrg	func_resolve_sysroot "$file"
422835c4bbdfSmrg	file=$func_resolve_sysroot_result
422935c4bbdfSmrg
42304642e01fSmrg	# Check to see that this really is a libtool archive.
42314642e01fSmrg	func_lalib_unsafe_p "$file" \
423235c4bbdfSmrg	  || func_fatal_help "'$lib' is not a valid libtool archive"
423305b261ecSmrg
42344642e01fSmrg	# Read the libtool library.
42354642e01fSmrg	dlname=
42364642e01fSmrg	library_names=
42374642e01fSmrg	func_source "$file"
423805b261ecSmrg
42394642e01fSmrg	# Skip this library if it cannot be dlopened.
42404642e01fSmrg	if test -z "$dlname"; then
42414642e01fSmrg	  # Warn if it was a shared library.
42424642e01fSmrg	  test -n "$library_names" && \
424335c4bbdfSmrg	    func_warning "'$file' was not linked with '-export-dynamic'"
42444642e01fSmrg	  continue
42454642e01fSmrg	fi
424605b261ecSmrg
42474642e01fSmrg	func_dirname "$file" "" "."
424835c4bbdfSmrg	dir=$func_dirname_result
424905b261ecSmrg
42504642e01fSmrg	if test -f "$dir/$objdir/$dlname"; then
425135c4bbdfSmrg	  func_append dir "/$objdir"
42524642e01fSmrg	else
42534642e01fSmrg	  if test ! -f "$dir/$dlname"; then
425435c4bbdfSmrg	    func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'"
42554642e01fSmrg	  fi
42564642e01fSmrg	fi
425705b261ecSmrg	;;
425805b261ecSmrg
42594642e01fSmrg      *.lo)
42604642e01fSmrg	# Just add the directory containing the .lo file.
42614642e01fSmrg	func_dirname "$file" "" "."
426235c4bbdfSmrg	dir=$func_dirname_result
426305b261ecSmrg	;;
426405b261ecSmrg
42654642e01fSmrg      *)
426635c4bbdfSmrg	func_warning "'-dlopen' is ignored for non-libtool libraries and objects"
426705b261ecSmrg	continue
426805b261ecSmrg	;;
42694642e01fSmrg      esac
427005b261ecSmrg
42714642e01fSmrg      # Get the absolute pathname.
42724642e01fSmrg      absdir=`cd "$dir" && pwd`
427335c4bbdfSmrg      test -n "$absdir" && dir=$absdir
427405b261ecSmrg
42754642e01fSmrg      # Now add the directory to shlibpath_var.
42764642e01fSmrg      if eval "test -z \"\$$shlibpath_var\""; then
42774642e01fSmrg	eval "$shlibpath_var=\"\$dir\""
42784642e01fSmrg      else
42794642e01fSmrg	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
42804642e01fSmrg      fi
42814642e01fSmrg    done
428205b261ecSmrg
42834642e01fSmrg    # This variable tells wrapper scripts just to set shlibpath_var
42844642e01fSmrg    # rather than running their programs.
428535c4bbdfSmrg    libtool_execute_magic=$magic
428605b261ecSmrg
42874642e01fSmrg    # Check if any of the arguments is a wrapper script.
42884642e01fSmrg    args=
42894642e01fSmrg    for file
42904642e01fSmrg    do
42914642e01fSmrg      case $file in
42926747b715Smrg      -* | *.la | *.lo ) ;;
42934642e01fSmrg      *)
42944642e01fSmrg	# Do a test to see if this is really a libtool program.
42954642e01fSmrg	if func_ltwrapper_script_p "$file"; then
42964642e01fSmrg	  func_source "$file"
42974642e01fSmrg	  # Transform arg to wrapped name.
429835c4bbdfSmrg	  file=$progdir/$program
42994642e01fSmrg	elif func_ltwrapper_executable_p "$file"; then
43004642e01fSmrg	  func_ltwrapper_scriptname "$file"
43014642e01fSmrg	  func_source "$func_ltwrapper_scriptname_result"
43024642e01fSmrg	  # Transform arg to wrapped name.
430335c4bbdfSmrg	  file=$progdir/$program
43044642e01fSmrg	fi
43054642e01fSmrg	;;
43064642e01fSmrg      esac
43074642e01fSmrg      # Quote arguments (to preserve shell metacharacters).
430835c4bbdfSmrg      func_append_quoted args "$file"
43094642e01fSmrg    done
431005b261ecSmrg
431135c4bbdfSmrg    if $opt_dry_run; then
431235c4bbdfSmrg      # Display what would be done.
431335c4bbdfSmrg      if test -n "$shlibpath_var"; then
431435c4bbdfSmrg	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
431535c4bbdfSmrg	echo "export $shlibpath_var"
431635c4bbdfSmrg      fi
431735c4bbdfSmrg      $ECHO "$cmd$args"
431835c4bbdfSmrg      exit $EXIT_SUCCESS
431935c4bbdfSmrg    else
43204642e01fSmrg      if test -n "$shlibpath_var"; then
43214642e01fSmrg	# Export the shlibpath_var.
43224642e01fSmrg	eval "export $shlibpath_var"
43234642e01fSmrg      fi
432405b261ecSmrg
43254642e01fSmrg      # Restore saved environment variables
43264642e01fSmrg      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
43274642e01fSmrg      do
43284642e01fSmrg	eval "if test \"\${save_$lt_var+set}\" = set; then
43294642e01fSmrg                $lt_var=\$save_$lt_var; export $lt_var
433005b261ecSmrg	      else
43314642e01fSmrg		$lt_unset $lt_var
43324642e01fSmrg	      fi"
43334642e01fSmrg      done
433405b261ecSmrg
43354642e01fSmrg      # Now prepare to actually exec the command.
433635c4bbdfSmrg      exec_cmd=\$cmd$args
43374642e01fSmrg    fi
43384642e01fSmrg}
433905b261ecSmrg
434035c4bbdfSmrgtest execute = "$opt_mode" && func_mode_execute ${1+"$@"}
434105b261ecSmrg
434205b261ecSmrg
43434642e01fSmrg# func_mode_finish arg...
43444642e01fSmrgfunc_mode_finish ()
43454642e01fSmrg{
434635c4bbdfSmrg    $debug_cmd
434735c4bbdfSmrg
434835c4bbdfSmrg    libs=
434935c4bbdfSmrg    libdirs=
43504642e01fSmrg    admincmds=
435105b261ecSmrg
435235c4bbdfSmrg    for opt in "$nonopt" ${1+"$@"}
435335c4bbdfSmrg    do
435435c4bbdfSmrg      if test -d "$opt"; then
435535c4bbdfSmrg	func_append libdirs " $opt"
435635c4bbdfSmrg
435735c4bbdfSmrg      elif test -f "$opt"; then
435835c4bbdfSmrg	if func_lalib_unsafe_p "$opt"; then
435935c4bbdfSmrg	  func_append libs " $opt"
436035c4bbdfSmrg	else
436135c4bbdfSmrg	  func_warning "'$opt' is not a valid libtool archive"
436235c4bbdfSmrg	fi
436335c4bbdfSmrg
436435c4bbdfSmrg      else
436535c4bbdfSmrg	func_fatal_error "invalid argument '$opt'"
436635c4bbdfSmrg      fi
436735c4bbdfSmrg    done
436835c4bbdfSmrg
436935c4bbdfSmrg    if test -n "$libs"; then
437035c4bbdfSmrg      if test -n "$lt_sysroot"; then
437135c4bbdfSmrg        sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
437235c4bbdfSmrg        sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
437335c4bbdfSmrg      else
437435c4bbdfSmrg        sysroot_cmd=
437535c4bbdfSmrg      fi
4376475c125cSmrg
437735c4bbdfSmrg      # Remove sysroot references
437835c4bbdfSmrg      if $opt_dry_run; then
437935c4bbdfSmrg        for lib in $libs; do
438035c4bbdfSmrg          echo "removing references to $lt_sysroot and '=' prefixes from $lib"
438135c4bbdfSmrg        done
438235c4bbdfSmrg      else
438335c4bbdfSmrg        tmpdir=`func_mktempdir`
438435c4bbdfSmrg        for lib in $libs; do
438535c4bbdfSmrg	  $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
438635c4bbdfSmrg	    > $tmpdir/tmp-la
438735c4bbdfSmrg	  mv -f $tmpdir/tmp-la $lib
438835c4bbdfSmrg	done
438935c4bbdfSmrg        ${RM}r "$tmpdir"
439035c4bbdfSmrg      fi
439135c4bbdfSmrg    fi
439235c4bbdfSmrg
439354b5899cSmrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs" && $opt_finishing; then
43944642e01fSmrg      for libdir in $libdirs; do
43954642e01fSmrg	if test -n "$finish_cmds"; then
43964642e01fSmrg	  # Do each command in the finish commands.
43974642e01fSmrg	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
43984642e01fSmrg'"$cmd"'"'
439905b261ecSmrg	fi
44004642e01fSmrg	if test -n "$finish_eval"; then
44014642e01fSmrg	  # Do the single finish_eval.
44024642e01fSmrg	  eval cmds=\"$finish_eval\"
440335c4bbdfSmrg	  $opt_dry_run || eval "$cmds" || func_append admincmds "
44044642e01fSmrg       $cmds"
44054642e01fSmrg	fi
44064642e01fSmrg      done
44074642e01fSmrg    fi
440805b261ecSmrg
44094642e01fSmrg    # Exit here if they wanted silent mode.
441035c4bbdfSmrg    $opt_quiet && exit $EXIT_SUCCESS
441105b261ecSmrg
441235c4bbdfSmrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
441335c4bbdfSmrg      echo "----------------------------------------------------------------------"
441435c4bbdfSmrg      echo "Libraries have been installed in:"
441535c4bbdfSmrg      for libdir in $libdirs; do
441635c4bbdfSmrg	$ECHO "   $libdir"
441735c4bbdfSmrg      done
441854b5899cSmrg      if test "false" = "$opt_finishing"; then
441954b5899cSmrg        echo
442054b5899cSmrg        echo "NOTE: finish_cmds were not executed during testing, so you must"
442154b5899cSmrg        echo "manually run ldconfig to add a given test directory, LIBDIR, to"
442254b5899cSmrg        echo "the search path for generated executables."
442354b5899cSmrg      fi
442435c4bbdfSmrg      echo
442535c4bbdfSmrg      echo "If you ever happen to want to link against installed libraries"
442635c4bbdfSmrg      echo "in a given directory, LIBDIR, you must either use libtool, and"
442735c4bbdfSmrg      echo "specify the full pathname of the library, or use the '-LLIBDIR'"
442835c4bbdfSmrg      echo "flag during linking and do at least one of the following:"
442935c4bbdfSmrg      if test -n "$shlibpath_var"; then
443035c4bbdfSmrg	echo "   - add LIBDIR to the '$shlibpath_var' environment variable"
443135c4bbdfSmrg	echo "     during execution"
443235c4bbdfSmrg      fi
443335c4bbdfSmrg      if test -n "$runpath_var"; then
443435c4bbdfSmrg	echo "   - add LIBDIR to the '$runpath_var' environment variable"
443535c4bbdfSmrg	echo "     during linking"
443635c4bbdfSmrg      fi
443735c4bbdfSmrg      if test -n "$hardcode_libdir_flag_spec"; then
443835c4bbdfSmrg	libdir=LIBDIR
443935c4bbdfSmrg	eval flag=\"$hardcode_libdir_flag_spec\"
44404642e01fSmrg
444135c4bbdfSmrg	$ECHO "   - use the '$flag' linker flag"
444235c4bbdfSmrg      fi
444335c4bbdfSmrg      if test -n "$admincmds"; then
444435c4bbdfSmrg	$ECHO "   - have your system administrator run these commands:$admincmds"
444535c4bbdfSmrg      fi
444635c4bbdfSmrg      if test -f /etc/ld.so.conf; then
444735c4bbdfSmrg	echo "   - have your system administrator add LIBDIR to '/etc/ld.so.conf'"
444835c4bbdfSmrg      fi
444935c4bbdfSmrg      echo
4450475c125cSmrg
445135c4bbdfSmrg      echo "See any operating system documentation about shared libraries for"
445235c4bbdfSmrg      case $host in
445335c4bbdfSmrg	solaris2.[6789]|solaris2.1[0-9])
445435c4bbdfSmrg	  echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
445535c4bbdfSmrg	  echo "pages."
445635c4bbdfSmrg	  ;;
445735c4bbdfSmrg	*)
445835c4bbdfSmrg	  echo "more information, such as the ld(1) and ld.so(8) manual pages."
445935c4bbdfSmrg	  ;;
446035c4bbdfSmrg      esac
446135c4bbdfSmrg      echo "----------------------------------------------------------------------"
446235c4bbdfSmrg    fi
44634642e01fSmrg    exit $EXIT_SUCCESS
44644642e01fSmrg}
44654642e01fSmrg
446635c4bbdfSmrgtest finish = "$opt_mode" && func_mode_finish ${1+"$@"}
44674642e01fSmrg
44684642e01fSmrg
44694642e01fSmrg# func_mode_install arg...
44704642e01fSmrgfunc_mode_install ()
44714642e01fSmrg{
447235c4bbdfSmrg    $debug_cmd
447335c4bbdfSmrg
44744642e01fSmrg    # There may be an optional sh(1) argument at the beginning of
44754642e01fSmrg    # install_prog (especially on Windows NT).
447635c4bbdfSmrg    if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" ||
44774642e01fSmrg       # Allow the use of GNU shtool's install command.
447835c4bbdfSmrg       case $nonopt in *shtool*) :;; *) false;; esac
447935c4bbdfSmrg    then
44804642e01fSmrg      # Aesthetically quote it.
4481c82838c1Smrg      func_quote_arg pretty "$nonopt"
4482c82838c1Smrg      install_prog="$func_quote_arg_result "
44834642e01fSmrg      arg=$1
44844642e01fSmrg      shift
44854642e01fSmrg    else
44864642e01fSmrg      install_prog=
44874642e01fSmrg      arg=$nonopt
44884642e01fSmrg    fi
44894642e01fSmrg
44904642e01fSmrg    # The real first argument should be the name of the installation program.
44914642e01fSmrg    # Aesthetically quote it.
4492c82838c1Smrg    func_quote_arg pretty "$arg"
4493c82838c1Smrg    func_append install_prog "$func_quote_arg_result"
44946747b715Smrg    install_shared_prog=$install_prog
44956747b715Smrg    case " $install_prog " in
44966747b715Smrg      *[\\\ /]cp\ *) install_cp=: ;;
44976747b715Smrg      *) install_cp=false ;;
44986747b715Smrg    esac
44994642e01fSmrg
45004642e01fSmrg    # We need to accept at least all the BSD install flags.
45014642e01fSmrg    dest=
45024642e01fSmrg    files=
45034642e01fSmrg    opts=
45044642e01fSmrg    prev=
45054642e01fSmrg    install_type=
450635c4bbdfSmrg    isdir=false
45074642e01fSmrg    stripme=
45086747b715Smrg    no_mode=:
45094642e01fSmrg    for arg
45104642e01fSmrg    do
45116747b715Smrg      arg2=
45124642e01fSmrg      if test -n "$dest"; then
451335c4bbdfSmrg	func_append files " $dest"
45144642e01fSmrg	dest=$arg
45154642e01fSmrg	continue
45164642e01fSmrg      fi
45174642e01fSmrg
45184642e01fSmrg      case $arg in
451935c4bbdfSmrg      -d) isdir=: ;;
45204642e01fSmrg      -f)
45216747b715Smrg	if $install_cp; then :; else
45226747b715Smrg	  prev=$arg
45236747b715Smrg	fi
45244642e01fSmrg	;;
45254642e01fSmrg      -g | -m | -o)
45264642e01fSmrg	prev=$arg
45274642e01fSmrg	;;
45284642e01fSmrg      -s)
45294642e01fSmrg	stripme=" -s"
45304642e01fSmrg	continue
45314642e01fSmrg	;;
45324642e01fSmrg      -*)
45334642e01fSmrg	;;
45344642e01fSmrg      *)
45354642e01fSmrg	# If the previous option needed an argument, then skip it.
45364642e01fSmrg	if test -n "$prev"; then
453735c4bbdfSmrg	  if test X-m = "X$prev" && test -n "$install_override_mode"; then
45386747b715Smrg	    arg2=$install_override_mode
45396747b715Smrg	    no_mode=false
45406747b715Smrg	  fi
454105b261ecSmrg	  prev=
454205b261ecSmrg	else
45434642e01fSmrg	  dest=$arg
45444642e01fSmrg	  continue
454505b261ecSmrg	fi
454605b261ecSmrg	;;
45474642e01fSmrg      esac
454805b261ecSmrg
45494642e01fSmrg      # Aesthetically quote the argument.
4550c82838c1Smrg      func_quote_arg pretty "$arg"
4551c82838c1Smrg      func_append install_prog " $func_quote_arg_result"
45526747b715Smrg      if test -n "$arg2"; then
4553c82838c1Smrg	func_quote_arg pretty "$arg2"
45546747b715Smrg      fi
4555c82838c1Smrg      func_append install_shared_prog " $func_quote_arg_result"
45564642e01fSmrg    done
455705b261ecSmrg
45584642e01fSmrg    test -z "$install_prog" && \
45594642e01fSmrg      func_fatal_help "you must specify an install program"
456005b261ecSmrg
45614642e01fSmrg    test -n "$prev" && \
456235c4bbdfSmrg      func_fatal_help "the '$prev' option requires an argument"
456305b261ecSmrg
45646747b715Smrg    if test -n "$install_override_mode" && $no_mode; then
45656747b715Smrg      if $install_cp; then :; else
4566c82838c1Smrg	func_quote_arg pretty "$install_override_mode"
4567c82838c1Smrg	func_append install_shared_prog " -m $func_quote_arg_result"
45686747b715Smrg      fi
45696747b715Smrg    fi
45706747b715Smrg
45714642e01fSmrg    if test -z "$files"; then
45724642e01fSmrg      if test -z "$dest"; then
45734642e01fSmrg	func_fatal_help "no file or destination specified"
45744642e01fSmrg      else
45754642e01fSmrg	func_fatal_help "you must specify a destination"
45764642e01fSmrg      fi
457705b261ecSmrg    fi
457805b261ecSmrg
45794642e01fSmrg    # Strip any trailing slash from the destination.
45804642e01fSmrg    func_stripname '' '/' "$dest"
45814642e01fSmrg    dest=$func_stripname_result
458205b261ecSmrg
45834642e01fSmrg    # Check to see that the destination is a directory.
458435c4bbdfSmrg    test -d "$dest" && isdir=:
458535c4bbdfSmrg    if $isdir; then
458635c4bbdfSmrg      destdir=$dest
45874642e01fSmrg      destname=
458805b261ecSmrg    else
45894642e01fSmrg      func_dirname_and_basename "$dest" "" "."
459035c4bbdfSmrg      destdir=$func_dirname_result
459135c4bbdfSmrg      destname=$func_basename_result
459205b261ecSmrg
45934642e01fSmrg      # Not a directory, so check to see that there is only one file specified.
45944642e01fSmrg      set dummy $files; shift
45954642e01fSmrg      test "$#" -gt 1 && \
459635c4bbdfSmrg	func_fatal_help "'$dest' is not a directory"
459705b261ecSmrg    fi
45984642e01fSmrg    case $destdir in
45994642e01fSmrg    [\\/]* | [A-Za-z]:[\\/]*) ;;
460005b261ecSmrg    *)
46014642e01fSmrg      for file in $files; do
46024642e01fSmrg	case $file in
46034642e01fSmrg	*.lo) ;;
46044642e01fSmrg	*)
460535c4bbdfSmrg	  func_fatal_help "'$destdir' must be an absolute directory name"
46064642e01fSmrg	  ;;
46074642e01fSmrg	esac
46084642e01fSmrg      done
460905b261ecSmrg      ;;
461005b261ecSmrg    esac
461105b261ecSmrg
46124642e01fSmrg    # This variable tells wrapper scripts just to set variables rather
46134642e01fSmrg    # than running their programs.
461435c4bbdfSmrg    libtool_install_magic=$magic
461505b261ecSmrg
46164642e01fSmrg    staticlibs=
46174642e01fSmrg    future_libdirs=
46184642e01fSmrg    current_libdirs=
46194642e01fSmrg    for file in $files; do
462005b261ecSmrg
46214642e01fSmrg      # Do each installation.
46224642e01fSmrg      case $file in
46234642e01fSmrg      *.$libext)
46244642e01fSmrg	# Do the static libraries later.
462535c4bbdfSmrg	func_append staticlibs " $file"
46264642e01fSmrg	;;
46274642e01fSmrg
46284642e01fSmrg      *.la)
462935c4bbdfSmrg	func_resolve_sysroot "$file"
463035c4bbdfSmrg	file=$func_resolve_sysroot_result
463135c4bbdfSmrg
46324642e01fSmrg	# Check to see that this really is a libtool archive.
46334642e01fSmrg	func_lalib_unsafe_p "$file" \
463435c4bbdfSmrg	  || func_fatal_help "'$file' is not a valid libtool archive"
46354642e01fSmrg
46364642e01fSmrg	library_names=
46374642e01fSmrg	old_library=
46384642e01fSmrg	relink_command=
46394642e01fSmrg	func_source "$file"
46404642e01fSmrg
46414642e01fSmrg	# Add the libdir to current_libdirs if it is the destination.
46424642e01fSmrg	if test "X$destdir" = "X$libdir"; then
46434642e01fSmrg	  case "$current_libdirs " in
46444642e01fSmrg	  *" $libdir "*) ;;
464535c4bbdfSmrg	  *) func_append current_libdirs " $libdir" ;;
464605b261ecSmrg	  esac
46474642e01fSmrg	else
46484642e01fSmrg	  # Note the libdir as a future libdir.
46494642e01fSmrg	  case "$future_libdirs " in
46504642e01fSmrg	  *" $libdir "*) ;;
465135c4bbdfSmrg	  *) func_append future_libdirs " $libdir" ;;
46524642e01fSmrg	  esac
46534642e01fSmrg	fi
465405b261ecSmrg
46554642e01fSmrg	func_dirname "$file" "/" ""
465635c4bbdfSmrg	dir=$func_dirname_result
465735c4bbdfSmrg	func_append dir "$objdir"
46584642e01fSmrg
46594642e01fSmrg	if test -n "$relink_command"; then
466054b5899cSmrg	  # Strip any trailing slash from the destination.
466154b5899cSmrg	  func_stripname '' '/' "$libdir"
466254b5899cSmrg	  destlibdir=$func_stripname_result
466354b5899cSmrg
466454b5899cSmrg	  func_stripname '' '/' "$destdir"
466554b5899cSmrg	  s_destdir=$func_stripname_result
466654b5899cSmrg
46674642e01fSmrg	  # Determine the prefix the user has applied to our future dir.
466854b5899cSmrg	  inst_prefix_dir=`$ECHO "X$s_destdir" | $Xsed -e "s%$destlibdir\$%%"`
46694642e01fSmrg
46704642e01fSmrg	  # Don't allow the user to place us outside of our expected
46714642e01fSmrg	  # location b/c this prevents finding dependent libraries that
46724642e01fSmrg	  # are installed to the same prefix.
46734642e01fSmrg	  # At present, this check doesn't affect windows .dll's that
46744642e01fSmrg	  # are installed into $libdir/../bin (currently, that works fine)
46754642e01fSmrg	  # but it's something to keep an eye on.
46764642e01fSmrg	  test "$inst_prefix_dir" = "$destdir" && \
467735c4bbdfSmrg	    func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir"
46784642e01fSmrg
46794642e01fSmrg	  if test -n "$inst_prefix_dir"; then
46804642e01fSmrg	    # Stick the inst_prefix_dir data into the link command.
46816747b715Smrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
46824642e01fSmrg	  else
46836747b715Smrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
46844642e01fSmrg	  fi
46854642e01fSmrg
468635c4bbdfSmrg	  func_warning "relinking '$file'"
46874642e01fSmrg	  func_show_eval "$relink_command" \
468835c4bbdfSmrg	    'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"'
46894642e01fSmrg	fi
46904642e01fSmrg
46914642e01fSmrg	# See the names of the shared library.
46924642e01fSmrg	set dummy $library_names; shift
46934642e01fSmrg	if test -n "$1"; then
469435c4bbdfSmrg	  realname=$1
46954642e01fSmrg	  shift
46964642e01fSmrg
469735c4bbdfSmrg	  srcname=$realname
469835c4bbdfSmrg	  test -n "$relink_command" && srcname=${realname}T
46994642e01fSmrg
47004642e01fSmrg	  # Install the shared library and build the symlinks.
47016747b715Smrg	  func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
47024642e01fSmrg	      'exit $?'
470335c4bbdfSmrg	  tstripme=$stripme
47044642e01fSmrg	  case $host_os in
470554b5899cSmrg	  cygwin* | mingw* | windows* | pw32* | cegcc*)
47064642e01fSmrg	    case $realname in
47074642e01fSmrg	    *.dll.a)
470835c4bbdfSmrg	      tstripme=
470935c4bbdfSmrg	      ;;
471035c4bbdfSmrg	    esac
471135c4bbdfSmrg	    ;;
471235c4bbdfSmrg	  os2*)
471335c4bbdfSmrg	    case $realname in
471435c4bbdfSmrg	    *_dll.a)
471535c4bbdfSmrg	      tstripme=
47164642e01fSmrg	      ;;
47174642e01fSmrg	    esac
471805b261ecSmrg	    ;;
471905b261ecSmrg	  esac
47204642e01fSmrg	  if test -n "$tstripme" && test -n "$striplib"; then
47214642e01fSmrg	    func_show_eval "$striplib $destdir/$realname" 'exit $?'
472205b261ecSmrg	  fi
47234642e01fSmrg
47244642e01fSmrg	  if test "$#" -gt 0; then
47254642e01fSmrg	    # Delete the old symlinks, and create new ones.
472635c4bbdfSmrg	    # Try 'ln -sf' first, because the 'ln' binary might depend on
47274642e01fSmrg	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
47284642e01fSmrg	    # so we also need to try rm && ln -s.
47294642e01fSmrg	    for linkname
47304642e01fSmrg	    do
47314642e01fSmrg	      test "$linkname" != "$realname" \
47324642e01fSmrg		&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
473305b261ecSmrg	    done
473405b261ecSmrg	  fi
473505b261ecSmrg
47364642e01fSmrg	  # Do each command in the postinstall commands.
473735c4bbdfSmrg	  lib=$destdir/$realname
47384642e01fSmrg	  func_execute_cmds "$postinstall_cmds" 'exit $?'
473905b261ecSmrg	fi
474005b261ecSmrg
47414642e01fSmrg	# Install the pseudo-library for information purposes.
47424642e01fSmrg	func_basename "$file"
474335c4bbdfSmrg	name=$func_basename_result
474435c4bbdfSmrg	instname=$dir/${name}i
47454642e01fSmrg	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
474605b261ecSmrg
47474642e01fSmrg	# Maybe install the static library, too.
474835c4bbdfSmrg	test -n "$old_library" && func_append staticlibs " $dir/$old_library"
47494642e01fSmrg	;;
475005b261ecSmrg
47514642e01fSmrg      *.lo)
47524642e01fSmrg	# Install (i.e. copy) a libtool object.
475305b261ecSmrg
47544642e01fSmrg	# Figure out destination file name, if it wasn't already specified.
47554642e01fSmrg	if test -n "$destname"; then
475635c4bbdfSmrg	  destfile=$destdir/$destname
47574642e01fSmrg	else
47584642e01fSmrg	  func_basename "$file"
475935c4bbdfSmrg	  destfile=$func_basename_result
476035c4bbdfSmrg	  destfile=$destdir/$destfile
47614642e01fSmrg	fi
47624642e01fSmrg
47634642e01fSmrg	# Deduce the name of the destination old-style object file.
47644642e01fSmrg	case $destfile in
47654642e01fSmrg	*.lo)
47664642e01fSmrg	  func_lo2o "$destfile"
47674642e01fSmrg	  staticdest=$func_lo2o_result
47684642e01fSmrg	  ;;
47694642e01fSmrg	*.$objext)
477035c4bbdfSmrg	  staticdest=$destfile
47714642e01fSmrg	  destfile=
47724642e01fSmrg	  ;;
47734642e01fSmrg	*)
477435c4bbdfSmrg	  func_fatal_help "cannot copy a libtool object to '$destfile'"
47754642e01fSmrg	  ;;
477605b261ecSmrg	esac
477705b261ecSmrg
47784642e01fSmrg	# Install the libtool object if requested.
47794642e01fSmrg	test -n "$destfile" && \
47804642e01fSmrg	  func_show_eval "$install_prog $file $destfile" 'exit $?'
47814642e01fSmrg
47824642e01fSmrg	# Install the old object if enabled.
478335c4bbdfSmrg	if test yes = "$build_old_libs"; then
47844642e01fSmrg	  # Deduce the name of the old-style object file.
47854642e01fSmrg	  func_lo2o "$file"
47864642e01fSmrg	  staticobj=$func_lo2o_result
47874642e01fSmrg	  func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
478805b261ecSmrg	fi
47894642e01fSmrg	exit $EXIT_SUCCESS
47904642e01fSmrg	;;
479105b261ecSmrg
47924642e01fSmrg      *)
47934642e01fSmrg	# Figure out destination file name, if it wasn't already specified.
47944642e01fSmrg	if test -n "$destname"; then
479535c4bbdfSmrg	  destfile=$destdir/$destname
47964642e01fSmrg	else
47974642e01fSmrg	  func_basename "$file"
479835c4bbdfSmrg	  destfile=$func_basename_result
479935c4bbdfSmrg	  destfile=$destdir/$destfile
48004642e01fSmrg	fi
480105b261ecSmrg
48024642e01fSmrg	# If the file is missing, and there is a .exe on the end, strip it
48034642e01fSmrg	# because it is most likely a libtool script we actually want to
48044642e01fSmrg	# install
480535c4bbdfSmrg	stripped_ext=
48064642e01fSmrg	case $file in
48074642e01fSmrg	  *.exe)
48084642e01fSmrg	    if test ! -f "$file"; then
48094642e01fSmrg	      func_stripname '' '.exe' "$file"
48104642e01fSmrg	      file=$func_stripname_result
481135c4bbdfSmrg	      stripped_ext=.exe
48124642e01fSmrg	    fi
48134642e01fSmrg	    ;;
48144642e01fSmrg	esac
481505b261ecSmrg
48164642e01fSmrg	# Do a test to see if this is really a libtool program.
48174642e01fSmrg	case $host in
481854b5899cSmrg	*cygwin* | *mingw* | *windows*)
48194642e01fSmrg	    if func_ltwrapper_executable_p "$file"; then
48204642e01fSmrg	      func_ltwrapper_scriptname "$file"
48214642e01fSmrg	      wrapper=$func_ltwrapper_scriptname_result
48224642e01fSmrg	    else
48234642e01fSmrg	      func_stripname '' '.exe' "$file"
48244642e01fSmrg	      wrapper=$func_stripname_result
48254642e01fSmrg	    fi
48264642e01fSmrg	    ;;
48274642e01fSmrg	*)
48284642e01fSmrg	    wrapper=$file
48294642e01fSmrg	    ;;
48304642e01fSmrg	esac
48314642e01fSmrg	if func_ltwrapper_script_p "$wrapper"; then
48324642e01fSmrg	  notinst_deplibs=
48334642e01fSmrg	  relink_command=
483405b261ecSmrg
48354642e01fSmrg	  func_source "$wrapper"
48364642e01fSmrg
48374642e01fSmrg	  # Check the variables that should have been set.
48384642e01fSmrg	  test -z "$generated_by_libtool_version" && \
483935c4bbdfSmrg	    func_fatal_error "invalid libtool wrapper script '$wrapper'"
48404642e01fSmrg
484135c4bbdfSmrg	  finalize=:
48424642e01fSmrg	  for lib in $notinst_deplibs; do
48434642e01fSmrg	    # Check to see that each library is installed.
48444642e01fSmrg	    libdir=
48454642e01fSmrg	    if test -f "$lib"; then
48464642e01fSmrg	      func_source "$lib"
48474642e01fSmrg	    fi
484835c4bbdfSmrg	    libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'`
48494642e01fSmrg	    if test -n "$libdir" && test ! -f "$libfile"; then
485035c4bbdfSmrg	      func_warning "'$lib' has not been installed in '$libdir'"
485135c4bbdfSmrg	      finalize=false
48524642e01fSmrg	    fi
48534642e01fSmrg	  done
48544642e01fSmrg
48554642e01fSmrg	  relink_command=
48564642e01fSmrg	  func_source "$wrapper"
48574642e01fSmrg
48584642e01fSmrg	  outputname=
485935c4bbdfSmrg	  if test no = "$fast_install" && test -n "$relink_command"; then
48604642e01fSmrg	    $opt_dry_run || {
486135c4bbdfSmrg	      if $finalize; then
48624642e01fSmrg	        tmpdir=`func_mktempdir`
48634642e01fSmrg		func_basename "$file$stripped_ext"
486435c4bbdfSmrg		file=$func_basename_result
486535c4bbdfSmrg	        outputname=$tmpdir/$file
48664642e01fSmrg	        # Replace the output file specification.
48676747b715Smrg	        relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
48684642e01fSmrg
486935c4bbdfSmrg	        $opt_quiet || {
4870c82838c1Smrg	          func_quote_arg expand,pretty "$relink_command"
4871c82838c1Smrg		  eval "func_echo $func_quote_arg_result"
48724642e01fSmrg	        }
48734642e01fSmrg	        if eval "$relink_command"; then :
48744642e01fSmrg	          else
487535c4bbdfSmrg		  func_error "error: relink '$file' with the above command before installing it"
48764642e01fSmrg		  $opt_dry_run || ${RM}r "$tmpdir"
48774642e01fSmrg		  continue
48784642e01fSmrg	        fi
487935c4bbdfSmrg	        file=$outputname
48804642e01fSmrg	      else
488135c4bbdfSmrg	        func_warning "cannot relink '$file'"
48824642e01fSmrg	      fi
48834642e01fSmrg	    }
488405b261ecSmrg	  else
48854642e01fSmrg	    # Install the binary that we compiled earlier.
48866747b715Smrg	    file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
488705b261ecSmrg	  fi
48884642e01fSmrg	fi
488905b261ecSmrg
48904642e01fSmrg	# remove .exe since cygwin /usr/bin/install will append another
48914642e01fSmrg	# one anyway
48924642e01fSmrg	case $install_prog,$host in
48934642e01fSmrg	*/usr/bin/install*,*cygwin*)
48944642e01fSmrg	  case $file:$destfile in
48954642e01fSmrg	  *.exe:*.exe)
48964642e01fSmrg	    # this is ok
48974642e01fSmrg	    ;;
48984642e01fSmrg	  *.exe:*)
48994642e01fSmrg	    destfile=$destfile.exe
49004642e01fSmrg	    ;;
49014642e01fSmrg	  *:*.exe)
49024642e01fSmrg	    func_stripname '' '.exe' "$destfile"
49034642e01fSmrg	    destfile=$func_stripname_result
49044642e01fSmrg	    ;;
49054642e01fSmrg	  esac
490605b261ecSmrg	  ;;
490705b261ecSmrg	esac
49084642e01fSmrg	func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
49094642e01fSmrg	$opt_dry_run || if test -n "$outputname"; then
49104642e01fSmrg	  ${RM}r "$tmpdir"
49114642e01fSmrg	fi
49124642e01fSmrg	;;
49134642e01fSmrg      esac
49144642e01fSmrg    done
491505b261ecSmrg
49164642e01fSmrg    for file in $staticlibs; do
49174642e01fSmrg      func_basename "$file"
491835c4bbdfSmrg      name=$func_basename_result
49194642e01fSmrg
49204642e01fSmrg      # Set up the ranlib parameters.
492135c4bbdfSmrg      oldlib=$destdir/$name
492235c4bbdfSmrg      func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
492335c4bbdfSmrg      tool_oldlib=$func_to_tool_file_result
49244642e01fSmrg
49254642e01fSmrg      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
49264642e01fSmrg
49274642e01fSmrg      if test -n "$stripme" && test -n "$old_striplib"; then
492835c4bbdfSmrg	func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
49294642e01fSmrg      fi
49304642e01fSmrg
49314642e01fSmrg      # Do each command in the postinstall commands.
49324642e01fSmrg      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
49334642e01fSmrg    done
49344642e01fSmrg
49354642e01fSmrg    test -n "$future_libdirs" && \
493635c4bbdfSmrg      func_warning "remember to run '$progname --finish$future_libdirs'"
49374642e01fSmrg
49384642e01fSmrg    if test -n "$current_libdirs"; then
49394642e01fSmrg      # Maybe just do a dry run.
49404642e01fSmrg      $opt_dry_run && current_libdirs=" -n$current_libdirs"
494135c4bbdfSmrg      exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs'
49424642e01fSmrg    else
49434642e01fSmrg      exit $EXIT_SUCCESS
49444642e01fSmrg    fi
49454642e01fSmrg}
49464642e01fSmrg
494735c4bbdfSmrgtest install = "$opt_mode" && func_mode_install ${1+"$@"}
49484642e01fSmrg
49494642e01fSmrg
49504642e01fSmrg# func_generate_dlsyms outputname originator pic_p
49514642e01fSmrg# Extract symbols from dlprefiles and create ${outputname}S.o with
49524642e01fSmrg# a dlpreopen symbol table.
49534642e01fSmrgfunc_generate_dlsyms ()
49544642e01fSmrg{
495535c4bbdfSmrg    $debug_cmd
495635c4bbdfSmrg
495735c4bbdfSmrg    my_outputname=$1
495835c4bbdfSmrg    my_originator=$2
495935c4bbdfSmrg    my_pic_p=${3-false}
496035c4bbdfSmrg    my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'`
49614642e01fSmrg    my_dlsyms=
49624642e01fSmrg
496335c4bbdfSmrg    if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
49644642e01fSmrg      if test -n "$NM" && test -n "$global_symbol_pipe"; then
496535c4bbdfSmrg	my_dlsyms=${my_outputname}S.c
49664642e01fSmrg      else
49674642e01fSmrg	func_error "not configured to extract global symbols from dlpreopened files"
49684642e01fSmrg      fi
49694642e01fSmrg    fi
49704642e01fSmrg
49714642e01fSmrg    if test -n "$my_dlsyms"; then
49724642e01fSmrg      case $my_dlsyms in
49734642e01fSmrg      "") ;;
49744642e01fSmrg      *.c)
49754642e01fSmrg	# Discover the nlist of each of the dlfiles.
497635c4bbdfSmrg	nlist=$output_objdir/$my_outputname.nm
49774642e01fSmrg
49784642e01fSmrg	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
49794642e01fSmrg
49804642e01fSmrg	# Parse the name list into a source file.
49814642e01fSmrg	func_verbose "creating $output_objdir/$my_dlsyms"
49824642e01fSmrg
49834642e01fSmrg	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
498435c4bbdfSmrg/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */
498535c4bbdfSmrg/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */
49864642e01fSmrg
49874642e01fSmrg#ifdef __cplusplus
49884642e01fSmrgextern \"C\" {
49894642e01fSmrg#endif
49904642e01fSmrg
499135c4bbdfSmrg#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
49926747b715Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
49936747b715Smrg#endif
49946747b715Smrg
499535c4bbdfSmrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
499635c4bbdfSmrg#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE
499735c4bbdfSmrg/* DATA imports from DLLs on WIN32 can't be const, because runtime
499835c4bbdfSmrg   relocations are performed -- see ld's documentation on pseudo-relocs.  */
499935c4bbdfSmrg# define LT_DLSYM_CONST
500035c4bbdfSmrg#elif defined __osf__
500135c4bbdfSmrg/* This system does not cope well with relocations in const data.  */
500235c4bbdfSmrg# define LT_DLSYM_CONST
500335c4bbdfSmrg#else
500435c4bbdfSmrg# define LT_DLSYM_CONST const
500535c4bbdfSmrg#endif
500635c4bbdfSmrg
500735c4bbdfSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
500835c4bbdfSmrg
50094642e01fSmrg/* External symbol declarations for the compiler. */\
50104642e01fSmrg"
50114642e01fSmrg
501235c4bbdfSmrg	if test yes = "$dlself"; then
501335c4bbdfSmrg	  func_verbose "generating symbol list for '$output'"
50144642e01fSmrg
50154642e01fSmrg	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
50164642e01fSmrg
50174642e01fSmrg	  # Add our own program objects to the symbol list.
50186747b715Smrg	  progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
50194642e01fSmrg	  for progfile in $progfiles; do
502035c4bbdfSmrg	    func_to_tool_file "$progfile" func_convert_file_msys_to_w32
502135c4bbdfSmrg	    func_verbose "extracting global C symbols from '$func_to_tool_file_result'"
502235c4bbdfSmrg	    $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
50234642e01fSmrg	  done
50244642e01fSmrg
50254642e01fSmrg	  if test -n "$exclude_expsyms"; then
50264642e01fSmrg	    $opt_dry_run || {
50274642e01fSmrg	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
50284642e01fSmrg	      eval '$MV "$nlist"T "$nlist"'
50294642e01fSmrg	    }
503005b261ecSmrg	  fi
50314642e01fSmrg
50324642e01fSmrg	  if test -n "$export_symbols_regex"; then
50334642e01fSmrg	    $opt_dry_run || {
50344642e01fSmrg	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
50354642e01fSmrg	      eval '$MV "$nlist"T "$nlist"'
50364642e01fSmrg	    }
50374642e01fSmrg	  fi
50384642e01fSmrg
50394642e01fSmrg	  # Prepare the list of exported symbols
50404642e01fSmrg	  if test -z "$export_symbols"; then
504135c4bbdfSmrg	    export_symbols=$output_objdir/$outputname.exp
50424642e01fSmrg	    $opt_dry_run || {
50434642e01fSmrg	      $RM $export_symbols
504435c4bbdfSmrg	      eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
50454642e01fSmrg	      case $host in
504654b5899cSmrg	      *cygwin* | *mingw* | *windows* | *cegcc* )
50474642e01fSmrg                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
50484642e01fSmrg                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
50494642e01fSmrg	        ;;
50504642e01fSmrg	      esac
50514642e01fSmrg	    }
505205b261ecSmrg	  else
50534642e01fSmrg	    $opt_dry_run || {
505435c4bbdfSmrg	      eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
50554642e01fSmrg	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
50564642e01fSmrg	      eval '$MV "$nlist"T "$nlist"'
50574642e01fSmrg	      case $host in
505854b5899cSmrg	        *cygwin* | *mingw* | *windows* | *cegcc* )
50594642e01fSmrg	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
50604642e01fSmrg	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
50614642e01fSmrg	          ;;
50624642e01fSmrg	      esac
50634642e01fSmrg	    }
506405b261ecSmrg	  fi
50654642e01fSmrg	fi
506605b261ecSmrg
50674642e01fSmrg	for dlprefile in $dlprefiles; do
506835c4bbdfSmrg	  func_verbose "extracting global C symbols from '$dlprefile'"
50694642e01fSmrg	  func_basename "$dlprefile"
507035c4bbdfSmrg	  name=$func_basename_result
507135c4bbdfSmrg          case $host in
507254b5899cSmrg	    *cygwin* | *mingw* | *windows* | *cegcc* )
507335c4bbdfSmrg	      # if an import library, we need to obtain dlname
507435c4bbdfSmrg	      if func_win32_import_lib_p "$dlprefile"; then
507535c4bbdfSmrg	        func_tr_sh "$dlprefile"
507635c4bbdfSmrg	        eval "curr_lafile=\$libfile_$func_tr_sh_result"
507735c4bbdfSmrg	        dlprefile_dlbasename=
507835c4bbdfSmrg	        if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
507935c4bbdfSmrg	          # Use subshell, to avoid clobbering current variable values
508035c4bbdfSmrg	          dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
508135c4bbdfSmrg	          if test -n "$dlprefile_dlname"; then
508235c4bbdfSmrg	            func_basename "$dlprefile_dlname"
508335c4bbdfSmrg	            dlprefile_dlbasename=$func_basename_result
508435c4bbdfSmrg	          else
508535c4bbdfSmrg	            # no lafile. user explicitly requested -dlpreopen <import library>.
508635c4bbdfSmrg	            $sharedlib_from_linklib_cmd "$dlprefile"
508735c4bbdfSmrg	            dlprefile_dlbasename=$sharedlib_from_linklib_result
508835c4bbdfSmrg	          fi
508935c4bbdfSmrg	        fi
509035c4bbdfSmrg	        $opt_dry_run || {
509135c4bbdfSmrg	          if test -n "$dlprefile_dlbasename"; then
509235c4bbdfSmrg	            eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
509335c4bbdfSmrg	          else
509435c4bbdfSmrg	            func_warning "Could not compute DLL name from $name"
509535c4bbdfSmrg	            eval '$ECHO ": $name " >> "$nlist"'
509635c4bbdfSmrg	          fi
509735c4bbdfSmrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
509854b5899cSmrg	          case $host in
509954b5899cSmrg	            i[3456]86-*-mingw32*)
510054b5899cSmrg	              eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
510154b5899cSmrg	                $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
510254b5899cSmrg	            ;;
510354b5899cSmrg	            *)
510454b5899cSmrg	              eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
510554b5899cSmrg	                $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/__nm_//' >> '$nlist'"
510654b5899cSmrg	            ;;
510754b5899cSmrg	          esac
510835c4bbdfSmrg	        }
510935c4bbdfSmrg	      else # not an import lib
511035c4bbdfSmrg	        $opt_dry_run || {
511135c4bbdfSmrg	          eval '$ECHO ": $name " >> "$nlist"'
511235c4bbdfSmrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
511335c4bbdfSmrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
511435c4bbdfSmrg	        }
511535c4bbdfSmrg	      fi
511635c4bbdfSmrg	    ;;
511735c4bbdfSmrg	    *)
511835c4bbdfSmrg	      $opt_dry_run || {
511935c4bbdfSmrg	        eval '$ECHO ": $name " >> "$nlist"'
512035c4bbdfSmrg	        func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
512135c4bbdfSmrg	        eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
512235c4bbdfSmrg	      }
512335c4bbdfSmrg	    ;;
512435c4bbdfSmrg          esac
51254642e01fSmrg	done
51264642e01fSmrg
51274642e01fSmrg	$opt_dry_run || {
51284642e01fSmrg	  # Make sure we have at least an empty file.
51294642e01fSmrg	  test -f "$nlist" || : > "$nlist"
51304642e01fSmrg
51314642e01fSmrg	  if test -n "$exclude_expsyms"; then
51324642e01fSmrg	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
51334642e01fSmrg	    $MV "$nlist"T "$nlist"
513405b261ecSmrg	  fi
51354642e01fSmrg
51364642e01fSmrg	  # Try sorting and uniquifying the output.
51374642e01fSmrg	  if $GREP -v "^: " < "$nlist" |
51384642e01fSmrg	      if sort -k 3 </dev/null >/dev/null 2>&1; then
51394642e01fSmrg		sort -k 3
51404642e01fSmrg	      else
51414642e01fSmrg		sort +2
51424642e01fSmrg	      fi |
51434642e01fSmrg	      uniq > "$nlist"S; then
51444642e01fSmrg	    :
514505b261ecSmrg	  else
51464642e01fSmrg	    $GREP -v "^: " < "$nlist" > "$nlist"S
514705b261ecSmrg	  fi
514805b261ecSmrg
51494642e01fSmrg	  if test -f "$nlist"S; then
51504642e01fSmrg	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
515105b261ecSmrg	  else
51526747b715Smrg	    echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
515305b261ecSmrg	  fi
515405b261ecSmrg
515535c4bbdfSmrg	  func_show_eval '$RM "${nlist}I"'
515635c4bbdfSmrg	  if test -n "$global_symbol_to_import"; then
515735c4bbdfSmrg	    eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I'
515835c4bbdfSmrg	  fi
515935c4bbdfSmrg
51606747b715Smrg	  echo >> "$output_objdir/$my_dlsyms" "\
516105b261ecSmrg
51624642e01fSmrg/* The mapping between symbol names and symbols.  */
51634642e01fSmrgtypedef struct {
51644642e01fSmrg  const char *name;
51654642e01fSmrg  void *address;
51664642e01fSmrg} lt_dlsymlist;
516735c4bbdfSmrgextern LT_DLSYM_CONST lt_dlsymlist
516835c4bbdfSmrglt_${my_prefix}_LTX_preloaded_symbols[];\
5169475c125cSmrg"
517035c4bbdfSmrg
517135c4bbdfSmrg	  if test -s "$nlist"I; then
5172475c125cSmrg	    echo >> "$output_objdir/$my_dlsyms" "\
517335c4bbdfSmrgstatic void lt_syminit(void)
517435c4bbdfSmrg{
517535c4bbdfSmrg  LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols;
517635c4bbdfSmrg  for (; symbol->name; ++symbol)
517735c4bbdfSmrg    {"
517835c4bbdfSmrg	    $SED 's/.*/      if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms"
5179475c125cSmrg	    echo >> "$output_objdir/$my_dlsyms" "\
518035c4bbdfSmrg    }
518135c4bbdfSmrg}"
518235c4bbdfSmrg	  fi
5183475c125cSmrg	  echo >> "$output_objdir/$my_dlsyms" "\
518435c4bbdfSmrgLT_DLSYM_CONST lt_dlsymlist
51854642e01fSmrglt_${my_prefix}_LTX_preloaded_symbols[] =
518635c4bbdfSmrg{ {\"$my_originator\", (void *) 0},"
518735c4bbdfSmrg
518835c4bbdfSmrg	  if test -s "$nlist"I; then
518935c4bbdfSmrg	    echo >> "$output_objdir/$my_dlsyms" "\
519035c4bbdfSmrg  {\"@INIT@\", (void *) &lt_syminit},"
519135c4bbdfSmrg	  fi
519205b261ecSmrg
51934642e01fSmrg	  case $need_lib_prefix in
51944642e01fSmrg	  no)
51954642e01fSmrg	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
51964642e01fSmrg	    ;;
51974642e01fSmrg	  *)
51984642e01fSmrg	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
51994642e01fSmrg	    ;;
52004642e01fSmrg	  esac
52016747b715Smrg	  echo >> "$output_objdir/$my_dlsyms" "\
52024642e01fSmrg  {0, (void *) 0}
52034642e01fSmrg};
520405b261ecSmrg
52054642e01fSmrg/* This works around a problem in FreeBSD linker */
52064642e01fSmrg#ifdef FREEBSD_WORKAROUND
52074642e01fSmrgstatic const void *lt_preloaded_setup() {
52084642e01fSmrg  return lt_${my_prefix}_LTX_preloaded_symbols;
52094642e01fSmrg}
52104642e01fSmrg#endif
52114642e01fSmrg
52124642e01fSmrg#ifdef __cplusplus
52134642e01fSmrg}
52144642e01fSmrg#endif\
52154642e01fSmrg"
52164642e01fSmrg	} # !$opt_dry_run
52174642e01fSmrg
52184642e01fSmrg	pic_flag_for_symtable=
52194642e01fSmrg	case "$compile_command " in
52204642e01fSmrg	*" -static "*) ;;
52214642e01fSmrg	*)
52224642e01fSmrg	  case $host in
52234642e01fSmrg	  # compiling the symbol table file with pic_flag works around
52244642e01fSmrg	  # a FreeBSD bug that causes programs to crash when -lm is
52254642e01fSmrg	  # linked before any other PIC object.  But we must not use
52264642e01fSmrg	  # pic_flag when linking with -static.  The problem exists in
52274642e01fSmrg	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
522835c4bbdfSmrg	  *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
52294642e01fSmrg	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
52304642e01fSmrg	  *-*-hpux*)
52314642e01fSmrg	    pic_flag_for_symtable=" $pic_flag"  ;;
52324642e01fSmrg	  *)
523335c4bbdfSmrg	    $my_pic_p && pic_flag_for_symtable=" $pic_flag"
52344642e01fSmrg	    ;;
52354642e01fSmrg	  esac
52364642e01fSmrg	  ;;
52374642e01fSmrg	esac
52384642e01fSmrg	symtab_cflags=
52394642e01fSmrg	for arg in $LTCFLAGS; do
52404642e01fSmrg	  case $arg in
52414642e01fSmrg	  -pie | -fpie | -fPIE) ;;
524235c4bbdfSmrg	  *) func_append symtab_cflags " $arg" ;;
52434642e01fSmrg	  esac
52444642e01fSmrg	done
524505b261ecSmrg
52464642e01fSmrg	# Now compile the dynamic symbol file.
52474642e01fSmrg	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
524805b261ecSmrg
52494642e01fSmrg	# Clean up the generated files.
525035c4bbdfSmrg	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"'
525105b261ecSmrg
52524642e01fSmrg	# Transform the symbol file into the correct name.
525335c4bbdfSmrg	symfileobj=$output_objdir/${my_outputname}S.$objext
52544642e01fSmrg	case $host in
525554b5899cSmrg	*cygwin* | *mingw* | *windows* | *cegcc* )
52564642e01fSmrg	  if test -f "$output_objdir/$my_outputname.def"; then
52576747b715Smrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
52586747b715Smrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
52594642e01fSmrg	  else
52606747b715Smrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
52616747b715Smrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
526205b261ecSmrg	  fi
52634642e01fSmrg	  ;;
52644642e01fSmrg	*)
52656747b715Smrg	  compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
52666747b715Smrg	  finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
52674642e01fSmrg	  ;;
52684642e01fSmrg	esac
52694642e01fSmrg	;;
52704642e01fSmrg      *)
527135c4bbdfSmrg	func_fatal_error "unknown suffix for '$my_dlsyms'"
52724642e01fSmrg	;;
52734642e01fSmrg      esac
52744642e01fSmrg    else
52754642e01fSmrg      # We keep going just in case the user didn't refer to
52764642e01fSmrg      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
52774642e01fSmrg      # really was required.
527805b261ecSmrg
52794642e01fSmrg      # Nullify the symbol file.
52806747b715Smrg      compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
52816747b715Smrg      finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
52824642e01fSmrg    fi
52834642e01fSmrg}
528405b261ecSmrg
528535c4bbdfSmrg# func_cygming_gnu_implib_p ARG
528635c4bbdfSmrg# This predicate returns with zero status (TRUE) if
528735c4bbdfSmrg# ARG is a GNU/binutils-style import library. Returns
528835c4bbdfSmrg# with nonzero status (FALSE) otherwise.
528935c4bbdfSmrgfunc_cygming_gnu_implib_p ()
529035c4bbdfSmrg{
529135c4bbdfSmrg  $debug_cmd
529235c4bbdfSmrg
529335c4bbdfSmrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
529435c4bbdfSmrg  func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'`
529535c4bbdfSmrg  test -n "$func_cygming_gnu_implib_tmp"
529635c4bbdfSmrg}
529735c4bbdfSmrg
529835c4bbdfSmrg# func_cygming_ms_implib_p ARG
529935c4bbdfSmrg# This predicate returns with zero status (TRUE) if
530035c4bbdfSmrg# ARG is an MS-style import library. Returns
530135c4bbdfSmrg# with nonzero status (FALSE) otherwise.
530235c4bbdfSmrgfunc_cygming_ms_implib_p ()
530335c4bbdfSmrg{
530435c4bbdfSmrg  $debug_cmd
530535c4bbdfSmrg
530635c4bbdfSmrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
530735c4bbdfSmrg  func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
530835c4bbdfSmrg  test -n "$func_cygming_ms_implib_tmp"
530935c4bbdfSmrg}
531035c4bbdfSmrg
53114642e01fSmrg# func_win32_libid arg
53124642e01fSmrg# return the library type of file 'arg'
53134642e01fSmrg#
53144642e01fSmrg# Need a lot of goo to handle *both* DLLs and import libs
53154642e01fSmrg# Has to be a shell function in order to 'eat' the argument
53164642e01fSmrg# that is supplied when $file_magic_command is called.
53176747b715Smrg# Despite the name, also deal with 64 bit binaries.
53184642e01fSmrgfunc_win32_libid ()
53194642e01fSmrg{
532035c4bbdfSmrg  $debug_cmd
532135c4bbdfSmrg
532235c4bbdfSmrg  win32_libid_type=unknown
53234642e01fSmrg  win32_fileres=`file -L $1 2>/dev/null`
53244642e01fSmrg  case $win32_fileres in
53254642e01fSmrg  *ar\ archive\ import\ library*) # definitely import
53264642e01fSmrg    win32_libid_type="x86 archive import"
53274642e01fSmrg    ;;
53284642e01fSmrg  *ar\ archive*) # could be an import, or static
53296747b715Smrg    # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
53304642e01fSmrg    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
533154b5899cSmrg       $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64|pe-aarch64)' >/dev/null; then
533235c4bbdfSmrg      case $nm_interface in
533335c4bbdfSmrg      "MS dumpbin")
533435c4bbdfSmrg	if func_cygming_ms_implib_p "$1" ||
533535c4bbdfSmrg	   func_cygming_gnu_implib_p "$1"
533635c4bbdfSmrg	then
533735c4bbdfSmrg	  win32_nmres=import
533835c4bbdfSmrg	else
533935c4bbdfSmrg	  win32_nmres=
534035c4bbdfSmrg	fi
534135c4bbdfSmrg	;;
534235c4bbdfSmrg      *)
534335c4bbdfSmrg	func_to_tool_file "$1" func_convert_file_msys_to_w32
534435c4bbdfSmrg	win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
534535c4bbdfSmrg	  $SED -n -e '
53464642e01fSmrg	    1,100{
53474642e01fSmrg		/ I /{
534835c4bbdfSmrg		    s|.*|import|
53494642e01fSmrg		    p
53504642e01fSmrg		    q
53514642e01fSmrg		}
53524642e01fSmrg	    }'`
535335c4bbdfSmrg	;;
535435c4bbdfSmrg      esac
53554642e01fSmrg      case $win32_nmres in
53564642e01fSmrg      import*)  win32_libid_type="x86 archive import";;
53574642e01fSmrg      *)        win32_libid_type="x86 archive static";;
53584642e01fSmrg      esac
53594642e01fSmrg    fi
53604642e01fSmrg    ;;
53614642e01fSmrg  *DLL*)
53624642e01fSmrg    win32_libid_type="x86 DLL"
53634642e01fSmrg    ;;
53644642e01fSmrg  *executable*) # but shell scripts are "executable" too...
53654642e01fSmrg    case $win32_fileres in
53664642e01fSmrg    *MS\ Windows\ PE\ Intel*)
53674642e01fSmrg      win32_libid_type="x86 DLL"
53684642e01fSmrg      ;;
53694642e01fSmrg    esac
53704642e01fSmrg    ;;
53714642e01fSmrg  esac
53724642e01fSmrg  $ECHO "$win32_libid_type"
53734642e01fSmrg}
537405b261ecSmrg
537535c4bbdfSmrg# func_cygming_dll_for_implib ARG
537635c4bbdfSmrg#
537735c4bbdfSmrg# Platform-specific function to extract the
537835c4bbdfSmrg# name of the DLL associated with the specified
537935c4bbdfSmrg# import library ARG.
538035c4bbdfSmrg# Invoked by eval'ing the libtool variable
538135c4bbdfSmrg#    $sharedlib_from_linklib_cmd
538235c4bbdfSmrg# Result is available in the variable
538335c4bbdfSmrg#    $sharedlib_from_linklib_result
538435c4bbdfSmrgfunc_cygming_dll_for_implib ()
538535c4bbdfSmrg{
538635c4bbdfSmrg  $debug_cmd
538735c4bbdfSmrg
538835c4bbdfSmrg  sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
538935c4bbdfSmrg}
539035c4bbdfSmrg
539135c4bbdfSmrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
539235c4bbdfSmrg#
539335c4bbdfSmrg# The is the core of a fallback implementation of a
539435c4bbdfSmrg# platform-specific function to extract the name of the
539535c4bbdfSmrg# DLL associated with the specified import library LIBNAME.
539635c4bbdfSmrg#
539735c4bbdfSmrg# SECTION_NAME is either .idata$6 or .idata$7, depending
539835c4bbdfSmrg# on the platform and compiler that created the implib.
539935c4bbdfSmrg#
540035c4bbdfSmrg# Echos the name of the DLL associated with the
540135c4bbdfSmrg# specified import library.
540235c4bbdfSmrgfunc_cygming_dll_for_implib_fallback_core ()
540335c4bbdfSmrg{
540435c4bbdfSmrg  $debug_cmd
540535c4bbdfSmrg
540635c4bbdfSmrg  match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
540735c4bbdfSmrg  $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
540835c4bbdfSmrg    $SED '/^Contents of section '"$match_literal"':/{
540935c4bbdfSmrg      # Place marker at beginning of archive member dllname section
541035c4bbdfSmrg      s/.*/====MARK====/
541135c4bbdfSmrg      p
541235c4bbdfSmrg      d
541335c4bbdfSmrg    }
541435c4bbdfSmrg    # These lines can sometimes be longer than 43 characters, but
541535c4bbdfSmrg    # are always uninteresting
541635c4bbdfSmrg    /:[	 ]*file format pe[i]\{,1\}-/d
541735c4bbdfSmrg    /^In archive [^:]*:/d
541835c4bbdfSmrg    # Ensure marker is printed
541935c4bbdfSmrg    /^====MARK====/p
542035c4bbdfSmrg    # Remove all lines with less than 43 characters
542135c4bbdfSmrg    /^.\{43\}/!d
542235c4bbdfSmrg    # From remaining lines, remove first 43 characters
542335c4bbdfSmrg    s/^.\{43\}//' |
542435c4bbdfSmrg    $SED -n '
542535c4bbdfSmrg      # Join marker and all lines until next marker into a single line
542635c4bbdfSmrg      /^====MARK====/ b para
542735c4bbdfSmrg      H
542835c4bbdfSmrg      $ b para
542935c4bbdfSmrg      b
543035c4bbdfSmrg      :para
543135c4bbdfSmrg      x
543235c4bbdfSmrg      s/\n//g
543335c4bbdfSmrg      # Remove the marker
543435c4bbdfSmrg      s/^====MARK====//
543535c4bbdfSmrg      # Remove trailing dots and whitespace
543635c4bbdfSmrg      s/[\. \t]*$//
543735c4bbdfSmrg      # Print
543835c4bbdfSmrg      /./p' |
543935c4bbdfSmrg    # we now have a list, one entry per line, of the stringified
544035c4bbdfSmrg    # contents of the appropriate section of all members of the
544135c4bbdfSmrg    # archive that possess that section. Heuristic: eliminate
544235c4bbdfSmrg    # all those that have a first or second character that is
544335c4bbdfSmrg    # a '.' (that is, objdump's representation of an unprintable
544435c4bbdfSmrg    # character.) This should work for all archives with less than
544535c4bbdfSmrg    # 0x302f exports -- but will fail for DLLs whose name actually
544635c4bbdfSmrg    # begins with a literal '.' or a single character followed by
544735c4bbdfSmrg    # a '.'.
544835c4bbdfSmrg    #
544935c4bbdfSmrg    # Of those that remain, print the first one.
545035c4bbdfSmrg    $SED -e '/^\./d;/^.\./d;q'
545135c4bbdfSmrg}
545235c4bbdfSmrg
545335c4bbdfSmrg# func_cygming_dll_for_implib_fallback ARG
545435c4bbdfSmrg# Platform-specific function to extract the
545535c4bbdfSmrg# name of the DLL associated with the specified
545635c4bbdfSmrg# import library ARG.
545735c4bbdfSmrg#
545835c4bbdfSmrg# This fallback implementation is for use when $DLLTOOL
545935c4bbdfSmrg# does not support the --identify-strict option.
546035c4bbdfSmrg# Invoked by eval'ing the libtool variable
546135c4bbdfSmrg#    $sharedlib_from_linklib_cmd
546235c4bbdfSmrg# Result is available in the variable
546335c4bbdfSmrg#    $sharedlib_from_linklib_result
546435c4bbdfSmrgfunc_cygming_dll_for_implib_fallback ()
546535c4bbdfSmrg{
546635c4bbdfSmrg  $debug_cmd
546735c4bbdfSmrg
546835c4bbdfSmrg  if func_cygming_gnu_implib_p "$1"; then
546935c4bbdfSmrg    # binutils import library
547035c4bbdfSmrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
547135c4bbdfSmrg  elif func_cygming_ms_implib_p "$1"; then
547235c4bbdfSmrg    # ms-generated import library
547335c4bbdfSmrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
547435c4bbdfSmrg  else
547535c4bbdfSmrg    # unknown
547635c4bbdfSmrg    sharedlib_from_linklib_result=
547735c4bbdfSmrg  fi
547835c4bbdfSmrg}
547905b261ecSmrg
548005b261ecSmrg
54814642e01fSmrg# func_extract_an_archive dir oldlib
54824642e01fSmrgfunc_extract_an_archive ()
54834642e01fSmrg{
548435c4bbdfSmrg    $debug_cmd
548535c4bbdfSmrg
548635c4bbdfSmrg    f_ex_an_ar_dir=$1; shift
548735c4bbdfSmrg    f_ex_an_ar_oldlib=$1
548835c4bbdfSmrg    if test yes = "$lock_old_archive_extraction"; then
54896747b715Smrg      lockfile=$f_ex_an_ar_oldlib.lock
54906747b715Smrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
54916747b715Smrg	func_echo "Waiting for $lockfile to be removed"
54926747b715Smrg	sleep 2
54936747b715Smrg      done
54946747b715Smrg    fi
54956747b715Smrg    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
54966747b715Smrg		   'stat=$?; rm -f "$lockfile"; exit $stat'
549735c4bbdfSmrg    if test yes = "$lock_old_archive_extraction"; then
54986747b715Smrg      $opt_dry_run || rm -f "$lockfile"
54996747b715Smrg    fi
55004642e01fSmrg    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
55014642e01fSmrg     :
55024642e01fSmrg    else
55034642e01fSmrg      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
55044642e01fSmrg    fi
55054642e01fSmrg}
550605b261ecSmrg
550705b261ecSmrg
55084642e01fSmrg# func_extract_archives gentop oldlib ...
55094642e01fSmrgfunc_extract_archives ()
55104642e01fSmrg{
551135c4bbdfSmrg    $debug_cmd
551235c4bbdfSmrg
551335c4bbdfSmrg    my_gentop=$1; shift
55144642e01fSmrg    my_oldlibs=${1+"$@"}
551535c4bbdfSmrg    my_oldobjs=
551635c4bbdfSmrg    my_xlib=
551735c4bbdfSmrg    my_xabs=
551835c4bbdfSmrg    my_xdir=
551905b261ecSmrg
55204642e01fSmrg    for my_xlib in $my_oldlibs; do
55214642e01fSmrg      # Extract the objects.
55224642e01fSmrg      case $my_xlib in
552335c4bbdfSmrg	[\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;;
55244642e01fSmrg	*) my_xabs=`pwd`"/$my_xlib" ;;
55254642e01fSmrg      esac
55264642e01fSmrg      func_basename "$my_xlib"
552735c4bbdfSmrg      my_xlib=$func_basename_result
55284642e01fSmrg      my_xlib_u=$my_xlib
55294642e01fSmrg      while :; do
55304642e01fSmrg        case " $extracted_archives " in
55314642e01fSmrg	*" $my_xlib_u "*)
55324642e01fSmrg	  func_arith $extracted_serial + 1
55334642e01fSmrg	  extracted_serial=$func_arith_result
55344642e01fSmrg	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
55354642e01fSmrg	*) break ;;
55364642e01fSmrg	esac
55374642e01fSmrg      done
55384642e01fSmrg      extracted_archives="$extracted_archives $my_xlib_u"
553935c4bbdfSmrg      my_xdir=$my_gentop/$my_xlib_u
554005b261ecSmrg
55414642e01fSmrg      func_mkdir_p "$my_xdir"
554205b261ecSmrg
55434642e01fSmrg      case $host in
55444642e01fSmrg      *-darwin*)
55454642e01fSmrg	func_verbose "Extracting $my_xabs"
55464642e01fSmrg	# Do not bother doing anything if just a dry run
55474642e01fSmrg	$opt_dry_run || {
55484642e01fSmrg	  darwin_orig_dir=`pwd`
55494642e01fSmrg	  cd $my_xdir || exit $?
55504642e01fSmrg	  darwin_archive=$my_xabs
55514642e01fSmrg	  darwin_curdir=`pwd`
555235c4bbdfSmrg	  func_basename "$darwin_archive"
555335c4bbdfSmrg	  darwin_base_archive=$func_basename_result
55544642e01fSmrg	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
55554642e01fSmrg	  if test -n "$darwin_arches"; then
55564642e01fSmrg	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
55574642e01fSmrg	    darwin_arch=
55584642e01fSmrg	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
555935c4bbdfSmrg	    for darwin_arch in  $darwin_arches; do
556035c4bbdfSmrg	      func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch"
556135c4bbdfSmrg	      $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive"
556235c4bbdfSmrg	      cd "unfat-$$/$darwin_base_archive-$darwin_arch"
556335c4bbdfSmrg	      func_extract_an_archive "`pwd`" "$darwin_base_archive"
55644642e01fSmrg	      cd "$darwin_curdir"
556535c4bbdfSmrg	      $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive"
55664642e01fSmrg	    done # $darwin_arches
55674642e01fSmrg            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
556835c4bbdfSmrg	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u`
55694642e01fSmrg	    darwin_file=
55704642e01fSmrg	    darwin_files=
55714642e01fSmrg	    for darwin_file in $darwin_filelist; do
55726747b715Smrg	      darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
55734642e01fSmrg	      $LIPO -create -output "$darwin_file" $darwin_files
55744642e01fSmrg	    done # $darwin_filelist
55754642e01fSmrg	    $RM -rf unfat-$$
55764642e01fSmrg	    cd "$darwin_orig_dir"
557705b261ecSmrg	  else
55784642e01fSmrg	    cd $darwin_orig_dir
55794642e01fSmrg	    func_extract_an_archive "$my_xdir" "$my_xabs"
55804642e01fSmrg	  fi # $darwin_arches
55814642e01fSmrg	} # !$opt_dry_run
55824642e01fSmrg	;;
55834642e01fSmrg      *)
55844642e01fSmrg        func_extract_an_archive "$my_xdir" "$my_xabs"
55854642e01fSmrg	;;
55864642e01fSmrg      esac
55876747b715Smrg      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
55884642e01fSmrg    done
558905b261ecSmrg
559035c4bbdfSmrg    func_extract_archives_result=$my_oldobjs
55914642e01fSmrg}
559205b261ecSmrg
559305b261ecSmrg
55946747b715Smrg# func_emit_wrapper [arg=no]
55956747b715Smrg#
55966747b715Smrg# Emit a libtool wrapper script on stdout.
55976747b715Smrg# Don't directly open a file because we may want to
559854b5899cSmrg# incorporate the script contents within a cygwin/mingw/windows
55996747b715Smrg# wrapper executable.  Must ONLY be called from within
56006747b715Smrg# func_mode_link because it depends on a number of variables
56016747b715Smrg# set therein.
56024642e01fSmrg#
56036747b715Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
56046747b715Smrg# variable will take.  If 'yes', then the emitted script
560535c4bbdfSmrg# will assume that the directory where it is stored is
560654b5899cSmrg# the $objdir directory.  This is a cygwin/mingw/windows-specific
56076747b715Smrg# behavior.
56086747b715Smrgfunc_emit_wrapper ()
56094642e01fSmrg{
56106747b715Smrg	func_emit_wrapper_arg1=${1-no}
561105b261ecSmrg
56124642e01fSmrg	$ECHO "\
56134642e01fSmrg#! $SHELL
561405b261ecSmrg
56154642e01fSmrg# $output - temporary wrapper script for $objdir/$outputname
561635c4bbdfSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
56174642e01fSmrg#
56184642e01fSmrg# The $output program cannot be directly executed until all the libtool
56194642e01fSmrg# libraries that it depends on are installed.
56204642e01fSmrg#
56214642e01fSmrg# This wrapper script should never be moved out of the build directory.
56224642e01fSmrg# If it is, it will not operate correctly.
562305b261ecSmrg
56244642e01fSmrg# Sed substitution that helps us do robust quoting.  It backslashifies
56254642e01fSmrg# metacharacters that are still active within double-quoted strings.
56264642e01fSmrgsed_quote_subst='$sed_quote_subst'
562705b261ecSmrg
56284642e01fSmrg# Be Bourne compatible
56294642e01fSmrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
56304642e01fSmrg  emulate sh
56314642e01fSmrg  NULLCMD=:
56324642e01fSmrg  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
56334642e01fSmrg  # is contrary to our usage.  Disable this feature.
56344642e01fSmrg  alias -g '\${1+\"\$@\"}'='\"\$@\"'
56354642e01fSmrg  setopt NO_GLOB_SUBST
56364642e01fSmrgelse
56374642e01fSmrg  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
56384642e01fSmrgfi
56394642e01fSmrgBIN_SH=xpg4; export BIN_SH # for Tru64
56404642e01fSmrgDUALCASE=1; export DUALCASE # for MKS sh
564105b261ecSmrg
56424642e01fSmrg# The HP-UX ksh and POSIX shell print the target directory to stdout
56434642e01fSmrg# if CDPATH is set.
56444642e01fSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
564505b261ecSmrg
56464642e01fSmrgrelink_command=\"$relink_command\"
564705b261ecSmrg
56484642e01fSmrg# This environment variable determines our operation mode.
56494642e01fSmrgif test \"\$libtool_install_magic\" = \"$magic\"; then
56504642e01fSmrg  # install mode needs the following variables:
56514642e01fSmrg  generated_by_libtool_version='$macro_version'
56524642e01fSmrg  notinst_deplibs='$notinst_deplibs'
56534642e01fSmrgelse
56544642e01fSmrg  # When we are sourced in execute mode, \$file and \$ECHO are already set.
56554642e01fSmrg  if test \"\$libtool_execute_magic\" != \"$magic\"; then
56566747b715Smrg    file=\"\$0\""
56576747b715Smrg
5658c82838c1Smrg    func_quote_arg pretty "$ECHO"
5659c82838c1Smrg    qECHO=$func_quote_arg_result
56606747b715Smrg    $ECHO "\
56616747b715Smrg
56626747b715Smrg# A function that is used when there is no print builtin or printf.
56636747b715Smrgfunc_fallback_echo ()
56646747b715Smrg{
56656747b715Smrg  eval 'cat <<_LTECHO_EOF
56666747b715Smrg\$1
56676747b715Smrg_LTECHO_EOF'
56686747b715Smrg}
5669c82838c1Smrg    ECHO=$qECHO
56706747b715Smrg  fi
56716747b715Smrg
56726747b715Smrg# Very basic option parsing. These options are (a) specific to
56736747b715Smrg# the libtool wrapper, (b) are identical between the wrapper
567435c4bbdfSmrg# /script/ and the wrapper /executable/ that is used only on
56756747b715Smrg# windows platforms, and (c) all begin with the string "--lt-"
567635c4bbdfSmrg# (application programs are unlikely to have options that match
56776747b715Smrg# this pattern).
56786747b715Smrg#
56796747b715Smrg# There are only two supported options: --lt-debug and
56806747b715Smrg# --lt-dump-script. There is, deliberately, no --lt-help.
56816747b715Smrg#
56826747b715Smrg# The first argument to this parsing function should be the
56836747b715Smrg# script's $0 value, followed by "$@".
56846747b715Smrglt_option_debug=
56856747b715Smrgfunc_parse_lt_options ()
56866747b715Smrg{
56876747b715Smrg  lt_script_arg0=\$0
56886747b715Smrg  shift
56896747b715Smrg  for lt_opt
56906747b715Smrg  do
56916747b715Smrg    case \"\$lt_opt\" in
56926747b715Smrg    --lt-debug) lt_option_debug=1 ;;
56936747b715Smrg    --lt-dump-script)
56946747b715Smrg        lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
56956747b715Smrg        test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
56966747b715Smrg        lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
56976747b715Smrg        cat \"\$lt_dump_D/\$lt_dump_F\"
56986747b715Smrg        exit 0
56996747b715Smrg      ;;
57006747b715Smrg    --lt-*)
57016747b715Smrg        \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
57026747b715Smrg        exit 1
57036747b715Smrg      ;;
57046747b715Smrg    esac
57056747b715Smrg  done
57066747b715Smrg
57076747b715Smrg  # Print the debug banner immediately:
57086747b715Smrg  if test -n \"\$lt_option_debug\"; then
570935c4bbdfSmrg    echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2
57106747b715Smrg  fi
57116747b715Smrg}
57126747b715Smrg
57136747b715Smrg# Used when --lt-debug. Prints its arguments to stdout
57146747b715Smrg# (redirection is the responsibility of the caller)
57156747b715Smrgfunc_lt_dump_args ()
57166747b715Smrg{
57176747b715Smrg  lt_dump_args_N=1;
57186747b715Smrg  for lt_arg
57196747b715Smrg  do
572035c4bbdfSmrg    \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\"
57216747b715Smrg    lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
57226747b715Smrg  done
57236747b715Smrg}
57246747b715Smrg
57256747b715Smrg# Core function for launching the target application
57266747b715Smrgfunc_exec_program_core ()
57276747b715Smrg{
57284642e01fSmrg"
57296747b715Smrg  case $host in
57306747b715Smrg  # Backslashes separate directories on plain windows
573154b5899cSmrg  *-*-mingw* | *-*-windows* | *-*-os2* | *-cegcc*)
57326747b715Smrg    $ECHO "\
57336747b715Smrg      if test -n \"\$lt_option_debug\"; then
573435c4bbdfSmrg        \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2
57356747b715Smrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
57366747b715Smrg      fi
57376747b715Smrg      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
57386747b715Smrg"
57396747b715Smrg    ;;
57406747b715Smrg
57416747b715Smrg  *)
57426747b715Smrg    $ECHO "\
57436747b715Smrg      if test -n \"\$lt_option_debug\"; then
574435c4bbdfSmrg        \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2
57456747b715Smrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
57466747b715Smrg      fi
57476747b715Smrg      exec \"\$progdir/\$program\" \${1+\"\$@\"}
57486747b715Smrg"
57496747b715Smrg    ;;
57506747b715Smrg  esac
57516747b715Smrg  $ECHO "\
57526747b715Smrg      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
57536747b715Smrg      exit 1
57546747b715Smrg}
57556747b715Smrg
57566747b715Smrg# A function to encapsulate launching the target application
57576747b715Smrg# Strips options in the --lt-* namespace from \$@ and
57586747b715Smrg# launches target application with the remaining arguments.
57596747b715Smrgfunc_exec_program ()
57606747b715Smrg{
576135c4bbdfSmrg  case \" \$* \" in
576235c4bbdfSmrg  *\\ --lt-*)
576335c4bbdfSmrg    for lt_wr_arg
576435c4bbdfSmrg    do
576535c4bbdfSmrg      case \$lt_wr_arg in
576635c4bbdfSmrg      --lt-*) ;;
576735c4bbdfSmrg      *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
576835c4bbdfSmrg      esac
576935c4bbdfSmrg      shift
577035c4bbdfSmrg    done ;;
577135c4bbdfSmrg  esac
57726747b715Smrg  func_exec_program_core \${1+\"\$@\"}
57736747b715Smrg}
57746747b715Smrg
57756747b715Smrg  # Parse options
57766747b715Smrg  func_parse_lt_options \"\$0\" \${1+\"\$@\"}
577705b261ecSmrg
57784642e01fSmrg  # Find the directory that this script lives in.
57796747b715Smrg  thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
57804642e01fSmrg  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
578105b261ecSmrg
57824642e01fSmrg  # Follow symbolic links until we get to the real thisdir.
57836747b715Smrg  file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
57844642e01fSmrg  while test -n \"\$file\"; do
57856747b715Smrg    destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
578605b261ecSmrg
57874642e01fSmrg    # If there was a directory component, then change thisdir.
57884642e01fSmrg    if test \"x\$destdir\" != \"x\$file\"; then
57894642e01fSmrg      case \"\$destdir\" in
57904642e01fSmrg      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
57914642e01fSmrg      *) thisdir=\"\$thisdir/\$destdir\" ;;
579205b261ecSmrg      esac
57934642e01fSmrg    fi
579405b261ecSmrg
57956747b715Smrg    file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
57966747b715Smrg    file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
57974642e01fSmrg  done
579805b261ecSmrg
579954b5899cSmrg  # Usually 'no', except on cygwin/mingw/windows when embedded into
58004642e01fSmrg  # the cwrapper.
58016747b715Smrg  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
58024642e01fSmrg  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
58034642e01fSmrg    # special case for '.'
58044642e01fSmrg    if test \"\$thisdir\" = \".\"; then
58054642e01fSmrg      thisdir=\`pwd\`
58064642e01fSmrg    fi
58074642e01fSmrg    # remove .libs from thisdir
58084642e01fSmrg    case \"\$thisdir\" in
58096747b715Smrg    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
58104642e01fSmrg    $objdir )   thisdir=. ;;
58114642e01fSmrg    esac
58124642e01fSmrg  fi
58134642e01fSmrg
58144642e01fSmrg  # Try to get the absolute directory name.
58154642e01fSmrg  absdir=\`cd \"\$thisdir\" && pwd\`
58164642e01fSmrg  test -n \"\$absdir\" && thisdir=\"\$absdir\"
58174642e01fSmrg"
58184642e01fSmrg
581935c4bbdfSmrg	if test yes = "$fast_install"; then
58204642e01fSmrg	  $ECHO "\
58214642e01fSmrg  program=lt-'$outputname'$exeext
58224642e01fSmrg  progdir=\"\$thisdir/$objdir\"
58234642e01fSmrg
58244642e01fSmrg  if test ! -f \"\$progdir/\$program\" ||
582535c4bbdfSmrg     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\
58264642e01fSmrg       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
58274642e01fSmrg
58284642e01fSmrg    file=\"\$\$-\$program\"
58294642e01fSmrg
58304642e01fSmrg    if test ! -d \"\$progdir\"; then
58314642e01fSmrg      $MKDIR \"\$progdir\"
58324642e01fSmrg    else
58334642e01fSmrg      $RM \"\$progdir/\$file\"
58344642e01fSmrg    fi"
58354642e01fSmrg
58364642e01fSmrg	  $ECHO "\
58374642e01fSmrg
58384642e01fSmrg    # relink executable if necessary
58394642e01fSmrg    if test -n \"\$relink_command\"; then
58404642e01fSmrg      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
58414642e01fSmrg      else
584235c4bbdfSmrg	\$ECHO \"\$relink_command_output\" >&2
58434642e01fSmrg	$RM \"\$progdir/\$file\"
58444642e01fSmrg	exit 1
584505b261ecSmrg      fi
58464642e01fSmrg    fi
584705b261ecSmrg
58484642e01fSmrg    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
58494642e01fSmrg    { $RM \"\$progdir/\$program\";
58504642e01fSmrg      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
58514642e01fSmrg    $RM \"\$progdir/\$file\"
58524642e01fSmrg  fi"
58534642e01fSmrg	else
58544642e01fSmrg	  $ECHO "\
58554642e01fSmrg  program='$outputname'
58564642e01fSmrg  progdir=\"\$thisdir/$objdir\"
58574642e01fSmrg"
585805b261ecSmrg	fi
585905b261ecSmrg
58604642e01fSmrg	$ECHO "\
586105b261ecSmrg
58624642e01fSmrg  if test -f \"\$progdir/\$program\"; then"
586305b261ecSmrg
586435c4bbdfSmrg	# fixup the dll searchpath if we need to.
586535c4bbdfSmrg	#
586635c4bbdfSmrg	# Fix the DLL searchpath if we need to.  Do this before prepending
586735c4bbdfSmrg	# to shlibpath, because on Windows, both are PATH and uninstalled
586835c4bbdfSmrg	# libraries must come first.
586935c4bbdfSmrg	if test -n "$dllsearchpath"; then
587035c4bbdfSmrg	  $ECHO "\
587135c4bbdfSmrg    # Add the dll search path components to the executable PATH
587235c4bbdfSmrg    PATH=$dllsearchpath:\$PATH
587335c4bbdfSmrg"
587435c4bbdfSmrg	fi
587535c4bbdfSmrg
58764642e01fSmrg	# Export our shlibpath_var if we have one.
587735c4bbdfSmrg	if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
58784642e01fSmrg	  $ECHO "\
58794642e01fSmrg    # Add our own library path to $shlibpath_var
58804642e01fSmrg    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
588105b261ecSmrg
58824642e01fSmrg    # Some systems cannot cope with colon-terminated $shlibpath_var
58834642e01fSmrg    # The second colon is a workaround for a bug in BeOS R4 sed
58846747b715Smrg    $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
58854642e01fSmrg
58864642e01fSmrg    export $shlibpath_var
58874642e01fSmrg"
588805b261ecSmrg	fi
588905b261ecSmrg
58904642e01fSmrg	$ECHO "\
58914642e01fSmrg    if test \"\$libtool_execute_magic\" != \"$magic\"; then
58924642e01fSmrg      # Run the actual program with our arguments.
58936747b715Smrg      func_exec_program \${1+\"\$@\"}
58944642e01fSmrg    fi
58954642e01fSmrg  else
58964642e01fSmrg    # The program doesn't exist.
589735c4bbdfSmrg    \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2
58984642e01fSmrg    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
58996747b715Smrg    \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
59004642e01fSmrg    exit 1
59014642e01fSmrg  fi
59024642e01fSmrgfi\
59034642e01fSmrg"
59044642e01fSmrg}
590505b261ecSmrg
590605b261ecSmrg
59074642e01fSmrg# func_emit_cwrapperexe_src
59084642e01fSmrg# emit the source code for a wrapper executable on stdout
59094642e01fSmrg# Must ONLY be called from within func_mode_link because
59104642e01fSmrg# it depends on a number of variable set therein.
59114642e01fSmrgfunc_emit_cwrapperexe_src ()
59124642e01fSmrg{
59134642e01fSmrg	cat <<EOF
591405b261ecSmrg
59154642e01fSmrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
591635c4bbdfSmrg   Generated by $PROGRAM (GNU $PACKAGE) $VERSION
591705b261ecSmrg
59184642e01fSmrg   The $output program cannot be directly executed until all the libtool
59194642e01fSmrg   libraries that it depends on are installed.
592005b261ecSmrg
59214642e01fSmrg   This wrapper executable should never be moved out of the build directory.
59224642e01fSmrg   If it is, it will not operate correctly.
59234642e01fSmrg*/
59244642e01fSmrgEOF
59254642e01fSmrg	    cat <<"EOF"
59266747b715Smrg#ifdef _MSC_VER
59276747b715Smrg# define _CRT_SECURE_NO_DEPRECATE 1
59286747b715Smrg#endif
59294642e01fSmrg#include <stdio.h>
59304642e01fSmrg#include <stdlib.h>
593154b5899cSmrg#if defined _WIN32 && !defined __GNUC__
59324642e01fSmrg# include <direct.h>
59334642e01fSmrg# include <process.h>
59344642e01fSmrg# include <io.h>
59354642e01fSmrg#else
59364642e01fSmrg# include <unistd.h>
59374642e01fSmrg# include <stdint.h>
59384642e01fSmrg# ifdef __CYGWIN__
59394642e01fSmrg#  include <io.h>
59406747b715Smrg# endif
59416747b715Smrg#endif
59426747b715Smrg#include <malloc.h>
59436747b715Smrg#include <stdarg.h>
59446747b715Smrg#include <assert.h>
59456747b715Smrg#include <string.h>
59466747b715Smrg#include <ctype.h>
59476747b715Smrg#include <errno.h>
59486747b715Smrg#include <fcntl.h>
59496747b715Smrg#include <sys/stat.h>
59506747b715Smrg
595135c4bbdfSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
595235c4bbdfSmrg
59536747b715Smrg/* declarations of non-ANSI functions */
595435c4bbdfSmrg#if defined __MINGW32__
59556747b715Smrg# ifdef __STRICT_ANSI__
595654b5899cSmrg_CRTIMP int __cdecl _putenv (const char *);
59576747b715Smrg# endif
595835c4bbdfSmrg#elif defined __CYGWIN__
59596747b715Smrg# ifdef __STRICT_ANSI__
59604642e01fSmrgchar *realpath (const char *, char *);
59614642e01fSmrgint putenv (char *);
59624642e01fSmrgint setenv (const char *, const char *, int);
59634642e01fSmrg# endif
596435c4bbdfSmrg/* #elif defined other_platform || defined ... */
59656747b715Smrg#endif
59666747b715Smrg
59676747b715Smrg/* portability defines, excluding path handling macros */
596835c4bbdfSmrg#if defined _MSC_VER
59696747b715Smrg# define setmode _setmode
59706747b715Smrg# define stat    _stat
59716747b715Smrg# define chmod   _chmod
59726747b715Smrg# define getcwd  _getcwd
59736747b715Smrg# define putenv  _putenv
59746747b715Smrg# define S_IXUSR _S_IEXEC
597535c4bbdfSmrg#elif defined __MINGW32__
59766747b715Smrg# define setmode _setmode
59776747b715Smrg# define stat    _stat
59786747b715Smrg# define chmod   _chmod
59796747b715Smrg# define getcwd  _getcwd
59806747b715Smrg# define putenv  _putenv
598135c4bbdfSmrg#elif defined __CYGWIN__
59826747b715Smrg# define HAVE_SETENV
59836747b715Smrg# define FOPEN_WB "wb"
598435c4bbdfSmrg/* #elif defined other platforms ... */
59854642e01fSmrg#endif
598605b261ecSmrg
598735c4bbdfSmrg#if defined PATH_MAX
59884642e01fSmrg# define LT_PATHMAX PATH_MAX
598935c4bbdfSmrg#elif defined MAXPATHLEN
59904642e01fSmrg# define LT_PATHMAX MAXPATHLEN
59914642e01fSmrg#else
59924642e01fSmrg# define LT_PATHMAX 1024
59934642e01fSmrg#endif
599405b261ecSmrg
59954642e01fSmrg#ifndef S_IXOTH
59964642e01fSmrg# define S_IXOTH 0
59974642e01fSmrg#endif
59984642e01fSmrg#ifndef S_IXGRP
59994642e01fSmrg# define S_IXGRP 0
60004642e01fSmrg#endif
600105b261ecSmrg
60026747b715Smrg/* path handling portability macros */
60034642e01fSmrg#ifndef DIR_SEPARATOR
60044642e01fSmrg# define DIR_SEPARATOR '/'
60054642e01fSmrg# define PATH_SEPARATOR ':'
60064642e01fSmrg#endif
600705b261ecSmrg
600835c4bbdfSmrg#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \
600935c4bbdfSmrg  defined __OS2__
60104642e01fSmrg# define HAVE_DOS_BASED_FILE_SYSTEM
60114642e01fSmrg# define FOPEN_WB "wb"
60124642e01fSmrg# ifndef DIR_SEPARATOR_2
60134642e01fSmrg#  define DIR_SEPARATOR_2 '\\'
60144642e01fSmrg# endif
60154642e01fSmrg# ifndef PATH_SEPARATOR_2
60164642e01fSmrg#  define PATH_SEPARATOR_2 ';'
60174642e01fSmrg# endif
60184642e01fSmrg#endif
601905b261ecSmrg
60204642e01fSmrg#ifndef DIR_SEPARATOR_2
60214642e01fSmrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
60224642e01fSmrg#else /* DIR_SEPARATOR_2 */
60234642e01fSmrg# define IS_DIR_SEPARATOR(ch) \
60244642e01fSmrg	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
60254642e01fSmrg#endif /* DIR_SEPARATOR_2 */
602605b261ecSmrg
60274642e01fSmrg#ifndef PATH_SEPARATOR_2
60284642e01fSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
60294642e01fSmrg#else /* PATH_SEPARATOR_2 */
60304642e01fSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
60314642e01fSmrg#endif /* PATH_SEPARATOR_2 */
603205b261ecSmrg
60334642e01fSmrg#ifndef FOPEN_WB
60344642e01fSmrg# define FOPEN_WB "w"
60354642e01fSmrg#endif
60364642e01fSmrg#ifndef _O_BINARY
60374642e01fSmrg# define _O_BINARY 0
60384642e01fSmrg#endif
603905b261ecSmrg
60404642e01fSmrg#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
60414642e01fSmrg#define XFREE(stale) do { \
604235c4bbdfSmrg  if (stale) { free (stale); stale = 0; } \
60434642e01fSmrg} while (0)
604405b261ecSmrg
604535c4bbdfSmrg#if defined LT_DEBUGWRAPPER
60466747b715Smrgstatic int lt_debug = 1;
60474642e01fSmrg#else
60486747b715Smrgstatic int lt_debug = 0;
60494642e01fSmrg#endif
605005b261ecSmrg
60516747b715Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
605205b261ecSmrg
60534642e01fSmrgvoid *xmalloc (size_t num);
60544642e01fSmrgchar *xstrdup (const char *string);
60554642e01fSmrgconst char *base_name (const char *name);
60564642e01fSmrgchar *find_executable (const char *wrapper);
60574642e01fSmrgchar *chase_symlinks (const char *pathspec);
60584642e01fSmrgint make_executable (const char *path);
60594642e01fSmrgint check_executable (const char *path);
60604642e01fSmrgchar *strendzap (char *str, const char *pat);
60616747b715Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...);
60626747b715Smrgvoid lt_fatal (const char *file, int line, const char *message, ...);
60636747b715Smrgstatic const char *nonnull (const char *s);
60646747b715Smrgstatic const char *nonempty (const char *s);
60654642e01fSmrgvoid lt_setenv (const char *name, const char *value);
60664642e01fSmrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end);
60674642e01fSmrgvoid lt_update_exe_path (const char *name, const char *value);
60684642e01fSmrgvoid lt_update_lib_path (const char *name, const char *value);
60696747b715Smrgchar **prepare_spawn (char **argv);
60706747b715Smrgvoid lt_dump_script (FILE *f);
60714642e01fSmrgEOF
60724642e01fSmrg
60734642e01fSmrg	    cat <<EOF
607435c4bbdfSmrg#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5)
607535c4bbdfSmrg# define externally_visible volatile
607635c4bbdfSmrg#else
607735c4bbdfSmrg# define externally_visible __attribute__((externally_visible)) volatile
607835c4bbdfSmrg#endif
607935c4bbdfSmrgexternally_visible const char * MAGIC_EXE = "$magic_exe";
60804642e01fSmrgconst char * LIB_PATH_VARNAME = "$shlibpath_var";
60814642e01fSmrgEOF
608205b261ecSmrg
608335c4bbdfSmrg	    if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
608435c4bbdfSmrg              func_to_host_path "$temp_rpath"
60854642e01fSmrg	      cat <<EOF
608635c4bbdfSmrgconst char * LIB_PATH_VALUE   = "$func_to_host_path_result";
60874642e01fSmrgEOF
60884642e01fSmrg	    else
60894642e01fSmrg	      cat <<"EOF"
60904642e01fSmrgconst char * LIB_PATH_VALUE   = "";
60914642e01fSmrgEOF
609205b261ecSmrg	    fi
609305b261ecSmrg
60944642e01fSmrg	    if test -n "$dllsearchpath"; then
609535c4bbdfSmrg              func_to_host_path "$dllsearchpath:"
60964642e01fSmrg	      cat <<EOF
60974642e01fSmrgconst char * EXE_PATH_VARNAME = "PATH";
609835c4bbdfSmrgconst char * EXE_PATH_VALUE   = "$func_to_host_path_result";
609905b261ecSmrgEOF
610005b261ecSmrg	    else
61014642e01fSmrg	      cat <<"EOF"
61024642e01fSmrgconst char * EXE_PATH_VARNAME = "";
61034642e01fSmrgconst char * EXE_PATH_VALUE   = "";
61044642e01fSmrgEOF
610505b261ecSmrg	    fi
61064642e01fSmrg
610735c4bbdfSmrg	    if test yes = "$fast_install"; then
61084642e01fSmrg	      cat <<EOF
61094642e01fSmrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
61104642e01fSmrgEOF
611105b261ecSmrg	    else
61124642e01fSmrg	      cat <<EOF
61134642e01fSmrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
61144642e01fSmrgEOF
611505b261ecSmrg	    fi
611605b261ecSmrg
611705b261ecSmrg
61184642e01fSmrg	    cat <<"EOF"
611905b261ecSmrg
61204642e01fSmrg#define LTWRAPPER_OPTION_PREFIX         "--lt-"
612105b261ecSmrg
61224642e01fSmrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
61234642e01fSmrgstatic const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
61246747b715Smrgstatic const char *debug_opt            = LTWRAPPER_OPTION_PREFIX "debug";
612505b261ecSmrg
61264642e01fSmrgint
61274642e01fSmrgmain (int argc, char *argv[])
61284642e01fSmrg{
61294642e01fSmrg  char **newargz;
61304642e01fSmrg  int  newargc;
61314642e01fSmrg  char *tmp_pathspec;
61324642e01fSmrg  char *actual_cwrapper_path;
61334642e01fSmrg  char *actual_cwrapper_name;
61344642e01fSmrg  char *target_name;
61354642e01fSmrg  char *lt_argv_zero;
613635c4bbdfSmrg  int rval = 127;
613705b261ecSmrg
61384642e01fSmrg  int i;
613905b261ecSmrg
61404642e01fSmrg  program_name = (char *) xstrdup (base_name (argv[0]));
614135c4bbdfSmrg  newargz = XMALLOC (char *, (size_t) argc + 1);
614205b261ecSmrg
61436747b715Smrg  /* very simple arg parsing; don't want to rely on getopt
61446747b715Smrg   * also, copy all non cwrapper options to newargz, except
61456747b715Smrg   * argz[0], which is handled differently
61466747b715Smrg   */
61476747b715Smrg  newargc=0;
61484642e01fSmrg  for (i = 1; i < argc; i++)
61494642e01fSmrg    {
615035c4bbdfSmrg      if (STREQ (argv[i], dumpscript_opt))
61514642e01fSmrg	{
61524642e01fSmrgEOF
615335c4bbdfSmrg	    case $host in
615454b5899cSmrg	      *mingw* | *windows* | *cygwin* )
61554642e01fSmrg		# make stdout use "unix" line endings
61564642e01fSmrg		echo "          setmode(1,_O_BINARY);"
61574642e01fSmrg		;;
61584642e01fSmrg	      esac
615905b261ecSmrg
61604642e01fSmrg	    cat <<"EOF"
61616747b715Smrg	  lt_dump_script (stdout);
61624642e01fSmrg	  return 0;
61634642e01fSmrg	}
616435c4bbdfSmrg      if (STREQ (argv[i], debug_opt))
61656747b715Smrg	{
61666747b715Smrg          lt_debug = 1;
61676747b715Smrg          continue;
61686747b715Smrg	}
616935c4bbdfSmrg      if (STREQ (argv[i], ltwrapper_option_prefix))
61706747b715Smrg        {
61716747b715Smrg          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
61726747b715Smrg             namespace, but it is not one of the ones we know about and
617354b5899cSmrg             have already dealt with, above (including dump-script), then
61746747b715Smrg             report an error. Otherwise, targets might begin to believe
61756747b715Smrg             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
61766747b715Smrg             namespace. The first time any user complains about this, we'll
61776747b715Smrg             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
61786747b715Smrg             or a configure.ac-settable value.
61796747b715Smrg           */
61806747b715Smrg          lt_fatal (__FILE__, __LINE__,
61816747b715Smrg		    "unrecognized %s option: '%s'",
61826747b715Smrg                    ltwrapper_option_prefix, argv[i]);
61836747b715Smrg        }
61846747b715Smrg      /* otherwise ... */
61856747b715Smrg      newargz[++newargc] = xstrdup (argv[i]);
61864642e01fSmrg    }
61876747b715Smrg  newargz[++newargc] = NULL;
61886747b715Smrg
61896747b715SmrgEOF
61906747b715Smrg	    cat <<EOF
61916747b715Smrg  /* The GNU banner must be the first non-error debug message */
619235c4bbdfSmrg  lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n");
61936747b715SmrgEOF
61946747b715Smrg	    cat <<"EOF"
61956747b715Smrg  lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
61966747b715Smrg  lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
619705b261ecSmrg
61984642e01fSmrg  tmp_pathspec = find_executable (argv[0]);
61994642e01fSmrg  if (tmp_pathspec == NULL)
62006747b715Smrg    lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
62016747b715Smrg  lt_debugprintf (__FILE__, __LINE__,
62026747b715Smrg                  "(main) found exe (before symlink chase) at: %s\n",
62036747b715Smrg		  tmp_pathspec);
62044642e01fSmrg
62054642e01fSmrg  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
62066747b715Smrg  lt_debugprintf (__FILE__, __LINE__,
62076747b715Smrg                  "(main) found exe (after symlink chase) at: %s\n",
62086747b715Smrg		  actual_cwrapper_path);
62094642e01fSmrg  XFREE (tmp_pathspec);
62104642e01fSmrg
62116747b715Smrg  actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
62124642e01fSmrg  strendzap (actual_cwrapper_path, actual_cwrapper_name);
62134642e01fSmrg
62144642e01fSmrg  /* wrapper name transforms */
62154642e01fSmrg  strendzap (actual_cwrapper_name, ".exe");
62164642e01fSmrg  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
62174642e01fSmrg  XFREE (actual_cwrapper_name);
62184642e01fSmrg  actual_cwrapper_name = tmp_pathspec;
62194642e01fSmrg  tmp_pathspec = 0;
62204642e01fSmrg
62214642e01fSmrg  /* target_name transforms -- use actual target program name; might have lt- prefix */
62224642e01fSmrg  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
62234642e01fSmrg  strendzap (target_name, ".exe");
62244642e01fSmrg  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
62254642e01fSmrg  XFREE (target_name);
62264642e01fSmrg  target_name = tmp_pathspec;
62274642e01fSmrg  tmp_pathspec = 0;
62284642e01fSmrg
62296747b715Smrg  lt_debugprintf (__FILE__, __LINE__,
62306747b715Smrg		  "(main) libtool target name: %s\n",
62316747b715Smrg		  target_name);
62324642e01fSmrgEOF
623305b261ecSmrg
62344642e01fSmrg	    cat <<EOF
62354642e01fSmrg  newargz[0] =
62364642e01fSmrg    XMALLOC (char, (strlen (actual_cwrapper_path) +
62374642e01fSmrg		    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
62384642e01fSmrg  strcpy (newargz[0], actual_cwrapper_path);
62394642e01fSmrg  strcat (newargz[0], "$objdir");
62404642e01fSmrg  strcat (newargz[0], "/");
62414642e01fSmrgEOF
624205b261ecSmrg
62434642e01fSmrg	    cat <<"EOF"
62444642e01fSmrg  /* stop here, and copy so we don't have to do this twice */
62454642e01fSmrg  tmp_pathspec = xstrdup (newargz[0]);
624605b261ecSmrg
62474642e01fSmrg  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
62484642e01fSmrg  strcat (newargz[0], actual_cwrapper_name);
624905b261ecSmrg
62504642e01fSmrg  /* DO want the lt- prefix here if it exists, so use target_name */
62514642e01fSmrg  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
62524642e01fSmrg  XFREE (tmp_pathspec);
62534642e01fSmrg  tmp_pathspec = NULL;
62544642e01fSmrgEOF
625505b261ecSmrg
62564642e01fSmrg	    case $host_os in
625754b5899cSmrg	      mingw* | windows*)
62584642e01fSmrg	    cat <<"EOF"
62594642e01fSmrg  {
62604642e01fSmrg    char* p;
62614642e01fSmrg    while ((p = strchr (newargz[0], '\\')) != NULL)
62624642e01fSmrg      {
62634642e01fSmrg	*p = '/';
62644642e01fSmrg      }
62654642e01fSmrg    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
62664642e01fSmrg      {
62674642e01fSmrg	*p = '/';
62684642e01fSmrg      }
62694642e01fSmrg  }
62704642e01fSmrgEOF
62714642e01fSmrg	    ;;
62724642e01fSmrg	    esac
627305b261ecSmrg
62744642e01fSmrg	    cat <<"EOF"
62754642e01fSmrg  XFREE (target_name);
62764642e01fSmrg  XFREE (actual_cwrapper_path);
62774642e01fSmrg  XFREE (actual_cwrapper_name);
627805b261ecSmrg
62794642e01fSmrg  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
62804642e01fSmrg  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
628135c4bbdfSmrg  /* Update the DLL searchpath.  EXE_PATH_VALUE ($dllsearchpath) must
628235c4bbdfSmrg     be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
628335c4bbdfSmrg     because on Windows, both *_VARNAMEs are PATH but uninstalled
628435c4bbdfSmrg     libraries must come first. */
6285475c125cSmrg  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
628635c4bbdfSmrg  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
628705b261ecSmrg
62886747b715Smrg  lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
62896747b715Smrg		  nonnull (lt_argv_zero));
62904642e01fSmrg  for (i = 0; i < newargc; i++)
62914642e01fSmrg    {
62926747b715Smrg      lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
62936747b715Smrg		      i, nonnull (newargz[i]));
62944642e01fSmrg    }
629505b261ecSmrg
62964642e01fSmrgEOF
629705b261ecSmrg
62984642e01fSmrg	    case $host_os in
629954b5899cSmrg	      mingw* | windows*)
63004642e01fSmrg		cat <<"EOF"
63014642e01fSmrg  /* execv doesn't actually work on mingw as expected on unix */
63026747b715Smrg  newargz = prepare_spawn (newargz);
630335c4bbdfSmrg  rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
63044642e01fSmrg  if (rval == -1)
63054642e01fSmrg    {
63064642e01fSmrg      /* failed to start process */
63076747b715Smrg      lt_debugprintf (__FILE__, __LINE__,
63086747b715Smrg		      "(main) failed to launch target \"%s\": %s\n",
63096747b715Smrg		      lt_argv_zero, nonnull (strerror (errno)));
63104642e01fSmrg      return 127;
63114642e01fSmrg    }
63124642e01fSmrg  return rval;
63134642e01fSmrgEOF
63144642e01fSmrg		;;
63154642e01fSmrg	      *)
63164642e01fSmrg		cat <<"EOF"
63174642e01fSmrg  execv (lt_argv_zero, newargz);
63184642e01fSmrg  return rval; /* =127, but avoids unused variable warning */
63194642e01fSmrgEOF
63204642e01fSmrg		;;
63214642e01fSmrg	    esac
632205b261ecSmrg
63234642e01fSmrg	    cat <<"EOF"
63244642e01fSmrg}
632505b261ecSmrg
63264642e01fSmrgvoid *
63274642e01fSmrgxmalloc (size_t num)
63284642e01fSmrg{
63294642e01fSmrg  void *p = (void *) malloc (num);
63304642e01fSmrg  if (!p)
63316747b715Smrg    lt_fatal (__FILE__, __LINE__, "memory exhausted");
633205b261ecSmrg
63334642e01fSmrg  return p;
63344642e01fSmrg}
633505b261ecSmrg
63364642e01fSmrgchar *
63374642e01fSmrgxstrdup (const char *string)
63384642e01fSmrg{
63394642e01fSmrg  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
63404642e01fSmrg			  string) : NULL;
63414642e01fSmrg}
634205b261ecSmrg
63434642e01fSmrgconst char *
63444642e01fSmrgbase_name (const char *name)
63454642e01fSmrg{
63464642e01fSmrg  const char *base;
634705b261ecSmrg
634835c4bbdfSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM
63494642e01fSmrg  /* Skip over the disk name in MSDOS pathnames. */
63504642e01fSmrg  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
63514642e01fSmrg    name += 2;
63524642e01fSmrg#endif
635305b261ecSmrg
63544642e01fSmrg  for (base = name; *name; name++)
63554642e01fSmrg    if (IS_DIR_SEPARATOR (*name))
63564642e01fSmrg      base = name + 1;
63574642e01fSmrg  return base;
63584642e01fSmrg}
635905b261ecSmrg
63604642e01fSmrgint
63614642e01fSmrgcheck_executable (const char *path)
63624642e01fSmrg{
63634642e01fSmrg  struct stat st;
636405b261ecSmrg
63656747b715Smrg  lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
63666747b715Smrg                  nonempty (path));
63674642e01fSmrg  if ((!path) || (!*path))
63684642e01fSmrg    return 0;
636905b261ecSmrg
63704642e01fSmrg  if ((stat (path, &st) >= 0)
63714642e01fSmrg      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
63724642e01fSmrg    return 1;
63734642e01fSmrg  else
63744642e01fSmrg    return 0;
63754642e01fSmrg}
637605b261ecSmrg
63774642e01fSmrgint
63784642e01fSmrgmake_executable (const char *path)
63794642e01fSmrg{
63804642e01fSmrg  int rval = 0;
63814642e01fSmrg  struct stat st;
638205b261ecSmrg
63836747b715Smrg  lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
63846747b715Smrg                  nonempty (path));
63854642e01fSmrg  if ((!path) || (!*path))
63864642e01fSmrg    return 0;
638705b261ecSmrg
63884642e01fSmrg  if (stat (path, &st) >= 0)
63894642e01fSmrg    {
63904642e01fSmrg      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
63914642e01fSmrg    }
63924642e01fSmrg  return rval;
63934642e01fSmrg}
639405b261ecSmrg
63954642e01fSmrg/* Searches for the full path of the wrapper.  Returns
63964642e01fSmrg   newly allocated full path name if found, NULL otherwise
63974642e01fSmrg   Does not chase symlinks, even on platforms that support them.
63984642e01fSmrg*/
63994642e01fSmrgchar *
64004642e01fSmrgfind_executable (const char *wrapper)
64014642e01fSmrg{
64024642e01fSmrg  int has_slash = 0;
64034642e01fSmrg  const char *p;
64044642e01fSmrg  const char *p_next;
64054642e01fSmrg  /* static buffer for getcwd */
64064642e01fSmrg  char tmp[LT_PATHMAX + 1];
640735c4bbdfSmrg  size_t tmp_len;
64084642e01fSmrg  char *concat_name;
640905b261ecSmrg
64106747b715Smrg  lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
64116747b715Smrg                  nonempty (wrapper));
641205b261ecSmrg
64134642e01fSmrg  if ((wrapper == NULL) || (*wrapper == '\0'))
64144642e01fSmrg    return NULL;
641505b261ecSmrg
64164642e01fSmrg  /* Absolute path? */
641735c4bbdfSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM
64184642e01fSmrg  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
64194642e01fSmrg    {
64204642e01fSmrg      concat_name = xstrdup (wrapper);
64214642e01fSmrg      if (check_executable (concat_name))
64224642e01fSmrg	return concat_name;
64234642e01fSmrg      XFREE (concat_name);
64244642e01fSmrg    }
64254642e01fSmrg  else
64264642e01fSmrg    {
64274642e01fSmrg#endif
64284642e01fSmrg      if (IS_DIR_SEPARATOR (wrapper[0]))
64294642e01fSmrg	{
64304642e01fSmrg	  concat_name = xstrdup (wrapper);
64314642e01fSmrg	  if (check_executable (concat_name))
64324642e01fSmrg	    return concat_name;
64334642e01fSmrg	  XFREE (concat_name);
64344642e01fSmrg	}
643535c4bbdfSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM
64364642e01fSmrg    }
64374642e01fSmrg#endif
643805b261ecSmrg
64394642e01fSmrg  for (p = wrapper; *p; p++)
64404642e01fSmrg    if (*p == '/')
64414642e01fSmrg      {
64424642e01fSmrg	has_slash = 1;
64434642e01fSmrg	break;
64444642e01fSmrg      }
64454642e01fSmrg  if (!has_slash)
64464642e01fSmrg    {
64474642e01fSmrg      /* no slashes; search PATH */
64484642e01fSmrg      const char *path = getenv ("PATH");
64494642e01fSmrg      if (path != NULL)
64504642e01fSmrg	{
64514642e01fSmrg	  for (p = path; *p; p = p_next)
64524642e01fSmrg	    {
64534642e01fSmrg	      const char *q;
64544642e01fSmrg	      size_t p_len;
64554642e01fSmrg	      for (q = p; *q; q++)
64564642e01fSmrg		if (IS_PATH_SEPARATOR (*q))
64574642e01fSmrg		  break;
645835c4bbdfSmrg	      p_len = (size_t) (q - p);
64594642e01fSmrg	      p_next = (*q == '\0' ? q : q + 1);
64604642e01fSmrg	      if (p_len == 0)
64614642e01fSmrg		{
64624642e01fSmrg		  /* empty path: current directory */
64634642e01fSmrg		  if (getcwd (tmp, LT_PATHMAX) == NULL)
64646747b715Smrg		    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
64656747b715Smrg                              nonnull (strerror (errno)));
64664642e01fSmrg		  tmp_len = strlen (tmp);
64674642e01fSmrg		  concat_name =
64684642e01fSmrg		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
64694642e01fSmrg		  memcpy (concat_name, tmp, tmp_len);
64704642e01fSmrg		  concat_name[tmp_len] = '/';
64714642e01fSmrg		  strcpy (concat_name + tmp_len + 1, wrapper);
64724642e01fSmrg		}
64734642e01fSmrg	      else
64744642e01fSmrg		{
64754642e01fSmrg		  concat_name =
64764642e01fSmrg		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
64774642e01fSmrg		  memcpy (concat_name, p, p_len);
64784642e01fSmrg		  concat_name[p_len] = '/';
64794642e01fSmrg		  strcpy (concat_name + p_len + 1, wrapper);
64804642e01fSmrg		}
64814642e01fSmrg	      if (check_executable (concat_name))
64824642e01fSmrg		return concat_name;
64834642e01fSmrg	      XFREE (concat_name);
64844642e01fSmrg	    }
64854642e01fSmrg	}
64864642e01fSmrg      /* not found in PATH; assume curdir */
64874642e01fSmrg    }
64884642e01fSmrg  /* Relative path | not found in path: prepend cwd */
64894642e01fSmrg  if (getcwd (tmp, LT_PATHMAX) == NULL)
64906747b715Smrg    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
64916747b715Smrg              nonnull (strerror (errno)));
64924642e01fSmrg  tmp_len = strlen (tmp);
64934642e01fSmrg  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
64944642e01fSmrg  memcpy (concat_name, tmp, tmp_len);
64954642e01fSmrg  concat_name[tmp_len] = '/';
64964642e01fSmrg  strcpy (concat_name + tmp_len + 1, wrapper);
649705b261ecSmrg
64984642e01fSmrg  if (check_executable (concat_name))
64994642e01fSmrg    return concat_name;
65004642e01fSmrg  XFREE (concat_name);
65014642e01fSmrg  return NULL;
65024642e01fSmrg}
650305b261ecSmrg
65044642e01fSmrgchar *
65054642e01fSmrgchase_symlinks (const char *pathspec)
65064642e01fSmrg{
65074642e01fSmrg#ifndef S_ISLNK
65084642e01fSmrg  return xstrdup (pathspec);
65094642e01fSmrg#else
65104642e01fSmrg  char buf[LT_PATHMAX];
65114642e01fSmrg  struct stat s;
65124642e01fSmrg  char *tmp_pathspec = xstrdup (pathspec);
65134642e01fSmrg  char *p;
65144642e01fSmrg  int has_symlinks = 0;
65154642e01fSmrg  while (strlen (tmp_pathspec) && !has_symlinks)
65164642e01fSmrg    {
65176747b715Smrg      lt_debugprintf (__FILE__, __LINE__,
65186747b715Smrg		      "checking path component for symlinks: %s\n",
65196747b715Smrg		      tmp_pathspec);
65204642e01fSmrg      if (lstat (tmp_pathspec, &s) == 0)
65214642e01fSmrg	{
65224642e01fSmrg	  if (S_ISLNK (s.st_mode) != 0)
65234642e01fSmrg	    {
65244642e01fSmrg	      has_symlinks = 1;
65254642e01fSmrg	      break;
65264642e01fSmrg	    }
652705b261ecSmrg
65284642e01fSmrg	  /* search backwards for last DIR_SEPARATOR */
65294642e01fSmrg	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
65304642e01fSmrg	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
65314642e01fSmrg	    p--;
65324642e01fSmrg	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
65334642e01fSmrg	    {
65344642e01fSmrg	      /* no more DIR_SEPARATORS left */
65354642e01fSmrg	      break;
65364642e01fSmrg	    }
65374642e01fSmrg	  *p = '\0';
65384642e01fSmrg	}
65394642e01fSmrg      else
65404642e01fSmrg	{
65416747b715Smrg	  lt_fatal (__FILE__, __LINE__,
65426747b715Smrg		    "error accessing file \"%s\": %s",
65436747b715Smrg		    tmp_pathspec, nonnull (strerror (errno)));
65444642e01fSmrg	}
65454642e01fSmrg    }
65464642e01fSmrg  XFREE (tmp_pathspec);
654705b261ecSmrg
65484642e01fSmrg  if (!has_symlinks)
65494642e01fSmrg    {
65504642e01fSmrg      return xstrdup (pathspec);
65514642e01fSmrg    }
655205b261ecSmrg
65534642e01fSmrg  tmp_pathspec = realpath (pathspec, buf);
65544642e01fSmrg  if (tmp_pathspec == 0)
65554642e01fSmrg    {
65566747b715Smrg      lt_fatal (__FILE__, __LINE__,
65576747b715Smrg		"could not follow symlinks for %s", pathspec);
65584642e01fSmrg    }
65594642e01fSmrg  return xstrdup (tmp_pathspec);
65604642e01fSmrg#endif
65614642e01fSmrg}
656205b261ecSmrg
65634642e01fSmrgchar *
65644642e01fSmrgstrendzap (char *str, const char *pat)
65654642e01fSmrg{
65664642e01fSmrg  size_t len, patlen;
656705b261ecSmrg
65684642e01fSmrg  assert (str != NULL);
65694642e01fSmrg  assert (pat != NULL);
657005b261ecSmrg
65714642e01fSmrg  len = strlen (str);
65724642e01fSmrg  patlen = strlen (pat);
657305b261ecSmrg
65744642e01fSmrg  if (patlen <= len)
65754642e01fSmrg    {
65764642e01fSmrg      str += len - patlen;
657735c4bbdfSmrg      if (STREQ (str, pat))
65784642e01fSmrg	*str = '\0';
65794642e01fSmrg    }
65804642e01fSmrg  return str;
65814642e01fSmrg}
658205b261ecSmrg
65836747b715Smrgvoid
65846747b715Smrglt_debugprintf (const char *file, int line, const char *fmt, ...)
65856747b715Smrg{
65866747b715Smrg  va_list args;
65876747b715Smrg  if (lt_debug)
65886747b715Smrg    {
65896747b715Smrg      (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
65906747b715Smrg      va_start (args, fmt);
65916747b715Smrg      (void) vfprintf (stderr, fmt, args);
65926747b715Smrg      va_end (args);
65936747b715Smrg    }
65946747b715Smrg}
65956747b715Smrg
65964642e01fSmrgstatic void
65976747b715Smrglt_error_core (int exit_status, const char *file,
65986747b715Smrg	       int line, const char *mode,
65994642e01fSmrg	       const char *message, va_list ap)
66004642e01fSmrg{
66016747b715Smrg  fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
66024642e01fSmrg  vfprintf (stderr, message, ap);
66034642e01fSmrg  fprintf (stderr, ".\n");
660405b261ecSmrg
66054642e01fSmrg  if (exit_status >= 0)
66064642e01fSmrg    exit (exit_status);
66074642e01fSmrg}
660805b261ecSmrg
66094642e01fSmrgvoid
66106747b715Smrglt_fatal (const char *file, int line, const char *message, ...)
66114642e01fSmrg{
66124642e01fSmrg  va_list ap;
66134642e01fSmrg  va_start (ap, message);
66146747b715Smrg  lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
66154642e01fSmrg  va_end (ap);
66164642e01fSmrg}
661705b261ecSmrg
66186747b715Smrgstatic const char *
66196747b715Smrgnonnull (const char *s)
66206747b715Smrg{
66216747b715Smrg  return s ? s : "(null)";
66226747b715Smrg}
66236747b715Smrg
66246747b715Smrgstatic const char *
66256747b715Smrgnonempty (const char *s)
66266747b715Smrg{
66276747b715Smrg  return (s && !*s) ? "(empty)" : nonnull (s);
66286747b715Smrg}
66296747b715Smrg
66304642e01fSmrgvoid
66314642e01fSmrglt_setenv (const char *name, const char *value)
66324642e01fSmrg{
66336747b715Smrg  lt_debugprintf (__FILE__, __LINE__,
66346747b715Smrg		  "(lt_setenv) setting '%s' to '%s'\n",
66356747b715Smrg                  nonnull (name), nonnull (value));
66364642e01fSmrg  {
66374642e01fSmrg#ifdef HAVE_SETENV
66384642e01fSmrg    /* always make a copy, for consistency with !HAVE_SETENV */
66394642e01fSmrg    char *str = xstrdup (value);
66404642e01fSmrg    setenv (name, str, 1);
66414642e01fSmrg#else
664235c4bbdfSmrg    size_t len = strlen (name) + 1 + strlen (value) + 1;
66434642e01fSmrg    char *str = XMALLOC (char, len);
66444642e01fSmrg    sprintf (str, "%s=%s", name, value);
66454642e01fSmrg    if (putenv (str) != EXIT_SUCCESS)
66464642e01fSmrg      {
66474642e01fSmrg        XFREE (str);
66484642e01fSmrg      }
66494642e01fSmrg#endif
66504642e01fSmrg  }
66514642e01fSmrg}
665205b261ecSmrg
66534642e01fSmrgchar *
66544642e01fSmrglt_extend_str (const char *orig_value, const char *add, int to_end)
66554642e01fSmrg{
66564642e01fSmrg  char *new_value;
66574642e01fSmrg  if (orig_value && *orig_value)
66584642e01fSmrg    {
665935c4bbdfSmrg      size_t orig_value_len = strlen (orig_value);
666035c4bbdfSmrg      size_t add_len = strlen (add);
66614642e01fSmrg      new_value = XMALLOC (char, add_len + orig_value_len + 1);
66624642e01fSmrg      if (to_end)
66634642e01fSmrg        {
66644642e01fSmrg          strcpy (new_value, orig_value);
66654642e01fSmrg          strcpy (new_value + orig_value_len, add);
66664642e01fSmrg        }
66674642e01fSmrg      else
66684642e01fSmrg        {
66694642e01fSmrg          strcpy (new_value, add);
66704642e01fSmrg          strcpy (new_value + add_len, orig_value);
66714642e01fSmrg        }
66724642e01fSmrg    }
66734642e01fSmrg  else
66744642e01fSmrg    {
66754642e01fSmrg      new_value = xstrdup (add);
66764642e01fSmrg    }
66774642e01fSmrg  return new_value;
66784642e01fSmrg}
667905b261ecSmrg
66804642e01fSmrgvoid
66814642e01fSmrglt_update_exe_path (const char *name, const char *value)
66824642e01fSmrg{
66836747b715Smrg  lt_debugprintf (__FILE__, __LINE__,
66846747b715Smrg		  "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
66856747b715Smrg                  nonnull (name), nonnull (value));
668605b261ecSmrg
66874642e01fSmrg  if (name && *name && value && *value)
66884642e01fSmrg    {
66894642e01fSmrg      char *new_value = lt_extend_str (getenv (name), value, 0);
66904642e01fSmrg      /* some systems can't cope with a ':'-terminated path #' */
669135c4bbdfSmrg      size_t len = strlen (new_value);
669235c4bbdfSmrg      while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
66934642e01fSmrg        {
669435c4bbdfSmrg          new_value[--len] = '\0';
66954642e01fSmrg        }
66964642e01fSmrg      lt_setenv (name, new_value);
66974642e01fSmrg      XFREE (new_value);
66984642e01fSmrg    }
66994642e01fSmrg}
670005b261ecSmrg
67014642e01fSmrgvoid
67024642e01fSmrglt_update_lib_path (const char *name, const char *value)
67034642e01fSmrg{
67046747b715Smrg  lt_debugprintf (__FILE__, __LINE__,
67056747b715Smrg		  "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
67066747b715Smrg                  nonnull (name), nonnull (value));
670705b261ecSmrg
67084642e01fSmrg  if (name && *name && value && *value)
67094642e01fSmrg    {
67104642e01fSmrg      char *new_value = lt_extend_str (getenv (name), value, 0);
67114642e01fSmrg      lt_setenv (name, new_value);
67124642e01fSmrg      XFREE (new_value);
67134642e01fSmrg    }
67144642e01fSmrg}
671505b261ecSmrg
67166747b715SmrgEOF
67176747b715Smrg	    case $host_os in
671854b5899cSmrg	      mingw* | windows*)
67196747b715Smrg		cat <<"EOF"
67206747b715Smrg
67216747b715Smrg/* Prepares an argument vector before calling spawn().
67226747b715Smrg   Note that spawn() does not by itself call the command interpreter
67236747b715Smrg     (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
67246747b715Smrg      ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
67256747b715Smrg         GetVersionEx(&v);
67266747b715Smrg         v.dwPlatformId == VER_PLATFORM_WIN32_NT;
67276747b715Smrg      }) ? "cmd.exe" : "command.com").
67286747b715Smrg   Instead it simply concatenates the arguments, separated by ' ', and calls
67296747b715Smrg   CreateProcess().  We must quote the arguments since Win32 CreateProcess()
67306747b715Smrg   interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
67316747b715Smrg   special way:
67326747b715Smrg   - Space and tab are interpreted as delimiters. They are not treated as
67336747b715Smrg     delimiters if they are surrounded by double quotes: "...".
67346747b715Smrg   - Unescaped double quotes are removed from the input. Their only effect is
67356747b715Smrg     that within double quotes, space and tab are treated like normal
67366747b715Smrg     characters.
67376747b715Smrg   - Backslashes not followed by double quotes are not special.
67386747b715Smrg   - But 2*n+1 backslashes followed by a double quote become
67396747b715Smrg     n backslashes followed by a double quote (n >= 0):
67406747b715Smrg       \" -> "
67416747b715Smrg       \\\" -> \"
67426747b715Smrg       \\\\\" -> \\"
67436747b715Smrg */
67446747b715Smrg#define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037"
67456747b715Smrg#define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037"
67466747b715Smrgchar **
67476747b715Smrgprepare_spawn (char **argv)
67486747b715Smrg{
67496747b715Smrg  size_t argc;
67506747b715Smrg  char **new_argv;
67516747b715Smrg  size_t i;
67526747b715Smrg
67536747b715Smrg  /* Count number of arguments.  */
67546747b715Smrg  for (argc = 0; argv[argc] != NULL; argc++)
67556747b715Smrg    ;
67566747b715Smrg
67576747b715Smrg  /* Allocate new argument vector.  */
67586747b715Smrg  new_argv = XMALLOC (char *, argc + 1);
67596747b715Smrg
67606747b715Smrg  /* Put quoted arguments into the new argument vector.  */
67616747b715Smrg  for (i = 0; i < argc; i++)
67626747b715Smrg    {
67636747b715Smrg      const char *string = argv[i];
67646747b715Smrg
67656747b715Smrg      if (string[0] == '\0')
67666747b715Smrg	new_argv[i] = xstrdup ("\"\"");
67676747b715Smrg      else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
67686747b715Smrg	{
67696747b715Smrg	  int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
67706747b715Smrg	  size_t length;
67716747b715Smrg	  unsigned int backslashes;
67726747b715Smrg	  const char *s;
67736747b715Smrg	  char *quoted_string;
67746747b715Smrg	  char *p;
67756747b715Smrg
67766747b715Smrg	  length = 0;
67776747b715Smrg	  backslashes = 0;
67786747b715Smrg	  if (quote_around)
67796747b715Smrg	    length++;
67806747b715Smrg	  for (s = string; *s != '\0'; s++)
67816747b715Smrg	    {
67826747b715Smrg	      char c = *s;
67836747b715Smrg	      if (c == '"')
67846747b715Smrg		length += backslashes + 1;
67856747b715Smrg	      length++;
67866747b715Smrg	      if (c == '\\')
67876747b715Smrg		backslashes++;
67886747b715Smrg	      else
67896747b715Smrg		backslashes = 0;
67906747b715Smrg	    }
67916747b715Smrg	  if (quote_around)
67926747b715Smrg	    length += backslashes + 1;
67936747b715Smrg
67946747b715Smrg	  quoted_string = XMALLOC (char, length + 1);
67956747b715Smrg
67966747b715Smrg	  p = quoted_string;
67976747b715Smrg	  backslashes = 0;
67986747b715Smrg	  if (quote_around)
67996747b715Smrg	    *p++ = '"';
68006747b715Smrg	  for (s = string; *s != '\0'; s++)
68016747b715Smrg	    {
68026747b715Smrg	      char c = *s;
68036747b715Smrg	      if (c == '"')
68046747b715Smrg		{
68056747b715Smrg		  unsigned int j;
68066747b715Smrg		  for (j = backslashes + 1; j > 0; j--)
68076747b715Smrg		    *p++ = '\\';
68086747b715Smrg		}
68096747b715Smrg	      *p++ = c;
68106747b715Smrg	      if (c == '\\')
68116747b715Smrg		backslashes++;
68126747b715Smrg	      else
68136747b715Smrg		backslashes = 0;
68146747b715Smrg	    }
68156747b715Smrg	  if (quote_around)
68166747b715Smrg	    {
68176747b715Smrg	      unsigned int j;
68186747b715Smrg	      for (j = backslashes; j > 0; j--)
68196747b715Smrg		*p++ = '\\';
68206747b715Smrg	      *p++ = '"';
68216747b715Smrg	    }
68226747b715Smrg	  *p = '\0';
68236747b715Smrg
68246747b715Smrg	  new_argv[i] = quoted_string;
68256747b715Smrg	}
68266747b715Smrg      else
68276747b715Smrg	new_argv[i] = (char *) string;
68286747b715Smrg    }
68296747b715Smrg  new_argv[argc] = NULL;
68306747b715Smrg
68316747b715Smrg  return new_argv;
68326747b715Smrg}
68336747b715SmrgEOF
68346747b715Smrg		;;
68356747b715Smrg	    esac
68366747b715Smrg
68376747b715Smrg            cat <<"EOF"
68386747b715Smrgvoid lt_dump_script (FILE* f)
68396747b715Smrg{
68406747b715SmrgEOF
68416747b715Smrg	    func_emit_wrapper yes |
684235c4bbdfSmrg	      $SED -n -e '
684335c4bbdfSmrgs/^\(.\{79\}\)\(..*\)/\1\
684435c4bbdfSmrg\2/
684535c4bbdfSmrgh
684635c4bbdfSmrgs/\([\\"]\)/\\\1/g
684735c4bbdfSmrgs/$/\\n/
684835c4bbdfSmrgs/\([^\n]*\).*/  fputs ("\1", f);/p
684935c4bbdfSmrgg
685035c4bbdfSmrgD'
68516747b715Smrg            cat <<"EOF"
68526747b715Smrg}
68534642e01fSmrgEOF
68544642e01fSmrg}
68554642e01fSmrg# end: func_emit_cwrapperexe_src
685605b261ecSmrg
68576747b715Smrg# func_win32_import_lib_p ARG
68586747b715Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd
68596747b715Smrgfunc_win32_import_lib_p ()
68606747b715Smrg{
686135c4bbdfSmrg    $debug_cmd
686235c4bbdfSmrg
68636747b715Smrg    case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
68646747b715Smrg    *import*) : ;;
68656747b715Smrg    *) false ;;
68666747b715Smrg    esac
68676747b715Smrg}
68686747b715Smrg
686935c4bbdfSmrg# func_suncc_cstd_abi
687035c4bbdfSmrg# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!!
687135c4bbdfSmrg# Several compiler flags select an ABI that is incompatible with the
687235c4bbdfSmrg# Cstd library. Avoid specifying it if any are in CXXFLAGS.
687335c4bbdfSmrgfunc_suncc_cstd_abi ()
687435c4bbdfSmrg{
687535c4bbdfSmrg    $debug_cmd
687635c4bbdfSmrg
687735c4bbdfSmrg    case " $compile_command " in
687835c4bbdfSmrg    *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*)
687935c4bbdfSmrg      suncc_use_cstd_abi=no
688035c4bbdfSmrg      ;;
688135c4bbdfSmrg    *)
688235c4bbdfSmrg      suncc_use_cstd_abi=yes
688335c4bbdfSmrg      ;;
688435c4bbdfSmrg    esac
688535c4bbdfSmrg}
688635c4bbdfSmrg
68874642e01fSmrg# func_mode_link arg...
68884642e01fSmrgfunc_mode_link ()
68894642e01fSmrg{
689035c4bbdfSmrg    $debug_cmd
689135c4bbdfSmrg
68924642e01fSmrg    case $host in
689354b5899cSmrg    *-*-cygwin* | *-*-mingw* | *-*-windows* | *-*-pw32* | *-*-os2* | *-cegcc*)
68944642e01fSmrg      # It is impossible to link a dll without this setting, and
68954642e01fSmrg      # we shouldn't force the makefile maintainer to figure out
689635c4bbdfSmrg      # what system we are compiling for in order to pass an extra
68974642e01fSmrg      # flag for every libtool invocation.
68984642e01fSmrg      # allow_undefined=no
689905b261ecSmrg
69004642e01fSmrg      # FIXME: Unfortunately, there are problems with the above when trying
690135c4bbdfSmrg      # to make a dll that has undefined symbols, in which case not
69024642e01fSmrg      # even a static library is built.  For now, we need to specify
69034642e01fSmrg      # -no-undefined on the libtool link line when we can be certain
69044642e01fSmrg      # that all symbols are satisfied, otherwise we get a static library.
69054642e01fSmrg      allow_undefined=yes
69064642e01fSmrg      ;;
69074642e01fSmrg    *)
69084642e01fSmrg      allow_undefined=yes
69094642e01fSmrg      ;;
69104642e01fSmrg    esac
69114642e01fSmrg    libtool_args=$nonopt
69124642e01fSmrg    base_compile="$nonopt $@"
69134642e01fSmrg    compile_command=$nonopt
69144642e01fSmrg    finalize_command=$nonopt
691505b261ecSmrg
69164642e01fSmrg    compile_rpath=
691754b5899cSmrg    compile_rpath_tail=
69184642e01fSmrg    finalize_rpath=
69194642e01fSmrg    compile_shlibpath=
69204642e01fSmrg    finalize_shlibpath=
69214642e01fSmrg    convenience=
69224642e01fSmrg    old_convenience=
69234642e01fSmrg    deplibs=
69244642e01fSmrg    old_deplibs=
69254642e01fSmrg    compiler_flags=
69264642e01fSmrg    linker_flags=
69274642e01fSmrg    dllsearchpath=
69284642e01fSmrg    lib_search_path=`pwd`
69294642e01fSmrg    inst_prefix_dir=
69304642e01fSmrg    new_inherited_linker_flags=
693105b261ecSmrg
69324642e01fSmrg    avoid_version=no
69336747b715Smrg    bindir=
69344642e01fSmrg    dlfiles=
69354642e01fSmrg    dlprefiles=
69364642e01fSmrg    dlself=no
69374642e01fSmrg    export_dynamic=no
69384642e01fSmrg    export_symbols=
69394642e01fSmrg    export_symbols_regex=
69404642e01fSmrg    generated=
69414642e01fSmrg    libobjs=
69424642e01fSmrg    ltlibs=
69434642e01fSmrg    module=no
69444642e01fSmrg    no_install=no
69454642e01fSmrg    objs=
694635c4bbdfSmrg    os2dllname=
69474642e01fSmrg    non_pic_objects=
69484642e01fSmrg    precious_files_regex=
69494642e01fSmrg    prefer_static_libs=no
695035c4bbdfSmrg    preload=false
69514642e01fSmrg    prev=
69524642e01fSmrg    prevarg=
69534642e01fSmrg    release=
69544642e01fSmrg    rpath=
69554642e01fSmrg    xrpath=
69564642e01fSmrg    perm_rpath=
69574642e01fSmrg    temp_rpath=
695854b5899cSmrg    temp_rpath_tail=
69594642e01fSmrg    thread_safe=no
69604642e01fSmrg    vinfo=
69614642e01fSmrg    vinfo_number=no
69624642e01fSmrg    weak_libs=
696354b5899cSmrg    rpath_arg=
696435c4bbdfSmrg    single_module=$wl-single_module
69654642e01fSmrg    func_infer_tag $base_compile
696605b261ecSmrg
69674642e01fSmrg    # We need to know -static, to get the right output filenames.
69684642e01fSmrg    for arg
69694642e01fSmrg    do
69704642e01fSmrg      case $arg in
69714642e01fSmrg      -shared)
697235c4bbdfSmrg	test yes != "$build_libtool_libs" \
697335c4bbdfSmrg	  && func_fatal_configuration "cannot build a shared library"
69744642e01fSmrg	build_old_libs=no
69754642e01fSmrg	break
69764642e01fSmrg	;;
69774642e01fSmrg      -all-static | -static | -static-libtool-libs)
69784642e01fSmrg	case $arg in
69794642e01fSmrg	-all-static)
698035c4bbdfSmrg	  if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then
69814642e01fSmrg	    func_warning "complete static linking is impossible in this configuration"
69824642e01fSmrg	  fi
69834642e01fSmrg	  if test -n "$link_static_flag"; then
69844642e01fSmrg	    dlopen_self=$dlopen_self_static
69854642e01fSmrg	  fi
69864642e01fSmrg	  prefer_static_libs=yes
69874642e01fSmrg	  ;;
69884642e01fSmrg	-static)
69894642e01fSmrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
69904642e01fSmrg	    dlopen_self=$dlopen_self_static
69914642e01fSmrg	  fi
69924642e01fSmrg	  prefer_static_libs=built
69934642e01fSmrg	  ;;
69944642e01fSmrg	-static-libtool-libs)
69954642e01fSmrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
69964642e01fSmrg	    dlopen_self=$dlopen_self_static
69974642e01fSmrg	  fi
69984642e01fSmrg	  prefer_static_libs=yes
69994642e01fSmrg	  ;;
70004642e01fSmrg	esac
70014642e01fSmrg	build_libtool_libs=no
70024642e01fSmrg	build_old_libs=yes
70034642e01fSmrg	break
70044642e01fSmrg	;;
70054642e01fSmrg      esac
70064642e01fSmrg    done
700705b261ecSmrg
70084642e01fSmrg    # See if our shared archives depend on static archives.
70094642e01fSmrg    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
701005b261ecSmrg
70114642e01fSmrg    # Go through the arguments, transforming them on the way.
70124642e01fSmrg    while test "$#" -gt 0; do
701335c4bbdfSmrg      arg=$1
70144642e01fSmrg      shift
7015c82838c1Smrg      func_quote_arg pretty,unquoted "$arg"
7016c82838c1Smrg      qarg=$func_quote_arg_unquoted_result
7017c82838c1Smrg      func_append libtool_args " $func_quote_arg_result"
701805b261ecSmrg
70194642e01fSmrg      # If the previous option needs an argument, assign it.
70204642e01fSmrg      if test -n "$prev"; then
70214642e01fSmrg	case $prev in
70224642e01fSmrg	output)
70234642e01fSmrg	  func_append compile_command " @OUTPUT@"
70244642e01fSmrg	  func_append finalize_command " @OUTPUT@"
70254642e01fSmrg	  ;;
70264642e01fSmrg	esac
702705b261ecSmrg
70284642e01fSmrg	case $prev in
70296747b715Smrg	bindir)
703035c4bbdfSmrg	  bindir=$arg
70316747b715Smrg	  prev=
70326747b715Smrg	  continue
70336747b715Smrg	  ;;
70344642e01fSmrg	dlfiles|dlprefiles)
703535c4bbdfSmrg	  $preload || {
70364642e01fSmrg	    # Add the symbol object into the linking commands.
70374642e01fSmrg	    func_append compile_command " @SYMFILE@"
70384642e01fSmrg	    func_append finalize_command " @SYMFILE@"
703935c4bbdfSmrg	    preload=:
704035c4bbdfSmrg	  }
70414642e01fSmrg	  case $arg in
70424642e01fSmrg	  *.la | *.lo) ;;  # We handle these cases below.
70434642e01fSmrg	  force)
704435c4bbdfSmrg	    if test no = "$dlself"; then
70454642e01fSmrg	      dlself=needless
70464642e01fSmrg	      export_dynamic=yes
70474642e01fSmrg	    fi
70484642e01fSmrg	    prev=
70494642e01fSmrg	    continue
70504642e01fSmrg	    ;;
70514642e01fSmrg	  self)
705235c4bbdfSmrg	    if test dlprefiles = "$prev"; then
70534642e01fSmrg	      dlself=yes
705435c4bbdfSmrg	    elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then
70554642e01fSmrg	      dlself=yes
70564642e01fSmrg	    else
70574642e01fSmrg	      dlself=needless
70584642e01fSmrg	      export_dynamic=yes
70594642e01fSmrg	    fi
70604642e01fSmrg	    prev=
70614642e01fSmrg	    continue
70624642e01fSmrg	    ;;
70634642e01fSmrg	  *)
706435c4bbdfSmrg	    if test dlfiles = "$prev"; then
706535c4bbdfSmrg	      func_append dlfiles " $arg"
70664642e01fSmrg	    else
706735c4bbdfSmrg	      func_append dlprefiles " $arg"
70684642e01fSmrg	    fi
70694642e01fSmrg	    prev=
70704642e01fSmrg	    continue
70714642e01fSmrg	    ;;
70724642e01fSmrg	  esac
70734642e01fSmrg	  ;;
70744642e01fSmrg	expsyms)
707535c4bbdfSmrg	  export_symbols=$arg
70764642e01fSmrg	  test -f "$arg" \
707735c4bbdfSmrg	    || func_fatal_error "symbol file '$arg' does not exist"
70784642e01fSmrg	  prev=
70794642e01fSmrg	  continue
70804642e01fSmrg	  ;;
70814642e01fSmrg	expsyms_regex)
708235c4bbdfSmrg	  export_symbols_regex=$arg
70834642e01fSmrg	  prev=
70844642e01fSmrg	  continue
70854642e01fSmrg	  ;;
70864642e01fSmrg	framework)
708705b261ecSmrg	  case $host in
70884642e01fSmrg	    *-*-darwin*)
70894642e01fSmrg	      case "$deplibs " in
70904642e01fSmrg		*" $qarg.ltframework "*) ;;
709135c4bbdfSmrg		*) func_append deplibs " $qarg.ltframework" # this is fixed later
70924642e01fSmrg		   ;;
70934642e01fSmrg	      esac
70944642e01fSmrg	      ;;
709505b261ecSmrg	  esac
70964642e01fSmrg	  prev=
70974642e01fSmrg	  continue
709805b261ecSmrg	  ;;
70994642e01fSmrg	inst_prefix)
710035c4bbdfSmrg	  inst_prefix_dir=$arg
710135c4bbdfSmrg	  prev=
710235c4bbdfSmrg	  continue
710335c4bbdfSmrg	  ;;
710435c4bbdfSmrg	mllvm)
710535c4bbdfSmrg	  # Clang does not use LLVM to link, so we can simply discard any
710635c4bbdfSmrg	  # '-mllvm $arg' options when doing the link step.
71074642e01fSmrg	  prev=
71084642e01fSmrg	  continue
710905b261ecSmrg	  ;;
71104642e01fSmrg	objectlist)
71114642e01fSmrg	  if test -f "$arg"; then
71124642e01fSmrg	    save_arg=$arg
71134642e01fSmrg	    moreargs=
71144642e01fSmrg	    for fil in `cat "$save_arg"`
71154642e01fSmrg	    do
711635c4bbdfSmrg#	      func_append moreargs " $fil"
71174642e01fSmrg	      arg=$fil
71184642e01fSmrg	      # A libtool-controlled object.
711905b261ecSmrg
71204642e01fSmrg	      # Check to see that this really is a libtool object.
71214642e01fSmrg	      if func_lalib_unsafe_p "$arg"; then
71224642e01fSmrg		pic_object=
71234642e01fSmrg		non_pic_object=
712405b261ecSmrg
71254642e01fSmrg		# Read the .lo file
71264642e01fSmrg		func_source "$arg"
712705b261ecSmrg
71284642e01fSmrg		if test -z "$pic_object" ||
71294642e01fSmrg		   test -z "$non_pic_object" ||
713035c4bbdfSmrg		   test none = "$pic_object" &&
713135c4bbdfSmrg		   test none = "$non_pic_object"; then
713235c4bbdfSmrg		  func_fatal_error "cannot find name of object for '$arg'"
71334642e01fSmrg		fi
713405b261ecSmrg
71354642e01fSmrg		# Extract subdirectory from the argument.
71364642e01fSmrg		func_dirname "$arg" "/" ""
713735c4bbdfSmrg		xdir=$func_dirname_result
713805b261ecSmrg
713935c4bbdfSmrg		if test none != "$pic_object"; then
71404642e01fSmrg		  # Prepend the subdirectory the object is found in.
714135c4bbdfSmrg		  pic_object=$xdir$pic_object
714205b261ecSmrg
714335c4bbdfSmrg		  if test dlfiles = "$prev"; then
714435c4bbdfSmrg		    if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
714535c4bbdfSmrg		      func_append dlfiles " $pic_object"
71464642e01fSmrg		      prev=
71474642e01fSmrg		      continue
71484642e01fSmrg		    else
71494642e01fSmrg		      # If libtool objects are unsupported, then we need to preload.
71504642e01fSmrg		      prev=dlprefiles
71514642e01fSmrg		    fi
71524642e01fSmrg		  fi
715305b261ecSmrg
71544642e01fSmrg		  # CHECK ME:  I think I busted this.  -Ossama
715535c4bbdfSmrg		  if test dlprefiles = "$prev"; then
71564642e01fSmrg		    # Preload the old-style object.
715735c4bbdfSmrg		    func_append dlprefiles " $pic_object"
71584642e01fSmrg		    prev=
71594642e01fSmrg		  fi
716005b261ecSmrg
71614642e01fSmrg		  # A PIC object.
71624642e01fSmrg		  func_append libobjs " $pic_object"
716335c4bbdfSmrg		  arg=$pic_object
71644642e01fSmrg		fi
716505b261ecSmrg
71664642e01fSmrg		# Non-PIC object.
716735c4bbdfSmrg		if test none != "$non_pic_object"; then
71684642e01fSmrg		  # Prepend the subdirectory the object is found in.
716935c4bbdfSmrg		  non_pic_object=$xdir$non_pic_object
717005b261ecSmrg
71714642e01fSmrg		  # A standard non-PIC object
71724642e01fSmrg		  func_append non_pic_objects " $non_pic_object"
717335c4bbdfSmrg		  if test -z "$pic_object" || test none = "$pic_object"; then
717435c4bbdfSmrg		    arg=$non_pic_object
71754642e01fSmrg		  fi
71764642e01fSmrg		else
71774642e01fSmrg		  # If the PIC object exists, use it instead.
71784642e01fSmrg		  # $xdir was prepended to $pic_object above.
717935c4bbdfSmrg		  non_pic_object=$pic_object
71804642e01fSmrg		  func_append non_pic_objects " $non_pic_object"
71814642e01fSmrg		fi
71824642e01fSmrg	      else
71834642e01fSmrg		# Only an error if not doing a dry-run.
71844642e01fSmrg		if $opt_dry_run; then
71854642e01fSmrg		  # Extract subdirectory from the argument.
71864642e01fSmrg		  func_dirname "$arg" "/" ""
718735c4bbdfSmrg		  xdir=$func_dirname_result
71884642e01fSmrg
71894642e01fSmrg		  func_lo2o "$arg"
71904642e01fSmrg		  pic_object=$xdir$objdir/$func_lo2o_result
71914642e01fSmrg		  non_pic_object=$xdir$func_lo2o_result
71924642e01fSmrg		  func_append libobjs " $pic_object"
71934642e01fSmrg		  func_append non_pic_objects " $non_pic_object"
71944642e01fSmrg	        else
719535c4bbdfSmrg		  func_fatal_error "'$arg' is not a valid libtool object"
71964642e01fSmrg		fi
71974642e01fSmrg	      fi
71984642e01fSmrg	    done
719905b261ecSmrg	  else
720035c4bbdfSmrg	    func_fatal_error "link input file '$arg' does not exist"
720105b261ecSmrg	  fi
72024642e01fSmrg	  arg=$save_arg
72034642e01fSmrg	  prev=
72044642e01fSmrg	  continue
72054642e01fSmrg	  ;;
720635c4bbdfSmrg	os2dllname)
720735c4bbdfSmrg	  os2dllname=$arg
720835c4bbdfSmrg	  prev=
720935c4bbdfSmrg	  continue
721035c4bbdfSmrg	  ;;
72114642e01fSmrg	precious_regex)
721235c4bbdfSmrg	  precious_files_regex=$arg
72134642e01fSmrg	  prev=
72144642e01fSmrg	  continue
72154642e01fSmrg	  ;;
72164642e01fSmrg	release)
721735c4bbdfSmrg	  release=-$arg
72184642e01fSmrg	  prev=
72194642e01fSmrg	  continue
72204642e01fSmrg	  ;;
72214642e01fSmrg	rpath | xrpath)
72224642e01fSmrg	  # We need an absolute path.
72234642e01fSmrg	  case $arg in
72244642e01fSmrg	  [\\/]* | [A-Za-z]:[\\/]*) ;;
72254642e01fSmrg	  *)
722654b5899cSmrg	    func_fatal_error "argument to -rpath is not absolute: $arg"
72274642e01fSmrg	    ;;
72284642e01fSmrg	  esac
722935c4bbdfSmrg	  if test rpath = "$prev"; then
72304642e01fSmrg	    case "$rpath " in
72314642e01fSmrg	    *" $arg "*) ;;
723235c4bbdfSmrg	    *) func_append rpath " $arg" ;;
72334642e01fSmrg	    esac
723405b261ecSmrg	  else
72354642e01fSmrg	    case "$xrpath " in
72364642e01fSmrg	    *" $arg "*) ;;
723735c4bbdfSmrg	    *) func_append xrpath " $arg" ;;
72384642e01fSmrg	    esac
723905b261ecSmrg	  fi
72404642e01fSmrg	  prev=
72414642e01fSmrg	  continue
72424642e01fSmrg	  ;;
72434642e01fSmrg	shrext)
724435c4bbdfSmrg	  shrext_cmds=$arg
72454642e01fSmrg	  prev=
72464642e01fSmrg	  continue
72474642e01fSmrg	  ;;
72484642e01fSmrg	weak)
724935c4bbdfSmrg	  func_append weak_libs " $arg"
72504642e01fSmrg	  prev=
72514642e01fSmrg	  continue
72524642e01fSmrg	  ;;
7253c82838c1Smrg	xassembler)
7254c82838c1Smrg	  func_append compiler_flags " -Xassembler $qarg"
7255c82838c1Smrg	  prev=
7256c82838c1Smrg	  func_append compile_command " -Xassembler $qarg"
7257c82838c1Smrg	  func_append finalize_command " -Xassembler $qarg"
7258c82838c1Smrg	  continue
7259c82838c1Smrg	  ;;
72604642e01fSmrg	xcclinker)
726135c4bbdfSmrg	  func_append linker_flags " $qarg"
726235c4bbdfSmrg	  func_append compiler_flags " $qarg"
72634642e01fSmrg	  prev=
72644642e01fSmrg	  func_append compile_command " $qarg"
72654642e01fSmrg	  func_append finalize_command " $qarg"
72664642e01fSmrg	  continue
72674642e01fSmrg	  ;;
72684642e01fSmrg	xcompiler)
726935c4bbdfSmrg	  func_append compiler_flags " $qarg"
72704642e01fSmrg	  prev=
72714642e01fSmrg	  func_append compile_command " $qarg"
72724642e01fSmrg	  func_append finalize_command " $qarg"
72734642e01fSmrg	  continue
72744642e01fSmrg	  ;;
72754642e01fSmrg	xlinker)
727635c4bbdfSmrg	  func_append linker_flags " $qarg"
727735c4bbdfSmrg	  func_append compiler_flags " $wl$qarg"
72784642e01fSmrg	  prev=
72794642e01fSmrg	  func_append compile_command " $wl$qarg"
72804642e01fSmrg	  func_append finalize_command " $wl$qarg"
72814642e01fSmrg	  continue
72824642e01fSmrg	  ;;
72834642e01fSmrg	*)
72844642e01fSmrg	  eval "$prev=\"\$arg\""
72854642e01fSmrg	  prev=
72864642e01fSmrg	  continue
72874642e01fSmrg	  ;;
728805b261ecSmrg	esac
72894642e01fSmrg      fi # test -n "$prev"
729005b261ecSmrg
729135c4bbdfSmrg      prevarg=$arg
729205b261ecSmrg
72934642e01fSmrg      case $arg in
72944642e01fSmrg      -all-static)
72954642e01fSmrg	if test -n "$link_static_flag"; then
72964642e01fSmrg	  # See comment for -static flag below, for more details.
72974642e01fSmrg	  func_append compile_command " $link_static_flag"
72984642e01fSmrg	  func_append finalize_command " $link_static_flag"
72994642e01fSmrg	fi
73004642e01fSmrg	continue
73014642e01fSmrg	;;
730205b261ecSmrg
73034642e01fSmrg      -allow-undefined)
73044642e01fSmrg	# FIXME: remove this flag sometime in the future.
730535c4bbdfSmrg	func_fatal_error "'-allow-undefined' must not be used because it is the default"
73064642e01fSmrg	;;
730705b261ecSmrg
73084642e01fSmrg      -avoid-version)
73094642e01fSmrg	avoid_version=yes
73104642e01fSmrg	continue
73114642e01fSmrg	;;
731205b261ecSmrg
73136747b715Smrg      -bindir)
73146747b715Smrg	prev=bindir
73156747b715Smrg	continue
73166747b715Smrg	;;
73176747b715Smrg
73184642e01fSmrg      -dlopen)
73194642e01fSmrg	prev=dlfiles
73204642e01fSmrg	continue
73214642e01fSmrg	;;
732205b261ecSmrg
73234642e01fSmrg      -dlpreopen)
73244642e01fSmrg	prev=dlprefiles
73254642e01fSmrg	continue
73264642e01fSmrg	;;
732705b261ecSmrg
73284642e01fSmrg      -export-dynamic)
73294642e01fSmrg	export_dynamic=yes
73304642e01fSmrg	continue
73314642e01fSmrg	;;
733205b261ecSmrg
73334642e01fSmrg      -export-symbols | -export-symbols-regex)
73344642e01fSmrg	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
73354642e01fSmrg	  func_fatal_error "more than one -exported-symbols argument is not allowed"
73364642e01fSmrg	fi
733735c4bbdfSmrg	if test X-export-symbols = "X$arg"; then
73384642e01fSmrg	  prev=expsyms
73394642e01fSmrg	else
73404642e01fSmrg	  prev=expsyms_regex
73414642e01fSmrg	fi
73424642e01fSmrg	continue
73434642e01fSmrg	;;
734405b261ecSmrg
73454642e01fSmrg      -framework)
73464642e01fSmrg	prev=framework
73474642e01fSmrg	continue
73484642e01fSmrg	;;
734905b261ecSmrg
73504642e01fSmrg      -inst-prefix-dir)
73514642e01fSmrg	prev=inst_prefix
73524642e01fSmrg	continue
73534642e01fSmrg	;;
735405b261ecSmrg
73554642e01fSmrg      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
73564642e01fSmrg      # so, if we see these flags be careful not to treat them like -L
73574642e01fSmrg      -L[A-Z][A-Z]*:*)
73584642e01fSmrg	case $with_gcc/$host in
73594642e01fSmrg	no/*-*-irix* | /*-*-irix*)
73604642e01fSmrg	  func_append compile_command " $arg"
73614642e01fSmrg	  func_append finalize_command " $arg"
73624642e01fSmrg	  ;;
73634642e01fSmrg	esac
73644642e01fSmrg	continue
73654642e01fSmrg	;;
736605b261ecSmrg
73674642e01fSmrg      -L*)
736835c4bbdfSmrg	func_stripname "-L" '' "$arg"
736935c4bbdfSmrg	if test -z "$func_stripname_result"; then
73704642e01fSmrg	  if test "$#" -gt 0; then
737135c4bbdfSmrg	    func_fatal_error "require no space between '-L' and '$1'"
73724642e01fSmrg	  else
737335c4bbdfSmrg	    func_fatal_error "need path for '-L' option"
73744642e01fSmrg	  fi
73754642e01fSmrg	fi
737635c4bbdfSmrg	func_resolve_sysroot "$func_stripname_result"
737735c4bbdfSmrg	dir=$func_resolve_sysroot_result
73784642e01fSmrg	# We need an absolute path.
73794642e01fSmrg	case $dir in
73804642e01fSmrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
73814642e01fSmrg	*)
73824642e01fSmrg	  absdir=`cd "$dir" && pwd`
73834642e01fSmrg	  test -z "$absdir" && \
738435c4bbdfSmrg	    func_fatal_error "cannot determine absolute directory name of '$dir'"
738535c4bbdfSmrg	  dir=$absdir
73864642e01fSmrg	  ;;
73874642e01fSmrg	esac
73884642e01fSmrg	case "$deplibs " in
738935c4bbdfSmrg	*" -L$dir "* | *" $arg "*)
739035c4bbdfSmrg	  # Will only happen for absolute or sysroot arguments
739135c4bbdfSmrg	  ;;
73924642e01fSmrg	*)
739335c4bbdfSmrg	  # Preserve sysroot, but never include relative directories
739435c4bbdfSmrg	  case $dir in
739535c4bbdfSmrg	    [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
739635c4bbdfSmrg	    *) func_append deplibs " -L$dir" ;;
739735c4bbdfSmrg	  esac
739835c4bbdfSmrg	  func_append lib_search_path " $dir"
73994642e01fSmrg	  ;;
74004642e01fSmrg	esac
74014642e01fSmrg	case $host in
740254b5899cSmrg	*-*-cygwin* | *-*-mingw* | *-*-windows* | *-*-pw32* | *-*-os2* | *-cegcc*)
74036747b715Smrg	  testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
74044642e01fSmrg	  case :$dllsearchpath: in
74054642e01fSmrg	  *":$dir:"*) ;;
74064642e01fSmrg	  ::) dllsearchpath=$dir;;
740735c4bbdfSmrg	  *) func_append dllsearchpath ":$dir";;
74084642e01fSmrg	  esac
74094642e01fSmrg	  case :$dllsearchpath: in
74104642e01fSmrg	  *":$testbindir:"*) ;;
74114642e01fSmrg	  ::) dllsearchpath=$testbindir;;
741235c4bbdfSmrg	  *) func_append dllsearchpath ":$testbindir";;
74134642e01fSmrg	  esac
74144642e01fSmrg	  ;;
74154642e01fSmrg	esac
74164642e01fSmrg	continue
74174642e01fSmrg	;;
741805b261ecSmrg
74194642e01fSmrg      -l*)
742035c4bbdfSmrg	if test X-lc = "X$arg" || test X-lm = "X$arg"; then
74214642e01fSmrg	  case $host in
742254b5899cSmrg	  *-*-cygwin* | *-*-mingw* | *-*-windows* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
74234642e01fSmrg	    # These systems don't actually have a C or math library (as such)
74244642e01fSmrg	    continue
74254642e01fSmrg	    ;;
74264642e01fSmrg	  *-*-os2*)
74274642e01fSmrg	    # These systems don't actually have a C library (as such)
742835c4bbdfSmrg	    test X-lc = "X$arg" && continue
74294642e01fSmrg	    ;;
743054b5899cSmrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-midnightbsd*)
74314642e01fSmrg	    # Do not include libc due to us having libc/libc_r.
743235c4bbdfSmrg	    test X-lc = "X$arg" && continue
74334642e01fSmrg	    ;;
74344642e01fSmrg	  *-*-rhapsody* | *-*-darwin1.[012])
74354642e01fSmrg	    # Rhapsody C and math libraries are in the System framework
743635c4bbdfSmrg	    func_append deplibs " System.ltframework"
74374642e01fSmrg	    continue
74384642e01fSmrg	    ;;
74394642e01fSmrg	  *-*-sco3.2v5* | *-*-sco5v6*)
74404642e01fSmrg	    # Causes problems with __ctype
744135c4bbdfSmrg	    test X-lc = "X$arg" && continue
74424642e01fSmrg	    ;;
74434642e01fSmrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
74444642e01fSmrg	    # Compiler inserts libc in the correct place for threads to work
744535c4bbdfSmrg	    test X-lc = "X$arg" && continue
74464642e01fSmrg	    ;;
74474642e01fSmrg	  esac
744835c4bbdfSmrg	elif test X-lc_r = "X$arg"; then
74494642e01fSmrg	 case $host in
745054b5899cSmrg	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-midnightbsd*)
74514642e01fSmrg	   # Do not include libc_r directly, use -pthread flag.
74524642e01fSmrg	   continue
74534642e01fSmrg	   ;;
74544642e01fSmrg	 esac
74554642e01fSmrg	fi
745635c4bbdfSmrg	func_append deplibs " $arg"
745735c4bbdfSmrg	continue
745835c4bbdfSmrg	;;
745935c4bbdfSmrg
746035c4bbdfSmrg      -mllvm)
746135c4bbdfSmrg	prev=mllvm
74624642e01fSmrg	continue
74634642e01fSmrg	;;
746405b261ecSmrg
74654642e01fSmrg      -module)
74664642e01fSmrg	module=yes
74674642e01fSmrg	continue
74684642e01fSmrg	;;
746905b261ecSmrg
74704642e01fSmrg      # Tru64 UNIX uses -model [arg] to determine the layout of C++
74714642e01fSmrg      # classes, name mangling, and exception handling.
74724642e01fSmrg      # Darwin uses the -arch flag to determine output architecture.
747354b5899cSmrg      # -q <option> for IBM XL C/C++ compiler.
747454b5899cSmrg      -model|-arch|-isysroot|--sysroot|-q)
747535c4bbdfSmrg	func_append compiler_flags " $arg"
74764642e01fSmrg	func_append compile_command " $arg"
74774642e01fSmrg	func_append finalize_command " $arg"
74784642e01fSmrg	prev=xcompiler
74794642e01fSmrg	continue
74804642e01fSmrg	;;
7481c82838c1Smrg     # Solaris ld rejects as of 11.4. Refer to Oracle bug 22985199.
7482c82838c1Smrg     -pthread)
7483c82838c1Smrg	case $host in
7484c82838c1Smrg	  *solaris2*) ;;
7485c82838c1Smrg	  *)
7486c82838c1Smrg	    case "$new_inherited_linker_flags " in
7487c82838c1Smrg	        *" $arg "*) ;;
7488c82838c1Smrg	        * ) func_append new_inherited_linker_flags " $arg" ;;
7489c82838c1Smrg	    esac
7490c82838c1Smrg	  ;;
7491c82838c1Smrg	esac
7492c82838c1Smrg	continue
7493c82838c1Smrg	;;
7494c82838c1Smrg      -mt|-mthreads|-kthread|-Kthread|-pthreads|--thread-safe \
749554b5899cSmrg      |-threads|-fopenmp|-fopenmp=*|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
749635c4bbdfSmrg	func_append compiler_flags " $arg"
74974642e01fSmrg	func_append compile_command " $arg"
74984642e01fSmrg	func_append finalize_command " $arg"
74994642e01fSmrg	case "$new_inherited_linker_flags " in
75004642e01fSmrg	    *" $arg "*) ;;
750135c4bbdfSmrg	    * ) func_append new_inherited_linker_flags " $arg" ;;
75024642e01fSmrg	esac
75034642e01fSmrg	continue
75044642e01fSmrg	;;
750505b261ecSmrg
75064642e01fSmrg      -multi_module)
750735c4bbdfSmrg	single_module=$wl-multi_module
75084642e01fSmrg	continue
75094642e01fSmrg	;;
751005b261ecSmrg
75114642e01fSmrg      -no-fast-install)
75124642e01fSmrg	fast_install=no
75134642e01fSmrg	continue
75144642e01fSmrg	;;
751505b261ecSmrg
75164642e01fSmrg      -no-install)
75174642e01fSmrg	case $host in
751854b5899cSmrg	*-*-cygwin* | *-*-mingw* | *-*-windows* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
75194642e01fSmrg	  # The PATH hackery in wrapper scripts is required on Windows
75204642e01fSmrg	  # and Darwin in order for the loader to find any dlls it needs.
752135c4bbdfSmrg	  func_warning "'-no-install' is ignored for $host"
752235c4bbdfSmrg	  func_warning "assuming '-no-fast-install' instead"
75234642e01fSmrg	  fast_install=no
75244642e01fSmrg	  ;;
75254642e01fSmrg	*) no_install=yes ;;
75264642e01fSmrg	esac
75274642e01fSmrg	continue
75284642e01fSmrg	;;
752905b261ecSmrg
75304642e01fSmrg      -no-undefined)
75314642e01fSmrg	allow_undefined=no
75324642e01fSmrg	continue
75334642e01fSmrg	;;
753405b261ecSmrg
75354642e01fSmrg      -objectlist)
75364642e01fSmrg	prev=objectlist
75374642e01fSmrg	continue
75384642e01fSmrg	;;
753905b261ecSmrg
754035c4bbdfSmrg      -os2dllname)
754135c4bbdfSmrg	prev=os2dllname
754235c4bbdfSmrg	continue
754335c4bbdfSmrg	;;
754435c4bbdfSmrg
75454642e01fSmrg      -o) prev=output ;;
754605b261ecSmrg
75474642e01fSmrg      -precious-files-regex)
75484642e01fSmrg	prev=precious_regex
75494642e01fSmrg	continue
75504642e01fSmrg	;;
755105b261ecSmrg
75524642e01fSmrg      -release)
75534642e01fSmrg	prev=release
75544642e01fSmrg	continue
75554642e01fSmrg	;;
755605b261ecSmrg
75574642e01fSmrg      -rpath)
75584642e01fSmrg	prev=rpath
75594642e01fSmrg	continue
75604642e01fSmrg	;;
756105b261ecSmrg
75624642e01fSmrg      -R)
75634642e01fSmrg	prev=xrpath
75644642e01fSmrg	continue
75654642e01fSmrg	;;
756605b261ecSmrg
75674642e01fSmrg      -R*)
75684642e01fSmrg	func_stripname '-R' '' "$arg"
75694642e01fSmrg	dir=$func_stripname_result
75704642e01fSmrg	# We need an absolute path.
75714642e01fSmrg	case $dir in
75724642e01fSmrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
757335c4bbdfSmrg	=*)
757435c4bbdfSmrg	  func_stripname '=' '' "$dir"
757535c4bbdfSmrg	  dir=$lt_sysroot$func_stripname_result
757635c4bbdfSmrg	  ;;
75774642e01fSmrg	*)
757854b5899cSmrg	  func_fatal_error "argument ($arg) to '-R' is not an absolute path: $dir"
75794642e01fSmrg	  ;;
75804642e01fSmrg	esac
75814642e01fSmrg	case "$xrpath " in
75824642e01fSmrg	*" $dir "*) ;;
758335c4bbdfSmrg	*) func_append xrpath " $dir" ;;
75844642e01fSmrg	esac
75854642e01fSmrg	continue
75864642e01fSmrg	;;
758705b261ecSmrg
75884642e01fSmrg      -shared)
75894642e01fSmrg	# The effects of -shared are defined in a previous loop.
75904642e01fSmrg	continue
75914642e01fSmrg	;;
759205b261ecSmrg
75934642e01fSmrg      -shrext)
75944642e01fSmrg	prev=shrext
75954642e01fSmrg	continue
75964642e01fSmrg	;;
759705b261ecSmrg
75984642e01fSmrg      -static | -static-libtool-libs)
75994642e01fSmrg	# The effects of -static are defined in a previous loop.
76004642e01fSmrg	# We used to do the same as -all-static on platforms that
76014642e01fSmrg	# didn't have a PIC flag, but the assumption that the effects
76024642e01fSmrg	# would be equivalent was wrong.  It would break on at least
76034642e01fSmrg	# Digital Unix and AIX.
76044642e01fSmrg	continue
76054642e01fSmrg	;;
760605b261ecSmrg
76074642e01fSmrg      -thread-safe)
76084642e01fSmrg	thread_safe=yes
76094642e01fSmrg	continue
76104642e01fSmrg	;;
761105b261ecSmrg
76124642e01fSmrg      -version-info)
76134642e01fSmrg	prev=vinfo
76144642e01fSmrg	continue
76154642e01fSmrg	;;
761605b261ecSmrg
76174642e01fSmrg      -version-number)
76184642e01fSmrg	prev=vinfo
76194642e01fSmrg	vinfo_number=yes
76204642e01fSmrg	continue
76214642e01fSmrg	;;
762205b261ecSmrg
76234642e01fSmrg      -weak)
76244642e01fSmrg        prev=weak
76254642e01fSmrg	continue
76264642e01fSmrg	;;
762705b261ecSmrg
76284642e01fSmrg      -Wc,*)
76294642e01fSmrg	func_stripname '-Wc,' '' "$arg"
76304642e01fSmrg	args=$func_stripname_result
76314642e01fSmrg	arg=
763235c4bbdfSmrg	save_ifs=$IFS; IFS=,
76334642e01fSmrg	for flag in $args; do
763435c4bbdfSmrg	  IFS=$save_ifs
7635c82838c1Smrg          func_quote_arg pretty "$flag"
7636c82838c1Smrg	  func_append arg " $func_quote_arg_result"
7637c82838c1Smrg	  func_append compiler_flags " $func_quote_arg_result"
76384642e01fSmrg	done
763935c4bbdfSmrg	IFS=$save_ifs
76404642e01fSmrg	func_stripname ' ' '' "$arg"
76414642e01fSmrg	arg=$func_stripname_result
76424642e01fSmrg	;;
764305b261ecSmrg
76444642e01fSmrg      -Wl,*)
76454642e01fSmrg	func_stripname '-Wl,' '' "$arg"
76464642e01fSmrg	args=$func_stripname_result
76474642e01fSmrg	arg=
764835c4bbdfSmrg	save_ifs=$IFS; IFS=,
76494642e01fSmrg	for flag in $args; do
765035c4bbdfSmrg	  IFS=$save_ifs
7651c82838c1Smrg          func_quote_arg pretty "$flag"
7652c82838c1Smrg	  func_append arg " $wl$func_quote_arg_result"
7653c82838c1Smrg	  func_append compiler_flags " $wl$func_quote_arg_result"
7654c82838c1Smrg	  func_append linker_flags " $func_quote_arg_result"
76554642e01fSmrg	done
765635c4bbdfSmrg	IFS=$save_ifs
76574642e01fSmrg	func_stripname ' ' '' "$arg"
76584642e01fSmrg	arg=$func_stripname_result
76594642e01fSmrg	;;
766005b261ecSmrg
7661c82838c1Smrg      -Xassembler)
7662c82838c1Smrg        prev=xassembler
7663c82838c1Smrg        continue
7664c82838c1Smrg        ;;
7665c82838c1Smrg
76664642e01fSmrg      -Xcompiler)
76674642e01fSmrg	prev=xcompiler
76684642e01fSmrg	continue
76694642e01fSmrg	;;
767005b261ecSmrg
76714642e01fSmrg      -Xlinker)
76724642e01fSmrg	prev=xlinker
76734642e01fSmrg	continue
76744642e01fSmrg	;;
767505b261ecSmrg
76764642e01fSmrg      -XCClinker)
76774642e01fSmrg	prev=xcclinker
76784642e01fSmrg	continue
76794642e01fSmrg	;;
768005b261ecSmrg
76814642e01fSmrg      # -msg_* for osf cc
76824642e01fSmrg      -msg_*)
7683c82838c1Smrg	func_quote_arg pretty "$arg"
7684c82838c1Smrg	arg=$func_quote_arg_result
76854642e01fSmrg	;;
768605b261ecSmrg
76876747b715Smrg      # Flags to be passed through unchanged, with rationale:
76886747b715Smrg      # -64, -mips[0-9]      enable 64-bit mode for the SGI compiler
76896747b715Smrg      # -r[0-9][0-9]*        specify processor for the SGI compiler
76906747b715Smrg      # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
76916747b715Smrg      # +DA*, +DD*           enable 64-bit mode for the HP compiler
76926747b715Smrg      # -q*                  compiler args for the IBM compiler
76936747b715Smrg      # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
76946747b715Smrg      # -F/path              path to uninstalled frameworks, gcc on darwin
76956747b715Smrg      # -p, -pg, --coverage, -fprofile-*  profiling flags for GCC
769635c4bbdfSmrg      # -fstack-protector*   stack protector flags for GCC
76976747b715Smrg      # @file                GCC response files
76986747b715Smrg      # -tp=*                Portland pgcc target processor selection
769935c4bbdfSmrg      # --sysroot=*          for sysroot support
770035c4bbdfSmrg      # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
77011b5d61b8Smrg      # -specs=*             GCC specs files
770235c4bbdfSmrg      # -stdlib=*            select c++ std lib with clang
770354b5899cSmrg      # -fdiagnostics-color* simply affects output
770454b5899cSmrg      # -frecord-gcc-switches used to verify flags were respected
770525da500fSmrg      # -fsanitize=*         Clang/GCC memory and address sanitizer
770654b5899cSmrg      # -fno-sanitize*       Clang/GCC memory and address sanitizer
770754b5899cSmrg      # -shared-libsan       Link with shared sanitizer runtimes (Clang)
770854b5899cSmrg      # -static-libsan       Link with static sanitizer runtimes (Clang)
770954b5899cSmrg      # -no-canonical-prefixes Do not expand any symbolic links
771025da500fSmrg      # -fuse-ld=*           Linker select flags for GCC
771154b5899cSmrg      # -static-*            direct GCC to link specific libraries statically
771254b5899cSmrg      # -fcilkplus           Cilk Plus language extension features for C/C++
771354b5899cSmrg      # -rtlib=*             select c runtime lib with clang
771454b5899cSmrg      # --unwindlib=*        select unwinder library with clang
771554b5899cSmrg      # -f{file|debug|macro|profile}-prefix-map=* needed for lto linking
7716c82838c1Smrg      # -Wa,*                Pass flags directly to the assembler
771754b5899cSmrg      # -Werror, -Werror=*   Report (specified) warnings as errors
77184642e01fSmrg      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
771935c4bbdfSmrg      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
772054b5899cSmrg      -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-no-canonical-prefixes| \
772154b5899cSmrg      -stdlib=*|-rtlib=*|--unwindlib=*| \
772254b5899cSmrg      -specs=*|-fsanitize=*|-fno-sanitize*|-shared-libsan|-static-libsan| \
772354b5899cSmrg      -ffile-prefix-map=*|-fdebug-prefix-map=*|-fmacro-prefix-map=*|-fprofile-prefix-map=*| \
772454b5899cSmrg      -fdiagnostics-color*|-frecord-gcc-switches| \
772554b5899cSmrg      -fuse-ld=*|-static-*|-fcilkplus|-Wa,*|-Werror|-Werror=*)
7726c82838c1Smrg        func_quote_arg pretty "$arg"
7727c82838c1Smrg	arg=$func_quote_arg_result
77284642e01fSmrg        func_append compile_command " $arg"
77294642e01fSmrg        func_append finalize_command " $arg"
773035c4bbdfSmrg        func_append compiler_flags " $arg"
77314642e01fSmrg        continue
77324642e01fSmrg        ;;
773305b261ecSmrg
773435c4bbdfSmrg      -Z*)
773535c4bbdfSmrg        if test os2 = "`expr $host : '.*\(os2\)'`"; then
773635c4bbdfSmrg          # OS/2 uses -Zxxx to specify OS/2-specific options
773735c4bbdfSmrg	  compiler_flags="$compiler_flags $arg"
773835c4bbdfSmrg	  func_append compile_command " $arg"
773935c4bbdfSmrg	  func_append finalize_command " $arg"
774035c4bbdfSmrg	  case $arg in
774135c4bbdfSmrg	  -Zlinker | -Zstack)
774235c4bbdfSmrg	    prev=xcompiler
774335c4bbdfSmrg	    ;;
774435c4bbdfSmrg	  esac
774535c4bbdfSmrg	  continue
774635c4bbdfSmrg        else
774735c4bbdfSmrg	  # Otherwise treat like 'Some other compiler flag' below
7748c82838c1Smrg	  func_quote_arg pretty "$arg"
7749c82838c1Smrg	  arg=$func_quote_arg_result
775035c4bbdfSmrg        fi
775135c4bbdfSmrg	;;
775235c4bbdfSmrg
77534642e01fSmrg      # Some other compiler flag.
77544642e01fSmrg      -* | +*)
7755c82838c1Smrg        func_quote_arg pretty "$arg"
7756c82838c1Smrg	arg=$func_quote_arg_result
77574642e01fSmrg	;;
775805b261ecSmrg
77594642e01fSmrg      *.$objext)
77604642e01fSmrg	# A standard object.
776135c4bbdfSmrg	func_append objs " $arg"
77624642e01fSmrg	;;
776305b261ecSmrg
77644642e01fSmrg      *.lo)
77654642e01fSmrg	# A libtool-controlled object.
776605b261ecSmrg
77674642e01fSmrg	# Check to see that this really is a libtool object.
77684642e01fSmrg	if func_lalib_unsafe_p "$arg"; then
77694642e01fSmrg	  pic_object=
77704642e01fSmrg	  non_pic_object=
777105b261ecSmrg
77724642e01fSmrg	  # Read the .lo file
77734642e01fSmrg	  func_source "$arg"
777405b261ecSmrg
77754642e01fSmrg	  if test -z "$pic_object" ||
77764642e01fSmrg	     test -z "$non_pic_object" ||
777735c4bbdfSmrg	     test none = "$pic_object" &&
777835c4bbdfSmrg	     test none = "$non_pic_object"; then
777935c4bbdfSmrg	    func_fatal_error "cannot find name of object for '$arg'"
77804642e01fSmrg	  fi
778105b261ecSmrg
77824642e01fSmrg	  # Extract subdirectory from the argument.
77834642e01fSmrg	  func_dirname "$arg" "/" ""
778435c4bbdfSmrg	  xdir=$func_dirname_result
778505b261ecSmrg
778635c4bbdfSmrg	  test none = "$pic_object" || {
77874642e01fSmrg	    # Prepend the subdirectory the object is found in.
778835c4bbdfSmrg	    pic_object=$xdir$pic_object
778905b261ecSmrg
779035c4bbdfSmrg	    if test dlfiles = "$prev"; then
779135c4bbdfSmrg	      if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
779235c4bbdfSmrg		func_append dlfiles " $pic_object"
77934642e01fSmrg		prev=
77944642e01fSmrg		continue
77954642e01fSmrg	      else
77964642e01fSmrg		# If libtool objects are unsupported, then we need to preload.
77974642e01fSmrg		prev=dlprefiles
77984642e01fSmrg	      fi
77994642e01fSmrg	    fi
780005b261ecSmrg
78014642e01fSmrg	    # CHECK ME:  I think I busted this.  -Ossama
780235c4bbdfSmrg	    if test dlprefiles = "$prev"; then
78034642e01fSmrg	      # Preload the old-style object.
780435c4bbdfSmrg	      func_append dlprefiles " $pic_object"
78054642e01fSmrg	      prev=
78064642e01fSmrg	    fi
780705b261ecSmrg
78084642e01fSmrg	    # A PIC object.
78094642e01fSmrg	    func_append libobjs " $pic_object"
781035c4bbdfSmrg	    arg=$pic_object
781135c4bbdfSmrg	  }
781205b261ecSmrg
78134642e01fSmrg	  # Non-PIC object.
781435c4bbdfSmrg	  if test none != "$non_pic_object"; then
78154642e01fSmrg	    # Prepend the subdirectory the object is found in.
781635c4bbdfSmrg	    non_pic_object=$xdir$non_pic_object
781705b261ecSmrg
78184642e01fSmrg	    # A standard non-PIC object
78194642e01fSmrg	    func_append non_pic_objects " $non_pic_object"
782035c4bbdfSmrg	    if test -z "$pic_object" || test none = "$pic_object"; then
782135c4bbdfSmrg	      arg=$non_pic_object
78224642e01fSmrg	    fi
78234642e01fSmrg	  else
78244642e01fSmrg	    # If the PIC object exists, use it instead.
78254642e01fSmrg	    # $xdir was prepended to $pic_object above.
782635c4bbdfSmrg	    non_pic_object=$pic_object
78274642e01fSmrg	    func_append non_pic_objects " $non_pic_object"
78284642e01fSmrg	  fi
78294642e01fSmrg	else
78304642e01fSmrg	  # Only an error if not doing a dry-run.
78314642e01fSmrg	  if $opt_dry_run; then
78324642e01fSmrg	    # Extract subdirectory from the argument.
78334642e01fSmrg	    func_dirname "$arg" "/" ""
783435c4bbdfSmrg	    xdir=$func_dirname_result
78354642e01fSmrg
78364642e01fSmrg	    func_lo2o "$arg"
78374642e01fSmrg	    pic_object=$xdir$objdir/$func_lo2o_result
78384642e01fSmrg	    non_pic_object=$xdir$func_lo2o_result
78394642e01fSmrg	    func_append libobjs " $pic_object"
78404642e01fSmrg	    func_append non_pic_objects " $non_pic_object"
78414642e01fSmrg	  else
784235c4bbdfSmrg	    func_fatal_error "'$arg' is not a valid libtool object"
78434642e01fSmrg	  fi
78444642e01fSmrg	fi
78454642e01fSmrg	;;
78464642e01fSmrg
78474642e01fSmrg      *.$libext)
78484642e01fSmrg	# An archive.
784935c4bbdfSmrg	func_append deplibs " $arg"
785035c4bbdfSmrg	func_append old_deplibs " $arg"
78514642e01fSmrg	continue
78524642e01fSmrg	;;
78534642e01fSmrg
78544642e01fSmrg      *.la)
78554642e01fSmrg	# A libtool-controlled library.
78564642e01fSmrg
785735c4bbdfSmrg	func_resolve_sysroot "$arg"
785835c4bbdfSmrg	if test dlfiles = "$prev"; then
78594642e01fSmrg	  # This library was specified with -dlopen.
786035c4bbdfSmrg	  func_append dlfiles " $func_resolve_sysroot_result"
78614642e01fSmrg	  prev=
786235c4bbdfSmrg	elif test dlprefiles = "$prev"; then
78634642e01fSmrg	  # The library was specified with -dlpreopen.
786435c4bbdfSmrg	  func_append dlprefiles " $func_resolve_sysroot_result"
78654642e01fSmrg	  prev=
78664642e01fSmrg	else
786735c4bbdfSmrg	  func_append deplibs " $func_resolve_sysroot_result"
78684642e01fSmrg	fi
78694642e01fSmrg	continue
78704642e01fSmrg	;;
78714642e01fSmrg
78724642e01fSmrg      # Some other compiler argument.
78734642e01fSmrg      *)
78744642e01fSmrg	# Unknown arguments in both finalize_command and compile_command need
78754642e01fSmrg	# to be aesthetically quoted because they are evaled later.
7876c82838c1Smrg	func_quote_arg pretty "$arg"
7877c82838c1Smrg	arg=$func_quote_arg_result
78784642e01fSmrg	;;
78794642e01fSmrg      esac # arg
78804642e01fSmrg
78814642e01fSmrg      # Now actually substitute the argument into the commands.
78824642e01fSmrg      if test -n "$arg"; then
788354b5899cSmrg	if test -n "$rpath_arg"; then
788454b5899cSmrg          func_append finalize_rpath " ${arg##*,}"
788554b5899cSmrg	  unset rpath_arg
788654b5899cSmrg	else
788754b5899cSmrg	  case $arg in
788854b5899cSmrg          -Wl,-rpath,*)
788954b5899cSmrg	    func_append finalize_rpath " ${arg##*,}";;
789054b5899cSmrg          -Wl,-rpath)
789154b5899cSmrg	    rpath_arg=1;;
789254b5899cSmrg          *)
789354b5899cSmrg            func_append compile_command " $arg"
789454b5899cSmrg	    func_append finalize_command " $arg"
789554b5899cSmrg	  esac
789654b5899cSmrg        fi
78974642e01fSmrg      fi
78984642e01fSmrg    done # argument parsing loop
78994642e01fSmrg
79004642e01fSmrg    test -n "$prev" && \
790135c4bbdfSmrg      func_fatal_help "the '$prevarg' option requires an argument"
79024642e01fSmrg
790335c4bbdfSmrg    if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then
79044642e01fSmrg      eval arg=\"$export_dynamic_flag_spec\"
79054642e01fSmrg      func_append compile_command " $arg"
79064642e01fSmrg      func_append finalize_command " $arg"
79074642e01fSmrg    fi
79084642e01fSmrg
79094642e01fSmrg    oldlibs=
79104642e01fSmrg    # calculate the name of the file, without its directory
79114642e01fSmrg    func_basename "$output"
791235c4bbdfSmrg    outputname=$func_basename_result
791335c4bbdfSmrg    libobjs_save=$libobjs
79144642e01fSmrg
79154642e01fSmrg    if test -n "$shlibpath_var"; then
79164642e01fSmrg      # get the directories listed in $shlibpath_var
791735c4bbdfSmrg      eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\`
79184642e01fSmrg    else
79194642e01fSmrg      shlib_search_path=
79204642e01fSmrg    fi
79214642e01fSmrg    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
79224642e01fSmrg    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
79234642e01fSmrg
792435c4bbdfSmrg    # Definition is injected by LT_CONFIG during libtool generation.
792535c4bbdfSmrg    func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH"
792635c4bbdfSmrg
79274642e01fSmrg    func_dirname "$output" "/" ""
792835c4bbdfSmrg    output_objdir=$func_dirname_result$objdir
792935c4bbdfSmrg    func_to_tool_file "$output_objdir/"
793035c4bbdfSmrg    tool_output_objdir=$func_to_tool_file_result
79314642e01fSmrg    # Create the object directory.
79324642e01fSmrg    func_mkdir_p "$output_objdir"
79334642e01fSmrg
79344642e01fSmrg    # Determine the type of output
79354642e01fSmrg    case $output in
79364642e01fSmrg    "")
79374642e01fSmrg      func_fatal_help "you must specify an output file"
79384642e01fSmrg      ;;
79394642e01fSmrg    *.$libext) linkmode=oldlib ;;
79404642e01fSmrg    *.lo | *.$objext) linkmode=obj ;;
79414642e01fSmrg    *.la) linkmode=lib ;;
79424642e01fSmrg    *) linkmode=prog ;; # Anything else should be a program.
79434642e01fSmrg    esac
79444642e01fSmrg
79454642e01fSmrg    specialdeplibs=
79464642e01fSmrg
79474642e01fSmrg    libs=
79484642e01fSmrg    # Find all interdependent deplibs by searching for libraries
79494642e01fSmrg    # that are linked more than once (e.g. -la -lb -la)
79504642e01fSmrg    for deplib in $deplibs; do
795135c4bbdfSmrg      if $opt_preserve_dup_deps; then
79524642e01fSmrg	case "$libs " in
795335c4bbdfSmrg	*" $deplib "*) func_append specialdeplibs " $deplib" ;;
79544642e01fSmrg	esac
79554642e01fSmrg      fi
795635c4bbdfSmrg      func_append libs " $deplib"
79574642e01fSmrg    done
79584642e01fSmrg
795935c4bbdfSmrg    if test lib = "$linkmode"; then
79604642e01fSmrg      libs="$predeps $libs $compiler_lib_search_path $postdeps"
79614642e01fSmrg
79624642e01fSmrg      # Compute libraries that are listed more than once in $predeps
79634642e01fSmrg      # $postdeps and mark them as special (i.e., whose duplicates are
79644642e01fSmrg      # not to be eliminated).
79654642e01fSmrg      pre_post_deps=
79664642e01fSmrg      if $opt_duplicate_compiler_generated_deps; then
79674642e01fSmrg	for pre_post_dep in $predeps $postdeps; do
79684642e01fSmrg	  case "$pre_post_deps " in
796935c4bbdfSmrg	  *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
79704642e01fSmrg	  esac
797135c4bbdfSmrg	  func_append pre_post_deps " $pre_post_dep"
79724642e01fSmrg	done
79734642e01fSmrg      fi
79744642e01fSmrg      pre_post_deps=
79754642e01fSmrg    fi
79764642e01fSmrg
79774642e01fSmrg    deplibs=
79784642e01fSmrg    newdependency_libs=
79794642e01fSmrg    newlib_search_path=
79804642e01fSmrg    need_relink=no # whether we're linking any uninstalled libtool libraries
79814642e01fSmrg    notinst_deplibs= # not-installed libtool libraries
79824642e01fSmrg    notinst_path= # paths that contain not-installed libtool libraries
79834642e01fSmrg
79844642e01fSmrg    case $linkmode in
79854642e01fSmrg    lib)
79864642e01fSmrg	passes="conv dlpreopen link"
79874642e01fSmrg	for file in $dlfiles $dlprefiles; do
79884642e01fSmrg	  case $file in
79894642e01fSmrg	  *.la) ;;
79904642e01fSmrg	  *)
799135c4bbdfSmrg	    func_fatal_help "libraries can '-dlopen' only libtool libraries: $file"
79924642e01fSmrg	    ;;
79934642e01fSmrg	  esac
79944642e01fSmrg	done
79954642e01fSmrg	;;
79964642e01fSmrg    prog)
79974642e01fSmrg	compile_deplibs=
79984642e01fSmrg	finalize_deplibs=
799935c4bbdfSmrg	alldeplibs=false
80004642e01fSmrg	newdlfiles=
80014642e01fSmrg	newdlprefiles=
80024642e01fSmrg	passes="conv scan dlopen dlpreopen link"
80034642e01fSmrg	;;
80044642e01fSmrg    *)  passes="conv"
80054642e01fSmrg	;;
80064642e01fSmrg    esac
80074642e01fSmrg
80084642e01fSmrg    for pass in $passes; do
80094642e01fSmrg      # The preopen pass in lib mode reverses $deplibs; put it back here
80104642e01fSmrg      # so that -L comes before libs that need it for instance...
801135c4bbdfSmrg      if test lib,link = "$linkmode,$pass"; then
80124642e01fSmrg	## FIXME: Find the place where the list is rebuilt in the wrong
80134642e01fSmrg	##        order, and fix it there properly
80144642e01fSmrg        tmp_deplibs=
80154642e01fSmrg	for deplib in $deplibs; do
80164642e01fSmrg	  tmp_deplibs="$deplib $tmp_deplibs"
80174642e01fSmrg	done
801835c4bbdfSmrg	deplibs=$tmp_deplibs
80194642e01fSmrg      fi
80204642e01fSmrg
802135c4bbdfSmrg      if test lib,link = "$linkmode,$pass" ||
802235c4bbdfSmrg	 test prog,scan = "$linkmode,$pass"; then
802335c4bbdfSmrg	libs=$deplibs
80244642e01fSmrg	deplibs=
80254642e01fSmrg      fi
802635c4bbdfSmrg      if test prog = "$linkmode"; then
80274642e01fSmrg	case $pass in
802835c4bbdfSmrg	dlopen) libs=$dlfiles ;;
802935c4bbdfSmrg	dlpreopen) libs=$dlprefiles ;;
8030c82838c1Smrg	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
80314642e01fSmrg	esac
80324642e01fSmrg      fi
803335c4bbdfSmrg      if test lib,dlpreopen = "$linkmode,$pass"; then
80344642e01fSmrg	# Collect and forward deplibs of preopened libtool libs
80354642e01fSmrg	for lib in $dlprefiles; do
80364642e01fSmrg	  # Ignore non-libtool-libs
80374642e01fSmrg	  dependency_libs=
803835c4bbdfSmrg	  func_resolve_sysroot "$lib"
80394642e01fSmrg	  case $lib in
804035c4bbdfSmrg	  *.la)	func_source "$func_resolve_sysroot_result" ;;
80414642e01fSmrg	  esac
80424642e01fSmrg
80434642e01fSmrg	  # Collect preopened libtool deplibs, except any this library
80444642e01fSmrg	  # has declared as weak libs
80454642e01fSmrg	  for deplib in $dependency_libs; do
80466747b715Smrg	    func_basename "$deplib"
80476747b715Smrg            deplib_base=$func_basename_result
80484642e01fSmrg	    case " $weak_libs " in
80494642e01fSmrg	    *" $deplib_base "*) ;;
805035c4bbdfSmrg	    *) func_append deplibs " $deplib" ;;
80514642e01fSmrg	    esac
80524642e01fSmrg	  done
80534642e01fSmrg	done
805435c4bbdfSmrg	libs=$dlprefiles
80554642e01fSmrg      fi
805635c4bbdfSmrg      if test dlopen = "$pass"; then
80574642e01fSmrg	# Collect dlpreopened libraries
805835c4bbdfSmrg	save_deplibs=$deplibs
80594642e01fSmrg	deplibs=
80604642e01fSmrg      fi
80614642e01fSmrg
80624642e01fSmrg      for deplib in $libs; do
80634642e01fSmrg	lib=
806435c4bbdfSmrg	found=false
80654642e01fSmrg	case $deplib in
806635c4bbdfSmrg	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
806754b5899cSmrg        |-threads|-fopenmp|-fopenmp=*|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
806835c4bbdfSmrg	  if test prog,link = "$linkmode,$pass"; then
80694642e01fSmrg	    compile_deplibs="$deplib $compile_deplibs"
80704642e01fSmrg	    finalize_deplibs="$deplib $finalize_deplibs"
80714642e01fSmrg	  else
807235c4bbdfSmrg	    func_append compiler_flags " $deplib"
807335c4bbdfSmrg	    if test lib = "$linkmode"; then
80744642e01fSmrg		case "$new_inherited_linker_flags " in
80754642e01fSmrg		    *" $deplib "*) ;;
807635c4bbdfSmrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
80774642e01fSmrg		esac
80784642e01fSmrg	    fi
80794642e01fSmrg	  fi
80804642e01fSmrg	  continue
80814642e01fSmrg	  ;;
80824642e01fSmrg	-l*)
808335c4bbdfSmrg	  if test lib != "$linkmode" && test prog != "$linkmode"; then
808435c4bbdfSmrg	    func_warning "'-l' is ignored for archives/objects"
80854642e01fSmrg	    continue
80864642e01fSmrg	  fi
80874642e01fSmrg	  func_stripname '-l' '' "$deplib"
80884642e01fSmrg	  name=$func_stripname_result
808935c4bbdfSmrg	  if test lib = "$linkmode"; then
80904642e01fSmrg	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
80914642e01fSmrg	  else
80924642e01fSmrg	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
80934642e01fSmrg	  fi
80944642e01fSmrg	  for searchdir in $searchdirs; do
80954642e01fSmrg	    for search_ext in .la $std_shrext .so .a; do
80964642e01fSmrg	      # Search the libtool library
809735c4bbdfSmrg	      lib=$searchdir/lib$name$search_ext
80984642e01fSmrg	      if test -f "$lib"; then
809935c4bbdfSmrg		if test .la = "$search_ext"; then
810035c4bbdfSmrg		  found=:
81014642e01fSmrg		else
810235c4bbdfSmrg		  found=false
81034642e01fSmrg		fi
81044642e01fSmrg		break 2
81054642e01fSmrg	      fi
81064642e01fSmrg	    done
81074642e01fSmrg	  done
810835c4bbdfSmrg	  if $found; then
810935c4bbdfSmrg	    # deplib is a libtool library
81104642e01fSmrg	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
81114642e01fSmrg	    # We need to do some special things here, and not later.
811235c4bbdfSmrg	    if test yes = "$allow_libtool_libs_with_static_runtimes"; then
81134642e01fSmrg	      case " $predeps $postdeps " in
81144642e01fSmrg	      *" $deplib "*)
81154642e01fSmrg		if func_lalib_p "$lib"; then
81164642e01fSmrg		  library_names=
81174642e01fSmrg		  old_library=
81184642e01fSmrg		  func_source "$lib"
81194642e01fSmrg		  for l in $old_library $library_names; do
812035c4bbdfSmrg		    ll=$l
81214642e01fSmrg		  done
812235c4bbdfSmrg		  if test "X$ll" = "X$old_library"; then # only static version available
812335c4bbdfSmrg		    found=false
81244642e01fSmrg		    func_dirname "$lib" "" "."
812535c4bbdfSmrg		    ladir=$func_dirname_result
81264642e01fSmrg		    lib=$ladir/$old_library
812735c4bbdfSmrg		    if test prog,link = "$linkmode,$pass"; then
81284642e01fSmrg		      compile_deplibs="$deplib $compile_deplibs"
81294642e01fSmrg		      finalize_deplibs="$deplib $finalize_deplibs"
81304642e01fSmrg		    else
81314642e01fSmrg		      deplibs="$deplib $deplibs"
813235c4bbdfSmrg		      test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
81334642e01fSmrg		    fi
81344642e01fSmrg		    continue
81354642e01fSmrg		  fi
81364642e01fSmrg		fi
81374642e01fSmrg		;;
81384642e01fSmrg	      *) ;;
81394642e01fSmrg	      esac
81404642e01fSmrg	    fi
814135c4bbdfSmrg	  else
814235c4bbdfSmrg	    # deplib doesn't seem to be a libtool library
814335c4bbdfSmrg	    if test prog,link = "$linkmode,$pass"; then
814435c4bbdfSmrg	      compile_deplibs="$deplib $compile_deplibs"
814535c4bbdfSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
814635c4bbdfSmrg	    else
814735c4bbdfSmrg	      deplibs="$deplib $deplibs"
814835c4bbdfSmrg	      test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
814935c4bbdfSmrg	    fi
815035c4bbdfSmrg	    continue
81514642e01fSmrg	  fi
81524642e01fSmrg	  ;; # -l
81534642e01fSmrg	*.ltframework)
815435c4bbdfSmrg	  if test prog,link = "$linkmode,$pass"; then
81554642e01fSmrg	    compile_deplibs="$deplib $compile_deplibs"
81564642e01fSmrg	    finalize_deplibs="$deplib $finalize_deplibs"
81574642e01fSmrg	  else
81584642e01fSmrg	    deplibs="$deplib $deplibs"
815935c4bbdfSmrg	    if test lib = "$linkmode"; then
81604642e01fSmrg		case "$new_inherited_linker_flags " in
81614642e01fSmrg		    *" $deplib "*) ;;
816235c4bbdfSmrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
81634642e01fSmrg		esac
81644642e01fSmrg	    fi
81654642e01fSmrg	  fi
81664642e01fSmrg	  continue
81674642e01fSmrg	  ;;
81684642e01fSmrg	-L*)
81694642e01fSmrg	  case $linkmode in
81704642e01fSmrg	  lib)
81714642e01fSmrg	    deplibs="$deplib $deplibs"
817235c4bbdfSmrg	    test conv = "$pass" && continue
81734642e01fSmrg	    newdependency_libs="$deplib $newdependency_libs"
81744642e01fSmrg	    func_stripname '-L' '' "$deplib"
817535c4bbdfSmrg	    func_resolve_sysroot "$func_stripname_result"
817635c4bbdfSmrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
81774642e01fSmrg	    ;;
81784642e01fSmrg	  prog)
817935c4bbdfSmrg	    if test conv = "$pass"; then
81804642e01fSmrg	      deplibs="$deplib $deplibs"
81814642e01fSmrg	      continue
81824642e01fSmrg	    fi
818335c4bbdfSmrg	    if test scan = "$pass"; then
81844642e01fSmrg	      deplibs="$deplib $deplibs"
81854642e01fSmrg	    else
81864642e01fSmrg	      compile_deplibs="$deplib $compile_deplibs"
81874642e01fSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
81884642e01fSmrg	    fi
81894642e01fSmrg	    func_stripname '-L' '' "$deplib"
819035c4bbdfSmrg	    func_resolve_sysroot "$func_stripname_result"
819135c4bbdfSmrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
81924642e01fSmrg	    ;;
81934642e01fSmrg	  *)
819435c4bbdfSmrg	    func_warning "'-L' is ignored for archives/objects"
81954642e01fSmrg	    ;;
81964642e01fSmrg	  esac # linkmode
81974642e01fSmrg	  continue
81984642e01fSmrg	  ;; # -L
81994642e01fSmrg	-R*)
820035c4bbdfSmrg	  if test link = "$pass"; then
82014642e01fSmrg	    func_stripname '-R' '' "$deplib"
820235c4bbdfSmrg	    func_resolve_sysroot "$func_stripname_result"
820335c4bbdfSmrg	    dir=$func_resolve_sysroot_result
82044642e01fSmrg	    # Make sure the xrpath contains only unique directories.
82054642e01fSmrg	    case "$xrpath " in
82064642e01fSmrg	    *" $dir "*) ;;
820735c4bbdfSmrg	    *) func_append xrpath " $dir" ;;
82084642e01fSmrg	    esac
82094642e01fSmrg	  fi
82104642e01fSmrg	  deplibs="$deplib $deplibs"
82114642e01fSmrg	  continue
82124642e01fSmrg	  ;;
821335c4bbdfSmrg	*.la)
821435c4bbdfSmrg	  func_resolve_sysroot "$deplib"
821535c4bbdfSmrg	  lib=$func_resolve_sysroot_result
821635c4bbdfSmrg	  ;;
82174642e01fSmrg	*.$libext)
821835c4bbdfSmrg	  if test conv = "$pass"; then
82194642e01fSmrg	    deplibs="$deplib $deplibs"
82204642e01fSmrg	    continue
82214642e01fSmrg	  fi
82224642e01fSmrg	  case $linkmode in
82234642e01fSmrg	  lib)
82244642e01fSmrg	    # Linking convenience modules into shared libraries is allowed,
82254642e01fSmrg	    # but linking other static libraries is non-portable.
82264642e01fSmrg	    case " $dlpreconveniencelibs " in
82274642e01fSmrg	    *" $deplib "*) ;;
82284642e01fSmrg	    *)
822935c4bbdfSmrg	      valid_a_lib=false
82304642e01fSmrg	      case $deplibs_check_method in
82314642e01fSmrg		match_pattern*)
82324642e01fSmrg		  set dummy $deplibs_check_method; shift
82334642e01fSmrg		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
82346747b715Smrg		  if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
82354642e01fSmrg		    | $EGREP "$match_pattern_regex" > /dev/null; then
823635c4bbdfSmrg		    valid_a_lib=:
82374642e01fSmrg		  fi
82384642e01fSmrg		;;
82394642e01fSmrg		pass_all)
824035c4bbdfSmrg		  valid_a_lib=:
82414642e01fSmrg		;;
82424642e01fSmrg	      esac
824335c4bbdfSmrg	      if $valid_a_lib; then
824454b5899cSmrg		func_warning "Linking the shared library $output against the static library $deplib is not portable!"
824535c4bbdfSmrg		deplibs="$deplib $deplibs"
824635c4bbdfSmrg	      else
824754b5899cSmrg		func_warning "Trying to link with static lib archive $deplib."
824854b5899cSmrg		func_warning "I have the capability to make that library automatically link in when"
824954b5899cSmrg		func_warning "you link to this library.  But I can only do this if you have a"
825054b5899cSmrg		func_warning "shared version of the library, which you do not appear to have"
825154b5899cSmrg		func_warning "because the file extensions .$libext of this argument makes me believe"
825254b5899cSmrg		func_warning "that it is just a static archive that I should not use here."
82534642e01fSmrg	      fi
82544642e01fSmrg	      ;;
82554642e01fSmrg	    esac
82564642e01fSmrg	    continue
82574642e01fSmrg	    ;;
82584642e01fSmrg	  prog)
825935c4bbdfSmrg	    if test link != "$pass"; then
82604642e01fSmrg	      deplibs="$deplib $deplibs"
82614642e01fSmrg	    else
82624642e01fSmrg	      compile_deplibs="$deplib $compile_deplibs"
82634642e01fSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
82644642e01fSmrg	    fi
82654642e01fSmrg	    continue
82664642e01fSmrg	    ;;
82674642e01fSmrg	  esac # linkmode
82684642e01fSmrg	  ;; # *.$libext
82694642e01fSmrg	*.lo | *.$objext)
827035c4bbdfSmrg	  if test conv = "$pass"; then
82714642e01fSmrg	    deplibs="$deplib $deplibs"
827235c4bbdfSmrg	  elif test prog = "$linkmode"; then
827335c4bbdfSmrg	    if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then
82744642e01fSmrg	      # If there is no dlopen support or we're linking statically,
82754642e01fSmrg	      # we need to preload.
827635c4bbdfSmrg	      func_append newdlprefiles " $deplib"
82774642e01fSmrg	      compile_deplibs="$deplib $compile_deplibs"
82784642e01fSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
82794642e01fSmrg	    else
828035c4bbdfSmrg	      func_append newdlfiles " $deplib"
82814642e01fSmrg	    fi
82824642e01fSmrg	  fi
82834642e01fSmrg	  continue
82844642e01fSmrg	  ;;
82854642e01fSmrg	%DEPLIBS%)
828635c4bbdfSmrg	  alldeplibs=:
82874642e01fSmrg	  continue
82884642e01fSmrg	  ;;
82894642e01fSmrg	esac # case $deplib
82904642e01fSmrg
829135c4bbdfSmrg	$found || test -f "$lib" \
829235c4bbdfSmrg	  || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'"
82934642e01fSmrg
82944642e01fSmrg	# Check to see that this really is a libtool archive.
82954642e01fSmrg	func_lalib_unsafe_p "$lib" \
829635c4bbdfSmrg	  || func_fatal_error "'$lib' is not a valid libtool archive"
82974642e01fSmrg
82984642e01fSmrg	func_dirname "$lib" "" "."
829935c4bbdfSmrg	ladir=$func_dirname_result
83004642e01fSmrg
83014642e01fSmrg	dlname=
83024642e01fSmrg	dlopen=
83034642e01fSmrg	dlpreopen=
83044642e01fSmrg	libdir=
83054642e01fSmrg	library_names=
83064642e01fSmrg	old_library=
83074642e01fSmrg	inherited_linker_flags=
83084642e01fSmrg	# If the library was installed with an old release of libtool,
83094642e01fSmrg	# it will not redefine variables installed, or shouldnotlink
83104642e01fSmrg	installed=yes
83114642e01fSmrg	shouldnotlink=no
83124642e01fSmrg	avoidtemprpath=
83134642e01fSmrg
83144642e01fSmrg
83154642e01fSmrg	# Read the .la file
83164642e01fSmrg	func_source "$lib"
83174642e01fSmrg
83184642e01fSmrg	# Convert "-framework foo" to "foo.ltframework"
83194642e01fSmrg	if test -n "$inherited_linker_flags"; then
83206747b715Smrg	  tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
83214642e01fSmrg	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
83224642e01fSmrg	    case " $new_inherited_linker_flags " in
83234642e01fSmrg	      *" $tmp_inherited_linker_flag "*) ;;
832435c4bbdfSmrg	      *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
83254642e01fSmrg	    esac
83264642e01fSmrg	  done
83274642e01fSmrg	fi
83286747b715Smrg	dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
832935c4bbdfSmrg	if test lib,link = "$linkmode,$pass" ||
833035c4bbdfSmrg	   test prog,scan = "$linkmode,$pass" ||
833135c4bbdfSmrg	   { test prog != "$linkmode" && test lib != "$linkmode"; }; then
833235c4bbdfSmrg	  test -n "$dlopen" && func_append dlfiles " $dlopen"
833335c4bbdfSmrg	  test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
83344642e01fSmrg	fi
83354642e01fSmrg
833635c4bbdfSmrg	if test conv = "$pass"; then
83374642e01fSmrg	  # Only check for convenience libraries
83384642e01fSmrg	  deplibs="$lib $deplibs"
83394642e01fSmrg	  if test -z "$libdir"; then
83404642e01fSmrg	    if test -z "$old_library"; then
834135c4bbdfSmrg	      func_fatal_error "cannot find name of link library for '$lib'"
83424642e01fSmrg	    fi
83434642e01fSmrg	    # It is a libtool convenience library, so add in its objects.
834435c4bbdfSmrg	    func_append convenience " $ladir/$objdir/$old_library"
834535c4bbdfSmrg	    func_append old_convenience " $ladir/$objdir/$old_library"
834635c4bbdfSmrg	  elif test prog != "$linkmode" && test lib != "$linkmode"; then
834735c4bbdfSmrg	    func_fatal_error "'$lib' is not a convenience library"
83484642e01fSmrg	  fi
8349c82838c1Smrg	  tmp_libs=
8350c82838c1Smrg	  for deplib in $dependency_libs; do
8351c82838c1Smrg	    deplibs="$deplib $deplibs"
8352c82838c1Smrg	    if $opt_preserve_dup_deps; then
8353c82838c1Smrg	      case "$tmp_libs " in
8354c82838c1Smrg	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
8355c82838c1Smrg	      esac
8356c82838c1Smrg	    fi
8357c82838c1Smrg	    func_append tmp_libs " $deplib"
8358c82838c1Smrg	  done
83594642e01fSmrg	  continue
83604642e01fSmrg	fi # $pass = conv
83614642e01fSmrg
83624642e01fSmrg
83634642e01fSmrg	# Get the name of the library we link against.
83644642e01fSmrg	linklib=
836535c4bbdfSmrg	if test -n "$old_library" &&
836635c4bbdfSmrg	   { test yes = "$prefer_static_libs" ||
836735c4bbdfSmrg	     test built,no = "$prefer_static_libs,$installed"; }; then
836835c4bbdfSmrg	  linklib=$old_library
836935c4bbdfSmrg	else
837035c4bbdfSmrg	  for l in $old_library $library_names; do
837135c4bbdfSmrg	    linklib=$l
837235c4bbdfSmrg	  done
837335c4bbdfSmrg	fi
83744642e01fSmrg	if test -z "$linklib"; then
837535c4bbdfSmrg	  func_fatal_error "cannot find name of link library for '$lib'"
83764642e01fSmrg	fi
83774642e01fSmrg
83784642e01fSmrg	# This library was specified with -dlopen.
837935c4bbdfSmrg	if test dlopen = "$pass"; then
838035c4bbdfSmrg	  test -z "$libdir" \
838135c4bbdfSmrg	    && func_fatal_error "cannot -dlopen a convenience library: '$lib'"
83824642e01fSmrg	  if test -z "$dlname" ||
838335c4bbdfSmrg	     test yes != "$dlopen_support" ||
838435c4bbdfSmrg	     test no = "$build_libtool_libs"
838535c4bbdfSmrg	  then
83864642e01fSmrg	    # If there is no dlname, no dlopen support or we're linking
83874642e01fSmrg	    # statically, we need to preload.  We also need to preload any
83884642e01fSmrg	    # dependent libraries so libltdl's deplib preloader doesn't
83894642e01fSmrg	    # bomb out in the load deplibs phase.
839035c4bbdfSmrg	    func_append dlprefiles " $lib $dependency_libs"
83914642e01fSmrg	  else
839235c4bbdfSmrg	    func_append newdlfiles " $lib"
83934642e01fSmrg	  fi
83944642e01fSmrg	  continue
83954642e01fSmrg	fi # $pass = dlopen
83964642e01fSmrg
83974642e01fSmrg	# We need an absolute path.
83984642e01fSmrg	case $ladir in
839935c4bbdfSmrg	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;;
84004642e01fSmrg	*)
84014642e01fSmrg	  abs_ladir=`cd "$ladir" && pwd`
84024642e01fSmrg	  if test -z "$abs_ladir"; then
840335c4bbdfSmrg	    func_warning "cannot determine absolute directory name of '$ladir'"
84044642e01fSmrg	    func_warning "passing it literally to the linker, although it might fail"
840535c4bbdfSmrg	    abs_ladir=$ladir
84064642e01fSmrg	  fi
84074642e01fSmrg	  ;;
84084642e01fSmrg	esac
84094642e01fSmrg	func_basename "$lib"
841035c4bbdfSmrg	laname=$func_basename_result
84114642e01fSmrg
84124642e01fSmrg	# Find the relevant object directory and library name.
841335c4bbdfSmrg	if test yes = "$installed"; then
841435c4bbdfSmrg	  if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
841535c4bbdfSmrg	    func_warning "library '$lib' was moved."
841635c4bbdfSmrg	    dir=$ladir
841735c4bbdfSmrg	    absdir=$abs_ladir
841835c4bbdfSmrg	    libdir=$abs_ladir
84194642e01fSmrg	  else
842035c4bbdfSmrg	    dir=$lt_sysroot$libdir
842135c4bbdfSmrg	    absdir=$lt_sysroot$libdir
84224642e01fSmrg	  fi
842335c4bbdfSmrg	  test yes = "$hardcode_automatic" && avoidtemprpath=yes
84244642e01fSmrg	else
84254642e01fSmrg	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
842635c4bbdfSmrg	    dir=$ladir
842735c4bbdfSmrg	    absdir=$abs_ladir
84284642e01fSmrg	    # Remove this search path later
842935c4bbdfSmrg	    func_append notinst_path " $abs_ladir"
84304642e01fSmrg	  else
843135c4bbdfSmrg	    dir=$ladir/$objdir
843235c4bbdfSmrg	    absdir=$abs_ladir/$objdir
84334642e01fSmrg	    # Remove this search path later
843435c4bbdfSmrg	    func_append notinst_path " $abs_ladir"
84354642e01fSmrg	  fi
84364642e01fSmrg	fi # $installed = yes
84374642e01fSmrg	func_stripname 'lib' '.la' "$laname"
84384642e01fSmrg	name=$func_stripname_result
84394642e01fSmrg
84404642e01fSmrg	# This library was specified with -dlpreopen.
844135c4bbdfSmrg	if test dlpreopen = "$pass"; then
844235c4bbdfSmrg	  if test -z "$libdir" && test prog = "$linkmode"; then
844335c4bbdfSmrg	    func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'"
8444475c125cSmrg	  fi
844535c4bbdfSmrg	  case $host in
844635c4bbdfSmrg	    # special handling for platforms with PE-DLLs.
844754b5899cSmrg	    *cygwin* | *mingw* | *windows* | *cegcc* )
844835c4bbdfSmrg	      # Linker will automatically link against shared library if both
844935c4bbdfSmrg	      # static and shared are present.  Therefore, ensure we extract
845035c4bbdfSmrg	      # symbols from the import library if a shared library is present
845135c4bbdfSmrg	      # (otherwise, the dlopen module name will be incorrect).  We do
845235c4bbdfSmrg	      # this by putting the import library name into $newdlprefiles.
845335c4bbdfSmrg	      # We recover the dlopen module name by 'saving' the la file
845435c4bbdfSmrg	      # name in a special purpose variable, and (later) extracting the
845535c4bbdfSmrg	      # dlname from the la file.
845635c4bbdfSmrg	      if test -n "$dlname"; then
845735c4bbdfSmrg	        func_tr_sh "$dir/$linklib"
845835c4bbdfSmrg	        eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
845935c4bbdfSmrg	        func_append newdlprefiles " $dir/$linklib"
846035c4bbdfSmrg	      else
846135c4bbdfSmrg	        func_append newdlprefiles " $dir/$old_library"
846235c4bbdfSmrg	        # Keep a list of preopened convenience libraries to check
846335c4bbdfSmrg	        # that they are being used correctly in the link pass.
846435c4bbdfSmrg	        test -z "$libdir" && \
846535c4bbdfSmrg	          func_append dlpreconveniencelibs " $dir/$old_library"
846635c4bbdfSmrg	      fi
846735c4bbdfSmrg	    ;;
846835c4bbdfSmrg	    * )
846935c4bbdfSmrg	      # Prefer using a static library (so that no silly _DYNAMIC symbols
847035c4bbdfSmrg	      # are required to link).
847135c4bbdfSmrg	      if test -n "$old_library"; then
847235c4bbdfSmrg	        func_append newdlprefiles " $dir/$old_library"
847335c4bbdfSmrg	        # Keep a list of preopened convenience libraries to check
847435c4bbdfSmrg	        # that they are being used correctly in the link pass.
847535c4bbdfSmrg	        test -z "$libdir" && \
847635c4bbdfSmrg	          func_append dlpreconveniencelibs " $dir/$old_library"
847735c4bbdfSmrg	      # Otherwise, use the dlname, so that lt_dlopen finds it.
847835c4bbdfSmrg	      elif test -n "$dlname"; then
847935c4bbdfSmrg	        func_append newdlprefiles " $dir/$dlname"
848035c4bbdfSmrg	      else
848135c4bbdfSmrg	        func_append newdlprefiles " $dir/$linklib"
848235c4bbdfSmrg	      fi
848335c4bbdfSmrg	    ;;
848435c4bbdfSmrg	  esac
84854642e01fSmrg	fi # $pass = dlpreopen
84864642e01fSmrg
84874642e01fSmrg	if test -z "$libdir"; then
84884642e01fSmrg	  # Link the convenience library
848935c4bbdfSmrg	  if test lib = "$linkmode"; then
84904642e01fSmrg	    deplibs="$dir/$old_library $deplibs"
849135c4bbdfSmrg	  elif test prog,link = "$linkmode,$pass"; then
84924642e01fSmrg	    compile_deplibs="$dir/$old_library $compile_deplibs"
84934642e01fSmrg	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
84944642e01fSmrg	  else
84954642e01fSmrg	    deplibs="$lib $deplibs" # used for prog,scan pass
84964642e01fSmrg	  fi
84974642e01fSmrg	  continue
84984642e01fSmrg	fi
84994642e01fSmrg
85004642e01fSmrg
850135c4bbdfSmrg	if test prog = "$linkmode" && test link != "$pass"; then
850235c4bbdfSmrg	  func_append newlib_search_path " $ladir"
85034642e01fSmrg	  deplibs="$lib $deplibs"
85044642e01fSmrg
850535c4bbdfSmrg	  linkalldeplibs=false
850635c4bbdfSmrg	  if test no != "$link_all_deplibs" || test -z "$library_names" ||
850735c4bbdfSmrg	     test no = "$build_libtool_libs"; then
850835c4bbdfSmrg	    linkalldeplibs=:
85094642e01fSmrg	  fi
85104642e01fSmrg
85114642e01fSmrg	  tmp_libs=
85124642e01fSmrg	  for deplib in $dependency_libs; do
85134642e01fSmrg	    case $deplib in
85144642e01fSmrg	    -L*) func_stripname '-L' '' "$deplib"
851535c4bbdfSmrg	         func_resolve_sysroot "$func_stripname_result"
851635c4bbdfSmrg	         func_append newlib_search_path " $func_resolve_sysroot_result"
85174642e01fSmrg		 ;;
85184642e01fSmrg	    esac
85194642e01fSmrg	    # Need to link against all dependency_libs?
852035c4bbdfSmrg	    if $linkalldeplibs; then
85214642e01fSmrg	      deplibs="$deplib $deplibs"
85224642e01fSmrg	    else
85234642e01fSmrg	      # Need to hardcode shared library paths
85244642e01fSmrg	      # or/and link against static libraries
85254642e01fSmrg	      newdependency_libs="$deplib $newdependency_libs"
85264642e01fSmrg	    fi
852735c4bbdfSmrg	    if $opt_preserve_dup_deps; then
85284642e01fSmrg	      case "$tmp_libs " in
852935c4bbdfSmrg	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
85304642e01fSmrg	      esac
85314642e01fSmrg	    fi
853235c4bbdfSmrg	    func_append tmp_libs " $deplib"
85334642e01fSmrg	  done # for deplib
85344642e01fSmrg	  continue
85354642e01fSmrg	fi # $linkmode = prog...
85364642e01fSmrg
853735c4bbdfSmrg	if test prog,link = "$linkmode,$pass"; then
85384642e01fSmrg	  if test -n "$library_names" &&
853935c4bbdfSmrg	     { { test no = "$prefer_static_libs" ||
854035c4bbdfSmrg	         test built,yes = "$prefer_static_libs,$installed"; } ||
85414642e01fSmrg	       test -z "$old_library"; }; then
85424642e01fSmrg	    # We need to hardcode the library path
854335c4bbdfSmrg	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then
85444642e01fSmrg	      # Make sure the rpath contains only unique directories.
854535c4bbdfSmrg	      case $temp_rpath: in
85464642e01fSmrg	      *"$absdir:"*) ;;
854754b5899cSmrg              *) case $absdir in
854854b5899cSmrg                 "$progdir/"*) func_append temp_rpath "$absdir:" ;;
854954b5899cSmrg                 *)            func_append temp_rpath_tail "$absdir:" ;;
855054b5899cSmrg                 esac
85514642e01fSmrg	      esac
85524642e01fSmrg	    fi
85534642e01fSmrg
85544642e01fSmrg	    # Hardcode the library path.
85554642e01fSmrg	    # Skip directories that are in the system default run-time
85564642e01fSmrg	    # search path.
85574642e01fSmrg	    case " $sys_lib_dlsearch_path " in
85584642e01fSmrg	    *" $absdir "*) ;;
85594642e01fSmrg	    *)
856054b5899cSmrg	      case "$compile_rpath$compile_rpath_tail " in
85614642e01fSmrg	      *" $absdir "*) ;;
856254b5899cSmrg	      *) case $absdir in
856354b5899cSmrg                 "$progdir/"*) func_append compile_rpath " $absdir" ;;
856454b5899cSmrg                 *) func_append compile_rpath_tail " $absdir" ;;
856554b5899cSmrg		 esac
85664642e01fSmrg	      esac
85674642e01fSmrg	      ;;
85684642e01fSmrg	    esac
85694642e01fSmrg	    case " $sys_lib_dlsearch_path " in
85704642e01fSmrg	    *" $libdir "*) ;;
85714642e01fSmrg	    *)
85724642e01fSmrg	      case "$finalize_rpath " in
85734642e01fSmrg	      *" $libdir "*) ;;
857435c4bbdfSmrg	      *) func_append finalize_rpath " $libdir" ;;
85754642e01fSmrg	      esac
85764642e01fSmrg	      ;;
85774642e01fSmrg	    esac
85784642e01fSmrg	  fi # $linkmode,$pass = prog,link...
85794642e01fSmrg
858035c4bbdfSmrg	  if $alldeplibs &&
858135c4bbdfSmrg	     { test pass_all = "$deplibs_check_method" ||
858235c4bbdfSmrg	       { test yes = "$build_libtool_libs" &&
85834642e01fSmrg		 test -n "$library_names"; }; }; then
85844642e01fSmrg	    # We only need to search for static libraries
85854642e01fSmrg	    continue
85864642e01fSmrg	  fi
85874642e01fSmrg	fi
85884642e01fSmrg
85894642e01fSmrg	link_static=no # Whether the deplib will be linked statically
85904642e01fSmrg	use_static_libs=$prefer_static_libs
859135c4bbdfSmrg	if test built = "$use_static_libs" && test yes = "$installed"; then
85924642e01fSmrg	  use_static_libs=no
85934642e01fSmrg	fi
85944642e01fSmrg	if test -n "$library_names" &&
859535c4bbdfSmrg	   { test no = "$use_static_libs" || test -z "$old_library"; }; then
859654b5899cSmrg	  case $host_os in
859754b5899cSmrg	  cygwin* | mingw* | windows* | cegcc* | os2*)
85984642e01fSmrg	      # No point in relinking DLLs because paths are not encoded
859935c4bbdfSmrg	      func_append notinst_deplibs " $lib"
86004642e01fSmrg	      need_relink=no
86014642e01fSmrg	    ;;
86024642e01fSmrg	  *)
860335c4bbdfSmrg	    if test no = "$installed"; then
860435c4bbdfSmrg	      func_append notinst_deplibs " $lib"
86054642e01fSmrg	      need_relink=yes
86064642e01fSmrg	    fi
86074642e01fSmrg	    ;;
86084642e01fSmrg	  esac
86094642e01fSmrg	  # This is a shared library
86104642e01fSmrg
86114642e01fSmrg	  # Warn about portability, can't link against -module's on some
86124642e01fSmrg	  # systems (darwin).  Don't bleat about dlopened modules though!
861335c4bbdfSmrg	  dlopenmodule=
86144642e01fSmrg	  for dlpremoduletest in $dlprefiles; do
86154642e01fSmrg	    if test "X$dlpremoduletest" = "X$lib"; then
861635c4bbdfSmrg	      dlopenmodule=$dlpremoduletest
86174642e01fSmrg	      break
86184642e01fSmrg	    fi
86194642e01fSmrg	  done
862035c4bbdfSmrg	  if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then
86216747b715Smrg	    echo
862235c4bbdfSmrg	    if test prog = "$linkmode"; then
862354b5899cSmrg	      func_warning "Linking the executable $output against the loadable module"
86244642e01fSmrg	    else
862554b5899cSmrg	      func_warning "Linking the shared library $output against the loadable module"
86264642e01fSmrg	    fi
862754b5899cSmrg	    func_warning "$linklib is not portable!"
86284642e01fSmrg	  fi
862935c4bbdfSmrg	  if test lib = "$linkmode" &&
863035c4bbdfSmrg	     test yes = "$hardcode_into_libs"; then
86314642e01fSmrg	    # Hardcode the library path.
86324642e01fSmrg	    # Skip directories that are in the system default run-time
86334642e01fSmrg	    # search path.
86344642e01fSmrg	    case " $sys_lib_dlsearch_path " in
86354642e01fSmrg	    *" $absdir "*) ;;
86364642e01fSmrg	    *)
863754b5899cSmrg	      case "$compile_rpath$compile_rpath_tail " in
86384642e01fSmrg	      *" $absdir "*) ;;
863954b5899cSmrg	      *) case $absdir in
864054b5899cSmrg                 "$progdir/"*) func_append compile_rpath " $absdir" ;;
864154b5899cSmrg                 *) func_append compile_rpath_tail " $absdir" ;;
864254b5899cSmrg		 esac
86434642e01fSmrg	      esac
86444642e01fSmrg	      ;;
86454642e01fSmrg	    esac
86464642e01fSmrg	    case " $sys_lib_dlsearch_path " in
86474642e01fSmrg	    *" $libdir "*) ;;
86484642e01fSmrg	    *)
86494642e01fSmrg	      case "$finalize_rpath " in
86504642e01fSmrg	      *" $libdir "*) ;;
865135c4bbdfSmrg	      *) func_append finalize_rpath " $libdir" ;;
86524642e01fSmrg	      esac
86534642e01fSmrg	      ;;
86544642e01fSmrg	    esac
86554642e01fSmrg	  fi
86564642e01fSmrg
86574642e01fSmrg	  if test -n "$old_archive_from_expsyms_cmds"; then
86584642e01fSmrg	    # figure out the soname
86594642e01fSmrg	    set dummy $library_names
86604642e01fSmrg	    shift
866135c4bbdfSmrg	    realname=$1
86624642e01fSmrg	    shift
86634642e01fSmrg	    libname=`eval "\\$ECHO \"$libname_spec\""`
86644642e01fSmrg	    # use dlname if we got it. it's perfectly good, no?
86654642e01fSmrg	    if test -n "$dlname"; then
866635c4bbdfSmrg	      soname=$dlname
86674642e01fSmrg	    elif test -n "$soname_spec"; then
86684642e01fSmrg	      # bleh windows
866954b5899cSmrg	      case $host_os in
867054b5899cSmrg	      cygwin* | mingw* | windows* | cegcc* | os2*)
86714642e01fSmrg	        func_arith $current - $age
86724642e01fSmrg		major=$func_arith_result
867335c4bbdfSmrg		versuffix=-$major
86744642e01fSmrg		;;
86754642e01fSmrg	      esac
86764642e01fSmrg	      eval soname=\"$soname_spec\"
86774642e01fSmrg	    else
867835c4bbdfSmrg	      soname=$realname
86794642e01fSmrg	    fi
86804642e01fSmrg
86814642e01fSmrg	    # Make a new name for the extract_expsyms_cmds to use
868235c4bbdfSmrg	    soroot=$soname
86834642e01fSmrg	    func_basename "$soroot"
868435c4bbdfSmrg	    soname=$func_basename_result
86854642e01fSmrg	    func_stripname 'lib' '.dll' "$soname"
86864642e01fSmrg	    newlib=libimp-$func_stripname_result.a
86874642e01fSmrg
86884642e01fSmrg	    # If the library has no export list, then create one now
86894642e01fSmrg	    if test -f "$output_objdir/$soname-def"; then :
86904642e01fSmrg	    else
869135c4bbdfSmrg	      func_verbose "extracting exported symbol list from '$soname'"
86924642e01fSmrg	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
86934642e01fSmrg	    fi
86944642e01fSmrg
86954642e01fSmrg	    # Create $newlib
86964642e01fSmrg	    if test -f "$output_objdir/$newlib"; then :; else
869735c4bbdfSmrg	      func_verbose "generating import library for '$soname'"
86984642e01fSmrg	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
86994642e01fSmrg	    fi
87004642e01fSmrg	    # make sure the library variables are pointing to the new library
87014642e01fSmrg	    dir=$output_objdir
87024642e01fSmrg	    linklib=$newlib
87034642e01fSmrg	  fi # test -n "$old_archive_from_expsyms_cmds"
87044642e01fSmrg
870535c4bbdfSmrg	  if test prog = "$linkmode" || test relink != "$opt_mode"; then
87064642e01fSmrg	    add_shlibpath=
87074642e01fSmrg	    add_dir=
87084642e01fSmrg	    add=
87094642e01fSmrg	    lib_linked=yes
87104642e01fSmrg	    case $hardcode_action in
87114642e01fSmrg	    immediate | unsupported)
871235c4bbdfSmrg	      if test no = "$hardcode_direct"; then
871335c4bbdfSmrg		add=$dir/$linklib
87144642e01fSmrg		case $host in
871535c4bbdfSmrg		  *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;;
871635c4bbdfSmrg		  *-*-sysv4*uw2*) add_dir=-L$dir ;;
871754b5899cSmrg		  *-*-emscripten*) add_dir=-L$dir ;;
87184642e01fSmrg		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
871935c4bbdfSmrg		    *-*-unixware7*) add_dir=-L$dir ;;
87204642e01fSmrg		  *-*-darwin* )
872135c4bbdfSmrg		    # if the lib is a (non-dlopened) module then we cannot
87224642e01fSmrg		    # link against it, someone is ignoring the earlier warnings
87234642e01fSmrg		    if /usr/bin/file -L $add 2> /dev/null |
872435c4bbdfSmrg			 $GREP ": [^:]* bundle" >/dev/null; then
87254642e01fSmrg		      if test "X$dlopenmodule" != "X$lib"; then
872654b5899cSmrg			func_warning "lib $linklib is a module, not a shared library"
872735c4bbdfSmrg			if test -z "$old_library"; then
872854b5899cSmrg			  func_warning "And there doesn't seem to be a static archive available"
872954b5899cSmrg			  func_warning "The link will probably fail, sorry"
87304642e01fSmrg			else
873135c4bbdfSmrg			  add=$dir/$old_library
87324642e01fSmrg			fi
87334642e01fSmrg		      elif test -n "$old_library"; then
873435c4bbdfSmrg			add=$dir/$old_library
87354642e01fSmrg		      fi
87364642e01fSmrg		    fi
87374642e01fSmrg		esac
873835c4bbdfSmrg	      elif test no = "$hardcode_minus_L"; then
87394642e01fSmrg		case $host in
874035c4bbdfSmrg		*-*-sunos*) add_shlibpath=$dir ;;
87414642e01fSmrg		esac
874235c4bbdfSmrg		add_dir=-L$dir
874335c4bbdfSmrg		add=-l$name
874435c4bbdfSmrg	      elif test no = "$hardcode_shlibpath_var"; then
874535c4bbdfSmrg		add_shlibpath=$dir
874635c4bbdfSmrg		add=-l$name
87474642e01fSmrg	      else
87484642e01fSmrg		lib_linked=no
87494642e01fSmrg	      fi
87504642e01fSmrg	      ;;
87514642e01fSmrg	    relink)
875235c4bbdfSmrg	      if test yes = "$hardcode_direct" &&
875335c4bbdfSmrg	         test no = "$hardcode_direct_absolute"; then
875435c4bbdfSmrg		add=$dir/$linklib
875535c4bbdfSmrg	      elif test yes = "$hardcode_minus_L"; then
875635c4bbdfSmrg		add_dir=-L$absdir
87574642e01fSmrg		# Try looking first in the location we're being installed to.
87584642e01fSmrg		if test -n "$inst_prefix_dir"; then
87594642e01fSmrg		  case $libdir in
87604642e01fSmrg		    [\\/]*)
876135c4bbdfSmrg		      func_append add_dir " -L$inst_prefix_dir$libdir"
87624642e01fSmrg		      ;;
87634642e01fSmrg		  esac
87644642e01fSmrg		fi
876535c4bbdfSmrg		add=-l$name
876635c4bbdfSmrg	      elif test yes = "$hardcode_shlibpath_var"; then
876735c4bbdfSmrg		add_shlibpath=$dir
876835c4bbdfSmrg		add=-l$name
87694642e01fSmrg	      else
87704642e01fSmrg		lib_linked=no
87714642e01fSmrg	      fi
87724642e01fSmrg	      ;;
87734642e01fSmrg	    *) lib_linked=no ;;
87744642e01fSmrg	    esac
87754642e01fSmrg
877635c4bbdfSmrg	    if test yes != "$lib_linked"; then
87774642e01fSmrg	      func_fatal_configuration "unsupported hardcode properties"
87784642e01fSmrg	    fi
87794642e01fSmrg
87804642e01fSmrg	    if test -n "$add_shlibpath"; then
87814642e01fSmrg	      case :$compile_shlibpath: in
87824642e01fSmrg	      *":$add_shlibpath:"*) ;;
878335c4bbdfSmrg	      *) func_append compile_shlibpath "$add_shlibpath:" ;;
87844642e01fSmrg	      esac
87854642e01fSmrg	    fi
878635c4bbdfSmrg	    if test prog = "$linkmode"; then
87874642e01fSmrg	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
87884642e01fSmrg	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
87894642e01fSmrg	    else
87904642e01fSmrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
87914642e01fSmrg	      test -n "$add" && deplibs="$add $deplibs"
879235c4bbdfSmrg	      if test yes != "$hardcode_direct" &&
879335c4bbdfSmrg		 test yes != "$hardcode_minus_L" &&
879435c4bbdfSmrg		 test yes = "$hardcode_shlibpath_var"; then
87954642e01fSmrg		case :$finalize_shlibpath: in
87964642e01fSmrg		*":$libdir:"*) ;;
879735c4bbdfSmrg		*) func_append finalize_shlibpath "$libdir:" ;;
87984642e01fSmrg		esac
87994642e01fSmrg	      fi
88004642e01fSmrg	    fi
88014642e01fSmrg	  fi
88024642e01fSmrg
880335c4bbdfSmrg	  if test prog = "$linkmode" || test relink = "$opt_mode"; then
88044642e01fSmrg	    add_shlibpath=
88054642e01fSmrg	    add_dir=
88064642e01fSmrg	    add=
88074642e01fSmrg	    # Finalize command for both is simple: just hardcode it.
880835c4bbdfSmrg	    if test yes = "$hardcode_direct" &&
880935c4bbdfSmrg	       test no = "$hardcode_direct_absolute"; then
881035c4bbdfSmrg	      add=$libdir/$linklib
881135c4bbdfSmrg	    elif test yes = "$hardcode_minus_L"; then
881254b5899cSmrg	      add_dir=-L$lt_sysroot$libdir
881335c4bbdfSmrg	      add=-l$name
881435c4bbdfSmrg	    elif test yes = "$hardcode_shlibpath_var"; then
88154642e01fSmrg	      case :$finalize_shlibpath: in
88164642e01fSmrg	      *":$libdir:"*) ;;
881735c4bbdfSmrg	      *) func_append finalize_shlibpath "$libdir:" ;;
88184642e01fSmrg	      esac
881935c4bbdfSmrg	      add=-l$name
882035c4bbdfSmrg	    elif test yes = "$hardcode_automatic"; then
88214642e01fSmrg	      if test -n "$inst_prefix_dir" &&
882235c4bbdfSmrg		 test -f "$inst_prefix_dir$libdir/$linklib"; then
882335c4bbdfSmrg		add=$inst_prefix_dir$libdir/$linklib
88244642e01fSmrg	      else
882535c4bbdfSmrg		add=$libdir/$linklib
88264642e01fSmrg	      fi
88274642e01fSmrg	    else
88284642e01fSmrg	      # We cannot seem to hardcode it, guess we'll fake it.
882954b5899cSmrg	      add_dir=-L$lt_sysroot$libdir
88304642e01fSmrg	      # Try looking first in the location we're being installed to.
88314642e01fSmrg	      if test -n "$inst_prefix_dir"; then
88324642e01fSmrg		case $libdir in
88334642e01fSmrg		  [\\/]*)
883435c4bbdfSmrg		    func_append add_dir " -L$inst_prefix_dir$libdir"
88354642e01fSmrg		    ;;
88364642e01fSmrg		esac
88374642e01fSmrg	      fi
883835c4bbdfSmrg	      add=-l$name
88394642e01fSmrg	    fi
88404642e01fSmrg
884135c4bbdfSmrg	    if test prog = "$linkmode"; then
88424642e01fSmrg	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
88434642e01fSmrg	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
88444642e01fSmrg	    else
88454642e01fSmrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
88464642e01fSmrg	      test -n "$add" && deplibs="$add $deplibs"
88474642e01fSmrg	    fi
88484642e01fSmrg	  fi
884935c4bbdfSmrg	elif test prog = "$linkmode"; then
88504642e01fSmrg	  # Here we assume that one of hardcode_direct or hardcode_minus_L
88514642e01fSmrg	  # is not unsupported.  This is valid on all known static and
88524642e01fSmrg	  # shared platforms.
885335c4bbdfSmrg	  if test unsupported != "$hardcode_direct"; then
885435c4bbdfSmrg	    test -n "$old_library" && linklib=$old_library
88554642e01fSmrg	    compile_deplibs="$dir/$linklib $compile_deplibs"
88564642e01fSmrg	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
88574642e01fSmrg	  else
88584642e01fSmrg	    compile_deplibs="-l$name -L$dir $compile_deplibs"
88594642e01fSmrg	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
88604642e01fSmrg	  fi
886135c4bbdfSmrg	elif test yes = "$build_libtool_libs"; then
88624642e01fSmrg	  # Not a shared library
886335c4bbdfSmrg	  if test pass_all != "$deplibs_check_method"; then
88644642e01fSmrg	    # We're trying link a shared library against a static one
88654642e01fSmrg	    # but the system doesn't support it.
88664642e01fSmrg
88674642e01fSmrg	    # Just print a warning and add the library to dependency_libs so
88684642e01fSmrg	    # that the program can be linked against the static library.
886954b5899cSmrg	    func_warning "This system cannot link to static lib archive $lib."
887054b5899cSmrg	    func_warning "I have the capability to make that library automatically link in when"
887154b5899cSmrg	    func_warning "you link to this library.  But I can only do this if you have a"
887254b5899cSmrg	    func_warning "shared version of the library, which you do not appear to have."
887335c4bbdfSmrg	    if test yes = "$module"; then
887454b5899cSmrg	      func_warning "But as you try to build a module library, libtool will still create "
887554b5899cSmrg	      func_warning "a static module, that should work as long as the dlopening application"
887654b5899cSmrg	      func_warning "is linked with the -dlopen flag to resolve symbols at runtime."
88774642e01fSmrg	      if test -z "$global_symbol_pipe"; then
887854b5899cSmrg		func_warning "However, this would only work if libtool was able to extract symbol"
887954b5899cSmrg		func_warning "lists from a program, using 'nm' or equivalent, but libtool could"
888054b5899cSmrg		func_warning "not find such a program.  So, this module is probably useless."
888154b5899cSmrg		func_warning "'nm' from GNU binutils and a full rebuild may help."
88824642e01fSmrg	      fi
888335c4bbdfSmrg	      if test no = "$build_old_libs"; then
88844642e01fSmrg		build_libtool_libs=module
88854642e01fSmrg		build_old_libs=yes
88864642e01fSmrg	      else
88874642e01fSmrg		build_libtool_libs=no
88884642e01fSmrg	      fi
88894642e01fSmrg	    fi
88904642e01fSmrg	  else
88914642e01fSmrg	    deplibs="$dir/$old_library $deplibs"
88924642e01fSmrg	    link_static=yes
88934642e01fSmrg	  fi
88944642e01fSmrg	fi # link shared/static library?
88954642e01fSmrg
889635c4bbdfSmrg	if test lib = "$linkmode"; then
88974642e01fSmrg	  if test -n "$dependency_libs" &&
889835c4bbdfSmrg	     { test yes != "$hardcode_into_libs" ||
889935c4bbdfSmrg	       test yes = "$build_old_libs" ||
890035c4bbdfSmrg	       test yes = "$link_static"; }; then
89014642e01fSmrg	    # Extract -R from dependency_libs
89024642e01fSmrg	    temp_deplibs=
89034642e01fSmrg	    for libdir in $dependency_libs; do
89044642e01fSmrg	      case $libdir in
89054642e01fSmrg	      -R*) func_stripname '-R' '' "$libdir"
89064642e01fSmrg	           temp_xrpath=$func_stripname_result
89074642e01fSmrg		   case " $xrpath " in
89084642e01fSmrg		   *" $temp_xrpath "*) ;;
890935c4bbdfSmrg		   *) func_append xrpath " $temp_xrpath";;
89104642e01fSmrg		   esac;;
891135c4bbdfSmrg	      *) func_append temp_deplibs " $libdir";;
89124642e01fSmrg	      esac
89134642e01fSmrg	    done
891435c4bbdfSmrg	    dependency_libs=$temp_deplibs
89154642e01fSmrg	  fi
89164642e01fSmrg
891735c4bbdfSmrg	  func_append newlib_search_path " $absdir"
89184642e01fSmrg	  # Link against this library
891935c4bbdfSmrg	  test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
89204642e01fSmrg	  # ... and its dependency_libs
89214642e01fSmrg	  tmp_libs=
89224642e01fSmrg	  for deplib in $dependency_libs; do
89234642e01fSmrg	    newdependency_libs="$deplib $newdependency_libs"
892435c4bbdfSmrg	    case $deplib in
892535c4bbdfSmrg              -L*) func_stripname '-L' '' "$deplib"
892635c4bbdfSmrg                   func_resolve_sysroot "$func_stripname_result";;
892735c4bbdfSmrg              *) func_resolve_sysroot "$deplib" ;;
892835c4bbdfSmrg            esac
892935c4bbdfSmrg	    if $opt_preserve_dup_deps; then
89304642e01fSmrg	      case "$tmp_libs " in
893135c4bbdfSmrg	      *" $func_resolve_sysroot_result "*)
893235c4bbdfSmrg                func_append specialdeplibs " $func_resolve_sysroot_result" ;;
89334642e01fSmrg	      esac
89344642e01fSmrg	    fi
893535c4bbdfSmrg	    func_append tmp_libs " $func_resolve_sysroot_result"
89364642e01fSmrg	  done
89374642e01fSmrg
893835c4bbdfSmrg	  if test no != "$link_all_deplibs"; then
89394642e01fSmrg	    # Add the search paths of all dependency libraries
89404642e01fSmrg	    for deplib in $dependency_libs; do
89414642e01fSmrg	      path=
89424642e01fSmrg	      case $deplib in
894335c4bbdfSmrg	      -L*) path=$deplib ;;
89444642e01fSmrg	      *.la)
894535c4bbdfSmrg	        func_resolve_sysroot "$deplib"
894635c4bbdfSmrg	        deplib=$func_resolve_sysroot_result
89474642e01fSmrg	        func_dirname "$deplib" "" "."
894835c4bbdfSmrg		dir=$func_dirname_result
89494642e01fSmrg		# We need an absolute path.
89504642e01fSmrg		case $dir in
895135c4bbdfSmrg		[\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;;
89524642e01fSmrg		*)
89534642e01fSmrg		  absdir=`cd "$dir" && pwd`
89544642e01fSmrg		  if test -z "$absdir"; then
895535c4bbdfSmrg		    func_warning "cannot determine absolute directory name of '$dir'"
895635c4bbdfSmrg		    absdir=$dir
89574642e01fSmrg		  fi
89584642e01fSmrg		  ;;
89594642e01fSmrg		esac
89604642e01fSmrg		if $GREP "^installed=no" $deplib > /dev/null; then
89614642e01fSmrg		case $host in
89624642e01fSmrg		*-*-darwin*)
89634642e01fSmrg		  depdepl=
896435c4bbdfSmrg		  eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
896535c4bbdfSmrg		  if test -n "$deplibrary_names"; then
896635c4bbdfSmrg		    for tmp in $deplibrary_names; do
89674642e01fSmrg		      depdepl=$tmp
89684642e01fSmrg		    done
896935c4bbdfSmrg		    if test -f "$absdir/$objdir/$depdepl"; then
897035c4bbdfSmrg		      depdepl=$absdir/$objdir/$depdepl
897135c4bbdfSmrg		      darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
89724642e01fSmrg                      if test -z "$darwin_install_name"; then
897335c4bbdfSmrg                          darwin_install_name=`$OTOOL64 -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
89744642e01fSmrg                      fi
897535c4bbdfSmrg		      func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl"
897635c4bbdfSmrg		      func_append linker_flags " -dylib_file $darwin_install_name:$depdepl"
89774642e01fSmrg		      path=
89784642e01fSmrg		    fi
89794642e01fSmrg		  fi
89804642e01fSmrg		  ;;
89814642e01fSmrg		*)
898235c4bbdfSmrg		  path=-L$absdir/$objdir
89834642e01fSmrg		  ;;
89844642e01fSmrg		esac
89854642e01fSmrg		else
898635c4bbdfSmrg		  eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
89874642e01fSmrg		  test -z "$libdir" && \
898835c4bbdfSmrg		    func_fatal_error "'$deplib' is not a valid libtool archive"
89894642e01fSmrg		  test "$absdir" != "$libdir" && \
899035c4bbdfSmrg		    func_warning "'$deplib' seems to be moved"
89914642e01fSmrg
899235c4bbdfSmrg		  path=-L$absdir
89934642e01fSmrg		fi
89944642e01fSmrg		;;
89954642e01fSmrg	      esac
89964642e01fSmrg	      case " $deplibs " in
89974642e01fSmrg	      *" $path "*) ;;
89984642e01fSmrg	      *) deplibs="$path $deplibs" ;;
89994642e01fSmrg	      esac
90004642e01fSmrg	    done
90014642e01fSmrg	  fi # link_all_deplibs != no
90024642e01fSmrg	fi # linkmode = lib
90034642e01fSmrg      done # for deplib in $libs
900454b5899cSmrg
900554b5899cSmrg      func_append temp_rpath "$temp_rpath_tail"
900654b5899cSmrg      func_append compile_rpath "$compile_rpath_tail"
900754b5899cSmrg
900835c4bbdfSmrg      if test link = "$pass"; then
900935c4bbdfSmrg	if test prog = "$linkmode"; then
90104642e01fSmrg	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
90114642e01fSmrg	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
90124642e01fSmrg	else
90136747b715Smrg	  compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
90144642e01fSmrg	fi
90154642e01fSmrg      fi
901635c4bbdfSmrg      dependency_libs=$newdependency_libs
901735c4bbdfSmrg      if test dlpreopen = "$pass"; then
90184642e01fSmrg	# Link the dlpreopened libraries before other libraries
90194642e01fSmrg	for deplib in $save_deplibs; do
90204642e01fSmrg	  deplibs="$deplib $deplibs"
90214642e01fSmrg	done
90224642e01fSmrg      fi
902335c4bbdfSmrg      if test dlopen != "$pass"; then
902435c4bbdfSmrg	test conv = "$pass" || {
90254642e01fSmrg	  # Make sure lib_search_path contains only unique directories.
90264642e01fSmrg	  lib_search_path=
90274642e01fSmrg	  for dir in $newlib_search_path; do
90284642e01fSmrg	    case "$lib_search_path " in
90294642e01fSmrg	    *" $dir "*) ;;
903035c4bbdfSmrg	    *) func_append lib_search_path " $dir" ;;
90314642e01fSmrg	    esac
90324642e01fSmrg	  done
90334642e01fSmrg	  newlib_search_path=
903435c4bbdfSmrg	}
90354642e01fSmrg
903635c4bbdfSmrg	if test prog,link = "$linkmode,$pass"; then
90374642e01fSmrg	  vars="compile_deplibs finalize_deplibs"
903835c4bbdfSmrg	else
903935c4bbdfSmrg	  vars=deplibs
90404642e01fSmrg	fi
90414642e01fSmrg	for var in $vars dependency_libs; do
90424642e01fSmrg	  # Add libraries to $var in reverse order
90434642e01fSmrg	  eval tmp_libs=\"\$$var\"
90444642e01fSmrg	  new_libs=
904554b5899cSmrg	  # FIXME: Pedantically, this is the right thing to do, so
904654b5899cSmrg	  #        that some nasty dependency loop isn't accidentally
904754b5899cSmrg	  #        broken: new_libs="$deplib $new_libs"
90484642e01fSmrg	  for deplib in $tmp_libs; do
904954b5899cSmrg	    if $opt_preserve_dup_deps; then
905054b5899cSmrg	      new_libs="$deplib $new_libs"
905154b5899cSmrg	    else
905254b5899cSmrg	      # Pragmatically, this seems to cause very few problems in
905354b5899cSmrg	      # practice:
905454b5899cSmrg	      case $deplib in
905554b5899cSmrg	      -L*) new_libs="$deplib $new_libs" ;;
905654b5899cSmrg	      -R*) ;;
90574642e01fSmrg	      *)
905854b5899cSmrg	        # And here is the reason: when a library appears more
905954b5899cSmrg	        # than once as an explicit dependence of a library, or
906054b5899cSmrg	        # is implicitly linked in more than once by the
906154b5899cSmrg	        # compiler, it is considered special, and multiple
906254b5899cSmrg	        # occurrences thereof are not removed.  Compare this
906354b5899cSmrg	        # with having the same library being listed as a
906454b5899cSmrg	        # dependency of multiple other libraries: in this case,
906554b5899cSmrg	        # we know (pedantically, we assume) the library does not
906654b5899cSmrg	        # need to be listed more than once, so we keep only the
906754b5899cSmrg	        # last copy.  This is not always right, but it is rare
906854b5899cSmrg	        # enough that we require users that really mean to play
906954b5899cSmrg	        # such unportable linking tricks to link the library
907054b5899cSmrg	        # using -Wl,-lname, so that libtool does not consider it
907154b5899cSmrg	        # for duplicate removal.  And if not possible for portability
907254b5899cSmrg	        # reasons, then --preserve-dup-deps should be used.
907354b5899cSmrg	        case " $specialdeplibs " in
907454b5899cSmrg	        *" $deplib "*) new_libs="$deplib $new_libs" ;;
907554b5899cSmrg	        *)
907654b5899cSmrg	          case " $new_libs " in
907754b5899cSmrg	          *" $deplib "*) ;;
907854b5899cSmrg	          *) new_libs="$deplib $new_libs" ;;
907954b5899cSmrg	          esac
908054b5899cSmrg	          ;;
908154b5899cSmrg	        esac
908254b5899cSmrg	        ;;
90834642e01fSmrg	      esac
908454b5899cSmrg	    fi
90854642e01fSmrg	  done
90864642e01fSmrg	  tmp_libs=
90874642e01fSmrg	  for deplib in $new_libs; do
90884642e01fSmrg	    case $deplib in
90894642e01fSmrg	    -L*)
90904642e01fSmrg	      case " $tmp_libs " in
90914642e01fSmrg	      *" $deplib "*) ;;
909235c4bbdfSmrg	      *) func_append tmp_libs " $deplib" ;;
90934642e01fSmrg	      esac
90944642e01fSmrg	      ;;
909535c4bbdfSmrg	    *) func_append tmp_libs " $deplib" ;;
90964642e01fSmrg	    esac
90974642e01fSmrg	  done
90984642e01fSmrg	  eval $var=\"$tmp_libs\"
90994642e01fSmrg	done # for var
91004642e01fSmrg      fi
910135c4bbdfSmrg
910235c4bbdfSmrg      # Add Sun CC postdeps if required:
910335c4bbdfSmrg      test CXX = "$tagname" && {
910435c4bbdfSmrg        case $host_os in
910535c4bbdfSmrg        linux*)
9106c82838c1Smrg          case `$CC -V 2>&1 | $SED 5q` in
910735c4bbdfSmrg          *Sun\ C*) # Sun C++ 5.9
910835c4bbdfSmrg            func_suncc_cstd_abi
910935c4bbdfSmrg
911035c4bbdfSmrg            if test no != "$suncc_use_cstd_abi"; then
911135c4bbdfSmrg              func_append postdeps ' -library=Cstd -library=Crun'
911235c4bbdfSmrg            fi
911335c4bbdfSmrg            ;;
911435c4bbdfSmrg          esac
911535c4bbdfSmrg          ;;
911635c4bbdfSmrg
911735c4bbdfSmrg        solaris*)
911835c4bbdfSmrg          func_cc_basename "$CC"
911935c4bbdfSmrg          case $func_cc_basename_result in
912035c4bbdfSmrg          CC* | sunCC*)
912135c4bbdfSmrg            func_suncc_cstd_abi
912235c4bbdfSmrg
912335c4bbdfSmrg            if test no != "$suncc_use_cstd_abi"; then
912435c4bbdfSmrg              func_append postdeps ' -library=Cstd -library=Crun'
912535c4bbdfSmrg            fi
912635c4bbdfSmrg            ;;
912735c4bbdfSmrg          esac
912835c4bbdfSmrg          ;;
912935c4bbdfSmrg        esac
913035c4bbdfSmrg      }
913135c4bbdfSmrg
91324642e01fSmrg      # Last step: remove runtime libs from dependency_libs
91334642e01fSmrg      # (they stay in deplibs)
91344642e01fSmrg      tmp_libs=
913535c4bbdfSmrg      for i in $dependency_libs; do
91364642e01fSmrg	case " $predeps $postdeps $compiler_lib_search_path " in
91374642e01fSmrg	*" $i "*)
913835c4bbdfSmrg	  i=
91394642e01fSmrg	  ;;
91404642e01fSmrg	esac
914135c4bbdfSmrg	if test -n "$i"; then
914235c4bbdfSmrg	  func_append tmp_libs " $i"
91434642e01fSmrg	fi
91444642e01fSmrg      done
91454642e01fSmrg      dependency_libs=$tmp_libs
91464642e01fSmrg    done # for pass
914735c4bbdfSmrg    if test prog = "$linkmode"; then
914835c4bbdfSmrg      dlfiles=$newdlfiles
91494642e01fSmrg    fi
915035c4bbdfSmrg    if test prog = "$linkmode" || test lib = "$linkmode"; then
915135c4bbdfSmrg      dlprefiles=$newdlprefiles
91524642e01fSmrg    fi
91534642e01fSmrg
91544642e01fSmrg    case $linkmode in
91554642e01fSmrg    oldlib)
915635c4bbdfSmrg      if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
915735c4bbdfSmrg	func_warning "'-dlopen' is ignored for archives"
91584642e01fSmrg      fi
91594642e01fSmrg
91604642e01fSmrg      case " $deplibs" in
91614642e01fSmrg      *\ -l* | *\ -L*)
916235c4bbdfSmrg	func_warning "'-l' and '-L' are ignored for archives" ;;
91634642e01fSmrg      esac
91644642e01fSmrg
91654642e01fSmrg      test -n "$rpath" && \
916635c4bbdfSmrg	func_warning "'-rpath' is ignored for archives"
91674642e01fSmrg
91684642e01fSmrg      test -n "$xrpath" && \
916935c4bbdfSmrg	func_warning "'-R' is ignored for archives"
91704642e01fSmrg
91714642e01fSmrg      test -n "$vinfo" && \
917235c4bbdfSmrg	func_warning "'-version-info/-version-number' is ignored for archives"
91734642e01fSmrg
91744642e01fSmrg      test -n "$release" && \
917535c4bbdfSmrg	func_warning "'-release' is ignored for archives"
91764642e01fSmrg
91774642e01fSmrg      test -n "$export_symbols$export_symbols_regex" && \
917835c4bbdfSmrg	func_warning "'-export-symbols' is ignored for archives"
91794642e01fSmrg
91804642e01fSmrg      # Now set the variables for building old libraries.
91814642e01fSmrg      build_libtool_libs=no
918235c4bbdfSmrg      oldlibs=$output
918335c4bbdfSmrg      func_append objs "$old_deplibs"
91844642e01fSmrg      ;;
91854642e01fSmrg
91864642e01fSmrg    lib)
918735c4bbdfSmrg      # Make sure we only generate libraries of the form 'libNAME.la'.
91884642e01fSmrg      case $outputname in
91894642e01fSmrg      lib*)
91904642e01fSmrg	func_stripname 'lib' '.la' "$outputname"
91914642e01fSmrg	name=$func_stripname_result
91924642e01fSmrg	eval shared_ext=\"$shrext_cmds\"
91934642e01fSmrg	eval libname=\"$libname_spec\"
91944642e01fSmrg	;;
91954642e01fSmrg      *)
919635c4bbdfSmrg	test no = "$module" \
919735c4bbdfSmrg	  && func_fatal_help "libtool library '$output' must begin with 'lib'"
91984642e01fSmrg
919935c4bbdfSmrg	if test no != "$need_lib_prefix"; then
92004642e01fSmrg	  # Add the "lib" prefix for modules if required
92014642e01fSmrg	  func_stripname '' '.la' "$outputname"
92024642e01fSmrg	  name=$func_stripname_result
92034642e01fSmrg	  eval shared_ext=\"$shrext_cmds\"
92044642e01fSmrg	  eval libname=\"$libname_spec\"
92054642e01fSmrg	else
92064642e01fSmrg	  func_stripname '' '.la' "$outputname"
92074642e01fSmrg	  libname=$func_stripname_result
92084642e01fSmrg	fi
92094642e01fSmrg	;;
92104642e01fSmrg      esac
92114642e01fSmrg
92124642e01fSmrg      if test -n "$objs"; then
921335c4bbdfSmrg	if test pass_all != "$deplibs_check_method"; then
921435c4bbdfSmrg	  func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs"
92154642e01fSmrg	else
921654b5899cSmrg	  func_warning "Linking the shared library $output against the non-libtool objects $objs is not portable!"
921735c4bbdfSmrg	  func_append libobjs " $objs"
92184642e01fSmrg	fi
92194642e01fSmrg      fi
92204642e01fSmrg
922135c4bbdfSmrg      test no = "$dlself" \
922235c4bbdfSmrg	|| func_warning "'-dlopen self' is ignored for libtool libraries"
92234642e01fSmrg
92244642e01fSmrg      set dummy $rpath
92254642e01fSmrg      shift
922635c4bbdfSmrg      test 1 -lt "$#" \
922735c4bbdfSmrg	&& func_warning "ignoring multiple '-rpath's for a libtool library"
92284642e01fSmrg
922935c4bbdfSmrg      install_libdir=$1
92304642e01fSmrg
92314642e01fSmrg      oldlibs=
92324642e01fSmrg      if test -z "$rpath"; then
923335c4bbdfSmrg	if test yes = "$build_libtool_libs"; then
92344642e01fSmrg	  # Building a libtool convenience library.
923535c4bbdfSmrg	  # Some compilers have problems with a '.al' extension so
92364642e01fSmrg	  # convenience libraries should have the same extension an
92374642e01fSmrg	  # archive normally would.
92384642e01fSmrg	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
92394642e01fSmrg	  build_libtool_libs=convenience
92404642e01fSmrg	  build_old_libs=yes
92414642e01fSmrg	fi
92424642e01fSmrg
92434642e01fSmrg	test -n "$vinfo" && \
924435c4bbdfSmrg	  func_warning "'-version-info/-version-number' is ignored for convenience libraries"
92454642e01fSmrg
92464642e01fSmrg	test -n "$release" && \
924735c4bbdfSmrg	  func_warning "'-release' is ignored for convenience libraries"
92484642e01fSmrg      else
92494642e01fSmrg
92504642e01fSmrg	# Parse the version information argument.
925135c4bbdfSmrg	save_ifs=$IFS; IFS=:
92524642e01fSmrg	set dummy $vinfo 0 0 0
92534642e01fSmrg	shift
925435c4bbdfSmrg	IFS=$save_ifs
92554642e01fSmrg
92564642e01fSmrg	test -n "$7" && \
925735c4bbdfSmrg	  func_fatal_help "too many parameters to '-version-info'"
92584642e01fSmrg
92594642e01fSmrg	# convert absolute version numbers to libtool ages
92604642e01fSmrg	# this retains compatibility with .la files and attempts
92614642e01fSmrg	# to make the code below a bit more comprehensible
92624642e01fSmrg
92634642e01fSmrg	case $vinfo_number in
92644642e01fSmrg	yes)
926535c4bbdfSmrg	  number_major=$1
926635c4bbdfSmrg	  number_minor=$2
926735c4bbdfSmrg	  number_revision=$3
92684642e01fSmrg	  #
92694642e01fSmrg	  # There are really only two kinds -- those that
92704642e01fSmrg	  # use the current revision as the major version
92714642e01fSmrg	  # and those that subtract age and use age as
92724642e01fSmrg	  # a minor version.  But, then there is irix
927335c4bbdfSmrg	  # that has an extra 1 added just for fun
92744642e01fSmrg	  #
92754642e01fSmrg	  case $version_type in
927635c4bbdfSmrg	  # correct linux to gnu/linux during the next big refactor
927754b5899cSmrg	  darwin|freebsd-elf|linux|midnightbsd-elf|osf|qnx|windows|none)
92784642e01fSmrg	    func_arith $number_major + $number_minor
92794642e01fSmrg	    current=$func_arith_result
928035c4bbdfSmrg	    age=$number_minor
928135c4bbdfSmrg	    revision=$number_revision
92824642e01fSmrg	    ;;
928354b5899cSmrg	  freebsd-aout|sco|sunos)
928435c4bbdfSmrg	    current=$number_major
928535c4bbdfSmrg	    revision=$number_minor
928635c4bbdfSmrg	    age=0
92874642e01fSmrg	    ;;
92884642e01fSmrg	  irix|nonstopux)
92894642e01fSmrg	    func_arith $number_major + $number_minor
92904642e01fSmrg	    current=$func_arith_result
929135c4bbdfSmrg	    age=$number_minor
929235c4bbdfSmrg	    revision=$number_minor
92934642e01fSmrg	    lt_irix_increment=no
92944642e01fSmrg	    ;;
929554b5899cSmrg	  *)
929654b5899cSmrg	    func_fatal_configuration "$modename: unknown library version type '$version_type'"
929754b5899cSmrg	    ;;
92984642e01fSmrg	  esac
92994642e01fSmrg	  ;;
93004642e01fSmrg	no)
930135c4bbdfSmrg	  current=$1
930235c4bbdfSmrg	  revision=$2
930335c4bbdfSmrg	  age=$3
93044642e01fSmrg	  ;;
93054642e01fSmrg	esac
93064642e01fSmrg
93074642e01fSmrg	# Check that each of the things are valid numbers.
93084642e01fSmrg	case $current in
93094642e01fSmrg	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]) ;;
93104642e01fSmrg	*)
931135c4bbdfSmrg	  func_error "CURRENT '$current' must be a nonnegative integer"
931235c4bbdfSmrg	  func_fatal_error "'$vinfo' is not valid version information"
93134642e01fSmrg	  ;;
93144642e01fSmrg	esac
93154642e01fSmrg
93164642e01fSmrg	case $revision in
93174642e01fSmrg	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]) ;;
93184642e01fSmrg	*)
931935c4bbdfSmrg	  func_error "REVISION '$revision' must be a nonnegative integer"
932035c4bbdfSmrg	  func_fatal_error "'$vinfo' is not valid version information"
93214642e01fSmrg	  ;;
93224642e01fSmrg	esac
93234642e01fSmrg
93244642e01fSmrg	case $age in
93254642e01fSmrg	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]) ;;
93264642e01fSmrg	*)
932735c4bbdfSmrg	  func_error "AGE '$age' must be a nonnegative integer"
932835c4bbdfSmrg	  func_fatal_error "'$vinfo' is not valid version information"
93294642e01fSmrg	  ;;
93304642e01fSmrg	esac
93314642e01fSmrg
93324642e01fSmrg	if test "$age" -gt "$current"; then
933335c4bbdfSmrg	  func_error "AGE '$age' is greater than the current interface number '$current'"
933435c4bbdfSmrg	  func_fatal_error "'$vinfo' is not valid version information"
93354642e01fSmrg	fi
93364642e01fSmrg
93374642e01fSmrg	# Calculate the version variables.
93384642e01fSmrg	major=
93394642e01fSmrg	versuffix=
93404642e01fSmrg	verstring=
93414642e01fSmrg	case $version_type in
93424642e01fSmrg	none) ;;
93434642e01fSmrg
93444642e01fSmrg	darwin)
93454642e01fSmrg	  # Like Linux, but with the current version available in
93464642e01fSmrg	  # verstring for coding it into the library header
93474642e01fSmrg	  func_arith $current - $age
93484642e01fSmrg	  major=.$func_arith_result
934935c4bbdfSmrg	  versuffix=$major.$age.$revision
93504642e01fSmrg	  # Darwin ld doesn't like 0 for these options...
93514642e01fSmrg	  func_arith $current + 1
93524642e01fSmrg	  minor_current=$func_arith_result
935335c4bbdfSmrg	  xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
93544642e01fSmrg	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
935535c4bbdfSmrg          # On Darwin other compilers
935635c4bbdfSmrg          case $CC in
935735c4bbdfSmrg              nagfor*)
935835c4bbdfSmrg                  verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
935935c4bbdfSmrg                  ;;
936035c4bbdfSmrg              *)
936135c4bbdfSmrg                  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
936235c4bbdfSmrg                  ;;
936335c4bbdfSmrg          esac
93644642e01fSmrg	  ;;
93654642e01fSmrg
93664642e01fSmrg	freebsd-aout)
936735c4bbdfSmrg	  major=.$current
936835c4bbdfSmrg	  versuffix=.$current.$revision
93694642e01fSmrg	  ;;
93704642e01fSmrg
9371c82838c1Smrg	freebsd-elf | midnightbsd-elf)
937235c4bbdfSmrg	  func_arith $current - $age
937335c4bbdfSmrg	  major=.$func_arith_result
937435c4bbdfSmrg	  versuffix=$major.$age.$revision
93754642e01fSmrg	  ;;
93764642e01fSmrg
93774642e01fSmrg	irix | nonstopux)
937835c4bbdfSmrg	  if test no = "$lt_irix_increment"; then
93794642e01fSmrg	    func_arith $current - $age
93804642e01fSmrg	  else
93814642e01fSmrg	    func_arith $current - $age + 1
93824642e01fSmrg	  fi
93834642e01fSmrg	  major=$func_arith_result
93844642e01fSmrg
93854642e01fSmrg	  case $version_type in
93864642e01fSmrg	    nonstopux) verstring_prefix=nonstopux ;;
93874642e01fSmrg	    *)         verstring_prefix=sgi ;;
93884642e01fSmrg	  esac
938935c4bbdfSmrg	  verstring=$verstring_prefix$major.$revision
93904642e01fSmrg
93914642e01fSmrg	  # Add in all the interfaces that we are compatible with.
93924642e01fSmrg	  loop=$revision
939335c4bbdfSmrg	  while test 0 -ne "$loop"; do
93944642e01fSmrg	    func_arith $revision - $loop
93954642e01fSmrg	    iface=$func_arith_result
93964642e01fSmrg	    func_arith $loop - 1
93974642e01fSmrg	    loop=$func_arith_result
939835c4bbdfSmrg	    verstring=$verstring_prefix$major.$iface:$verstring
93994642e01fSmrg	  done
94004642e01fSmrg
940135c4bbdfSmrg	  # Before this point, $major must not contain '.'.
94024642e01fSmrg	  major=.$major
940335c4bbdfSmrg	  versuffix=$major.$revision
94044642e01fSmrg	  ;;
94054642e01fSmrg
940635c4bbdfSmrg	linux) # correct to gnu/linux during the next big refactor
94074642e01fSmrg	  func_arith $current - $age
94084642e01fSmrg	  major=.$func_arith_result
940935c4bbdfSmrg	  versuffix=$major.$age.$revision
94104642e01fSmrg	  ;;
94114642e01fSmrg
94124642e01fSmrg	osf)
94134642e01fSmrg	  func_arith $current - $age
94144642e01fSmrg	  major=.$func_arith_result
941535c4bbdfSmrg	  versuffix=.$current.$age.$revision
941635c4bbdfSmrg	  verstring=$current.$age.$revision
94174642e01fSmrg
94184642e01fSmrg	  # Add in all the interfaces that we are compatible with.
94194642e01fSmrg	  loop=$age
942035c4bbdfSmrg	  while test 0 -ne "$loop"; do
94214642e01fSmrg	    func_arith $current - $loop
94224642e01fSmrg	    iface=$func_arith_result
94234642e01fSmrg	    func_arith $loop - 1
94244642e01fSmrg	    loop=$func_arith_result
942535c4bbdfSmrg	    verstring=$verstring:$iface.0
94264642e01fSmrg	  done
94274642e01fSmrg
94284642e01fSmrg	  # Make executables depend on our current version.
942935c4bbdfSmrg	  func_append verstring ":$current.0"
94304642e01fSmrg	  ;;
94314642e01fSmrg
94324642e01fSmrg	qnx)
943354b5899cSmrg	  func_arith $current - $age
943454b5899cSmrg	  major=.$func_arith_result
943554b5899cSmrg	  versuffix=$major.$age.$revision
943635c4bbdfSmrg	  ;;
943735c4bbdfSmrg
943835c4bbdfSmrg	sco)
943935c4bbdfSmrg	  major=.$current
944035c4bbdfSmrg	  versuffix=.$current
94414642e01fSmrg	  ;;
94424642e01fSmrg
94434642e01fSmrg	sunos)
944435c4bbdfSmrg	  major=.$current
944535c4bbdfSmrg	  versuffix=.$current.$revision
94464642e01fSmrg	  ;;
94474642e01fSmrg
94484642e01fSmrg	windows)
94494642e01fSmrg	  # Use '-' rather than '.', since we only want one
945035c4bbdfSmrg	  # extension on DOS 8.3 file systems.
94514642e01fSmrg	  func_arith $current - $age
94524642e01fSmrg	  major=$func_arith_result
945335c4bbdfSmrg	  versuffix=-$major
94544642e01fSmrg	  ;;
94554642e01fSmrg
94564642e01fSmrg	*)
945735c4bbdfSmrg	  func_fatal_configuration "unknown library version type '$version_type'"
94584642e01fSmrg	  ;;
94594642e01fSmrg	esac
94604642e01fSmrg
94614642e01fSmrg	# Clear the version info if we defaulted, and they specified a release.
94624642e01fSmrg	if test -z "$vinfo" && test -n "$release"; then
94634642e01fSmrg	  major=
94644642e01fSmrg	  case $version_type in
94654642e01fSmrg	  darwin)
94664642e01fSmrg	    # we can't check for "0.0" in archive_cmds due to quoting
94674642e01fSmrg	    # problems, so we reset it completely
94684642e01fSmrg	    verstring=
94694642e01fSmrg	    ;;
94704642e01fSmrg	  *)
947135c4bbdfSmrg	    verstring=0.0
94724642e01fSmrg	    ;;
94734642e01fSmrg	  esac
947435c4bbdfSmrg	  if test no = "$need_version"; then
94754642e01fSmrg	    versuffix=
94764642e01fSmrg	  else
947735c4bbdfSmrg	    versuffix=.0.0
94784642e01fSmrg	  fi
94794642e01fSmrg	fi
94804642e01fSmrg
94814642e01fSmrg	# Remove version info from name if versioning should be avoided
948235c4bbdfSmrg	if test yes,no = "$avoid_version,$need_version"; then
94834642e01fSmrg	  major=
94844642e01fSmrg	  versuffix=
948535c4bbdfSmrg	  verstring=
94864642e01fSmrg	fi
94874642e01fSmrg
94884642e01fSmrg	# Check to see if the archive will have undefined symbols.
948935c4bbdfSmrg	if test yes = "$allow_undefined"; then
949035c4bbdfSmrg	  if test unsupported = "$allow_undefined_flag"; then
949135c4bbdfSmrg	    if test yes = "$build_old_libs"; then
949235c4bbdfSmrg	      func_warning "undefined symbols not allowed in $host shared libraries; building static only"
949335c4bbdfSmrg	      build_libtool_libs=no
949435c4bbdfSmrg	    else
949535c4bbdfSmrg	      func_fatal_error "can't build $host shared library unless -no-undefined is specified"
949635c4bbdfSmrg	    fi
94974642e01fSmrg	  fi
94984642e01fSmrg	else
94994642e01fSmrg	  # Don't allow undefined symbols.
950035c4bbdfSmrg	  allow_undefined_flag=$no_undefined_flag
95014642e01fSmrg	fi
95024642e01fSmrg
95034642e01fSmrg      fi
95044642e01fSmrg
950535c4bbdfSmrg      func_generate_dlsyms "$libname" "$libname" :
950635c4bbdfSmrg      func_append libobjs " $symfileobj"
950735c4bbdfSmrg      test " " = "$libobjs" && libobjs=
95084642e01fSmrg
950935c4bbdfSmrg      if test relink != "$opt_mode"; then
95104642e01fSmrg	# Remove our outputs, but don't remove object files since they
95114642e01fSmrg	# may have been created when compiling PIC objects.
95124642e01fSmrg	removelist=
95134642e01fSmrg	tempremovelist=`$ECHO "$output_objdir/*"`
95144642e01fSmrg	for p in $tempremovelist; do
95154642e01fSmrg	  case $p in
95164642e01fSmrg	    *.$objext | *.gcno)
95174642e01fSmrg	       ;;
951835c4bbdfSmrg	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*)
951935c4bbdfSmrg	       if test -n "$precious_files_regex"; then
95204642e01fSmrg		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
95214642e01fSmrg		 then
95224642e01fSmrg		   continue
95234642e01fSmrg		 fi
95244642e01fSmrg	       fi
952535c4bbdfSmrg	       func_append removelist " $p"
95264642e01fSmrg	       ;;
95274642e01fSmrg	    *) ;;
95284642e01fSmrg	  esac
95294642e01fSmrg	done
95304642e01fSmrg	test -n "$removelist" && \
95314642e01fSmrg	  func_show_eval "${RM}r \$removelist"
95324642e01fSmrg      fi
95334642e01fSmrg
95344642e01fSmrg      # Now set the variables for building old libraries.
953535c4bbdfSmrg      if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then
953635c4bbdfSmrg	func_append oldlibs " $output_objdir/$libname.$libext"
95374642e01fSmrg
95384642e01fSmrg	# Transform .lo files to .o files.
953935c4bbdfSmrg	oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP`
95404642e01fSmrg      fi
95414642e01fSmrg
95424642e01fSmrg      # Eliminate all temporary directories.
95434642e01fSmrg      #for path in $notinst_path; do
95446747b715Smrg      #	lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
95456747b715Smrg      #	deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
95466747b715Smrg      #	dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
95474642e01fSmrg      #done
95484642e01fSmrg
95494642e01fSmrg      if test -n "$xrpath"; then
95504642e01fSmrg	# If the user specified any rpath flags, then add them.
95514642e01fSmrg	temp_xrpath=
95524642e01fSmrg	for libdir in $xrpath; do
955335c4bbdfSmrg	  func_replace_sysroot "$libdir"
955435c4bbdfSmrg	  func_append temp_xrpath " -R$func_replace_sysroot_result"
95554642e01fSmrg	  case "$finalize_rpath " in
95564642e01fSmrg	  *" $libdir "*) ;;
955735c4bbdfSmrg	  *) func_append finalize_rpath " $libdir" ;;
95584642e01fSmrg	  esac
95594642e01fSmrg	done
956035c4bbdfSmrg	if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then
95614642e01fSmrg	  dependency_libs="$temp_xrpath $dependency_libs"
95624642e01fSmrg	fi
95634642e01fSmrg      fi
95644642e01fSmrg
95654642e01fSmrg      # Make sure dlfiles contains only unique files that won't be dlpreopened
956635c4bbdfSmrg      old_dlfiles=$dlfiles
95674642e01fSmrg      dlfiles=
95684642e01fSmrg      for lib in $old_dlfiles; do
95694642e01fSmrg	case " $dlprefiles $dlfiles " in
95704642e01fSmrg	*" $lib "*) ;;
957135c4bbdfSmrg	*) func_append dlfiles " $lib" ;;
95724642e01fSmrg	esac
95734642e01fSmrg      done
95744642e01fSmrg
95754642e01fSmrg      # Make sure dlprefiles contains only unique files
957635c4bbdfSmrg      old_dlprefiles=$dlprefiles
95774642e01fSmrg      dlprefiles=
95784642e01fSmrg      for lib in $old_dlprefiles; do
95794642e01fSmrg	case "$dlprefiles " in
95804642e01fSmrg	*" $lib "*) ;;
958135c4bbdfSmrg	*) func_append dlprefiles " $lib" ;;
95824642e01fSmrg	esac
95834642e01fSmrg      done
95844642e01fSmrg
958535c4bbdfSmrg      if test yes = "$build_libtool_libs"; then
95864642e01fSmrg	if test -n "$rpath"; then
95874642e01fSmrg	  case $host in
958854b5899cSmrg	  *-*-cygwin* | *-*-mingw* | *-*-windows* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
95894642e01fSmrg	    # these systems don't actually have a c library (as such)!
95904642e01fSmrg	    ;;
95914642e01fSmrg	  *-*-rhapsody* | *-*-darwin1.[012])
95924642e01fSmrg	    # Rhapsody C library is in the System framework
959335c4bbdfSmrg	    func_append deplibs " System.ltframework"
95944642e01fSmrg	    ;;
95954642e01fSmrg	  *-*-netbsd*)
95964642e01fSmrg	    # Don't link with libc until the a.out ld.so is fixed.
95974642e01fSmrg	    ;;
9598c82838c1Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-midnightbsd*)
95994642e01fSmrg	    # Do not include libc due to us having libc/libc_r.
96004642e01fSmrg	    ;;
96014642e01fSmrg	  *-*-sco3.2v5* | *-*-sco5v6*)
96024642e01fSmrg	    # Causes problems with __ctype
96034642e01fSmrg	    ;;
96044642e01fSmrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
96054642e01fSmrg	    # Compiler inserts libc in the correct place for threads to work
96064642e01fSmrg	    ;;
96074642e01fSmrg	  *)
96084642e01fSmrg	    # Add libc to deplibs on all other systems if necessary.
960935c4bbdfSmrg	    if test yes = "$build_libtool_need_lc"; then
961035c4bbdfSmrg	      func_append deplibs " -lc"
96114642e01fSmrg	    fi
96124642e01fSmrg	    ;;
96134642e01fSmrg	  esac
96144642e01fSmrg	fi
96154642e01fSmrg
96164642e01fSmrg	# Transform deplibs into only deplibs that can be linked in shared.
96174642e01fSmrg	name_save=$name
96184642e01fSmrg	libname_save=$libname
96194642e01fSmrg	release_save=$release
96204642e01fSmrg	versuffix_save=$versuffix
96214642e01fSmrg	major_save=$major
96224642e01fSmrg	# I'm not sure if I'm treating the release correctly.  I think
96234642e01fSmrg	# release should show up in the -l (ie -lgmp5) so we don't want to
96244642e01fSmrg	# add it in twice.  Is that correct?
962535c4bbdfSmrg	release=
962635c4bbdfSmrg	versuffix=
962735c4bbdfSmrg	major=
96284642e01fSmrg	newdeplibs=
96294642e01fSmrg	droppeddeps=no
96304642e01fSmrg	case $deplibs_check_method in
96314642e01fSmrg	pass_all)
96324642e01fSmrg	  # Don't check for shared/static.  Everything works.
96334642e01fSmrg	  # This might be a little naive.  We might want to check
96344642e01fSmrg	  # whether the library exists or not.  But this is on
96354642e01fSmrg	  # osf3 & osf4 and I'm not really sure... Just
96364642e01fSmrg	  # implementing what was already the behavior.
96374642e01fSmrg	  newdeplibs=$deplibs
96384642e01fSmrg	  ;;
96394642e01fSmrg	file_magic*)
96404642e01fSmrg	  set dummy $deplibs_check_method; shift
96414642e01fSmrg	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
96424642e01fSmrg	  for a_deplib in $deplibs; do
96434642e01fSmrg	    case $a_deplib in
96444642e01fSmrg	    -l*)
96454642e01fSmrg	      func_stripname -l '' "$a_deplib"
96464642e01fSmrg	      name=$func_stripname_result
964735c4bbdfSmrg	      if test yes = "$allow_libtool_libs_with_static_runtimes"; then
96484642e01fSmrg		case " $predeps $postdeps " in
96494642e01fSmrg		*" $a_deplib "*)
965035c4bbdfSmrg		  func_append newdeplibs " $a_deplib"
965135c4bbdfSmrg		  a_deplib=
96524642e01fSmrg		  ;;
96534642e01fSmrg		esac
96544642e01fSmrg	      fi
965535c4bbdfSmrg	      if test -n "$a_deplib"; then
96564642e01fSmrg		libname=`eval "\\$ECHO \"$libname_spec\""`
965735c4bbdfSmrg		if test -n "$file_magic_glob"; then
965835c4bbdfSmrg		  libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
965935c4bbdfSmrg		else
966035c4bbdfSmrg		  libnameglob=$libname
966135c4bbdfSmrg		fi
966235c4bbdfSmrg		test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob`
96634642e01fSmrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
966435c4bbdfSmrg		  if test yes = "$want_nocaseglob"; then
966535c4bbdfSmrg		    shopt -s nocaseglob
966635c4bbdfSmrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
966735c4bbdfSmrg		    $nocaseglob
966835c4bbdfSmrg		  else
966935c4bbdfSmrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
967035c4bbdfSmrg		  fi
96714642e01fSmrg		  for potent_lib in $potential_libs; do
96724642e01fSmrg		      # Follow soft links.
96734642e01fSmrg		      if ls -lLd "$potent_lib" 2>/dev/null |
96744642e01fSmrg			 $GREP " -> " >/dev/null; then
96754642e01fSmrg			continue
96764642e01fSmrg		      fi
96774642e01fSmrg		      # The statement above tries to avoid entering an
96784642e01fSmrg		      # endless loop below, in case of cyclic links.
96794642e01fSmrg		      # We might still enter an endless loop, since a link
96804642e01fSmrg		      # loop can be closed while we follow links,
96814642e01fSmrg		      # but so what?
968235c4bbdfSmrg		      potlib=$potent_lib
96834642e01fSmrg		      while test -h "$potlib" 2>/dev/null; do
968435c4bbdfSmrg			potliblink=`ls -ld $potlib | $SED 's/.* -> //'`
96854642e01fSmrg			case $potliblink in
968635c4bbdfSmrg			[\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;;
968735c4bbdfSmrg			*) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";;
96884642e01fSmrg			esac
96894642e01fSmrg		      done
96904642e01fSmrg		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
96914642e01fSmrg			 $SED -e 10q |
96924642e01fSmrg			 $EGREP "$file_magic_regex" > /dev/null; then
969335c4bbdfSmrg			func_append newdeplibs " $a_deplib"
969435c4bbdfSmrg			a_deplib=
96954642e01fSmrg			break 2
96964642e01fSmrg		      fi
96974642e01fSmrg		  done
96984642e01fSmrg		done
96994642e01fSmrg	      fi
970035c4bbdfSmrg	      if test -n "$a_deplib"; then
97014642e01fSmrg		droppeddeps=yes
970254b5899cSmrg		func_warning "Linker path does not have real file for library $a_deplib."
970354b5899cSmrg		func_warning "I have the capability to make that library automatically link in when"
970454b5899cSmrg		func_warning "you link to this library.  But I can only do this if you have a"
970554b5899cSmrg		func_warning "shared version of the library, which you do not appear to have"
970654b5899cSmrg		func_warning "because I did check the linker path looking for a file starting"
970735c4bbdfSmrg		if test -z "$potlib"; then
970854b5899cSmrg		  func_warning "with $libname but no candidates were found. (...for file magic test)"
97094642e01fSmrg		else
971054b5899cSmrg		  func_warning "with $libname and none of the candidates passed a file format test"
971154b5899cSmrg		  func_warning "using a file magic. Last file checked: $potlib"
97124642e01fSmrg		fi
97134642e01fSmrg	      fi
97144642e01fSmrg	      ;;
97154642e01fSmrg	    *)
97164642e01fSmrg	      # Add a -L argument.
971735c4bbdfSmrg	      func_append newdeplibs " $a_deplib"
97184642e01fSmrg	      ;;
97194642e01fSmrg	    esac
97204642e01fSmrg	  done # Gone through all deplibs.
97214642e01fSmrg	  ;;
97224642e01fSmrg	match_pattern*)
97234642e01fSmrg	  set dummy $deplibs_check_method; shift
97244642e01fSmrg	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
97254642e01fSmrg	  for a_deplib in $deplibs; do
97264642e01fSmrg	    case $a_deplib in
97274642e01fSmrg	    -l*)
97284642e01fSmrg	      func_stripname -l '' "$a_deplib"
97294642e01fSmrg	      name=$func_stripname_result
973035c4bbdfSmrg	      if test yes = "$allow_libtool_libs_with_static_runtimes"; then
97314642e01fSmrg		case " $predeps $postdeps " in
97324642e01fSmrg		*" $a_deplib "*)
973335c4bbdfSmrg		  func_append newdeplibs " $a_deplib"
973435c4bbdfSmrg		  a_deplib=
97354642e01fSmrg		  ;;
97364642e01fSmrg		esac
97374642e01fSmrg	      fi
973835c4bbdfSmrg	      if test -n "$a_deplib"; then
97394642e01fSmrg		libname=`eval "\\$ECHO \"$libname_spec\""`
97404642e01fSmrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
97414642e01fSmrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
97424642e01fSmrg		  for potent_lib in $potential_libs; do
974335c4bbdfSmrg		    potlib=$potent_lib # see symlink-check above in file_magic test
97446747b715Smrg		    if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
97454642e01fSmrg		       $EGREP "$match_pattern_regex" > /dev/null; then
974635c4bbdfSmrg		      func_append newdeplibs " $a_deplib"
974735c4bbdfSmrg		      a_deplib=
97484642e01fSmrg		      break 2
97494642e01fSmrg		    fi
97504642e01fSmrg		  done
97514642e01fSmrg		done
97524642e01fSmrg	      fi
975335c4bbdfSmrg	      if test -n "$a_deplib"; then
97544642e01fSmrg		droppeddeps=yes
975554b5899cSmrg		func_warning "Linker path does not have real file for library $a_deplib."
975654b5899cSmrg		func_warning "I have the capability to make that library automatically link in when"
975754b5899cSmrg		func_warning "you link to this library.  But I can only do this if you have a"
975854b5899cSmrg		func_warning "shared version of the library, which you do not appear to have"
975954b5899cSmrg		func_warning "because I did check the linker path looking for a file starting"
976035c4bbdfSmrg		if test -z "$potlib"; then
976154b5899cSmrg		  func_warning "with $libname but no candidates were found. (...for regex pattern test)"
97624642e01fSmrg		else
976354b5899cSmrg		  func_warning "with $libname and none of the candidates passed a file format test"
976454b5899cSmrg		  func_warning "using a regex pattern. Last file checked: $potlib"
97654642e01fSmrg		fi
97664642e01fSmrg	      fi
97674642e01fSmrg	      ;;
97684642e01fSmrg	    *)
97694642e01fSmrg	      # Add a -L argument.
977035c4bbdfSmrg	      func_append newdeplibs " $a_deplib"
97714642e01fSmrg	      ;;
97724642e01fSmrg	    esac
97734642e01fSmrg	  done # Gone through all deplibs.
97744642e01fSmrg	  ;;
97754642e01fSmrg	none | unknown | *)
977635c4bbdfSmrg	  newdeplibs=
97776747b715Smrg	  tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
977835c4bbdfSmrg	  if test yes = "$allow_libtool_libs_with_static_runtimes"; then
977935c4bbdfSmrg	    for i in $predeps $postdeps; do
97804642e01fSmrg	      # can't use Xsed below, because $i might contain '/'
978135c4bbdfSmrg	      tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"`
97824642e01fSmrg	    done
97834642e01fSmrg	  fi
97846747b715Smrg	  case $tmp_deplibs in
97856747b715Smrg	  *[!\	\ ]*)
97866747b715Smrg	    echo
978735c4bbdfSmrg	    if test none = "$deplibs_check_method"; then
978854b5899cSmrg	      func_warning "Inter-library dependencies are not supported in this platform."
97894642e01fSmrg	    else
979054b5899cSmrg	      func_warning "Inter-library dependencies are not known to be supported."
97914642e01fSmrg	    fi
979254b5899cSmrg	    func_warning "All declared inter-library dependencies are being dropped."
97934642e01fSmrg	    droppeddeps=yes
97946747b715Smrg	    ;;
97956747b715Smrg	  esac
97964642e01fSmrg	  ;;
97974642e01fSmrg	esac
97984642e01fSmrg	versuffix=$versuffix_save
97994642e01fSmrg	major=$major_save
98004642e01fSmrg	release=$release_save
98014642e01fSmrg	libname=$libname_save
98024642e01fSmrg	name=$name_save
98034642e01fSmrg
98044642e01fSmrg	case $host in
98054642e01fSmrg	*-*-rhapsody* | *-*-darwin1.[012])
98064642e01fSmrg	  # On Rhapsody replace the C library with the System framework
98076747b715Smrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
98084642e01fSmrg	  ;;
98094642e01fSmrg	esac
98104642e01fSmrg
981135c4bbdfSmrg	if test yes = "$droppeddeps"; then
981235c4bbdfSmrg	  if test yes = "$module"; then
981354b5899cSmrg	    func_warning "libtool could not satisfy all declared inter-library"
981454b5899cSmrg	    func_warning "dependencies of module $libname.  Therefore, libtool will create"
981554b5899cSmrg	    func_warning "a static module, that should work as long as the dlopening"
981654b5899cSmrg	    func_warning "application is linked with the -dlopen flag."
98174642e01fSmrg	    if test -z "$global_symbol_pipe"; then
981854b5899cSmrg	      func_warning "However, this would only work if libtool was able to extract symbol"
981954b5899cSmrg	      func_warning "lists from a program, using 'nm' or equivalent, but libtool could"
982054b5899cSmrg	      func_warning "not find such a program.  So, this module is probably useless."
982154b5899cSmrg	      func_warning "'nm' from GNU binutils and a full rebuild may help."
98224642e01fSmrg	    fi
982335c4bbdfSmrg	    if test no = "$build_old_libs"; then
982435c4bbdfSmrg	      oldlibs=$output_objdir/$libname.$libext
98254642e01fSmrg	      build_libtool_libs=module
98264642e01fSmrg	      build_old_libs=yes
98274642e01fSmrg	    else
98284642e01fSmrg	      build_libtool_libs=no
98294642e01fSmrg	    fi
98304642e01fSmrg	  else
98316747b715Smrg	    echo "*** The inter-library dependencies that have been dropped here will be"
98326747b715Smrg	    echo "*** automatically added whenever a program is linked with this library"
98336747b715Smrg	    echo "*** or is declared to -dlopen it."
98344642e01fSmrg
983535c4bbdfSmrg	    if test no = "$allow_undefined"; then
98366747b715Smrg	      echo
98376747b715Smrg	      echo "*** Since this library must not contain undefined symbols,"
98386747b715Smrg	      echo "*** because either the platform does not support them or"
98396747b715Smrg	      echo "*** it was explicitly requested with -no-undefined,"
98406747b715Smrg	      echo "*** libtool will only create a static version of it."
984135c4bbdfSmrg	      if test no = "$build_old_libs"; then
984235c4bbdfSmrg		oldlibs=$output_objdir/$libname.$libext
98434642e01fSmrg		build_libtool_libs=module
98444642e01fSmrg		build_old_libs=yes
98454642e01fSmrg	      else
98464642e01fSmrg		build_libtool_libs=no
98474642e01fSmrg	      fi
98484642e01fSmrg	    fi
98494642e01fSmrg	  fi
98504642e01fSmrg	fi
98514642e01fSmrg	# Done checking deplibs!
98524642e01fSmrg	deplibs=$newdeplibs
98534642e01fSmrg      fi
98544642e01fSmrg      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
98554642e01fSmrg      case $host in
98564642e01fSmrg	*-*-darwin*)
98576747b715Smrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
98586747b715Smrg	  new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
98596747b715Smrg	  deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
98604642e01fSmrg	  ;;
98614642e01fSmrg      esac
98624642e01fSmrg
98634642e01fSmrg      # move library search paths that coincide with paths to not yet
98644642e01fSmrg      # installed libraries to the beginning of the library search list
98654642e01fSmrg      new_libs=
98664642e01fSmrg      for path in $notinst_path; do
98674642e01fSmrg	case " $new_libs " in
98684642e01fSmrg	*" -L$path/$objdir "*) ;;
98694642e01fSmrg	*)
98704642e01fSmrg	  case " $deplibs " in
98714642e01fSmrg	  *" -L$path/$objdir "*)
987235c4bbdfSmrg	    func_append new_libs " -L$path/$objdir" ;;
98734642e01fSmrg	  esac
98744642e01fSmrg	  ;;
98754642e01fSmrg	esac
98764642e01fSmrg      done
98774642e01fSmrg      for deplib in $deplibs; do
98784642e01fSmrg	case $deplib in
98794642e01fSmrg	-L*)
98804642e01fSmrg	  case " $new_libs " in
98814642e01fSmrg	  *" $deplib "*) ;;
988235c4bbdfSmrg	  *) func_append new_libs " $deplib" ;;
98834642e01fSmrg	  esac
98844642e01fSmrg	  ;;
988535c4bbdfSmrg	*) func_append new_libs " $deplib" ;;
98864642e01fSmrg	esac
98874642e01fSmrg      done
988835c4bbdfSmrg      deplibs=$new_libs
98894642e01fSmrg
98904642e01fSmrg      # All the library-specific variables (install_libdir is set above).
98914642e01fSmrg      library_names=
98924642e01fSmrg      old_library=
98934642e01fSmrg      dlname=
98944642e01fSmrg
98954642e01fSmrg      # Test again, we may have decided not to build it any more
989635c4bbdfSmrg      if test yes = "$build_libtool_libs"; then
989735c4bbdfSmrg	# Remove $wl instances when linking with ld.
989835c4bbdfSmrg	# FIXME: should test the right _cmds variable.
989935c4bbdfSmrg	case $archive_cmds in
990035c4bbdfSmrg	  *\$LD\ *) wl= ;;
990135c4bbdfSmrg        esac
990235c4bbdfSmrg	if test yes = "$hardcode_into_libs"; then
99034642e01fSmrg	  # Hardcode the library paths
99044642e01fSmrg	  hardcode_libdirs=
99054642e01fSmrg	  dep_rpath=
990635c4bbdfSmrg	  rpath=$finalize_rpath
990735c4bbdfSmrg	  test relink = "$opt_mode" || rpath=$compile_rpath$rpath
99084642e01fSmrg	  for libdir in $rpath; do
99094642e01fSmrg	    if test -n "$hardcode_libdir_flag_spec"; then
99104642e01fSmrg	      if test -n "$hardcode_libdir_separator"; then
991135c4bbdfSmrg		func_replace_sysroot "$libdir"
991235c4bbdfSmrg		libdir=$func_replace_sysroot_result
99134642e01fSmrg		if test -z "$hardcode_libdirs"; then
991435c4bbdfSmrg		  hardcode_libdirs=$libdir
99154642e01fSmrg		else
99164642e01fSmrg		  # Just accumulate the unique libdirs.
99174642e01fSmrg		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
99184642e01fSmrg		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
99194642e01fSmrg		    ;;
99204642e01fSmrg		  *)
992135c4bbdfSmrg		    func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
99224642e01fSmrg		    ;;
99234642e01fSmrg		  esac
99244642e01fSmrg		fi
99254642e01fSmrg	      else
99264642e01fSmrg		eval flag=\"$hardcode_libdir_flag_spec\"
992735c4bbdfSmrg		func_append dep_rpath " $flag"
99284642e01fSmrg	      fi
99294642e01fSmrg	    elif test -n "$runpath_var"; then
99304642e01fSmrg	      case "$perm_rpath " in
99314642e01fSmrg	      *" $libdir "*) ;;
993235c4bbdfSmrg	      *) func_append perm_rpath " $libdir" ;;
99334642e01fSmrg	      esac
99344642e01fSmrg	    fi
99354642e01fSmrg	  done
99364642e01fSmrg	  # Substitute the hardcoded libdirs into the rpath.
99374642e01fSmrg	  if test -n "$hardcode_libdir_separator" &&
99384642e01fSmrg	     test -n "$hardcode_libdirs"; then
993935c4bbdfSmrg	    libdir=$hardcode_libdirs
994035c4bbdfSmrg	    eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
99414642e01fSmrg	  fi
99424642e01fSmrg	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
99434642e01fSmrg	    # We should set the runpath_var.
99444642e01fSmrg	    rpath=
99454642e01fSmrg	    for dir in $perm_rpath; do
994635c4bbdfSmrg	      func_append rpath "$dir:"
99474642e01fSmrg	    done
99484642e01fSmrg	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
99494642e01fSmrg	  fi
99504642e01fSmrg	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
99514642e01fSmrg	fi
995205b261ecSmrg
995335c4bbdfSmrg	shlibpath=$finalize_shlibpath
995435c4bbdfSmrg	test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath
99554642e01fSmrg	if test -n "$shlibpath"; then
99564642e01fSmrg	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
99574642e01fSmrg	fi
995805b261ecSmrg
99594642e01fSmrg	# Get the real and link names of the library.
99604642e01fSmrg	eval shared_ext=\"$shrext_cmds\"
99614642e01fSmrg	eval library_names=\"$library_names_spec\"
99624642e01fSmrg	set dummy $library_names
99634642e01fSmrg	shift
996435c4bbdfSmrg	realname=$1
99654642e01fSmrg	shift
996605b261ecSmrg
99674642e01fSmrg	if test -n "$soname_spec"; then
99684642e01fSmrg	  eval soname=\"$soname_spec\"
99694642e01fSmrg	else
997035c4bbdfSmrg	  soname=$realname
99714642e01fSmrg	fi
99724642e01fSmrg	if test -z "$dlname"; then
99734642e01fSmrg	  dlname=$soname
99744642e01fSmrg	fi
997505b261ecSmrg
997635c4bbdfSmrg	lib=$output_objdir/$realname
99774642e01fSmrg	linknames=
99784642e01fSmrg	for link
99794642e01fSmrg	do
998035c4bbdfSmrg	  func_append linknames " $link"
99814642e01fSmrg	done
998205b261ecSmrg
99834642e01fSmrg	# Use standard objects if they are pic
99846747b715Smrg	test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
99854642e01fSmrg	test "X$libobjs" = "X " && libobjs=
998605b261ecSmrg
99874642e01fSmrg	delfiles=
99884642e01fSmrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
99894642e01fSmrg	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
999035c4bbdfSmrg	  export_symbols=$output_objdir/$libname.uexp
999135c4bbdfSmrg	  func_append delfiles " $export_symbols"
99924642e01fSmrg	fi
999305b261ecSmrg
99944642e01fSmrg	orig_export_symbols=
99954642e01fSmrg	case $host_os in
999654b5899cSmrg	cygwin* | mingw* | windows* | cegcc*)
99974642e01fSmrg	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
99984642e01fSmrg	    # exporting using user supplied symfile
999935c4bbdfSmrg	    func_dll_def_p "$export_symbols" || {
100004642e01fSmrg	      # and it's NOT already a .def file. Must figure out
100014642e01fSmrg	      # which of the given symbols are data symbols and tag
100024642e01fSmrg	      # them as such. So, trigger use of export_symbols_cmds.
100034642e01fSmrg	      # export_symbols gets reassigned inside the "prepare
100044642e01fSmrg	      # the list of exported symbols" if statement, so the
100054642e01fSmrg	      # include_expsyms logic still works.
1000635c4bbdfSmrg	      orig_export_symbols=$export_symbols
100074642e01fSmrg	      export_symbols=
100084642e01fSmrg	      always_export_symbols=yes
1000935c4bbdfSmrg	    }
100104642e01fSmrg	  fi
100114642e01fSmrg	  ;;
100124642e01fSmrg	esac
1001305b261ecSmrg
100144642e01fSmrg	# Prepare the list of exported symbols
100154642e01fSmrg	if test -z "$export_symbols"; then
1001635c4bbdfSmrg	  if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then
1001735c4bbdfSmrg	    func_verbose "generating symbol list for '$libname.la'"
1001835c4bbdfSmrg	    export_symbols=$output_objdir/$libname.exp
100194642e01fSmrg	    $opt_dry_run || $RM $export_symbols
100204642e01fSmrg	    cmds=$export_symbols_cmds
1002135c4bbdfSmrg	    save_ifs=$IFS; IFS='~'
1002235c4bbdfSmrg	    for cmd1 in $cmds; do
1002335c4bbdfSmrg	      IFS=$save_ifs
1002435c4bbdfSmrg	      # Take the normal branch if the nm_file_list_spec branch
1002535c4bbdfSmrg	      # doesn't work or if tool conversion is not needed.
1002635c4bbdfSmrg	      case $nm_file_list_spec~$to_tool_file_cmd in
1002735c4bbdfSmrg		*~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
1002835c4bbdfSmrg		  try_normal_branch=yes
1002935c4bbdfSmrg		  eval cmd=\"$cmd1\"
1003035c4bbdfSmrg		  func_len " $cmd"
1003135c4bbdfSmrg		  len=$func_len_result
1003235c4bbdfSmrg		  ;;
1003335c4bbdfSmrg		*)
1003435c4bbdfSmrg		  try_normal_branch=no
1003535c4bbdfSmrg		  ;;
1003635c4bbdfSmrg	      esac
1003735c4bbdfSmrg	      if test yes = "$try_normal_branch" \
1003835c4bbdfSmrg		 && { test "$len" -lt "$max_cmd_len" \
1003935c4bbdfSmrg		      || test "$max_cmd_len" -le -1; }
1004035c4bbdfSmrg	      then
1004135c4bbdfSmrg		func_show_eval "$cmd" 'exit $?'
1004235c4bbdfSmrg		skipped_export=false
1004335c4bbdfSmrg	      elif test -n "$nm_file_list_spec"; then
1004435c4bbdfSmrg		func_basename "$output"
1004535c4bbdfSmrg		output_la=$func_basename_result
1004635c4bbdfSmrg		save_libobjs=$libobjs
1004735c4bbdfSmrg		save_output=$output
1004835c4bbdfSmrg		output=$output_objdir/$output_la.nm
1004935c4bbdfSmrg		func_to_tool_file "$output"
1005035c4bbdfSmrg		libobjs=$nm_file_list_spec$func_to_tool_file_result
1005135c4bbdfSmrg		func_append delfiles " $output"
1005235c4bbdfSmrg		func_verbose "creating $NM input file list: $output"
1005335c4bbdfSmrg		for obj in $save_libobjs; do
1005435c4bbdfSmrg		  func_to_tool_file "$obj"
1005535c4bbdfSmrg		  $ECHO "$func_to_tool_file_result"
1005635c4bbdfSmrg		done > "$output"
1005735c4bbdfSmrg		eval cmd=\"$cmd1\"
100584642e01fSmrg		func_show_eval "$cmd" 'exit $?'
1005935c4bbdfSmrg		output=$save_output
1006035c4bbdfSmrg		libobjs=$save_libobjs
100614642e01fSmrg		skipped_export=false
100624642e01fSmrg	      else
100634642e01fSmrg		# The command line is too long to execute in one step.
100644642e01fSmrg		func_verbose "using reloadable object file for export list..."
100654642e01fSmrg		skipped_export=:
100664642e01fSmrg		# Break out early, otherwise skipped_export may be
100674642e01fSmrg		# set to false by a later but shorter cmd.
100684642e01fSmrg		break
100694642e01fSmrg	      fi
100704642e01fSmrg	    done
1007135c4bbdfSmrg	    IFS=$save_ifs
1007235c4bbdfSmrg	    if test -n "$export_symbols_regex" && test : != "$skipped_export"; then
100734642e01fSmrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
100744642e01fSmrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
100754642e01fSmrg	    fi
100764642e01fSmrg	  fi
1007705b261ecSmrg	fi
1007805b261ecSmrg
100794642e01fSmrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
1008035c4bbdfSmrg	  tmp_export_symbols=$export_symbols
1008135c4bbdfSmrg	  test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
100826747b715Smrg	  $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
100834642e01fSmrg	fi
1008405b261ecSmrg
1008535c4bbdfSmrg	if test : != "$skipped_export" && test -n "$orig_export_symbols"; then
100864642e01fSmrg	  # The given exports_symbols file has to be filtered, so filter it.
1008735c4bbdfSmrg	  func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
100884642e01fSmrg	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
1008935c4bbdfSmrg	  # 's' commands, which not all seds can handle. GNU sed should be fine
100904642e01fSmrg	  # though. Also, the filter scales superlinearly with the number of
100914642e01fSmrg	  # global variables. join(1) would be nice here, but unfortunately
100924642e01fSmrg	  # isn't a blessed tool.
100934642e01fSmrg	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
1009435c4bbdfSmrg	  func_append delfiles " $export_symbols $output_objdir/$libname.filter"
100954642e01fSmrg	  export_symbols=$output_objdir/$libname.def
100964642e01fSmrg	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
100974642e01fSmrg	fi
1009805b261ecSmrg
100994642e01fSmrg	tmp_deplibs=
101004642e01fSmrg	for test_deplib in $deplibs; do
101014642e01fSmrg	  case " $convenience " in
101024642e01fSmrg	  *" $test_deplib "*) ;;
101034642e01fSmrg	  *)
1010435c4bbdfSmrg	    func_append tmp_deplibs " $test_deplib"
101054642e01fSmrg	    ;;
101064642e01fSmrg	  esac
101074642e01fSmrg	done
1010835c4bbdfSmrg	deplibs=$tmp_deplibs
1010905b261ecSmrg
101104642e01fSmrg	if test -n "$convenience"; then
101114642e01fSmrg	  if test -n "$whole_archive_flag_spec" &&
1011235c4bbdfSmrg	    test yes = "$compiler_needs_object" &&
101134642e01fSmrg	    test -z "$libobjs"; then
101144642e01fSmrg	    # extract the archives, so we have objects to list.
101154642e01fSmrg	    # TODO: could optimize this to just extract one archive.
101164642e01fSmrg	    whole_archive_flag_spec=
101174642e01fSmrg	  fi
101184642e01fSmrg	  if test -n "$whole_archive_flag_spec"; then
101194642e01fSmrg	    save_libobjs=$libobjs
101204642e01fSmrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
101214642e01fSmrg	    test "X$libobjs" = "X " && libobjs=
101224642e01fSmrg	  else
1012335c4bbdfSmrg	    gentop=$output_objdir/${outputname}x
1012435c4bbdfSmrg	    func_append generated " $gentop"
1012505b261ecSmrg
101264642e01fSmrg	    func_extract_archives $gentop $convenience
1012735c4bbdfSmrg	    func_append libobjs " $func_extract_archives_result"
101284642e01fSmrg	    test "X$libobjs" = "X " && libobjs=
101294642e01fSmrg	  fi
1013005b261ecSmrg	fi
1013105b261ecSmrg
1013235c4bbdfSmrg	if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then
101334642e01fSmrg	  eval flag=\"$thread_safe_flag_spec\"
1013435c4bbdfSmrg	  func_append linker_flags " $flag"
1013505b261ecSmrg	fi
1013605b261ecSmrg
101374642e01fSmrg	# Make a backup of the uninstalled library when relinking
1013835c4bbdfSmrg	if test relink = "$opt_mode"; then
101394642e01fSmrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
101404642e01fSmrg	fi
1014105b261ecSmrg
101424642e01fSmrg	# Do each of the archive commands.
1014335c4bbdfSmrg	if test yes = "$module" && test -n "$module_cmds"; then
101444642e01fSmrg	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
101454642e01fSmrg	    eval test_cmds=\"$module_expsym_cmds\"
101464642e01fSmrg	    cmds=$module_expsym_cmds
101474642e01fSmrg	  else
101484642e01fSmrg	    eval test_cmds=\"$module_cmds\"
101494642e01fSmrg	    cmds=$module_cmds
101504642e01fSmrg	  fi
1015105b261ecSmrg	else
101524642e01fSmrg	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
101534642e01fSmrg	    eval test_cmds=\"$archive_expsym_cmds\"
101544642e01fSmrg	    cmds=$archive_expsym_cmds
101554642e01fSmrg	  else
101564642e01fSmrg	    eval test_cmds=\"$archive_cmds\"
101574642e01fSmrg	    cmds=$archive_cmds
101584642e01fSmrg	  fi
1015905b261ecSmrg	fi
1016005b261ecSmrg
1016135c4bbdfSmrg	if test : != "$skipped_export" &&
101624642e01fSmrg	   func_len " $test_cmds" &&
101634642e01fSmrg	   len=$func_len_result &&
101644642e01fSmrg	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
101654642e01fSmrg	  :
101664642e01fSmrg	else
101674642e01fSmrg	  # The command line is too long to link in one step, link piecewise
101684642e01fSmrg	  # or, if using GNU ld and skipped_export is not :, use a linker
101694642e01fSmrg	  # script.
1017005b261ecSmrg
101714642e01fSmrg	  # Save the value of $output and $libobjs because we want to
101724642e01fSmrg	  # use them later.  If we have whole_archive_flag_spec, we
101734642e01fSmrg	  # want to use save_libobjs as it was before
101744642e01fSmrg	  # whole_archive_flag_spec was expanded, because we can't
101754642e01fSmrg	  # assume the linker understands whole_archive_flag_spec.
101764642e01fSmrg	  # This may have to be revisited, in case too many
101774642e01fSmrg	  # convenience libraries get linked in and end up exceeding
101784642e01fSmrg	  # the spec.
101794642e01fSmrg	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
101804642e01fSmrg	    save_libobjs=$libobjs
101814642e01fSmrg	  fi
101824642e01fSmrg	  save_output=$output
101836747b715Smrg	  func_basename "$output"
101846747b715Smrg	  output_la=$func_basename_result
1018505b261ecSmrg
101864642e01fSmrg	  # Clear the reloadable object creation command queue and
101874642e01fSmrg	  # initialize k to one.
101884642e01fSmrg	  test_cmds=
101894642e01fSmrg	  concat_cmds=
101904642e01fSmrg	  objlist=
101914642e01fSmrg	  last_robj=
101924642e01fSmrg	  k=1
101934642e01fSmrg
1019454b5899cSmrg	  if test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then
1019535c4bbdfSmrg	    output=$output_objdir/$output_la.lnk
101964642e01fSmrg	    func_verbose "creating linker input file list: $output"
101974642e01fSmrg	    : > $output
101984642e01fSmrg	    set x $save_libobjs
101994642e01fSmrg	    shift
102004642e01fSmrg	    firstobj=
1020135c4bbdfSmrg	    if test yes = "$compiler_needs_object"; then
102024642e01fSmrg	      firstobj="$1 "
102034642e01fSmrg	      shift
102044642e01fSmrg	    fi
102054642e01fSmrg	    for obj
102064642e01fSmrg	    do
1020735c4bbdfSmrg	      func_to_tool_file "$obj"
1020835c4bbdfSmrg	      $ECHO "$func_to_tool_file_result" >> $output
102094642e01fSmrg	    done
1021035c4bbdfSmrg	    func_append delfiles " $output"
1021135c4bbdfSmrg	    func_to_tool_file "$output"
1021235c4bbdfSmrg	    output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
1021354b5899cSmrg	  elif test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then
1021454b5899cSmrg	    output=$output_objdir/$output_la.lnkscript
1021554b5899cSmrg	    func_verbose "creating GNU ld script: $output"
1021654b5899cSmrg	    echo 'INPUT (' > $output
1021754b5899cSmrg	    for obj in $save_libobjs
1021854b5899cSmrg	    do
1021954b5899cSmrg	      func_to_tool_file "$obj"
1022054b5899cSmrg	      $ECHO "$func_to_tool_file_result" >> $output
1022154b5899cSmrg	    done
1022254b5899cSmrg	    echo ')' >> $output
1022354b5899cSmrg	    func_append delfiles " $output"
1022454b5899cSmrg	    func_to_tool_file "$output"
1022554b5899cSmrg	    output=$func_to_tool_file_result
102264642e01fSmrg	  else
102274642e01fSmrg	    if test -n "$save_libobjs"; then
102284642e01fSmrg	      func_verbose "creating reloadable object files..."
1022935c4bbdfSmrg	      output=$output_objdir/$output_la-$k.$objext
102304642e01fSmrg	      eval test_cmds=\"$reload_cmds\"
102314642e01fSmrg	      func_len " $test_cmds"
102324642e01fSmrg	      len0=$func_len_result
102334642e01fSmrg	      len=$len0
102344642e01fSmrg
102354642e01fSmrg	      # Loop over the list of objects to be linked.
102364642e01fSmrg	      for obj in $save_libobjs
102374642e01fSmrg	      do
102384642e01fSmrg		func_len " $obj"
102394642e01fSmrg		func_arith $len + $func_len_result
102404642e01fSmrg		len=$func_arith_result
1024135c4bbdfSmrg		if test -z "$objlist" ||
102424642e01fSmrg		   test "$len" -lt "$max_cmd_len"; then
102434642e01fSmrg		  func_append objlist " $obj"
102444642e01fSmrg		else
102454642e01fSmrg		  # The command $test_cmds is almost too long, add a
102464642e01fSmrg		  # command to the queue.
1024735c4bbdfSmrg		  if test 1 -eq "$k"; then
102484642e01fSmrg		    # The first file doesn't have a previous command to add.
102496747b715Smrg		    reload_objs=$objlist
102506747b715Smrg		    eval concat_cmds=\"$reload_cmds\"
102514642e01fSmrg		  else
102524642e01fSmrg		    # All subsequent reloadable object files will link in
102534642e01fSmrg		    # the last one created.
102546747b715Smrg		    reload_objs="$objlist $last_robj"
102556747b715Smrg		    eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
102564642e01fSmrg		  fi
1025735c4bbdfSmrg		  last_robj=$output_objdir/$output_la-$k.$objext
102584642e01fSmrg		  func_arith $k + 1
102594642e01fSmrg		  k=$func_arith_result
1026035c4bbdfSmrg		  output=$output_objdir/$output_la-$k.$objext
102616747b715Smrg		  objlist=" $obj"
102624642e01fSmrg		  func_len " $last_robj"
102634642e01fSmrg		  func_arith $len0 + $func_len_result
102644642e01fSmrg		  len=$func_arith_result
102654642e01fSmrg		fi
102664642e01fSmrg	      done
102674642e01fSmrg	      # Handle the remaining objects by creating one last
102684642e01fSmrg	      # reloadable object file.  All subsequent reloadable object
102694642e01fSmrg	      # files will link in the last one created.
102704642e01fSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
102716747b715Smrg	      reload_objs="$objlist $last_robj"
1027235c4bbdfSmrg	      eval concat_cmds=\"\$concat_cmds$reload_cmds\"
102734642e01fSmrg	      if test -n "$last_robj"; then
1027435c4bbdfSmrg	        eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
102754642e01fSmrg	      fi
1027635c4bbdfSmrg	      func_append delfiles " $output"
1027705b261ecSmrg
102784642e01fSmrg	    else
102794642e01fSmrg	      output=
102804642e01fSmrg	    fi
1028105b261ecSmrg
1028235c4bbdfSmrg	    ${skipped_export-false} && {
1028335c4bbdfSmrg	      func_verbose "generating symbol list for '$libname.la'"
1028435c4bbdfSmrg	      export_symbols=$output_objdir/$libname.exp
102854642e01fSmrg	      $opt_dry_run || $RM $export_symbols
102864642e01fSmrg	      libobjs=$output
102874642e01fSmrg	      # Append the command to create the export file.
102884642e01fSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
102894642e01fSmrg	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
102904642e01fSmrg	      if test -n "$last_robj"; then
102914642e01fSmrg		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
102924642e01fSmrg	      fi
1029335c4bbdfSmrg	    }
1029405b261ecSmrg
102954642e01fSmrg	    test -n "$save_libobjs" &&
102964642e01fSmrg	      func_verbose "creating a temporary reloadable object file: $output"
1029705b261ecSmrg
102984642e01fSmrg	    # Loop through the commands generated above and execute them.
1029935c4bbdfSmrg	    save_ifs=$IFS; IFS='~'
103004642e01fSmrg	    for cmd in $concat_cmds; do
1030135c4bbdfSmrg	      IFS=$save_ifs
1030235c4bbdfSmrg	      $opt_quiet || {
10303c82838c1Smrg		  func_quote_arg expand,pretty "$cmd"
10304c82838c1Smrg		  eval "func_echo $func_quote_arg_result"
103054642e01fSmrg	      }
103064642e01fSmrg	      $opt_dry_run || eval "$cmd" || {
103074642e01fSmrg		lt_exit=$?
103084642e01fSmrg
103094642e01fSmrg		# Restore the uninstalled library and exit
1031035c4bbdfSmrg		if test relink = "$opt_mode"; then
103114642e01fSmrg		  ( cd "$output_objdir" && \
103124642e01fSmrg		    $RM "${realname}T" && \
103134642e01fSmrg		    $MV "${realname}U" "$realname" )
103144642e01fSmrg		fi
1031505b261ecSmrg
103164642e01fSmrg		exit $lt_exit
103174642e01fSmrg	      }
103184642e01fSmrg	    done
1031935c4bbdfSmrg	    IFS=$save_ifs
1032005b261ecSmrg
103214642e01fSmrg	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
103224642e01fSmrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
103234642e01fSmrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
1032405b261ecSmrg	    fi
1032505b261ecSmrg	  fi
1032605b261ecSmrg
1032735c4bbdfSmrg          ${skipped_export-false} && {
103284642e01fSmrg	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
1032935c4bbdfSmrg	      tmp_export_symbols=$export_symbols
1033035c4bbdfSmrg	      test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
103316747b715Smrg	      $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
103324642e01fSmrg	    fi
1033305b261ecSmrg
103344642e01fSmrg	    if test -n "$orig_export_symbols"; then
103354642e01fSmrg	      # The given exports_symbols file has to be filtered, so filter it.
1033635c4bbdfSmrg	      func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
103374642e01fSmrg	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
1033835c4bbdfSmrg	      # 's' commands, which not all seds can handle. GNU sed should be fine
103394642e01fSmrg	      # though. Also, the filter scales superlinearly with the number of
103404642e01fSmrg	      # global variables. join(1) would be nice here, but unfortunately
103414642e01fSmrg	      # isn't a blessed tool.
103424642e01fSmrg	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
1034335c4bbdfSmrg	      func_append delfiles " $export_symbols $output_objdir/$libname.filter"
103444642e01fSmrg	      export_symbols=$output_objdir/$libname.def
103454642e01fSmrg	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
103464642e01fSmrg	    fi
1034735c4bbdfSmrg	  }
1034805b261ecSmrg
103494642e01fSmrg	  libobjs=$output
103504642e01fSmrg	  # Restore the value of output.
103514642e01fSmrg	  output=$save_output
1035205b261ecSmrg
103534642e01fSmrg	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
103544642e01fSmrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
103554642e01fSmrg	    test "X$libobjs" = "X " && libobjs=
103564642e01fSmrg	  fi
103574642e01fSmrg	  # Expand the library linking commands again to reset the
103584642e01fSmrg	  # value of $libobjs for piecewise linking.
1035905b261ecSmrg
103604642e01fSmrg	  # Do each of the archive commands.
1036135c4bbdfSmrg	  if test yes = "$module" && test -n "$module_cmds"; then
103624642e01fSmrg	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
103634642e01fSmrg	      cmds=$module_expsym_cmds
103644642e01fSmrg	    else
103654642e01fSmrg	      cmds=$module_cmds
1036605b261ecSmrg	    fi
1036705b261ecSmrg	  else
103684642e01fSmrg	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
103694642e01fSmrg	      cmds=$archive_expsym_cmds
103704642e01fSmrg	    else
103714642e01fSmrg	      cmds=$archive_cmds
103724642e01fSmrg	    fi
1037305b261ecSmrg	  fi
103744642e01fSmrg	fi
1037505b261ecSmrg
103764642e01fSmrg	if test -n "$delfiles"; then
103774642e01fSmrg	  # Append the command to remove temporary files to $cmds.
103784642e01fSmrg	  eval cmds=\"\$cmds~\$RM $delfiles\"
103794642e01fSmrg	fi
1038005b261ecSmrg
103814642e01fSmrg	# Add any objects from preloaded convenience libraries
103824642e01fSmrg	if test -n "$dlprefiles"; then
1038335c4bbdfSmrg	  gentop=$output_objdir/${outputname}x
1038435c4bbdfSmrg	  func_append generated " $gentop"
1038505b261ecSmrg
103864642e01fSmrg	  func_extract_archives $gentop $dlprefiles
1038735c4bbdfSmrg	  func_append libobjs " $func_extract_archives_result"
103884642e01fSmrg	  test "X$libobjs" = "X " && libobjs=
103894642e01fSmrg	fi
1039005b261ecSmrg
1039135c4bbdfSmrg	save_ifs=$IFS; IFS='~'
103924642e01fSmrg	for cmd in $cmds; do
1039335c4bbdfSmrg	  IFS=$sp$nl
103944642e01fSmrg	  eval cmd=\"$cmd\"
1039535c4bbdfSmrg	  IFS=$save_ifs
1039635c4bbdfSmrg	  $opt_quiet || {
10397c82838c1Smrg	    func_quote_arg expand,pretty "$cmd"
10398c82838c1Smrg	    eval "func_echo $func_quote_arg_result"
103994642e01fSmrg	  }
104004642e01fSmrg	  $opt_dry_run || eval "$cmd" || {
104014642e01fSmrg	    lt_exit=$?
1040205b261ecSmrg
104034642e01fSmrg	    # Restore the uninstalled library and exit
1040435c4bbdfSmrg	    if test relink = "$opt_mode"; then
104054642e01fSmrg	      ( cd "$output_objdir" && \
104064642e01fSmrg	        $RM "${realname}T" && \
104074642e01fSmrg		$MV "${realname}U" "$realname" )
104084642e01fSmrg	    fi
1040905b261ecSmrg
104104642e01fSmrg	    exit $lt_exit
104114642e01fSmrg	  }
104124642e01fSmrg	done
1041335c4bbdfSmrg	IFS=$save_ifs
1041405b261ecSmrg
104154642e01fSmrg	# Restore the uninstalled library and exit
1041635c4bbdfSmrg	if test relink = "$opt_mode"; then
104174642e01fSmrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
1041805b261ecSmrg
104194642e01fSmrg	  if test -n "$convenience"; then
104204642e01fSmrg	    if test -z "$whole_archive_flag_spec"; then
104214642e01fSmrg	      func_show_eval '${RM}r "$gentop"'
104224642e01fSmrg	    fi
104234642e01fSmrg	  fi
1042405b261ecSmrg
104254642e01fSmrg	  exit $EXIT_SUCCESS
104264642e01fSmrg	fi
104274642e01fSmrg
104284642e01fSmrg	# Create links to the real library.
104294642e01fSmrg	for linkname in $linknames; do
104304642e01fSmrg	  if test "$realname" != "$linkname"; then
104314642e01fSmrg	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
1043205b261ecSmrg	  fi
1043305b261ecSmrg	done
1043405b261ecSmrg
104354642e01fSmrg	# If -module or -export-dynamic was specified, set the dlname.
1043635c4bbdfSmrg	if test yes = "$module" || test yes = "$export_dynamic"; then
104374642e01fSmrg	  # On all known operating systems, these are identical.
1043835c4bbdfSmrg	  dlname=$soname
104394642e01fSmrg	fi
104404642e01fSmrg      fi
1044105b261ecSmrg      ;;
1044205b261ecSmrg
104434642e01fSmrg    obj)
1044435c4bbdfSmrg      if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
1044535c4bbdfSmrg	func_warning "'-dlopen' is ignored for objects"
104464642e01fSmrg      fi
1044705b261ecSmrg
104484642e01fSmrg      case " $deplibs" in
104494642e01fSmrg      *\ -l* | *\ -L*)
1045035c4bbdfSmrg	func_warning "'-l' and '-L' are ignored for objects" ;;
1045105b261ecSmrg      esac
1045205b261ecSmrg
104534642e01fSmrg      test -n "$rpath" && \
1045435c4bbdfSmrg	func_warning "'-rpath' is ignored for objects"
104554642e01fSmrg
104564642e01fSmrg      test -n "$xrpath" && \
1045735c4bbdfSmrg	func_warning "'-R' is ignored for objects"
1045805b261ecSmrg
104594642e01fSmrg      test -n "$vinfo" && \
1046035c4bbdfSmrg	func_warning "'-version-info' is ignored for objects"
1046105b261ecSmrg
104624642e01fSmrg      test -n "$release" && \
1046335c4bbdfSmrg	func_warning "'-release' is ignored for objects"
104644642e01fSmrg
104654642e01fSmrg      case $output in
104664642e01fSmrg      *.lo)
104674642e01fSmrg	test -n "$objs$old_deplibs" && \
1046835c4bbdfSmrg	  func_fatal_error "cannot build library object '$output' from non-libtool objects"
104694642e01fSmrg
104704642e01fSmrg	libobj=$output
104714642e01fSmrg	func_lo2o "$libobj"
104724642e01fSmrg	obj=$func_lo2o_result
1047305b261ecSmrg	;;
1047405b261ecSmrg      *)
104754642e01fSmrg	libobj=
1047635c4bbdfSmrg	obj=$output
1047705b261ecSmrg	;;
1047805b261ecSmrg      esac
1047905b261ecSmrg
104804642e01fSmrg      # Delete the old objects.
104814642e01fSmrg      $opt_dry_run || $RM $obj $libobj
1048205b261ecSmrg
104834642e01fSmrg      # Objects from convenience libraries.  This assumes
104844642e01fSmrg      # single-version convenience libraries.  Whenever we create
104854642e01fSmrg      # different ones for PIC/non-PIC, this we'll have to duplicate
104864642e01fSmrg      # the extraction.
104874642e01fSmrg      reload_conv_objs=
104884642e01fSmrg      gentop=
1048935c4bbdfSmrg      # if reload_cmds runs $LD directly, get rid of -Wl from
1049035c4bbdfSmrg      # whole_archive_flag_spec and hope we can get by with turning comma
1049135c4bbdfSmrg      # into space.
1049235c4bbdfSmrg      case $reload_cmds in
1049335c4bbdfSmrg        *\$LD[\ \$]*) wl= ;;
1049435c4bbdfSmrg      esac
104954642e01fSmrg      if test -n "$convenience"; then
104964642e01fSmrg	if test -n "$whole_archive_flag_spec"; then
104974642e01fSmrg	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
1049835c4bbdfSmrg	  test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
1049935c4bbdfSmrg	  reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags
105004642e01fSmrg	else
1050135c4bbdfSmrg	  gentop=$output_objdir/${obj}x
1050235c4bbdfSmrg	  func_append generated " $gentop"
1050305b261ecSmrg
105044642e01fSmrg	  func_extract_archives $gentop $convenience
105054642e01fSmrg	  reload_conv_objs="$reload_objs $func_extract_archives_result"
105064642e01fSmrg	fi
1050705b261ecSmrg      fi
1050805b261ecSmrg
1050935c4bbdfSmrg      # If we're not building shared, we need to use non_pic_objs
1051035c4bbdfSmrg      test yes = "$build_libtool_libs" || libobjs=$non_pic_objects
1051135c4bbdfSmrg
105124642e01fSmrg      # Create the old-style object.
1051335c4bbdfSmrg      reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs
1051405b261ecSmrg
1051535c4bbdfSmrg      output=$obj
105164642e01fSmrg      func_execute_cmds "$reload_cmds" 'exit $?'
1051705b261ecSmrg
105184642e01fSmrg      # Exit if we aren't doing a library object file.
105194642e01fSmrg      if test -z "$libobj"; then
105204642e01fSmrg	if test -n "$gentop"; then
105214642e01fSmrg	  func_show_eval '${RM}r "$gentop"'
105224642e01fSmrg	fi
105234642e01fSmrg
105244642e01fSmrg	exit $EXIT_SUCCESS
1052505b261ecSmrg      fi
105264642e01fSmrg
1052735c4bbdfSmrg      test yes = "$build_libtool_libs" || {
105284642e01fSmrg	if test -n "$gentop"; then
105294642e01fSmrg	  func_show_eval '${RM}r "$gentop"'
105304642e01fSmrg	fi
105314642e01fSmrg
105324642e01fSmrg	# Create an invalid libtool object if no PIC, so that we don't
105334642e01fSmrg	# accidentally link it into a program.
105344642e01fSmrg	# $show "echo timestamp > $libobj"
105354642e01fSmrg	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
105364642e01fSmrg	exit $EXIT_SUCCESS
1053735c4bbdfSmrg      }
105384642e01fSmrg
1053935c4bbdfSmrg      if test -n "$pic_flag" || test default != "$pic_mode"; then
105404642e01fSmrg	# Only do commands if we really have different PIC objects.
105414642e01fSmrg	reload_objs="$libobjs $reload_conv_objs"
1054235c4bbdfSmrg	output=$libobj
105434642e01fSmrg	func_execute_cmds "$reload_cmds" 'exit $?'
105444642e01fSmrg      fi
105454642e01fSmrg
105464642e01fSmrg      if test -n "$gentop"; then
105474642e01fSmrg	func_show_eval '${RM}r "$gentop"'
105484642e01fSmrg      fi
105494642e01fSmrg
105504642e01fSmrg      exit $EXIT_SUCCESS
1055105b261ecSmrg      ;;
1055205b261ecSmrg
105534642e01fSmrg    prog)
105544642e01fSmrg      case $host in
105554642e01fSmrg	*cygwin*) func_stripname '' '.exe' "$output"
105564642e01fSmrg	          output=$func_stripname_result.exe;;
105574642e01fSmrg      esac
105584642e01fSmrg      test -n "$vinfo" && \
1055935c4bbdfSmrg	func_warning "'-version-info' is ignored for programs"
1056005b261ecSmrg
105614642e01fSmrg      test -n "$release" && \
1056235c4bbdfSmrg	func_warning "'-release' is ignored for programs"
1056305b261ecSmrg
1056435c4bbdfSmrg      $preload \
1056535c4bbdfSmrg	&& test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \
1056635c4bbdfSmrg	&& func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support."
105674642e01fSmrg
105684642e01fSmrg      case $host in
105694642e01fSmrg      *-*-rhapsody* | *-*-darwin1.[012])
105704642e01fSmrg	# On Rhapsody replace the C library is the System framework
105716747b715Smrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
105726747b715Smrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
1057305b261ecSmrg	;;
105744642e01fSmrg      esac
1057505b261ecSmrg
105764642e01fSmrg      case $host in
105774642e01fSmrg      *-*-darwin*)
105784642e01fSmrg	# Don't allow lazy linking, it breaks C++ global constructors
105794642e01fSmrg	# But is supposedly fixed on 10.4 or later (yay!).
1058035c4bbdfSmrg	if test CXX = "$tagname"; then
105814642e01fSmrg	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
105824642e01fSmrg	    10.[0123])
1058335c4bbdfSmrg	      func_append compile_command " $wl-bind_at_load"
1058435c4bbdfSmrg	      func_append finalize_command " $wl-bind_at_load"
105854642e01fSmrg	    ;;
105864642e01fSmrg	  esac
1058705b261ecSmrg	fi
105884642e01fSmrg	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
105896747b715Smrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
105906747b715Smrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
105914642e01fSmrg	;;
105924642e01fSmrg      esac
1059305b261ecSmrg
1059405b261ecSmrg
105954642e01fSmrg      # move library search paths that coincide with paths to not yet
105964642e01fSmrg      # installed libraries to the beginning of the library search list
105974642e01fSmrg      new_libs=
105984642e01fSmrg      for path in $notinst_path; do
105994642e01fSmrg	case " $new_libs " in
106004642e01fSmrg	*" -L$path/$objdir "*) ;;
106014642e01fSmrg	*)
106024642e01fSmrg	  case " $compile_deplibs " in
106034642e01fSmrg	  *" -L$path/$objdir "*)
1060435c4bbdfSmrg	    func_append new_libs " -L$path/$objdir" ;;
1060505b261ecSmrg	  esac
106064642e01fSmrg	  ;;
106074642e01fSmrg	esac
106084642e01fSmrg      done
106094642e01fSmrg      for deplib in $compile_deplibs; do
106104642e01fSmrg	case $deplib in
106114642e01fSmrg	-L*)
106124642e01fSmrg	  case " $new_libs " in
106134642e01fSmrg	  *" $deplib "*) ;;
1061435c4bbdfSmrg	  *) func_append new_libs " $deplib" ;;
1061505b261ecSmrg	  esac
106164642e01fSmrg	  ;;
1061735c4bbdfSmrg	*) func_append new_libs " $deplib" ;;
106184642e01fSmrg	esac
106194642e01fSmrg      done
1062035c4bbdfSmrg      compile_deplibs=$new_libs
1062105b261ecSmrg
1062205b261ecSmrg
1062335c4bbdfSmrg      func_append compile_command " $compile_deplibs"
1062435c4bbdfSmrg      func_append finalize_command " $finalize_deplibs"
1062505b261ecSmrg
106264642e01fSmrg      if test -n "$rpath$xrpath"; then
106274642e01fSmrg	# If the user specified any rpath flags, then add them.
106284642e01fSmrg	for libdir in $rpath $xrpath; do
106294642e01fSmrg	  # This is the magic to use -rpath.
106304642e01fSmrg	  case "$finalize_rpath " in
106314642e01fSmrg	  *" $libdir "*) ;;
1063235c4bbdfSmrg	  *) func_append finalize_rpath " $libdir" ;;
106334642e01fSmrg	  esac
106344642e01fSmrg	done
106354642e01fSmrg      fi
1063605b261ecSmrg
106374642e01fSmrg      # Now hardcode the library paths
106384642e01fSmrg      rpath=
106394642e01fSmrg      hardcode_libdirs=
106404642e01fSmrg      for libdir in $compile_rpath $finalize_rpath; do
106414642e01fSmrg	if test -n "$hardcode_libdir_flag_spec"; then
106424642e01fSmrg	  if test -n "$hardcode_libdir_separator"; then
106434642e01fSmrg	    if test -z "$hardcode_libdirs"; then
1064435c4bbdfSmrg	      hardcode_libdirs=$libdir
106454642e01fSmrg	    else
106464642e01fSmrg	      # Just accumulate the unique libdirs.
106474642e01fSmrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
106484642e01fSmrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
106494642e01fSmrg		;;
106504642e01fSmrg	      *)
1065135c4bbdfSmrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
106524642e01fSmrg		;;
106534642e01fSmrg	      esac
106544642e01fSmrg	    fi
1065505b261ecSmrg	  else
106564642e01fSmrg	    eval flag=\"$hardcode_libdir_flag_spec\"
1065735c4bbdfSmrg	    func_append rpath " $flag"
1065805b261ecSmrg	  fi
106594642e01fSmrg	elif test -n "$runpath_var"; then
106604642e01fSmrg	  case "$perm_rpath " in
106614642e01fSmrg	  *" $libdir "*) ;;
1066235c4bbdfSmrg	  *) func_append perm_rpath " $libdir" ;;
106634642e01fSmrg	  esac
106644642e01fSmrg	fi
106654642e01fSmrg	case $host in
1066654b5899cSmrg	*-*-cygwin* | *-*-mingw* | *-*-windows* | *-*-pw32* | *-*-os2* | *-cegcc*)
1066735c4bbdfSmrg	  testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'`
106684642e01fSmrg	  case :$dllsearchpath: in
106694642e01fSmrg	  *":$libdir:"*) ;;
106704642e01fSmrg	  ::) dllsearchpath=$libdir;;
1067135c4bbdfSmrg	  *) func_append dllsearchpath ":$libdir";;
106724642e01fSmrg	  esac
106734642e01fSmrg	  case :$dllsearchpath: in
106744642e01fSmrg	  *":$testbindir:"*) ;;
106754642e01fSmrg	  ::) dllsearchpath=$testbindir;;
1067635c4bbdfSmrg	  *) func_append dllsearchpath ":$testbindir";;
106774642e01fSmrg	  esac
106784642e01fSmrg	  ;;
106794642e01fSmrg	esac
106804642e01fSmrg      done
106814642e01fSmrg      # Substitute the hardcoded libdirs into the rpath.
106824642e01fSmrg      if test -n "$hardcode_libdir_separator" &&
106834642e01fSmrg	 test -n "$hardcode_libdirs"; then
1068435c4bbdfSmrg	libdir=$hardcode_libdirs
106854642e01fSmrg	eval rpath=\" $hardcode_libdir_flag_spec\"
106864642e01fSmrg      fi
1068735c4bbdfSmrg      compile_rpath=$rpath
1068805b261ecSmrg
106894642e01fSmrg      rpath=
106904642e01fSmrg      hardcode_libdirs=
106914642e01fSmrg      for libdir in $finalize_rpath; do
106924642e01fSmrg	if test -n "$hardcode_libdir_flag_spec"; then
106934642e01fSmrg	  if test -n "$hardcode_libdir_separator"; then
106944642e01fSmrg	    if test -z "$hardcode_libdirs"; then
1069535c4bbdfSmrg	      hardcode_libdirs=$libdir
106964642e01fSmrg	    else
106974642e01fSmrg	      # Just accumulate the unique libdirs.
106984642e01fSmrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
106994642e01fSmrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
107004642e01fSmrg		;;
107014642e01fSmrg	      *)
1070235c4bbdfSmrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
107034642e01fSmrg		;;
107044642e01fSmrg	      esac
107054642e01fSmrg	    fi
1070605b261ecSmrg	  else
107074642e01fSmrg	    eval flag=\"$hardcode_libdir_flag_spec\"
1070835c4bbdfSmrg	    func_append rpath " $flag"
1070905b261ecSmrg	  fi
107104642e01fSmrg	elif test -n "$runpath_var"; then
107114642e01fSmrg	  case "$finalize_perm_rpath " in
107124642e01fSmrg	  *" $libdir "*) ;;
1071335c4bbdfSmrg	  *) func_append finalize_perm_rpath " $libdir" ;;
107144642e01fSmrg	  esac
1071505b261ecSmrg	fi
107164642e01fSmrg      done
107174642e01fSmrg      # Substitute the hardcoded libdirs into the rpath.
107184642e01fSmrg      if test -n "$hardcode_libdir_separator" &&
107194642e01fSmrg	 test -n "$hardcode_libdirs"; then
1072035c4bbdfSmrg	libdir=$hardcode_libdirs
107214642e01fSmrg	eval rpath=\" $hardcode_libdir_flag_spec\"
107224642e01fSmrg      fi
1072335c4bbdfSmrg      finalize_rpath=$rpath
1072405b261ecSmrg
1072535c4bbdfSmrg      if test -n "$libobjs" && test yes = "$build_old_libs"; then
107264642e01fSmrg	# Transform all the library objects into standard objects.
107276747b715Smrg	compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
107286747b715Smrg	finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
107294642e01fSmrg      fi
1073005b261ecSmrg
1073135c4bbdfSmrg      func_generate_dlsyms "$outputname" "@PROGRAM@" false
1073205b261ecSmrg
107334642e01fSmrg      # template prelinking step
107344642e01fSmrg      if test -n "$prelink_cmds"; then
107354642e01fSmrg	func_execute_cmds "$prelink_cmds" 'exit $?'
107364642e01fSmrg      fi
1073705b261ecSmrg
1073835c4bbdfSmrg      wrappers_required=:
107394642e01fSmrg      case $host in
107406747b715Smrg      *cegcc* | *mingw32ce*)
107416747b715Smrg        # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
1074235c4bbdfSmrg        wrappers_required=false
107436747b715Smrg        ;;
1074454b5899cSmrg      *cygwin* | *mingw* | *windows* )
1074535c4bbdfSmrg        test yes = "$build_libtool_libs" || wrappers_required=false
107464642e01fSmrg        ;;
107474642e01fSmrg      *)
1074835c4bbdfSmrg        if test no = "$need_relink" || test yes != "$build_libtool_libs"; then
1074935c4bbdfSmrg          wrappers_required=false
107504642e01fSmrg        fi
107514642e01fSmrg        ;;
107524642e01fSmrg      esac
1075335c4bbdfSmrg      $wrappers_required || {
107544642e01fSmrg	# Replace the output file specification.
107556747b715Smrg	compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
1075635c4bbdfSmrg	link_command=$compile_command$compile_rpath
1075705b261ecSmrg
107584642e01fSmrg	# We have no uninstalled library dependencies, so finalize right now.
107594642e01fSmrg	exit_status=0
107604642e01fSmrg	func_show_eval "$link_command" 'exit_status=$?'
1076105b261ecSmrg
1076235c4bbdfSmrg	if test -n "$postlink_cmds"; then
1076335c4bbdfSmrg	  func_to_tool_file "$output"
1076435c4bbdfSmrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
1076535c4bbdfSmrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
1076635c4bbdfSmrg	fi
1076735c4bbdfSmrg
107684642e01fSmrg	# Delete the generated files.
1076935c4bbdfSmrg	if test -f "$output_objdir/${outputname}S.$objext"; then
1077035c4bbdfSmrg	  func_show_eval '$RM "$output_objdir/${outputname}S.$objext"'
1077105b261ecSmrg	fi
1077205b261ecSmrg
107734642e01fSmrg	exit $exit_status
1077435c4bbdfSmrg      }
1077505b261ecSmrg
107764642e01fSmrg      if test -n "$compile_shlibpath$finalize_shlibpath"; then
107774642e01fSmrg	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
107784642e01fSmrg      fi
107794642e01fSmrg      if test -n "$finalize_shlibpath"; then
107804642e01fSmrg	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
107814642e01fSmrg      fi
1078205b261ecSmrg
107834642e01fSmrg      compile_var=
107844642e01fSmrg      finalize_var=
107854642e01fSmrg      if test -n "$runpath_var"; then
107864642e01fSmrg	if test -n "$perm_rpath"; then
107874642e01fSmrg	  # We should set the runpath_var.
107884642e01fSmrg	  rpath=
107894642e01fSmrg	  for dir in $perm_rpath; do
1079035c4bbdfSmrg	    func_append rpath "$dir:"
107914642e01fSmrg	  done
107924642e01fSmrg	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
1079305b261ecSmrg	fi
107944642e01fSmrg	if test -n "$finalize_perm_rpath"; then
107954642e01fSmrg	  # We should set the runpath_var.
107964642e01fSmrg	  rpath=
107974642e01fSmrg	  for dir in $finalize_perm_rpath; do
1079835c4bbdfSmrg	    func_append rpath "$dir:"
107994642e01fSmrg	  done
108004642e01fSmrg	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
1080105b261ecSmrg	fi
108024642e01fSmrg      fi
1080305b261ecSmrg
1080435c4bbdfSmrg      if test yes = "$no_install"; then
108054642e01fSmrg	# We don't need to create a wrapper script.
1080635c4bbdfSmrg	link_command=$compile_var$compile_command$compile_rpath
108074642e01fSmrg	# Replace the output file specification.
108086747b715Smrg	link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
108094642e01fSmrg	# Delete the old output file.
108104642e01fSmrg	$opt_dry_run || $RM $output
108114642e01fSmrg	# Link the executable and exit
108124642e01fSmrg	func_show_eval "$link_command" 'exit $?'
1081335c4bbdfSmrg
1081435c4bbdfSmrg	if test -n "$postlink_cmds"; then
1081535c4bbdfSmrg	  func_to_tool_file "$output"
1081635c4bbdfSmrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
1081735c4bbdfSmrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
1081835c4bbdfSmrg	fi
1081935c4bbdfSmrg
1082005b261ecSmrg	exit $EXIT_SUCCESS
108214642e01fSmrg      fi
1082205b261ecSmrg
1082335c4bbdfSmrg      case $hardcode_action,$fast_install in
1082435c4bbdfSmrg        relink,*)
1082535c4bbdfSmrg	  # Fast installation is not supported
1082635c4bbdfSmrg	  link_command=$compile_var$compile_command$compile_rpath
1082735c4bbdfSmrg	  relink_command=$finalize_var$finalize_command$finalize_rpath
108284642e01fSmrg
1082935c4bbdfSmrg	  func_warning "this platform does not like uninstalled shared libraries"
1083035c4bbdfSmrg	  func_warning "'$output' will be relinked during installation"
1083135c4bbdfSmrg	  ;;
1083235c4bbdfSmrg        *,yes)
1083335c4bbdfSmrg	  link_command=$finalize_var$compile_command$finalize_rpath
1083435c4bbdfSmrg	  relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
1083535c4bbdfSmrg          ;;
1083635c4bbdfSmrg	*,no)
1083735c4bbdfSmrg	  link_command=$compile_var$compile_command$compile_rpath
1083835c4bbdfSmrg	  relink_command=$finalize_var$finalize_command$finalize_rpath
1083935c4bbdfSmrg          ;;
1084035c4bbdfSmrg	*,needless)
1084135c4bbdfSmrg	  link_command=$finalize_var$compile_command$finalize_rpath
1084235c4bbdfSmrg	  relink_command=
1084335c4bbdfSmrg          ;;
1084435c4bbdfSmrg      esac
1084505b261ecSmrg
108464642e01fSmrg      # Replace the output file specification.
108476747b715Smrg      link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
1084805b261ecSmrg
108494642e01fSmrg      # Delete the old output files.
108504642e01fSmrg      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
1085105b261ecSmrg
108524642e01fSmrg      func_show_eval "$link_command" 'exit $?'
1085305b261ecSmrg
1085435c4bbdfSmrg      if test -n "$postlink_cmds"; then
1085535c4bbdfSmrg	func_to_tool_file "$output_objdir/$outputname"
1085635c4bbdfSmrg	postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
1085735c4bbdfSmrg	func_execute_cmds "$postlink_cmds" 'exit $?'
1085835c4bbdfSmrg      fi
1085935c4bbdfSmrg
108604642e01fSmrg      # Now create the wrapper script.
108614642e01fSmrg      func_verbose "creating $output"
1086205b261ecSmrg
108634642e01fSmrg      # Quote the relink command for shipping.
108644642e01fSmrg      if test -n "$relink_command"; then
108654642e01fSmrg	# Preserve any variables that may affect compiler behavior
108664642e01fSmrg	for var in $variables_saved_for_relink; do
108674642e01fSmrg	  if eval test -z \"\${$var+set}\"; then
108684642e01fSmrg	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
108694642e01fSmrg	  elif eval var_value=\$$var; test -z "$var_value"; then
108704642e01fSmrg	    relink_command="$var=; export $var; $relink_command"
1087105b261ecSmrg	  else
10872c82838c1Smrg	    func_quote_arg pretty "$var_value"
10873c82838c1Smrg	    relink_command="$var=$func_quote_arg_result; export $var; $relink_command"
1087405b261ecSmrg	  fi
108754642e01fSmrg	done
10876c82838c1Smrg	func_quote eval cd "`pwd`"
10877c82838c1Smrg	func_quote_arg pretty,unquoted "($func_quote_result; $relink_command)"
10878c82838c1Smrg	relink_command=$func_quote_arg_unquoted_result
108794642e01fSmrg      fi
108804642e01fSmrg
108814642e01fSmrg      # Only actually do things if not in dry run mode.
108824642e01fSmrg      $opt_dry_run || {
108834642e01fSmrg	# win32 will think the script is a binary if it has
108844642e01fSmrg	# a .exe suffix, so we strip it off here.
108854642e01fSmrg	case $output in
108864642e01fSmrg	  *.exe) func_stripname '' '.exe' "$output"
108874642e01fSmrg	         output=$func_stripname_result ;;
108884642e01fSmrg	esac
108894642e01fSmrg	# test for cygwin because mv fails w/o .exe extensions
108904642e01fSmrg	case $host in
108914642e01fSmrg	  *cygwin*)
108924642e01fSmrg	    exeext=.exe
108934642e01fSmrg	    func_stripname '' '.exe' "$outputname"
108944642e01fSmrg	    outputname=$func_stripname_result ;;
108954642e01fSmrg	  *) exeext= ;;
1089605b261ecSmrg	esac
108974642e01fSmrg	case $host in
1089854b5899cSmrg	  *cygwin* | *mingw* | windows* )
108994642e01fSmrg	    func_dirname_and_basename "$output" "" "."
109004642e01fSmrg	    output_name=$func_basename_result
109014642e01fSmrg	    output_path=$func_dirname_result
1090235c4bbdfSmrg	    cwrappersource=$output_path/$objdir/lt-$output_name.c
1090335c4bbdfSmrg	    cwrapper=$output_path/$output_name.exe
109044642e01fSmrg	    $RM $cwrappersource $cwrapper
109054642e01fSmrg	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
109064642e01fSmrg
109074642e01fSmrg	    func_emit_cwrapperexe_src > $cwrappersource
109084642e01fSmrg
109094642e01fSmrg	    # The wrapper executable is built using the $host compiler,
109104642e01fSmrg	    # because it contains $host paths and files. If cross-
109114642e01fSmrg	    # compiling, it, like the target executable, must be
109124642e01fSmrg	    # executed on the $host or under an emulation environment.
109134642e01fSmrg	    $opt_dry_run || {
109144642e01fSmrg	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
109154642e01fSmrg	      $STRIP $cwrapper
109164642e01fSmrg	    }
1091705b261ecSmrg
109184642e01fSmrg	    # Now, create the wrapper script for func_source use:
109194642e01fSmrg	    func_ltwrapper_scriptname $cwrapper
109204642e01fSmrg	    $RM $func_ltwrapper_scriptname_result
109214642e01fSmrg	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
109224642e01fSmrg	    $opt_dry_run || {
109234642e01fSmrg	      # note: this script will not be executed, so do not chmod.
1092435c4bbdfSmrg	      if test "x$build" = "x$host"; then
109254642e01fSmrg		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
109264642e01fSmrg	      else
109274642e01fSmrg		func_emit_wrapper no > $func_ltwrapper_scriptname_result
109284642e01fSmrg	      fi
109294642e01fSmrg	    }
109304642e01fSmrg	  ;;
109314642e01fSmrg	  * )
109324642e01fSmrg	    $RM $output
109334642e01fSmrg	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
1093405b261ecSmrg
109354642e01fSmrg	    func_emit_wrapper no > $output
109364642e01fSmrg	    chmod +x $output
109374642e01fSmrg	  ;;
109384642e01fSmrg	esac
109394642e01fSmrg      }
109404642e01fSmrg      exit $EXIT_SUCCESS
109414642e01fSmrg      ;;
109424642e01fSmrg    esac
1094305b261ecSmrg
109444642e01fSmrg    # See if we need to build an old-fashioned archive.
109454642e01fSmrg    for oldlib in $oldlibs; do
1094605b261ecSmrg
1094735c4bbdfSmrg      case $build_libtool_libs in
1094835c4bbdfSmrg        convenience)
1094935c4bbdfSmrg	  oldobjs="$libobjs_save $symfileobj"
1095035c4bbdfSmrg	  addlibs=$convenience
109514642e01fSmrg	  build_libtool_libs=no
1095235c4bbdfSmrg	  ;;
1095335c4bbdfSmrg	module)
1095435c4bbdfSmrg	  oldobjs=$libobjs_save
1095535c4bbdfSmrg	  addlibs=$old_convenience
1095635c4bbdfSmrg	  build_libtool_libs=no
1095735c4bbdfSmrg          ;;
1095835c4bbdfSmrg	*)
109594642e01fSmrg	  oldobjs="$old_deplibs $non_pic_objects"
1096035c4bbdfSmrg	  $preload && test -f "$symfileobj" \
1096135c4bbdfSmrg	    && func_append oldobjs " $symfileobj"
1096235c4bbdfSmrg	  addlibs=$old_convenience
1096335c4bbdfSmrg	  ;;
1096435c4bbdfSmrg      esac
1096505b261ecSmrg
109664642e01fSmrg      if test -n "$addlibs"; then
1096735c4bbdfSmrg	gentop=$output_objdir/${outputname}x
1096835c4bbdfSmrg	func_append generated " $gentop"
1096905b261ecSmrg
109704642e01fSmrg	func_extract_archives $gentop $addlibs
1097135c4bbdfSmrg	func_append oldobjs " $func_extract_archives_result"
109724642e01fSmrg      fi
1097305b261ecSmrg
109744642e01fSmrg      # Do each command in the archive commands.
1097535c4bbdfSmrg      if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then
109764642e01fSmrg	cmds=$old_archive_from_new_cmds
109774642e01fSmrg      else
1097805b261ecSmrg
109794642e01fSmrg	# Add any objects from preloaded convenience libraries
109804642e01fSmrg	if test -n "$dlprefiles"; then
1098135c4bbdfSmrg	  gentop=$output_objdir/${outputname}x
1098235c4bbdfSmrg	  func_append generated " $gentop"
1098305b261ecSmrg
109844642e01fSmrg	  func_extract_archives $gentop $dlprefiles
1098535c4bbdfSmrg	  func_append oldobjs " $func_extract_archives_result"
109864642e01fSmrg	fi
1098705b261ecSmrg
109884642e01fSmrg	# POSIX demands no paths to be encoded in archives.  We have
109894642e01fSmrg	# to avoid creating archives with duplicate basenames if we
109904642e01fSmrg	# might have to extract them afterwards, e.g., when creating a
109914642e01fSmrg	# static archive out of a convenience library, or when linking
109924642e01fSmrg	# the entirety of a libtool archive into another (currently
109934642e01fSmrg	# not supported by libtool).
109944642e01fSmrg	if (for obj in $oldobjs
109954642e01fSmrg	    do
109964642e01fSmrg	      func_basename "$obj"
109974642e01fSmrg	      $ECHO "$func_basename_result"
109984642e01fSmrg	    done | sort | sort -uc >/dev/null 2>&1); then
109994642e01fSmrg	  :
110004642e01fSmrg	else
110016747b715Smrg	  echo "copying selected object files to avoid basename conflicts..."
1100235c4bbdfSmrg	  gentop=$output_objdir/${outputname}x
1100335c4bbdfSmrg	  func_append generated " $gentop"
110044642e01fSmrg	  func_mkdir_p "$gentop"
110054642e01fSmrg	  save_oldobjs=$oldobjs
110064642e01fSmrg	  oldobjs=
110074642e01fSmrg	  counter=1
110084642e01fSmrg	  for obj in $save_oldobjs
110094642e01fSmrg	  do
110104642e01fSmrg	    func_basename "$obj"
1101135c4bbdfSmrg	    objbase=$func_basename_result
110124642e01fSmrg	    case " $oldobjs " in
110134642e01fSmrg	    " ") oldobjs=$obj ;;
110144642e01fSmrg	    *[\ /]"$objbase "*)
110154642e01fSmrg	      while :; do
110164642e01fSmrg		# Make sure we don't pick an alternate name that also
110174642e01fSmrg		# overlaps.
110184642e01fSmrg		newobj=lt$counter-$objbase
110194642e01fSmrg		func_arith $counter + 1
110204642e01fSmrg		counter=$func_arith_result
110214642e01fSmrg		case " $oldobjs " in
110224642e01fSmrg		*[\ /]"$newobj "*) ;;
110234642e01fSmrg		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
110244642e01fSmrg		esac
110254642e01fSmrg	      done
110264642e01fSmrg	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
1102735c4bbdfSmrg	      func_append oldobjs " $gentop/$newobj"
110284642e01fSmrg	      ;;
1102935c4bbdfSmrg	    *) func_append oldobjs " $obj" ;;
110304642e01fSmrg	    esac
1103105b261ecSmrg	  done
1103205b261ecSmrg	fi
1103335c4bbdfSmrg	func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
1103435c4bbdfSmrg	tool_oldlib=$func_to_tool_file_result
110354642e01fSmrg	eval cmds=\"$old_archive_cmds\"
1103605b261ecSmrg
110374642e01fSmrg	func_len " $cmds"
110384642e01fSmrg	len=$func_len_result
110394642e01fSmrg	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
110404642e01fSmrg	  cmds=$old_archive_cmds
1104135c4bbdfSmrg	elif test -n "$archiver_list_spec"; then
1104235c4bbdfSmrg	  func_verbose "using command file archive linking..."
1104335c4bbdfSmrg	  for obj in $oldobjs
1104435c4bbdfSmrg	  do
1104535c4bbdfSmrg	    func_to_tool_file "$obj"
1104635c4bbdfSmrg	    $ECHO "$func_to_tool_file_result"
1104735c4bbdfSmrg	  done > $output_objdir/$libname.libcmd
1104835c4bbdfSmrg	  func_to_tool_file "$output_objdir/$libname.libcmd"
1104935c4bbdfSmrg	  oldobjs=" $archiver_list_spec$func_to_tool_file_result"
1105035c4bbdfSmrg	  cmds=$old_archive_cmds
110514642e01fSmrg	else
110524642e01fSmrg	  # the command line is too long to link in one step, link in parts
110534642e01fSmrg	  func_verbose "using piecewise archive linking..."
110544642e01fSmrg	  save_RANLIB=$RANLIB
110554642e01fSmrg	  RANLIB=:
110564642e01fSmrg	  objlist=
110574642e01fSmrg	  concat_cmds=
110584642e01fSmrg	  save_oldobjs=$oldobjs
110594642e01fSmrg	  oldobjs=
110604642e01fSmrg	  # Is there a better way of finding the last object in the list?
110614642e01fSmrg	  for obj in $save_oldobjs
110624642e01fSmrg	  do
110634642e01fSmrg	    last_oldobj=$obj
110644642e01fSmrg	  done
110654642e01fSmrg	  eval test_cmds=\"$old_archive_cmds\"
110664642e01fSmrg	  func_len " $test_cmds"
110674642e01fSmrg	  len0=$func_len_result
110684642e01fSmrg	  len=$len0
110694642e01fSmrg	  for obj in $save_oldobjs
110704642e01fSmrg	  do
110714642e01fSmrg	    func_len " $obj"
110724642e01fSmrg	    func_arith $len + $func_len_result
110734642e01fSmrg	    len=$func_arith_result
110744642e01fSmrg	    func_append objlist " $obj"
110754642e01fSmrg	    if test "$len" -lt "$max_cmd_len"; then
110764642e01fSmrg	      :
110774642e01fSmrg	    else
110784642e01fSmrg	      # the above command should be used before it gets too long
110794642e01fSmrg	      oldobjs=$objlist
1108035c4bbdfSmrg	      if test "$obj" = "$last_oldobj"; then
110814642e01fSmrg		RANLIB=$save_RANLIB
110824642e01fSmrg	      fi
110834642e01fSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
1108435c4bbdfSmrg	      eval concat_cmds=\"\$concat_cmds$old_archive_cmds\"
110854642e01fSmrg	      objlist=
110864642e01fSmrg	      len=$len0
110874642e01fSmrg	    fi
110884642e01fSmrg	  done
110894642e01fSmrg	  RANLIB=$save_RANLIB
110904642e01fSmrg	  oldobjs=$objlist
1109135c4bbdfSmrg	  if test -z "$oldobjs"; then
110924642e01fSmrg	    eval cmds=\"\$concat_cmds\"
110934642e01fSmrg	  else
110944642e01fSmrg	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
110954642e01fSmrg	  fi
110964642e01fSmrg	fi
110974642e01fSmrg      fi
110984642e01fSmrg      func_execute_cmds "$cmds" 'exit $?'
1109905b261ecSmrg    done
1110005b261ecSmrg
111014642e01fSmrg    test -n "$generated" && \
111024642e01fSmrg      func_show_eval "${RM}r$generated"
1110305b261ecSmrg
111044642e01fSmrg    # Now create the libtool archive.
111054642e01fSmrg    case $output in
111064642e01fSmrg    *.la)
111074642e01fSmrg      old_library=
1110835c4bbdfSmrg      test yes = "$build_old_libs" && old_library=$libname.$libext
111094642e01fSmrg      func_verbose "creating $output"
1111005b261ecSmrg
111114642e01fSmrg      # Preserve any variables that may affect compiler behavior
111124642e01fSmrg      for var in $variables_saved_for_relink; do
111134642e01fSmrg	if eval test -z \"\${$var+set}\"; then
111144642e01fSmrg	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
111154642e01fSmrg	elif eval var_value=\$$var; test -z "$var_value"; then
111164642e01fSmrg	  relink_command="$var=; export $var; $relink_command"
1111705b261ecSmrg	else
11118c82838c1Smrg	  func_quote_arg pretty,unquoted "$var_value"
11119c82838c1Smrg	  relink_command="$var=$func_quote_arg_unquoted_result; export $var; $relink_command"
1112005b261ecSmrg	fi
111214642e01fSmrg      done
111224642e01fSmrg      # Quote the link command for shipping.
11123c82838c1Smrg      func_quote eval cd "`pwd`"
11124c82838c1Smrg      relink_command="($func_quote_result; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
11125c82838c1Smrg      func_quote_arg pretty,unquoted "$relink_command"
11126c82838c1Smrg      relink_command=$func_quote_arg_unquoted_result
1112735c4bbdfSmrg      if test yes = "$hardcode_automatic"; then
111284642e01fSmrg	relink_command=
111294642e01fSmrg      fi
1113005b261ecSmrg
111314642e01fSmrg      # Only create the output if not a dry run.
111324642e01fSmrg      $opt_dry_run || {
111334642e01fSmrg	for installed in no yes; do
1113435c4bbdfSmrg	  if test yes = "$installed"; then
111354642e01fSmrg	    if test -z "$install_libdir"; then
111364642e01fSmrg	      break
111374642e01fSmrg	    fi
1113835c4bbdfSmrg	    output=$output_objdir/${outputname}i
111394642e01fSmrg	    # Replace all uninstalled libtool libraries with the installed ones
111404642e01fSmrg	    newdependency_libs=
111414642e01fSmrg	    for deplib in $dependency_libs; do
111424642e01fSmrg	      case $deplib in
111434642e01fSmrg	      *.la)
111444642e01fSmrg		func_basename "$deplib"
1114535c4bbdfSmrg		name=$func_basename_result
1114635c4bbdfSmrg		func_resolve_sysroot "$deplib"
1114735c4bbdfSmrg		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
111484642e01fSmrg		test -z "$libdir" && \
1114935c4bbdfSmrg		  func_fatal_error "'$deplib' is not a valid libtool archive"
1115035c4bbdfSmrg		func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
1115135c4bbdfSmrg		;;
1115235c4bbdfSmrg	      -L*)
1115335c4bbdfSmrg		func_stripname -L '' "$deplib"
1115435c4bbdfSmrg		func_replace_sysroot "$func_stripname_result"
1115535c4bbdfSmrg		func_append newdependency_libs " -L$func_replace_sysroot_result"
111566747b715Smrg		;;
1115735c4bbdfSmrg	      -R*)
1115835c4bbdfSmrg		func_stripname -R '' "$deplib"
1115935c4bbdfSmrg		func_replace_sysroot "$func_stripname_result"
1116035c4bbdfSmrg		func_append newdependency_libs " -R$func_replace_sysroot_result"
1116135c4bbdfSmrg		;;
1116235c4bbdfSmrg	      *) func_append newdependency_libs " $deplib" ;;
111634642e01fSmrg	      esac
111644642e01fSmrg	    done
1116535c4bbdfSmrg	    dependency_libs=$newdependency_libs
111664642e01fSmrg	    newdlfiles=
111674642e01fSmrg
111684642e01fSmrg	    for lib in $dlfiles; do
111694642e01fSmrg	      case $lib in
111704642e01fSmrg	      *.la)
111714642e01fSmrg	        func_basename "$lib"
1117235c4bbdfSmrg		name=$func_basename_result
1117335c4bbdfSmrg		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
111744642e01fSmrg		test -z "$libdir" && \
1117535c4bbdfSmrg		  func_fatal_error "'$lib' is not a valid libtool archive"
1117635c4bbdfSmrg		func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
111774642e01fSmrg		;;
1117835c4bbdfSmrg	      *) func_append newdlfiles " $lib" ;;
111794642e01fSmrg	      esac
111804642e01fSmrg	    done
1118135c4bbdfSmrg	    dlfiles=$newdlfiles
111824642e01fSmrg	    newdlprefiles=
111834642e01fSmrg	    for lib in $dlprefiles; do
111844642e01fSmrg	      case $lib in
111854642e01fSmrg	      *.la)
111864642e01fSmrg		# Only pass preopened files to the pseudo-archive (for
111874642e01fSmrg		# eventual linking with the app. that links it) if we
111884642e01fSmrg		# didn't already link the preopened objects directly into
111894642e01fSmrg		# the library:
111904642e01fSmrg		func_basename "$lib"
1119135c4bbdfSmrg		name=$func_basename_result
1119235c4bbdfSmrg		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
111934642e01fSmrg		test -z "$libdir" && \
1119435c4bbdfSmrg		  func_fatal_error "'$lib' is not a valid libtool archive"
1119535c4bbdfSmrg		func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
111964642e01fSmrg		;;
111974642e01fSmrg	      esac
111984642e01fSmrg	    done
1119935c4bbdfSmrg	    dlprefiles=$newdlprefiles
112004642e01fSmrg	  else
112014642e01fSmrg	    newdlfiles=
112024642e01fSmrg	    for lib in $dlfiles; do
112034642e01fSmrg	      case $lib in
1120435c4bbdfSmrg		[\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
112054642e01fSmrg		*) abs=`pwd`"/$lib" ;;
112064642e01fSmrg	      esac
1120735c4bbdfSmrg	      func_append newdlfiles " $abs"
112084642e01fSmrg	    done
1120935c4bbdfSmrg	    dlfiles=$newdlfiles
112104642e01fSmrg	    newdlprefiles=
112114642e01fSmrg	    for lib in $dlprefiles; do
112124642e01fSmrg	      case $lib in
1121335c4bbdfSmrg		[\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
112144642e01fSmrg		*) abs=`pwd`"/$lib" ;;
112154642e01fSmrg	      esac
1121635c4bbdfSmrg	      func_append newdlprefiles " $abs"
112174642e01fSmrg	    done
1121835c4bbdfSmrg	    dlprefiles=$newdlprefiles
112194642e01fSmrg	  fi
112204642e01fSmrg	  $RM $output
112214642e01fSmrg	  # place dlname in correct position for cygwin
112226747b715Smrg	  # In fact, it would be nice if we could use this code for all target
112236747b715Smrg	  # systems that can't hard-code library paths into their executables
112246747b715Smrg	  # and that have no shared library path variable independent of PATH,
112256747b715Smrg	  # but it turns out we can't easily determine that from inspecting
112266747b715Smrg	  # libtool variables, so we have to hard-code the OSs to which it
112276747b715Smrg	  # applies here; at the moment, that means platforms that use the PE
112286747b715Smrg	  # object format with DLL files.  See the long comment at the top of
112296747b715Smrg	  # tests/bindir.at for full details.
112304642e01fSmrg	  tdlname=$dlname
112314642e01fSmrg	  case $host,$output,$installed,$module,$dlname in
1123254b5899cSmrg	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *windows*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
112336747b715Smrg	      # If a -bindir argument was supplied, place the dll there.
1123435c4bbdfSmrg	      if test -n "$bindir"; then
112356747b715Smrg		func_relative_path "$install_libdir" "$bindir"
1123635c4bbdfSmrg		tdlname=$func_relative_path_result/$dlname
112376747b715Smrg	      else
112386747b715Smrg		# Otherwise fall back on heuristic.
112396747b715Smrg		tdlname=../bin/$dlname
112406747b715Smrg	      fi
112416747b715Smrg	      ;;
112424642e01fSmrg	  esac
112434642e01fSmrg	  $ECHO > $output "\
112444642e01fSmrg# $outputname - a libtool library file
1124535c4bbdfSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
112464642e01fSmrg#
112474642e01fSmrg# Please DO NOT delete this file!
112484642e01fSmrg# It is necessary for linking the library.
1124905b261ecSmrg
112504642e01fSmrg# The name that we can dlopen(3).
112514642e01fSmrgdlname='$tdlname'
1125205b261ecSmrg
112534642e01fSmrg# Names of this library.
112544642e01fSmrglibrary_names='$library_names'
1125505b261ecSmrg
112564642e01fSmrg# The name of the static archive.
112574642e01fSmrgold_library='$old_library'
1125805b261ecSmrg
1125935c4bbdfSmrg# Linker flags that cannot go in dependency_libs.
112604642e01fSmrginherited_linker_flags='$new_inherited_linker_flags'
1126105b261ecSmrg
112624642e01fSmrg# Libraries that this one depends upon.
112634642e01fSmrgdependency_libs='$dependency_libs'
1126405b261ecSmrg
112654642e01fSmrg# Names of additional weak libraries provided by this library
112664642e01fSmrgweak_library_names='$weak_libs'
1126705b261ecSmrg
112684642e01fSmrg# Version information for $libname.
112694642e01fSmrgcurrent=$current
112704642e01fSmrgage=$age
112714642e01fSmrgrevision=$revision
1127205b261ecSmrg
112734642e01fSmrg# Is this an already installed library?
112744642e01fSmrginstalled=$installed
1127505b261ecSmrg
112764642e01fSmrg# Should we warn about portability when linking against -modules?
112774642e01fSmrgshouldnotlink=$module
1127805b261ecSmrg
112794642e01fSmrg# Files to dlopen/dlpreopen
112804642e01fSmrgdlopen='$dlfiles'
112814642e01fSmrgdlpreopen='$dlprefiles'
1128205b261ecSmrg
112834642e01fSmrg# Directory that this library needs to be installed in:
112844642e01fSmrglibdir='$install_libdir'"
1128535c4bbdfSmrg	  if test no,yes = "$installed,$need_relink"; then
112864642e01fSmrg	    $ECHO >> $output "\
112874642e01fSmrgrelink_command=\"$relink_command\""
112884642e01fSmrg	  fi
112894642e01fSmrg	done
112904642e01fSmrg      }
1129105b261ecSmrg
112924642e01fSmrg      # Do a symbolic link so that the libtool archive can be found in
112934642e01fSmrg      # LD_LIBRARY_PATH before the program is installed.
112944642e01fSmrg      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
112954642e01fSmrg      ;;
112964642e01fSmrg    esac
112974642e01fSmrg    exit $EXIT_SUCCESS
112984642e01fSmrg}
1129905b261ecSmrg
1130035c4bbdfSmrgif test link = "$opt_mode" || test relink = "$opt_mode"; then
1130135c4bbdfSmrg  func_mode_link ${1+"$@"}
1130235c4bbdfSmrgfi
1130305b261ecSmrg
1130405b261ecSmrg
113054642e01fSmrg# func_mode_uninstall arg...
113064642e01fSmrgfunc_mode_uninstall ()
113074642e01fSmrg{
1130835c4bbdfSmrg    $debug_cmd
1130935c4bbdfSmrg
1131035c4bbdfSmrg    RM=$nonopt
1131105b261ecSmrg    files=
1131235c4bbdfSmrg    rmforce=false
1131305b261ecSmrg    exit_status=0
1131405b261ecSmrg
1131505b261ecSmrg    # This variable tells wrapper scripts just to set variables rather
1131605b261ecSmrg    # than running their programs.
1131735c4bbdfSmrg    libtool_install_magic=$magic
1131805b261ecSmrg
1131905b261ecSmrg    for arg
1132005b261ecSmrg    do
1132105b261ecSmrg      case $arg in
1132235c4bbdfSmrg      -f) func_append RM " $arg"; rmforce=: ;;
1132335c4bbdfSmrg      -*) func_append RM " $arg" ;;
1132435c4bbdfSmrg      *) func_append files " $arg" ;;
1132505b261ecSmrg      esac
1132605b261ecSmrg    done
1132705b261ecSmrg
113284642e01fSmrg    test -z "$RM" && \
113294642e01fSmrg      func_fatal_help "you must specify an RM program"
1133005b261ecSmrg
1133105b261ecSmrg    rmdirs=
1133205b261ecSmrg
1133305b261ecSmrg    for file in $files; do
113344642e01fSmrg      func_dirname "$file" "" "."
1133535c4bbdfSmrg      dir=$func_dirname_result
1133635c4bbdfSmrg      if test . = "$dir"; then
1133735c4bbdfSmrg	odir=$objdir
1133805b261ecSmrg      else
1133935c4bbdfSmrg	odir=$dir/$objdir
1134005b261ecSmrg      fi
113414642e01fSmrg      func_basename "$file"
1134235c4bbdfSmrg      name=$func_basename_result
1134335c4bbdfSmrg      test uninstall = "$opt_mode" && odir=$dir
1134405b261ecSmrg
1134535c4bbdfSmrg      # Remember odir for removal later, being careful to avoid duplicates
1134635c4bbdfSmrg      if test clean = "$opt_mode"; then
1134705b261ecSmrg	case " $rmdirs " in
1134835c4bbdfSmrg	  *" $odir "*) ;;
1134935c4bbdfSmrg	  *) func_append rmdirs " $odir" ;;
1135005b261ecSmrg	esac
1135105b261ecSmrg      fi
1135205b261ecSmrg
1135305b261ecSmrg      # Don't error if the file doesn't exist and rm -f was used.
113544642e01fSmrg      if { test -L "$file"; } >/dev/null 2>&1 ||
113554642e01fSmrg	 { test -h "$file"; } >/dev/null 2>&1 ||
113564642e01fSmrg	 test -f "$file"; then
1135705b261ecSmrg	:
1135805b261ecSmrg      elif test -d "$file"; then
1135905b261ecSmrg	exit_status=1
1136005b261ecSmrg	continue
1136135c4bbdfSmrg      elif $rmforce; then
1136205b261ecSmrg	continue
1136305b261ecSmrg      fi
1136405b261ecSmrg
1136535c4bbdfSmrg      rmfiles=$file
1136605b261ecSmrg
1136705b261ecSmrg      case $name in
1136805b261ecSmrg      *.la)
1136905b261ecSmrg	# Possibly a libtool archive, so verify it.
113704642e01fSmrg	if func_lalib_p "$file"; then
113714642e01fSmrg	  func_source $dir/$name
1137205b261ecSmrg
1137305b261ecSmrg	  # Delete the libtool libraries and symlinks.
1137405b261ecSmrg	  for n in $library_names; do
1137535c4bbdfSmrg	    func_append rmfiles " $odir/$n"
1137605b261ecSmrg	  done
1137735c4bbdfSmrg	  test -n "$old_library" && func_append rmfiles " $odir/$old_library"
1137805b261ecSmrg
1137935c4bbdfSmrg	  case $opt_mode in
1138005b261ecSmrg	  clean)
1138135c4bbdfSmrg	    case " $library_names " in
1138205b261ecSmrg	    *" $dlname "*) ;;
1138335c4bbdfSmrg	    *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
1138405b261ecSmrg	    esac
1138535c4bbdfSmrg	    test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
1138605b261ecSmrg	    ;;
1138705b261ecSmrg	  uninstall)
1138805b261ecSmrg	    if test -n "$library_names"; then
1138905b261ecSmrg	      # Do each command in the postuninstall commands.
1139035c4bbdfSmrg	      func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1'
1139105b261ecSmrg	    fi
1139205b261ecSmrg
1139305b261ecSmrg	    if test -n "$old_library"; then
1139405b261ecSmrg	      # Do each command in the old_postuninstall commands.
1139535c4bbdfSmrg	      func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1'
1139605b261ecSmrg	    fi
1139705b261ecSmrg	    # FIXME: should reinstall the best remaining shared library.
1139805b261ecSmrg	    ;;
1139905b261ecSmrg	  esac
1140005b261ecSmrg	fi
1140105b261ecSmrg	;;
1140205b261ecSmrg
1140305b261ecSmrg      *.lo)
1140405b261ecSmrg	# Possibly a libtool object, so verify it.
114054642e01fSmrg	if func_lalib_p "$file"; then
1140605b261ecSmrg
1140705b261ecSmrg	  # Read the .lo file
114084642e01fSmrg	  func_source $dir/$name
1140905b261ecSmrg
1141005b261ecSmrg	  # Add PIC object to the list of files to remove.
1141135c4bbdfSmrg	  if test -n "$pic_object" && test none != "$pic_object"; then
1141235c4bbdfSmrg	    func_append rmfiles " $dir/$pic_object"
1141305b261ecSmrg	  fi
1141405b261ecSmrg
1141505b261ecSmrg	  # Add non-PIC object to the list of files to remove.
1141635c4bbdfSmrg	  if test -n "$non_pic_object" && test none != "$non_pic_object"; then
1141735c4bbdfSmrg	    func_append rmfiles " $dir/$non_pic_object"
1141805b261ecSmrg	  fi
1141905b261ecSmrg	fi
1142005b261ecSmrg	;;
1142105b261ecSmrg
1142205b261ecSmrg      *)
1142335c4bbdfSmrg	if test clean = "$opt_mode"; then
1142405b261ecSmrg	  noexename=$name
1142505b261ecSmrg	  case $file in
1142605b261ecSmrg	  *.exe)
114274642e01fSmrg	    func_stripname '' '.exe' "$file"
114284642e01fSmrg	    file=$func_stripname_result
114294642e01fSmrg	    func_stripname '' '.exe' "$name"
114304642e01fSmrg	    noexename=$func_stripname_result
1143105b261ecSmrg	    # $file with .exe has already been added to rmfiles,
1143205b261ecSmrg	    # add $file without .exe
1143335c4bbdfSmrg	    func_append rmfiles " $file"
1143405b261ecSmrg	    ;;
1143505b261ecSmrg	  esac
1143605b261ecSmrg	  # Do a test to see if this is a libtool program.
114374642e01fSmrg	  if func_ltwrapper_p "$file"; then
114384642e01fSmrg	    if func_ltwrapper_executable_p "$file"; then
114394642e01fSmrg	      func_ltwrapper_scriptname "$file"
114404642e01fSmrg	      relink_command=
114414642e01fSmrg	      func_source $func_ltwrapper_scriptname_result
1144235c4bbdfSmrg	      func_append rmfiles " $func_ltwrapper_scriptname_result"
114434642e01fSmrg	    else
114444642e01fSmrg	      relink_command=
114454642e01fSmrg	      func_source $dir/$noexename
114464642e01fSmrg	    fi
1144705b261ecSmrg
1144805b261ecSmrg	    # note $name still contains .exe if it was in $file originally
1144905b261ecSmrg	    # as does the version of $file that was added into $rmfiles
1145035c4bbdfSmrg	    func_append rmfiles " $odir/$name $odir/${name}S.$objext"
1145135c4bbdfSmrg	    if test yes = "$fast_install" && test -n "$relink_command"; then
1145235c4bbdfSmrg	      func_append rmfiles " $odir/lt-$name"
1145305b261ecSmrg	    fi
1145435c4bbdfSmrg	    if test "X$noexename" != "X$name"; then
1145535c4bbdfSmrg	      func_append rmfiles " $odir/lt-$noexename.c"
1145605b261ecSmrg	    fi
1145705b261ecSmrg	  fi
1145805b261ecSmrg	fi
1145905b261ecSmrg	;;
1146005b261ecSmrg      esac
114614642e01fSmrg      func_show_eval "$RM $rmfiles" 'exit_status=1'
1146205b261ecSmrg    done
1146305b261ecSmrg
1146435c4bbdfSmrg    # Try to remove the $objdir's in the directories where we deleted files
1146505b261ecSmrg    for dir in $rmdirs; do
1146605b261ecSmrg      if test -d "$dir"; then
114674642e01fSmrg	func_show_eval "rmdir $dir >/dev/null 2>&1"
1146805b261ecSmrg      fi
1146905b261ecSmrg    done
1147005b261ecSmrg
1147105b261ecSmrg    exit $exit_status
114724642e01fSmrg}
1147305b261ecSmrg
1147435c4bbdfSmrgif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then
1147535c4bbdfSmrg  func_mode_uninstall ${1+"$@"}
1147635c4bbdfSmrgfi
1147705b261ecSmrg
1147835c4bbdfSmrgtest -z "$opt_mode" && {
1147935c4bbdfSmrg  help=$generic_help
114804642e01fSmrg  func_fatal_help "you must specify a MODE"
114814642e01fSmrg}
114824642e01fSmrg
114834642e01fSmrgtest -z "$exec_cmd" && \
1148435c4bbdfSmrg  func_fatal_help "invalid operation mode '$opt_mode'"
1148505b261ecSmrg
1148605b261ecSmrgif test -n "$exec_cmd"; then
114874642e01fSmrg  eval exec "$exec_cmd"
1148805b261ecSmrg  exit $EXIT_FAILURE
1148905b261ecSmrgfi
1149005b261ecSmrg
114914642e01fSmrgexit $exit_status
1149205b261ecSmrg
1149305b261ecSmrg
1149405b261ecSmrg# The TAGs below are defined such that we never get into a situation
1149535c4bbdfSmrg# where we disable both kinds of libraries.  Given conflicting
1149605b261ecSmrg# choices, we go for a static library, that is the most portable,
1149705b261ecSmrg# since we can't tell whether shared libraries were disabled because
1149805b261ecSmrg# the user asked for that or because the platform doesn't support
1149905b261ecSmrg# them.  This is particularly important on AIX, because we don't
1150005b261ecSmrg# support having both static and shared libraries enabled at the same
1150105b261ecSmrg# time on that platform, so we default to a shared-only configuration.
1150205b261ecSmrg# If a disable-shared tag is given, we'll fallback to a static-only
1150305b261ecSmrg# configuration.  But we'll never go from static-only to shared-only.
1150405b261ecSmrg
1150505b261ecSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
115064642e01fSmrgbuild_libtool_libs=no
115074642e01fSmrgbuild_old_libs=yes
1150805b261ecSmrg# ### END LIBTOOL TAG CONFIG: disable-shared
1150905b261ecSmrg
1151005b261ecSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static
115114642e01fSmrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
1151205b261ecSmrg# ### END LIBTOOL TAG CONFIG: disable-static
1151305b261ecSmrg
1151405b261ecSmrg# Local Variables:
1151505b261ecSmrg# mode:shell-script
1151605b261ecSmrg# sh-indentation:2
1151705b261ecSmrg# End:
11518