ltmain.sh revision ed6184df
135c4bbdfSmrg#! /bin/sh
235c4bbdfSmrg## DO NOT EDIT - This file generated from ./build-aux/ltmain.in
335c4bbdfSmrg##               by inline-source v2014-01-03.01
44642e01fSmrg
535c4bbdfSmrg# libtool (GNU libtool) 2.4.6
635c4bbdfSmrg# Provide generalized library-building support services.
74642e01fSmrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
84642e01fSmrg
935c4bbdfSmrg# Copyright (C) 1996-2015 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
34ed6184dfSmrgVERSION="2.4.6 Debian-2.4.6-14"
3535c4bbdfSmrgpackage_revision=2.4.6
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.
67ed6184dfSmrgscriptversion=2015-01-20.17; # UTC
6835c4bbdfSmrg
6935c4bbdfSmrg# General shell script boiler plate, and helper functions.
7035c4bbdfSmrg# Written by Gary V. Vaughan, 2004
7135c4bbdfSmrg
7235c4bbdfSmrg# Copyright (C) 2004-2015 Free Software Foundation, Inc.
7335c4bbdfSmrg# This is free software; see the source for copying conditions.  There is NO
7435c4bbdfSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7535c4bbdfSmrg
7635c4bbdfSmrg# This program is free software; you can redistribute it and/or modify
7735c4bbdfSmrg# it under the terms of the GNU General Public License as published by
7835c4bbdfSmrg# the Free Software Foundation; either version 3 of the License, or
7935c4bbdfSmrg# (at your option) any later version.
8035c4bbdfSmrg
8135c4bbdfSmrg# As a special exception to the GNU General Public License, if you distribute
8235c4bbdfSmrg# this file as part of a program or library that is built using GNU Libtool,
8335c4bbdfSmrg# you may include this file under the same distribution terms that you use
8435c4bbdfSmrg# for the rest of that program.
8535c4bbdfSmrg
8635c4bbdfSmrg# This program is distributed in the hope that it will be useful,
8735c4bbdfSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
8835c4bbdfSmrg# MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU
8935c4bbdfSmrg# General Public License for more details.
9035c4bbdfSmrg
9135c4bbdfSmrg# You should have received a copy of the GNU General Public License
9235c4bbdfSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>.
9335c4bbdfSmrg
9435c4bbdfSmrg# Please report bugs or propose patches to gary@gnu.org.
9535c4bbdfSmrg
9635c4bbdfSmrg
9735c4bbdfSmrg## ------ ##
9835c4bbdfSmrg## Usage. ##
9935c4bbdfSmrg## ------ ##
10035c4bbdfSmrg
10135c4bbdfSmrg# Evaluate this file near the top of your script to gain access to
10235c4bbdfSmrg# the functions and variables defined here:
10335c4bbdfSmrg#
10435c4bbdfSmrg#   . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh
10535c4bbdfSmrg#
10635c4bbdfSmrg# If you need to override any of the default environment variable
10735c4bbdfSmrg# settings, do that before evaluating this file.
10835c4bbdfSmrg
10935c4bbdfSmrg
11035c4bbdfSmrg## -------------------- ##
11135c4bbdfSmrg## Shell normalisation. ##
11235c4bbdfSmrg## -------------------- ##
11335c4bbdfSmrg
11435c4bbdfSmrg# Some shells need a little help to be as Bourne compatible as possible.
11535c4bbdfSmrg# Before doing anything else, make sure all that help has been provided!
11635c4bbdfSmrg
11735c4bbdfSmrgDUALCASE=1; export DUALCASE # for MKS sh
11835c4bbdfSmrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
11905b261ecSmrg  emulate sh
12005b261ecSmrg  NULLCMD=:
12135c4bbdfSmrg  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
12205b261ecSmrg  # is contrary to our usage.  Disable this feature.
12305b261ecSmrg  alias -g '${1+"$@"}'='"$@"'
12405b261ecSmrg  setopt NO_GLOB_SUBST
12505b261ecSmrgelse
12635c4bbdfSmrg  case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac
12705b261ecSmrgfi
1286747b715Smrg
12935c4bbdfSmrg# NLS nuisances: We save the old values in case they are required later.
13035c4bbdfSmrg_G_user_locale=
13135c4bbdfSmrg_G_safe_locale=
13235c4bbdfSmrgfor _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
13305b261ecSmrgdo
13435c4bbdfSmrg  eval "if test set = \"\${$_G_var+set}\"; then
13535c4bbdfSmrg          save_$_G_var=\$$_G_var
13635c4bbdfSmrg          $_G_var=C
13735c4bbdfSmrg	  export $_G_var
13835c4bbdfSmrg	  _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\"
13935c4bbdfSmrg	  _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\"
14005b261ecSmrg	fi"
14105b261ecSmrgdone
14205b261ecSmrg
14335c4bbdfSmrg# CDPATH.
14435c4bbdfSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
1454642e01fSmrg
14635c4bbdfSmrg# Make sure IFS has a sensible default
14735c4bbdfSmrgsp=' '
14835c4bbdfSmrgnl='
14935c4bbdfSmrg'
15035c4bbdfSmrgIFS="$sp	$nl"
15135c4bbdfSmrg
15235c4bbdfSmrg# There are apparently some retarded systems that use ';' as a PATH separator!
15335c4bbdfSmrgif test "${PATH_SEPARATOR+set}" != set; then
15435c4bbdfSmrg  PATH_SEPARATOR=:
15535c4bbdfSmrg  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
15635c4bbdfSmrg    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
15735c4bbdfSmrg      PATH_SEPARATOR=';'
15835c4bbdfSmrg  }
15935c4bbdfSmrgfi
1604642e01fSmrg
1614642e01fSmrg
1624642e01fSmrg
16335c4bbdfSmrg## ------------------------- ##
16435c4bbdfSmrg## Locate command utilities. ##
16535c4bbdfSmrg## ------------------------- ##
16635c4bbdfSmrg
16735c4bbdfSmrg
16835c4bbdfSmrg# func_executable_p FILE
16935c4bbdfSmrg# ----------------------
17035c4bbdfSmrg# Check that FILE is an executable regular file.
17135c4bbdfSmrgfunc_executable_p ()
17235c4bbdfSmrg{
17335c4bbdfSmrg    test -f "$1" && test -x "$1"
17435c4bbdfSmrg}
17535c4bbdfSmrg
17635c4bbdfSmrg
17735c4bbdfSmrg# func_path_progs PROGS_LIST CHECK_FUNC [PATH]
17835c4bbdfSmrg# --------------------------------------------
17935c4bbdfSmrg# Search for either a program that responds to --version with output
18035c4bbdfSmrg# containing "GNU", or else returned by CHECK_FUNC otherwise, by
18135c4bbdfSmrg# trying all the directories in PATH with each of the elements of
18235c4bbdfSmrg# PROGS_LIST.
18335c4bbdfSmrg#
18435c4bbdfSmrg# CHECK_FUNC should accept the path to a candidate program, and
18535c4bbdfSmrg# set $func_check_prog_result if it truncates its output less than
18635c4bbdfSmrg# $_G_path_prog_max characters.
18735c4bbdfSmrgfunc_path_progs ()
18835c4bbdfSmrg{
18935c4bbdfSmrg    _G_progs_list=$1
19035c4bbdfSmrg    _G_check_func=$2
19135c4bbdfSmrg    _G_PATH=${3-"$PATH"}
19235c4bbdfSmrg
19335c4bbdfSmrg    _G_path_prog_max=0
19435c4bbdfSmrg    _G_path_prog_found=false
19535c4bbdfSmrg    _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:}
19635c4bbdfSmrg    for _G_dir in $_G_PATH; do
19735c4bbdfSmrg      IFS=$_G_save_IFS
19835c4bbdfSmrg      test -z "$_G_dir" && _G_dir=.
19935c4bbdfSmrg      for _G_prog_name in $_G_progs_list; do
20035c4bbdfSmrg        for _exeext in '' .EXE; do
20135c4bbdfSmrg          _G_path_prog=$_G_dir/$_G_prog_name$_exeext
20235c4bbdfSmrg          func_executable_p "$_G_path_prog" || continue
20335c4bbdfSmrg          case `"$_G_path_prog" --version 2>&1` in
20435c4bbdfSmrg            *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;;
20535c4bbdfSmrg            *)     $_G_check_func $_G_path_prog
20635c4bbdfSmrg		   func_path_progs_result=$func_check_prog_result
20735c4bbdfSmrg		   ;;
20835c4bbdfSmrg          esac
20935c4bbdfSmrg          $_G_path_prog_found && break 3
21035c4bbdfSmrg        done
21135c4bbdfSmrg      done
21235c4bbdfSmrg    done
21335c4bbdfSmrg    IFS=$_G_save_IFS
21435c4bbdfSmrg    test -z "$func_path_progs_result" && {
21535c4bbdfSmrg      echo "no acceptable sed could be found in \$PATH" >&2
21635c4bbdfSmrg      exit 1
21735c4bbdfSmrg    }
21835c4bbdfSmrg}
21935c4bbdfSmrg
22035c4bbdfSmrg
22135c4bbdfSmrg# We want to be able to use the functions in this file before configure
22235c4bbdfSmrg# has figured out where the best binaries are kept, which means we have
22335c4bbdfSmrg# to search for them ourselves - except when the results are already set
22435c4bbdfSmrg# where we skip the searches.
22535c4bbdfSmrg
22635c4bbdfSmrg# Unless the user overrides by setting SED, search the path for either GNU
22735c4bbdfSmrg# sed, or the sed that truncates its output the least.
22835c4bbdfSmrgtest -z "$SED" && {
22935c4bbdfSmrg  _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
23035c4bbdfSmrg  for _G_i in 1 2 3 4 5 6 7; do
23135c4bbdfSmrg    _G_sed_script=$_G_sed_script$nl$_G_sed_script
23235c4bbdfSmrg  done
23335c4bbdfSmrg  echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed
23435c4bbdfSmrg  _G_sed_script=
23535c4bbdfSmrg
23635c4bbdfSmrg  func_check_prog_sed ()
23735c4bbdfSmrg  {
23835c4bbdfSmrg    _G_path_prog=$1
23935c4bbdfSmrg
24035c4bbdfSmrg    _G_count=0
24135c4bbdfSmrg    printf 0123456789 >conftest.in
24235c4bbdfSmrg    while :
24335c4bbdfSmrg    do
24435c4bbdfSmrg      cat conftest.in conftest.in >conftest.tmp
24535c4bbdfSmrg      mv conftest.tmp conftest.in
24635c4bbdfSmrg      cp conftest.in conftest.nl
24735c4bbdfSmrg      echo '' >> conftest.nl
24835c4bbdfSmrg      "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break
24935c4bbdfSmrg      diff conftest.out conftest.nl >/dev/null 2>&1 || break
25035c4bbdfSmrg      _G_count=`expr $_G_count + 1`
25135c4bbdfSmrg      if test "$_G_count" -gt "$_G_path_prog_max"; then
25235c4bbdfSmrg        # Best one so far, save it but keep looking for a better one
25335c4bbdfSmrg        func_check_prog_result=$_G_path_prog
25435c4bbdfSmrg        _G_path_prog_max=$_G_count
25535c4bbdfSmrg      fi
25635c4bbdfSmrg      # 10*(2^10) chars as input seems more than enough
25735c4bbdfSmrg      test 10 -lt "$_G_count" && break
25835c4bbdfSmrg    done
25935c4bbdfSmrg    rm -f conftest.in conftest.tmp conftest.nl conftest.out
26035c4bbdfSmrg  }
26135c4bbdfSmrg
26235c4bbdfSmrg  func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin
26335c4bbdfSmrg  rm -f conftest.sed
26435c4bbdfSmrg  SED=$func_path_progs_result
26535c4bbdfSmrg}
26635c4bbdfSmrg
26735c4bbdfSmrg
26835c4bbdfSmrg# Unless the user overrides by setting GREP, search the path for either GNU
26935c4bbdfSmrg# grep, or the grep that truncates its output the least.
27035c4bbdfSmrgtest -z "$GREP" && {
27135c4bbdfSmrg  func_check_prog_grep ()
27235c4bbdfSmrg  {
27335c4bbdfSmrg    _G_path_prog=$1
27435c4bbdfSmrg
27535c4bbdfSmrg    _G_count=0
27635c4bbdfSmrg    _G_path_prog_max=0
27735c4bbdfSmrg    printf 0123456789 >conftest.in
27835c4bbdfSmrg    while :
27935c4bbdfSmrg    do
28035c4bbdfSmrg      cat conftest.in conftest.in >conftest.tmp
28135c4bbdfSmrg      mv conftest.tmp conftest.in
28235c4bbdfSmrg      cp conftest.in conftest.nl
28335c4bbdfSmrg      echo 'GREP' >> conftest.nl
28435c4bbdfSmrg      "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break
28535c4bbdfSmrg      diff conftest.out conftest.nl >/dev/null 2>&1 || break
28635c4bbdfSmrg      _G_count=`expr $_G_count + 1`
28735c4bbdfSmrg      if test "$_G_count" -gt "$_G_path_prog_max"; then
28835c4bbdfSmrg        # Best one so far, save it but keep looking for a better one
28935c4bbdfSmrg        func_check_prog_result=$_G_path_prog
29035c4bbdfSmrg        _G_path_prog_max=$_G_count
29135c4bbdfSmrg      fi
29235c4bbdfSmrg      # 10*(2^10) chars as input seems more than enough
29335c4bbdfSmrg      test 10 -lt "$_G_count" && break
29435c4bbdfSmrg    done
29535c4bbdfSmrg    rm -f conftest.in conftest.tmp conftest.nl conftest.out
29635c4bbdfSmrg  }
29735c4bbdfSmrg
29835c4bbdfSmrg  func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin
29935c4bbdfSmrg  GREP=$func_path_progs_result
30035c4bbdfSmrg}
30135c4bbdfSmrg
30235c4bbdfSmrg
30335c4bbdfSmrg## ------------------------------- ##
30435c4bbdfSmrg## User overridable command paths. ##
30535c4bbdfSmrg## ------------------------------- ##
30635c4bbdfSmrg
30735c4bbdfSmrg# All uppercase variable names are used for environment variables.  These
30835c4bbdfSmrg# variables can be overridden by the user before calling a script that
30935c4bbdfSmrg# uses them if a suitable command of that name is not already available
31035c4bbdfSmrg# in the command search PATH.
3114642e01fSmrg
3124642e01fSmrg: ${CP="cp -f"}
31335c4bbdfSmrg: ${ECHO="printf %s\n"}
31435c4bbdfSmrg: ${EGREP="$GREP -E"}
31535c4bbdfSmrg: ${FGREP="$GREP -F"}
3164642e01fSmrg: ${LN_S="ln -s"}
3174642e01fSmrg: ${MAKE="make"}
3184642e01fSmrg: ${MKDIR="mkdir"}
3194642e01fSmrg: ${MV="mv -f"}
3204642e01fSmrg: ${RM="rm -f"}
3214642e01fSmrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
3224642e01fSmrg
3234642e01fSmrg
32435c4bbdfSmrg## -------------------- ##
32535c4bbdfSmrg## Useful sed snippets. ##
32635c4bbdfSmrg## -------------------- ##
32705b261ecSmrg
32835c4bbdfSmrgsed_dirname='s|/[^/]*$||'
32935c4bbdfSmrgsed_basename='s|^.*/||'
33005b261ecSmrg
33135c4bbdfSmrg# Sed substitution that helps us do robust quoting.  It backslashifies
33235c4bbdfSmrg# metacharacters that are still active within double-quoted strings.
33335c4bbdfSmrgsed_quote_subst='s|\([`"$\\]\)|\\\1|g'
3344642e01fSmrg
33535c4bbdfSmrg# Same as above, but do not quote variable references.
33635c4bbdfSmrgsed_double_quote_subst='s/\(["`\\]\)/\\\1/g'
33735c4bbdfSmrg
33835c4bbdfSmrg# Sed substitution that turns a string into a regex matching for the
33935c4bbdfSmrg# string literally.
34035c4bbdfSmrgsed_make_literal_regex='s|[].[^$\\*\/]|\\&|g'
34135c4bbdfSmrg
34235c4bbdfSmrg# Sed substitution that converts a w32 file name or path
34335c4bbdfSmrg# that contains forward slashes, into one that contains
34435c4bbdfSmrg# (escaped) backslashes.  A very naive implementation.
34535c4bbdfSmrgsed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
34635c4bbdfSmrg
34735c4bbdfSmrg# Re-'\' parameter expansions in output of sed_double_quote_subst that
34835c4bbdfSmrg# were '\'-ed in input to the same.  If an odd number of '\' preceded a
34935c4bbdfSmrg# '$' in input to sed_double_quote_subst, that '$' was protected from
35035c4bbdfSmrg# expansion.  Since each input '\' is now two '\'s, look for any number
35135c4bbdfSmrg# of runs of four '\'s followed by two '\'s and then a '$'.  '\' that '$'.
35235c4bbdfSmrg_G_bs='\\'
35335c4bbdfSmrg_G_bs2='\\\\'
35435c4bbdfSmrg_G_bs4='\\\\\\\\'
35535c4bbdfSmrg_G_dollar='\$'
35635c4bbdfSmrgsed_double_backslash="\
35735c4bbdfSmrg  s/$_G_bs4/&\\
35835c4bbdfSmrg/g
35935c4bbdfSmrg  s/^$_G_bs2$_G_dollar/$_G_bs&/
36035c4bbdfSmrg  s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g
36135c4bbdfSmrg  s/\n//g"
3626747b715Smrg
3636747b715Smrg
36435c4bbdfSmrg## ----------------- ##
36535c4bbdfSmrg## Global variables. ##
36635c4bbdfSmrg## ----------------- ##
3676747b715Smrg
36835c4bbdfSmrg# Except for the global variables explicitly listed below, the following
36935c4bbdfSmrg# functions in the '^func_' namespace, and the '^require_' namespace
37035c4bbdfSmrg# variables initialised in the 'Resource management' section, sourcing
37135c4bbdfSmrg# this file will not pollute your global namespace with anything
37235c4bbdfSmrg# else. There's no portable way to scope variables in Bourne shell
37335c4bbdfSmrg# though, so actually running these functions will sometimes place
37435c4bbdfSmrg# results into a variable named after the function, and often use
37535c4bbdfSmrg# temporary variables in the '^_G_' namespace. If you are careful to
37635c4bbdfSmrg# avoid using those namespaces casually in your sourcing script, things
37735c4bbdfSmrg# should continue to work as you expect. And, of course, you can freely
37835c4bbdfSmrg# overwrite any of the functions or variables defined here before
37935c4bbdfSmrg# calling anything to customize them.
38005b261ecSmrg
38135c4bbdfSmrgEXIT_SUCCESS=0
38235c4bbdfSmrgEXIT_FAILURE=1
38335c4bbdfSmrgEXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
38435c4bbdfSmrgEXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
3854642e01fSmrg
38635c4bbdfSmrg# Allow overriding, eg assuming that you follow the convention of
38735c4bbdfSmrg# putting '$debug_cmd' at the start of all your functions, you can get
38835c4bbdfSmrg# bash to show function call trace with:
38935c4bbdfSmrg#
390ed6184dfSmrg#    debug_cmd='echo "${FUNCNAME[0]} $*" >&2' bash your-script-name
39135c4bbdfSmrgdebug_cmd=${debug_cmd-":"}
39235c4bbdfSmrgexit_cmd=:
3936747b715Smrg
39435c4bbdfSmrg# By convention, finish your script with:
39535c4bbdfSmrg#
39635c4bbdfSmrg#    exit $exit_status
39735c4bbdfSmrg#
39835c4bbdfSmrg# so that you can set exit_status to non-zero if you want to indicate
39935c4bbdfSmrg# something went wrong during execution without actually bailing out at
40035c4bbdfSmrg# the point of failure.
40135c4bbdfSmrgexit_status=$EXIT_SUCCESS
40235c4bbdfSmrg
40335c4bbdfSmrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
40435c4bbdfSmrg# is ksh but when the shell is invoked as "sh" and the current value of
40535c4bbdfSmrg# the _XPG environment variable is not equal to 1 (one), the special
40635c4bbdfSmrg# positional parameter $0, within a function call, is the name of the
40735c4bbdfSmrg# function.
40835c4bbdfSmrgprogpath=$0
4094642e01fSmrg
41035c4bbdfSmrg# The name of this program.
41135c4bbdfSmrgprogname=`$ECHO "$progpath" |$SED "$sed_basename"`
4124642e01fSmrg
41335c4bbdfSmrg# Make sure we have an absolute progpath for reexecution:
4144642e01fSmrgcase $progpath in
4154642e01fSmrg  [\\/]*|[A-Za-z]:\\*) ;;
4164642e01fSmrg  *[\\/]*)
41735c4bbdfSmrg     progdir=`$ECHO "$progpath" |$SED "$sed_dirname"`
4184642e01fSmrg     progdir=`cd "$progdir" && pwd`
41935c4bbdfSmrg     progpath=$progdir/$progname
4204642e01fSmrg     ;;
4214642e01fSmrg  *)
42235c4bbdfSmrg     _G_IFS=$IFS
42335c4bbdfSmrg     IFS=${PATH_SEPARATOR-:}
4244642e01fSmrg     for progdir in $PATH; do
42535c4bbdfSmrg       IFS=$_G_IFS
4264642e01fSmrg       test -x "$progdir/$progname" && break
4274642e01fSmrg     done
42835c4bbdfSmrg     IFS=$_G_IFS
4294642e01fSmrg     test -n "$progdir" || progdir=`pwd`
43035c4bbdfSmrg     progpath=$progdir/$progname
4314642e01fSmrg     ;;
4324642e01fSmrgesac
4334642e01fSmrg
4344642e01fSmrg
43535c4bbdfSmrg## ----------------- ##
43635c4bbdfSmrg## Standard options. ##
43735c4bbdfSmrg## ----------------- ##
43835c4bbdfSmrg
43935c4bbdfSmrg# The following options affect the operation of the functions defined
44035c4bbdfSmrg# below, and should be set appropriately depending on run-time para-
44135c4bbdfSmrg# meters passed on the command line.
4424642e01fSmrg
4434642e01fSmrgopt_dry_run=false
4444642e01fSmrgopt_quiet=false
4454642e01fSmrgopt_verbose=false
4464642e01fSmrg
44735c4bbdfSmrg# Categories 'all' and 'none' are always available.  Append any others
44835c4bbdfSmrg# you will pass as the first argument to func_warning from your own
44935c4bbdfSmrg# code.
45035c4bbdfSmrgwarning_categories=
4514642e01fSmrg
45235c4bbdfSmrg# By default, display warnings according to 'opt_warning_types'.  Set
45335c4bbdfSmrg# 'warning_func'  to ':' to elide all warnings, or func_fatal_error to
45435c4bbdfSmrg# treat the next displayed warning as a fatal error.
45535c4bbdfSmrgwarning_func=func_warn_and_continue
4564642e01fSmrg
45735c4bbdfSmrg# Set to 'all' to display all warnings, 'none' to suppress all
45835c4bbdfSmrg# warnings, or a space delimited list of some subset of
45935c4bbdfSmrg# 'warning_categories' to display only the listed warnings.
46035c4bbdfSmrgopt_warning_types=all
4614642e01fSmrg
4626747b715Smrg
46335c4bbdfSmrg## -------------------- ##
46435c4bbdfSmrg## Resource management. ##
46535c4bbdfSmrg## -------------------- ##
4664642e01fSmrg
46735c4bbdfSmrg# This section contains definitions for functions that each ensure a
46835c4bbdfSmrg# particular resource (a file, or a non-empty configuration variable for
46935c4bbdfSmrg# example) is available, and if appropriate to extract default values
47035c4bbdfSmrg# from pertinent package files. Call them using their associated
47135c4bbdfSmrg# 'require_*' variable to ensure that they are executed, at most, once.
47235c4bbdfSmrg#
47335c4bbdfSmrg# It's entirely deliberate that calling these functions can set
47435c4bbdfSmrg# variables that don't obey the namespace limitations obeyed by the rest
47535c4bbdfSmrg# of this file, in order that that they be as useful as possible to
47635c4bbdfSmrg# callers.
4774642e01fSmrg
4784642e01fSmrg
47935c4bbdfSmrg# require_term_colors
48035c4bbdfSmrg# -------------------
48135c4bbdfSmrg# Allow display of bold text on terminals that support it.
48235c4bbdfSmrgrequire_term_colors=func_require_term_colors
48335c4bbdfSmrgfunc_require_term_colors ()
4844642e01fSmrg{
48535c4bbdfSmrg    $debug_cmd
48635c4bbdfSmrg
48735c4bbdfSmrg    test -t 1 && {
48835c4bbdfSmrg      # COLORTERM and USE_ANSI_COLORS environment variables take
48935c4bbdfSmrg      # precedence, because most terminfo databases neglect to describe
49035c4bbdfSmrg      # whether color sequences are supported.
49135c4bbdfSmrg      test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"}
49235c4bbdfSmrg
49335c4bbdfSmrg      if test 1 = "$USE_ANSI_COLORS"; then
49435c4bbdfSmrg        # Standard ANSI escape sequences
49535c4bbdfSmrg        tc_reset='[0m'
49635c4bbdfSmrg        tc_bold='[1m';   tc_standout='[7m'
49735c4bbdfSmrg        tc_red='[31m';   tc_green='[32m'
49835c4bbdfSmrg        tc_blue='[34m';  tc_cyan='[36m'
49935c4bbdfSmrg      else
50035c4bbdfSmrg        # Otherwise trust the terminfo database after all.
50135c4bbdfSmrg        test -n "`tput sgr0 2>/dev/null`" && {
50235c4bbdfSmrg          tc_reset=`tput sgr0`
50335c4bbdfSmrg          test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold`
50435c4bbdfSmrg          tc_standout=$tc_bold
50535c4bbdfSmrg          test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso`
50635c4bbdfSmrg          test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1`
50735c4bbdfSmrg          test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2`
50835c4bbdfSmrg          test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4`
50935c4bbdfSmrg          test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5`
51035c4bbdfSmrg        }
51135c4bbdfSmrg      fi
51235c4bbdfSmrg    }
5134642e01fSmrg
51435c4bbdfSmrg    require_term_colors=:
5154642e01fSmrg}
5164642e01fSmrg
5174642e01fSmrg
51835c4bbdfSmrg## ----------------- ##
51935c4bbdfSmrg## Function library. ##
52035c4bbdfSmrg## ----------------- ##
5214642e01fSmrg
52235c4bbdfSmrg# This section contains a variety of useful functions to call in your
52335c4bbdfSmrg# scripts. Take note of the portable wrappers for features provided by
52435c4bbdfSmrg# some modern shells, which will fall back to slower equivalents on
52535c4bbdfSmrg# less featureful shells.
5264642e01fSmrg
5274642e01fSmrg
52835c4bbdfSmrg# func_append VAR VALUE
52935c4bbdfSmrg# ---------------------
53035c4bbdfSmrg# Append VALUE onto the existing contents of VAR.
5314642e01fSmrg
53235c4bbdfSmrg  # We should try to minimise forks, especially on Windows where they are
53335c4bbdfSmrg  # unreasonably slow, so skip the feature probes when bash or zsh are
53435c4bbdfSmrg  # being used:
53535c4bbdfSmrg  if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then
53635c4bbdfSmrg    : ${_G_HAVE_ARITH_OP="yes"}
53735c4bbdfSmrg    : ${_G_HAVE_XSI_OPS="yes"}
53835c4bbdfSmrg    # The += operator was introduced in bash 3.1
53935c4bbdfSmrg    case $BASH_VERSION in
54035c4bbdfSmrg      [12].* | 3.0 | 3.0*) ;;
54135c4bbdfSmrg      *)
54235c4bbdfSmrg        : ${_G_HAVE_PLUSEQ_OP="yes"}
54335c4bbdfSmrg        ;;
54435c4bbdfSmrg    esac
54535c4bbdfSmrg  fi
5464642e01fSmrg
54735c4bbdfSmrg  # _G_HAVE_PLUSEQ_OP
54835c4bbdfSmrg  # Can be empty, in which case the shell is probed, "yes" if += is
54935c4bbdfSmrg  # useable or anything else if it does not work.
55035c4bbdfSmrg  test -z "$_G_HAVE_PLUSEQ_OP" \
55135c4bbdfSmrg    && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \
55235c4bbdfSmrg    && _G_HAVE_PLUSEQ_OP=yes
55335c4bbdfSmrg
55435c4bbdfSmrgif test yes = "$_G_HAVE_PLUSEQ_OP"
55535c4bbdfSmrgthen
55635c4bbdfSmrg  # This is an XSI compatible shell, allowing a faster implementation...
55735c4bbdfSmrg  eval 'func_append ()
55835c4bbdfSmrg  {
55935c4bbdfSmrg    $debug_cmd
5604642e01fSmrg
56135c4bbdfSmrg    eval "$1+=\$2"
56235c4bbdfSmrg  }'
56335c4bbdfSmrgelse
56435c4bbdfSmrg  # ...otherwise fall back to using expr, which is often a shell builtin.
56535c4bbdfSmrg  func_append ()
56635c4bbdfSmrg  {
56735c4bbdfSmrg    $debug_cmd
5684642e01fSmrg
56935c4bbdfSmrg    eval "$1=\$$1\$2"
57035c4bbdfSmrg  }
57135c4bbdfSmrgfi
57235c4bbdfSmrg
57335c4bbdfSmrg
57435c4bbdfSmrg# func_append_quoted VAR VALUE
57535c4bbdfSmrg# ----------------------------
57635c4bbdfSmrg# Quote VALUE and append to the end of shell variable VAR, separated
57735c4bbdfSmrg# by a space.
57835c4bbdfSmrgif test yes = "$_G_HAVE_PLUSEQ_OP"; then
57935c4bbdfSmrg  eval 'func_append_quoted ()
58035c4bbdfSmrg  {
58135c4bbdfSmrg    $debug_cmd
58235c4bbdfSmrg
58335c4bbdfSmrg    func_quote_for_eval "$2"
58435c4bbdfSmrg    eval "$1+=\\ \$func_quote_for_eval_result"
58535c4bbdfSmrg  }'
58635c4bbdfSmrgelse
58735c4bbdfSmrg  func_append_quoted ()
58835c4bbdfSmrg  {
58935c4bbdfSmrg    $debug_cmd
59035c4bbdfSmrg
59135c4bbdfSmrg    func_quote_for_eval "$2"
59235c4bbdfSmrg    eval "$1=\$$1\\ \$func_quote_for_eval_result"
59335c4bbdfSmrg  }
59435c4bbdfSmrgfi
59535c4bbdfSmrg
59635c4bbdfSmrg
59735c4bbdfSmrg# func_append_uniq VAR VALUE
59835c4bbdfSmrg# --------------------------
59935c4bbdfSmrg# Append unique VALUE onto the existing contents of VAR, assuming
60035c4bbdfSmrg# entries are delimited by the first character of VALUE.  For example:
60135c4bbdfSmrg#
60235c4bbdfSmrg#   func_append_uniq options " --another-option option-argument"
60335c4bbdfSmrg#
60435c4bbdfSmrg# will only append to $options if " --another-option option-argument "
60535c4bbdfSmrg# is not already present somewhere in $options already (note spaces at
60635c4bbdfSmrg# each end implied by leading space in second argument).
60735c4bbdfSmrgfunc_append_uniq ()
60835c4bbdfSmrg{
60935c4bbdfSmrg    $debug_cmd
61035c4bbdfSmrg
61135c4bbdfSmrg    eval _G_current_value='`$ECHO $'$1'`'
61235c4bbdfSmrg    _G_delim=`expr "$2" : '\(.\)'`
61335c4bbdfSmrg
61435c4bbdfSmrg    case $_G_delim$_G_current_value$_G_delim in
61535c4bbdfSmrg      *"$2$_G_delim"*) ;;
61635c4bbdfSmrg      *) func_append "$@" ;;
61735c4bbdfSmrg    esac
61835c4bbdfSmrg}
61935c4bbdfSmrg
62035c4bbdfSmrg
62135c4bbdfSmrg# func_arith TERM...
62235c4bbdfSmrg# ------------------
62335c4bbdfSmrg# Set func_arith_result to the result of evaluating TERMs.
62435c4bbdfSmrg  test -z "$_G_HAVE_ARITH_OP" \
62535c4bbdfSmrg    && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \
62635c4bbdfSmrg    && _G_HAVE_ARITH_OP=yes
62735c4bbdfSmrg
62835c4bbdfSmrgif test yes = "$_G_HAVE_ARITH_OP"; then
62935c4bbdfSmrg  eval 'func_arith ()
63035c4bbdfSmrg  {
63135c4bbdfSmrg    $debug_cmd
63235c4bbdfSmrg
63335c4bbdfSmrg    func_arith_result=$(( $* ))
63435c4bbdfSmrg  }'
63535c4bbdfSmrgelse
63635c4bbdfSmrg  func_arith ()
63735c4bbdfSmrg  {
63835c4bbdfSmrg    $debug_cmd
63935c4bbdfSmrg
64035c4bbdfSmrg    func_arith_result=`expr "$@"`
64135c4bbdfSmrg  }
64235c4bbdfSmrgfi
64335c4bbdfSmrg
64435c4bbdfSmrg
64535c4bbdfSmrg# func_basename FILE
64635c4bbdfSmrg# ------------------
64735c4bbdfSmrg# Set func_basename_result to FILE with everything up to and including
64835c4bbdfSmrg# the last / stripped.
64935c4bbdfSmrgif test yes = "$_G_HAVE_XSI_OPS"; then
65035c4bbdfSmrg  # If this shell supports suffix pattern removal, then use it to avoid
65135c4bbdfSmrg  # forking. Hide the definitions single quotes in case the shell chokes
65235c4bbdfSmrg  # on unsupported syntax...
65335c4bbdfSmrg  _b='func_basename_result=${1##*/}'
65435c4bbdfSmrg  _d='case $1 in
65535c4bbdfSmrg        */*) func_dirname_result=${1%/*}$2 ;;
65635c4bbdfSmrg        *  ) func_dirname_result=$3        ;;
65735c4bbdfSmrg      esac'
65835c4bbdfSmrg
65935c4bbdfSmrgelse
66035c4bbdfSmrg  # ...otherwise fall back to using sed.
66135c4bbdfSmrg  _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`'
66235c4bbdfSmrg  _d='func_dirname_result=`$ECHO "$1"  |$SED "$sed_dirname"`
66335c4bbdfSmrg      if test "X$func_dirname_result" = "X$1"; then
66435c4bbdfSmrg        func_dirname_result=$3
66535c4bbdfSmrg      else
66635c4bbdfSmrg        func_append func_dirname_result "$2"
66735c4bbdfSmrg      fi'
66835c4bbdfSmrgfi
66935c4bbdfSmrg
67035c4bbdfSmrgeval 'func_basename ()
67135c4bbdfSmrg{
67235c4bbdfSmrg    $debug_cmd
67335c4bbdfSmrg
67435c4bbdfSmrg    '"$_b"'
67535c4bbdfSmrg}'
67635c4bbdfSmrg
67735c4bbdfSmrg
67835c4bbdfSmrg# func_dirname FILE APPEND NONDIR_REPLACEMENT
67935c4bbdfSmrg# -------------------------------------------
68035c4bbdfSmrg# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
68135c4bbdfSmrg# otherwise set result to NONDIR_REPLACEMENT.
68235c4bbdfSmrgeval 'func_dirname ()
68335c4bbdfSmrg{
68435c4bbdfSmrg    $debug_cmd
68535c4bbdfSmrg
68635c4bbdfSmrg    '"$_d"'
68735c4bbdfSmrg}'
68835c4bbdfSmrg
68935c4bbdfSmrg
69035c4bbdfSmrg# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT
69135c4bbdfSmrg# --------------------------------------------------------
69235c4bbdfSmrg# Perform func_basename and func_dirname in a single function
69335c4bbdfSmrg# call:
69435c4bbdfSmrg#   dirname:  Compute the dirname of FILE.  If nonempty,
69535c4bbdfSmrg#             add APPEND to the result, otherwise set result
69635c4bbdfSmrg#             to NONDIR_REPLACEMENT.
69735c4bbdfSmrg#             value returned in "$func_dirname_result"
69835c4bbdfSmrg#   basename: Compute filename of FILE.
69935c4bbdfSmrg#             value retuned in "$func_basename_result"
70035c4bbdfSmrg# For efficiency, we do not delegate to the functions above but instead
70135c4bbdfSmrg# duplicate the functionality here.
70235c4bbdfSmrgeval 'func_dirname_and_basename ()
70335c4bbdfSmrg{
70435c4bbdfSmrg    $debug_cmd
70535c4bbdfSmrg
70635c4bbdfSmrg    '"$_b"'
70735c4bbdfSmrg    '"$_d"'
70835c4bbdfSmrg}'
70935c4bbdfSmrg
71035c4bbdfSmrg
71135c4bbdfSmrg# func_echo ARG...
71235c4bbdfSmrg# ----------------
71335c4bbdfSmrg# Echo program name prefixed message.
71435c4bbdfSmrgfunc_echo ()
71535c4bbdfSmrg{
71635c4bbdfSmrg    $debug_cmd
71735c4bbdfSmrg
71835c4bbdfSmrg    _G_message=$*
71935c4bbdfSmrg
72035c4bbdfSmrg    func_echo_IFS=$IFS
72135c4bbdfSmrg    IFS=$nl
72235c4bbdfSmrg    for _G_line in $_G_message; do
72335c4bbdfSmrg      IFS=$func_echo_IFS
72435c4bbdfSmrg      $ECHO "$progname: $_G_line"
72535c4bbdfSmrg    done
72635c4bbdfSmrg    IFS=$func_echo_IFS
72735c4bbdfSmrg}
72835c4bbdfSmrg
72935c4bbdfSmrg
73035c4bbdfSmrg# func_echo_all ARG...
73135c4bbdfSmrg# --------------------
73235c4bbdfSmrg# Invoke $ECHO with all args, space-separated.
73335c4bbdfSmrgfunc_echo_all ()
73435c4bbdfSmrg{
73535c4bbdfSmrg    $ECHO "$*"
73635c4bbdfSmrg}
73735c4bbdfSmrg
73835c4bbdfSmrg
73935c4bbdfSmrg# func_echo_infix_1 INFIX ARG...
74035c4bbdfSmrg# ------------------------------
74135c4bbdfSmrg# Echo program name, followed by INFIX on the first line, with any
74235c4bbdfSmrg# additional lines not showing INFIX.
74335c4bbdfSmrgfunc_echo_infix_1 ()
74435c4bbdfSmrg{
74535c4bbdfSmrg    $debug_cmd
74635c4bbdfSmrg
74735c4bbdfSmrg    $require_term_colors
74835c4bbdfSmrg
74935c4bbdfSmrg    _G_infix=$1; shift
75035c4bbdfSmrg    _G_indent=$_G_infix
75135c4bbdfSmrg    _G_prefix="$progname: $_G_infix: "
75235c4bbdfSmrg    _G_message=$*
75335c4bbdfSmrg
75435c4bbdfSmrg    # Strip color escape sequences before counting printable length
75535c4bbdfSmrg    for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan"
75635c4bbdfSmrg    do
75735c4bbdfSmrg      test -n "$_G_tc" && {
75835c4bbdfSmrg        _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"`
75935c4bbdfSmrg        _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"`
76035c4bbdfSmrg      }
76135c4bbdfSmrg    done
76235c4bbdfSmrg    _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`"  " ## exclude from sc_prohibit_nested_quotes
76335c4bbdfSmrg
76435c4bbdfSmrg    func_echo_infix_1_IFS=$IFS
76535c4bbdfSmrg    IFS=$nl
76635c4bbdfSmrg    for _G_line in $_G_message; do
76735c4bbdfSmrg      IFS=$func_echo_infix_1_IFS
76835c4bbdfSmrg      $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2
76935c4bbdfSmrg      _G_prefix=$_G_indent
77035c4bbdfSmrg    done
77135c4bbdfSmrg    IFS=$func_echo_infix_1_IFS
77235c4bbdfSmrg}
77335c4bbdfSmrg
77435c4bbdfSmrg
77535c4bbdfSmrg# func_error ARG...
77635c4bbdfSmrg# -----------------
77735c4bbdfSmrg# Echo program name prefixed message to standard error.
77835c4bbdfSmrgfunc_error ()
77935c4bbdfSmrg{
78035c4bbdfSmrg    $debug_cmd
78135c4bbdfSmrg
78235c4bbdfSmrg    $require_term_colors
78335c4bbdfSmrg
78435c4bbdfSmrg    func_echo_infix_1 "  $tc_standout${tc_red}error$tc_reset" "$*" >&2
78535c4bbdfSmrg}
78635c4bbdfSmrg
78735c4bbdfSmrg
78835c4bbdfSmrg# func_fatal_error ARG...
78935c4bbdfSmrg# -----------------------
79035c4bbdfSmrg# Echo program name prefixed message to standard error, and exit.
79135c4bbdfSmrgfunc_fatal_error ()
79235c4bbdfSmrg{
79335c4bbdfSmrg    $debug_cmd
79435c4bbdfSmrg
79535c4bbdfSmrg    func_error "$*"
79635c4bbdfSmrg    exit $EXIT_FAILURE
79735c4bbdfSmrg}
79835c4bbdfSmrg
79935c4bbdfSmrg
80035c4bbdfSmrg# func_grep EXPRESSION FILENAME
80135c4bbdfSmrg# -----------------------------
80235c4bbdfSmrg# Check whether EXPRESSION matches any line of FILENAME, without output.
80335c4bbdfSmrgfunc_grep ()
80435c4bbdfSmrg{
80535c4bbdfSmrg    $debug_cmd
80635c4bbdfSmrg
80735c4bbdfSmrg    $GREP "$1" "$2" >/dev/null 2>&1
80835c4bbdfSmrg}
80935c4bbdfSmrg
81035c4bbdfSmrg
81135c4bbdfSmrg# func_len STRING
81235c4bbdfSmrg# ---------------
81335c4bbdfSmrg# Set func_len_result to the length of STRING. STRING may not
81435c4bbdfSmrg# start with a hyphen.
81535c4bbdfSmrg  test -z "$_G_HAVE_XSI_OPS" \
81635c4bbdfSmrg    && (eval 'x=a/b/c;
81735c4bbdfSmrg      test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
81835c4bbdfSmrg    && _G_HAVE_XSI_OPS=yes
81935c4bbdfSmrg
82035c4bbdfSmrgif test yes = "$_G_HAVE_XSI_OPS"; then
82135c4bbdfSmrg  eval 'func_len ()
82235c4bbdfSmrg  {
82335c4bbdfSmrg    $debug_cmd
82435c4bbdfSmrg
82535c4bbdfSmrg    func_len_result=${#1}
82635c4bbdfSmrg  }'
82735c4bbdfSmrgelse
82835c4bbdfSmrg  func_len ()
82935c4bbdfSmrg  {
83035c4bbdfSmrg    $debug_cmd
83135c4bbdfSmrg
83235c4bbdfSmrg    func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len`
83335c4bbdfSmrg  }
83435c4bbdfSmrgfi
83535c4bbdfSmrg
83635c4bbdfSmrg
83735c4bbdfSmrg# func_mkdir_p DIRECTORY-PATH
83835c4bbdfSmrg# ---------------------------
83935c4bbdfSmrg# Make sure the entire path to DIRECTORY-PATH is available.
84035c4bbdfSmrgfunc_mkdir_p ()
84135c4bbdfSmrg{
84235c4bbdfSmrg    $debug_cmd
84335c4bbdfSmrg
84435c4bbdfSmrg    _G_directory_path=$1
84535c4bbdfSmrg    _G_dir_list=
84635c4bbdfSmrg
84735c4bbdfSmrg    if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then
84835c4bbdfSmrg
84935c4bbdfSmrg      # Protect directory names starting with '-'
85035c4bbdfSmrg      case $_G_directory_path in
85135c4bbdfSmrg        -*) _G_directory_path=./$_G_directory_path ;;
85235c4bbdfSmrg      esac
85335c4bbdfSmrg
85435c4bbdfSmrg      # While some portion of DIR does not yet exist...
85535c4bbdfSmrg      while test ! -d "$_G_directory_path"; do
85635c4bbdfSmrg        # ...make a list in topmost first order.  Use a colon delimited
85735c4bbdfSmrg	# list incase some portion of path contains whitespace.
85835c4bbdfSmrg        _G_dir_list=$_G_directory_path:$_G_dir_list
85935c4bbdfSmrg
86035c4bbdfSmrg        # If the last portion added has no slash in it, the list is done
86135c4bbdfSmrg        case $_G_directory_path in */*) ;; *) break ;; esac
86235c4bbdfSmrg
86335c4bbdfSmrg        # ...otherwise throw away the child directory and loop
86435c4bbdfSmrg        _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"`
86535c4bbdfSmrg      done
86635c4bbdfSmrg      _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'`
8674642e01fSmrg
86835c4bbdfSmrg      func_mkdir_p_IFS=$IFS; IFS=:
86935c4bbdfSmrg      for _G_dir in $_G_dir_list; do
87035c4bbdfSmrg	IFS=$func_mkdir_p_IFS
87135c4bbdfSmrg        # mkdir can fail with a 'File exist' error if two processes
8724642e01fSmrg        # try to create one of the directories concurrently.  Don't
8734642e01fSmrg        # stop in that case!
87435c4bbdfSmrg        $MKDIR "$_G_dir" 2>/dev/null || :
8754642e01fSmrg      done
87635c4bbdfSmrg      IFS=$func_mkdir_p_IFS
8774642e01fSmrg
8784642e01fSmrg      # Bail out if we (or some other process) failed to create a directory.
87935c4bbdfSmrg      test -d "$_G_directory_path" || \
88035c4bbdfSmrg        func_fatal_error "Failed to create '$1'"
8814642e01fSmrg    fi
8824642e01fSmrg}
88305b261ecSmrg
88405b261ecSmrg
88535c4bbdfSmrg# func_mktempdir [BASENAME]
88635c4bbdfSmrg# -------------------------
88705b261ecSmrg# Make a temporary directory that won't clash with other running
88805b261ecSmrg# libtool processes, and avoids race conditions if possible.  If
88935c4bbdfSmrg# given, BASENAME is the basename for that directory.
89005b261ecSmrgfunc_mktempdir ()
89105b261ecSmrg{
89235c4bbdfSmrg    $debug_cmd
89305b261ecSmrg
89435c4bbdfSmrg    _G_template=${TMPDIR-/tmp}/${1-$progname}
89535c4bbdfSmrg
89635c4bbdfSmrg    if test : = "$opt_dry_run"; then
89705b261ecSmrg      # Return a directory name, but don't create it in dry-run mode
89835c4bbdfSmrg      _G_tmpdir=$_G_template-$$
89905b261ecSmrg    else
90005b261ecSmrg
90105b261ecSmrg      # If mktemp works, use that first and foremost
90235c4bbdfSmrg      _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null`
90305b261ecSmrg
90435c4bbdfSmrg      if test ! -d "$_G_tmpdir"; then
9054642e01fSmrg        # Failing that, at least try and use $RANDOM to avoid a race
90635c4bbdfSmrg        _G_tmpdir=$_G_template-${RANDOM-0}$$
90705b261ecSmrg
90835c4bbdfSmrg        func_mktempdir_umask=`umask`
9094642e01fSmrg        umask 0077
91035c4bbdfSmrg        $MKDIR "$_G_tmpdir"
91135c4bbdfSmrg        umask $func_mktempdir_umask
91205b261ecSmrg      fi
91305b261ecSmrg
91405b261ecSmrg      # If we're not in dry-run mode, bomb out on failure
91535c4bbdfSmrg      test -d "$_G_tmpdir" || \
91635c4bbdfSmrg        func_fatal_error "cannot create temporary directory '$_G_tmpdir'"
91705b261ecSmrg    fi
91805b261ecSmrg
91935c4bbdfSmrg    $ECHO "$_G_tmpdir"
92005b261ecSmrg}
92105b261ecSmrg
92205b261ecSmrg
92335c4bbdfSmrg# func_normal_abspath PATH
92435c4bbdfSmrg# ------------------------
92535c4bbdfSmrg# Remove doubled-up and trailing slashes, "." path components,
92635c4bbdfSmrg# and cancel out any ".." path components in PATH after making
92735c4bbdfSmrg# it an absolute path.
92835c4bbdfSmrgfunc_normal_abspath ()
92905b261ecSmrg{
93035c4bbdfSmrg    $debug_cmd
9314642e01fSmrg
93235c4bbdfSmrg    # These SED scripts presuppose an absolute path with a trailing slash.
93335c4bbdfSmrg    _G_pathcar='s|^/\([^/]*\).*$|\1|'
93435c4bbdfSmrg    _G_pathcdr='s|^/[^/]*||'
93535c4bbdfSmrg    _G_removedotparts=':dotsl
93635c4bbdfSmrg		s|/\./|/|g
93735c4bbdfSmrg		t dotsl
93835c4bbdfSmrg		s|/\.$|/|'
93935c4bbdfSmrg    _G_collapseslashes='s|/\{1,\}|/|g'
94035c4bbdfSmrg    _G_finalslash='s|/*$|/|'
94135c4bbdfSmrg
94235c4bbdfSmrg    # Start from root dir and reassemble the path.
94335c4bbdfSmrg    func_normal_abspath_result=
94435c4bbdfSmrg    func_normal_abspath_tpath=$1
94535c4bbdfSmrg    func_normal_abspath_altnamespace=
94635c4bbdfSmrg    case $func_normal_abspath_tpath in
94735c4bbdfSmrg      "")
94835c4bbdfSmrg        # Empty path, that just means $cwd.
94935c4bbdfSmrg        func_stripname '' '/' "`pwd`"
95035c4bbdfSmrg        func_normal_abspath_result=$func_stripname_result
95135c4bbdfSmrg        return
95235c4bbdfSmrg        ;;
95335c4bbdfSmrg      # The next three entries are used to spot a run of precisely
95435c4bbdfSmrg      # two leading slashes without using negated character classes;
95535c4bbdfSmrg      # we take advantage of case's first-match behaviour.
95635c4bbdfSmrg      ///*)
95735c4bbdfSmrg        # Unusual form of absolute path, do nothing.
95835c4bbdfSmrg        ;;
95935c4bbdfSmrg      //*)
96035c4bbdfSmrg        # Not necessarily an ordinary path; POSIX reserves leading '//'
96135c4bbdfSmrg        # and for example Cygwin uses it to access remote file shares
96235c4bbdfSmrg        # over CIFS/SMB, so we conserve a leading double slash if found.
96335c4bbdfSmrg        func_normal_abspath_altnamespace=/
96435c4bbdfSmrg        ;;
96535c4bbdfSmrg      /*)
96635c4bbdfSmrg        # Absolute path, do nothing.
9674642e01fSmrg        ;;
9684642e01fSmrg      *)
96935c4bbdfSmrg        # Relative path, prepend $cwd.
97035c4bbdfSmrg        func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
97135c4bbdfSmrg        ;;
97205b261ecSmrg    esac
97335c4bbdfSmrg
97435c4bbdfSmrg    # Cancel out all the simple stuff to save iterations.  We also want
97535c4bbdfSmrg    # the path to end with a slash for ease of parsing, so make sure
97635c4bbdfSmrg    # there is one (and only one) here.
97735c4bbdfSmrg    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
97835c4bbdfSmrg          -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"`
97935c4bbdfSmrg    while :; do
98035c4bbdfSmrg      # Processed it all yet?
98135c4bbdfSmrg      if test / = "$func_normal_abspath_tpath"; then
98235c4bbdfSmrg        # If we ascended to the root using ".." the result may be empty now.
98335c4bbdfSmrg        if test -z "$func_normal_abspath_result"; then
98435c4bbdfSmrg          func_normal_abspath_result=/
98535c4bbdfSmrg        fi
98635c4bbdfSmrg        break
98735c4bbdfSmrg      fi
98835c4bbdfSmrg      func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
98935c4bbdfSmrg          -e "$_G_pathcar"`
99035c4bbdfSmrg      func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
99135c4bbdfSmrg          -e "$_G_pathcdr"`
99235c4bbdfSmrg      # Figure out what to do with it
99335c4bbdfSmrg      case $func_normal_abspath_tcomponent in
99435c4bbdfSmrg        "")
99535c4bbdfSmrg          # Trailing empty path component, ignore it.
99635c4bbdfSmrg          ;;
99735c4bbdfSmrg        ..)
99835c4bbdfSmrg          # Parent dir; strip last assembled component from result.
99935c4bbdfSmrg          func_dirname "$func_normal_abspath_result"
100035c4bbdfSmrg          func_normal_abspath_result=$func_dirname_result
100135c4bbdfSmrg          ;;
100235c4bbdfSmrg        *)
100335c4bbdfSmrg          # Actual path component, append it.
100435c4bbdfSmrg          func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent"
100535c4bbdfSmrg          ;;
100635c4bbdfSmrg      esac
100735c4bbdfSmrg    done
100835c4bbdfSmrg    # Restore leading double-slash if one was found on entry.
100935c4bbdfSmrg    func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
101035c4bbdfSmrg}
101135c4bbdfSmrg
101235c4bbdfSmrg
101335c4bbdfSmrg# func_notquiet ARG...
101435c4bbdfSmrg# --------------------
101535c4bbdfSmrg# Echo program name prefixed message only when not in quiet mode.
101635c4bbdfSmrgfunc_notquiet ()
101735c4bbdfSmrg{
101835c4bbdfSmrg    $debug_cmd
101935c4bbdfSmrg
102035c4bbdfSmrg    $opt_quiet || func_echo ${1+"$@"}
102135c4bbdfSmrg
102235c4bbdfSmrg    # A bug in bash halts the script if the last line of a function
102335c4bbdfSmrg    # fails when set -e is in force, so we need another command to
102435c4bbdfSmrg    # work around that:
102535c4bbdfSmrg    :
102635c4bbdfSmrg}
102735c4bbdfSmrg
102835c4bbdfSmrg
102935c4bbdfSmrg# func_relative_path SRCDIR DSTDIR
103035c4bbdfSmrg# --------------------------------
103135c4bbdfSmrg# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR.
103235c4bbdfSmrgfunc_relative_path ()
103335c4bbdfSmrg{
103435c4bbdfSmrg    $debug_cmd
103535c4bbdfSmrg
103635c4bbdfSmrg    func_relative_path_result=
103735c4bbdfSmrg    func_normal_abspath "$1"
103835c4bbdfSmrg    func_relative_path_tlibdir=$func_normal_abspath_result
103935c4bbdfSmrg    func_normal_abspath "$2"
104035c4bbdfSmrg    func_relative_path_tbindir=$func_normal_abspath_result
104135c4bbdfSmrg
104235c4bbdfSmrg    # Ascend the tree starting from libdir
104335c4bbdfSmrg    while :; do
104435c4bbdfSmrg      # check if we have found a prefix of bindir
104535c4bbdfSmrg      case $func_relative_path_tbindir in
104635c4bbdfSmrg        $func_relative_path_tlibdir)
104735c4bbdfSmrg          # found an exact match
104835c4bbdfSmrg          func_relative_path_tcancelled=
104935c4bbdfSmrg          break
105035c4bbdfSmrg          ;;
105135c4bbdfSmrg        $func_relative_path_tlibdir*)
105235c4bbdfSmrg          # found a matching prefix
105335c4bbdfSmrg          func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
105435c4bbdfSmrg          func_relative_path_tcancelled=$func_stripname_result
105535c4bbdfSmrg          if test -z "$func_relative_path_result"; then
105635c4bbdfSmrg            func_relative_path_result=.
105735c4bbdfSmrg          fi
105835c4bbdfSmrg          break
105935c4bbdfSmrg          ;;
106035c4bbdfSmrg        *)
106135c4bbdfSmrg          func_dirname $func_relative_path_tlibdir
106235c4bbdfSmrg          func_relative_path_tlibdir=$func_dirname_result
106335c4bbdfSmrg          if test -z "$func_relative_path_tlibdir"; then
106435c4bbdfSmrg            # Have to descend all the way to the root!
106535c4bbdfSmrg            func_relative_path_result=../$func_relative_path_result
106635c4bbdfSmrg            func_relative_path_tcancelled=$func_relative_path_tbindir
106735c4bbdfSmrg            break
106835c4bbdfSmrg          fi
106935c4bbdfSmrg          func_relative_path_result=../$func_relative_path_result
107035c4bbdfSmrg          ;;
107135c4bbdfSmrg      esac
107235c4bbdfSmrg    done
107335c4bbdfSmrg
107435c4bbdfSmrg    # Now calculate path; take care to avoid doubling-up slashes.
107535c4bbdfSmrg    func_stripname '' '/' "$func_relative_path_result"
107635c4bbdfSmrg    func_relative_path_result=$func_stripname_result
107735c4bbdfSmrg    func_stripname '/' '/' "$func_relative_path_tcancelled"
107835c4bbdfSmrg    if test -n "$func_stripname_result"; then
107935c4bbdfSmrg      func_append func_relative_path_result "/$func_stripname_result"
108035c4bbdfSmrg    fi
108135c4bbdfSmrg
108235c4bbdfSmrg    # Normalisation. If bindir is libdir, return '.' else relative path.
108335c4bbdfSmrg    if test -n "$func_relative_path_result"; then
108435c4bbdfSmrg      func_stripname './' '' "$func_relative_path_result"
108535c4bbdfSmrg      func_relative_path_result=$func_stripname_result
108635c4bbdfSmrg    fi
108735c4bbdfSmrg
108835c4bbdfSmrg    test -n "$func_relative_path_result" || func_relative_path_result=.
108935c4bbdfSmrg
109035c4bbdfSmrg    :
109135c4bbdfSmrg}
109235c4bbdfSmrg
109335c4bbdfSmrg
109435c4bbdfSmrg# func_quote_for_eval ARG...
109535c4bbdfSmrg# --------------------------
109635c4bbdfSmrg# Aesthetically quote ARGs to be evaled later.
109735c4bbdfSmrg# This function returns two values:
109835c4bbdfSmrg#   i) func_quote_for_eval_result
109935c4bbdfSmrg#      double-quoted, suitable for a subsequent eval
110035c4bbdfSmrg#  ii) func_quote_for_eval_unquoted_result
110135c4bbdfSmrg#      has all characters that are still active within double
110235c4bbdfSmrg#      quotes backslashified.
110335c4bbdfSmrgfunc_quote_for_eval ()
110435c4bbdfSmrg{
110535c4bbdfSmrg    $debug_cmd
110635c4bbdfSmrg
110735c4bbdfSmrg    func_quote_for_eval_unquoted_result=
110835c4bbdfSmrg    func_quote_for_eval_result=
110935c4bbdfSmrg    while test 0 -lt $#; do
1110ed6184dfSmrg      case $1 in
1111ed6184dfSmrg        *[\\\`\"\$]*)
1112ed6184dfSmrg	  _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;;
1113ed6184dfSmrg        *)
1114ed6184dfSmrg          _G_unquoted_arg=$1 ;;
1115ed6184dfSmrg      esac
111635c4bbdfSmrg      if test -n "$func_quote_for_eval_unquoted_result"; then
111735c4bbdfSmrg	func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg"
111835c4bbdfSmrg      else
111935c4bbdfSmrg        func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg"
112035c4bbdfSmrg      fi
112135c4bbdfSmrg
112235c4bbdfSmrg      case $_G_unquoted_arg in
112335c4bbdfSmrg        # Double-quote args containing shell metacharacters to delay
112435c4bbdfSmrg        # word splitting, command substitution and variable expansion
112535c4bbdfSmrg        # for a subsequent eval.
112635c4bbdfSmrg        # Many Bourne shells cannot handle close brackets correctly
112735c4bbdfSmrg        # in scan sets, so we specify it separately.
112835c4bbdfSmrg        *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
112935c4bbdfSmrg          _G_quoted_arg=\"$_G_unquoted_arg\"
113035c4bbdfSmrg          ;;
113135c4bbdfSmrg        *)
113235c4bbdfSmrg          _G_quoted_arg=$_G_unquoted_arg
113335c4bbdfSmrg	  ;;
113435c4bbdfSmrg      esac
113535c4bbdfSmrg
113635c4bbdfSmrg      if test -n "$func_quote_for_eval_result"; then
113735c4bbdfSmrg	func_append func_quote_for_eval_result " $_G_quoted_arg"
113835c4bbdfSmrg      else
113935c4bbdfSmrg        func_append func_quote_for_eval_result "$_G_quoted_arg"
114035c4bbdfSmrg      fi
114135c4bbdfSmrg      shift
114235c4bbdfSmrg    done
114305b261ecSmrg}
114405b261ecSmrg
114505b261ecSmrg
114635c4bbdfSmrg# func_quote_for_expand ARG
114735c4bbdfSmrg# -------------------------
11484642e01fSmrg# Aesthetically quote ARG to be evaled later; same as above,
11494642e01fSmrg# but do not quote variable references.
11504642e01fSmrgfunc_quote_for_expand ()
115105b261ecSmrg{
115235c4bbdfSmrg    $debug_cmd
115335c4bbdfSmrg
11544642e01fSmrg    case $1 in
11554642e01fSmrg      *[\\\`\"]*)
115635c4bbdfSmrg	_G_arg=`$ECHO "$1" | $SED \
115735c4bbdfSmrg	    -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;;
115805b261ecSmrg      *)
115935c4bbdfSmrg        _G_arg=$1 ;;
11604642e01fSmrg    esac
11614642e01fSmrg
116235c4bbdfSmrg    case $_G_arg in
11634642e01fSmrg      # Double-quote args containing shell metacharacters to delay
11644642e01fSmrg      # word splitting and command substitution for a subsequent eval.
11654642e01fSmrg      # Many Bourne shells cannot handle close brackets correctly
11664642e01fSmrg      # in scan sets, so we specify it separately.
11674642e01fSmrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
116835c4bbdfSmrg        _G_arg=\"$_G_arg\"
11694642e01fSmrg        ;;
11704642e01fSmrg    esac
11714642e01fSmrg
117235c4bbdfSmrg    func_quote_for_expand_result=$_G_arg
117305b261ecSmrg}
117405b261ecSmrg
117505b261ecSmrg
117635c4bbdfSmrg# func_stripname PREFIX SUFFIX NAME
117735c4bbdfSmrg# ---------------------------------
117835c4bbdfSmrg# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result.
117935c4bbdfSmrg# PREFIX and SUFFIX must not contain globbing or regex special
118035c4bbdfSmrg# characters, hashes, percent signs, but SUFFIX may contain a leading
118135c4bbdfSmrg# dot (in which case that matches only a dot).
118235c4bbdfSmrgif test yes = "$_G_HAVE_XSI_OPS"; then
118335c4bbdfSmrg  eval 'func_stripname ()
118435c4bbdfSmrg  {
118535c4bbdfSmrg    $debug_cmd
118635c4bbdfSmrg
118735c4bbdfSmrg    # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
118835c4bbdfSmrg    # positional parameters, so assign one to ordinary variable first.
118935c4bbdfSmrg    func_stripname_result=$3
119035c4bbdfSmrg    func_stripname_result=${func_stripname_result#"$1"}
119135c4bbdfSmrg    func_stripname_result=${func_stripname_result%"$2"}
119235c4bbdfSmrg  }'
119335c4bbdfSmrgelse
119435c4bbdfSmrg  func_stripname ()
119535c4bbdfSmrg  {
119635c4bbdfSmrg    $debug_cmd
119735c4bbdfSmrg
119835c4bbdfSmrg    case $2 in
119935c4bbdfSmrg      .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;;
120035c4bbdfSmrg      *)  func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;;
120135c4bbdfSmrg    esac
120235c4bbdfSmrg  }
120335c4bbdfSmrgfi
120435c4bbdfSmrg
120535c4bbdfSmrg
120635c4bbdfSmrg# func_show_eval CMD [FAIL_EXP]
120735c4bbdfSmrg# -----------------------------
120835c4bbdfSmrg# Unless opt_quiet is true, then output CMD.  Then, if opt_dryrun is
12094642e01fSmrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
12104642e01fSmrg# is given, then evaluate it.
12114642e01fSmrgfunc_show_eval ()
121205b261ecSmrg{
121335c4bbdfSmrg    $debug_cmd
121405b261ecSmrg
121535c4bbdfSmrg    _G_cmd=$1
121635c4bbdfSmrg    _G_fail_exp=${2-':'}
12174642e01fSmrg
121835c4bbdfSmrg    func_quote_for_expand "$_G_cmd"
121935c4bbdfSmrg    eval "func_notquiet $func_quote_for_expand_result"
122035c4bbdfSmrg
122135c4bbdfSmrg    $opt_dry_run || {
122235c4bbdfSmrg      eval "$_G_cmd"
122335c4bbdfSmrg      _G_status=$?
122435c4bbdfSmrg      if test 0 -ne "$_G_status"; then
122535c4bbdfSmrg	eval "(exit $_G_status); $_G_fail_exp"
12264642e01fSmrg      fi
122735c4bbdfSmrg    }
122805b261ecSmrg}
122905b261ecSmrg
12304642e01fSmrg
123135c4bbdfSmrg# func_show_eval_locale CMD [FAIL_EXP]
123235c4bbdfSmrg# ------------------------------------
123335c4bbdfSmrg# Unless opt_quiet is true, then output CMD.  Then, if opt_dryrun is
12344642e01fSmrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
12354642e01fSmrg# is given, then evaluate it.  Use the saved locale for evaluation.
12364642e01fSmrgfunc_show_eval_locale ()
123705b261ecSmrg{
123835c4bbdfSmrg    $debug_cmd
12394642e01fSmrg
124035c4bbdfSmrg    _G_cmd=$1
124135c4bbdfSmrg    _G_fail_exp=${2-':'}
124235c4bbdfSmrg
124335c4bbdfSmrg    $opt_quiet || {
124435c4bbdfSmrg      func_quote_for_expand "$_G_cmd"
12454642e01fSmrg      eval "func_echo $func_quote_for_expand_result"
12464642e01fSmrg    }
12474642e01fSmrg
124835c4bbdfSmrg    $opt_dry_run || {
124935c4bbdfSmrg      eval "$_G_user_locale
125035c4bbdfSmrg	    $_G_cmd"
125135c4bbdfSmrg      _G_status=$?
125235c4bbdfSmrg      eval "$_G_safe_locale"
125335c4bbdfSmrg      if test 0 -ne "$_G_status"; then
125435c4bbdfSmrg	eval "(exit $_G_status); $_G_fail_exp"
12554642e01fSmrg      fi
125635c4bbdfSmrg    }
12574642e01fSmrg}
125805b261ecSmrg
12594642e01fSmrg
126035c4bbdfSmrg# func_tr_sh
126135c4bbdfSmrg# ----------
126235c4bbdfSmrg# Turn $1 into a string suitable for a shell variable name.
126335c4bbdfSmrg# Result is stored in $func_tr_sh_result.  All characters
126435c4bbdfSmrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
126535c4bbdfSmrg# if $1 begins with a digit, a '_' is prepended as well.
126635c4bbdfSmrgfunc_tr_sh ()
12674642e01fSmrg{
126835c4bbdfSmrg    $debug_cmd
12694642e01fSmrg
127035c4bbdfSmrg    case $1 in
127135c4bbdfSmrg    [0-9]* | *[!a-zA-Z0-9_]*)
127235c4bbdfSmrg      func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'`
127335c4bbdfSmrg      ;;
127435c4bbdfSmrg    * )
127535c4bbdfSmrg      func_tr_sh_result=$1
127635c4bbdfSmrg      ;;
127735c4bbdfSmrg    esac
12784642e01fSmrg}
12794642e01fSmrg
12804642e01fSmrg
128135c4bbdfSmrg# func_verbose ARG...
128235c4bbdfSmrg# -------------------
128335c4bbdfSmrg# Echo program name prefixed message in verbose mode only.
128435c4bbdfSmrgfunc_verbose ()
12854642e01fSmrg{
128635c4bbdfSmrg    $debug_cmd
128705b261ecSmrg
128835c4bbdfSmrg    $opt_verbose && func_echo "$*"
12896747b715Smrg
129035c4bbdfSmrg    :
129135c4bbdfSmrg}
12924642e01fSmrg
12934642e01fSmrg
129435c4bbdfSmrg# func_warn_and_continue ARG...
129535c4bbdfSmrg# -----------------------------
129635c4bbdfSmrg# Echo program name prefixed warning message to standard error.
129735c4bbdfSmrgfunc_warn_and_continue ()
129835c4bbdfSmrg{
129935c4bbdfSmrg    $debug_cmd
130005b261ecSmrg
130135c4bbdfSmrg    $require_term_colors
130205b261ecSmrg
130335c4bbdfSmrg    func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2
130435c4bbdfSmrg}
1305475c125cSmrg
130635c4bbdfSmrg
130735c4bbdfSmrg# func_warning CATEGORY ARG...
130835c4bbdfSmrg# ----------------------------
130935c4bbdfSmrg# Echo program name prefixed warning message to standard error. Warning
131035c4bbdfSmrg# messages can be filtered according to CATEGORY, where this function
131135c4bbdfSmrg# elides messages where CATEGORY is not listed in the global variable
131235c4bbdfSmrg# 'opt_warning_types'.
131335c4bbdfSmrgfunc_warning ()
131435c4bbdfSmrg{
131535c4bbdfSmrg    $debug_cmd
131635c4bbdfSmrg
131735c4bbdfSmrg    # CATEGORY must be in the warning_categories list!
131835c4bbdfSmrg    case " $warning_categories " in
131935c4bbdfSmrg      *" $1 "*) ;;
132035c4bbdfSmrg      *) func_internal_error "invalid warning category '$1'" ;;
132135c4bbdfSmrg    esac
132235c4bbdfSmrg
132335c4bbdfSmrg    _G_category=$1
132435c4bbdfSmrg    shift
132535c4bbdfSmrg
132635c4bbdfSmrg    case " $opt_warning_types " in
132735c4bbdfSmrg      *" $_G_category "*) $warning_func ${1+"$@"} ;;
132835c4bbdfSmrg    esac
132935c4bbdfSmrg}
133035c4bbdfSmrg
133135c4bbdfSmrg
133235c4bbdfSmrg# func_sort_ver VER1 VER2
133335c4bbdfSmrg# -----------------------
133435c4bbdfSmrg# 'sort -V' is not generally available.
133535c4bbdfSmrg# Note this deviates from the version comparison in automake
133635c4bbdfSmrg# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a
133735c4bbdfSmrg# but this should suffice as we won't be specifying old
133835c4bbdfSmrg# version formats or redundant trailing .0 in bootstrap.conf.
133935c4bbdfSmrg# If we did want full compatibility then we should probably
134035c4bbdfSmrg# use m4_version_compare from autoconf.
134135c4bbdfSmrgfunc_sort_ver ()
134235c4bbdfSmrg{
134335c4bbdfSmrg    $debug_cmd
134435c4bbdfSmrg
134535c4bbdfSmrg    printf '%s\n%s\n' "$1" "$2" \
134635c4bbdfSmrg      | 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
134735c4bbdfSmrg}
134835c4bbdfSmrg
134935c4bbdfSmrg# func_lt_ver PREV CURR
135035c4bbdfSmrg# ---------------------
135135c4bbdfSmrg# Return true if PREV and CURR are in the correct order according to
135235c4bbdfSmrg# func_sort_ver, otherwise false.  Use it like this:
135335c4bbdfSmrg#
135435c4bbdfSmrg#  func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..."
135535c4bbdfSmrgfunc_lt_ver ()
135635c4bbdfSmrg{
135735c4bbdfSmrg    $debug_cmd
135835c4bbdfSmrg
135935c4bbdfSmrg    test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q`
136035c4bbdfSmrg}
136135c4bbdfSmrg
136235c4bbdfSmrg
136335c4bbdfSmrg# Local variables:
136435c4bbdfSmrg# mode: shell-script
136535c4bbdfSmrg# sh-indentation: 2
136635c4bbdfSmrg# eval: (add-hook 'before-save-hook 'time-stamp)
136735c4bbdfSmrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
136835c4bbdfSmrg# time-stamp-time-zone: "UTC"
136935c4bbdfSmrg# End:
137035c4bbdfSmrg#! /bin/sh
137135c4bbdfSmrg
137235c4bbdfSmrg# Set a version string for this script.
1373ed6184dfSmrgscriptversion=2015-10-07.11; # UTC
137435c4bbdfSmrg
137535c4bbdfSmrg# A portable, pluggable option parser for Bourne shell.
137635c4bbdfSmrg# Written by Gary V. Vaughan, 2010
137735c4bbdfSmrg
137835c4bbdfSmrg# Copyright (C) 2010-2015 Free Software Foundation, Inc.
137935c4bbdfSmrg# This is free software; see the source for copying conditions.  There is NO
138035c4bbdfSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
138135c4bbdfSmrg
138235c4bbdfSmrg# This program is free software: you can redistribute it and/or modify
138335c4bbdfSmrg# it under the terms of the GNU General Public License as published by
138435c4bbdfSmrg# the Free Software Foundation, either version 3 of the License, or
138535c4bbdfSmrg# (at your option) any later version.
138635c4bbdfSmrg
138735c4bbdfSmrg# This program is distributed in the hope that it will be useful,
138835c4bbdfSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
138935c4bbdfSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
139035c4bbdfSmrg# GNU General Public License for more details.
139135c4bbdfSmrg
139235c4bbdfSmrg# You should have received a copy of the GNU General Public License
139335c4bbdfSmrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
139435c4bbdfSmrg
139535c4bbdfSmrg# Please report bugs or propose patches to gary@gnu.org.
139635c4bbdfSmrg
139735c4bbdfSmrg
139835c4bbdfSmrg## ------ ##
139935c4bbdfSmrg## Usage. ##
140035c4bbdfSmrg## ------ ##
140135c4bbdfSmrg
140235c4bbdfSmrg# This file is a library for parsing options in your shell scripts along
140335c4bbdfSmrg# with assorted other useful supporting features that you can make use
140435c4bbdfSmrg# of too.
140535c4bbdfSmrg#
140635c4bbdfSmrg# For the simplest scripts you might need only:
140735c4bbdfSmrg#
140835c4bbdfSmrg#   #!/bin/sh
140935c4bbdfSmrg#   . relative/path/to/funclib.sh
141035c4bbdfSmrg#   . relative/path/to/options-parser
141135c4bbdfSmrg#   scriptversion=1.0
141235c4bbdfSmrg#   func_options ${1+"$@"}
141335c4bbdfSmrg#   eval set dummy "$func_options_result"; shift
141435c4bbdfSmrg#   ...rest of your script...
141535c4bbdfSmrg#
141635c4bbdfSmrg# In order for the '--version' option to work, you will need to have a
141735c4bbdfSmrg# suitably formatted comment like the one at the top of this file
141835c4bbdfSmrg# starting with '# Written by ' and ending with '# warranty; '.
141935c4bbdfSmrg#
142035c4bbdfSmrg# For '-h' and '--help' to work, you will also need a one line
142135c4bbdfSmrg# description of your script's purpose in a comment directly above the
142235c4bbdfSmrg# '# Written by ' line, like the one at the top of this file.
142335c4bbdfSmrg#
142435c4bbdfSmrg# The default options also support '--debug', which will turn on shell
142535c4bbdfSmrg# execution tracing (see the comment above debug_cmd below for another
142635c4bbdfSmrg# use), and '--verbose' and the func_verbose function to allow your script
142735c4bbdfSmrg# to display verbose messages only when your user has specified
142835c4bbdfSmrg# '--verbose'.
142935c4bbdfSmrg#
143035c4bbdfSmrg# After sourcing this file, you can plug processing for additional
143135c4bbdfSmrg# options by amending the variables from the 'Configuration' section
143235c4bbdfSmrg# below, and following the instructions in the 'Option parsing'
143335c4bbdfSmrg# section further down.
143435c4bbdfSmrg
143535c4bbdfSmrg## -------------- ##
143635c4bbdfSmrg## Configuration. ##
143735c4bbdfSmrg## -------------- ##
143835c4bbdfSmrg
143935c4bbdfSmrg# You should override these variables in your script after sourcing this
144035c4bbdfSmrg# file so that they reflect the customisations you have added to the
144135c4bbdfSmrg# option parser.
144235c4bbdfSmrg
144335c4bbdfSmrg# The usage line for option parsing errors and the start of '-h' and
144435c4bbdfSmrg# '--help' output messages. You can embed shell variables for delayed
144535c4bbdfSmrg# expansion at the time the message is displayed, but you will need to
144635c4bbdfSmrg# quote other shell meta-characters carefully to prevent them being
144735c4bbdfSmrg# expanded when the contents are evaled.
144835c4bbdfSmrgusage='$progpath [OPTION]...'
144935c4bbdfSmrg
145035c4bbdfSmrg# Short help message in response to '-h' and '--help'.  Add to this or
145135c4bbdfSmrg# override it after sourcing this library to reflect the full set of
145235c4bbdfSmrg# options your script accepts.
145335c4bbdfSmrgusage_message="\
145435c4bbdfSmrg       --debug        enable verbose shell tracing
145535c4bbdfSmrg   -W, --warnings=CATEGORY
145635c4bbdfSmrg                      report the warnings falling in CATEGORY [all]
145735c4bbdfSmrg   -v, --verbose      verbosely report processing
145835c4bbdfSmrg       --version      print version information and exit
145935c4bbdfSmrg   -h, --help         print short or long help message and exit
146035c4bbdfSmrg"
146135c4bbdfSmrg
146235c4bbdfSmrg# Additional text appended to 'usage_message' in response to '--help'.
146335c4bbdfSmrglong_help_message="
146435c4bbdfSmrgWarning categories include:
146535c4bbdfSmrg       'all'          show all warnings
146635c4bbdfSmrg       'none'         turn off all the warnings
146735c4bbdfSmrg       'error'        warnings are treated as fatal errors"
146835c4bbdfSmrg
146935c4bbdfSmrg# Help message printed before fatal option parsing errors.
147035c4bbdfSmrgfatal_help="Try '\$progname --help' for more information."
147135c4bbdfSmrg
147235c4bbdfSmrg
147335c4bbdfSmrg
147435c4bbdfSmrg## ------------------------- ##
147535c4bbdfSmrg## Hook function management. ##
147635c4bbdfSmrg## ------------------------- ##
147735c4bbdfSmrg
147835c4bbdfSmrg# This section contains functions for adding, removing, and running hooks
147935c4bbdfSmrg# to the main code.  A hook is just a named list of of function, that can
148035c4bbdfSmrg# be run in order later on.
148135c4bbdfSmrg
148235c4bbdfSmrg# func_hookable FUNC_NAME
148335c4bbdfSmrg# -----------------------
148435c4bbdfSmrg# Declare that FUNC_NAME will run hooks added with
148535c4bbdfSmrg# 'func_add_hook FUNC_NAME ...'.
148635c4bbdfSmrgfunc_hookable ()
148735c4bbdfSmrg{
148835c4bbdfSmrg    $debug_cmd
148935c4bbdfSmrg
149035c4bbdfSmrg    func_append hookable_fns " $1"
149135c4bbdfSmrg}
149235c4bbdfSmrg
149335c4bbdfSmrg
149435c4bbdfSmrg# func_add_hook FUNC_NAME HOOK_FUNC
149535c4bbdfSmrg# ---------------------------------
149635c4bbdfSmrg# Request that FUNC_NAME call HOOK_FUNC before it returns.  FUNC_NAME must
149735c4bbdfSmrg# first have been declared "hookable" by a call to 'func_hookable'.
149835c4bbdfSmrgfunc_add_hook ()
149935c4bbdfSmrg{
150035c4bbdfSmrg    $debug_cmd
150135c4bbdfSmrg
150235c4bbdfSmrg    case " $hookable_fns " in
150335c4bbdfSmrg      *" $1 "*) ;;
150435c4bbdfSmrg      *) func_fatal_error "'$1' does not accept hook functions." ;;
150535c4bbdfSmrg    esac
150635c4bbdfSmrg
150735c4bbdfSmrg    eval func_append ${1}_hooks '" $2"'
150835c4bbdfSmrg}
150935c4bbdfSmrg
151035c4bbdfSmrg
151135c4bbdfSmrg# func_remove_hook FUNC_NAME HOOK_FUNC
151235c4bbdfSmrg# ------------------------------------
151335c4bbdfSmrg# Remove HOOK_FUNC from the list of functions called by FUNC_NAME.
151435c4bbdfSmrgfunc_remove_hook ()
151535c4bbdfSmrg{
151635c4bbdfSmrg    $debug_cmd
151735c4bbdfSmrg
151835c4bbdfSmrg    eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`'
151935c4bbdfSmrg}
152035c4bbdfSmrg
152135c4bbdfSmrg
152235c4bbdfSmrg# func_run_hooks FUNC_NAME [ARG]...
152335c4bbdfSmrg# ---------------------------------
152435c4bbdfSmrg# Run all hook functions registered to FUNC_NAME.
152535c4bbdfSmrg# It is assumed that the list of hook functions contains nothing more
152635c4bbdfSmrg# than a whitespace-delimited list of legal shell function names, and
152735c4bbdfSmrg# no effort is wasted trying to catch shell meta-characters or preserve
152835c4bbdfSmrg# whitespace.
152935c4bbdfSmrgfunc_run_hooks ()
153035c4bbdfSmrg{
153135c4bbdfSmrg    $debug_cmd
153235c4bbdfSmrg
1533ed6184dfSmrg    _G_rc_run_hooks=false
1534ed6184dfSmrg
153535c4bbdfSmrg    case " $hookable_fns " in
153635c4bbdfSmrg      *" $1 "*) ;;
153735c4bbdfSmrg      *) func_fatal_error "'$1' does not support hook funcions.n" ;;
153835c4bbdfSmrg    esac
153935c4bbdfSmrg
154035c4bbdfSmrg    eval _G_hook_fns=\$$1_hooks; shift
154135c4bbdfSmrg
154235c4bbdfSmrg    for _G_hook in $_G_hook_fns; do
1543ed6184dfSmrg      if eval $_G_hook '"$@"'; then
1544ed6184dfSmrg        # store returned options list back into positional
1545ed6184dfSmrg        # parameters for next 'cmd' execution.
1546ed6184dfSmrg        eval _G_hook_result=\$${_G_hook}_result
1547ed6184dfSmrg        eval set dummy "$_G_hook_result"; shift
1548ed6184dfSmrg        _G_rc_run_hooks=:
1549ed6184dfSmrg      fi
155035c4bbdfSmrg    done
155135c4bbdfSmrg
1552ed6184dfSmrg    $_G_rc_run_hooks && func_run_hooks_result=$_G_hook_result
155335c4bbdfSmrg}
155435c4bbdfSmrg
155535c4bbdfSmrg
155635c4bbdfSmrg
155735c4bbdfSmrg## --------------- ##
155835c4bbdfSmrg## Option parsing. ##
155935c4bbdfSmrg## --------------- ##
156035c4bbdfSmrg
156135c4bbdfSmrg# In order to add your own option parsing hooks, you must accept the
1562ed6184dfSmrg# full positional parameter list in your hook function, you may remove/edit
1563ed6184dfSmrg# any options that you action, and then pass back the remaining unprocessed
156435c4bbdfSmrg# options in '<hooked_function_name>_result', escaped suitably for
1565ed6184dfSmrg# 'eval'.  In this case you also must return $EXIT_SUCCESS to let the
1566ed6184dfSmrg# hook's caller know that it should pay attention to
1567ed6184dfSmrg# '<hooked_function_name>_result'.  Returning $EXIT_FAILURE signalizes that
1568ed6184dfSmrg# arguments are left untouched by the hook and therefore caller will ignore the
1569ed6184dfSmrg# result variable.
1570ed6184dfSmrg#
1571ed6184dfSmrg# Like this:
157235c4bbdfSmrg#
157335c4bbdfSmrg#    my_options_prep ()
157435c4bbdfSmrg#    {
157535c4bbdfSmrg#        $debug_cmd
157635c4bbdfSmrg#
157735c4bbdfSmrg#        # Extend the existing usage message.
157835c4bbdfSmrg#        usage_message=$usage_message'
157935c4bbdfSmrg#      -s, --silent       don'\''t print informational messages
158035c4bbdfSmrg#    '
1581ed6184dfSmrg#        # No change in '$@' (ignored completely by this hook).  There is
1582ed6184dfSmrg#        # no need to do the equivalent (but slower) action:
1583ed6184dfSmrg#        # func_quote_for_eval ${1+"$@"}
1584ed6184dfSmrg#        # my_options_prep_result=$func_quote_for_eval_result
1585ed6184dfSmrg#        false
158635c4bbdfSmrg#    }
158735c4bbdfSmrg#    func_add_hook func_options_prep my_options_prep
158835c4bbdfSmrg#
158935c4bbdfSmrg#
159035c4bbdfSmrg#    my_silent_option ()
159135c4bbdfSmrg#    {
159235c4bbdfSmrg#        $debug_cmd
159335c4bbdfSmrg#
1594ed6184dfSmrg#        args_changed=false
1595ed6184dfSmrg#
159635c4bbdfSmrg#        # Note that for efficiency, we parse as many options as we can
159735c4bbdfSmrg#        # recognise in a loop before passing the remainder back to the
159835c4bbdfSmrg#        # caller on the first unrecognised argument we encounter.
159935c4bbdfSmrg#        while test $# -gt 0; do
160035c4bbdfSmrg#          opt=$1; shift
160135c4bbdfSmrg#          case $opt in
1602ed6184dfSmrg#            --silent|-s) opt_silent=:
1603ed6184dfSmrg#                         args_changed=:
1604ed6184dfSmrg#                         ;;
160535c4bbdfSmrg#            # Separate non-argument short options:
160635c4bbdfSmrg#            -s*)         func_split_short_opt "$_G_opt"
160735c4bbdfSmrg#                         set dummy "$func_split_short_opt_name" \
160835c4bbdfSmrg#                             "-$func_split_short_opt_arg" ${1+"$@"}
160935c4bbdfSmrg#                         shift
1610ed6184dfSmrg#                         args_changed=:
161135c4bbdfSmrg#                         ;;
1612ed6184dfSmrg#            *)           # Make sure the first unrecognised option "$_G_opt"
1613ed6184dfSmrg#                         # is added back to "$@", we could need that later
1614ed6184dfSmrg#                         # if $args_changed is true.
1615ed6184dfSmrg#                         set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
161635c4bbdfSmrg#          esac
161735c4bbdfSmrg#        done
161835c4bbdfSmrg#
1619ed6184dfSmrg#        if $args_changed; then
1620ed6184dfSmrg#          func_quote_for_eval ${1+"$@"}
1621ed6184dfSmrg#          my_silent_option_result=$func_quote_for_eval_result
1622ed6184dfSmrg#        fi
1623ed6184dfSmrg#
1624ed6184dfSmrg#        $args_changed
162535c4bbdfSmrg#    }
162635c4bbdfSmrg#    func_add_hook func_parse_options my_silent_option
162735c4bbdfSmrg#
162835c4bbdfSmrg#
162935c4bbdfSmrg#    my_option_validation ()
163035c4bbdfSmrg#    {
163135c4bbdfSmrg#        $debug_cmd
163235c4bbdfSmrg#
163335c4bbdfSmrg#        $opt_silent && $opt_verbose && func_fatal_help "\
163435c4bbdfSmrg#    '--silent' and '--verbose' options are mutually exclusive."
163535c4bbdfSmrg#
1636ed6184dfSmrg#        false
163735c4bbdfSmrg#    }
163835c4bbdfSmrg#    func_add_hook func_validate_options my_option_validation
163935c4bbdfSmrg#
1640ed6184dfSmrg# You'll also need to manually amend $usage_message to reflect the extra
164135c4bbdfSmrg# options you parse.  It's preferable to append if you can, so that
164235c4bbdfSmrg# multiple option parsing hooks can be added safely.
164335c4bbdfSmrg
164435c4bbdfSmrg
1645ed6184dfSmrg# func_options_finish [ARG]...
1646ed6184dfSmrg# ----------------------------
1647ed6184dfSmrg# Finishing the option parse loop (call 'func_options' hooks ATM).
1648ed6184dfSmrgfunc_options_finish ()
1649ed6184dfSmrg{
1650ed6184dfSmrg    $debug_cmd
1651ed6184dfSmrg
1652ed6184dfSmrg    _G_func_options_finish_exit=false
1653ed6184dfSmrg    if func_run_hooks func_options ${1+"$@"}; then
1654ed6184dfSmrg      func_options_finish_result=$func_run_hooks_result
1655ed6184dfSmrg      _G_func_options_finish_exit=:
1656ed6184dfSmrg    fi
1657ed6184dfSmrg
1658ed6184dfSmrg    $_G_func_options_finish_exit
1659ed6184dfSmrg}
1660ed6184dfSmrg
1661ed6184dfSmrg
166235c4bbdfSmrg# func_options [ARG]...
166335c4bbdfSmrg# ---------------------
166435c4bbdfSmrg# All the functions called inside func_options are hookable. See the
166535c4bbdfSmrg# individual implementations for details.
166635c4bbdfSmrgfunc_hookable func_options
166735c4bbdfSmrgfunc_options ()
166835c4bbdfSmrg{
166935c4bbdfSmrg    $debug_cmd
167035c4bbdfSmrg
1671ed6184dfSmrg    _G_rc_options=false
1672ed6184dfSmrg
1673ed6184dfSmrg    for my_func in options_prep parse_options validate_options options_finish
1674ed6184dfSmrg    do
1675ed6184dfSmrg      if eval func_$my_func '${1+"$@"}'; then
1676ed6184dfSmrg        eval _G_res_var='$'"func_${my_func}_result"
1677ed6184dfSmrg        eval set dummy "$_G_res_var" ; shift
1678ed6184dfSmrg        _G_rc_options=:
1679ed6184dfSmrg      fi
1680ed6184dfSmrg    done
168135c4bbdfSmrg
1682ed6184dfSmrg    # Save modified positional parameters for caller.  As a top-level
1683ed6184dfSmrg    # options-parser function we always need to set the 'func_options_result'
1684ed6184dfSmrg    # variable (regardless the $_G_rc_options value).
1685ed6184dfSmrg    if $_G_rc_options; then
1686ed6184dfSmrg      func_options_result=$_G_res_var
1687ed6184dfSmrg    else
1688ed6184dfSmrg      func_quote_for_eval ${1+"$@"}
1689ed6184dfSmrg      func_options_result=$func_quote_for_eval_result
1690ed6184dfSmrg    fi
169135c4bbdfSmrg
1692ed6184dfSmrg    $_G_rc_options
169335c4bbdfSmrg}
169435c4bbdfSmrg
169535c4bbdfSmrg
169635c4bbdfSmrg# func_options_prep [ARG]...
169735c4bbdfSmrg# --------------------------
169835c4bbdfSmrg# All initialisations required before starting the option parse loop.
169935c4bbdfSmrg# Note that when calling hook functions, we pass through the list of
170035c4bbdfSmrg# positional parameters.  If a hook function modifies that list, and
1701ed6184dfSmrg# needs to propagate that back to rest of this script, then the complete
170235c4bbdfSmrg# modified list must be put in 'func_run_hooks_result' before
1703ed6184dfSmrg# returning $EXIT_SUCCESS (otherwise $EXIT_FAILURE is returned).
170435c4bbdfSmrgfunc_hookable func_options_prep
170535c4bbdfSmrgfunc_options_prep ()
170635c4bbdfSmrg{
170735c4bbdfSmrg    $debug_cmd
170835c4bbdfSmrg
170935c4bbdfSmrg    # Option defaults:
171035c4bbdfSmrg    opt_verbose=false
171135c4bbdfSmrg    opt_warning_types=
171235c4bbdfSmrg
1713ed6184dfSmrg    _G_rc_options_prep=false
1714ed6184dfSmrg    if func_run_hooks func_options_prep ${1+"$@"}; then
1715ed6184dfSmrg      _G_rc_options_prep=:
1716ed6184dfSmrg      # save modified positional parameters for caller
1717ed6184dfSmrg      func_options_prep_result=$func_run_hooks_result
1718ed6184dfSmrg    fi
171935c4bbdfSmrg
1720ed6184dfSmrg    $_G_rc_options_prep
172135c4bbdfSmrg}
172235c4bbdfSmrg
172335c4bbdfSmrg
172435c4bbdfSmrg# func_parse_options [ARG]...
172535c4bbdfSmrg# ---------------------------
172635c4bbdfSmrg# The main option parsing loop.
172735c4bbdfSmrgfunc_hookable func_parse_options
172835c4bbdfSmrgfunc_parse_options ()
172935c4bbdfSmrg{
173035c4bbdfSmrg    $debug_cmd
173135c4bbdfSmrg
173235c4bbdfSmrg    func_parse_options_result=
173335c4bbdfSmrg
1734ed6184dfSmrg    _G_rc_parse_options=false
173535c4bbdfSmrg    # this just eases exit handling
173635c4bbdfSmrg    while test $# -gt 0; do
173735c4bbdfSmrg      # Defer to hook functions for initial option parsing, so they
173835c4bbdfSmrg      # get priority in the event of reusing an option name.
1739ed6184dfSmrg      if func_run_hooks func_parse_options ${1+"$@"}; then
1740ed6184dfSmrg        eval set dummy "$func_run_hooks_result"; shift
1741ed6184dfSmrg        _G_rc_parse_options=:
1742ed6184dfSmrg      fi
174335c4bbdfSmrg
174435c4bbdfSmrg      # Break out of the loop if we already parsed every option.
174535c4bbdfSmrg      test $# -gt 0 || break
174635c4bbdfSmrg
1747ed6184dfSmrg      _G_match_parse_options=:
174835c4bbdfSmrg      _G_opt=$1
174935c4bbdfSmrg      shift
175035c4bbdfSmrg      case $_G_opt in
175135c4bbdfSmrg        --debug|-x)   debug_cmd='set -x'
175235c4bbdfSmrg                      func_echo "enabling shell trace mode"
175335c4bbdfSmrg                      $debug_cmd
175435c4bbdfSmrg                      ;;
175535c4bbdfSmrg
175635c4bbdfSmrg        --no-warnings|--no-warning|--no-warn)
175735c4bbdfSmrg                      set dummy --warnings none ${1+"$@"}
175835c4bbdfSmrg                      shift
175935c4bbdfSmrg		      ;;
176035c4bbdfSmrg
176135c4bbdfSmrg        --warnings|--warning|-W)
1762ed6184dfSmrg                      if test $# = 0 && func_missing_arg $_G_opt; then
1763ed6184dfSmrg                        _G_rc_parse_options=:
1764ed6184dfSmrg                        break
1765ed6184dfSmrg                      fi
176635c4bbdfSmrg                      case " $warning_categories $1" in
176735c4bbdfSmrg                        *" $1 "*)
176835c4bbdfSmrg                          # trailing space prevents matching last $1 above
176935c4bbdfSmrg                          func_append_uniq opt_warning_types " $1"
177035c4bbdfSmrg                          ;;
177135c4bbdfSmrg                        *all)
177235c4bbdfSmrg                          opt_warning_types=$warning_categories
177335c4bbdfSmrg                          ;;
177435c4bbdfSmrg                        *none)
177535c4bbdfSmrg                          opt_warning_types=none
177635c4bbdfSmrg                          warning_func=:
177735c4bbdfSmrg                          ;;
177835c4bbdfSmrg                        *error)
177935c4bbdfSmrg                          opt_warning_types=$warning_categories
178035c4bbdfSmrg                          warning_func=func_fatal_error
178135c4bbdfSmrg                          ;;
178235c4bbdfSmrg                        *)
178335c4bbdfSmrg                          func_fatal_error \
178435c4bbdfSmrg                             "unsupported warning category: '$1'"
178535c4bbdfSmrg                          ;;
178635c4bbdfSmrg                      esac
178735c4bbdfSmrg                      shift
178835c4bbdfSmrg                      ;;
178935c4bbdfSmrg
179035c4bbdfSmrg        --verbose|-v) opt_verbose=: ;;
179135c4bbdfSmrg        --version)    func_version ;;
179235c4bbdfSmrg        -\?|-h)       func_usage ;;
179335c4bbdfSmrg        --help)       func_help ;;
179435c4bbdfSmrg
179535c4bbdfSmrg	# Separate optargs to long options (plugins may need this):
179635c4bbdfSmrg	--*=*)        func_split_equals "$_G_opt"
179735c4bbdfSmrg	              set dummy "$func_split_equals_lhs" \
179835c4bbdfSmrg                          "$func_split_equals_rhs" ${1+"$@"}
179935c4bbdfSmrg                      shift
180035c4bbdfSmrg                      ;;
180135c4bbdfSmrg
180235c4bbdfSmrg       # Separate optargs to short options:
180335c4bbdfSmrg        -W*)
180435c4bbdfSmrg                      func_split_short_opt "$_G_opt"
180535c4bbdfSmrg                      set dummy "$func_split_short_opt_name" \
180635c4bbdfSmrg                          "$func_split_short_opt_arg" ${1+"$@"}
180735c4bbdfSmrg                      shift
180835c4bbdfSmrg                      ;;
180935c4bbdfSmrg
181035c4bbdfSmrg        # Separate non-argument short options:
181135c4bbdfSmrg        -\?*|-h*|-v*|-x*)
181235c4bbdfSmrg                      func_split_short_opt "$_G_opt"
181335c4bbdfSmrg                      set dummy "$func_split_short_opt_name" \
181435c4bbdfSmrg                          "-$func_split_short_opt_arg" ${1+"$@"}
181535c4bbdfSmrg                      shift
181635c4bbdfSmrg                      ;;
181735c4bbdfSmrg
1818ed6184dfSmrg        --)           _G_rc_parse_options=: ; break ;;
181935c4bbdfSmrg        -*)           func_fatal_help "unrecognised option: '$_G_opt'" ;;
1820ed6184dfSmrg        *)            set dummy "$_G_opt" ${1+"$@"}; shift
1821ed6184dfSmrg                      _G_match_parse_options=false
1822ed6184dfSmrg                      break
1823ed6184dfSmrg                      ;;
182435c4bbdfSmrg      esac
1825ed6184dfSmrg
1826ed6184dfSmrg      $_G_match_parse_options && _G_rc_parse_options=:
182735c4bbdfSmrg    done
182835c4bbdfSmrg
1829ed6184dfSmrg
1830ed6184dfSmrg    if $_G_rc_parse_options; then
1831ed6184dfSmrg      # save modified positional parameters for caller
1832ed6184dfSmrg      func_quote_for_eval ${1+"$@"}
1833ed6184dfSmrg      func_parse_options_result=$func_quote_for_eval_result
1834ed6184dfSmrg    fi
1835ed6184dfSmrg
1836ed6184dfSmrg    $_G_rc_parse_options
183735c4bbdfSmrg}
183835c4bbdfSmrg
183935c4bbdfSmrg
184035c4bbdfSmrg# func_validate_options [ARG]...
184135c4bbdfSmrg# ------------------------------
184235c4bbdfSmrg# Perform any sanity checks on option settings and/or unconsumed
184335c4bbdfSmrg# arguments.
184435c4bbdfSmrgfunc_hookable func_validate_options
184535c4bbdfSmrgfunc_validate_options ()
184635c4bbdfSmrg{
184735c4bbdfSmrg    $debug_cmd
184835c4bbdfSmrg
1849ed6184dfSmrg    _G_rc_validate_options=false
1850ed6184dfSmrg
185135c4bbdfSmrg    # Display all warnings if -W was not given.
185235c4bbdfSmrg    test -n "$opt_warning_types" || opt_warning_types=" $warning_categories"
185335c4bbdfSmrg
1854ed6184dfSmrg    if func_run_hooks func_validate_options ${1+"$@"}; then
1855ed6184dfSmrg      # save modified positional parameters for caller
1856ed6184dfSmrg      func_validate_options_result=$func_run_hooks_result
1857ed6184dfSmrg      _G_rc_validate_options=:
1858ed6184dfSmrg    fi
185935c4bbdfSmrg
186035c4bbdfSmrg    # Bail if the options were screwed!
186135c4bbdfSmrg    $exit_cmd $EXIT_FAILURE
186235c4bbdfSmrg
1863ed6184dfSmrg    $_G_rc_validate_options
186435c4bbdfSmrg}
186535c4bbdfSmrg
186635c4bbdfSmrg
186735c4bbdfSmrg
186835c4bbdfSmrg## ----------------- ##
186935c4bbdfSmrg## Helper functions. ##
187035c4bbdfSmrg## ----------------- ##
187135c4bbdfSmrg
187235c4bbdfSmrg# This section contains the helper functions used by the rest of the
187335c4bbdfSmrg# hookable option parser framework in ascii-betical order.
187435c4bbdfSmrg
187535c4bbdfSmrg
187635c4bbdfSmrg# func_fatal_help ARG...
187735c4bbdfSmrg# ----------------------
187835c4bbdfSmrg# Echo program name prefixed message to standard error, followed by
187935c4bbdfSmrg# a help hint, and exit.
188035c4bbdfSmrgfunc_fatal_help ()
188135c4bbdfSmrg{
188235c4bbdfSmrg    $debug_cmd
188335c4bbdfSmrg
188435c4bbdfSmrg    eval \$ECHO \""Usage: $usage"\"
188535c4bbdfSmrg    eval \$ECHO \""$fatal_help"\"
188635c4bbdfSmrg    func_error ${1+"$@"}
188735c4bbdfSmrg    exit $EXIT_FAILURE
188835c4bbdfSmrg}
188935c4bbdfSmrg
189035c4bbdfSmrg
189135c4bbdfSmrg# func_help
189235c4bbdfSmrg# ---------
189335c4bbdfSmrg# Echo long help message to standard output and exit.
189435c4bbdfSmrgfunc_help ()
189535c4bbdfSmrg{
189635c4bbdfSmrg    $debug_cmd
189735c4bbdfSmrg
189835c4bbdfSmrg    func_usage_message
189935c4bbdfSmrg    $ECHO "$long_help_message"
190035c4bbdfSmrg    exit 0
190135c4bbdfSmrg}
190235c4bbdfSmrg
190335c4bbdfSmrg
190435c4bbdfSmrg# func_missing_arg ARGNAME
190535c4bbdfSmrg# ------------------------
190635c4bbdfSmrg# Echo program name prefixed message to standard error and set global
190735c4bbdfSmrg# exit_cmd.
190835c4bbdfSmrgfunc_missing_arg ()
190935c4bbdfSmrg{
191035c4bbdfSmrg    $debug_cmd
191135c4bbdfSmrg
191235c4bbdfSmrg    func_error "Missing argument for '$1'."
191335c4bbdfSmrg    exit_cmd=exit
191435c4bbdfSmrg}
191535c4bbdfSmrg
191635c4bbdfSmrg
191735c4bbdfSmrg# func_split_equals STRING
191835c4bbdfSmrg# ------------------------
191935c4bbdfSmrg# Set func_split_equals_lhs and func_split_equals_rhs shell variables after
192035c4bbdfSmrg# splitting STRING at the '=' sign.
192135c4bbdfSmrgtest -z "$_G_HAVE_XSI_OPS" \
192235c4bbdfSmrg    && (eval 'x=a/b/c;
192335c4bbdfSmrg      test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
192435c4bbdfSmrg    && _G_HAVE_XSI_OPS=yes
192535c4bbdfSmrg
192635c4bbdfSmrgif test yes = "$_G_HAVE_XSI_OPS"
192735c4bbdfSmrgthen
192835c4bbdfSmrg  # This is an XSI compatible shell, allowing a faster implementation...
192935c4bbdfSmrg  eval 'func_split_equals ()
193035c4bbdfSmrg  {
193135c4bbdfSmrg      $debug_cmd
193235c4bbdfSmrg
193335c4bbdfSmrg      func_split_equals_lhs=${1%%=*}
193435c4bbdfSmrg      func_split_equals_rhs=${1#*=}
193535c4bbdfSmrg      test "x$func_split_equals_lhs" = "x$1" \
193635c4bbdfSmrg        && func_split_equals_rhs=
193735c4bbdfSmrg  }'
193835c4bbdfSmrgelse
193935c4bbdfSmrg  # ...otherwise fall back to using expr, which is often a shell builtin.
194035c4bbdfSmrg  func_split_equals ()
194135c4bbdfSmrg  {
194235c4bbdfSmrg      $debug_cmd
194335c4bbdfSmrg
194435c4bbdfSmrg      func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'`
194535c4bbdfSmrg      func_split_equals_rhs=
194635c4bbdfSmrg      test "x$func_split_equals_lhs" = "x$1" \
194735c4bbdfSmrg        || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'`
194835c4bbdfSmrg  }
194935c4bbdfSmrgfi #func_split_equals
195035c4bbdfSmrg
195135c4bbdfSmrg
195235c4bbdfSmrg# func_split_short_opt SHORTOPT
195335c4bbdfSmrg# -----------------------------
195435c4bbdfSmrg# Set func_split_short_opt_name and func_split_short_opt_arg shell
195535c4bbdfSmrg# variables after splitting SHORTOPT after the 2nd character.
195635c4bbdfSmrgif test yes = "$_G_HAVE_XSI_OPS"
195735c4bbdfSmrgthen
195835c4bbdfSmrg  # This is an XSI compatible shell, allowing a faster implementation...
195935c4bbdfSmrg  eval 'func_split_short_opt ()
196035c4bbdfSmrg  {
196135c4bbdfSmrg      $debug_cmd
196235c4bbdfSmrg
196335c4bbdfSmrg      func_split_short_opt_arg=${1#??}
196435c4bbdfSmrg      func_split_short_opt_name=${1%"$func_split_short_opt_arg"}
196535c4bbdfSmrg  }'
196635c4bbdfSmrgelse
196735c4bbdfSmrg  # ...otherwise fall back to using expr, which is often a shell builtin.
196835c4bbdfSmrg  func_split_short_opt ()
196935c4bbdfSmrg  {
197035c4bbdfSmrg      $debug_cmd
197135c4bbdfSmrg
197235c4bbdfSmrg      func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'`
197335c4bbdfSmrg      func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'`
197435c4bbdfSmrg  }
197535c4bbdfSmrgfi #func_split_short_opt
197635c4bbdfSmrg
197735c4bbdfSmrg
197835c4bbdfSmrg# func_usage
197935c4bbdfSmrg# ----------
198035c4bbdfSmrg# Echo short help message to standard output and exit.
198135c4bbdfSmrgfunc_usage ()
198235c4bbdfSmrg{
198335c4bbdfSmrg    $debug_cmd
198435c4bbdfSmrg
198535c4bbdfSmrg    func_usage_message
198635c4bbdfSmrg    $ECHO "Run '$progname --help |${PAGER-more}' for full usage"
198735c4bbdfSmrg    exit 0
198835c4bbdfSmrg}
198935c4bbdfSmrg
199035c4bbdfSmrg
199135c4bbdfSmrg# func_usage_message
199235c4bbdfSmrg# ------------------
199335c4bbdfSmrg# Echo short help message to standard output.
199435c4bbdfSmrgfunc_usage_message ()
199535c4bbdfSmrg{
199635c4bbdfSmrg    $debug_cmd
199735c4bbdfSmrg
199835c4bbdfSmrg    eval \$ECHO \""Usage: $usage"\"
199935c4bbdfSmrg    echo
200035c4bbdfSmrg    $SED -n 's|^# ||
200135c4bbdfSmrg        /^Written by/{
200235c4bbdfSmrg          x;p;x
200335c4bbdfSmrg        }
200435c4bbdfSmrg	h
200535c4bbdfSmrg	/^Written by/q' < "$progpath"
200635c4bbdfSmrg    echo
200735c4bbdfSmrg    eval \$ECHO \""$usage_message"\"
200835c4bbdfSmrg}
200935c4bbdfSmrg
201035c4bbdfSmrg
201135c4bbdfSmrg# func_version
201235c4bbdfSmrg# ------------
201335c4bbdfSmrg# Echo version message to standard output and exit.
201435c4bbdfSmrgfunc_version ()
201535c4bbdfSmrg{
201635c4bbdfSmrg    $debug_cmd
201735c4bbdfSmrg
201835c4bbdfSmrg    printf '%s\n' "$progname $scriptversion"
201935c4bbdfSmrg    $SED -n '
202035c4bbdfSmrg        /(C)/!b go
202135c4bbdfSmrg        :more
202235c4bbdfSmrg        /\./!{
202335c4bbdfSmrg          N
202435c4bbdfSmrg          s|\n# | |
202535c4bbdfSmrg          b more
202635c4bbdfSmrg        }
202735c4bbdfSmrg        :go
202835c4bbdfSmrg        /^# Written by /,/# warranty; / {
202935c4bbdfSmrg          s|^# ||
203035c4bbdfSmrg          s|^# *$||
203135c4bbdfSmrg          s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2|
203235c4bbdfSmrg          p
203335c4bbdfSmrg        }
203435c4bbdfSmrg        /^# Written by / {
203535c4bbdfSmrg          s|^# ||
203635c4bbdfSmrg          p
203735c4bbdfSmrg        }
203835c4bbdfSmrg        /^warranty; /q' < "$progpath"
203935c4bbdfSmrg
204035c4bbdfSmrg    exit $?
204135c4bbdfSmrg}
204235c4bbdfSmrg
204335c4bbdfSmrg
204435c4bbdfSmrg# Local variables:
204535c4bbdfSmrg# mode: shell-script
204635c4bbdfSmrg# sh-indentation: 2
204735c4bbdfSmrg# eval: (add-hook 'before-save-hook 'time-stamp)
204835c4bbdfSmrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
204935c4bbdfSmrg# time-stamp-time-zone: "UTC"
205035c4bbdfSmrg# End:
205135c4bbdfSmrg
205235c4bbdfSmrg# Set a version string.
205335c4bbdfSmrgscriptversion='(GNU libtool) 2.4.6'
205435c4bbdfSmrg
205535c4bbdfSmrg
205635c4bbdfSmrg# func_echo ARG...
205735c4bbdfSmrg# ----------------
205835c4bbdfSmrg# Libtool also displays the current mode in messages, so override
205935c4bbdfSmrg# funclib.sh func_echo with this custom definition.
206035c4bbdfSmrgfunc_echo ()
206135c4bbdfSmrg{
206235c4bbdfSmrg    $debug_cmd
206335c4bbdfSmrg
206435c4bbdfSmrg    _G_message=$*
206535c4bbdfSmrg
206635c4bbdfSmrg    func_echo_IFS=$IFS
206735c4bbdfSmrg    IFS=$nl
206835c4bbdfSmrg    for _G_line in $_G_message; do
206935c4bbdfSmrg      IFS=$func_echo_IFS
207035c4bbdfSmrg      $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line"
207135c4bbdfSmrg    done
207235c4bbdfSmrg    IFS=$func_echo_IFS
207335c4bbdfSmrg}
207435c4bbdfSmrg
207535c4bbdfSmrg
207635c4bbdfSmrg# func_warning ARG...
207735c4bbdfSmrg# -------------------
207835c4bbdfSmrg# Libtool warnings are not categorized, so override funclib.sh
207935c4bbdfSmrg# func_warning with this simpler definition.
208035c4bbdfSmrgfunc_warning ()
208135c4bbdfSmrg{
208235c4bbdfSmrg    $debug_cmd
208335c4bbdfSmrg
208435c4bbdfSmrg    $warning_func ${1+"$@"}
208535c4bbdfSmrg}
208635c4bbdfSmrg
208735c4bbdfSmrg
208835c4bbdfSmrg## ---------------- ##
208935c4bbdfSmrg## Options parsing. ##
209035c4bbdfSmrg## ---------------- ##
209135c4bbdfSmrg
209235c4bbdfSmrg# Hook in the functions to make sure our own options are parsed during
209335c4bbdfSmrg# the option parsing loop.
209435c4bbdfSmrg
209535c4bbdfSmrgusage='$progpath [OPTION]... [MODE-ARG]...'
209635c4bbdfSmrg
209735c4bbdfSmrg# Short help message in response to '-h'.
209835c4bbdfSmrgusage_message="Options:
209935c4bbdfSmrg       --config             show all configuration variables
210035c4bbdfSmrg       --debug              enable verbose shell tracing
210135c4bbdfSmrg   -n, --dry-run            display commands without modifying any files
210235c4bbdfSmrg       --features           display basic configuration information and exit
210335c4bbdfSmrg       --mode=MODE          use operation mode MODE
210435c4bbdfSmrg       --no-warnings        equivalent to '-Wnone'
210535c4bbdfSmrg       --preserve-dup-deps  don't remove duplicate dependency libraries
210635c4bbdfSmrg       --quiet, --silent    don't print informational messages
210735c4bbdfSmrg       --tag=TAG            use configuration variables from tag TAG
210835c4bbdfSmrg   -v, --verbose            print more informational messages than default
210935c4bbdfSmrg       --version            print version information
211035c4bbdfSmrg   -W, --warnings=CATEGORY  report the warnings falling in CATEGORY [all]
211135c4bbdfSmrg   -h, --help, --help-all   print short, long, or detailed help message
211235c4bbdfSmrg"
211335c4bbdfSmrg
211435c4bbdfSmrg# Additional text appended to 'usage_message' in response to '--help'.
211535c4bbdfSmrgfunc_help ()
211635c4bbdfSmrg{
211735c4bbdfSmrg    $debug_cmd
211835c4bbdfSmrg
211935c4bbdfSmrg    func_usage_message
212035c4bbdfSmrg    $ECHO "$long_help_message
212135c4bbdfSmrg
212235c4bbdfSmrgMODE must be one of the following:
212335c4bbdfSmrg
212435c4bbdfSmrg       clean           remove files from the build directory
212535c4bbdfSmrg       compile         compile a source file into a libtool object
212635c4bbdfSmrg       execute         automatically set library path, then run a program
212735c4bbdfSmrg       finish          complete the installation of libtool libraries
212835c4bbdfSmrg       install         install libraries or executables
212935c4bbdfSmrg       link            create a library or an executable
213035c4bbdfSmrg       uninstall       remove libraries from an installed directory
213135c4bbdfSmrg
213235c4bbdfSmrgMODE-ARGS vary depending on the MODE.  When passed as first option,
213335c4bbdfSmrg'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that.
213435c4bbdfSmrgTry '$progname --help --mode=MODE' for a more detailed description of MODE.
213535c4bbdfSmrg
213635c4bbdfSmrgWhen reporting a bug, please describe a test case to reproduce it and
213735c4bbdfSmrginclude the following information:
213835c4bbdfSmrg
213935c4bbdfSmrg       host-triplet:   $host
214035c4bbdfSmrg       shell:          $SHELL
214135c4bbdfSmrg       compiler:       $LTCC
214235c4bbdfSmrg       compiler flags: $LTCFLAGS
214335c4bbdfSmrg       linker:         $LD (gnu? $with_gnu_ld)
2144ed6184dfSmrg       version:        $progname $scriptversion Debian-2.4.6-14
214535c4bbdfSmrg       automake:       `($AUTOMAKE --version) 2>/dev/null |$SED 1q`
214635c4bbdfSmrg       autoconf:       `($AUTOCONF --version) 2>/dev/null |$SED 1q`
214735c4bbdfSmrg
214835c4bbdfSmrgReport bugs to <bug-libtool@gnu.org>.
2149ed6184dfSmrgGNU libtool home page: <http://www.gnu.org/s/libtool/>.
215035c4bbdfSmrgGeneral help using GNU software: <http://www.gnu.org/gethelp/>."
215135c4bbdfSmrg    exit 0
215235c4bbdfSmrg}
215335c4bbdfSmrg
215435c4bbdfSmrg
215535c4bbdfSmrg# func_lo2o OBJECT-NAME
215635c4bbdfSmrg# ---------------------
215735c4bbdfSmrg# Transform OBJECT-NAME from a '.lo' suffix to the platform specific
215835c4bbdfSmrg# object suffix.
215935c4bbdfSmrg
216035c4bbdfSmrglo2o=s/\\.lo\$/.$objext/
216135c4bbdfSmrgo2lo=s/\\.$objext\$/.lo/
216235c4bbdfSmrg
216335c4bbdfSmrgif test yes = "$_G_HAVE_XSI_OPS"; then
216435c4bbdfSmrg  eval 'func_lo2o ()
216535c4bbdfSmrg  {
216635c4bbdfSmrg    case $1 in
216735c4bbdfSmrg      *.lo) func_lo2o_result=${1%.lo}.$objext ;;
216835c4bbdfSmrg      *   ) func_lo2o_result=$1               ;;
216935c4bbdfSmrg    esac
217035c4bbdfSmrg  }'
217135c4bbdfSmrg
217235c4bbdfSmrg  # func_xform LIBOBJ-OR-SOURCE
217335c4bbdfSmrg  # ---------------------------
217435c4bbdfSmrg  # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise)
217535c4bbdfSmrg  # suffix to a '.lo' libtool-object suffix.
217635c4bbdfSmrg  eval 'func_xform ()
217735c4bbdfSmrg  {
217835c4bbdfSmrg    func_xform_result=${1%.*}.lo
217935c4bbdfSmrg  }'
218035c4bbdfSmrgelse
218135c4bbdfSmrg  # ...otherwise fall back to using sed.
218235c4bbdfSmrg  func_lo2o ()
218335c4bbdfSmrg  {
218435c4bbdfSmrg    func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"`
218535c4bbdfSmrg  }
218635c4bbdfSmrg
218735c4bbdfSmrg  func_xform ()
218835c4bbdfSmrg  {
218935c4bbdfSmrg    func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'`
219035c4bbdfSmrg  }
219135c4bbdfSmrgfi
219235c4bbdfSmrg
219335c4bbdfSmrg
219435c4bbdfSmrg# func_fatal_configuration ARG...
219535c4bbdfSmrg# -------------------------------
219635c4bbdfSmrg# Echo program name prefixed message to standard error, followed by
219735c4bbdfSmrg# a configuration failure hint, and exit.
219835c4bbdfSmrgfunc_fatal_configuration ()
219935c4bbdfSmrg{
220025da500fSmrg    func__fatal_error ${1+"$@"} \
220135c4bbdfSmrg      "See the $PACKAGE documentation for more information." \
220235c4bbdfSmrg      "Fatal configuration error."
220335c4bbdfSmrg}
220435c4bbdfSmrg
220535c4bbdfSmrg
220635c4bbdfSmrg# func_config
220735c4bbdfSmrg# -----------
220835c4bbdfSmrg# Display the configuration for all the tags in this script.
220935c4bbdfSmrgfunc_config ()
221035c4bbdfSmrg{
221135c4bbdfSmrg    re_begincf='^# ### BEGIN LIBTOOL'
221235c4bbdfSmrg    re_endcf='^# ### END LIBTOOL'
221335c4bbdfSmrg
221435c4bbdfSmrg    # Default configuration.
221535c4bbdfSmrg    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
221635c4bbdfSmrg
221735c4bbdfSmrg    # Now print the configurations for the tags.
221835c4bbdfSmrg    for tagname in $taglist; do
221935c4bbdfSmrg      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
222035c4bbdfSmrg    done
222135c4bbdfSmrg
222235c4bbdfSmrg    exit $?
222335c4bbdfSmrg}
222435c4bbdfSmrg
222535c4bbdfSmrg
222635c4bbdfSmrg# func_features
222735c4bbdfSmrg# -------------
222835c4bbdfSmrg# Display the features supported by this script.
222935c4bbdfSmrgfunc_features ()
223035c4bbdfSmrg{
223135c4bbdfSmrg    echo "host: $host"
223235c4bbdfSmrg    if test yes = "$build_libtool_libs"; then
223335c4bbdfSmrg      echo "enable shared libraries"
223435c4bbdfSmrg    else
223535c4bbdfSmrg      echo "disable shared libraries"
223635c4bbdfSmrg    fi
223735c4bbdfSmrg    if test yes = "$build_old_libs"; then
223835c4bbdfSmrg      echo "enable static libraries"
223935c4bbdfSmrg    else
224035c4bbdfSmrg      echo "disable static libraries"
224135c4bbdfSmrg    fi
224235c4bbdfSmrg
224335c4bbdfSmrg    exit $?
224435c4bbdfSmrg}
224535c4bbdfSmrg
224635c4bbdfSmrg
224735c4bbdfSmrg# func_enable_tag TAGNAME
224835c4bbdfSmrg# -----------------------
224935c4bbdfSmrg# Verify that TAGNAME is valid, and either flag an error and exit, or
225035c4bbdfSmrg# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
225135c4bbdfSmrg# variable here.
225235c4bbdfSmrgfunc_enable_tag ()
225335c4bbdfSmrg{
225435c4bbdfSmrg    # Global variable:
225535c4bbdfSmrg    tagname=$1
225635c4bbdfSmrg
225735c4bbdfSmrg    re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
225835c4bbdfSmrg    re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
225935c4bbdfSmrg    sed_extractcf=/$re_begincf/,/$re_endcf/p
226035c4bbdfSmrg
226135c4bbdfSmrg    # Validate tagname.
226235c4bbdfSmrg    case $tagname in
226335c4bbdfSmrg      *[!-_A-Za-z0-9,/]*)
226435c4bbdfSmrg        func_fatal_error "invalid tag name: $tagname"
226535c4bbdfSmrg        ;;
226635c4bbdfSmrg    esac
226735c4bbdfSmrg
226835c4bbdfSmrg    # Don't test for the "default" C tag, as we know it's
226935c4bbdfSmrg    # there but not specially marked.
227035c4bbdfSmrg    case $tagname in
227135c4bbdfSmrg        CC) ;;
227235c4bbdfSmrg    *)
227335c4bbdfSmrg        if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
227435c4bbdfSmrg	  taglist="$taglist $tagname"
227535c4bbdfSmrg
227635c4bbdfSmrg	  # Evaluate the configuration.  Be careful to quote the path
227735c4bbdfSmrg	  # and the sed script, to avoid splitting on whitespace, but
227835c4bbdfSmrg	  # also don't use non-portable quotes within backquotes within
227935c4bbdfSmrg	  # quotes we have to do it in 2 steps:
228035c4bbdfSmrg	  extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
228135c4bbdfSmrg	  eval "$extractedcf"
228235c4bbdfSmrg        else
228335c4bbdfSmrg	  func_error "ignoring unknown tag $tagname"
228435c4bbdfSmrg        fi
228535c4bbdfSmrg        ;;
228635c4bbdfSmrg    esac
228735c4bbdfSmrg}
228835c4bbdfSmrg
228935c4bbdfSmrg
229035c4bbdfSmrg# func_check_version_match
229135c4bbdfSmrg# ------------------------
229235c4bbdfSmrg# Ensure that we are using m4 macros, and libtool script from the same
229335c4bbdfSmrg# release of libtool.
229435c4bbdfSmrgfunc_check_version_match ()
229535c4bbdfSmrg{
229635c4bbdfSmrg    if test "$package_revision" != "$macro_revision"; then
229735c4bbdfSmrg      if test "$VERSION" != "$macro_version"; then
229835c4bbdfSmrg        if test -z "$macro_version"; then
229935c4bbdfSmrg          cat >&2 <<_LT_EOF
230035c4bbdfSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
230135c4bbdfSmrg$progname: definition of this LT_INIT comes from an older release.
230235c4bbdfSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
230335c4bbdfSmrg$progname: and run autoconf again.
230435c4bbdfSmrg_LT_EOF
230535c4bbdfSmrg        else
230635c4bbdfSmrg          cat >&2 <<_LT_EOF
230735c4bbdfSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
230835c4bbdfSmrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
230935c4bbdfSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
231035c4bbdfSmrg$progname: and run autoconf again.
231135c4bbdfSmrg_LT_EOF
231235c4bbdfSmrg        fi
231335c4bbdfSmrg      else
231435c4bbdfSmrg        cat >&2 <<_LT_EOF
231535c4bbdfSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
231635c4bbdfSmrg$progname: but the definition of this LT_INIT comes from revision $macro_revision.
231735c4bbdfSmrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision
231835c4bbdfSmrg$progname: of $PACKAGE $VERSION and run autoconf again.
231935c4bbdfSmrg_LT_EOF
232035c4bbdfSmrg      fi
232135c4bbdfSmrg
232235c4bbdfSmrg      exit $EXIT_MISMATCH
232335c4bbdfSmrg    fi
232435c4bbdfSmrg}
232535c4bbdfSmrg
232635c4bbdfSmrg
232735c4bbdfSmrg# libtool_options_prep [ARG]...
232835c4bbdfSmrg# -----------------------------
232935c4bbdfSmrg# Preparation for options parsed by libtool.
233035c4bbdfSmrglibtool_options_prep ()
233135c4bbdfSmrg{
233235c4bbdfSmrg    $debug_mode
233335c4bbdfSmrg
233435c4bbdfSmrg    # Option defaults:
233535c4bbdfSmrg    opt_config=false
233635c4bbdfSmrg    opt_dlopen=
233735c4bbdfSmrg    opt_dry_run=false
233835c4bbdfSmrg    opt_help=false
233935c4bbdfSmrg    opt_mode=
234035c4bbdfSmrg    opt_preserve_dup_deps=false
234135c4bbdfSmrg    opt_quiet=false
234235c4bbdfSmrg
234335c4bbdfSmrg    nonopt=
234435c4bbdfSmrg    preserve_args=
234535c4bbdfSmrg
2346ed6184dfSmrg    _G_rc_lt_options_prep=:
2347ed6184dfSmrg
234835c4bbdfSmrg    # Shorthand for --mode=foo, only valid as the first argument
234935c4bbdfSmrg    case $1 in
235035c4bbdfSmrg    clean|clea|cle|cl)
235135c4bbdfSmrg      shift; set dummy --mode clean ${1+"$@"}; shift
235235c4bbdfSmrg      ;;
235335c4bbdfSmrg    compile|compil|compi|comp|com|co|c)
235435c4bbdfSmrg      shift; set dummy --mode compile ${1+"$@"}; shift
235535c4bbdfSmrg      ;;
235635c4bbdfSmrg    execute|execut|execu|exec|exe|ex|e)
235735c4bbdfSmrg      shift; set dummy --mode execute ${1+"$@"}; shift
235835c4bbdfSmrg      ;;
235935c4bbdfSmrg    finish|finis|fini|fin|fi|f)
236035c4bbdfSmrg      shift; set dummy --mode finish ${1+"$@"}; shift
236135c4bbdfSmrg      ;;
236235c4bbdfSmrg    install|instal|insta|inst|ins|in|i)
236335c4bbdfSmrg      shift; set dummy --mode install ${1+"$@"}; shift
236435c4bbdfSmrg      ;;
236535c4bbdfSmrg    link|lin|li|l)
236635c4bbdfSmrg      shift; set dummy --mode link ${1+"$@"}; shift
236735c4bbdfSmrg      ;;
236835c4bbdfSmrg    uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
236935c4bbdfSmrg      shift; set dummy --mode uninstall ${1+"$@"}; shift
237035c4bbdfSmrg      ;;
2371ed6184dfSmrg    *)
2372ed6184dfSmrg      _G_rc_lt_options_prep=false
2373ed6184dfSmrg      ;;
237435c4bbdfSmrg    esac
237535c4bbdfSmrg
2376ed6184dfSmrg    if $_G_rc_lt_options_prep; then
2377ed6184dfSmrg      # Pass back the list of options.
2378ed6184dfSmrg      func_quote_for_eval ${1+"$@"}
2379ed6184dfSmrg      libtool_options_prep_result=$func_quote_for_eval_result
2380ed6184dfSmrg    fi
2381ed6184dfSmrg
2382ed6184dfSmrg    $_G_rc_lt_options_prep
238335c4bbdfSmrg}
238435c4bbdfSmrgfunc_add_hook func_options_prep libtool_options_prep
238535c4bbdfSmrg
238635c4bbdfSmrg
238735c4bbdfSmrg# libtool_parse_options [ARG]...
238835c4bbdfSmrg# ---------------------------------
238935c4bbdfSmrg# Provide handling for libtool specific options.
239035c4bbdfSmrglibtool_parse_options ()
239135c4bbdfSmrg{
239235c4bbdfSmrg    $debug_cmd
239335c4bbdfSmrg
2394ed6184dfSmrg    _G_rc_lt_parse_options=false
2395ed6184dfSmrg
239635c4bbdfSmrg    # Perform our own loop to consume as many options as possible in
239735c4bbdfSmrg    # each iteration.
239835c4bbdfSmrg    while test $# -gt 0; do
2399ed6184dfSmrg      _G_match_lt_parse_options=:
240035c4bbdfSmrg      _G_opt=$1
240135c4bbdfSmrg      shift
240235c4bbdfSmrg      case $_G_opt in
240335c4bbdfSmrg        --dry-run|--dryrun|-n)
240435c4bbdfSmrg                        opt_dry_run=:
240535c4bbdfSmrg                        ;;
240635c4bbdfSmrg
240735c4bbdfSmrg        --config)       func_config ;;
240835c4bbdfSmrg
240935c4bbdfSmrg        --dlopen|-dlopen)
241035c4bbdfSmrg                        opt_dlopen="${opt_dlopen+$opt_dlopen
241135c4bbdfSmrg}$1"
241235c4bbdfSmrg                        shift
241335c4bbdfSmrg                        ;;
241435c4bbdfSmrg
241535c4bbdfSmrg        --preserve-dup-deps)
241635c4bbdfSmrg                        opt_preserve_dup_deps=: ;;
241735c4bbdfSmrg
241835c4bbdfSmrg        --features)     func_features ;;
241935c4bbdfSmrg
242035c4bbdfSmrg        --finish)       set dummy --mode finish ${1+"$@"}; shift ;;
242135c4bbdfSmrg
242235c4bbdfSmrg        --help)         opt_help=: ;;
242335c4bbdfSmrg
242435c4bbdfSmrg        --help-all)     opt_help=': help-all' ;;
242535c4bbdfSmrg
242635c4bbdfSmrg        --mode)         test $# = 0 && func_missing_arg $_G_opt && break
242735c4bbdfSmrg                        opt_mode=$1
242835c4bbdfSmrg                        case $1 in
242935c4bbdfSmrg                          # Valid mode arguments:
243035c4bbdfSmrg                          clean|compile|execute|finish|install|link|relink|uninstall) ;;
243135c4bbdfSmrg
243235c4bbdfSmrg                          # Catch anything else as an error
243335c4bbdfSmrg                          *) func_error "invalid argument for $_G_opt"
243435c4bbdfSmrg                             exit_cmd=exit
243535c4bbdfSmrg                             break
243635c4bbdfSmrg                             ;;
243735c4bbdfSmrg                        esac
243835c4bbdfSmrg                        shift
243935c4bbdfSmrg                        ;;
244035c4bbdfSmrg
244135c4bbdfSmrg        --no-silent|--no-quiet)
244235c4bbdfSmrg                        opt_quiet=false
244335c4bbdfSmrg                        func_append preserve_args " $_G_opt"
244435c4bbdfSmrg                        ;;
244535c4bbdfSmrg
244635c4bbdfSmrg        --no-warnings|--no-warning|--no-warn)
244735c4bbdfSmrg                        opt_warning=false
244835c4bbdfSmrg                        func_append preserve_args " $_G_opt"
244935c4bbdfSmrg                        ;;
245035c4bbdfSmrg
245135c4bbdfSmrg        --no-verbose)
245235c4bbdfSmrg                        opt_verbose=false
245335c4bbdfSmrg                        func_append preserve_args " $_G_opt"
245435c4bbdfSmrg                        ;;
245535c4bbdfSmrg
245635c4bbdfSmrg        --silent|--quiet)
245735c4bbdfSmrg                        opt_quiet=:
245835c4bbdfSmrg                        opt_verbose=false
245935c4bbdfSmrg                        func_append preserve_args " $_G_opt"
246035c4bbdfSmrg                        ;;
246135c4bbdfSmrg
246235c4bbdfSmrg        --tag)          test $# = 0 && func_missing_arg $_G_opt && break
246335c4bbdfSmrg                        opt_tag=$1
246435c4bbdfSmrg                        func_append preserve_args " $_G_opt $1"
246535c4bbdfSmrg                        func_enable_tag "$1"
246635c4bbdfSmrg                        shift
246735c4bbdfSmrg                        ;;
246835c4bbdfSmrg
246935c4bbdfSmrg        --verbose|-v)   opt_quiet=false
247035c4bbdfSmrg                        opt_verbose=:
247135c4bbdfSmrg                        func_append preserve_args " $_G_opt"
247235c4bbdfSmrg                        ;;
247335c4bbdfSmrg
2474ed6184dfSmrg        # An option not handled by this hook function:
2475ed6184dfSmrg        *)              set dummy "$_G_opt" ${1+"$@"} ; shift
2476ed6184dfSmrg                        _G_match_lt_parse_options=false
2477ed6184dfSmrg                        break
2478ed6184dfSmrg                        ;;
247935c4bbdfSmrg      esac
2480ed6184dfSmrg      $_G_match_lt_parse_options && _G_rc_lt_parse_options=:
248135c4bbdfSmrg    done
248235c4bbdfSmrg
2483ed6184dfSmrg    if $_G_rc_lt_parse_options; then
2484ed6184dfSmrg      # save modified positional parameters for caller
2485ed6184dfSmrg      func_quote_for_eval ${1+"$@"}
2486ed6184dfSmrg      libtool_parse_options_result=$func_quote_for_eval_result
2487ed6184dfSmrg    fi
248835c4bbdfSmrg
2489ed6184dfSmrg    $_G_rc_lt_parse_options
249035c4bbdfSmrg}
249135c4bbdfSmrgfunc_add_hook func_parse_options libtool_parse_options
249235c4bbdfSmrg
249335c4bbdfSmrg
249435c4bbdfSmrg
249535c4bbdfSmrg# libtool_validate_options [ARG]...
249635c4bbdfSmrg# ---------------------------------
249735c4bbdfSmrg# Perform any sanity checks on option settings and/or unconsumed
249835c4bbdfSmrg# arguments.
249935c4bbdfSmrglibtool_validate_options ()
250035c4bbdfSmrg{
250135c4bbdfSmrg    # save first non-option argument
250235c4bbdfSmrg    if test 0 -lt $#; then
250335c4bbdfSmrg      nonopt=$1
250435c4bbdfSmrg      shift
250535c4bbdfSmrg    fi
250635c4bbdfSmrg
250735c4bbdfSmrg    # preserve --debug
250835c4bbdfSmrg    test : = "$debug_cmd" || func_append preserve_args " --debug"
250935c4bbdfSmrg
251035c4bbdfSmrg    case $host in
251135c4bbdfSmrg      # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452
251235c4bbdfSmrg      # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788
251335c4bbdfSmrg      *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*)
251435c4bbdfSmrg        # don't eliminate duplications in $postdeps and $predeps
251535c4bbdfSmrg        opt_duplicate_compiler_generated_deps=:
251635c4bbdfSmrg        ;;
251735c4bbdfSmrg      *)
251835c4bbdfSmrg        opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
251935c4bbdfSmrg        ;;
252035c4bbdfSmrg    esac
252135c4bbdfSmrg
252235c4bbdfSmrg    $opt_help || {
252335c4bbdfSmrg      # Sanity checks first:
252435c4bbdfSmrg      func_check_version_match
252535c4bbdfSmrg
252635c4bbdfSmrg      test yes != "$build_libtool_libs" \
252735c4bbdfSmrg        && test yes != "$build_old_libs" \
252835c4bbdfSmrg        && func_fatal_configuration "not configured to build any kind of library"
252935c4bbdfSmrg
253035c4bbdfSmrg      # Darwin sucks
253135c4bbdfSmrg      eval std_shrext=\"$shrext_cmds\"
253235c4bbdfSmrg
253335c4bbdfSmrg      # Only execute mode is allowed to have -dlopen flags.
253435c4bbdfSmrg      if test -n "$opt_dlopen" && test execute != "$opt_mode"; then
253535c4bbdfSmrg        func_error "unrecognized option '-dlopen'"
253635c4bbdfSmrg        $ECHO "$help" 1>&2
253735c4bbdfSmrg        exit $EXIT_FAILURE
253835c4bbdfSmrg      fi
253935c4bbdfSmrg
254035c4bbdfSmrg      # Change the help message to a mode-specific one.
254135c4bbdfSmrg      generic_help=$help
254235c4bbdfSmrg      help="Try '$progname --help --mode=$opt_mode' for more information."
254335c4bbdfSmrg    }
254435c4bbdfSmrg
254535c4bbdfSmrg    # Pass back the unparsed argument list
254635c4bbdfSmrg    func_quote_for_eval ${1+"$@"}
254735c4bbdfSmrg    libtool_validate_options_result=$func_quote_for_eval_result
254835c4bbdfSmrg}
254935c4bbdfSmrgfunc_add_hook func_validate_options libtool_validate_options
255035c4bbdfSmrg
255135c4bbdfSmrg
255235c4bbdfSmrg# Process options as early as possible so that --help and --version
255335c4bbdfSmrg# can return quickly.
255435c4bbdfSmrgfunc_options ${1+"$@"}
255535c4bbdfSmrgeval set dummy "$func_options_result"; shift
255635c4bbdfSmrg
255735c4bbdfSmrg
255835c4bbdfSmrg
255935c4bbdfSmrg## ----------- ##
256035c4bbdfSmrg##    Main.    ##
256135c4bbdfSmrg## ----------- ##
256235c4bbdfSmrg
256335c4bbdfSmrgmagic='%%%MAGIC variable%%%'
256435c4bbdfSmrgmagic_exe='%%%MAGIC EXE variable%%%'
256505b261ecSmrg
25664642e01fSmrg# Global variables.
25674642e01fSmrgextracted_archives=
25684642e01fSmrgextracted_serial=0
256905b261ecSmrg
257035c4bbdfSmrg# If this variable is set in any of the actions, the command in it
257135c4bbdfSmrg# will be execed at the end.  This prevents here-documents from being
257235c4bbdfSmrg# left over by shells.
257335c4bbdfSmrgexec_cmd=
257435c4bbdfSmrg
257535c4bbdfSmrg
257635c4bbdfSmrg# A function that is used when there is no print builtin or printf.
257735c4bbdfSmrgfunc_fallback_echo ()
257835c4bbdfSmrg{
257935c4bbdfSmrg  eval 'cat <<_LTECHO_EOF
258035c4bbdfSmrg$1
258135c4bbdfSmrg_LTECHO_EOF'
258235c4bbdfSmrg}
258335c4bbdfSmrg
258435c4bbdfSmrg# func_generated_by_libtool
258535c4bbdfSmrg# True iff stdin has been generated by Libtool. This function is only
258635c4bbdfSmrg# a basic sanity check; it will hardly flush out determined imposters.
258735c4bbdfSmrgfunc_generated_by_libtool_p ()
258835c4bbdfSmrg{
258935c4bbdfSmrg  $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
259035c4bbdfSmrg}
259135c4bbdfSmrg
259235c4bbdfSmrg# func_lalib_p file
259335c4bbdfSmrg# True iff FILE is a libtool '.la' library or '.lo' object file.
259435c4bbdfSmrg# This function is only a basic sanity check; it will hardly flush out
259535c4bbdfSmrg# determined imposters.
259635c4bbdfSmrgfunc_lalib_p ()
259735c4bbdfSmrg{
259835c4bbdfSmrg    test -f "$1" &&
259935c4bbdfSmrg      $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p
260035c4bbdfSmrg}
260135c4bbdfSmrg
260235c4bbdfSmrg# func_lalib_unsafe_p file
260335c4bbdfSmrg# True iff FILE is a libtool '.la' library or '.lo' object file.
260435c4bbdfSmrg# This function implements the same check as func_lalib_p without
260535c4bbdfSmrg# resorting to external programs.  To this end, it redirects stdin and
260635c4bbdfSmrg# closes it afterwards, without saving the original file descriptor.
260735c4bbdfSmrg# As a safety measure, use it only where a negative result would be
260835c4bbdfSmrg# fatal anyway.  Works if 'file' does not exist.
260935c4bbdfSmrgfunc_lalib_unsafe_p ()
261035c4bbdfSmrg{
261135c4bbdfSmrg    lalib_p=no
261235c4bbdfSmrg    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
261335c4bbdfSmrg	for lalib_p_l in 1 2 3 4
261435c4bbdfSmrg	do
261535c4bbdfSmrg	    read lalib_p_line
261635c4bbdfSmrg	    case $lalib_p_line in
261735c4bbdfSmrg		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
261835c4bbdfSmrg	    esac
261935c4bbdfSmrg	done
262035c4bbdfSmrg	exec 0<&5 5<&-
262135c4bbdfSmrg    fi
262235c4bbdfSmrg    test yes = "$lalib_p"
262335c4bbdfSmrg}
262435c4bbdfSmrg
262535c4bbdfSmrg# func_ltwrapper_script_p file
262635c4bbdfSmrg# True iff FILE is a libtool wrapper script
262735c4bbdfSmrg# This function is only a basic sanity check; it will hardly flush out
262835c4bbdfSmrg# determined imposters.
262935c4bbdfSmrgfunc_ltwrapper_script_p ()
263035c4bbdfSmrg{
263135c4bbdfSmrg    test -f "$1" &&
263235c4bbdfSmrg      $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p
263335c4bbdfSmrg}
263435c4bbdfSmrg
263535c4bbdfSmrg# func_ltwrapper_executable_p file
263635c4bbdfSmrg# True iff FILE is a libtool wrapper executable
263735c4bbdfSmrg# This function is only a basic sanity check; it will hardly flush out
263835c4bbdfSmrg# determined imposters.
263935c4bbdfSmrgfunc_ltwrapper_executable_p ()
264035c4bbdfSmrg{
264135c4bbdfSmrg    func_ltwrapper_exec_suffix=
264235c4bbdfSmrg    case $1 in
264335c4bbdfSmrg    *.exe) ;;
264435c4bbdfSmrg    *) func_ltwrapper_exec_suffix=.exe ;;
264535c4bbdfSmrg    esac
264635c4bbdfSmrg    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
264735c4bbdfSmrg}
264835c4bbdfSmrg
264935c4bbdfSmrg# func_ltwrapper_scriptname file
265035c4bbdfSmrg# Assumes file is an ltwrapper_executable
265135c4bbdfSmrg# uses $file to determine the appropriate filename for a
265235c4bbdfSmrg# temporary ltwrapper_script.
265335c4bbdfSmrgfunc_ltwrapper_scriptname ()
265435c4bbdfSmrg{
265535c4bbdfSmrg    func_dirname_and_basename "$1" "" "."
265635c4bbdfSmrg    func_stripname '' '.exe' "$func_basename_result"
265735c4bbdfSmrg    func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper
265835c4bbdfSmrg}
265935c4bbdfSmrg
266035c4bbdfSmrg# func_ltwrapper_p file
266135c4bbdfSmrg# True iff FILE is a libtool wrapper script or wrapper executable
266235c4bbdfSmrg# This function is only a basic sanity check; it will hardly flush out
266335c4bbdfSmrg# determined imposters.
266435c4bbdfSmrgfunc_ltwrapper_p ()
266535c4bbdfSmrg{
266635c4bbdfSmrg    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
266735c4bbdfSmrg}
266835c4bbdfSmrg
266935c4bbdfSmrg
267035c4bbdfSmrg# func_execute_cmds commands fail_cmd
267135c4bbdfSmrg# Execute tilde-delimited COMMANDS.
267235c4bbdfSmrg# If FAIL_CMD is given, eval that upon failure.
267335c4bbdfSmrg# FAIL_CMD may read-access the current command in variable CMD!
267435c4bbdfSmrgfunc_execute_cmds ()
267535c4bbdfSmrg{
267635c4bbdfSmrg    $debug_cmd
267735c4bbdfSmrg
267835c4bbdfSmrg    save_ifs=$IFS; IFS='~'
267935c4bbdfSmrg    for cmd in $1; do
268035c4bbdfSmrg      IFS=$sp$nl
268135c4bbdfSmrg      eval cmd=\"$cmd\"
268235c4bbdfSmrg      IFS=$save_ifs
268335c4bbdfSmrg      func_show_eval "$cmd" "${2-:}"
268435c4bbdfSmrg    done
268535c4bbdfSmrg    IFS=$save_ifs
268635c4bbdfSmrg}
268735c4bbdfSmrg
268835c4bbdfSmrg
268935c4bbdfSmrg# func_source file
269035c4bbdfSmrg# Source FILE, adding directory component if necessary.
269135c4bbdfSmrg# Note that it is not necessary on cygwin/mingw to append a dot to
269235c4bbdfSmrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
269335c4bbdfSmrg# behavior happens only for exec(3), not for open(2)!  Also, sourcing
269435c4bbdfSmrg# 'FILE.' does not work on cygwin managed mounts.
269535c4bbdfSmrgfunc_source ()
269635c4bbdfSmrg{
269735c4bbdfSmrg    $debug_cmd
269835c4bbdfSmrg
269935c4bbdfSmrg    case $1 in
270035c4bbdfSmrg    */* | *\\*)	. "$1" ;;
270135c4bbdfSmrg    *)		. "./$1" ;;
270235c4bbdfSmrg    esac
270335c4bbdfSmrg}
270435c4bbdfSmrg
270535c4bbdfSmrg
270635c4bbdfSmrg# func_resolve_sysroot PATH
270735c4bbdfSmrg# Replace a leading = in PATH with a sysroot.  Store the result into
270835c4bbdfSmrg# func_resolve_sysroot_result
270935c4bbdfSmrgfunc_resolve_sysroot ()
271035c4bbdfSmrg{
271135c4bbdfSmrg  func_resolve_sysroot_result=$1
271235c4bbdfSmrg  case $func_resolve_sysroot_result in
271335c4bbdfSmrg  =*)
271435c4bbdfSmrg    func_stripname '=' '' "$func_resolve_sysroot_result"
271535c4bbdfSmrg    func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
271635c4bbdfSmrg    ;;
271735c4bbdfSmrg  esac
271835c4bbdfSmrg}
271935c4bbdfSmrg
272035c4bbdfSmrg# func_replace_sysroot PATH
272135c4bbdfSmrg# If PATH begins with the sysroot, replace it with = and
272235c4bbdfSmrg# store the result into func_replace_sysroot_result.
272335c4bbdfSmrgfunc_replace_sysroot ()
272435c4bbdfSmrg{
272535c4bbdfSmrg  case $lt_sysroot:$1 in
272635c4bbdfSmrg  ?*:"$lt_sysroot"*)
272735c4bbdfSmrg    func_stripname "$lt_sysroot" '' "$1"
272835c4bbdfSmrg    func_replace_sysroot_result='='$func_stripname_result
272935c4bbdfSmrg    ;;
273035c4bbdfSmrg  *)
273135c4bbdfSmrg    # Including no sysroot.
273235c4bbdfSmrg    func_replace_sysroot_result=$1
273335c4bbdfSmrg    ;;
273435c4bbdfSmrg  esac
273535c4bbdfSmrg}
273635c4bbdfSmrg
273735c4bbdfSmrg# func_infer_tag arg
273835c4bbdfSmrg# Infer tagged configuration to use if any are available and
273935c4bbdfSmrg# if one wasn't chosen via the "--tag" command line option.
274035c4bbdfSmrg# Only attempt this if the compiler in the base compile
274135c4bbdfSmrg# command doesn't match the default compiler.
274235c4bbdfSmrg# arg is usually of the form 'gcc ...'
274335c4bbdfSmrgfunc_infer_tag ()
274435c4bbdfSmrg{
274535c4bbdfSmrg    $debug_cmd
274635c4bbdfSmrg
274735c4bbdfSmrg    if test -n "$available_tags" && test -z "$tagname"; then
274835c4bbdfSmrg      CC_quoted=
274935c4bbdfSmrg      for arg in $CC; do
275035c4bbdfSmrg	func_append_quoted CC_quoted "$arg"
275135c4bbdfSmrg      done
275235c4bbdfSmrg      CC_expanded=`func_echo_all $CC`
275335c4bbdfSmrg      CC_quoted_expanded=`func_echo_all $CC_quoted`
275435c4bbdfSmrg      case $@ in
275535c4bbdfSmrg      # Blanks in the command may have been stripped by the calling shell,
275635c4bbdfSmrg      # but not from the CC environment variable when configure was run.
275735c4bbdfSmrg      " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
275835c4bbdfSmrg      " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
275935c4bbdfSmrg      # Blanks at the start of $base_compile will cause this to fail
276035c4bbdfSmrg      # if we don't check for them as well.
276135c4bbdfSmrg      *)
276235c4bbdfSmrg	for z in $available_tags; do
276335c4bbdfSmrg	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
276435c4bbdfSmrg	    # Evaluate the configuration.
276535c4bbdfSmrg	    eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
276635c4bbdfSmrg	    CC_quoted=
276735c4bbdfSmrg	    for arg in $CC; do
276835c4bbdfSmrg	      # Double-quote args containing other shell metacharacters.
276935c4bbdfSmrg	      func_append_quoted CC_quoted "$arg"
277035c4bbdfSmrg	    done
277135c4bbdfSmrg	    CC_expanded=`func_echo_all $CC`
277235c4bbdfSmrg	    CC_quoted_expanded=`func_echo_all $CC_quoted`
277335c4bbdfSmrg	    case "$@ " in
277435c4bbdfSmrg	    " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
277535c4bbdfSmrg	    " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
277635c4bbdfSmrg	      # The compiler in the base compile command matches
277735c4bbdfSmrg	      # the one in the tagged configuration.
277835c4bbdfSmrg	      # Assume this is the tagged configuration we want.
277935c4bbdfSmrg	      tagname=$z
278035c4bbdfSmrg	      break
278135c4bbdfSmrg	      ;;
278235c4bbdfSmrg	    esac
278335c4bbdfSmrg	  fi
278435c4bbdfSmrg	done
278535c4bbdfSmrg	# If $tagname still isn't set, then no tagged configuration
278635c4bbdfSmrg	# was found and let the user know that the "--tag" command
278735c4bbdfSmrg	# line option must be used.
278835c4bbdfSmrg	if test -z "$tagname"; then
278935c4bbdfSmrg	  func_echo "unable to infer tagged configuration"
279035c4bbdfSmrg	  func_fatal_error "specify a tag with '--tag'"
279135c4bbdfSmrg#	else
279235c4bbdfSmrg#	  func_verbose "using $tagname tagged configuration"
279335c4bbdfSmrg	fi
279435c4bbdfSmrg	;;
279535c4bbdfSmrg      esac
279635c4bbdfSmrg    fi
279735c4bbdfSmrg}
279835c4bbdfSmrg
2799475c125cSmrg
28004642e01fSmrg
280135c4bbdfSmrg# func_write_libtool_object output_name pic_name nonpic_name
280235c4bbdfSmrg# Create a libtool object file (analogous to a ".la" file),
280335c4bbdfSmrg# but don't create it if we're doing a dry run.
280435c4bbdfSmrgfunc_write_libtool_object ()
28054642e01fSmrg{
280635c4bbdfSmrg    write_libobj=$1
280735c4bbdfSmrg    if test yes = "$build_libtool_libs"; then
280835c4bbdfSmrg      write_lobj=\'$2\'
280935c4bbdfSmrg    else
281035c4bbdfSmrg      write_lobj=none
281135c4bbdfSmrg    fi
281205b261ecSmrg
281335c4bbdfSmrg    if test yes = "$build_old_libs"; then
281435c4bbdfSmrg      write_oldobj=\'$3\'
281535c4bbdfSmrg    else
281635c4bbdfSmrg      write_oldobj=none
281735c4bbdfSmrg    fi
281805b261ecSmrg
281935c4bbdfSmrg    $opt_dry_run || {
282035c4bbdfSmrg      cat >${write_libobj}T <<EOF
282135c4bbdfSmrg# $write_libobj - a libtool object file
282235c4bbdfSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
282335c4bbdfSmrg#
282435c4bbdfSmrg# Please DO NOT delete this file!
282535c4bbdfSmrg# It is necessary for linking the library.
28264642e01fSmrg
282735c4bbdfSmrg# Name of the PIC object.
282835c4bbdfSmrgpic_object=$write_lobj
282905b261ecSmrg
283035c4bbdfSmrg# Name of the non-PIC object
283135c4bbdfSmrgnon_pic_object=$write_oldobj
283205b261ecSmrg
283335c4bbdfSmrgEOF
283435c4bbdfSmrg      $MV "${write_libobj}T" "$write_libobj"
283535c4bbdfSmrg    }
28364642e01fSmrg}
283705b261ecSmrg
283835c4bbdfSmrg
283935c4bbdfSmrg##################################################
284035c4bbdfSmrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
284135c4bbdfSmrg##################################################
284235c4bbdfSmrg
284335c4bbdfSmrg# func_convert_core_file_wine_to_w32 ARG
284435c4bbdfSmrg# Helper function used by file name conversion functions when $build is *nix,
284535c4bbdfSmrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a
284635c4bbdfSmrg# correctly configured wine environment available, with the winepath program
284735c4bbdfSmrg# in $build's $PATH.
284835c4bbdfSmrg#
284935c4bbdfSmrg# ARG is the $build file name to be converted to w32 format.
285035c4bbdfSmrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will
285135c4bbdfSmrg# be empty on error (or when ARG is empty)
285235c4bbdfSmrgfunc_convert_core_file_wine_to_w32 ()
28534642e01fSmrg{
285435c4bbdfSmrg  $debug_cmd
285535c4bbdfSmrg
285635c4bbdfSmrg  func_convert_core_file_wine_to_w32_result=$1
285735c4bbdfSmrg  if test -n "$1"; then
285835c4bbdfSmrg    # Unfortunately, winepath does not exit with a non-zero error code, so we
285935c4bbdfSmrg    # are forced to check the contents of stdout. On the other hand, if the
286035c4bbdfSmrg    # command is not found, the shell will set an exit code of 127 and print
286135c4bbdfSmrg    # *an error message* to stdout. So we must check for both error code of
286235c4bbdfSmrg    # zero AND non-empty stdout, which explains the odd construction:
286335c4bbdfSmrg    func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
286435c4bbdfSmrg    if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then
286535c4bbdfSmrg      func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
286635c4bbdfSmrg        $SED -e "$sed_naive_backslashify"`
286705b261ecSmrg    else
286835c4bbdfSmrg      func_convert_core_file_wine_to_w32_result=
286905b261ecSmrg    fi
287035c4bbdfSmrg  fi
287135c4bbdfSmrg}
287235c4bbdfSmrg# end: func_convert_core_file_wine_to_w32
28734642e01fSmrg
287435c4bbdfSmrg
287535c4bbdfSmrg# func_convert_core_path_wine_to_w32 ARG
287635c4bbdfSmrg# Helper function used by path conversion functions when $build is *nix, and
287735c4bbdfSmrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
287835c4bbdfSmrg# configured wine environment available, with the winepath program in $build's
287935c4bbdfSmrg# $PATH. Assumes ARG has no leading or trailing path separator characters.
288035c4bbdfSmrg#
288135c4bbdfSmrg# ARG is path to be converted from $build format to win32.
288235c4bbdfSmrg# Result is available in $func_convert_core_path_wine_to_w32_result.
288335c4bbdfSmrg# Unconvertible file (directory) names in ARG are skipped; if no directory names
288435c4bbdfSmrg# are convertible, then the result may be empty.
288535c4bbdfSmrgfunc_convert_core_path_wine_to_w32 ()
288635c4bbdfSmrg{
288735c4bbdfSmrg  $debug_cmd
288835c4bbdfSmrg
288935c4bbdfSmrg  # unfortunately, winepath doesn't convert paths, only file names
289035c4bbdfSmrg  func_convert_core_path_wine_to_w32_result=
289135c4bbdfSmrg  if test -n "$1"; then
289235c4bbdfSmrg    oldIFS=$IFS
289335c4bbdfSmrg    IFS=:
289435c4bbdfSmrg    for func_convert_core_path_wine_to_w32_f in $1; do
289535c4bbdfSmrg      IFS=$oldIFS
289635c4bbdfSmrg      func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
289735c4bbdfSmrg      if test -n "$func_convert_core_file_wine_to_w32_result"; then
289835c4bbdfSmrg        if test -z "$func_convert_core_path_wine_to_w32_result"; then
289935c4bbdfSmrg          func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result
290035c4bbdfSmrg        else
290135c4bbdfSmrg          func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
290235c4bbdfSmrg        fi
290335c4bbdfSmrg      fi
290435c4bbdfSmrg    done
290535c4bbdfSmrg    IFS=$oldIFS
290635c4bbdfSmrg  fi
29074642e01fSmrg}
290835c4bbdfSmrg# end: func_convert_core_path_wine_to_w32
290935c4bbdfSmrg
291035c4bbdfSmrg
291135c4bbdfSmrg# func_cygpath ARGS...
291235c4bbdfSmrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
291335c4bbdfSmrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
291435c4bbdfSmrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
291535c4bbdfSmrg# (2), returns the Cygwin file name or path in func_cygpath_result (input
291635c4bbdfSmrg# file name or path is assumed to be in w32 format, as previously converted
291735c4bbdfSmrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name
291835c4bbdfSmrg# or path in func_cygpath_result (input file name or path is assumed to be in
291935c4bbdfSmrg# Cygwin format). Returns an empty string on error.
292035c4bbdfSmrg#
292135c4bbdfSmrg# ARGS are passed to cygpath, with the last one being the file name or path to
292235c4bbdfSmrg# be converted.
292335c4bbdfSmrg#
292435c4bbdfSmrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
292535c4bbdfSmrg# environment variable; do not put it in $PATH.
292635c4bbdfSmrgfunc_cygpath ()
292735c4bbdfSmrg{
292835c4bbdfSmrg  $debug_cmd
292905b261ecSmrg
293035c4bbdfSmrg  if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
293135c4bbdfSmrg    func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
293235c4bbdfSmrg    if test "$?" -ne 0; then
293335c4bbdfSmrg      # on failure, ensure result is empty
293435c4bbdfSmrg      func_cygpath_result=
293535c4bbdfSmrg    fi
293635c4bbdfSmrg  else
293735c4bbdfSmrg    func_cygpath_result=
293835c4bbdfSmrg    func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'"
293935c4bbdfSmrg  fi
294035c4bbdfSmrg}
294135c4bbdfSmrg#end: func_cygpath
294235c4bbdfSmrg
294335c4bbdfSmrg
294435c4bbdfSmrg# func_convert_core_msys_to_w32 ARG
294535c4bbdfSmrg# Convert file name or path ARG from MSYS format to w32 format.  Return
294635c4bbdfSmrg# result in func_convert_core_msys_to_w32_result.
294735c4bbdfSmrgfunc_convert_core_msys_to_w32 ()
29484642e01fSmrg{
294935c4bbdfSmrg  $debug_cmd
295005b261ecSmrg
295135c4bbdfSmrg  # awkward: cmd appends spaces to result
295235c4bbdfSmrg  func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
295335c4bbdfSmrg    $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"`
295435c4bbdfSmrg}
295535c4bbdfSmrg#end: func_convert_core_msys_to_w32
295605b261ecSmrg
295705b261ecSmrg
295835c4bbdfSmrg# func_convert_file_check ARG1 ARG2
295935c4bbdfSmrg# Verify that ARG1 (a file name in $build format) was converted to $host
296035c4bbdfSmrg# format in ARG2. Otherwise, emit an error message, but continue (resetting
296135c4bbdfSmrg# func_to_host_file_result to ARG1).
296235c4bbdfSmrgfunc_convert_file_check ()
296335c4bbdfSmrg{
296435c4bbdfSmrg  $debug_cmd
296535c4bbdfSmrg
296635c4bbdfSmrg  if test -z "$2" && test -n "$1"; then
296735c4bbdfSmrg    func_error "Could not determine host file name corresponding to"
296835c4bbdfSmrg    func_error "  '$1'"
296935c4bbdfSmrg    func_error "Continuing, but uninstalled executables may not work."
297035c4bbdfSmrg    # Fallback:
297135c4bbdfSmrg    func_to_host_file_result=$1
297235c4bbdfSmrg  fi
29734642e01fSmrg}
297435c4bbdfSmrg# end func_convert_file_check
29754642e01fSmrg
297635c4bbdfSmrg
297735c4bbdfSmrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
297835c4bbdfSmrg# Verify that FROM_PATH (a path in $build format) was converted to $host
297935c4bbdfSmrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting
298035c4bbdfSmrg# func_to_host_file_result to a simplistic fallback value (see below).
298135c4bbdfSmrgfunc_convert_path_check ()
29824642e01fSmrg{
298335c4bbdfSmrg  $debug_cmd
298435c4bbdfSmrg
298535c4bbdfSmrg  if test -z "$4" && test -n "$3"; then
298635c4bbdfSmrg    func_error "Could not determine the host path corresponding to"
298735c4bbdfSmrg    func_error "  '$3'"
298835c4bbdfSmrg    func_error "Continuing, but uninstalled executables may not work."
298935c4bbdfSmrg    # Fallback.  This is a deliberately simplistic "conversion" and
299035c4bbdfSmrg    # should not be "improved".  See libtool.info.
299135c4bbdfSmrg    if test "x$1" != "x$2"; then
299235c4bbdfSmrg      lt_replace_pathsep_chars="s|$1|$2|g"
299335c4bbdfSmrg      func_to_host_path_result=`echo "$3" |
299435c4bbdfSmrg        $SED -e "$lt_replace_pathsep_chars"`
299535c4bbdfSmrg    else
299635c4bbdfSmrg      func_to_host_path_result=$3
299735c4bbdfSmrg    fi
299835c4bbdfSmrg  fi
299935c4bbdfSmrg}
300035c4bbdfSmrg# end func_convert_path_check
30016747b715Smrg
300235c4bbdfSmrg
300335c4bbdfSmrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
300435c4bbdfSmrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
300535c4bbdfSmrg# and appending REPL if ORIG matches BACKPAT.
300635c4bbdfSmrgfunc_convert_path_front_back_pathsep ()
300735c4bbdfSmrg{
300835c4bbdfSmrg  $debug_cmd
300935c4bbdfSmrg
301035c4bbdfSmrg  case $4 in
301135c4bbdfSmrg  $1 ) func_to_host_path_result=$3$func_to_host_path_result
3012475c125cSmrg    ;;
301335c4bbdfSmrg  esac
301435c4bbdfSmrg  case $4 in
301535c4bbdfSmrg  $2 ) func_append func_to_host_path_result "$3"
3016475c125cSmrg    ;;
3017475c125cSmrg  esac
301835c4bbdfSmrg}
301935c4bbdfSmrg# end func_convert_path_front_back_pathsep
30206747b715Smrg
3021475c125cSmrg
302235c4bbdfSmrg##################################################
302335c4bbdfSmrg# $build to $host FILE NAME CONVERSION FUNCTIONS #
302435c4bbdfSmrg##################################################
302535c4bbdfSmrg# invoked via '$to_host_file_cmd ARG'
302635c4bbdfSmrg#
302735c4bbdfSmrg# In each case, ARG is the path to be converted from $build to $host format.
302835c4bbdfSmrg# Result will be available in $func_to_host_file_result.
30294642e01fSmrg
30304642e01fSmrg
303135c4bbdfSmrg# func_to_host_file ARG
303235c4bbdfSmrg# Converts the file name ARG from $build format to $host format. Return result
303335c4bbdfSmrg# in func_to_host_file_result.
303435c4bbdfSmrgfunc_to_host_file ()
303535c4bbdfSmrg{
303635c4bbdfSmrg  $debug_cmd
303735c4bbdfSmrg
303835c4bbdfSmrg  $to_host_file_cmd "$1"
303935c4bbdfSmrg}
304035c4bbdfSmrg# end func_to_host_file
304135c4bbdfSmrg
304235c4bbdfSmrg
304335c4bbdfSmrg# func_to_tool_file ARG LAZY
304435c4bbdfSmrg# converts the file name ARG from $build format to toolchain format. Return
304535c4bbdfSmrg# result in func_to_tool_file_result.  If the conversion in use is listed
304635c4bbdfSmrg# in (the comma separated) LAZY, no conversion takes place.
304735c4bbdfSmrgfunc_to_tool_file ()
304835c4bbdfSmrg{
304935c4bbdfSmrg  $debug_cmd
305035c4bbdfSmrg
305135c4bbdfSmrg  case ,$2, in
305235c4bbdfSmrg    *,"$to_tool_file_cmd",*)
305335c4bbdfSmrg      func_to_tool_file_result=$1
305405b261ecSmrg      ;;
305505b261ecSmrg    *)
305635c4bbdfSmrg      $to_tool_file_cmd "$1"
305735c4bbdfSmrg      func_to_tool_file_result=$func_to_host_file_result
30584642e01fSmrg      ;;
30594642e01fSmrg  esac
306035c4bbdfSmrg}
306135c4bbdfSmrg# end func_to_tool_file
306205b261ecSmrg
306335c4bbdfSmrg
306435c4bbdfSmrg# func_convert_file_noop ARG
306535c4bbdfSmrg# Copy ARG to func_to_host_file_result.
306635c4bbdfSmrgfunc_convert_file_noop ()
306735c4bbdfSmrg{
306835c4bbdfSmrg  func_to_host_file_result=$1
3069475c125cSmrg}
307035c4bbdfSmrg# end func_convert_file_noop
30714642e01fSmrg
307235c4bbdfSmrg
307335c4bbdfSmrg# func_convert_file_msys_to_w32 ARG
307435c4bbdfSmrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
307535c4bbdfSmrg# conversion to w32 is not available inside the cwrapper.  Returns result in
307635c4bbdfSmrg# func_to_host_file_result.
307735c4bbdfSmrgfunc_convert_file_msys_to_w32 ()
3078475c125cSmrg{
307935c4bbdfSmrg  $debug_cmd
30804642e01fSmrg
308135c4bbdfSmrg  func_to_host_file_result=$1
308235c4bbdfSmrg  if test -n "$1"; then
308335c4bbdfSmrg    func_convert_core_msys_to_w32 "$1"
308435c4bbdfSmrg    func_to_host_file_result=$func_convert_core_msys_to_w32_result
3085475c125cSmrg  fi
308635c4bbdfSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
3087475c125cSmrg}
308835c4bbdfSmrg# end func_convert_file_msys_to_w32
30894642e01fSmrg
309005b261ecSmrg
309135c4bbdfSmrg# func_convert_file_cygwin_to_w32 ARG
309235c4bbdfSmrg# Convert file name ARG from Cygwin to w32 format.  Returns result in
309335c4bbdfSmrg# func_to_host_file_result.
309435c4bbdfSmrgfunc_convert_file_cygwin_to_w32 ()
309535c4bbdfSmrg{
309635c4bbdfSmrg  $debug_cmd
30974642e01fSmrg
309835c4bbdfSmrg  func_to_host_file_result=$1
309935c4bbdfSmrg  if test -n "$1"; then
310035c4bbdfSmrg    # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
310135c4bbdfSmrg    # LT_CYGPATH in this case.
310235c4bbdfSmrg    func_to_host_file_result=`cygpath -m "$1"`
3103475c125cSmrg  fi
310435c4bbdfSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
310535c4bbdfSmrg}
310635c4bbdfSmrg# end func_convert_file_cygwin_to_w32
31074642e01fSmrg
3108475c125cSmrg
310935c4bbdfSmrg# func_convert_file_nix_to_w32 ARG
311035c4bbdfSmrg# Convert file name ARG from *nix to w32 format.  Requires a wine environment
311135c4bbdfSmrg# and a working winepath. Returns result in func_to_host_file_result.
311235c4bbdfSmrgfunc_convert_file_nix_to_w32 ()
311335c4bbdfSmrg{
311435c4bbdfSmrg  $debug_cmd
3115475c125cSmrg
311635c4bbdfSmrg  func_to_host_file_result=$1
311735c4bbdfSmrg  if test -n "$1"; then
311835c4bbdfSmrg    func_convert_core_file_wine_to_w32 "$1"
311935c4bbdfSmrg    func_to_host_file_result=$func_convert_core_file_wine_to_w32_result
3120475c125cSmrg  fi
312135c4bbdfSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
3122475c125cSmrg}
312335c4bbdfSmrg# end func_convert_file_nix_to_w32
312405b261ecSmrg
312505b261ecSmrg
312635c4bbdfSmrg# func_convert_file_msys_to_cygwin ARG
312735c4bbdfSmrg# Convert file name ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
312835c4bbdfSmrg# Returns result in func_to_host_file_result.
312935c4bbdfSmrgfunc_convert_file_msys_to_cygwin ()
31304642e01fSmrg{
313135c4bbdfSmrg  $debug_cmd
313205b261ecSmrg
313335c4bbdfSmrg  func_to_host_file_result=$1
313435c4bbdfSmrg  if test -n "$1"; then
313535c4bbdfSmrg    func_convert_core_msys_to_w32 "$1"
313635c4bbdfSmrg    func_cygpath -u "$func_convert_core_msys_to_w32_result"
313735c4bbdfSmrg    func_to_host_file_result=$func_cygpath_result
313835c4bbdfSmrg  fi
313935c4bbdfSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
31404642e01fSmrg}
314135c4bbdfSmrg# end func_convert_file_msys_to_cygwin
314205b261ecSmrg
314305b261ecSmrg
314435c4bbdfSmrg# func_convert_file_nix_to_cygwin ARG
314535c4bbdfSmrg# Convert file name ARG from *nix to Cygwin format.  Requires Cygwin installed
314635c4bbdfSmrg# in a wine environment, working winepath, and LT_CYGPATH set.  Returns result
314735c4bbdfSmrg# in func_to_host_file_result.
314835c4bbdfSmrgfunc_convert_file_nix_to_cygwin ()
31494642e01fSmrg{
315035c4bbdfSmrg  $debug_cmd
315135c4bbdfSmrg
315235c4bbdfSmrg  func_to_host_file_result=$1
315335c4bbdfSmrg  if test -n "$1"; then
315435c4bbdfSmrg    # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
315535c4bbdfSmrg    func_convert_core_file_wine_to_w32 "$1"
315635c4bbdfSmrg    func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
315735c4bbdfSmrg    func_to_host_file_result=$func_cygpath_result
315835c4bbdfSmrg  fi
315935c4bbdfSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
31604642e01fSmrg}
316135c4bbdfSmrg# end func_convert_file_nix_to_cygwin
316205b261ecSmrg
316335c4bbdfSmrg
316435c4bbdfSmrg#############################################
316535c4bbdfSmrg# $build to $host PATH CONVERSION FUNCTIONS #
316635c4bbdfSmrg#############################################
316735c4bbdfSmrg# invoked via '$to_host_path_cmd ARG'
316835c4bbdfSmrg#
316935c4bbdfSmrg# In each case, ARG is the path to be converted from $build to $host format.
317035c4bbdfSmrg# The result will be available in $func_to_host_path_result.
317135c4bbdfSmrg#
317235c4bbdfSmrg# Path separators are also converted from $build format to $host format.  If
317335c4bbdfSmrg# ARG begins or ends with a path separator character, it is preserved (but
317435c4bbdfSmrg# converted to $host format) on output.
317535c4bbdfSmrg#
317635c4bbdfSmrg# All path conversion functions are named using the following convention:
317735c4bbdfSmrg#   file name conversion function    : func_convert_file_X_to_Y ()
317835c4bbdfSmrg#   path conversion function         : func_convert_path_X_to_Y ()
317935c4bbdfSmrg# where, for any given $build/$host combination the 'X_to_Y' value is the
318035c4bbdfSmrg# same.  If conversion functions are added for new $build/$host combinations,
318135c4bbdfSmrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd
318235c4bbdfSmrg# will break.
318335c4bbdfSmrg
318435c4bbdfSmrg
318535c4bbdfSmrg# func_init_to_host_path_cmd
318635c4bbdfSmrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the
318735c4bbdfSmrg# appropriate value, based on the value of $to_host_file_cmd.
318835c4bbdfSmrgto_host_path_cmd=
318935c4bbdfSmrgfunc_init_to_host_path_cmd ()
31904642e01fSmrg{
319135c4bbdfSmrg  $debug_cmd
319235c4bbdfSmrg
319335c4bbdfSmrg  if test -z "$to_host_path_cmd"; then
319435c4bbdfSmrg    func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
319535c4bbdfSmrg    to_host_path_cmd=func_convert_path_$func_stripname_result
319635c4bbdfSmrg  fi
31974642e01fSmrg}
31984642e01fSmrg
319935c4bbdfSmrg
320035c4bbdfSmrg# func_to_host_path ARG
320135c4bbdfSmrg# Converts the path ARG from $build format to $host format. Return result
320235c4bbdfSmrg# in func_to_host_path_result.
320335c4bbdfSmrgfunc_to_host_path ()
32044642e01fSmrg{
320535c4bbdfSmrg  $debug_cmd
320635c4bbdfSmrg
320735c4bbdfSmrg  func_init_to_host_path_cmd
320835c4bbdfSmrg  $to_host_path_cmd "$1"
32094642e01fSmrg}
321035c4bbdfSmrg# end func_to_host_path
32114642e01fSmrg
32124642e01fSmrg
321335c4bbdfSmrg# func_convert_path_noop ARG
321435c4bbdfSmrg# Copy ARG to func_to_host_path_result.
321535c4bbdfSmrgfunc_convert_path_noop ()
32164642e01fSmrg{
321735c4bbdfSmrg  func_to_host_path_result=$1
32184642e01fSmrg}
321935c4bbdfSmrg# end func_convert_path_noop
32204642e01fSmrg
32214642e01fSmrg
322235c4bbdfSmrg# func_convert_path_msys_to_w32 ARG
322335c4bbdfSmrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
322435c4bbdfSmrg# conversion to w32 is not available inside the cwrapper.  Returns result in
322535c4bbdfSmrg# func_to_host_path_result.
322635c4bbdfSmrgfunc_convert_path_msys_to_w32 ()
32274642e01fSmrg{
322835c4bbdfSmrg  $debug_cmd
322935c4bbdfSmrg
323035c4bbdfSmrg  func_to_host_path_result=$1
323135c4bbdfSmrg  if test -n "$1"; then
323235c4bbdfSmrg    # Remove leading and trailing path separator characters from ARG.  MSYS
323335c4bbdfSmrg    # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
323435c4bbdfSmrg    # and winepath ignores them completely.
323535c4bbdfSmrg    func_stripname : : "$1"
323635c4bbdfSmrg    func_to_host_path_tmp1=$func_stripname_result
323735c4bbdfSmrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
323835c4bbdfSmrg    func_to_host_path_result=$func_convert_core_msys_to_w32_result
323935c4bbdfSmrg    func_convert_path_check : ";" \
324035c4bbdfSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
324135c4bbdfSmrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
324235c4bbdfSmrg  fi
32434642e01fSmrg}
324435c4bbdfSmrg# end func_convert_path_msys_to_w32
32454642e01fSmrg
32464642e01fSmrg
324735c4bbdfSmrg# func_convert_path_cygwin_to_w32 ARG
324835c4bbdfSmrg# Convert path ARG from Cygwin to w32 format.  Returns result in
324935c4bbdfSmrg# func_to_host_file_result.
325035c4bbdfSmrgfunc_convert_path_cygwin_to_w32 ()
32514642e01fSmrg{
325235c4bbdfSmrg  $debug_cmd
325335c4bbdfSmrg
325435c4bbdfSmrg  func_to_host_path_result=$1
325535c4bbdfSmrg  if test -n "$1"; then
325635c4bbdfSmrg    # See func_convert_path_msys_to_w32:
325735c4bbdfSmrg    func_stripname : : "$1"
325835c4bbdfSmrg    func_to_host_path_tmp1=$func_stripname_result
325935c4bbdfSmrg    func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
326035c4bbdfSmrg    func_convert_path_check : ";" \
326135c4bbdfSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
326235c4bbdfSmrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
326335c4bbdfSmrg  fi
32646747b715Smrg}
326535c4bbdfSmrg# end func_convert_path_cygwin_to_w32
32666747b715Smrg
32676747b715Smrg
326835c4bbdfSmrg# func_convert_path_nix_to_w32 ARG
326935c4bbdfSmrg# Convert path ARG from *nix to w32 format.  Requires a wine environment and
327035c4bbdfSmrg# a working winepath.  Returns result in func_to_host_file_result.
327135c4bbdfSmrgfunc_convert_path_nix_to_w32 ()
327235c4bbdfSmrg{
327335c4bbdfSmrg  $debug_cmd
32746747b715Smrg
327535c4bbdfSmrg  func_to_host_path_result=$1
327635c4bbdfSmrg  if test -n "$1"; then
327735c4bbdfSmrg    # See func_convert_path_msys_to_w32:
327835c4bbdfSmrg    func_stripname : : "$1"
327935c4bbdfSmrg    func_to_host_path_tmp1=$func_stripname_result
328035c4bbdfSmrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
328135c4bbdfSmrg    func_to_host_path_result=$func_convert_core_path_wine_to_w32_result
328235c4bbdfSmrg    func_convert_path_check : ";" \
328335c4bbdfSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
328435c4bbdfSmrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
328535c4bbdfSmrg  fi
328635c4bbdfSmrg}
328735c4bbdfSmrg# end func_convert_path_nix_to_w32
328835c4bbdfSmrg
328935c4bbdfSmrg
329035c4bbdfSmrg# func_convert_path_msys_to_cygwin ARG
329135c4bbdfSmrg# Convert path ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
329235c4bbdfSmrg# Returns result in func_to_host_file_result.
329335c4bbdfSmrgfunc_convert_path_msys_to_cygwin ()
32946747b715Smrg{
329535c4bbdfSmrg  $debug_cmd
32966747b715Smrg
329735c4bbdfSmrg  func_to_host_path_result=$1
329835c4bbdfSmrg  if test -n "$1"; then
329935c4bbdfSmrg    # See func_convert_path_msys_to_w32:
330035c4bbdfSmrg    func_stripname : : "$1"
330135c4bbdfSmrg    func_to_host_path_tmp1=$func_stripname_result
330235c4bbdfSmrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
330335c4bbdfSmrg    func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
330435c4bbdfSmrg    func_to_host_path_result=$func_cygpath_result
330535c4bbdfSmrg    func_convert_path_check : : \
330635c4bbdfSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
330735c4bbdfSmrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
330835c4bbdfSmrg  fi
330935c4bbdfSmrg}
331035c4bbdfSmrg# end func_convert_path_msys_to_cygwin
33116747b715Smrg
33126747b715Smrg
331335c4bbdfSmrg# func_convert_path_nix_to_cygwin ARG
331435c4bbdfSmrg# Convert path ARG from *nix to Cygwin format.  Requires Cygwin installed in a
331535c4bbdfSmrg# a wine environment, working winepath, and LT_CYGPATH set.  Returns result in
331635c4bbdfSmrg# func_to_host_file_result.
331735c4bbdfSmrgfunc_convert_path_nix_to_cygwin ()
331835c4bbdfSmrg{
331935c4bbdfSmrg  $debug_cmd
33206747b715Smrg
332135c4bbdfSmrg  func_to_host_path_result=$1
332235c4bbdfSmrg  if test -n "$1"; then
332335c4bbdfSmrg    # Remove leading and trailing path separator characters from
332435c4bbdfSmrg    # ARG. msys behavior is inconsistent here, cygpath turns them
332535c4bbdfSmrg    # into '.;' and ';.', and winepath ignores them completely.
332635c4bbdfSmrg    func_stripname : : "$1"
332735c4bbdfSmrg    func_to_host_path_tmp1=$func_stripname_result
332835c4bbdfSmrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
332935c4bbdfSmrg    func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
333035c4bbdfSmrg    func_to_host_path_result=$func_cygpath_result
333135c4bbdfSmrg    func_convert_path_check : : \
333235c4bbdfSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
333335c4bbdfSmrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
333435c4bbdfSmrg  fi
333535c4bbdfSmrg}
333635c4bbdfSmrg# end func_convert_path_nix_to_cygwin
33376747b715Smrg
333835c4bbdfSmrg
333935c4bbdfSmrg# func_dll_def_p FILE
334035c4bbdfSmrg# True iff FILE is a Windows DLL '.def' file.
334135c4bbdfSmrg# Keep in sync with _LT_DLL_DEF_P in libtool.m4
334235c4bbdfSmrgfunc_dll_def_p ()
334335c4bbdfSmrg{
334435c4bbdfSmrg  $debug_cmd
334535c4bbdfSmrg
334635c4bbdfSmrg  func_dll_def_p_tmp=`$SED -n \
334735c4bbdfSmrg    -e 's/^[	 ]*//' \
334835c4bbdfSmrg    -e '/^\(;.*\)*$/d' \
334935c4bbdfSmrg    -e 's/^\(EXPORTS\|LIBRARY\)\([	 ].*\)*$/DEF/p' \
335035c4bbdfSmrg    -e q \
335135c4bbdfSmrg    "$1"`
335235c4bbdfSmrg  test DEF = "$func_dll_def_p_tmp"
33536747b715Smrg}
33546747b715Smrg
335535c4bbdfSmrg
33564642e01fSmrg# func_mode_compile arg...
33574642e01fSmrgfunc_mode_compile ()
33584642e01fSmrg{
335935c4bbdfSmrg    $debug_cmd
336035c4bbdfSmrg
33614642e01fSmrg    # Get the compilation command and the source file.
33624642e01fSmrg    base_compile=
336335c4bbdfSmrg    srcfile=$nonopt  #  always keep a non-empty value in "srcfile"
33644642e01fSmrg    suppress_opt=yes
33654642e01fSmrg    suppress_output=
33664642e01fSmrg    arg_mode=normal
33674642e01fSmrg    libobj=
33684642e01fSmrg    later=
33694642e01fSmrg    pie_flag=
33704642e01fSmrg
33714642e01fSmrg    for arg
33724642e01fSmrg    do
33734642e01fSmrg      case $arg_mode in
33744642e01fSmrg      arg  )
33754642e01fSmrg	# do not "continue".  Instead, add this to base_compile
337635c4bbdfSmrg	lastarg=$arg
33774642e01fSmrg	arg_mode=normal
33784642e01fSmrg	;;
33794642e01fSmrg
33804642e01fSmrg      target )
338135c4bbdfSmrg	libobj=$arg
33824642e01fSmrg	arg_mode=normal
33834642e01fSmrg	continue
33844642e01fSmrg	;;
33854642e01fSmrg
33864642e01fSmrg      normal )
33874642e01fSmrg	# Accept any command-line options.
33884642e01fSmrg	case $arg in
33894642e01fSmrg	-o)
33904642e01fSmrg	  test -n "$libobj" && \
339135c4bbdfSmrg	    func_fatal_error "you cannot specify '-o' more than once"
33924642e01fSmrg	  arg_mode=target
33934642e01fSmrg	  continue
33944642e01fSmrg	  ;;
33954642e01fSmrg
33964642e01fSmrg	-pie | -fpie | -fPIE)
339735c4bbdfSmrg          func_append pie_flag " $arg"
33984642e01fSmrg	  continue
33994642e01fSmrg	  ;;
34004642e01fSmrg
34014642e01fSmrg	-shared | -static | -prefer-pic | -prefer-non-pic)
340235c4bbdfSmrg	  func_append later " $arg"
34034642e01fSmrg	  continue
34044642e01fSmrg	  ;;
34054642e01fSmrg
34064642e01fSmrg	-no-suppress)
340705b261ecSmrg	  suppress_opt=no
340805b261ecSmrg	  continue
340905b261ecSmrg	  ;;
341005b261ecSmrg
341105b261ecSmrg	-Xcompiler)
341205b261ecSmrg	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
341305b261ecSmrg	  continue      #  The current "srcfile" will either be retained or
341405b261ecSmrg	  ;;            #  replaced later.  I would guess that would be a bug.
341505b261ecSmrg
341605b261ecSmrg	-Wc,*)
34174642e01fSmrg	  func_stripname '-Wc,' '' "$arg"
34184642e01fSmrg	  args=$func_stripname_result
341905b261ecSmrg	  lastarg=
342035c4bbdfSmrg	  save_ifs=$IFS; IFS=,
34214642e01fSmrg	  for arg in $args; do
342235c4bbdfSmrg	    IFS=$save_ifs
342335c4bbdfSmrg	    func_append_quoted lastarg "$arg"
342405b261ecSmrg	  done
342535c4bbdfSmrg	  IFS=$save_ifs
34264642e01fSmrg	  func_stripname ' ' '' "$lastarg"
34274642e01fSmrg	  lastarg=$func_stripname_result
342805b261ecSmrg
342905b261ecSmrg	  # Add the arguments to base_compile.
343035c4bbdfSmrg	  func_append base_compile " $lastarg"
343105b261ecSmrg	  continue
343205b261ecSmrg	  ;;
343305b261ecSmrg
34344642e01fSmrg	*)
343505b261ecSmrg	  # Accept the current argument as the source file.
343605b261ecSmrg	  # The previous "srcfile" becomes the current argument.
343705b261ecSmrg	  #
343835c4bbdfSmrg	  lastarg=$srcfile
343935c4bbdfSmrg	  srcfile=$arg
344005b261ecSmrg	  ;;
344105b261ecSmrg	esac  #  case $arg
344205b261ecSmrg	;;
344305b261ecSmrg      esac    #  case $arg_mode
344405b261ecSmrg
344505b261ecSmrg      # Aesthetically quote the previous argument.
344635c4bbdfSmrg      func_append_quoted base_compile "$lastarg"
344705b261ecSmrg    done # for arg
344805b261ecSmrg
344905b261ecSmrg    case $arg_mode in
345005b261ecSmrg    arg)
34514642e01fSmrg      func_fatal_error "you must specify an argument for -Xcompile"
345205b261ecSmrg      ;;
345305b261ecSmrg    target)
345435c4bbdfSmrg      func_fatal_error "you must specify a target with '-o'"
345505b261ecSmrg      ;;
345605b261ecSmrg    *)
345705b261ecSmrg      # Get the name of the library object.
34584642e01fSmrg      test -z "$libobj" && {
34594642e01fSmrg	func_basename "$srcfile"
346035c4bbdfSmrg	libobj=$func_basename_result
34614642e01fSmrg      }
346205b261ecSmrg      ;;
346305b261ecSmrg    esac
346405b261ecSmrg
346505b261ecSmrg    # Recognize several different file suffixes.
346605b261ecSmrg    # If the user specifies -o file.o, it is replaced with file.lo
346705b261ecSmrg    case $libobj in
34684642e01fSmrg    *.[cCFSifmso] | \
34694642e01fSmrg    *.ada | *.adb | *.ads | *.asm | \
34704642e01fSmrg    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
347135c4bbdfSmrg    *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
34724642e01fSmrg      func_xform "$libobj"
34734642e01fSmrg      libobj=$func_xform_result
34744642e01fSmrg      ;;
347505b261ecSmrg    esac
347605b261ecSmrg
347705b261ecSmrg    case $libobj in
34784642e01fSmrg    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
347905b261ecSmrg    *)
348035c4bbdfSmrg      func_fatal_error "cannot determine name of library object from '$libobj'"
348105b261ecSmrg      ;;
348205b261ecSmrg    esac
348305b261ecSmrg
348405b261ecSmrg    func_infer_tag $base_compile
348505b261ecSmrg
348605b261ecSmrg    for arg in $later; do
348705b261ecSmrg      case $arg in
34884642e01fSmrg      -shared)
348935c4bbdfSmrg	test yes = "$build_libtool_libs" \
349035c4bbdfSmrg	  || func_fatal_configuration "cannot build a shared library"
34914642e01fSmrg	build_old_libs=no
34924642e01fSmrg	continue
34934642e01fSmrg	;;
34944642e01fSmrg
349505b261ecSmrg      -static)
34964642e01fSmrg	build_libtool_libs=no
349705b261ecSmrg	build_old_libs=yes
349805b261ecSmrg	continue
349905b261ecSmrg	;;
350005b261ecSmrg
350105b261ecSmrg      -prefer-pic)
350205b261ecSmrg	pic_mode=yes
350305b261ecSmrg	continue
350405b261ecSmrg	;;
350505b261ecSmrg
350605b261ecSmrg      -prefer-non-pic)
350705b261ecSmrg	pic_mode=no
350805b261ecSmrg	continue
350905b261ecSmrg	;;
351005b261ecSmrg      esac
351105b261ecSmrg    done
351205b261ecSmrg
35134642e01fSmrg    func_quote_for_eval "$libobj"
35144642e01fSmrg    test "X$libobj" != "X$func_quote_for_eval_result" \
35154642e01fSmrg      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
351635c4bbdfSmrg      && func_warning "libobj name '$libobj' may not contain shell special characters."
35174642e01fSmrg    func_dirname_and_basename "$obj" "/" ""
351835c4bbdfSmrg    objname=$func_basename_result
351935c4bbdfSmrg    xdir=$func_dirname_result
352035c4bbdfSmrg    lobj=$xdir$objdir/$objname
352105b261ecSmrg
35224642e01fSmrg    test -z "$base_compile" && \
35234642e01fSmrg      func_fatal_help "you must specify a compilation command"
352405b261ecSmrg
352505b261ecSmrg    # Delete any leftover library objects.
352635c4bbdfSmrg    if test yes = "$build_old_libs"; then
352705b261ecSmrg      removelist="$obj $lobj $libobj ${libobj}T"
352805b261ecSmrg    else
352905b261ecSmrg      removelist="$lobj $libobj ${libobj}T"
353005b261ecSmrg    fi
353105b261ecSmrg
353205b261ecSmrg    # On Cygwin there's no "real" PIC flag so we must build both object types
353305b261ecSmrg    case $host_os in
35344642e01fSmrg    cygwin* | mingw* | pw32* | os2* | cegcc*)
353505b261ecSmrg      pic_mode=default
353605b261ecSmrg      ;;
353705b261ecSmrg    esac
353835c4bbdfSmrg    if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then
353905b261ecSmrg      # non-PIC code in shared libraries is not supported
354005b261ecSmrg      pic_mode=default
354105b261ecSmrg    fi
354205b261ecSmrg
354305b261ecSmrg    # Calculate the filename of the output object if compiler does
354405b261ecSmrg    # not support -o with -c
354535c4bbdfSmrg    if test no = "$compiler_c_o"; then
354635c4bbdfSmrg      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext
354735c4bbdfSmrg      lockfile=$output_obj.lock
354805b261ecSmrg    else
354905b261ecSmrg      output_obj=
355005b261ecSmrg      need_locks=no
355105b261ecSmrg      lockfile=
355205b261ecSmrg    fi
355305b261ecSmrg
355405b261ecSmrg    # Lock this critical section if it is needed
355505b261ecSmrg    # We use this script file to make the link, it avoids creating a new file
355635c4bbdfSmrg    if test yes = "$need_locks"; then
35574642e01fSmrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
35584642e01fSmrg	func_echo "Waiting for $lockfile to be removed"
355905b261ecSmrg	sleep 2
356005b261ecSmrg      done
356135c4bbdfSmrg    elif test warn = "$need_locks"; then
356205b261ecSmrg      if test -f "$lockfile"; then
35634642e01fSmrg	$ECHO "\
356405b261ecSmrg*** ERROR, $lockfile exists and contains:
356505b261ecSmrg`cat $lockfile 2>/dev/null`
356605b261ecSmrg
356705b261ecSmrgThis indicates that another process is trying to use the same
356805b261ecSmrgtemporary object file, and libtool could not work around it because
356935c4bbdfSmrgyour compiler does not support '-c' and '-o' together.  If you
357005b261ecSmrgrepeat this compilation, it may succeed, by chance, but you had better
357105b261ecSmrgavoid parallel builds (make -j) in this platform, or get a better
357205b261ecSmrgcompiler."
357305b261ecSmrg
35744642e01fSmrg	$opt_dry_run || $RM $removelist
357505b261ecSmrg	exit $EXIT_FAILURE
357605b261ecSmrg      fi
357735c4bbdfSmrg      func_append removelist " $output_obj"
35784642e01fSmrg      $ECHO "$srcfile" > "$lockfile"
357905b261ecSmrg    fi
358005b261ecSmrg
35814642e01fSmrg    $opt_dry_run || $RM $removelist
358235c4bbdfSmrg    func_append removelist " $lockfile"
35834642e01fSmrg    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
35844642e01fSmrg
358535c4bbdfSmrg    func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
358635c4bbdfSmrg    srcfile=$func_to_tool_file_result
35874642e01fSmrg    func_quote_for_eval "$srcfile"
35884642e01fSmrg    qsrcfile=$func_quote_for_eval_result
358905b261ecSmrg
359005b261ecSmrg    # Only build a PIC object if we are building libtool libraries.
359135c4bbdfSmrg    if test yes = "$build_libtool_libs"; then
359205b261ecSmrg      # Without this assignment, base_compile gets emptied.
359305b261ecSmrg      fbsd_hideous_sh_bug=$base_compile
359405b261ecSmrg
359535c4bbdfSmrg      if test no != "$pic_mode"; then
359605b261ecSmrg	command="$base_compile $qsrcfile $pic_flag"
359705b261ecSmrg      else
359805b261ecSmrg	# Don't build PIC code
359905b261ecSmrg	command="$base_compile $qsrcfile"
360005b261ecSmrg      fi
360105b261ecSmrg
36024642e01fSmrg      func_mkdir_p "$xdir$objdir"
360305b261ecSmrg
360405b261ecSmrg      if test -z "$output_obj"; then
360505b261ecSmrg	# Place PIC objects in $objdir
360635c4bbdfSmrg	func_append command " -o $lobj"
360705b261ecSmrg      fi
360805b261ecSmrg
36094642e01fSmrg      func_show_eval_locale "$command"	\
36104642e01fSmrg          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
361105b261ecSmrg
361235c4bbdfSmrg      if test warn = "$need_locks" &&
361305b261ecSmrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
36144642e01fSmrg	$ECHO "\
361505b261ecSmrg*** ERROR, $lockfile contains:
361605b261ecSmrg`cat $lockfile 2>/dev/null`
361705b261ecSmrg
361805b261ecSmrgbut it should contain:
361905b261ecSmrg$srcfile
362005b261ecSmrg
362105b261ecSmrgThis indicates that another process is trying to use the same
362205b261ecSmrgtemporary object file, and libtool could not work around it because
362335c4bbdfSmrgyour compiler does not support '-c' and '-o' together.  If you
362405b261ecSmrgrepeat this compilation, it may succeed, by chance, but you had better
362505b261ecSmrgavoid parallel builds (make -j) in this platform, or get a better
362605b261ecSmrgcompiler."
362705b261ecSmrg
36284642e01fSmrg	$opt_dry_run || $RM $removelist
362905b261ecSmrg	exit $EXIT_FAILURE
363005b261ecSmrg      fi
363105b261ecSmrg
363205b261ecSmrg      # Just move the object if needed, then go on to compile the next one
363305b261ecSmrg      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
36344642e01fSmrg	func_show_eval '$MV "$output_obj" "$lobj"' \
36354642e01fSmrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
363605b261ecSmrg      fi
363705b261ecSmrg
363805b261ecSmrg      # Allow error messages only from the first compilation.
363935c4bbdfSmrg      if test yes = "$suppress_opt"; then
36404642e01fSmrg	suppress_output=' >/dev/null 2>&1'
364105b261ecSmrg      fi
364205b261ecSmrg    fi
364305b261ecSmrg
364405b261ecSmrg    # Only build a position-dependent object if we build old libraries.
364535c4bbdfSmrg    if test yes = "$build_old_libs"; then
364635c4bbdfSmrg      if test yes != "$pic_mode"; then
364705b261ecSmrg	# Don't build PIC code
36484642e01fSmrg	command="$base_compile $qsrcfile$pie_flag"
364905b261ecSmrg      else
365005b261ecSmrg	command="$base_compile $qsrcfile $pic_flag"
365105b261ecSmrg      fi
365235c4bbdfSmrg      if test yes = "$compiler_c_o"; then
365335c4bbdfSmrg	func_append command " -o $obj"
365405b261ecSmrg      fi
365505b261ecSmrg
365605b261ecSmrg      # Suppress compiler output if we already did a PIC compilation.
365735c4bbdfSmrg      func_append command "$suppress_output"
36584642e01fSmrg      func_show_eval_locale "$command" \
36594642e01fSmrg        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
366005b261ecSmrg
366135c4bbdfSmrg      if test warn = "$need_locks" &&
366205b261ecSmrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
36634642e01fSmrg	$ECHO "\
366405b261ecSmrg*** ERROR, $lockfile contains:
366505b261ecSmrg`cat $lockfile 2>/dev/null`
366605b261ecSmrg
366705b261ecSmrgbut it should contain:
366805b261ecSmrg$srcfile
366905b261ecSmrg
367005b261ecSmrgThis indicates that another process is trying to use the same
367105b261ecSmrgtemporary object file, and libtool could not work around it because
367235c4bbdfSmrgyour compiler does not support '-c' and '-o' together.  If you
367305b261ecSmrgrepeat this compilation, it may succeed, by chance, but you had better
367405b261ecSmrgavoid parallel builds (make -j) in this platform, or get a better
367505b261ecSmrgcompiler."
367605b261ecSmrg
36774642e01fSmrg	$opt_dry_run || $RM $removelist
367805b261ecSmrg	exit $EXIT_FAILURE
367905b261ecSmrg      fi
368005b261ecSmrg
368105b261ecSmrg      # Just move the object if needed
368205b261ecSmrg      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
36834642e01fSmrg	func_show_eval '$MV "$output_obj" "$obj"' \
36844642e01fSmrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
368505b261ecSmrg      fi
368605b261ecSmrg    fi
368705b261ecSmrg
36884642e01fSmrg    $opt_dry_run || {
36894642e01fSmrg      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
369005b261ecSmrg
36914642e01fSmrg      # Unlock the critical section if it was locked
369235c4bbdfSmrg      if test no != "$need_locks"; then
36934642e01fSmrg	removelist=$lockfile
36944642e01fSmrg        $RM "$lockfile"
36954642e01fSmrg      fi
36964642e01fSmrg    }
369705b261ecSmrg
369805b261ecSmrg    exit $EXIT_SUCCESS
36994642e01fSmrg}
370005b261ecSmrg
37014642e01fSmrg$opt_help || {
370235c4bbdfSmrg  test compile = "$opt_mode" && func_mode_compile ${1+"$@"}
37034642e01fSmrg}
370405b261ecSmrg
37054642e01fSmrgfunc_mode_help ()
37064642e01fSmrg{
37074642e01fSmrg    # We need to display help for each of the modes.
370835c4bbdfSmrg    case $opt_mode in
37094642e01fSmrg      "")
37104642e01fSmrg        # Generic help is extracted from the usage comments
37114642e01fSmrg        # at the start of this file.
37124642e01fSmrg        func_help
37134642e01fSmrg        ;;
371405b261ecSmrg
37154642e01fSmrg      clean)
37164642e01fSmrg        $ECHO \
37174642e01fSmrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
371805b261ecSmrg
37194642e01fSmrgRemove files from the build directory.
372005b261ecSmrg
37214642e01fSmrgRM is the name of the program to use to delete files associated with each FILE
372235c4bbdfSmrg(typically '/bin/rm').  RM-OPTIONS are options (such as '-f') to be passed
37234642e01fSmrgto RM.
372405b261ecSmrg
37254642e01fSmrgIf FILE is a libtool library, object or program, all the files associated
37264642e01fSmrgwith it are deleted. Otherwise, only FILE itself is deleted using RM."
37274642e01fSmrg        ;;
372805b261ecSmrg
37294642e01fSmrg      compile)
37304642e01fSmrg      $ECHO \
37314642e01fSmrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
373205b261ecSmrg
37334642e01fSmrgCompile a source file into a libtool library object.
373405b261ecSmrg
37354642e01fSmrgThis mode accepts the following additional options:
373605b261ecSmrg
37374642e01fSmrg  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
37384642e01fSmrg  -no-suppress      do not suppress compiler output for multiple passes
37396747b715Smrg  -prefer-pic       try to build PIC objects only
37406747b715Smrg  -prefer-non-pic   try to build non-PIC objects only
374135c4bbdfSmrg  -shared           do not build a '.o' file suitable for static linking
374235c4bbdfSmrg  -static           only build a '.o' file suitable for static linking
37436747b715Smrg  -Wc,FLAG          pass FLAG directly to the compiler
374405b261ecSmrg
374535c4bbdfSmrgCOMPILE-COMMAND is a command to be used in creating a 'standard' object file
37464642e01fSmrgfrom the given SOURCEFILE.
374705b261ecSmrg
37484642e01fSmrgThe output file name is determined by removing the directory component from
374935c4bbdfSmrgSOURCEFILE, then substituting the C source code suffix '.c' with the
375035c4bbdfSmrglibrary object suffix, '.lo'."
37514642e01fSmrg        ;;
375205b261ecSmrg
37534642e01fSmrg      execute)
37544642e01fSmrg        $ECHO \
37554642e01fSmrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
375605b261ecSmrg
37574642e01fSmrgAutomatically set library path, then run a program.
375805b261ecSmrg
37594642e01fSmrgThis mode accepts the following additional options:
376005b261ecSmrg
37614642e01fSmrg  -dlopen FILE      add the directory containing FILE to the library path
376205b261ecSmrg
376335c4bbdfSmrgThis mode sets the library path environment variable according to '-dlopen'
37644642e01fSmrgflags.
376505b261ecSmrg
37664642e01fSmrgIf any of the ARGS are libtool executable wrappers, then they are translated
37674642e01fSmrginto their corresponding uninstalled binary, and any of their required library
37684642e01fSmrgdirectories are added to the library path.
376905b261ecSmrg
37704642e01fSmrgThen, COMMAND is executed, with ARGS as arguments."
37714642e01fSmrg        ;;
377205b261ecSmrg
37734642e01fSmrg      finish)
37744642e01fSmrg        $ECHO \
37754642e01fSmrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
377605b261ecSmrg
37774642e01fSmrgComplete the installation of libtool libraries.
377805b261ecSmrg
37794642e01fSmrgEach LIBDIR is a directory that contains libtool libraries.
378005b261ecSmrg
37814642e01fSmrgThe commands that this mode executes may require superuser privileges.  Use
378235c4bbdfSmrgthe '--dry-run' option if you just want to see what would be executed."
37834642e01fSmrg        ;;
378405b261ecSmrg
37854642e01fSmrg      install)
37864642e01fSmrg        $ECHO \
37874642e01fSmrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
378805b261ecSmrg
37894642e01fSmrgInstall executables or libraries.
379005b261ecSmrg
37914642e01fSmrgINSTALL-COMMAND is the installation command.  The first component should be
379235c4bbdfSmrgeither the 'install' or 'cp' program.
379305b261ecSmrg
37944642e01fSmrgThe following components of INSTALL-COMMAND are treated specially:
379505b261ecSmrg
37966747b715Smrg  -inst-prefix-dir PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
379705b261ecSmrg
37984642e01fSmrgThe rest of the components are interpreted as arguments to that command (only
37994642e01fSmrgBSD-compatible install options are recognized)."
38004642e01fSmrg        ;;
380105b261ecSmrg
38024642e01fSmrg      link)
38034642e01fSmrg        $ECHO \
38044642e01fSmrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
380505b261ecSmrg
38064642e01fSmrgLink object files or libraries together to form another library, or to
38074642e01fSmrgcreate an executable program.
380805b261ecSmrg
38094642e01fSmrgLINK-COMMAND is a command using the C compiler that you would use to create
38104642e01fSmrga program from several object files.
381105b261ecSmrg
38124642e01fSmrgThe following components of LINK-COMMAND are treated specially:
381305b261ecSmrg
38144642e01fSmrg  -all-static       do not do any dynamic linking at all
38154642e01fSmrg  -avoid-version    do not add a version suffix if possible
38166747b715Smrg  -bindir BINDIR    specify path to binaries directory (for systems where
38176747b715Smrg                    libraries must be found in the PATH setting at runtime)
381835c4bbdfSmrg  -dlopen FILE      '-dlpreopen' FILE if it cannot be dlopened at runtime
38194642e01fSmrg  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
38204642e01fSmrg  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
38214642e01fSmrg  -export-symbols SYMFILE
38224642e01fSmrg                    try to export only the symbols listed in SYMFILE
38234642e01fSmrg  -export-symbols-regex REGEX
38244642e01fSmrg                    try to export only the symbols matching REGEX
38254642e01fSmrg  -LLIBDIR          search LIBDIR for required installed libraries
38264642e01fSmrg  -lNAME            OUTPUT-FILE requires the installed library libNAME
38274642e01fSmrg  -module           build a library that can dlopened
38284642e01fSmrg  -no-fast-install  disable the fast-install mode
38294642e01fSmrg  -no-install       link a not-installable executable
38304642e01fSmrg  -no-undefined     declare that a library does not refer to external symbols
38314642e01fSmrg  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
383235c4bbdfSmrg  -objectlist FILE  use a list of object files found in FILE to specify objects
383335c4bbdfSmrg  -os2dllname NAME  force a short DLL name on OS/2 (no effect on other OSes)
38344642e01fSmrg  -precious-files-regex REGEX
38354642e01fSmrg                    don't remove output files matching REGEX
38364642e01fSmrg  -release RELEASE  specify package release information
38374642e01fSmrg  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
38384642e01fSmrg  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
38394642e01fSmrg  -shared           only do dynamic linking of libtool libraries
38404642e01fSmrg  -shrext SUFFIX    override the standard shared library file extension
38414642e01fSmrg  -static           do not do any dynamic linking of uninstalled libtool libraries
38424642e01fSmrg  -static-libtool-libs
38434642e01fSmrg                    do not do any dynamic linking of libtool libraries
38444642e01fSmrg  -version-info CURRENT[:REVISION[:AGE]]
38454642e01fSmrg                    specify library version info [each variable defaults to 0]
38464642e01fSmrg  -weak LIBNAME     declare that the target provides the LIBNAME interface
38476747b715Smrg  -Wc,FLAG
38486747b715Smrg  -Xcompiler FLAG   pass linker-specific FLAG directly to the compiler
38496747b715Smrg  -Wl,FLAG
38506747b715Smrg  -Xlinker FLAG     pass linker-specific FLAG directly to the linker
38516747b715Smrg  -XCClinker FLAG   pass link-specific FLAG to the compiler driver (CC)
385205b261ecSmrg
385335c4bbdfSmrgAll other options (arguments beginning with '-') are ignored.
385405b261ecSmrg
385535c4bbdfSmrgEvery other argument is treated as a filename.  Files ending in '.la' are
38564642e01fSmrgtreated as uninstalled libtool libraries, other files are standard or library
38574642e01fSmrgobject files.
385805b261ecSmrg
385935c4bbdfSmrgIf the OUTPUT-FILE ends in '.la', then a libtool library is created,
386035c4bbdfSmrgonly library objects ('.lo' files) may be specified, and '-rpath' is
38614642e01fSmrgrequired, except when creating a convenience library.
386205b261ecSmrg
386335c4bbdfSmrgIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created
386435c4bbdfSmrgusing 'ar' and 'ranlib', or on Windows using 'lib'.
386505b261ecSmrg
386635c4bbdfSmrgIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file
38674642e01fSmrgis created, otherwise an executable program is created."
386805b261ecSmrg        ;;
386905b261ecSmrg
38704642e01fSmrg      uninstall)
38714642e01fSmrg        $ECHO \
38724642e01fSmrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
387305b261ecSmrg
38744642e01fSmrgRemove libraries from an installation directory.
387505b261ecSmrg
38764642e01fSmrgRM is the name of the program to use to delete files associated with each FILE
387735c4bbdfSmrg(typically '/bin/rm').  RM-OPTIONS are options (such as '-f') to be passed
38784642e01fSmrgto RM.
387905b261ecSmrg
38804642e01fSmrgIf FILE is a libtool library, all the files associated with it are deleted.
38814642e01fSmrgOtherwise, only FILE itself is deleted using RM."
38824642e01fSmrg        ;;
388305b261ecSmrg
38844642e01fSmrg      *)
388535c4bbdfSmrg        func_fatal_help "invalid operation mode '$opt_mode'"
38864642e01fSmrg        ;;
38874642e01fSmrg    esac
388805b261ecSmrg
38896747b715Smrg    echo
389035c4bbdfSmrg    $ECHO "Try '$progname --help' for more information about other modes."
38914642e01fSmrg}
389205b261ecSmrg
38936747b715Smrg# Now that we've collected a possible --mode arg, show help if necessary
38946747b715Smrgif $opt_help; then
389535c4bbdfSmrg  if test : = "$opt_help"; then
38966747b715Smrg    func_mode_help
38976747b715Smrg  else
38986747b715Smrg    {
38996747b715Smrg      func_help noexit
390035c4bbdfSmrg      for opt_mode in compile link execute install finish uninstall clean; do
39016747b715Smrg	func_mode_help
39026747b715Smrg      done
390335c4bbdfSmrg    } | $SED -n '1p; 2,$s/^Usage:/  or: /p'
39046747b715Smrg    {
39056747b715Smrg      func_help noexit
390635c4bbdfSmrg      for opt_mode in compile link execute install finish uninstall clean; do
39076747b715Smrg	echo
39086747b715Smrg	func_mode_help
39096747b715Smrg      done
39106747b715Smrg    } |
391135c4bbdfSmrg    $SED '1d
39126747b715Smrg      /^When reporting/,/^Report/{
39136747b715Smrg	H
39146747b715Smrg	d
39156747b715Smrg      }
39166747b715Smrg      $x
39176747b715Smrg      /information about other modes/d
39186747b715Smrg      /more detailed .*MODE/d
39196747b715Smrg      s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
39206747b715Smrg  fi
39216747b715Smrg  exit $?
39226747b715Smrgfi
392305b261ecSmrg
392405b261ecSmrg
39254642e01fSmrg# func_mode_execute arg...
39264642e01fSmrgfunc_mode_execute ()
39274642e01fSmrg{
392835c4bbdfSmrg    $debug_cmd
392935c4bbdfSmrg
39304642e01fSmrg    # The first argument is the command name.
393135c4bbdfSmrg    cmd=$nonopt
39324642e01fSmrg    test -z "$cmd" && \
39334642e01fSmrg      func_fatal_help "you must specify a COMMAND"
393405b261ecSmrg
39354642e01fSmrg    # Handle -dlopen flags immediately.
393635c4bbdfSmrg    for file in $opt_dlopen; do
39374642e01fSmrg      test -f "$file" \
393835c4bbdfSmrg	|| func_fatal_help "'$file' is not a file"
393905b261ecSmrg
39404642e01fSmrg      dir=
39414642e01fSmrg      case $file in
39424642e01fSmrg      *.la)
394335c4bbdfSmrg	func_resolve_sysroot "$file"
394435c4bbdfSmrg	file=$func_resolve_sysroot_result
394535c4bbdfSmrg
39464642e01fSmrg	# Check to see that this really is a libtool archive.
39474642e01fSmrg	func_lalib_unsafe_p "$file" \
394835c4bbdfSmrg	  || func_fatal_help "'$lib' is not a valid libtool archive"
394905b261ecSmrg
39504642e01fSmrg	# Read the libtool library.
39514642e01fSmrg	dlname=
39524642e01fSmrg	library_names=
39534642e01fSmrg	func_source "$file"
395405b261ecSmrg
39554642e01fSmrg	# Skip this library if it cannot be dlopened.
39564642e01fSmrg	if test -z "$dlname"; then
39574642e01fSmrg	  # Warn if it was a shared library.
39584642e01fSmrg	  test -n "$library_names" && \
395935c4bbdfSmrg	    func_warning "'$file' was not linked with '-export-dynamic'"
39604642e01fSmrg	  continue
39614642e01fSmrg	fi
396205b261ecSmrg
39634642e01fSmrg	func_dirname "$file" "" "."
396435c4bbdfSmrg	dir=$func_dirname_result
396505b261ecSmrg
39664642e01fSmrg	if test -f "$dir/$objdir/$dlname"; then
396735c4bbdfSmrg	  func_append dir "/$objdir"
39684642e01fSmrg	else
39694642e01fSmrg	  if test ! -f "$dir/$dlname"; then
397035c4bbdfSmrg	    func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'"
39714642e01fSmrg	  fi
39724642e01fSmrg	fi
397305b261ecSmrg	;;
397405b261ecSmrg
39754642e01fSmrg      *.lo)
39764642e01fSmrg	# Just add the directory containing the .lo file.
39774642e01fSmrg	func_dirname "$file" "" "."
397835c4bbdfSmrg	dir=$func_dirname_result
397905b261ecSmrg	;;
398005b261ecSmrg
39814642e01fSmrg      *)
398235c4bbdfSmrg	func_warning "'-dlopen' is ignored for non-libtool libraries and objects"
398305b261ecSmrg	continue
398405b261ecSmrg	;;
39854642e01fSmrg      esac
398605b261ecSmrg
39874642e01fSmrg      # Get the absolute pathname.
39884642e01fSmrg      absdir=`cd "$dir" && pwd`
398935c4bbdfSmrg      test -n "$absdir" && dir=$absdir
399005b261ecSmrg
39914642e01fSmrg      # Now add the directory to shlibpath_var.
39924642e01fSmrg      if eval "test -z \"\$$shlibpath_var\""; then
39934642e01fSmrg	eval "$shlibpath_var=\"\$dir\""
39944642e01fSmrg      else
39954642e01fSmrg	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
39964642e01fSmrg      fi
39974642e01fSmrg    done
399805b261ecSmrg
39994642e01fSmrg    # This variable tells wrapper scripts just to set shlibpath_var
40004642e01fSmrg    # rather than running their programs.
400135c4bbdfSmrg    libtool_execute_magic=$magic
400205b261ecSmrg
40034642e01fSmrg    # Check if any of the arguments is a wrapper script.
40044642e01fSmrg    args=
40054642e01fSmrg    for file
40064642e01fSmrg    do
40074642e01fSmrg      case $file in
40086747b715Smrg      -* | *.la | *.lo ) ;;
40094642e01fSmrg      *)
40104642e01fSmrg	# Do a test to see if this is really a libtool program.
40114642e01fSmrg	if func_ltwrapper_script_p "$file"; then
40124642e01fSmrg	  func_source "$file"
40134642e01fSmrg	  # Transform arg to wrapped name.
401435c4bbdfSmrg	  file=$progdir/$program
40154642e01fSmrg	elif func_ltwrapper_executable_p "$file"; then
40164642e01fSmrg	  func_ltwrapper_scriptname "$file"
40174642e01fSmrg	  func_source "$func_ltwrapper_scriptname_result"
40184642e01fSmrg	  # Transform arg to wrapped name.
401935c4bbdfSmrg	  file=$progdir/$program
40204642e01fSmrg	fi
40214642e01fSmrg	;;
40224642e01fSmrg      esac
40234642e01fSmrg      # Quote arguments (to preserve shell metacharacters).
402435c4bbdfSmrg      func_append_quoted args "$file"
40254642e01fSmrg    done
402605b261ecSmrg
402735c4bbdfSmrg    if $opt_dry_run; then
402835c4bbdfSmrg      # Display what would be done.
402935c4bbdfSmrg      if test -n "$shlibpath_var"; then
403035c4bbdfSmrg	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
403135c4bbdfSmrg	echo "export $shlibpath_var"
403235c4bbdfSmrg      fi
403335c4bbdfSmrg      $ECHO "$cmd$args"
403435c4bbdfSmrg      exit $EXIT_SUCCESS
403535c4bbdfSmrg    else
40364642e01fSmrg      if test -n "$shlibpath_var"; then
40374642e01fSmrg	# Export the shlibpath_var.
40384642e01fSmrg	eval "export $shlibpath_var"
40394642e01fSmrg      fi
404005b261ecSmrg
40414642e01fSmrg      # Restore saved environment variables
40424642e01fSmrg      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
40434642e01fSmrg      do
40444642e01fSmrg	eval "if test \"\${save_$lt_var+set}\" = set; then
40454642e01fSmrg                $lt_var=\$save_$lt_var; export $lt_var
404605b261ecSmrg	      else
40474642e01fSmrg		$lt_unset $lt_var
40484642e01fSmrg	      fi"
40494642e01fSmrg      done
405005b261ecSmrg
40514642e01fSmrg      # Now prepare to actually exec the command.
405235c4bbdfSmrg      exec_cmd=\$cmd$args
40534642e01fSmrg    fi
40544642e01fSmrg}
405505b261ecSmrg
405635c4bbdfSmrgtest execute = "$opt_mode" && func_mode_execute ${1+"$@"}
405705b261ecSmrg
405805b261ecSmrg
40594642e01fSmrg# func_mode_finish arg...
40604642e01fSmrgfunc_mode_finish ()
40614642e01fSmrg{
406235c4bbdfSmrg    $debug_cmd
406335c4bbdfSmrg
406435c4bbdfSmrg    libs=
406535c4bbdfSmrg    libdirs=
40664642e01fSmrg    admincmds=
406705b261ecSmrg
406835c4bbdfSmrg    for opt in "$nonopt" ${1+"$@"}
406935c4bbdfSmrg    do
407035c4bbdfSmrg      if test -d "$opt"; then
407135c4bbdfSmrg	func_append libdirs " $opt"
407235c4bbdfSmrg
407335c4bbdfSmrg      elif test -f "$opt"; then
407435c4bbdfSmrg	if func_lalib_unsafe_p "$opt"; then
407535c4bbdfSmrg	  func_append libs " $opt"
407635c4bbdfSmrg	else
407735c4bbdfSmrg	  func_warning "'$opt' is not a valid libtool archive"
407835c4bbdfSmrg	fi
407935c4bbdfSmrg
408035c4bbdfSmrg      else
408135c4bbdfSmrg	func_fatal_error "invalid argument '$opt'"
408235c4bbdfSmrg      fi
408335c4bbdfSmrg    done
408435c4bbdfSmrg
408535c4bbdfSmrg    if test -n "$libs"; then
408635c4bbdfSmrg      if test -n "$lt_sysroot"; then
408735c4bbdfSmrg        sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
408835c4bbdfSmrg        sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
408935c4bbdfSmrg      else
409035c4bbdfSmrg        sysroot_cmd=
409135c4bbdfSmrg      fi
4092475c125cSmrg
409335c4bbdfSmrg      # Remove sysroot references
409435c4bbdfSmrg      if $opt_dry_run; then
409535c4bbdfSmrg        for lib in $libs; do
409635c4bbdfSmrg          echo "removing references to $lt_sysroot and '=' prefixes from $lib"
409735c4bbdfSmrg        done
409835c4bbdfSmrg      else
409935c4bbdfSmrg        tmpdir=`func_mktempdir`
410035c4bbdfSmrg        for lib in $libs; do
410135c4bbdfSmrg	  $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
410235c4bbdfSmrg	    > $tmpdir/tmp-la
410335c4bbdfSmrg	  mv -f $tmpdir/tmp-la $lib
410435c4bbdfSmrg	done
410535c4bbdfSmrg        ${RM}r "$tmpdir"
410635c4bbdfSmrg      fi
410735c4bbdfSmrg    fi
410835c4bbdfSmrg
410935c4bbdfSmrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
41104642e01fSmrg      for libdir in $libdirs; do
41114642e01fSmrg	if test -n "$finish_cmds"; then
41124642e01fSmrg	  # Do each command in the finish commands.
41134642e01fSmrg	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
41144642e01fSmrg'"$cmd"'"'
411505b261ecSmrg	fi
41164642e01fSmrg	if test -n "$finish_eval"; then
41174642e01fSmrg	  # Do the single finish_eval.
41184642e01fSmrg	  eval cmds=\"$finish_eval\"
411935c4bbdfSmrg	  $opt_dry_run || eval "$cmds" || func_append admincmds "
41204642e01fSmrg       $cmds"
41214642e01fSmrg	fi
41224642e01fSmrg      done
41234642e01fSmrg    fi
412405b261ecSmrg
41254642e01fSmrg    # Exit here if they wanted silent mode.
412635c4bbdfSmrg    $opt_quiet && exit $EXIT_SUCCESS
412705b261ecSmrg
412835c4bbdfSmrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
412935c4bbdfSmrg      echo "----------------------------------------------------------------------"
413035c4bbdfSmrg      echo "Libraries have been installed in:"
413135c4bbdfSmrg      for libdir in $libdirs; do
413235c4bbdfSmrg	$ECHO "   $libdir"
413335c4bbdfSmrg      done
413435c4bbdfSmrg      echo
413535c4bbdfSmrg      echo "If you ever happen to want to link against installed libraries"
413635c4bbdfSmrg      echo "in a given directory, LIBDIR, you must either use libtool, and"
413735c4bbdfSmrg      echo "specify the full pathname of the library, or use the '-LLIBDIR'"
413835c4bbdfSmrg      echo "flag during linking and do at least one of the following:"
413935c4bbdfSmrg      if test -n "$shlibpath_var"; then
414035c4bbdfSmrg	echo "   - add LIBDIR to the '$shlibpath_var' environment variable"
414135c4bbdfSmrg	echo "     during execution"
414235c4bbdfSmrg      fi
414335c4bbdfSmrg      if test -n "$runpath_var"; then
414435c4bbdfSmrg	echo "   - add LIBDIR to the '$runpath_var' environment variable"
414535c4bbdfSmrg	echo "     during linking"
414635c4bbdfSmrg      fi
414735c4bbdfSmrg      if test -n "$hardcode_libdir_flag_spec"; then
414835c4bbdfSmrg	libdir=LIBDIR
414935c4bbdfSmrg	eval flag=\"$hardcode_libdir_flag_spec\"
41504642e01fSmrg
415135c4bbdfSmrg	$ECHO "   - use the '$flag' linker flag"
415235c4bbdfSmrg      fi
415335c4bbdfSmrg      if test -n "$admincmds"; then
415435c4bbdfSmrg	$ECHO "   - have your system administrator run these commands:$admincmds"
415535c4bbdfSmrg      fi
415635c4bbdfSmrg      if test -f /etc/ld.so.conf; then
415735c4bbdfSmrg	echo "   - have your system administrator add LIBDIR to '/etc/ld.so.conf'"
415835c4bbdfSmrg      fi
415935c4bbdfSmrg      echo
4160475c125cSmrg
416135c4bbdfSmrg      echo "See any operating system documentation about shared libraries for"
416235c4bbdfSmrg      case $host in
416335c4bbdfSmrg	solaris2.[6789]|solaris2.1[0-9])
416435c4bbdfSmrg	  echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
416535c4bbdfSmrg	  echo "pages."
416635c4bbdfSmrg	  ;;
416735c4bbdfSmrg	*)
416835c4bbdfSmrg	  echo "more information, such as the ld(1) and ld.so(8) manual pages."
416935c4bbdfSmrg	  ;;
417035c4bbdfSmrg      esac
417135c4bbdfSmrg      echo "----------------------------------------------------------------------"
417235c4bbdfSmrg    fi
41734642e01fSmrg    exit $EXIT_SUCCESS
41744642e01fSmrg}
41754642e01fSmrg
417635c4bbdfSmrgtest finish = "$opt_mode" && func_mode_finish ${1+"$@"}
41774642e01fSmrg
41784642e01fSmrg
41794642e01fSmrg# func_mode_install arg...
41804642e01fSmrgfunc_mode_install ()
41814642e01fSmrg{
418235c4bbdfSmrg    $debug_cmd
418335c4bbdfSmrg
41844642e01fSmrg    # There may be an optional sh(1) argument at the beginning of
41854642e01fSmrg    # install_prog (especially on Windows NT).
418635c4bbdfSmrg    if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" ||
41874642e01fSmrg       # Allow the use of GNU shtool's install command.
418835c4bbdfSmrg       case $nonopt in *shtool*) :;; *) false;; esac
418935c4bbdfSmrg    then
41904642e01fSmrg      # Aesthetically quote it.
41914642e01fSmrg      func_quote_for_eval "$nonopt"
41924642e01fSmrg      install_prog="$func_quote_for_eval_result "
41934642e01fSmrg      arg=$1
41944642e01fSmrg      shift
41954642e01fSmrg    else
41964642e01fSmrg      install_prog=
41974642e01fSmrg      arg=$nonopt
41984642e01fSmrg    fi
41994642e01fSmrg
42004642e01fSmrg    # The real first argument should be the name of the installation program.
42014642e01fSmrg    # Aesthetically quote it.
42024642e01fSmrg    func_quote_for_eval "$arg"
420335c4bbdfSmrg    func_append install_prog "$func_quote_for_eval_result"
42046747b715Smrg    install_shared_prog=$install_prog
42056747b715Smrg    case " $install_prog " in
42066747b715Smrg      *[\\\ /]cp\ *) install_cp=: ;;
42076747b715Smrg      *) install_cp=false ;;
42086747b715Smrg    esac
42094642e01fSmrg
42104642e01fSmrg    # We need to accept at least all the BSD install flags.
42114642e01fSmrg    dest=
42124642e01fSmrg    files=
42134642e01fSmrg    opts=
42144642e01fSmrg    prev=
42154642e01fSmrg    install_type=
421635c4bbdfSmrg    isdir=false
42174642e01fSmrg    stripme=
42186747b715Smrg    no_mode=:
42194642e01fSmrg    for arg
42204642e01fSmrg    do
42216747b715Smrg      arg2=
42224642e01fSmrg      if test -n "$dest"; then
422335c4bbdfSmrg	func_append files " $dest"
42244642e01fSmrg	dest=$arg
42254642e01fSmrg	continue
42264642e01fSmrg      fi
42274642e01fSmrg
42284642e01fSmrg      case $arg in
422935c4bbdfSmrg      -d) isdir=: ;;
42304642e01fSmrg      -f)
42316747b715Smrg	if $install_cp; then :; else
42326747b715Smrg	  prev=$arg
42336747b715Smrg	fi
42344642e01fSmrg	;;
42354642e01fSmrg      -g | -m | -o)
42364642e01fSmrg	prev=$arg
42374642e01fSmrg	;;
42384642e01fSmrg      -s)
42394642e01fSmrg	stripme=" -s"
42404642e01fSmrg	continue
42414642e01fSmrg	;;
42424642e01fSmrg      -*)
42434642e01fSmrg	;;
42444642e01fSmrg      *)
42454642e01fSmrg	# If the previous option needed an argument, then skip it.
42464642e01fSmrg	if test -n "$prev"; then
424735c4bbdfSmrg	  if test X-m = "X$prev" && test -n "$install_override_mode"; then
42486747b715Smrg	    arg2=$install_override_mode
42496747b715Smrg	    no_mode=false
42506747b715Smrg	  fi
425105b261ecSmrg	  prev=
425205b261ecSmrg	else
42534642e01fSmrg	  dest=$arg
42544642e01fSmrg	  continue
425505b261ecSmrg	fi
425605b261ecSmrg	;;
42574642e01fSmrg      esac
425805b261ecSmrg
42594642e01fSmrg      # Aesthetically quote the argument.
42604642e01fSmrg      func_quote_for_eval "$arg"
426135c4bbdfSmrg      func_append install_prog " $func_quote_for_eval_result"
42626747b715Smrg      if test -n "$arg2"; then
42636747b715Smrg	func_quote_for_eval "$arg2"
42646747b715Smrg      fi
426535c4bbdfSmrg      func_append install_shared_prog " $func_quote_for_eval_result"
42664642e01fSmrg    done
426705b261ecSmrg
42684642e01fSmrg    test -z "$install_prog" && \
42694642e01fSmrg      func_fatal_help "you must specify an install program"
427005b261ecSmrg
42714642e01fSmrg    test -n "$prev" && \
427235c4bbdfSmrg      func_fatal_help "the '$prev' option requires an argument"
427305b261ecSmrg
42746747b715Smrg    if test -n "$install_override_mode" && $no_mode; then
42756747b715Smrg      if $install_cp; then :; else
42766747b715Smrg	func_quote_for_eval "$install_override_mode"
427735c4bbdfSmrg	func_append install_shared_prog " -m $func_quote_for_eval_result"
42786747b715Smrg      fi
42796747b715Smrg    fi
42806747b715Smrg
42814642e01fSmrg    if test -z "$files"; then
42824642e01fSmrg      if test -z "$dest"; then
42834642e01fSmrg	func_fatal_help "no file or destination specified"
42844642e01fSmrg      else
42854642e01fSmrg	func_fatal_help "you must specify a destination"
42864642e01fSmrg      fi
428705b261ecSmrg    fi
428805b261ecSmrg
42894642e01fSmrg    # Strip any trailing slash from the destination.
42904642e01fSmrg    func_stripname '' '/' "$dest"
42914642e01fSmrg    dest=$func_stripname_result
429205b261ecSmrg
42934642e01fSmrg    # Check to see that the destination is a directory.
429435c4bbdfSmrg    test -d "$dest" && isdir=:
429535c4bbdfSmrg    if $isdir; then
429635c4bbdfSmrg      destdir=$dest
42974642e01fSmrg      destname=
429805b261ecSmrg    else
42994642e01fSmrg      func_dirname_and_basename "$dest" "" "."
430035c4bbdfSmrg      destdir=$func_dirname_result
430135c4bbdfSmrg      destname=$func_basename_result
430205b261ecSmrg
43034642e01fSmrg      # Not a directory, so check to see that there is only one file specified.
43044642e01fSmrg      set dummy $files; shift
43054642e01fSmrg      test "$#" -gt 1 && \
430635c4bbdfSmrg	func_fatal_help "'$dest' is not a directory"
430705b261ecSmrg    fi
43084642e01fSmrg    case $destdir in
43094642e01fSmrg    [\\/]* | [A-Za-z]:[\\/]*) ;;
431005b261ecSmrg    *)
43114642e01fSmrg      for file in $files; do
43124642e01fSmrg	case $file in
43134642e01fSmrg	*.lo) ;;
43144642e01fSmrg	*)
431535c4bbdfSmrg	  func_fatal_help "'$destdir' must be an absolute directory name"
43164642e01fSmrg	  ;;
43174642e01fSmrg	esac
43184642e01fSmrg      done
431905b261ecSmrg      ;;
432005b261ecSmrg    esac
432105b261ecSmrg
43224642e01fSmrg    # This variable tells wrapper scripts just to set variables rather
43234642e01fSmrg    # than running their programs.
432435c4bbdfSmrg    libtool_install_magic=$magic
432505b261ecSmrg
43264642e01fSmrg    staticlibs=
43274642e01fSmrg    future_libdirs=
43284642e01fSmrg    current_libdirs=
43294642e01fSmrg    for file in $files; do
433005b261ecSmrg
43314642e01fSmrg      # Do each installation.
43324642e01fSmrg      case $file in
43334642e01fSmrg      *.$libext)
43344642e01fSmrg	# Do the static libraries later.
433535c4bbdfSmrg	func_append staticlibs " $file"
43364642e01fSmrg	;;
43374642e01fSmrg
43384642e01fSmrg      *.la)
433935c4bbdfSmrg	func_resolve_sysroot "$file"
434035c4bbdfSmrg	file=$func_resolve_sysroot_result
434135c4bbdfSmrg
43424642e01fSmrg	# Check to see that this really is a libtool archive.
43434642e01fSmrg	func_lalib_unsafe_p "$file" \
434435c4bbdfSmrg	  || func_fatal_help "'$file' is not a valid libtool archive"
43454642e01fSmrg
43464642e01fSmrg	library_names=
43474642e01fSmrg	old_library=
43484642e01fSmrg	relink_command=
43494642e01fSmrg	func_source "$file"
43504642e01fSmrg
43514642e01fSmrg	# Add the libdir to current_libdirs if it is the destination.
43524642e01fSmrg	if test "X$destdir" = "X$libdir"; then
43534642e01fSmrg	  case "$current_libdirs " in
43544642e01fSmrg	  *" $libdir "*) ;;
435535c4bbdfSmrg	  *) func_append current_libdirs " $libdir" ;;
435605b261ecSmrg	  esac
43574642e01fSmrg	else
43584642e01fSmrg	  # Note the libdir as a future libdir.
43594642e01fSmrg	  case "$future_libdirs " in
43604642e01fSmrg	  *" $libdir "*) ;;
436135c4bbdfSmrg	  *) func_append future_libdirs " $libdir" ;;
43624642e01fSmrg	  esac
43634642e01fSmrg	fi
436405b261ecSmrg
43654642e01fSmrg	func_dirname "$file" "/" ""
436635c4bbdfSmrg	dir=$func_dirname_result
436735c4bbdfSmrg	func_append dir "$objdir"
43684642e01fSmrg
43694642e01fSmrg	if test -n "$relink_command"; then
43704642e01fSmrg	  # Determine the prefix the user has applied to our future dir.
43716747b715Smrg	  inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
43724642e01fSmrg
43734642e01fSmrg	  # Don't allow the user to place us outside of our expected
43744642e01fSmrg	  # location b/c this prevents finding dependent libraries that
43754642e01fSmrg	  # are installed to the same prefix.
43764642e01fSmrg	  # At present, this check doesn't affect windows .dll's that
43774642e01fSmrg	  # are installed into $libdir/../bin (currently, that works fine)
43784642e01fSmrg	  # but it's something to keep an eye on.
43794642e01fSmrg	  test "$inst_prefix_dir" = "$destdir" && \
438035c4bbdfSmrg	    func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir"
43814642e01fSmrg
43824642e01fSmrg	  if test -n "$inst_prefix_dir"; then
43834642e01fSmrg	    # Stick the inst_prefix_dir data into the link command.
43846747b715Smrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
43854642e01fSmrg	  else
43866747b715Smrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
43874642e01fSmrg	  fi
43884642e01fSmrg
438935c4bbdfSmrg	  func_warning "relinking '$file'"
43904642e01fSmrg	  func_show_eval "$relink_command" \
439135c4bbdfSmrg	    'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"'
43924642e01fSmrg	fi
43934642e01fSmrg
43944642e01fSmrg	# See the names of the shared library.
43954642e01fSmrg	set dummy $library_names; shift
43964642e01fSmrg	if test -n "$1"; then
439735c4bbdfSmrg	  realname=$1
43984642e01fSmrg	  shift
43994642e01fSmrg
440035c4bbdfSmrg	  srcname=$realname
440135c4bbdfSmrg	  test -n "$relink_command" && srcname=${realname}T
44024642e01fSmrg
44034642e01fSmrg	  # Install the shared library and build the symlinks.
44046747b715Smrg	  func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
44054642e01fSmrg	      'exit $?'
440635c4bbdfSmrg	  tstripme=$stripme
44074642e01fSmrg	  case $host_os in
44084642e01fSmrg	  cygwin* | mingw* | pw32* | cegcc*)
44094642e01fSmrg	    case $realname in
44104642e01fSmrg	    *.dll.a)
441135c4bbdfSmrg	      tstripme=
441235c4bbdfSmrg	      ;;
441335c4bbdfSmrg	    esac
441435c4bbdfSmrg	    ;;
441535c4bbdfSmrg	  os2*)
441635c4bbdfSmrg	    case $realname in
441735c4bbdfSmrg	    *_dll.a)
441835c4bbdfSmrg	      tstripme=
44194642e01fSmrg	      ;;
44204642e01fSmrg	    esac
442105b261ecSmrg	    ;;
442205b261ecSmrg	  esac
44234642e01fSmrg	  if test -n "$tstripme" && test -n "$striplib"; then
44244642e01fSmrg	    func_show_eval "$striplib $destdir/$realname" 'exit $?'
442505b261ecSmrg	  fi
44264642e01fSmrg
44274642e01fSmrg	  if test "$#" -gt 0; then
44284642e01fSmrg	    # Delete the old symlinks, and create new ones.
442935c4bbdfSmrg	    # Try 'ln -sf' first, because the 'ln' binary might depend on
44304642e01fSmrg	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
44314642e01fSmrg	    # so we also need to try rm && ln -s.
44324642e01fSmrg	    for linkname
44334642e01fSmrg	    do
44344642e01fSmrg	      test "$linkname" != "$realname" \
44354642e01fSmrg		&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
443605b261ecSmrg	    done
443705b261ecSmrg	  fi
443805b261ecSmrg
44394642e01fSmrg	  # Do each command in the postinstall commands.
444035c4bbdfSmrg	  lib=$destdir/$realname
44414642e01fSmrg	  func_execute_cmds "$postinstall_cmds" 'exit $?'
444205b261ecSmrg	fi
444305b261ecSmrg
44444642e01fSmrg	# Install the pseudo-library for information purposes.
44454642e01fSmrg	func_basename "$file"
444635c4bbdfSmrg	name=$func_basename_result
444735c4bbdfSmrg	instname=$dir/${name}i
44484642e01fSmrg	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
444905b261ecSmrg
44504642e01fSmrg	# Maybe install the static library, too.
445135c4bbdfSmrg	test -n "$old_library" && func_append staticlibs " $dir/$old_library"
44524642e01fSmrg	;;
445305b261ecSmrg
44544642e01fSmrg      *.lo)
44554642e01fSmrg	# Install (i.e. copy) a libtool object.
445605b261ecSmrg
44574642e01fSmrg	# Figure out destination file name, if it wasn't already specified.
44584642e01fSmrg	if test -n "$destname"; then
445935c4bbdfSmrg	  destfile=$destdir/$destname
44604642e01fSmrg	else
44614642e01fSmrg	  func_basename "$file"
446235c4bbdfSmrg	  destfile=$func_basename_result
446335c4bbdfSmrg	  destfile=$destdir/$destfile
44644642e01fSmrg	fi
44654642e01fSmrg
44664642e01fSmrg	# Deduce the name of the destination old-style object file.
44674642e01fSmrg	case $destfile in
44684642e01fSmrg	*.lo)
44694642e01fSmrg	  func_lo2o "$destfile"
44704642e01fSmrg	  staticdest=$func_lo2o_result
44714642e01fSmrg	  ;;
44724642e01fSmrg	*.$objext)
447335c4bbdfSmrg	  staticdest=$destfile
44744642e01fSmrg	  destfile=
44754642e01fSmrg	  ;;
44764642e01fSmrg	*)
447735c4bbdfSmrg	  func_fatal_help "cannot copy a libtool object to '$destfile'"
44784642e01fSmrg	  ;;
447905b261ecSmrg	esac
448005b261ecSmrg
44814642e01fSmrg	# Install the libtool object if requested.
44824642e01fSmrg	test -n "$destfile" && \
44834642e01fSmrg	  func_show_eval "$install_prog $file $destfile" 'exit $?'
44844642e01fSmrg
44854642e01fSmrg	# Install the old object if enabled.
448635c4bbdfSmrg	if test yes = "$build_old_libs"; then
44874642e01fSmrg	  # Deduce the name of the old-style object file.
44884642e01fSmrg	  func_lo2o "$file"
44894642e01fSmrg	  staticobj=$func_lo2o_result
44904642e01fSmrg	  func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
449105b261ecSmrg	fi
44924642e01fSmrg	exit $EXIT_SUCCESS
44934642e01fSmrg	;;
449405b261ecSmrg
44954642e01fSmrg      *)
44964642e01fSmrg	# Figure out destination file name, if it wasn't already specified.
44974642e01fSmrg	if test -n "$destname"; then
449835c4bbdfSmrg	  destfile=$destdir/$destname
44994642e01fSmrg	else
45004642e01fSmrg	  func_basename "$file"
450135c4bbdfSmrg	  destfile=$func_basename_result
450235c4bbdfSmrg	  destfile=$destdir/$destfile
45034642e01fSmrg	fi
450405b261ecSmrg
45054642e01fSmrg	# If the file is missing, and there is a .exe on the end, strip it
45064642e01fSmrg	# because it is most likely a libtool script we actually want to
45074642e01fSmrg	# install
450835c4bbdfSmrg	stripped_ext=
45094642e01fSmrg	case $file in
45104642e01fSmrg	  *.exe)
45114642e01fSmrg	    if test ! -f "$file"; then
45124642e01fSmrg	      func_stripname '' '.exe' "$file"
45134642e01fSmrg	      file=$func_stripname_result
451435c4bbdfSmrg	      stripped_ext=.exe
45154642e01fSmrg	    fi
45164642e01fSmrg	    ;;
45174642e01fSmrg	esac
451805b261ecSmrg
45194642e01fSmrg	# Do a test to see if this is really a libtool program.
45204642e01fSmrg	case $host in
45214642e01fSmrg	*cygwin* | *mingw*)
45224642e01fSmrg	    if func_ltwrapper_executable_p "$file"; then
45234642e01fSmrg	      func_ltwrapper_scriptname "$file"
45244642e01fSmrg	      wrapper=$func_ltwrapper_scriptname_result
45254642e01fSmrg	    else
45264642e01fSmrg	      func_stripname '' '.exe' "$file"
45274642e01fSmrg	      wrapper=$func_stripname_result
45284642e01fSmrg	    fi
45294642e01fSmrg	    ;;
45304642e01fSmrg	*)
45314642e01fSmrg	    wrapper=$file
45324642e01fSmrg	    ;;
45334642e01fSmrg	esac
45344642e01fSmrg	if func_ltwrapper_script_p "$wrapper"; then
45354642e01fSmrg	  notinst_deplibs=
45364642e01fSmrg	  relink_command=
453705b261ecSmrg
45384642e01fSmrg	  func_source "$wrapper"
45394642e01fSmrg
45404642e01fSmrg	  # Check the variables that should have been set.
45414642e01fSmrg	  test -z "$generated_by_libtool_version" && \
454235c4bbdfSmrg	    func_fatal_error "invalid libtool wrapper script '$wrapper'"
45434642e01fSmrg
454435c4bbdfSmrg	  finalize=:
45454642e01fSmrg	  for lib in $notinst_deplibs; do
45464642e01fSmrg	    # Check to see that each library is installed.
45474642e01fSmrg	    libdir=
45484642e01fSmrg	    if test -f "$lib"; then
45494642e01fSmrg	      func_source "$lib"
45504642e01fSmrg	    fi
455135c4bbdfSmrg	    libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'`
45524642e01fSmrg	    if test -n "$libdir" && test ! -f "$libfile"; then
455335c4bbdfSmrg	      func_warning "'$lib' has not been installed in '$libdir'"
455435c4bbdfSmrg	      finalize=false
45554642e01fSmrg	    fi
45564642e01fSmrg	  done
45574642e01fSmrg
45584642e01fSmrg	  relink_command=
45594642e01fSmrg	  func_source "$wrapper"
45604642e01fSmrg
45614642e01fSmrg	  outputname=
456235c4bbdfSmrg	  if test no = "$fast_install" && test -n "$relink_command"; then
45634642e01fSmrg	    $opt_dry_run || {
456435c4bbdfSmrg	      if $finalize; then
45654642e01fSmrg	        tmpdir=`func_mktempdir`
45664642e01fSmrg		func_basename "$file$stripped_ext"
456735c4bbdfSmrg		file=$func_basename_result
456835c4bbdfSmrg	        outputname=$tmpdir/$file
45694642e01fSmrg	        # Replace the output file specification.
45706747b715Smrg	        relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
45714642e01fSmrg
457235c4bbdfSmrg	        $opt_quiet || {
45734642e01fSmrg	          func_quote_for_expand "$relink_command"
45744642e01fSmrg		  eval "func_echo $func_quote_for_expand_result"
45754642e01fSmrg	        }
45764642e01fSmrg	        if eval "$relink_command"; then :
45774642e01fSmrg	          else
457835c4bbdfSmrg		  func_error "error: relink '$file' with the above command before installing it"
45794642e01fSmrg		  $opt_dry_run || ${RM}r "$tmpdir"
45804642e01fSmrg		  continue
45814642e01fSmrg	        fi
458235c4bbdfSmrg	        file=$outputname
45834642e01fSmrg	      else
458435c4bbdfSmrg	        func_warning "cannot relink '$file'"
45854642e01fSmrg	      fi
45864642e01fSmrg	    }
458705b261ecSmrg	  else
45884642e01fSmrg	    # Install the binary that we compiled earlier.
45896747b715Smrg	    file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
459005b261ecSmrg	  fi
45914642e01fSmrg	fi
459205b261ecSmrg
45934642e01fSmrg	# remove .exe since cygwin /usr/bin/install will append another
45944642e01fSmrg	# one anyway
45954642e01fSmrg	case $install_prog,$host in
45964642e01fSmrg	*/usr/bin/install*,*cygwin*)
45974642e01fSmrg	  case $file:$destfile in
45984642e01fSmrg	  *.exe:*.exe)
45994642e01fSmrg	    # this is ok
46004642e01fSmrg	    ;;
46014642e01fSmrg	  *.exe:*)
46024642e01fSmrg	    destfile=$destfile.exe
46034642e01fSmrg	    ;;
46044642e01fSmrg	  *:*.exe)
46054642e01fSmrg	    func_stripname '' '.exe' "$destfile"
46064642e01fSmrg	    destfile=$func_stripname_result
46074642e01fSmrg	    ;;
46084642e01fSmrg	  esac
460905b261ecSmrg	  ;;
461005b261ecSmrg	esac
46114642e01fSmrg	func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
46124642e01fSmrg	$opt_dry_run || if test -n "$outputname"; then
46134642e01fSmrg	  ${RM}r "$tmpdir"
46144642e01fSmrg	fi
46154642e01fSmrg	;;
46164642e01fSmrg      esac
46174642e01fSmrg    done
461805b261ecSmrg
46194642e01fSmrg    for file in $staticlibs; do
46204642e01fSmrg      func_basename "$file"
462135c4bbdfSmrg      name=$func_basename_result
46224642e01fSmrg
46234642e01fSmrg      # Set up the ranlib parameters.
462435c4bbdfSmrg      oldlib=$destdir/$name
462535c4bbdfSmrg      func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
462635c4bbdfSmrg      tool_oldlib=$func_to_tool_file_result
46274642e01fSmrg
46284642e01fSmrg      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
46294642e01fSmrg
46304642e01fSmrg      if test -n "$stripme" && test -n "$old_striplib"; then
463135c4bbdfSmrg	func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
46324642e01fSmrg      fi
46334642e01fSmrg
46344642e01fSmrg      # Do each command in the postinstall commands.
46354642e01fSmrg      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
46364642e01fSmrg    done
46374642e01fSmrg
46384642e01fSmrg    test -n "$future_libdirs" && \
463935c4bbdfSmrg      func_warning "remember to run '$progname --finish$future_libdirs'"
46404642e01fSmrg
46414642e01fSmrg    if test -n "$current_libdirs"; then
46424642e01fSmrg      # Maybe just do a dry run.
46434642e01fSmrg      $opt_dry_run && current_libdirs=" -n$current_libdirs"
464435c4bbdfSmrg      exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs'
46454642e01fSmrg    else
46464642e01fSmrg      exit $EXIT_SUCCESS
46474642e01fSmrg    fi
46484642e01fSmrg}
46494642e01fSmrg
465035c4bbdfSmrgtest install = "$opt_mode" && func_mode_install ${1+"$@"}
46514642e01fSmrg
46524642e01fSmrg
46534642e01fSmrg# func_generate_dlsyms outputname originator pic_p
46544642e01fSmrg# Extract symbols from dlprefiles and create ${outputname}S.o with
46554642e01fSmrg# a dlpreopen symbol table.
46564642e01fSmrgfunc_generate_dlsyms ()
46574642e01fSmrg{
465835c4bbdfSmrg    $debug_cmd
465935c4bbdfSmrg
466035c4bbdfSmrg    my_outputname=$1
466135c4bbdfSmrg    my_originator=$2
466235c4bbdfSmrg    my_pic_p=${3-false}
466335c4bbdfSmrg    my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'`
46644642e01fSmrg    my_dlsyms=
46654642e01fSmrg
466635c4bbdfSmrg    if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
46674642e01fSmrg      if test -n "$NM" && test -n "$global_symbol_pipe"; then
466835c4bbdfSmrg	my_dlsyms=${my_outputname}S.c
46694642e01fSmrg      else
46704642e01fSmrg	func_error "not configured to extract global symbols from dlpreopened files"
46714642e01fSmrg      fi
46724642e01fSmrg    fi
46734642e01fSmrg
46744642e01fSmrg    if test -n "$my_dlsyms"; then
46754642e01fSmrg      case $my_dlsyms in
46764642e01fSmrg      "") ;;
46774642e01fSmrg      *.c)
46784642e01fSmrg	# Discover the nlist of each of the dlfiles.
467935c4bbdfSmrg	nlist=$output_objdir/$my_outputname.nm
46804642e01fSmrg
46814642e01fSmrg	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
46824642e01fSmrg
46834642e01fSmrg	# Parse the name list into a source file.
46844642e01fSmrg	func_verbose "creating $output_objdir/$my_dlsyms"
46854642e01fSmrg
46864642e01fSmrg	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
468735c4bbdfSmrg/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */
468835c4bbdfSmrg/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */
46894642e01fSmrg
46904642e01fSmrg#ifdef __cplusplus
46914642e01fSmrgextern \"C\" {
46924642e01fSmrg#endif
46934642e01fSmrg
469435c4bbdfSmrg#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
46956747b715Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
46966747b715Smrg#endif
46976747b715Smrg
469835c4bbdfSmrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
469935c4bbdfSmrg#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE
470035c4bbdfSmrg/* DATA imports from DLLs on WIN32 can't be const, because runtime
470135c4bbdfSmrg   relocations are performed -- see ld's documentation on pseudo-relocs.  */
470235c4bbdfSmrg# define LT_DLSYM_CONST
470335c4bbdfSmrg#elif defined __osf__
470435c4bbdfSmrg/* This system does not cope well with relocations in const data.  */
470535c4bbdfSmrg# define LT_DLSYM_CONST
470635c4bbdfSmrg#else
470735c4bbdfSmrg# define LT_DLSYM_CONST const
470835c4bbdfSmrg#endif
470935c4bbdfSmrg
471035c4bbdfSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
471135c4bbdfSmrg
47124642e01fSmrg/* External symbol declarations for the compiler. */\
47134642e01fSmrg"
47144642e01fSmrg
471535c4bbdfSmrg	if test yes = "$dlself"; then
471635c4bbdfSmrg	  func_verbose "generating symbol list for '$output'"
47174642e01fSmrg
47184642e01fSmrg	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
47194642e01fSmrg
47204642e01fSmrg	  # Add our own program objects to the symbol list.
47216747b715Smrg	  progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
47224642e01fSmrg	  for progfile in $progfiles; do
472335c4bbdfSmrg	    func_to_tool_file "$progfile" func_convert_file_msys_to_w32
472435c4bbdfSmrg	    func_verbose "extracting global C symbols from '$func_to_tool_file_result'"
472535c4bbdfSmrg	    $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
47264642e01fSmrg	  done
47274642e01fSmrg
47284642e01fSmrg	  if test -n "$exclude_expsyms"; then
47294642e01fSmrg	    $opt_dry_run || {
47304642e01fSmrg	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
47314642e01fSmrg	      eval '$MV "$nlist"T "$nlist"'
47324642e01fSmrg	    }
473305b261ecSmrg	  fi
47344642e01fSmrg
47354642e01fSmrg	  if test -n "$export_symbols_regex"; then
47364642e01fSmrg	    $opt_dry_run || {
47374642e01fSmrg	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
47384642e01fSmrg	      eval '$MV "$nlist"T "$nlist"'
47394642e01fSmrg	    }
47404642e01fSmrg	  fi
47414642e01fSmrg
47424642e01fSmrg	  # Prepare the list of exported symbols
47434642e01fSmrg	  if test -z "$export_symbols"; then
474435c4bbdfSmrg	    export_symbols=$output_objdir/$outputname.exp
47454642e01fSmrg	    $opt_dry_run || {
47464642e01fSmrg	      $RM $export_symbols
474735c4bbdfSmrg	      eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
47484642e01fSmrg	      case $host in
47494642e01fSmrg	      *cygwin* | *mingw* | *cegcc* )
47504642e01fSmrg                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
47514642e01fSmrg                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
47524642e01fSmrg	        ;;
47534642e01fSmrg	      esac
47544642e01fSmrg	    }
475505b261ecSmrg	  else
47564642e01fSmrg	    $opt_dry_run || {
475735c4bbdfSmrg	      eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
47584642e01fSmrg	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
47594642e01fSmrg	      eval '$MV "$nlist"T "$nlist"'
47604642e01fSmrg	      case $host in
47616747b715Smrg	        *cygwin* | *mingw* | *cegcc* )
47624642e01fSmrg	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
47634642e01fSmrg	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
47644642e01fSmrg	          ;;
47654642e01fSmrg	      esac
47664642e01fSmrg	    }
476705b261ecSmrg	  fi
47684642e01fSmrg	fi
476905b261ecSmrg
47704642e01fSmrg	for dlprefile in $dlprefiles; do
477135c4bbdfSmrg	  func_verbose "extracting global C symbols from '$dlprefile'"
47724642e01fSmrg	  func_basename "$dlprefile"
477335c4bbdfSmrg	  name=$func_basename_result
477435c4bbdfSmrg          case $host in
477535c4bbdfSmrg	    *cygwin* | *mingw* | *cegcc* )
477635c4bbdfSmrg	      # if an import library, we need to obtain dlname
477735c4bbdfSmrg	      if func_win32_import_lib_p "$dlprefile"; then
477835c4bbdfSmrg	        func_tr_sh "$dlprefile"
477935c4bbdfSmrg	        eval "curr_lafile=\$libfile_$func_tr_sh_result"
478035c4bbdfSmrg	        dlprefile_dlbasename=
478135c4bbdfSmrg	        if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
478235c4bbdfSmrg	          # Use subshell, to avoid clobbering current variable values
478335c4bbdfSmrg	          dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
478435c4bbdfSmrg	          if test -n "$dlprefile_dlname"; then
478535c4bbdfSmrg	            func_basename "$dlprefile_dlname"
478635c4bbdfSmrg	            dlprefile_dlbasename=$func_basename_result
478735c4bbdfSmrg	          else
478835c4bbdfSmrg	            # no lafile. user explicitly requested -dlpreopen <import library>.
478935c4bbdfSmrg	            $sharedlib_from_linklib_cmd "$dlprefile"
479035c4bbdfSmrg	            dlprefile_dlbasename=$sharedlib_from_linklib_result
479135c4bbdfSmrg	          fi
479235c4bbdfSmrg	        fi
479335c4bbdfSmrg	        $opt_dry_run || {
479435c4bbdfSmrg	          if test -n "$dlprefile_dlbasename"; then
479535c4bbdfSmrg	            eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
479635c4bbdfSmrg	          else
479735c4bbdfSmrg	            func_warning "Could not compute DLL name from $name"
479835c4bbdfSmrg	            eval '$ECHO ": $name " >> "$nlist"'
479935c4bbdfSmrg	          fi
480035c4bbdfSmrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
480135c4bbdfSmrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
480235c4bbdfSmrg	            $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
480335c4bbdfSmrg	        }
480435c4bbdfSmrg	      else # not an import lib
480535c4bbdfSmrg	        $opt_dry_run || {
480635c4bbdfSmrg	          eval '$ECHO ": $name " >> "$nlist"'
480735c4bbdfSmrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
480835c4bbdfSmrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
480935c4bbdfSmrg	        }
481035c4bbdfSmrg	      fi
481135c4bbdfSmrg	    ;;
481235c4bbdfSmrg	    *)
481335c4bbdfSmrg	      $opt_dry_run || {
481435c4bbdfSmrg	        eval '$ECHO ": $name " >> "$nlist"'
481535c4bbdfSmrg	        func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
481635c4bbdfSmrg	        eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
481735c4bbdfSmrg	      }
481835c4bbdfSmrg	    ;;
481935c4bbdfSmrg          esac
48204642e01fSmrg	done
48214642e01fSmrg
48224642e01fSmrg	$opt_dry_run || {
48234642e01fSmrg	  # Make sure we have at least an empty file.
48244642e01fSmrg	  test -f "$nlist" || : > "$nlist"
48254642e01fSmrg
48264642e01fSmrg	  if test -n "$exclude_expsyms"; then
48274642e01fSmrg	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
48284642e01fSmrg	    $MV "$nlist"T "$nlist"
482905b261ecSmrg	  fi
48304642e01fSmrg
48314642e01fSmrg	  # Try sorting and uniquifying the output.
48324642e01fSmrg	  if $GREP -v "^: " < "$nlist" |
48334642e01fSmrg	      if sort -k 3 </dev/null >/dev/null 2>&1; then
48344642e01fSmrg		sort -k 3
48354642e01fSmrg	      else
48364642e01fSmrg		sort +2
48374642e01fSmrg	      fi |
48384642e01fSmrg	      uniq > "$nlist"S; then
48394642e01fSmrg	    :
484005b261ecSmrg	  else
48414642e01fSmrg	    $GREP -v "^: " < "$nlist" > "$nlist"S
484205b261ecSmrg	  fi
484305b261ecSmrg
48444642e01fSmrg	  if test -f "$nlist"S; then
48454642e01fSmrg	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
484605b261ecSmrg	  else
48476747b715Smrg	    echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
484805b261ecSmrg	  fi
484905b261ecSmrg
485035c4bbdfSmrg	  func_show_eval '$RM "${nlist}I"'
485135c4bbdfSmrg	  if test -n "$global_symbol_to_import"; then
485235c4bbdfSmrg	    eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I'
485335c4bbdfSmrg	  fi
485435c4bbdfSmrg
48556747b715Smrg	  echo >> "$output_objdir/$my_dlsyms" "\
485605b261ecSmrg
48574642e01fSmrg/* The mapping between symbol names and symbols.  */
48584642e01fSmrgtypedef struct {
48594642e01fSmrg  const char *name;
48604642e01fSmrg  void *address;
48614642e01fSmrg} lt_dlsymlist;
486235c4bbdfSmrgextern LT_DLSYM_CONST lt_dlsymlist
486335c4bbdfSmrglt_${my_prefix}_LTX_preloaded_symbols[];\
4864475c125cSmrg"
486535c4bbdfSmrg
486635c4bbdfSmrg	  if test -s "$nlist"I; then
4867475c125cSmrg	    echo >> "$output_objdir/$my_dlsyms" "\
486835c4bbdfSmrgstatic void lt_syminit(void)
486935c4bbdfSmrg{
487035c4bbdfSmrg  LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols;
487135c4bbdfSmrg  for (; symbol->name; ++symbol)
487235c4bbdfSmrg    {"
487335c4bbdfSmrg	    $SED 's/.*/      if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms"
4874475c125cSmrg	    echo >> "$output_objdir/$my_dlsyms" "\
487535c4bbdfSmrg    }
487635c4bbdfSmrg}"
487735c4bbdfSmrg	  fi
4878475c125cSmrg	  echo >> "$output_objdir/$my_dlsyms" "\
487935c4bbdfSmrgLT_DLSYM_CONST lt_dlsymlist
48804642e01fSmrglt_${my_prefix}_LTX_preloaded_symbols[] =
488135c4bbdfSmrg{ {\"$my_originator\", (void *) 0},"
488235c4bbdfSmrg
488335c4bbdfSmrg	  if test -s "$nlist"I; then
488435c4bbdfSmrg	    echo >> "$output_objdir/$my_dlsyms" "\
488535c4bbdfSmrg  {\"@INIT@\", (void *) &lt_syminit},"
488635c4bbdfSmrg	  fi
488705b261ecSmrg
48884642e01fSmrg	  case $need_lib_prefix in
48894642e01fSmrg	  no)
48904642e01fSmrg	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
48914642e01fSmrg	    ;;
48924642e01fSmrg	  *)
48934642e01fSmrg	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
48944642e01fSmrg	    ;;
48954642e01fSmrg	  esac
48966747b715Smrg	  echo >> "$output_objdir/$my_dlsyms" "\
48974642e01fSmrg  {0, (void *) 0}
48984642e01fSmrg};
489905b261ecSmrg
49004642e01fSmrg/* This works around a problem in FreeBSD linker */
49014642e01fSmrg#ifdef FREEBSD_WORKAROUND
49024642e01fSmrgstatic const void *lt_preloaded_setup() {
49034642e01fSmrg  return lt_${my_prefix}_LTX_preloaded_symbols;
49044642e01fSmrg}
49054642e01fSmrg#endif
49064642e01fSmrg
49074642e01fSmrg#ifdef __cplusplus
49084642e01fSmrg}
49094642e01fSmrg#endif\
49104642e01fSmrg"
49114642e01fSmrg	} # !$opt_dry_run
49124642e01fSmrg
49134642e01fSmrg	pic_flag_for_symtable=
49144642e01fSmrg	case "$compile_command " in
49154642e01fSmrg	*" -static "*) ;;
49164642e01fSmrg	*)
49174642e01fSmrg	  case $host in
49184642e01fSmrg	  # compiling the symbol table file with pic_flag works around
49194642e01fSmrg	  # a FreeBSD bug that causes programs to crash when -lm is
49204642e01fSmrg	  # linked before any other PIC object.  But we must not use
49214642e01fSmrg	  # pic_flag when linking with -static.  The problem exists in
49224642e01fSmrg	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
492335c4bbdfSmrg	  *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
49244642e01fSmrg	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
49254642e01fSmrg	  *-*-hpux*)
49264642e01fSmrg	    pic_flag_for_symtable=" $pic_flag"  ;;
49274642e01fSmrg	  *)
492835c4bbdfSmrg	    $my_pic_p && pic_flag_for_symtable=" $pic_flag"
49294642e01fSmrg	    ;;
49304642e01fSmrg	  esac
49314642e01fSmrg	  ;;
49324642e01fSmrg	esac
49334642e01fSmrg	symtab_cflags=
49344642e01fSmrg	for arg in $LTCFLAGS; do
49354642e01fSmrg	  case $arg in
49364642e01fSmrg	  -pie | -fpie | -fPIE) ;;
493735c4bbdfSmrg	  *) func_append symtab_cflags " $arg" ;;
49384642e01fSmrg	  esac
49394642e01fSmrg	done
494005b261ecSmrg
49414642e01fSmrg	# Now compile the dynamic symbol file.
49424642e01fSmrg	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
494305b261ecSmrg
49444642e01fSmrg	# Clean up the generated files.
494535c4bbdfSmrg	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"'
494605b261ecSmrg
49474642e01fSmrg	# Transform the symbol file into the correct name.
494835c4bbdfSmrg	symfileobj=$output_objdir/${my_outputname}S.$objext
49494642e01fSmrg	case $host in
49504642e01fSmrg	*cygwin* | *mingw* | *cegcc* )
49514642e01fSmrg	  if test -f "$output_objdir/$my_outputname.def"; then
49526747b715Smrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
49536747b715Smrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
49544642e01fSmrg	  else
49556747b715Smrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
49566747b715Smrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
495705b261ecSmrg	  fi
49584642e01fSmrg	  ;;
49594642e01fSmrg	*)
49606747b715Smrg	  compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
49616747b715Smrg	  finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
49624642e01fSmrg	  ;;
49634642e01fSmrg	esac
49644642e01fSmrg	;;
49654642e01fSmrg      *)
496635c4bbdfSmrg	func_fatal_error "unknown suffix for '$my_dlsyms'"
49674642e01fSmrg	;;
49684642e01fSmrg      esac
49694642e01fSmrg    else
49704642e01fSmrg      # We keep going just in case the user didn't refer to
49714642e01fSmrg      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
49724642e01fSmrg      # really was required.
497305b261ecSmrg
49744642e01fSmrg      # Nullify the symbol file.
49756747b715Smrg      compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
49766747b715Smrg      finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
49774642e01fSmrg    fi
49784642e01fSmrg}
497905b261ecSmrg
498035c4bbdfSmrg# func_cygming_gnu_implib_p ARG
498135c4bbdfSmrg# This predicate returns with zero status (TRUE) if
498235c4bbdfSmrg# ARG is a GNU/binutils-style import library. Returns
498335c4bbdfSmrg# with nonzero status (FALSE) otherwise.
498435c4bbdfSmrgfunc_cygming_gnu_implib_p ()
498535c4bbdfSmrg{
498635c4bbdfSmrg  $debug_cmd
498735c4bbdfSmrg
498835c4bbdfSmrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
498935c4bbdfSmrg  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)$'`
499035c4bbdfSmrg  test -n "$func_cygming_gnu_implib_tmp"
499135c4bbdfSmrg}
499235c4bbdfSmrg
499335c4bbdfSmrg# func_cygming_ms_implib_p ARG
499435c4bbdfSmrg# This predicate returns with zero status (TRUE) if
499535c4bbdfSmrg# ARG is an MS-style import library. Returns
499635c4bbdfSmrg# with nonzero status (FALSE) otherwise.
499735c4bbdfSmrgfunc_cygming_ms_implib_p ()
499835c4bbdfSmrg{
499935c4bbdfSmrg  $debug_cmd
500035c4bbdfSmrg
500135c4bbdfSmrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
500235c4bbdfSmrg  func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
500335c4bbdfSmrg  test -n "$func_cygming_ms_implib_tmp"
500435c4bbdfSmrg}
500535c4bbdfSmrg
50064642e01fSmrg# func_win32_libid arg
50074642e01fSmrg# return the library type of file 'arg'
50084642e01fSmrg#
50094642e01fSmrg# Need a lot of goo to handle *both* DLLs and import libs
50104642e01fSmrg# Has to be a shell function in order to 'eat' the argument
50114642e01fSmrg# that is supplied when $file_magic_command is called.
50126747b715Smrg# Despite the name, also deal with 64 bit binaries.
50134642e01fSmrgfunc_win32_libid ()
50144642e01fSmrg{
501535c4bbdfSmrg  $debug_cmd
501635c4bbdfSmrg
501735c4bbdfSmrg  win32_libid_type=unknown
50184642e01fSmrg  win32_fileres=`file -L $1 2>/dev/null`
50194642e01fSmrg  case $win32_fileres in
50204642e01fSmrg  *ar\ archive\ import\ library*) # definitely import
50214642e01fSmrg    win32_libid_type="x86 archive import"
50224642e01fSmrg    ;;
50234642e01fSmrg  *ar\ archive*) # could be an import, or static
50246747b715Smrg    # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
50254642e01fSmrg    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
50266747b715Smrg       $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
502735c4bbdfSmrg      case $nm_interface in
502835c4bbdfSmrg      "MS dumpbin")
502935c4bbdfSmrg	if func_cygming_ms_implib_p "$1" ||
503035c4bbdfSmrg	   func_cygming_gnu_implib_p "$1"
503135c4bbdfSmrg	then
503235c4bbdfSmrg	  win32_nmres=import
503335c4bbdfSmrg	else
503435c4bbdfSmrg	  win32_nmres=
503535c4bbdfSmrg	fi
503635c4bbdfSmrg	;;
503735c4bbdfSmrg      *)
503835c4bbdfSmrg	func_to_tool_file "$1" func_convert_file_msys_to_w32
503935c4bbdfSmrg	win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
504035c4bbdfSmrg	  $SED -n -e '
50414642e01fSmrg	    1,100{
50424642e01fSmrg		/ I /{
504335c4bbdfSmrg		    s|.*|import|
50444642e01fSmrg		    p
50454642e01fSmrg		    q
50464642e01fSmrg		}
50474642e01fSmrg	    }'`
504835c4bbdfSmrg	;;
504935c4bbdfSmrg      esac
50504642e01fSmrg      case $win32_nmres in
50514642e01fSmrg      import*)  win32_libid_type="x86 archive import";;
50524642e01fSmrg      *)        win32_libid_type="x86 archive static";;
50534642e01fSmrg      esac
50544642e01fSmrg    fi
50554642e01fSmrg    ;;
50564642e01fSmrg  *DLL*)
50574642e01fSmrg    win32_libid_type="x86 DLL"
50584642e01fSmrg    ;;
50594642e01fSmrg  *executable*) # but shell scripts are "executable" too...
50604642e01fSmrg    case $win32_fileres in
50614642e01fSmrg    *MS\ Windows\ PE\ Intel*)
50624642e01fSmrg      win32_libid_type="x86 DLL"
50634642e01fSmrg      ;;
50644642e01fSmrg    esac
50654642e01fSmrg    ;;
50664642e01fSmrg  esac
50674642e01fSmrg  $ECHO "$win32_libid_type"
50684642e01fSmrg}
506905b261ecSmrg
507035c4bbdfSmrg# func_cygming_dll_for_implib ARG
507135c4bbdfSmrg#
507235c4bbdfSmrg# Platform-specific function to extract the
507335c4bbdfSmrg# name of the DLL associated with the specified
507435c4bbdfSmrg# import library ARG.
507535c4bbdfSmrg# Invoked by eval'ing the libtool variable
507635c4bbdfSmrg#    $sharedlib_from_linklib_cmd
507735c4bbdfSmrg# Result is available in the variable
507835c4bbdfSmrg#    $sharedlib_from_linklib_result
507935c4bbdfSmrgfunc_cygming_dll_for_implib ()
508035c4bbdfSmrg{
508135c4bbdfSmrg  $debug_cmd
508235c4bbdfSmrg
508335c4bbdfSmrg  sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
508435c4bbdfSmrg}
508535c4bbdfSmrg
508635c4bbdfSmrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
508735c4bbdfSmrg#
508835c4bbdfSmrg# The is the core of a fallback implementation of a
508935c4bbdfSmrg# platform-specific function to extract the name of the
509035c4bbdfSmrg# DLL associated with the specified import library LIBNAME.
509135c4bbdfSmrg#
509235c4bbdfSmrg# SECTION_NAME is either .idata$6 or .idata$7, depending
509335c4bbdfSmrg# on the platform and compiler that created the implib.
509435c4bbdfSmrg#
509535c4bbdfSmrg# Echos the name of the DLL associated with the
509635c4bbdfSmrg# specified import library.
509735c4bbdfSmrgfunc_cygming_dll_for_implib_fallback_core ()
509835c4bbdfSmrg{
509935c4bbdfSmrg  $debug_cmd
510035c4bbdfSmrg
510135c4bbdfSmrg  match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
510235c4bbdfSmrg  $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
510335c4bbdfSmrg    $SED '/^Contents of section '"$match_literal"':/{
510435c4bbdfSmrg      # Place marker at beginning of archive member dllname section
510535c4bbdfSmrg      s/.*/====MARK====/
510635c4bbdfSmrg      p
510735c4bbdfSmrg      d
510835c4bbdfSmrg    }
510935c4bbdfSmrg    # These lines can sometimes be longer than 43 characters, but
511035c4bbdfSmrg    # are always uninteresting
511135c4bbdfSmrg    /:[	 ]*file format pe[i]\{,1\}-/d
511235c4bbdfSmrg    /^In archive [^:]*:/d
511335c4bbdfSmrg    # Ensure marker is printed
511435c4bbdfSmrg    /^====MARK====/p
511535c4bbdfSmrg    # Remove all lines with less than 43 characters
511635c4bbdfSmrg    /^.\{43\}/!d
511735c4bbdfSmrg    # From remaining lines, remove first 43 characters
511835c4bbdfSmrg    s/^.\{43\}//' |
511935c4bbdfSmrg    $SED -n '
512035c4bbdfSmrg      # Join marker and all lines until next marker into a single line
512135c4bbdfSmrg      /^====MARK====/ b para
512235c4bbdfSmrg      H
512335c4bbdfSmrg      $ b para
512435c4bbdfSmrg      b
512535c4bbdfSmrg      :para
512635c4bbdfSmrg      x
512735c4bbdfSmrg      s/\n//g
512835c4bbdfSmrg      # Remove the marker
512935c4bbdfSmrg      s/^====MARK====//
513035c4bbdfSmrg      # Remove trailing dots and whitespace
513135c4bbdfSmrg      s/[\. \t]*$//
513235c4bbdfSmrg      # Print
513335c4bbdfSmrg      /./p' |
513435c4bbdfSmrg    # we now have a list, one entry per line, of the stringified
513535c4bbdfSmrg    # contents of the appropriate section of all members of the
513635c4bbdfSmrg    # archive that possess that section. Heuristic: eliminate
513735c4bbdfSmrg    # all those that have a first or second character that is
513835c4bbdfSmrg    # a '.' (that is, objdump's representation of an unprintable
513935c4bbdfSmrg    # character.) This should work for all archives with less than
514035c4bbdfSmrg    # 0x302f exports -- but will fail for DLLs whose name actually
514135c4bbdfSmrg    # begins with a literal '.' or a single character followed by
514235c4bbdfSmrg    # a '.'.
514335c4bbdfSmrg    #
514435c4bbdfSmrg    # Of those that remain, print the first one.
514535c4bbdfSmrg    $SED -e '/^\./d;/^.\./d;q'
514635c4bbdfSmrg}
514735c4bbdfSmrg
514835c4bbdfSmrg# func_cygming_dll_for_implib_fallback ARG
514935c4bbdfSmrg# Platform-specific function to extract the
515035c4bbdfSmrg# name of the DLL associated with the specified
515135c4bbdfSmrg# import library ARG.
515235c4bbdfSmrg#
515335c4bbdfSmrg# This fallback implementation is for use when $DLLTOOL
515435c4bbdfSmrg# does not support the --identify-strict option.
515535c4bbdfSmrg# Invoked by eval'ing the libtool variable
515635c4bbdfSmrg#    $sharedlib_from_linklib_cmd
515735c4bbdfSmrg# Result is available in the variable
515835c4bbdfSmrg#    $sharedlib_from_linklib_result
515935c4bbdfSmrgfunc_cygming_dll_for_implib_fallback ()
516035c4bbdfSmrg{
516135c4bbdfSmrg  $debug_cmd
516235c4bbdfSmrg
516335c4bbdfSmrg  if func_cygming_gnu_implib_p "$1"; then
516435c4bbdfSmrg    # binutils import library
516535c4bbdfSmrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
516635c4bbdfSmrg  elif func_cygming_ms_implib_p "$1"; then
516735c4bbdfSmrg    # ms-generated import library
516835c4bbdfSmrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
516935c4bbdfSmrg  else
517035c4bbdfSmrg    # unknown
517135c4bbdfSmrg    sharedlib_from_linklib_result=
517235c4bbdfSmrg  fi
517335c4bbdfSmrg}
517405b261ecSmrg
517505b261ecSmrg
51764642e01fSmrg# func_extract_an_archive dir oldlib
51774642e01fSmrgfunc_extract_an_archive ()
51784642e01fSmrg{
517935c4bbdfSmrg    $debug_cmd
518035c4bbdfSmrg
518135c4bbdfSmrg    f_ex_an_ar_dir=$1; shift
518235c4bbdfSmrg    f_ex_an_ar_oldlib=$1
518335c4bbdfSmrg    if test yes = "$lock_old_archive_extraction"; then
51846747b715Smrg      lockfile=$f_ex_an_ar_oldlib.lock
51856747b715Smrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
51866747b715Smrg	func_echo "Waiting for $lockfile to be removed"
51876747b715Smrg	sleep 2
51886747b715Smrg      done
51896747b715Smrg    fi
51906747b715Smrg    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
51916747b715Smrg		   'stat=$?; rm -f "$lockfile"; exit $stat'
519235c4bbdfSmrg    if test yes = "$lock_old_archive_extraction"; then
51936747b715Smrg      $opt_dry_run || rm -f "$lockfile"
51946747b715Smrg    fi
51954642e01fSmrg    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
51964642e01fSmrg     :
51974642e01fSmrg    else
51984642e01fSmrg      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
51994642e01fSmrg    fi
52004642e01fSmrg}
520105b261ecSmrg
520205b261ecSmrg
52034642e01fSmrg# func_extract_archives gentop oldlib ...
52044642e01fSmrgfunc_extract_archives ()
52054642e01fSmrg{
520635c4bbdfSmrg    $debug_cmd
520735c4bbdfSmrg
520835c4bbdfSmrg    my_gentop=$1; shift
52094642e01fSmrg    my_oldlibs=${1+"$@"}
521035c4bbdfSmrg    my_oldobjs=
521135c4bbdfSmrg    my_xlib=
521235c4bbdfSmrg    my_xabs=
521335c4bbdfSmrg    my_xdir=
521405b261ecSmrg
52154642e01fSmrg    for my_xlib in $my_oldlibs; do
52164642e01fSmrg      # Extract the objects.
52174642e01fSmrg      case $my_xlib in
521835c4bbdfSmrg	[\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;;
52194642e01fSmrg	*) my_xabs=`pwd`"/$my_xlib" ;;
52204642e01fSmrg      esac
52214642e01fSmrg      func_basename "$my_xlib"
522235c4bbdfSmrg      my_xlib=$func_basename_result
52234642e01fSmrg      my_xlib_u=$my_xlib
52244642e01fSmrg      while :; do
52254642e01fSmrg        case " $extracted_archives " in
52264642e01fSmrg	*" $my_xlib_u "*)
52274642e01fSmrg	  func_arith $extracted_serial + 1
52284642e01fSmrg	  extracted_serial=$func_arith_result
52294642e01fSmrg	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
52304642e01fSmrg	*) break ;;
52314642e01fSmrg	esac
52324642e01fSmrg      done
52334642e01fSmrg      extracted_archives="$extracted_archives $my_xlib_u"
523435c4bbdfSmrg      my_xdir=$my_gentop/$my_xlib_u
523505b261ecSmrg
52364642e01fSmrg      func_mkdir_p "$my_xdir"
523705b261ecSmrg
52384642e01fSmrg      case $host in
52394642e01fSmrg      *-darwin*)
52404642e01fSmrg	func_verbose "Extracting $my_xabs"
52414642e01fSmrg	# Do not bother doing anything if just a dry run
52424642e01fSmrg	$opt_dry_run || {
52434642e01fSmrg	  darwin_orig_dir=`pwd`
52444642e01fSmrg	  cd $my_xdir || exit $?
52454642e01fSmrg	  darwin_archive=$my_xabs
52464642e01fSmrg	  darwin_curdir=`pwd`
524735c4bbdfSmrg	  func_basename "$darwin_archive"
524835c4bbdfSmrg	  darwin_base_archive=$func_basename_result
52494642e01fSmrg	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
52504642e01fSmrg	  if test -n "$darwin_arches"; then
52514642e01fSmrg	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
52524642e01fSmrg	    darwin_arch=
52534642e01fSmrg	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
525435c4bbdfSmrg	    for darwin_arch in  $darwin_arches; do
525535c4bbdfSmrg	      func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch"
525635c4bbdfSmrg	      $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive"
525735c4bbdfSmrg	      cd "unfat-$$/$darwin_base_archive-$darwin_arch"
525835c4bbdfSmrg	      func_extract_an_archive "`pwd`" "$darwin_base_archive"
52594642e01fSmrg	      cd "$darwin_curdir"
526035c4bbdfSmrg	      $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive"
52614642e01fSmrg	    done # $darwin_arches
52624642e01fSmrg            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
526335c4bbdfSmrg	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u`
52644642e01fSmrg	    darwin_file=
52654642e01fSmrg	    darwin_files=
52664642e01fSmrg	    for darwin_file in $darwin_filelist; do
52676747b715Smrg	      darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
52684642e01fSmrg	      $LIPO -create -output "$darwin_file" $darwin_files
52694642e01fSmrg	    done # $darwin_filelist
52704642e01fSmrg	    $RM -rf unfat-$$
52714642e01fSmrg	    cd "$darwin_orig_dir"
527205b261ecSmrg	  else
52734642e01fSmrg	    cd $darwin_orig_dir
52744642e01fSmrg	    func_extract_an_archive "$my_xdir" "$my_xabs"
52754642e01fSmrg	  fi # $darwin_arches
52764642e01fSmrg	} # !$opt_dry_run
52774642e01fSmrg	;;
52784642e01fSmrg      *)
52794642e01fSmrg        func_extract_an_archive "$my_xdir" "$my_xabs"
52804642e01fSmrg	;;
52814642e01fSmrg      esac
52826747b715Smrg      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
52834642e01fSmrg    done
528405b261ecSmrg
528535c4bbdfSmrg    func_extract_archives_result=$my_oldobjs
52864642e01fSmrg}
528705b261ecSmrg
528805b261ecSmrg
52896747b715Smrg# func_emit_wrapper [arg=no]
52906747b715Smrg#
52916747b715Smrg# Emit a libtool wrapper script on stdout.
52926747b715Smrg# Don't directly open a file because we may want to
52936747b715Smrg# incorporate the script contents within a cygwin/mingw
52946747b715Smrg# wrapper executable.  Must ONLY be called from within
52956747b715Smrg# func_mode_link because it depends on a number of variables
52966747b715Smrg# set therein.
52974642e01fSmrg#
52986747b715Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
52996747b715Smrg# variable will take.  If 'yes', then the emitted script
530035c4bbdfSmrg# will assume that the directory where it is stored is
53016747b715Smrg# the $objdir directory.  This is a cygwin/mingw-specific
53026747b715Smrg# behavior.
53036747b715Smrgfunc_emit_wrapper ()
53044642e01fSmrg{
53056747b715Smrg	func_emit_wrapper_arg1=${1-no}
530605b261ecSmrg
53074642e01fSmrg	$ECHO "\
53084642e01fSmrg#! $SHELL
530905b261ecSmrg
53104642e01fSmrg# $output - temporary wrapper script for $objdir/$outputname
531135c4bbdfSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
53124642e01fSmrg#
53134642e01fSmrg# The $output program cannot be directly executed until all the libtool
53144642e01fSmrg# libraries that it depends on are installed.
53154642e01fSmrg#
53164642e01fSmrg# This wrapper script should never be moved out of the build directory.
53174642e01fSmrg# If it is, it will not operate correctly.
531805b261ecSmrg
53194642e01fSmrg# Sed substitution that helps us do robust quoting.  It backslashifies
53204642e01fSmrg# metacharacters that are still active within double-quoted strings.
53214642e01fSmrgsed_quote_subst='$sed_quote_subst'
532205b261ecSmrg
53234642e01fSmrg# Be Bourne compatible
53244642e01fSmrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
53254642e01fSmrg  emulate sh
53264642e01fSmrg  NULLCMD=:
53274642e01fSmrg  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
53284642e01fSmrg  # is contrary to our usage.  Disable this feature.
53294642e01fSmrg  alias -g '\${1+\"\$@\"}'='\"\$@\"'
53304642e01fSmrg  setopt NO_GLOB_SUBST
53314642e01fSmrgelse
53324642e01fSmrg  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
53334642e01fSmrgfi
53344642e01fSmrgBIN_SH=xpg4; export BIN_SH # for Tru64
53354642e01fSmrgDUALCASE=1; export DUALCASE # for MKS sh
533605b261ecSmrg
53374642e01fSmrg# The HP-UX ksh and POSIX shell print the target directory to stdout
53384642e01fSmrg# if CDPATH is set.
53394642e01fSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
534005b261ecSmrg
53414642e01fSmrgrelink_command=\"$relink_command\"
534205b261ecSmrg
53434642e01fSmrg# This environment variable determines our operation mode.
53444642e01fSmrgif test \"\$libtool_install_magic\" = \"$magic\"; then
53454642e01fSmrg  # install mode needs the following variables:
53464642e01fSmrg  generated_by_libtool_version='$macro_version'
53474642e01fSmrg  notinst_deplibs='$notinst_deplibs'
53484642e01fSmrgelse
53494642e01fSmrg  # When we are sourced in execute mode, \$file and \$ECHO are already set.
53504642e01fSmrg  if test \"\$libtool_execute_magic\" != \"$magic\"; then
53516747b715Smrg    file=\"\$0\""
53526747b715Smrg
5353ed6184dfSmrg    qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
53546747b715Smrg    $ECHO "\
53556747b715Smrg
53566747b715Smrg# A function that is used when there is no print builtin or printf.
53576747b715Smrgfunc_fallback_echo ()
53586747b715Smrg{
53596747b715Smrg  eval 'cat <<_LTECHO_EOF
53606747b715Smrg\$1
53616747b715Smrg_LTECHO_EOF'
53626747b715Smrg}
53636747b715Smrg    ECHO=\"$qECHO\"
53646747b715Smrg  fi
53656747b715Smrg
53666747b715Smrg# Very basic option parsing. These options are (a) specific to
53676747b715Smrg# the libtool wrapper, (b) are identical between the wrapper
536835c4bbdfSmrg# /script/ and the wrapper /executable/ that is used only on
53696747b715Smrg# windows platforms, and (c) all begin with the string "--lt-"
537035c4bbdfSmrg# (application programs are unlikely to have options that match
53716747b715Smrg# this pattern).
53726747b715Smrg#
53736747b715Smrg# There are only two supported options: --lt-debug and
53746747b715Smrg# --lt-dump-script. There is, deliberately, no --lt-help.
53756747b715Smrg#
53766747b715Smrg# The first argument to this parsing function should be the
53776747b715Smrg# script's $0 value, followed by "$@".
53786747b715Smrglt_option_debug=
53796747b715Smrgfunc_parse_lt_options ()
53806747b715Smrg{
53816747b715Smrg  lt_script_arg0=\$0
53826747b715Smrg  shift
53836747b715Smrg  for lt_opt
53846747b715Smrg  do
53856747b715Smrg    case \"\$lt_opt\" in
53866747b715Smrg    --lt-debug) lt_option_debug=1 ;;
53876747b715Smrg    --lt-dump-script)
53886747b715Smrg        lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
53896747b715Smrg        test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
53906747b715Smrg        lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
53916747b715Smrg        cat \"\$lt_dump_D/\$lt_dump_F\"
53926747b715Smrg        exit 0
53936747b715Smrg      ;;
53946747b715Smrg    --lt-*)
53956747b715Smrg        \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
53966747b715Smrg        exit 1
53976747b715Smrg      ;;
53986747b715Smrg    esac
53996747b715Smrg  done
54006747b715Smrg
54016747b715Smrg  # Print the debug banner immediately:
54026747b715Smrg  if test -n \"\$lt_option_debug\"; then
540335c4bbdfSmrg    echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2
54046747b715Smrg  fi
54056747b715Smrg}
54066747b715Smrg
54076747b715Smrg# Used when --lt-debug. Prints its arguments to stdout
54086747b715Smrg# (redirection is the responsibility of the caller)
54096747b715Smrgfunc_lt_dump_args ()
54106747b715Smrg{
54116747b715Smrg  lt_dump_args_N=1;
54126747b715Smrg  for lt_arg
54136747b715Smrg  do
541435c4bbdfSmrg    \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\"
54156747b715Smrg    lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
54166747b715Smrg  done
54176747b715Smrg}
54186747b715Smrg
54196747b715Smrg# Core function for launching the target application
54206747b715Smrgfunc_exec_program_core ()
54216747b715Smrg{
54224642e01fSmrg"
54236747b715Smrg  case $host in
54246747b715Smrg  # Backslashes separate directories on plain windows
54256747b715Smrg  *-*-mingw | *-*-os2* | *-cegcc*)
54266747b715Smrg    $ECHO "\
54276747b715Smrg      if test -n \"\$lt_option_debug\"; then
542835c4bbdfSmrg        \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2
54296747b715Smrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
54306747b715Smrg      fi
54316747b715Smrg      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
54326747b715Smrg"
54336747b715Smrg    ;;
54346747b715Smrg
54356747b715Smrg  *)
54366747b715Smrg    $ECHO "\
54376747b715Smrg      if test -n \"\$lt_option_debug\"; then
543835c4bbdfSmrg        \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2
54396747b715Smrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
54406747b715Smrg      fi
54416747b715Smrg      exec \"\$progdir/\$program\" \${1+\"\$@\"}
54426747b715Smrg"
54436747b715Smrg    ;;
54446747b715Smrg  esac
54456747b715Smrg  $ECHO "\
54466747b715Smrg      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
54476747b715Smrg      exit 1
54486747b715Smrg}
54496747b715Smrg
54506747b715Smrg# A function to encapsulate launching the target application
54516747b715Smrg# Strips options in the --lt-* namespace from \$@ and
54526747b715Smrg# launches target application with the remaining arguments.
54536747b715Smrgfunc_exec_program ()
54546747b715Smrg{
545535c4bbdfSmrg  case \" \$* \" in
545635c4bbdfSmrg  *\\ --lt-*)
545735c4bbdfSmrg    for lt_wr_arg
545835c4bbdfSmrg    do
545935c4bbdfSmrg      case \$lt_wr_arg in
546035c4bbdfSmrg      --lt-*) ;;
546135c4bbdfSmrg      *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
546235c4bbdfSmrg      esac
546335c4bbdfSmrg      shift
546435c4bbdfSmrg    done ;;
546535c4bbdfSmrg  esac
54666747b715Smrg  func_exec_program_core \${1+\"\$@\"}
54676747b715Smrg}
54686747b715Smrg
54696747b715Smrg  # Parse options
54706747b715Smrg  func_parse_lt_options \"\$0\" \${1+\"\$@\"}
547105b261ecSmrg
54724642e01fSmrg  # Find the directory that this script lives in.
54736747b715Smrg  thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
54744642e01fSmrg  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
547505b261ecSmrg
54764642e01fSmrg  # Follow symbolic links until we get to the real thisdir.
54776747b715Smrg  file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
54784642e01fSmrg  while test -n \"\$file\"; do
54796747b715Smrg    destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
548005b261ecSmrg
54814642e01fSmrg    # If there was a directory component, then change thisdir.
54824642e01fSmrg    if test \"x\$destdir\" != \"x\$file\"; then
54834642e01fSmrg      case \"\$destdir\" in
54844642e01fSmrg      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
54854642e01fSmrg      *) thisdir=\"\$thisdir/\$destdir\" ;;
548605b261ecSmrg      esac
54874642e01fSmrg    fi
548805b261ecSmrg
54896747b715Smrg    file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
54906747b715Smrg    file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
54914642e01fSmrg  done
549205b261ecSmrg
54934642e01fSmrg  # Usually 'no', except on cygwin/mingw when embedded into
54944642e01fSmrg  # the cwrapper.
54956747b715Smrg  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
54964642e01fSmrg  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
54974642e01fSmrg    # special case for '.'
54984642e01fSmrg    if test \"\$thisdir\" = \".\"; then
54994642e01fSmrg      thisdir=\`pwd\`
55004642e01fSmrg    fi
55014642e01fSmrg    # remove .libs from thisdir
55024642e01fSmrg    case \"\$thisdir\" in
55036747b715Smrg    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
55044642e01fSmrg    $objdir )   thisdir=. ;;
55054642e01fSmrg    esac
55064642e01fSmrg  fi
55074642e01fSmrg
55084642e01fSmrg  # Try to get the absolute directory name.
55094642e01fSmrg  absdir=\`cd \"\$thisdir\" && pwd\`
55104642e01fSmrg  test -n \"\$absdir\" && thisdir=\"\$absdir\"
55114642e01fSmrg"
55124642e01fSmrg
551335c4bbdfSmrg	if test yes = "$fast_install"; then
55144642e01fSmrg	  $ECHO "\
55154642e01fSmrg  program=lt-'$outputname'$exeext
55164642e01fSmrg  progdir=\"\$thisdir/$objdir\"
55174642e01fSmrg
55184642e01fSmrg  if test ! -f \"\$progdir/\$program\" ||
551935c4bbdfSmrg     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\
55204642e01fSmrg       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
55214642e01fSmrg
55224642e01fSmrg    file=\"\$\$-\$program\"
55234642e01fSmrg
55244642e01fSmrg    if test ! -d \"\$progdir\"; then
55254642e01fSmrg      $MKDIR \"\$progdir\"
55264642e01fSmrg    else
55274642e01fSmrg      $RM \"\$progdir/\$file\"
55284642e01fSmrg    fi"
55294642e01fSmrg
55304642e01fSmrg	  $ECHO "\
55314642e01fSmrg
55324642e01fSmrg    # relink executable if necessary
55334642e01fSmrg    if test -n \"\$relink_command\"; then
55344642e01fSmrg      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
55354642e01fSmrg      else
553635c4bbdfSmrg	\$ECHO \"\$relink_command_output\" >&2
55374642e01fSmrg	$RM \"\$progdir/\$file\"
55384642e01fSmrg	exit 1
553905b261ecSmrg      fi
55404642e01fSmrg    fi
554105b261ecSmrg
55424642e01fSmrg    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
55434642e01fSmrg    { $RM \"\$progdir/\$program\";
55444642e01fSmrg      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
55454642e01fSmrg    $RM \"\$progdir/\$file\"
55464642e01fSmrg  fi"
55474642e01fSmrg	else
55484642e01fSmrg	  $ECHO "\
55494642e01fSmrg  program='$outputname'
55504642e01fSmrg  progdir=\"\$thisdir/$objdir\"
55514642e01fSmrg"
555205b261ecSmrg	fi
555305b261ecSmrg
55544642e01fSmrg	$ECHO "\
555505b261ecSmrg
55564642e01fSmrg  if test -f \"\$progdir/\$program\"; then"
555705b261ecSmrg
555835c4bbdfSmrg	# fixup the dll searchpath if we need to.
555935c4bbdfSmrg	#
556035c4bbdfSmrg	# Fix the DLL searchpath if we need to.  Do this before prepending
556135c4bbdfSmrg	# to shlibpath, because on Windows, both are PATH and uninstalled
556235c4bbdfSmrg	# libraries must come first.
556335c4bbdfSmrg	if test -n "$dllsearchpath"; then
556435c4bbdfSmrg	  $ECHO "\
556535c4bbdfSmrg    # Add the dll search path components to the executable PATH
556635c4bbdfSmrg    PATH=$dllsearchpath:\$PATH
556735c4bbdfSmrg"
556835c4bbdfSmrg	fi
556935c4bbdfSmrg
55704642e01fSmrg	# Export our shlibpath_var if we have one.
557135c4bbdfSmrg	if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
55724642e01fSmrg	  $ECHO "\
55734642e01fSmrg    # Add our own library path to $shlibpath_var
55744642e01fSmrg    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
557505b261ecSmrg
55764642e01fSmrg    # Some systems cannot cope with colon-terminated $shlibpath_var
55774642e01fSmrg    # The second colon is a workaround for a bug in BeOS R4 sed
55786747b715Smrg    $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
55794642e01fSmrg
55804642e01fSmrg    export $shlibpath_var
55814642e01fSmrg"
558205b261ecSmrg	fi
558305b261ecSmrg
55844642e01fSmrg	$ECHO "\
55854642e01fSmrg    if test \"\$libtool_execute_magic\" != \"$magic\"; then
55864642e01fSmrg      # Run the actual program with our arguments.
55876747b715Smrg      func_exec_program \${1+\"\$@\"}
55884642e01fSmrg    fi
55894642e01fSmrg  else
55904642e01fSmrg    # The program doesn't exist.
559135c4bbdfSmrg    \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2
55924642e01fSmrg    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
55936747b715Smrg    \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
55944642e01fSmrg    exit 1
55954642e01fSmrg  fi
55964642e01fSmrgfi\
55974642e01fSmrg"
55984642e01fSmrg}
559905b261ecSmrg
560005b261ecSmrg
56014642e01fSmrg# func_emit_cwrapperexe_src
56024642e01fSmrg# emit the source code for a wrapper executable on stdout
56034642e01fSmrg# Must ONLY be called from within func_mode_link because
56044642e01fSmrg# it depends on a number of variable set therein.
56054642e01fSmrgfunc_emit_cwrapperexe_src ()
56064642e01fSmrg{
56074642e01fSmrg	cat <<EOF
560805b261ecSmrg
56094642e01fSmrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
561035c4bbdfSmrg   Generated by $PROGRAM (GNU $PACKAGE) $VERSION
561105b261ecSmrg
56124642e01fSmrg   The $output program cannot be directly executed until all the libtool
56134642e01fSmrg   libraries that it depends on are installed.
561405b261ecSmrg
56154642e01fSmrg   This wrapper executable should never be moved out of the build directory.
56164642e01fSmrg   If it is, it will not operate correctly.
56174642e01fSmrg*/
56184642e01fSmrgEOF
56194642e01fSmrg	    cat <<"EOF"
56206747b715Smrg#ifdef _MSC_VER
56216747b715Smrg# define _CRT_SECURE_NO_DEPRECATE 1
56226747b715Smrg#endif
56234642e01fSmrg#include <stdio.h>
56244642e01fSmrg#include <stdlib.h>
56254642e01fSmrg#ifdef _MSC_VER
56264642e01fSmrg# include <direct.h>
56274642e01fSmrg# include <process.h>
56284642e01fSmrg# include <io.h>
56294642e01fSmrg#else
56304642e01fSmrg# include <unistd.h>
56314642e01fSmrg# include <stdint.h>
56324642e01fSmrg# ifdef __CYGWIN__
56334642e01fSmrg#  include <io.h>
56346747b715Smrg# endif
56356747b715Smrg#endif
56366747b715Smrg#include <malloc.h>
56376747b715Smrg#include <stdarg.h>
56386747b715Smrg#include <assert.h>
56396747b715Smrg#include <string.h>
56406747b715Smrg#include <ctype.h>
56416747b715Smrg#include <errno.h>
56426747b715Smrg#include <fcntl.h>
56436747b715Smrg#include <sys/stat.h>
56446747b715Smrg
564535c4bbdfSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
564635c4bbdfSmrg
56476747b715Smrg/* declarations of non-ANSI functions */
564835c4bbdfSmrg#if defined __MINGW32__
56496747b715Smrg# ifdef __STRICT_ANSI__
56506747b715Smrgint _putenv (const char *);
56516747b715Smrg# endif
565235c4bbdfSmrg#elif defined __CYGWIN__
56536747b715Smrg# ifdef __STRICT_ANSI__
56544642e01fSmrgchar *realpath (const char *, char *);
56554642e01fSmrgint putenv (char *);
56564642e01fSmrgint setenv (const char *, const char *, int);
56574642e01fSmrg# endif
565835c4bbdfSmrg/* #elif defined other_platform || defined ... */
56596747b715Smrg#endif
56606747b715Smrg
56616747b715Smrg/* portability defines, excluding path handling macros */
566235c4bbdfSmrg#if defined _MSC_VER
56636747b715Smrg# define setmode _setmode
56646747b715Smrg# define stat    _stat
56656747b715Smrg# define chmod   _chmod
56666747b715Smrg# define getcwd  _getcwd
56676747b715Smrg# define putenv  _putenv
56686747b715Smrg# define S_IXUSR _S_IEXEC
566935c4bbdfSmrg#elif defined __MINGW32__
56706747b715Smrg# define setmode _setmode
56716747b715Smrg# define stat    _stat
56726747b715Smrg# define chmod   _chmod
56736747b715Smrg# define getcwd  _getcwd
56746747b715Smrg# define putenv  _putenv
567535c4bbdfSmrg#elif defined __CYGWIN__
56766747b715Smrg# define HAVE_SETENV
56776747b715Smrg# define FOPEN_WB "wb"
567835c4bbdfSmrg/* #elif defined other platforms ... */
56794642e01fSmrg#endif
568005b261ecSmrg
568135c4bbdfSmrg#if defined PATH_MAX
56824642e01fSmrg# define LT_PATHMAX PATH_MAX
568335c4bbdfSmrg#elif defined MAXPATHLEN
56844642e01fSmrg# define LT_PATHMAX MAXPATHLEN
56854642e01fSmrg#else
56864642e01fSmrg# define LT_PATHMAX 1024
56874642e01fSmrg#endif
568805b261ecSmrg
56894642e01fSmrg#ifndef S_IXOTH
56904642e01fSmrg# define S_IXOTH 0
56914642e01fSmrg#endif
56924642e01fSmrg#ifndef S_IXGRP
56934642e01fSmrg# define S_IXGRP 0
56944642e01fSmrg#endif
569505b261ecSmrg
56966747b715Smrg/* path handling portability macros */
56974642e01fSmrg#ifndef DIR_SEPARATOR
56984642e01fSmrg# define DIR_SEPARATOR '/'
56994642e01fSmrg# define PATH_SEPARATOR ':'
57004642e01fSmrg#endif
570105b261ecSmrg
570235c4bbdfSmrg#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \
570335c4bbdfSmrg  defined __OS2__
57044642e01fSmrg# define HAVE_DOS_BASED_FILE_SYSTEM
57054642e01fSmrg# define FOPEN_WB "wb"
57064642e01fSmrg# ifndef DIR_SEPARATOR_2
57074642e01fSmrg#  define DIR_SEPARATOR_2 '\\'
57084642e01fSmrg# endif
57094642e01fSmrg# ifndef PATH_SEPARATOR_2
57104642e01fSmrg#  define PATH_SEPARATOR_2 ';'
57114642e01fSmrg# endif
57124642e01fSmrg#endif
571305b261ecSmrg
57144642e01fSmrg#ifndef DIR_SEPARATOR_2
57154642e01fSmrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
57164642e01fSmrg#else /* DIR_SEPARATOR_2 */
57174642e01fSmrg# define IS_DIR_SEPARATOR(ch) \
57184642e01fSmrg	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
57194642e01fSmrg#endif /* DIR_SEPARATOR_2 */
572005b261ecSmrg
57214642e01fSmrg#ifndef PATH_SEPARATOR_2
57224642e01fSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
57234642e01fSmrg#else /* PATH_SEPARATOR_2 */
57244642e01fSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
57254642e01fSmrg#endif /* PATH_SEPARATOR_2 */
572605b261ecSmrg
57274642e01fSmrg#ifndef FOPEN_WB
57284642e01fSmrg# define FOPEN_WB "w"
57294642e01fSmrg#endif
57304642e01fSmrg#ifndef _O_BINARY
57314642e01fSmrg# define _O_BINARY 0
57324642e01fSmrg#endif
573305b261ecSmrg
57344642e01fSmrg#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
57354642e01fSmrg#define XFREE(stale) do { \
573635c4bbdfSmrg  if (stale) { free (stale); stale = 0; } \
57374642e01fSmrg} while (0)
573805b261ecSmrg
573935c4bbdfSmrg#if defined LT_DEBUGWRAPPER
57406747b715Smrgstatic int lt_debug = 1;
57414642e01fSmrg#else
57426747b715Smrgstatic int lt_debug = 0;
57434642e01fSmrg#endif
574405b261ecSmrg
57456747b715Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
574605b261ecSmrg
57474642e01fSmrgvoid *xmalloc (size_t num);
57484642e01fSmrgchar *xstrdup (const char *string);
57494642e01fSmrgconst char *base_name (const char *name);
57504642e01fSmrgchar *find_executable (const char *wrapper);
57514642e01fSmrgchar *chase_symlinks (const char *pathspec);
57524642e01fSmrgint make_executable (const char *path);
57534642e01fSmrgint check_executable (const char *path);
57544642e01fSmrgchar *strendzap (char *str, const char *pat);
57556747b715Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...);
57566747b715Smrgvoid lt_fatal (const char *file, int line, const char *message, ...);
57576747b715Smrgstatic const char *nonnull (const char *s);
57586747b715Smrgstatic const char *nonempty (const char *s);
57594642e01fSmrgvoid lt_setenv (const char *name, const char *value);
57604642e01fSmrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end);
57614642e01fSmrgvoid lt_update_exe_path (const char *name, const char *value);
57624642e01fSmrgvoid lt_update_lib_path (const char *name, const char *value);
57636747b715Smrgchar **prepare_spawn (char **argv);
57646747b715Smrgvoid lt_dump_script (FILE *f);
57654642e01fSmrgEOF
57664642e01fSmrg
57674642e01fSmrg	    cat <<EOF
576835c4bbdfSmrg#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5)
576935c4bbdfSmrg# define externally_visible volatile
577035c4bbdfSmrg#else
577135c4bbdfSmrg# define externally_visible __attribute__((externally_visible)) volatile
577235c4bbdfSmrg#endif
577335c4bbdfSmrgexternally_visible const char * MAGIC_EXE = "$magic_exe";
57744642e01fSmrgconst char * LIB_PATH_VARNAME = "$shlibpath_var";
57754642e01fSmrgEOF
577605b261ecSmrg
577735c4bbdfSmrg	    if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
577835c4bbdfSmrg              func_to_host_path "$temp_rpath"
57794642e01fSmrg	      cat <<EOF
578035c4bbdfSmrgconst char * LIB_PATH_VALUE   = "$func_to_host_path_result";
57814642e01fSmrgEOF
57824642e01fSmrg	    else
57834642e01fSmrg	      cat <<"EOF"
57844642e01fSmrgconst char * LIB_PATH_VALUE   = "";
57854642e01fSmrgEOF
578605b261ecSmrg	    fi
578705b261ecSmrg
57884642e01fSmrg	    if test -n "$dllsearchpath"; then
578935c4bbdfSmrg              func_to_host_path "$dllsearchpath:"
57904642e01fSmrg	      cat <<EOF
57914642e01fSmrgconst char * EXE_PATH_VARNAME = "PATH";
579235c4bbdfSmrgconst char * EXE_PATH_VALUE   = "$func_to_host_path_result";
579305b261ecSmrgEOF
579405b261ecSmrg	    else
57954642e01fSmrg	      cat <<"EOF"
57964642e01fSmrgconst char * EXE_PATH_VARNAME = "";
57974642e01fSmrgconst char * EXE_PATH_VALUE   = "";
57984642e01fSmrgEOF
579905b261ecSmrg	    fi
58004642e01fSmrg
580135c4bbdfSmrg	    if test yes = "$fast_install"; then
58024642e01fSmrg	      cat <<EOF
58034642e01fSmrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
58044642e01fSmrgEOF
580505b261ecSmrg	    else
58064642e01fSmrg	      cat <<EOF
58074642e01fSmrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
58084642e01fSmrgEOF
580905b261ecSmrg	    fi
581005b261ecSmrg
581105b261ecSmrg
58124642e01fSmrg	    cat <<"EOF"
581305b261ecSmrg
58144642e01fSmrg#define LTWRAPPER_OPTION_PREFIX         "--lt-"
581505b261ecSmrg
58164642e01fSmrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
58174642e01fSmrgstatic const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
58186747b715Smrgstatic const char *debug_opt            = LTWRAPPER_OPTION_PREFIX "debug";
581905b261ecSmrg
58204642e01fSmrgint
58214642e01fSmrgmain (int argc, char *argv[])
58224642e01fSmrg{
58234642e01fSmrg  char **newargz;
58244642e01fSmrg  int  newargc;
58254642e01fSmrg  char *tmp_pathspec;
58264642e01fSmrg  char *actual_cwrapper_path;
58274642e01fSmrg  char *actual_cwrapper_name;
58284642e01fSmrg  char *target_name;
58294642e01fSmrg  char *lt_argv_zero;
583035c4bbdfSmrg  int rval = 127;
583105b261ecSmrg
58324642e01fSmrg  int i;
583305b261ecSmrg
58344642e01fSmrg  program_name = (char *) xstrdup (base_name (argv[0]));
583535c4bbdfSmrg  newargz = XMALLOC (char *, (size_t) argc + 1);
583605b261ecSmrg
58376747b715Smrg  /* very simple arg parsing; don't want to rely on getopt
58386747b715Smrg   * also, copy all non cwrapper options to newargz, except
58396747b715Smrg   * argz[0], which is handled differently
58406747b715Smrg   */
58416747b715Smrg  newargc=0;
58424642e01fSmrg  for (i = 1; i < argc; i++)
58434642e01fSmrg    {
584435c4bbdfSmrg      if (STREQ (argv[i], dumpscript_opt))
58454642e01fSmrg	{
58464642e01fSmrgEOF
584735c4bbdfSmrg	    case $host in
58484642e01fSmrg	      *mingw* | *cygwin* )
58494642e01fSmrg		# make stdout use "unix" line endings
58504642e01fSmrg		echo "          setmode(1,_O_BINARY);"
58514642e01fSmrg		;;
58524642e01fSmrg	      esac
585305b261ecSmrg
58544642e01fSmrg	    cat <<"EOF"
58556747b715Smrg	  lt_dump_script (stdout);
58564642e01fSmrg	  return 0;
58574642e01fSmrg	}
585835c4bbdfSmrg      if (STREQ (argv[i], debug_opt))
58596747b715Smrg	{
58606747b715Smrg          lt_debug = 1;
58616747b715Smrg          continue;
58626747b715Smrg	}
586335c4bbdfSmrg      if (STREQ (argv[i], ltwrapper_option_prefix))
58646747b715Smrg        {
58656747b715Smrg          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
58666747b715Smrg             namespace, but it is not one of the ones we know about and
58676747b715Smrg             have already dealt with, above (inluding dump-script), then
58686747b715Smrg             report an error. Otherwise, targets might begin to believe
58696747b715Smrg             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
58706747b715Smrg             namespace. The first time any user complains about this, we'll
58716747b715Smrg             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
58726747b715Smrg             or a configure.ac-settable value.
58736747b715Smrg           */
58746747b715Smrg          lt_fatal (__FILE__, __LINE__,
58756747b715Smrg		    "unrecognized %s option: '%s'",
58766747b715Smrg                    ltwrapper_option_prefix, argv[i]);
58776747b715Smrg        }
58786747b715Smrg      /* otherwise ... */
58796747b715Smrg      newargz[++newargc] = xstrdup (argv[i]);
58804642e01fSmrg    }
58816747b715Smrg  newargz[++newargc] = NULL;
58826747b715Smrg
58836747b715SmrgEOF
58846747b715Smrg	    cat <<EOF
58856747b715Smrg  /* The GNU banner must be the first non-error debug message */
588635c4bbdfSmrg  lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n");
58876747b715SmrgEOF
58886747b715Smrg	    cat <<"EOF"
58896747b715Smrg  lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
58906747b715Smrg  lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
589105b261ecSmrg
58924642e01fSmrg  tmp_pathspec = find_executable (argv[0]);
58934642e01fSmrg  if (tmp_pathspec == NULL)
58946747b715Smrg    lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
58956747b715Smrg  lt_debugprintf (__FILE__, __LINE__,
58966747b715Smrg                  "(main) found exe (before symlink chase) at: %s\n",
58976747b715Smrg		  tmp_pathspec);
58984642e01fSmrg
58994642e01fSmrg  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
59006747b715Smrg  lt_debugprintf (__FILE__, __LINE__,
59016747b715Smrg                  "(main) found exe (after symlink chase) at: %s\n",
59026747b715Smrg		  actual_cwrapper_path);
59034642e01fSmrg  XFREE (tmp_pathspec);
59044642e01fSmrg
59056747b715Smrg  actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
59064642e01fSmrg  strendzap (actual_cwrapper_path, actual_cwrapper_name);
59074642e01fSmrg
59084642e01fSmrg  /* wrapper name transforms */
59094642e01fSmrg  strendzap (actual_cwrapper_name, ".exe");
59104642e01fSmrg  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
59114642e01fSmrg  XFREE (actual_cwrapper_name);
59124642e01fSmrg  actual_cwrapper_name = tmp_pathspec;
59134642e01fSmrg  tmp_pathspec = 0;
59144642e01fSmrg
59154642e01fSmrg  /* target_name transforms -- use actual target program name; might have lt- prefix */
59164642e01fSmrg  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
59174642e01fSmrg  strendzap (target_name, ".exe");
59184642e01fSmrg  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
59194642e01fSmrg  XFREE (target_name);
59204642e01fSmrg  target_name = tmp_pathspec;
59214642e01fSmrg  tmp_pathspec = 0;
59224642e01fSmrg
59236747b715Smrg  lt_debugprintf (__FILE__, __LINE__,
59246747b715Smrg		  "(main) libtool target name: %s\n",
59256747b715Smrg		  target_name);
59264642e01fSmrgEOF
592705b261ecSmrg
59284642e01fSmrg	    cat <<EOF
59294642e01fSmrg  newargz[0] =
59304642e01fSmrg    XMALLOC (char, (strlen (actual_cwrapper_path) +
59314642e01fSmrg		    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
59324642e01fSmrg  strcpy (newargz[0], actual_cwrapper_path);
59334642e01fSmrg  strcat (newargz[0], "$objdir");
59344642e01fSmrg  strcat (newargz[0], "/");
59354642e01fSmrgEOF
593605b261ecSmrg
59374642e01fSmrg	    cat <<"EOF"
59384642e01fSmrg  /* stop here, and copy so we don't have to do this twice */
59394642e01fSmrg  tmp_pathspec = xstrdup (newargz[0]);
594005b261ecSmrg
59414642e01fSmrg  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
59424642e01fSmrg  strcat (newargz[0], actual_cwrapper_name);
594305b261ecSmrg
59444642e01fSmrg  /* DO want the lt- prefix here if it exists, so use target_name */
59454642e01fSmrg  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
59464642e01fSmrg  XFREE (tmp_pathspec);
59474642e01fSmrg  tmp_pathspec = NULL;
59484642e01fSmrgEOF
594905b261ecSmrg
59504642e01fSmrg	    case $host_os in
59514642e01fSmrg	      mingw*)
59524642e01fSmrg	    cat <<"EOF"
59534642e01fSmrg  {
59544642e01fSmrg    char* p;
59554642e01fSmrg    while ((p = strchr (newargz[0], '\\')) != NULL)
59564642e01fSmrg      {
59574642e01fSmrg	*p = '/';
59584642e01fSmrg      }
59594642e01fSmrg    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
59604642e01fSmrg      {
59614642e01fSmrg	*p = '/';
59624642e01fSmrg      }
59634642e01fSmrg  }
59644642e01fSmrgEOF
59654642e01fSmrg	    ;;
59664642e01fSmrg	    esac
596705b261ecSmrg
59684642e01fSmrg	    cat <<"EOF"
59694642e01fSmrg  XFREE (target_name);
59704642e01fSmrg  XFREE (actual_cwrapper_path);
59714642e01fSmrg  XFREE (actual_cwrapper_name);
597205b261ecSmrg
59734642e01fSmrg  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
59744642e01fSmrg  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
597535c4bbdfSmrg  /* Update the DLL searchpath.  EXE_PATH_VALUE ($dllsearchpath) must
597635c4bbdfSmrg     be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
597735c4bbdfSmrg     because on Windows, both *_VARNAMEs are PATH but uninstalled
597835c4bbdfSmrg     libraries must come first. */
5979475c125cSmrg  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
598035c4bbdfSmrg  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
598105b261ecSmrg
59826747b715Smrg  lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
59836747b715Smrg		  nonnull (lt_argv_zero));
59844642e01fSmrg  for (i = 0; i < newargc; i++)
59854642e01fSmrg    {
59866747b715Smrg      lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
59876747b715Smrg		      i, nonnull (newargz[i]));
59884642e01fSmrg    }
598905b261ecSmrg
59904642e01fSmrgEOF
599105b261ecSmrg
59924642e01fSmrg	    case $host_os in
59934642e01fSmrg	      mingw*)
59944642e01fSmrg		cat <<"EOF"
59954642e01fSmrg  /* execv doesn't actually work on mingw as expected on unix */
59966747b715Smrg  newargz = prepare_spawn (newargz);
599735c4bbdfSmrg  rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
59984642e01fSmrg  if (rval == -1)
59994642e01fSmrg    {
60004642e01fSmrg      /* failed to start process */
60016747b715Smrg      lt_debugprintf (__FILE__, __LINE__,
60026747b715Smrg		      "(main) failed to launch target \"%s\": %s\n",
60036747b715Smrg		      lt_argv_zero, nonnull (strerror (errno)));
60044642e01fSmrg      return 127;
60054642e01fSmrg    }
60064642e01fSmrg  return rval;
60074642e01fSmrgEOF
60084642e01fSmrg		;;
60094642e01fSmrg	      *)
60104642e01fSmrg		cat <<"EOF"
60114642e01fSmrg  execv (lt_argv_zero, newargz);
60124642e01fSmrg  return rval; /* =127, but avoids unused variable warning */
60134642e01fSmrgEOF
60144642e01fSmrg		;;
60154642e01fSmrg	    esac
601605b261ecSmrg
60174642e01fSmrg	    cat <<"EOF"
60184642e01fSmrg}
601905b261ecSmrg
60204642e01fSmrgvoid *
60214642e01fSmrgxmalloc (size_t num)
60224642e01fSmrg{
60234642e01fSmrg  void *p = (void *) malloc (num);
60244642e01fSmrg  if (!p)
60256747b715Smrg    lt_fatal (__FILE__, __LINE__, "memory exhausted");
602605b261ecSmrg
60274642e01fSmrg  return p;
60284642e01fSmrg}
602905b261ecSmrg
60304642e01fSmrgchar *
60314642e01fSmrgxstrdup (const char *string)
60324642e01fSmrg{
60334642e01fSmrg  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
60344642e01fSmrg			  string) : NULL;
60354642e01fSmrg}
603605b261ecSmrg
60374642e01fSmrgconst char *
60384642e01fSmrgbase_name (const char *name)
60394642e01fSmrg{
60404642e01fSmrg  const char *base;
604105b261ecSmrg
604235c4bbdfSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM
60434642e01fSmrg  /* Skip over the disk name in MSDOS pathnames. */
60444642e01fSmrg  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
60454642e01fSmrg    name += 2;
60464642e01fSmrg#endif
604705b261ecSmrg
60484642e01fSmrg  for (base = name; *name; name++)
60494642e01fSmrg    if (IS_DIR_SEPARATOR (*name))
60504642e01fSmrg      base = name + 1;
60514642e01fSmrg  return base;
60524642e01fSmrg}
605305b261ecSmrg
60544642e01fSmrgint
60554642e01fSmrgcheck_executable (const char *path)
60564642e01fSmrg{
60574642e01fSmrg  struct stat st;
605805b261ecSmrg
60596747b715Smrg  lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
60606747b715Smrg                  nonempty (path));
60614642e01fSmrg  if ((!path) || (!*path))
60624642e01fSmrg    return 0;
606305b261ecSmrg
60644642e01fSmrg  if ((stat (path, &st) >= 0)
60654642e01fSmrg      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
60664642e01fSmrg    return 1;
60674642e01fSmrg  else
60684642e01fSmrg    return 0;
60694642e01fSmrg}
607005b261ecSmrg
60714642e01fSmrgint
60724642e01fSmrgmake_executable (const char *path)
60734642e01fSmrg{
60744642e01fSmrg  int rval = 0;
60754642e01fSmrg  struct stat st;
607605b261ecSmrg
60776747b715Smrg  lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
60786747b715Smrg                  nonempty (path));
60794642e01fSmrg  if ((!path) || (!*path))
60804642e01fSmrg    return 0;
608105b261ecSmrg
60824642e01fSmrg  if (stat (path, &st) >= 0)
60834642e01fSmrg    {
60844642e01fSmrg      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
60854642e01fSmrg    }
60864642e01fSmrg  return rval;
60874642e01fSmrg}
608805b261ecSmrg
60894642e01fSmrg/* Searches for the full path of the wrapper.  Returns
60904642e01fSmrg   newly allocated full path name if found, NULL otherwise
60914642e01fSmrg   Does not chase symlinks, even on platforms that support them.
60924642e01fSmrg*/
60934642e01fSmrgchar *
60944642e01fSmrgfind_executable (const char *wrapper)
60954642e01fSmrg{
60964642e01fSmrg  int has_slash = 0;
60974642e01fSmrg  const char *p;
60984642e01fSmrg  const char *p_next;
60994642e01fSmrg  /* static buffer for getcwd */
61004642e01fSmrg  char tmp[LT_PATHMAX + 1];
610135c4bbdfSmrg  size_t tmp_len;
61024642e01fSmrg  char *concat_name;
610305b261ecSmrg
61046747b715Smrg  lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
61056747b715Smrg                  nonempty (wrapper));
610605b261ecSmrg
61074642e01fSmrg  if ((wrapper == NULL) || (*wrapper == '\0'))
61084642e01fSmrg    return NULL;
610905b261ecSmrg
61104642e01fSmrg  /* Absolute path? */
611135c4bbdfSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM
61124642e01fSmrg  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
61134642e01fSmrg    {
61144642e01fSmrg      concat_name = xstrdup (wrapper);
61154642e01fSmrg      if (check_executable (concat_name))
61164642e01fSmrg	return concat_name;
61174642e01fSmrg      XFREE (concat_name);
61184642e01fSmrg    }
61194642e01fSmrg  else
61204642e01fSmrg    {
61214642e01fSmrg#endif
61224642e01fSmrg      if (IS_DIR_SEPARATOR (wrapper[0]))
61234642e01fSmrg	{
61244642e01fSmrg	  concat_name = xstrdup (wrapper);
61254642e01fSmrg	  if (check_executable (concat_name))
61264642e01fSmrg	    return concat_name;
61274642e01fSmrg	  XFREE (concat_name);
61284642e01fSmrg	}
612935c4bbdfSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM
61304642e01fSmrg    }
61314642e01fSmrg#endif
613205b261ecSmrg
61334642e01fSmrg  for (p = wrapper; *p; p++)
61344642e01fSmrg    if (*p == '/')
61354642e01fSmrg      {
61364642e01fSmrg	has_slash = 1;
61374642e01fSmrg	break;
61384642e01fSmrg      }
61394642e01fSmrg  if (!has_slash)
61404642e01fSmrg    {
61414642e01fSmrg      /* no slashes; search PATH */
61424642e01fSmrg      const char *path = getenv ("PATH");
61434642e01fSmrg      if (path != NULL)
61444642e01fSmrg	{
61454642e01fSmrg	  for (p = path; *p; p = p_next)
61464642e01fSmrg	    {
61474642e01fSmrg	      const char *q;
61484642e01fSmrg	      size_t p_len;
61494642e01fSmrg	      for (q = p; *q; q++)
61504642e01fSmrg		if (IS_PATH_SEPARATOR (*q))
61514642e01fSmrg		  break;
615235c4bbdfSmrg	      p_len = (size_t) (q - p);
61534642e01fSmrg	      p_next = (*q == '\0' ? q : q + 1);
61544642e01fSmrg	      if (p_len == 0)
61554642e01fSmrg		{
61564642e01fSmrg		  /* empty path: current directory */
61574642e01fSmrg		  if (getcwd (tmp, LT_PATHMAX) == NULL)
61586747b715Smrg		    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
61596747b715Smrg                              nonnull (strerror (errno)));
61604642e01fSmrg		  tmp_len = strlen (tmp);
61614642e01fSmrg		  concat_name =
61624642e01fSmrg		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
61634642e01fSmrg		  memcpy (concat_name, tmp, tmp_len);
61644642e01fSmrg		  concat_name[tmp_len] = '/';
61654642e01fSmrg		  strcpy (concat_name + tmp_len + 1, wrapper);
61664642e01fSmrg		}
61674642e01fSmrg	      else
61684642e01fSmrg		{
61694642e01fSmrg		  concat_name =
61704642e01fSmrg		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
61714642e01fSmrg		  memcpy (concat_name, p, p_len);
61724642e01fSmrg		  concat_name[p_len] = '/';
61734642e01fSmrg		  strcpy (concat_name + p_len + 1, wrapper);
61744642e01fSmrg		}
61754642e01fSmrg	      if (check_executable (concat_name))
61764642e01fSmrg		return concat_name;
61774642e01fSmrg	      XFREE (concat_name);
61784642e01fSmrg	    }
61794642e01fSmrg	}
61804642e01fSmrg      /* not found in PATH; assume curdir */
61814642e01fSmrg    }
61824642e01fSmrg  /* Relative path | not found in path: prepend cwd */
61834642e01fSmrg  if (getcwd (tmp, LT_PATHMAX) == NULL)
61846747b715Smrg    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
61856747b715Smrg              nonnull (strerror (errno)));
61864642e01fSmrg  tmp_len = strlen (tmp);
61874642e01fSmrg  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
61884642e01fSmrg  memcpy (concat_name, tmp, tmp_len);
61894642e01fSmrg  concat_name[tmp_len] = '/';
61904642e01fSmrg  strcpy (concat_name + tmp_len + 1, wrapper);
619105b261ecSmrg
61924642e01fSmrg  if (check_executable (concat_name))
61934642e01fSmrg    return concat_name;
61944642e01fSmrg  XFREE (concat_name);
61954642e01fSmrg  return NULL;
61964642e01fSmrg}
619705b261ecSmrg
61984642e01fSmrgchar *
61994642e01fSmrgchase_symlinks (const char *pathspec)
62004642e01fSmrg{
62014642e01fSmrg#ifndef S_ISLNK
62024642e01fSmrg  return xstrdup (pathspec);
62034642e01fSmrg#else
62044642e01fSmrg  char buf[LT_PATHMAX];
62054642e01fSmrg  struct stat s;
62064642e01fSmrg  char *tmp_pathspec = xstrdup (pathspec);
62074642e01fSmrg  char *p;
62084642e01fSmrg  int has_symlinks = 0;
62094642e01fSmrg  while (strlen (tmp_pathspec) && !has_symlinks)
62104642e01fSmrg    {
62116747b715Smrg      lt_debugprintf (__FILE__, __LINE__,
62126747b715Smrg		      "checking path component for symlinks: %s\n",
62136747b715Smrg		      tmp_pathspec);
62144642e01fSmrg      if (lstat (tmp_pathspec, &s) == 0)
62154642e01fSmrg	{
62164642e01fSmrg	  if (S_ISLNK (s.st_mode) != 0)
62174642e01fSmrg	    {
62184642e01fSmrg	      has_symlinks = 1;
62194642e01fSmrg	      break;
62204642e01fSmrg	    }
622105b261ecSmrg
62224642e01fSmrg	  /* search backwards for last DIR_SEPARATOR */
62234642e01fSmrg	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
62244642e01fSmrg	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
62254642e01fSmrg	    p--;
62264642e01fSmrg	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
62274642e01fSmrg	    {
62284642e01fSmrg	      /* no more DIR_SEPARATORS left */
62294642e01fSmrg	      break;
62304642e01fSmrg	    }
62314642e01fSmrg	  *p = '\0';
62324642e01fSmrg	}
62334642e01fSmrg      else
62344642e01fSmrg	{
62356747b715Smrg	  lt_fatal (__FILE__, __LINE__,
62366747b715Smrg		    "error accessing file \"%s\": %s",
62376747b715Smrg		    tmp_pathspec, nonnull (strerror (errno)));
62384642e01fSmrg	}
62394642e01fSmrg    }
62404642e01fSmrg  XFREE (tmp_pathspec);
624105b261ecSmrg
62424642e01fSmrg  if (!has_symlinks)
62434642e01fSmrg    {
62444642e01fSmrg      return xstrdup (pathspec);
62454642e01fSmrg    }
624605b261ecSmrg
62474642e01fSmrg  tmp_pathspec = realpath (pathspec, buf);
62484642e01fSmrg  if (tmp_pathspec == 0)
62494642e01fSmrg    {
62506747b715Smrg      lt_fatal (__FILE__, __LINE__,
62516747b715Smrg		"could not follow symlinks for %s", pathspec);
62524642e01fSmrg    }
62534642e01fSmrg  return xstrdup (tmp_pathspec);
62544642e01fSmrg#endif
62554642e01fSmrg}
625605b261ecSmrg
62574642e01fSmrgchar *
62584642e01fSmrgstrendzap (char *str, const char *pat)
62594642e01fSmrg{
62604642e01fSmrg  size_t len, patlen;
626105b261ecSmrg
62624642e01fSmrg  assert (str != NULL);
62634642e01fSmrg  assert (pat != NULL);
626405b261ecSmrg
62654642e01fSmrg  len = strlen (str);
62664642e01fSmrg  patlen = strlen (pat);
626705b261ecSmrg
62684642e01fSmrg  if (patlen <= len)
62694642e01fSmrg    {
62704642e01fSmrg      str += len - patlen;
627135c4bbdfSmrg      if (STREQ (str, pat))
62724642e01fSmrg	*str = '\0';
62734642e01fSmrg    }
62744642e01fSmrg  return str;
62754642e01fSmrg}
627605b261ecSmrg
62776747b715Smrgvoid
62786747b715Smrglt_debugprintf (const char *file, int line, const char *fmt, ...)
62796747b715Smrg{
62806747b715Smrg  va_list args;
62816747b715Smrg  if (lt_debug)
62826747b715Smrg    {
62836747b715Smrg      (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
62846747b715Smrg      va_start (args, fmt);
62856747b715Smrg      (void) vfprintf (stderr, fmt, args);
62866747b715Smrg      va_end (args);
62876747b715Smrg    }
62886747b715Smrg}
62896747b715Smrg
62904642e01fSmrgstatic void
62916747b715Smrglt_error_core (int exit_status, const char *file,
62926747b715Smrg	       int line, const char *mode,
62934642e01fSmrg	       const char *message, va_list ap)
62944642e01fSmrg{
62956747b715Smrg  fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
62964642e01fSmrg  vfprintf (stderr, message, ap);
62974642e01fSmrg  fprintf (stderr, ".\n");
629805b261ecSmrg
62994642e01fSmrg  if (exit_status >= 0)
63004642e01fSmrg    exit (exit_status);
63014642e01fSmrg}
630205b261ecSmrg
63034642e01fSmrgvoid
63046747b715Smrglt_fatal (const char *file, int line, const char *message, ...)
63054642e01fSmrg{
63064642e01fSmrg  va_list ap;
63074642e01fSmrg  va_start (ap, message);
63086747b715Smrg  lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
63094642e01fSmrg  va_end (ap);
63104642e01fSmrg}
631105b261ecSmrg
63126747b715Smrgstatic const char *
63136747b715Smrgnonnull (const char *s)
63146747b715Smrg{
63156747b715Smrg  return s ? s : "(null)";
63166747b715Smrg}
63176747b715Smrg
63186747b715Smrgstatic const char *
63196747b715Smrgnonempty (const char *s)
63206747b715Smrg{
63216747b715Smrg  return (s && !*s) ? "(empty)" : nonnull (s);
63226747b715Smrg}
63236747b715Smrg
63244642e01fSmrgvoid
63254642e01fSmrglt_setenv (const char *name, const char *value)
63264642e01fSmrg{
63276747b715Smrg  lt_debugprintf (__FILE__, __LINE__,
63286747b715Smrg		  "(lt_setenv) setting '%s' to '%s'\n",
63296747b715Smrg                  nonnull (name), nonnull (value));
63304642e01fSmrg  {
63314642e01fSmrg#ifdef HAVE_SETENV
63324642e01fSmrg    /* always make a copy, for consistency with !HAVE_SETENV */
63334642e01fSmrg    char *str = xstrdup (value);
63344642e01fSmrg    setenv (name, str, 1);
63354642e01fSmrg#else
633635c4bbdfSmrg    size_t len = strlen (name) + 1 + strlen (value) + 1;
63374642e01fSmrg    char *str = XMALLOC (char, len);
63384642e01fSmrg    sprintf (str, "%s=%s", name, value);
63394642e01fSmrg    if (putenv (str) != EXIT_SUCCESS)
63404642e01fSmrg      {
63414642e01fSmrg        XFREE (str);
63424642e01fSmrg      }
63434642e01fSmrg#endif
63444642e01fSmrg  }
63454642e01fSmrg}
634605b261ecSmrg
63474642e01fSmrgchar *
63484642e01fSmrglt_extend_str (const char *orig_value, const char *add, int to_end)
63494642e01fSmrg{
63504642e01fSmrg  char *new_value;
63514642e01fSmrg  if (orig_value && *orig_value)
63524642e01fSmrg    {
635335c4bbdfSmrg      size_t orig_value_len = strlen (orig_value);
635435c4bbdfSmrg      size_t add_len = strlen (add);
63554642e01fSmrg      new_value = XMALLOC (char, add_len + orig_value_len + 1);
63564642e01fSmrg      if (to_end)
63574642e01fSmrg        {
63584642e01fSmrg          strcpy (new_value, orig_value);
63594642e01fSmrg          strcpy (new_value + orig_value_len, add);
63604642e01fSmrg        }
63614642e01fSmrg      else
63624642e01fSmrg        {
63634642e01fSmrg          strcpy (new_value, add);
63644642e01fSmrg          strcpy (new_value + add_len, orig_value);
63654642e01fSmrg        }
63664642e01fSmrg    }
63674642e01fSmrg  else
63684642e01fSmrg    {
63694642e01fSmrg      new_value = xstrdup (add);
63704642e01fSmrg    }
63714642e01fSmrg  return new_value;
63724642e01fSmrg}
637305b261ecSmrg
63744642e01fSmrgvoid
63754642e01fSmrglt_update_exe_path (const char *name, const char *value)
63764642e01fSmrg{
63776747b715Smrg  lt_debugprintf (__FILE__, __LINE__,
63786747b715Smrg		  "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
63796747b715Smrg                  nonnull (name), nonnull (value));
638005b261ecSmrg
63814642e01fSmrg  if (name && *name && value && *value)
63824642e01fSmrg    {
63834642e01fSmrg      char *new_value = lt_extend_str (getenv (name), value, 0);
63844642e01fSmrg      /* some systems can't cope with a ':'-terminated path #' */
638535c4bbdfSmrg      size_t len = strlen (new_value);
638635c4bbdfSmrg      while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
63874642e01fSmrg        {
638835c4bbdfSmrg          new_value[--len] = '\0';
63894642e01fSmrg        }
63904642e01fSmrg      lt_setenv (name, new_value);
63914642e01fSmrg      XFREE (new_value);
63924642e01fSmrg    }
63934642e01fSmrg}
639405b261ecSmrg
63954642e01fSmrgvoid
63964642e01fSmrglt_update_lib_path (const char *name, const char *value)
63974642e01fSmrg{
63986747b715Smrg  lt_debugprintf (__FILE__, __LINE__,
63996747b715Smrg		  "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
64006747b715Smrg                  nonnull (name), nonnull (value));
640105b261ecSmrg
64024642e01fSmrg  if (name && *name && value && *value)
64034642e01fSmrg    {
64044642e01fSmrg      char *new_value = lt_extend_str (getenv (name), value, 0);
64054642e01fSmrg      lt_setenv (name, new_value);
64064642e01fSmrg      XFREE (new_value);
64074642e01fSmrg    }
64084642e01fSmrg}
640905b261ecSmrg
64106747b715SmrgEOF
64116747b715Smrg	    case $host_os in
64126747b715Smrg	      mingw*)
64136747b715Smrg		cat <<"EOF"
64146747b715Smrg
64156747b715Smrg/* Prepares an argument vector before calling spawn().
64166747b715Smrg   Note that spawn() does not by itself call the command interpreter
64176747b715Smrg     (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
64186747b715Smrg      ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
64196747b715Smrg         GetVersionEx(&v);
64206747b715Smrg         v.dwPlatformId == VER_PLATFORM_WIN32_NT;
64216747b715Smrg      }) ? "cmd.exe" : "command.com").
64226747b715Smrg   Instead it simply concatenates the arguments, separated by ' ', and calls
64236747b715Smrg   CreateProcess().  We must quote the arguments since Win32 CreateProcess()
64246747b715Smrg   interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
64256747b715Smrg   special way:
64266747b715Smrg   - Space and tab are interpreted as delimiters. They are not treated as
64276747b715Smrg     delimiters if they are surrounded by double quotes: "...".
64286747b715Smrg   - Unescaped double quotes are removed from the input. Their only effect is
64296747b715Smrg     that within double quotes, space and tab are treated like normal
64306747b715Smrg     characters.
64316747b715Smrg   - Backslashes not followed by double quotes are not special.
64326747b715Smrg   - But 2*n+1 backslashes followed by a double quote become
64336747b715Smrg     n backslashes followed by a double quote (n >= 0):
64346747b715Smrg       \" -> "
64356747b715Smrg       \\\" -> \"
64366747b715Smrg       \\\\\" -> \\"
64376747b715Smrg */
64386747b715Smrg#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"
64396747b715Smrg#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"
64406747b715Smrgchar **
64416747b715Smrgprepare_spawn (char **argv)
64426747b715Smrg{
64436747b715Smrg  size_t argc;
64446747b715Smrg  char **new_argv;
64456747b715Smrg  size_t i;
64466747b715Smrg
64476747b715Smrg  /* Count number of arguments.  */
64486747b715Smrg  for (argc = 0; argv[argc] != NULL; argc++)
64496747b715Smrg    ;
64506747b715Smrg
64516747b715Smrg  /* Allocate new argument vector.  */
64526747b715Smrg  new_argv = XMALLOC (char *, argc + 1);
64536747b715Smrg
64546747b715Smrg  /* Put quoted arguments into the new argument vector.  */
64556747b715Smrg  for (i = 0; i < argc; i++)
64566747b715Smrg    {
64576747b715Smrg      const char *string = argv[i];
64586747b715Smrg
64596747b715Smrg      if (string[0] == '\0')
64606747b715Smrg	new_argv[i] = xstrdup ("\"\"");
64616747b715Smrg      else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
64626747b715Smrg	{
64636747b715Smrg	  int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
64646747b715Smrg	  size_t length;
64656747b715Smrg	  unsigned int backslashes;
64666747b715Smrg	  const char *s;
64676747b715Smrg	  char *quoted_string;
64686747b715Smrg	  char *p;
64696747b715Smrg
64706747b715Smrg	  length = 0;
64716747b715Smrg	  backslashes = 0;
64726747b715Smrg	  if (quote_around)
64736747b715Smrg	    length++;
64746747b715Smrg	  for (s = string; *s != '\0'; s++)
64756747b715Smrg	    {
64766747b715Smrg	      char c = *s;
64776747b715Smrg	      if (c == '"')
64786747b715Smrg		length += backslashes + 1;
64796747b715Smrg	      length++;
64806747b715Smrg	      if (c == '\\')
64816747b715Smrg		backslashes++;
64826747b715Smrg	      else
64836747b715Smrg		backslashes = 0;
64846747b715Smrg	    }
64856747b715Smrg	  if (quote_around)
64866747b715Smrg	    length += backslashes + 1;
64876747b715Smrg
64886747b715Smrg	  quoted_string = XMALLOC (char, length + 1);
64896747b715Smrg
64906747b715Smrg	  p = quoted_string;
64916747b715Smrg	  backslashes = 0;
64926747b715Smrg	  if (quote_around)
64936747b715Smrg	    *p++ = '"';
64946747b715Smrg	  for (s = string; *s != '\0'; s++)
64956747b715Smrg	    {
64966747b715Smrg	      char c = *s;
64976747b715Smrg	      if (c == '"')
64986747b715Smrg		{
64996747b715Smrg		  unsigned int j;
65006747b715Smrg		  for (j = backslashes + 1; j > 0; j--)
65016747b715Smrg		    *p++ = '\\';
65026747b715Smrg		}
65036747b715Smrg	      *p++ = c;
65046747b715Smrg	      if (c == '\\')
65056747b715Smrg		backslashes++;
65066747b715Smrg	      else
65076747b715Smrg		backslashes = 0;
65086747b715Smrg	    }
65096747b715Smrg	  if (quote_around)
65106747b715Smrg	    {
65116747b715Smrg	      unsigned int j;
65126747b715Smrg	      for (j = backslashes; j > 0; j--)
65136747b715Smrg		*p++ = '\\';
65146747b715Smrg	      *p++ = '"';
65156747b715Smrg	    }
65166747b715Smrg	  *p = '\0';
65176747b715Smrg
65186747b715Smrg	  new_argv[i] = quoted_string;
65196747b715Smrg	}
65206747b715Smrg      else
65216747b715Smrg	new_argv[i] = (char *) string;
65226747b715Smrg    }
65236747b715Smrg  new_argv[argc] = NULL;
65246747b715Smrg
65256747b715Smrg  return new_argv;
65266747b715Smrg}
65276747b715SmrgEOF
65286747b715Smrg		;;
65296747b715Smrg	    esac
65306747b715Smrg
65316747b715Smrg            cat <<"EOF"
65326747b715Smrgvoid lt_dump_script (FILE* f)
65336747b715Smrg{
65346747b715SmrgEOF
65356747b715Smrg	    func_emit_wrapper yes |
653635c4bbdfSmrg	      $SED -n -e '
653735c4bbdfSmrgs/^\(.\{79\}\)\(..*\)/\1\
653835c4bbdfSmrg\2/
653935c4bbdfSmrgh
654035c4bbdfSmrgs/\([\\"]\)/\\\1/g
654135c4bbdfSmrgs/$/\\n/
654235c4bbdfSmrgs/\([^\n]*\).*/  fputs ("\1", f);/p
654335c4bbdfSmrgg
654435c4bbdfSmrgD'
65456747b715Smrg            cat <<"EOF"
65466747b715Smrg}
65474642e01fSmrgEOF
65484642e01fSmrg}
65494642e01fSmrg# end: func_emit_cwrapperexe_src
655005b261ecSmrg
65516747b715Smrg# func_win32_import_lib_p ARG
65526747b715Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd
65536747b715Smrgfunc_win32_import_lib_p ()
65546747b715Smrg{
655535c4bbdfSmrg    $debug_cmd
655635c4bbdfSmrg
65576747b715Smrg    case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
65586747b715Smrg    *import*) : ;;
65596747b715Smrg    *) false ;;
65606747b715Smrg    esac
65616747b715Smrg}
65626747b715Smrg
656335c4bbdfSmrg# func_suncc_cstd_abi
656435c4bbdfSmrg# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!!
656535c4bbdfSmrg# Several compiler flags select an ABI that is incompatible with the
656635c4bbdfSmrg# Cstd library. Avoid specifying it if any are in CXXFLAGS.
656735c4bbdfSmrgfunc_suncc_cstd_abi ()
656835c4bbdfSmrg{
656935c4bbdfSmrg    $debug_cmd
657035c4bbdfSmrg
657135c4bbdfSmrg    case " $compile_command " in
657235c4bbdfSmrg    *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*)
657335c4bbdfSmrg      suncc_use_cstd_abi=no
657435c4bbdfSmrg      ;;
657535c4bbdfSmrg    *)
657635c4bbdfSmrg      suncc_use_cstd_abi=yes
657735c4bbdfSmrg      ;;
657835c4bbdfSmrg    esac
657935c4bbdfSmrg}
658035c4bbdfSmrg
65814642e01fSmrg# func_mode_link arg...
65824642e01fSmrgfunc_mode_link ()
65834642e01fSmrg{
658435c4bbdfSmrg    $debug_cmd
658535c4bbdfSmrg
65864642e01fSmrg    case $host in
65874642e01fSmrg    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
65884642e01fSmrg      # It is impossible to link a dll without this setting, and
65894642e01fSmrg      # we shouldn't force the makefile maintainer to figure out
659035c4bbdfSmrg      # what system we are compiling for in order to pass an extra
65914642e01fSmrg      # flag for every libtool invocation.
65924642e01fSmrg      # allow_undefined=no
659305b261ecSmrg
65944642e01fSmrg      # FIXME: Unfortunately, there are problems with the above when trying
659535c4bbdfSmrg      # to make a dll that has undefined symbols, in which case not
65964642e01fSmrg      # even a static library is built.  For now, we need to specify
65974642e01fSmrg      # -no-undefined on the libtool link line when we can be certain
65984642e01fSmrg      # that all symbols are satisfied, otherwise we get a static library.
65994642e01fSmrg      allow_undefined=yes
66004642e01fSmrg      ;;
66014642e01fSmrg    *)
66024642e01fSmrg      allow_undefined=yes
66034642e01fSmrg      ;;
66044642e01fSmrg    esac
66054642e01fSmrg    libtool_args=$nonopt
66064642e01fSmrg    base_compile="$nonopt $@"
66074642e01fSmrg    compile_command=$nonopt
66084642e01fSmrg    finalize_command=$nonopt
660905b261ecSmrg
66104642e01fSmrg    compile_rpath=
66114642e01fSmrg    finalize_rpath=
66124642e01fSmrg    compile_shlibpath=
66134642e01fSmrg    finalize_shlibpath=
66144642e01fSmrg    convenience=
66154642e01fSmrg    old_convenience=
66164642e01fSmrg    deplibs=
66174642e01fSmrg    old_deplibs=
66184642e01fSmrg    compiler_flags=
66194642e01fSmrg    linker_flags=
66204642e01fSmrg    dllsearchpath=
66214642e01fSmrg    lib_search_path=`pwd`
66224642e01fSmrg    inst_prefix_dir=
66234642e01fSmrg    new_inherited_linker_flags=
662405b261ecSmrg
66254642e01fSmrg    avoid_version=no
66266747b715Smrg    bindir=
66274642e01fSmrg    dlfiles=
66284642e01fSmrg    dlprefiles=
66294642e01fSmrg    dlself=no
66304642e01fSmrg    export_dynamic=no
66314642e01fSmrg    export_symbols=
66324642e01fSmrg    export_symbols_regex=
66334642e01fSmrg    generated=
66344642e01fSmrg    libobjs=
66354642e01fSmrg    ltlibs=
66364642e01fSmrg    module=no
66374642e01fSmrg    no_install=no
66384642e01fSmrg    objs=
663935c4bbdfSmrg    os2dllname=
66404642e01fSmrg    non_pic_objects=
66414642e01fSmrg    precious_files_regex=
66424642e01fSmrg    prefer_static_libs=no
664335c4bbdfSmrg    preload=false
66444642e01fSmrg    prev=
66454642e01fSmrg    prevarg=
66464642e01fSmrg    release=
66474642e01fSmrg    rpath=
66484642e01fSmrg    xrpath=
66494642e01fSmrg    perm_rpath=
66504642e01fSmrg    temp_rpath=
66514642e01fSmrg    thread_safe=no
66524642e01fSmrg    vinfo=
66534642e01fSmrg    vinfo_number=no
66544642e01fSmrg    weak_libs=
665535c4bbdfSmrg    single_module=$wl-single_module
66564642e01fSmrg    func_infer_tag $base_compile
665705b261ecSmrg
66584642e01fSmrg    # We need to know -static, to get the right output filenames.
66594642e01fSmrg    for arg
66604642e01fSmrg    do
66614642e01fSmrg      case $arg in
66624642e01fSmrg      -shared)
666335c4bbdfSmrg	test yes != "$build_libtool_libs" \
666435c4bbdfSmrg	  && func_fatal_configuration "cannot build a shared library"
66654642e01fSmrg	build_old_libs=no
66664642e01fSmrg	break
66674642e01fSmrg	;;
66684642e01fSmrg      -all-static | -static | -static-libtool-libs)
66694642e01fSmrg	case $arg in
66704642e01fSmrg	-all-static)
667135c4bbdfSmrg	  if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then
66724642e01fSmrg	    func_warning "complete static linking is impossible in this configuration"
66734642e01fSmrg	  fi
66744642e01fSmrg	  if test -n "$link_static_flag"; then
66754642e01fSmrg	    dlopen_self=$dlopen_self_static
66764642e01fSmrg	  fi
66774642e01fSmrg	  prefer_static_libs=yes
66784642e01fSmrg	  ;;
66794642e01fSmrg	-static)
66804642e01fSmrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
66814642e01fSmrg	    dlopen_self=$dlopen_self_static
66824642e01fSmrg	  fi
66834642e01fSmrg	  prefer_static_libs=built
66844642e01fSmrg	  ;;
66854642e01fSmrg	-static-libtool-libs)
66864642e01fSmrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
66874642e01fSmrg	    dlopen_self=$dlopen_self_static
66884642e01fSmrg	  fi
66894642e01fSmrg	  prefer_static_libs=yes
66904642e01fSmrg	  ;;
66914642e01fSmrg	esac
66924642e01fSmrg	build_libtool_libs=no
66934642e01fSmrg	build_old_libs=yes
66944642e01fSmrg	break
66954642e01fSmrg	;;
66964642e01fSmrg      esac
66974642e01fSmrg    done
669805b261ecSmrg
66994642e01fSmrg    # See if our shared archives depend on static archives.
67004642e01fSmrg    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
670105b261ecSmrg
67024642e01fSmrg    # Go through the arguments, transforming them on the way.
67034642e01fSmrg    while test "$#" -gt 0; do
670435c4bbdfSmrg      arg=$1
67054642e01fSmrg      shift
67064642e01fSmrg      func_quote_for_eval "$arg"
67074642e01fSmrg      qarg=$func_quote_for_eval_unquoted_result
67084642e01fSmrg      func_append libtool_args " $func_quote_for_eval_result"
670905b261ecSmrg
67104642e01fSmrg      # If the previous option needs an argument, assign it.
67114642e01fSmrg      if test -n "$prev"; then
67124642e01fSmrg	case $prev in
67134642e01fSmrg	output)
67144642e01fSmrg	  func_append compile_command " @OUTPUT@"
67154642e01fSmrg	  func_append finalize_command " @OUTPUT@"
67164642e01fSmrg	  ;;
67174642e01fSmrg	esac
671805b261ecSmrg
67194642e01fSmrg	case $prev in
67206747b715Smrg	bindir)
672135c4bbdfSmrg	  bindir=$arg
67226747b715Smrg	  prev=
67236747b715Smrg	  continue
67246747b715Smrg	  ;;
67254642e01fSmrg	dlfiles|dlprefiles)
672635c4bbdfSmrg	  $preload || {
67274642e01fSmrg	    # Add the symbol object into the linking commands.
67284642e01fSmrg	    func_append compile_command " @SYMFILE@"
67294642e01fSmrg	    func_append finalize_command " @SYMFILE@"
673035c4bbdfSmrg	    preload=:
673135c4bbdfSmrg	  }
67324642e01fSmrg	  case $arg in
67334642e01fSmrg	  *.la | *.lo) ;;  # We handle these cases below.
67344642e01fSmrg	  force)
673535c4bbdfSmrg	    if test no = "$dlself"; then
67364642e01fSmrg	      dlself=needless
67374642e01fSmrg	      export_dynamic=yes
67384642e01fSmrg	    fi
67394642e01fSmrg	    prev=
67404642e01fSmrg	    continue
67414642e01fSmrg	    ;;
67424642e01fSmrg	  self)
674335c4bbdfSmrg	    if test dlprefiles = "$prev"; then
67444642e01fSmrg	      dlself=yes
674535c4bbdfSmrg	    elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then
67464642e01fSmrg	      dlself=yes
67474642e01fSmrg	    else
67484642e01fSmrg	      dlself=needless
67494642e01fSmrg	      export_dynamic=yes
67504642e01fSmrg	    fi
67514642e01fSmrg	    prev=
67524642e01fSmrg	    continue
67534642e01fSmrg	    ;;
67544642e01fSmrg	  *)
675535c4bbdfSmrg	    if test dlfiles = "$prev"; then
675635c4bbdfSmrg	      func_append dlfiles " $arg"
67574642e01fSmrg	    else
675835c4bbdfSmrg	      func_append dlprefiles " $arg"
67594642e01fSmrg	    fi
67604642e01fSmrg	    prev=
67614642e01fSmrg	    continue
67624642e01fSmrg	    ;;
67634642e01fSmrg	  esac
67644642e01fSmrg	  ;;
67654642e01fSmrg	expsyms)
676635c4bbdfSmrg	  export_symbols=$arg
67674642e01fSmrg	  test -f "$arg" \
676835c4bbdfSmrg	    || func_fatal_error "symbol file '$arg' does not exist"
67694642e01fSmrg	  prev=
67704642e01fSmrg	  continue
67714642e01fSmrg	  ;;
67724642e01fSmrg	expsyms_regex)
677335c4bbdfSmrg	  export_symbols_regex=$arg
67744642e01fSmrg	  prev=
67754642e01fSmrg	  continue
67764642e01fSmrg	  ;;
67774642e01fSmrg	framework)
677805b261ecSmrg	  case $host in
67794642e01fSmrg	    *-*-darwin*)
67804642e01fSmrg	      case "$deplibs " in
67814642e01fSmrg		*" $qarg.ltframework "*) ;;
678235c4bbdfSmrg		*) func_append deplibs " $qarg.ltframework" # this is fixed later
67834642e01fSmrg		   ;;
67844642e01fSmrg	      esac
67854642e01fSmrg	      ;;
678605b261ecSmrg	  esac
67874642e01fSmrg	  prev=
67884642e01fSmrg	  continue
678905b261ecSmrg	  ;;
67904642e01fSmrg	inst_prefix)
679135c4bbdfSmrg	  inst_prefix_dir=$arg
679235c4bbdfSmrg	  prev=
679335c4bbdfSmrg	  continue
679435c4bbdfSmrg	  ;;
679535c4bbdfSmrg	mllvm)
679635c4bbdfSmrg	  # Clang does not use LLVM to link, so we can simply discard any
679735c4bbdfSmrg	  # '-mllvm $arg' options when doing the link step.
67984642e01fSmrg	  prev=
67994642e01fSmrg	  continue
680005b261ecSmrg	  ;;
68014642e01fSmrg	objectlist)
68024642e01fSmrg	  if test -f "$arg"; then
68034642e01fSmrg	    save_arg=$arg
68044642e01fSmrg	    moreargs=
68054642e01fSmrg	    for fil in `cat "$save_arg"`
68064642e01fSmrg	    do
680735c4bbdfSmrg#	      func_append moreargs " $fil"
68084642e01fSmrg	      arg=$fil
68094642e01fSmrg	      # A libtool-controlled object.
681005b261ecSmrg
68114642e01fSmrg	      # Check to see that this really is a libtool object.
68124642e01fSmrg	      if func_lalib_unsafe_p "$arg"; then
68134642e01fSmrg		pic_object=
68144642e01fSmrg		non_pic_object=
681505b261ecSmrg
68164642e01fSmrg		# Read the .lo file
68174642e01fSmrg		func_source "$arg"
681805b261ecSmrg
68194642e01fSmrg		if test -z "$pic_object" ||
68204642e01fSmrg		   test -z "$non_pic_object" ||
682135c4bbdfSmrg		   test none = "$pic_object" &&
682235c4bbdfSmrg		   test none = "$non_pic_object"; then
682335c4bbdfSmrg		  func_fatal_error "cannot find name of object for '$arg'"
68244642e01fSmrg		fi
682505b261ecSmrg
68264642e01fSmrg		# Extract subdirectory from the argument.
68274642e01fSmrg		func_dirname "$arg" "/" ""
682835c4bbdfSmrg		xdir=$func_dirname_result
682905b261ecSmrg
683035c4bbdfSmrg		if test none != "$pic_object"; then
68314642e01fSmrg		  # Prepend the subdirectory the object is found in.
683235c4bbdfSmrg		  pic_object=$xdir$pic_object
683305b261ecSmrg
683435c4bbdfSmrg		  if test dlfiles = "$prev"; then
683535c4bbdfSmrg		    if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
683635c4bbdfSmrg		      func_append dlfiles " $pic_object"
68374642e01fSmrg		      prev=
68384642e01fSmrg		      continue
68394642e01fSmrg		    else
68404642e01fSmrg		      # If libtool objects are unsupported, then we need to preload.
68414642e01fSmrg		      prev=dlprefiles
68424642e01fSmrg		    fi
68434642e01fSmrg		  fi
684405b261ecSmrg
68454642e01fSmrg		  # CHECK ME:  I think I busted this.  -Ossama
684635c4bbdfSmrg		  if test dlprefiles = "$prev"; then
68474642e01fSmrg		    # Preload the old-style object.
684835c4bbdfSmrg		    func_append dlprefiles " $pic_object"
68494642e01fSmrg		    prev=
68504642e01fSmrg		  fi
685105b261ecSmrg
68524642e01fSmrg		  # A PIC object.
68534642e01fSmrg		  func_append libobjs " $pic_object"
685435c4bbdfSmrg		  arg=$pic_object
68554642e01fSmrg		fi
685605b261ecSmrg
68574642e01fSmrg		# Non-PIC object.
685835c4bbdfSmrg		if test none != "$non_pic_object"; then
68594642e01fSmrg		  # Prepend the subdirectory the object is found in.
686035c4bbdfSmrg		  non_pic_object=$xdir$non_pic_object
686105b261ecSmrg
68624642e01fSmrg		  # A standard non-PIC object
68634642e01fSmrg		  func_append non_pic_objects " $non_pic_object"
686435c4bbdfSmrg		  if test -z "$pic_object" || test none = "$pic_object"; then
686535c4bbdfSmrg		    arg=$non_pic_object
68664642e01fSmrg		  fi
68674642e01fSmrg		else
68684642e01fSmrg		  # If the PIC object exists, use it instead.
68694642e01fSmrg		  # $xdir was prepended to $pic_object above.
687035c4bbdfSmrg		  non_pic_object=$pic_object
68714642e01fSmrg		  func_append non_pic_objects " $non_pic_object"
68724642e01fSmrg		fi
68734642e01fSmrg	      else
68744642e01fSmrg		# Only an error if not doing a dry-run.
68754642e01fSmrg		if $opt_dry_run; then
68764642e01fSmrg		  # Extract subdirectory from the argument.
68774642e01fSmrg		  func_dirname "$arg" "/" ""
687835c4bbdfSmrg		  xdir=$func_dirname_result
68794642e01fSmrg
68804642e01fSmrg		  func_lo2o "$arg"
68814642e01fSmrg		  pic_object=$xdir$objdir/$func_lo2o_result
68824642e01fSmrg		  non_pic_object=$xdir$func_lo2o_result
68834642e01fSmrg		  func_append libobjs " $pic_object"
68844642e01fSmrg		  func_append non_pic_objects " $non_pic_object"
68854642e01fSmrg	        else
688635c4bbdfSmrg		  func_fatal_error "'$arg' is not a valid libtool object"
68874642e01fSmrg		fi
68884642e01fSmrg	      fi
68894642e01fSmrg	    done
689005b261ecSmrg	  else
689135c4bbdfSmrg	    func_fatal_error "link input file '$arg' does not exist"
689205b261ecSmrg	  fi
68934642e01fSmrg	  arg=$save_arg
68944642e01fSmrg	  prev=
68954642e01fSmrg	  continue
68964642e01fSmrg	  ;;
689735c4bbdfSmrg	os2dllname)
689835c4bbdfSmrg	  os2dllname=$arg
689935c4bbdfSmrg	  prev=
690035c4bbdfSmrg	  continue
690135c4bbdfSmrg	  ;;
69024642e01fSmrg	precious_regex)
690335c4bbdfSmrg	  precious_files_regex=$arg
69044642e01fSmrg	  prev=
69054642e01fSmrg	  continue
69064642e01fSmrg	  ;;
69074642e01fSmrg	release)
690835c4bbdfSmrg	  release=-$arg
69094642e01fSmrg	  prev=
69104642e01fSmrg	  continue
69114642e01fSmrg	  ;;
69124642e01fSmrg	rpath | xrpath)
69134642e01fSmrg	  # We need an absolute path.
69144642e01fSmrg	  case $arg in
69154642e01fSmrg	  [\\/]* | [A-Za-z]:[\\/]*) ;;
69164642e01fSmrg	  *)
69174642e01fSmrg	    func_fatal_error "only absolute run-paths are allowed"
69184642e01fSmrg	    ;;
69194642e01fSmrg	  esac
692035c4bbdfSmrg	  if test rpath = "$prev"; then
69214642e01fSmrg	    case "$rpath " in
69224642e01fSmrg	    *" $arg "*) ;;
692335c4bbdfSmrg	    *) func_append rpath " $arg" ;;
69244642e01fSmrg	    esac
692505b261ecSmrg	  else
69264642e01fSmrg	    case "$xrpath " in
69274642e01fSmrg	    *" $arg "*) ;;
692835c4bbdfSmrg	    *) func_append xrpath " $arg" ;;
69294642e01fSmrg	    esac
693005b261ecSmrg	  fi
69314642e01fSmrg	  prev=
69324642e01fSmrg	  continue
69334642e01fSmrg	  ;;
69344642e01fSmrg	shrext)
693535c4bbdfSmrg	  shrext_cmds=$arg
69364642e01fSmrg	  prev=
69374642e01fSmrg	  continue
69384642e01fSmrg	  ;;
69394642e01fSmrg	weak)
694035c4bbdfSmrg	  func_append weak_libs " $arg"
69414642e01fSmrg	  prev=
69424642e01fSmrg	  continue
69434642e01fSmrg	  ;;
69444642e01fSmrg	xcclinker)
694535c4bbdfSmrg	  func_append linker_flags " $qarg"
694635c4bbdfSmrg	  func_append compiler_flags " $qarg"
69474642e01fSmrg	  prev=
69484642e01fSmrg	  func_append compile_command " $qarg"
69494642e01fSmrg	  func_append finalize_command " $qarg"
69504642e01fSmrg	  continue
69514642e01fSmrg	  ;;
69524642e01fSmrg	xcompiler)
695335c4bbdfSmrg	  func_append compiler_flags " $qarg"
69544642e01fSmrg	  prev=
69554642e01fSmrg	  func_append compile_command " $qarg"
69564642e01fSmrg	  func_append finalize_command " $qarg"
69574642e01fSmrg	  continue
69584642e01fSmrg	  ;;
69594642e01fSmrg	xlinker)
696035c4bbdfSmrg	  func_append linker_flags " $qarg"
696135c4bbdfSmrg	  func_append compiler_flags " $wl$qarg"
69624642e01fSmrg	  prev=
69634642e01fSmrg	  func_append compile_command " $wl$qarg"
69644642e01fSmrg	  func_append finalize_command " $wl$qarg"
69654642e01fSmrg	  continue
69664642e01fSmrg	  ;;
69674642e01fSmrg	*)
69684642e01fSmrg	  eval "$prev=\"\$arg\""
69694642e01fSmrg	  prev=
69704642e01fSmrg	  continue
69714642e01fSmrg	  ;;
697205b261ecSmrg	esac
69734642e01fSmrg      fi # test -n "$prev"
697405b261ecSmrg
697535c4bbdfSmrg      prevarg=$arg
697605b261ecSmrg
69774642e01fSmrg      case $arg in
69784642e01fSmrg      -all-static)
69794642e01fSmrg	if test -n "$link_static_flag"; then
69804642e01fSmrg	  # See comment for -static flag below, for more details.
69814642e01fSmrg	  func_append compile_command " $link_static_flag"
69824642e01fSmrg	  func_append finalize_command " $link_static_flag"
69834642e01fSmrg	fi
69844642e01fSmrg	continue
69854642e01fSmrg	;;
698605b261ecSmrg
69874642e01fSmrg      -allow-undefined)
69884642e01fSmrg	# FIXME: remove this flag sometime in the future.
698935c4bbdfSmrg	func_fatal_error "'-allow-undefined' must not be used because it is the default"
69904642e01fSmrg	;;
699105b261ecSmrg
69924642e01fSmrg      -avoid-version)
69934642e01fSmrg	avoid_version=yes
69944642e01fSmrg	continue
69954642e01fSmrg	;;
699605b261ecSmrg
69976747b715Smrg      -bindir)
69986747b715Smrg	prev=bindir
69996747b715Smrg	continue
70006747b715Smrg	;;
70016747b715Smrg
70024642e01fSmrg      -dlopen)
70034642e01fSmrg	prev=dlfiles
70044642e01fSmrg	continue
70054642e01fSmrg	;;
700605b261ecSmrg
70074642e01fSmrg      -dlpreopen)
70084642e01fSmrg	prev=dlprefiles
70094642e01fSmrg	continue
70104642e01fSmrg	;;
701105b261ecSmrg
70124642e01fSmrg      -export-dynamic)
70134642e01fSmrg	export_dynamic=yes
70144642e01fSmrg	continue
70154642e01fSmrg	;;
701605b261ecSmrg
70174642e01fSmrg      -export-symbols | -export-symbols-regex)
70184642e01fSmrg	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
70194642e01fSmrg	  func_fatal_error "more than one -exported-symbols argument is not allowed"
70204642e01fSmrg	fi
702135c4bbdfSmrg	if test X-export-symbols = "X$arg"; then
70224642e01fSmrg	  prev=expsyms
70234642e01fSmrg	else
70244642e01fSmrg	  prev=expsyms_regex
70254642e01fSmrg	fi
70264642e01fSmrg	continue
70274642e01fSmrg	;;
702805b261ecSmrg
70294642e01fSmrg      -framework)
70304642e01fSmrg	prev=framework
70314642e01fSmrg	continue
70324642e01fSmrg	;;
703305b261ecSmrg
70344642e01fSmrg      -inst-prefix-dir)
70354642e01fSmrg	prev=inst_prefix
70364642e01fSmrg	continue
70374642e01fSmrg	;;
703805b261ecSmrg
70394642e01fSmrg      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
70404642e01fSmrg      # so, if we see these flags be careful not to treat them like -L
70414642e01fSmrg      -L[A-Z][A-Z]*:*)
70424642e01fSmrg	case $with_gcc/$host in
70434642e01fSmrg	no/*-*-irix* | /*-*-irix*)
70444642e01fSmrg	  func_append compile_command " $arg"
70454642e01fSmrg	  func_append finalize_command " $arg"
70464642e01fSmrg	  ;;
70474642e01fSmrg	esac
70484642e01fSmrg	continue
70494642e01fSmrg	;;
705005b261ecSmrg
70514642e01fSmrg      -L*)
705235c4bbdfSmrg	func_stripname "-L" '' "$arg"
705335c4bbdfSmrg	if test -z "$func_stripname_result"; then
70544642e01fSmrg	  if test "$#" -gt 0; then
705535c4bbdfSmrg	    func_fatal_error "require no space between '-L' and '$1'"
70564642e01fSmrg	  else
705735c4bbdfSmrg	    func_fatal_error "need path for '-L' option"
70584642e01fSmrg	  fi
70594642e01fSmrg	fi
706035c4bbdfSmrg	func_resolve_sysroot "$func_stripname_result"
706135c4bbdfSmrg	dir=$func_resolve_sysroot_result
70624642e01fSmrg	# We need an absolute path.
70634642e01fSmrg	case $dir in
70644642e01fSmrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
70654642e01fSmrg	*)
70664642e01fSmrg	  absdir=`cd "$dir" && pwd`
70674642e01fSmrg	  test -z "$absdir" && \
706835c4bbdfSmrg	    func_fatal_error "cannot determine absolute directory name of '$dir'"
706935c4bbdfSmrg	  dir=$absdir
70704642e01fSmrg	  ;;
70714642e01fSmrg	esac
70724642e01fSmrg	case "$deplibs " in
707335c4bbdfSmrg	*" -L$dir "* | *" $arg "*)
707435c4bbdfSmrg	  # Will only happen for absolute or sysroot arguments
707535c4bbdfSmrg	  ;;
70764642e01fSmrg	*)
707735c4bbdfSmrg	  # Preserve sysroot, but never include relative directories
707835c4bbdfSmrg	  case $dir in
707935c4bbdfSmrg	    [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
708035c4bbdfSmrg	    *) func_append deplibs " -L$dir" ;;
708135c4bbdfSmrg	  esac
708235c4bbdfSmrg	  func_append lib_search_path " $dir"
70834642e01fSmrg	  ;;
70844642e01fSmrg	esac
70854642e01fSmrg	case $host in
70864642e01fSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
70876747b715Smrg	  testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
70884642e01fSmrg	  case :$dllsearchpath: in
70894642e01fSmrg	  *":$dir:"*) ;;
70904642e01fSmrg	  ::) dllsearchpath=$dir;;
709135c4bbdfSmrg	  *) func_append dllsearchpath ":$dir";;
70924642e01fSmrg	  esac
70934642e01fSmrg	  case :$dllsearchpath: in
70944642e01fSmrg	  *":$testbindir:"*) ;;
70954642e01fSmrg	  ::) dllsearchpath=$testbindir;;
709635c4bbdfSmrg	  *) func_append dllsearchpath ":$testbindir";;
70974642e01fSmrg	  esac
70984642e01fSmrg	  ;;
70994642e01fSmrg	esac
71004642e01fSmrg	continue
71014642e01fSmrg	;;
710205b261ecSmrg
71034642e01fSmrg      -l*)
710435c4bbdfSmrg	if test X-lc = "X$arg" || test X-lm = "X$arg"; then
71054642e01fSmrg	  case $host in
71066747b715Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
71074642e01fSmrg	    # These systems don't actually have a C or math library (as such)
71084642e01fSmrg	    continue
71094642e01fSmrg	    ;;
71104642e01fSmrg	  *-*-os2*)
71114642e01fSmrg	    # These systems don't actually have a C library (as such)
711235c4bbdfSmrg	    test X-lc = "X$arg" && continue
71134642e01fSmrg	    ;;
711435c4bbdfSmrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
71154642e01fSmrg	    # Do not include libc due to us having libc/libc_r.
711635c4bbdfSmrg	    test X-lc = "X$arg" && continue
71174642e01fSmrg	    ;;
71184642e01fSmrg	  *-*-rhapsody* | *-*-darwin1.[012])
71194642e01fSmrg	    # Rhapsody C and math libraries are in the System framework
712035c4bbdfSmrg	    func_append deplibs " System.ltframework"
71214642e01fSmrg	    continue
71224642e01fSmrg	    ;;
71234642e01fSmrg	  *-*-sco3.2v5* | *-*-sco5v6*)
71244642e01fSmrg	    # Causes problems with __ctype
712535c4bbdfSmrg	    test X-lc = "X$arg" && continue
71264642e01fSmrg	    ;;
71274642e01fSmrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
71284642e01fSmrg	    # Compiler inserts libc in the correct place for threads to work
712935c4bbdfSmrg	    test X-lc = "X$arg" && continue
71304642e01fSmrg	    ;;
71314642e01fSmrg	  esac
713235c4bbdfSmrg	elif test X-lc_r = "X$arg"; then
71334642e01fSmrg	 case $host in
713435c4bbdfSmrg	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
71354642e01fSmrg	   # Do not include libc_r directly, use -pthread flag.
71364642e01fSmrg	   continue
71374642e01fSmrg	   ;;
71384642e01fSmrg	 esac
71394642e01fSmrg	fi
714035c4bbdfSmrg	func_append deplibs " $arg"
714135c4bbdfSmrg	continue
714235c4bbdfSmrg	;;
714335c4bbdfSmrg
714435c4bbdfSmrg      -mllvm)
714535c4bbdfSmrg	prev=mllvm
71464642e01fSmrg	continue
71474642e01fSmrg	;;
714805b261ecSmrg
71494642e01fSmrg      -module)
71504642e01fSmrg	module=yes
71514642e01fSmrg	continue
71524642e01fSmrg	;;
715305b261ecSmrg
71544642e01fSmrg      # Tru64 UNIX uses -model [arg] to determine the layout of C++
71554642e01fSmrg      # classes, name mangling, and exception handling.
71564642e01fSmrg      # Darwin uses the -arch flag to determine output architecture.
715735c4bbdfSmrg      -model|-arch|-isysroot|--sysroot)
715835c4bbdfSmrg	func_append compiler_flags " $arg"
71594642e01fSmrg	func_append compile_command " $arg"
71604642e01fSmrg	func_append finalize_command " $arg"
71614642e01fSmrg	prev=xcompiler
71624642e01fSmrg	continue
71634642e01fSmrg	;;
716405b261ecSmrg
716535c4bbdfSmrg      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
716635c4bbdfSmrg      |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
716735c4bbdfSmrg	func_append compiler_flags " $arg"
71684642e01fSmrg	func_append compile_command " $arg"
71694642e01fSmrg	func_append finalize_command " $arg"
71704642e01fSmrg	case "$new_inherited_linker_flags " in
71714642e01fSmrg	    *" $arg "*) ;;
717235c4bbdfSmrg	    * ) func_append new_inherited_linker_flags " $arg" ;;
71734642e01fSmrg	esac
71744642e01fSmrg	continue
71754642e01fSmrg	;;
717605b261ecSmrg
71774642e01fSmrg      -multi_module)
717835c4bbdfSmrg	single_module=$wl-multi_module
71794642e01fSmrg	continue
71804642e01fSmrg	;;
718105b261ecSmrg
71824642e01fSmrg      -no-fast-install)
71834642e01fSmrg	fast_install=no
71844642e01fSmrg	continue
71854642e01fSmrg	;;
718605b261ecSmrg
71874642e01fSmrg      -no-install)
71884642e01fSmrg	case $host in
71894642e01fSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
71904642e01fSmrg	  # The PATH hackery in wrapper scripts is required on Windows
71914642e01fSmrg	  # and Darwin in order for the loader to find any dlls it needs.
719235c4bbdfSmrg	  func_warning "'-no-install' is ignored for $host"
719335c4bbdfSmrg	  func_warning "assuming '-no-fast-install' instead"
71944642e01fSmrg	  fast_install=no
71954642e01fSmrg	  ;;
71964642e01fSmrg	*) no_install=yes ;;
71974642e01fSmrg	esac
71984642e01fSmrg	continue
71994642e01fSmrg	;;
720005b261ecSmrg
72014642e01fSmrg      -no-undefined)
72024642e01fSmrg	allow_undefined=no
72034642e01fSmrg	continue
72044642e01fSmrg	;;
720505b261ecSmrg
72064642e01fSmrg      -objectlist)
72074642e01fSmrg	prev=objectlist
72084642e01fSmrg	continue
72094642e01fSmrg	;;
721005b261ecSmrg
721135c4bbdfSmrg      -os2dllname)
721235c4bbdfSmrg	prev=os2dllname
721335c4bbdfSmrg	continue
721435c4bbdfSmrg	;;
721535c4bbdfSmrg
72164642e01fSmrg      -o) prev=output ;;
721705b261ecSmrg
72184642e01fSmrg      -precious-files-regex)
72194642e01fSmrg	prev=precious_regex
72204642e01fSmrg	continue
72214642e01fSmrg	;;
722205b261ecSmrg
72234642e01fSmrg      -release)
72244642e01fSmrg	prev=release
72254642e01fSmrg	continue
72264642e01fSmrg	;;
722705b261ecSmrg
72284642e01fSmrg      -rpath)
72294642e01fSmrg	prev=rpath
72304642e01fSmrg	continue
72314642e01fSmrg	;;
723205b261ecSmrg
72334642e01fSmrg      -R)
72344642e01fSmrg	prev=xrpath
72354642e01fSmrg	continue
72364642e01fSmrg	;;
723705b261ecSmrg
72384642e01fSmrg      -R*)
72394642e01fSmrg	func_stripname '-R' '' "$arg"
72404642e01fSmrg	dir=$func_stripname_result
72414642e01fSmrg	# We need an absolute path.
72424642e01fSmrg	case $dir in
72434642e01fSmrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
724435c4bbdfSmrg	=*)
724535c4bbdfSmrg	  func_stripname '=' '' "$dir"
724635c4bbdfSmrg	  dir=$lt_sysroot$func_stripname_result
724735c4bbdfSmrg	  ;;
72484642e01fSmrg	*)
72494642e01fSmrg	  func_fatal_error "only absolute run-paths are allowed"
72504642e01fSmrg	  ;;
72514642e01fSmrg	esac
72524642e01fSmrg	case "$xrpath " in
72534642e01fSmrg	*" $dir "*) ;;
725435c4bbdfSmrg	*) func_append xrpath " $dir" ;;
72554642e01fSmrg	esac
72564642e01fSmrg	continue
72574642e01fSmrg	;;
725805b261ecSmrg
72594642e01fSmrg      -shared)
72604642e01fSmrg	# The effects of -shared are defined in a previous loop.
72614642e01fSmrg	continue
72624642e01fSmrg	;;
726305b261ecSmrg
72644642e01fSmrg      -shrext)
72654642e01fSmrg	prev=shrext
72664642e01fSmrg	continue
72674642e01fSmrg	;;
726805b261ecSmrg
72694642e01fSmrg      -static | -static-libtool-libs)
72704642e01fSmrg	# The effects of -static are defined in a previous loop.
72714642e01fSmrg	# We used to do the same as -all-static on platforms that
72724642e01fSmrg	# didn't have a PIC flag, but the assumption that the effects
72734642e01fSmrg	# would be equivalent was wrong.  It would break on at least
72744642e01fSmrg	# Digital Unix and AIX.
72754642e01fSmrg	continue
72764642e01fSmrg	;;
727705b261ecSmrg
72784642e01fSmrg      -thread-safe)
72794642e01fSmrg	thread_safe=yes
72804642e01fSmrg	continue
72814642e01fSmrg	;;
728205b261ecSmrg
72834642e01fSmrg      -version-info)
72844642e01fSmrg	prev=vinfo
72854642e01fSmrg	continue
72864642e01fSmrg	;;
728705b261ecSmrg
72884642e01fSmrg      -version-number)
72894642e01fSmrg	prev=vinfo
72904642e01fSmrg	vinfo_number=yes
72914642e01fSmrg	continue
72924642e01fSmrg	;;
729305b261ecSmrg
72944642e01fSmrg      -weak)
72954642e01fSmrg        prev=weak
72964642e01fSmrg	continue
72974642e01fSmrg	;;
729805b261ecSmrg
72994642e01fSmrg      -Wc,*)
73004642e01fSmrg	func_stripname '-Wc,' '' "$arg"
73014642e01fSmrg	args=$func_stripname_result
73024642e01fSmrg	arg=
730335c4bbdfSmrg	save_ifs=$IFS; IFS=,
73044642e01fSmrg	for flag in $args; do
730535c4bbdfSmrg	  IFS=$save_ifs
73064642e01fSmrg          func_quote_for_eval "$flag"
730735c4bbdfSmrg	  func_append arg " $func_quote_for_eval_result"
730835c4bbdfSmrg	  func_append compiler_flags " $func_quote_for_eval_result"
73094642e01fSmrg	done
731035c4bbdfSmrg	IFS=$save_ifs
73114642e01fSmrg	func_stripname ' ' '' "$arg"
73124642e01fSmrg	arg=$func_stripname_result
73134642e01fSmrg	;;
731405b261ecSmrg
73154642e01fSmrg      -Wl,*)
73164642e01fSmrg	func_stripname '-Wl,' '' "$arg"
73174642e01fSmrg	args=$func_stripname_result
73184642e01fSmrg	arg=
731935c4bbdfSmrg	save_ifs=$IFS; IFS=,
73204642e01fSmrg	for flag in $args; do
732135c4bbdfSmrg	  IFS=$save_ifs
73224642e01fSmrg          func_quote_for_eval "$flag"
732335c4bbdfSmrg	  func_append arg " $wl$func_quote_for_eval_result"
732435c4bbdfSmrg	  func_append compiler_flags " $wl$func_quote_for_eval_result"
732535c4bbdfSmrg	  func_append linker_flags " $func_quote_for_eval_result"
73264642e01fSmrg	done
732735c4bbdfSmrg	IFS=$save_ifs
73284642e01fSmrg	func_stripname ' ' '' "$arg"
73294642e01fSmrg	arg=$func_stripname_result
73304642e01fSmrg	;;
733105b261ecSmrg
73324642e01fSmrg      -Xcompiler)
73334642e01fSmrg	prev=xcompiler
73344642e01fSmrg	continue
73354642e01fSmrg	;;
733605b261ecSmrg
73374642e01fSmrg      -Xlinker)
73384642e01fSmrg	prev=xlinker
73394642e01fSmrg	continue
73404642e01fSmrg	;;
734105b261ecSmrg
73424642e01fSmrg      -XCClinker)
73434642e01fSmrg	prev=xcclinker
73444642e01fSmrg	continue
73454642e01fSmrg	;;
734605b261ecSmrg
73474642e01fSmrg      # -msg_* for osf cc
73484642e01fSmrg      -msg_*)
73494642e01fSmrg	func_quote_for_eval "$arg"
735035c4bbdfSmrg	arg=$func_quote_for_eval_result
73514642e01fSmrg	;;
735205b261ecSmrg
73536747b715Smrg      # Flags to be passed through unchanged, with rationale:
73546747b715Smrg      # -64, -mips[0-9]      enable 64-bit mode for the SGI compiler
73556747b715Smrg      # -r[0-9][0-9]*        specify processor for the SGI compiler
73566747b715Smrg      # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
73576747b715Smrg      # +DA*, +DD*           enable 64-bit mode for the HP compiler
73586747b715Smrg      # -q*                  compiler args for the IBM compiler
73596747b715Smrg      # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
73606747b715Smrg      # -F/path              path to uninstalled frameworks, gcc on darwin
73616747b715Smrg      # -p, -pg, --coverage, -fprofile-*  profiling flags for GCC
736235c4bbdfSmrg      # -fstack-protector*   stack protector flags for GCC
73636747b715Smrg      # @file                GCC response files
73646747b715Smrg      # -tp=*                Portland pgcc target processor selection
736535c4bbdfSmrg      # --sysroot=*          for sysroot support
736635c4bbdfSmrg      # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
73671b5d61b8Smrg      # -specs=*             GCC specs files
736835c4bbdfSmrg      # -stdlib=*            select c++ std lib with clang
736925da500fSmrg      # -fsanitize=*         Clang/GCC memory and address sanitizer
737025da500fSmrg      # -fuse-ld=*           Linker select flags for GCC
7371ed6184dfSmrg      # -static-*            direct GCC to link specific libraries statically
7372ed6184dfSmrg      # -fcilkplus           Cilk Plus language extension features for C/C++
73734642e01fSmrg      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
737435c4bbdfSmrg      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
73751b5d61b8Smrg      -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \
7376ed6184dfSmrg      -specs=*|-fsanitize=*|-fuse-ld=*|-static-*|-fcilkplus)
73774642e01fSmrg        func_quote_for_eval "$arg"
737835c4bbdfSmrg	arg=$func_quote_for_eval_result
73794642e01fSmrg        func_append compile_command " $arg"
73804642e01fSmrg        func_append finalize_command " $arg"
738135c4bbdfSmrg        func_append compiler_flags " $arg"
73824642e01fSmrg        continue
73834642e01fSmrg        ;;
738405b261ecSmrg
738535c4bbdfSmrg      -Z*)
738635c4bbdfSmrg        if test os2 = "`expr $host : '.*\(os2\)'`"; then
738735c4bbdfSmrg          # OS/2 uses -Zxxx to specify OS/2-specific options
738835c4bbdfSmrg	  compiler_flags="$compiler_flags $arg"
738935c4bbdfSmrg	  func_append compile_command " $arg"
739035c4bbdfSmrg	  func_append finalize_command " $arg"
739135c4bbdfSmrg	  case $arg in
739235c4bbdfSmrg	  -Zlinker | -Zstack)
739335c4bbdfSmrg	    prev=xcompiler
739435c4bbdfSmrg	    ;;
739535c4bbdfSmrg	  esac
739635c4bbdfSmrg	  continue
739735c4bbdfSmrg        else
739835c4bbdfSmrg	  # Otherwise treat like 'Some other compiler flag' below
739935c4bbdfSmrg	  func_quote_for_eval "$arg"
740035c4bbdfSmrg	  arg=$func_quote_for_eval_result
740135c4bbdfSmrg        fi
740235c4bbdfSmrg	;;
740335c4bbdfSmrg
74044642e01fSmrg      # Some other compiler flag.
74054642e01fSmrg      -* | +*)
74064642e01fSmrg        func_quote_for_eval "$arg"
740735c4bbdfSmrg	arg=$func_quote_for_eval_result
74084642e01fSmrg	;;
740905b261ecSmrg
74104642e01fSmrg      *.$objext)
74114642e01fSmrg	# A standard object.
741235c4bbdfSmrg	func_append objs " $arg"
74134642e01fSmrg	;;
741405b261ecSmrg
74154642e01fSmrg      *.lo)
74164642e01fSmrg	# A libtool-controlled object.
741705b261ecSmrg
74184642e01fSmrg	# Check to see that this really is a libtool object.
74194642e01fSmrg	if func_lalib_unsafe_p "$arg"; then
74204642e01fSmrg	  pic_object=
74214642e01fSmrg	  non_pic_object=
742205b261ecSmrg
74234642e01fSmrg	  # Read the .lo file
74244642e01fSmrg	  func_source "$arg"
742505b261ecSmrg
74264642e01fSmrg	  if test -z "$pic_object" ||
74274642e01fSmrg	     test -z "$non_pic_object" ||
742835c4bbdfSmrg	     test none = "$pic_object" &&
742935c4bbdfSmrg	     test none = "$non_pic_object"; then
743035c4bbdfSmrg	    func_fatal_error "cannot find name of object for '$arg'"
74314642e01fSmrg	  fi
743205b261ecSmrg
74334642e01fSmrg	  # Extract subdirectory from the argument.
74344642e01fSmrg	  func_dirname "$arg" "/" ""
743535c4bbdfSmrg	  xdir=$func_dirname_result
743605b261ecSmrg
743735c4bbdfSmrg	  test none = "$pic_object" || {
74384642e01fSmrg	    # Prepend the subdirectory the object is found in.
743935c4bbdfSmrg	    pic_object=$xdir$pic_object
744005b261ecSmrg
744135c4bbdfSmrg	    if test dlfiles = "$prev"; then
744235c4bbdfSmrg	      if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
744335c4bbdfSmrg		func_append dlfiles " $pic_object"
74444642e01fSmrg		prev=
74454642e01fSmrg		continue
74464642e01fSmrg	      else
74474642e01fSmrg		# If libtool objects are unsupported, then we need to preload.
74484642e01fSmrg		prev=dlprefiles
74494642e01fSmrg	      fi
74504642e01fSmrg	    fi
745105b261ecSmrg
74524642e01fSmrg	    # CHECK ME:  I think I busted this.  -Ossama
745335c4bbdfSmrg	    if test dlprefiles = "$prev"; then
74544642e01fSmrg	      # Preload the old-style object.
745535c4bbdfSmrg	      func_append dlprefiles " $pic_object"
74564642e01fSmrg	      prev=
74574642e01fSmrg	    fi
745805b261ecSmrg
74594642e01fSmrg	    # A PIC object.
74604642e01fSmrg	    func_append libobjs " $pic_object"
746135c4bbdfSmrg	    arg=$pic_object
746235c4bbdfSmrg	  }
746305b261ecSmrg
74644642e01fSmrg	  # Non-PIC object.
746535c4bbdfSmrg	  if test none != "$non_pic_object"; then
74664642e01fSmrg	    # Prepend the subdirectory the object is found in.
746735c4bbdfSmrg	    non_pic_object=$xdir$non_pic_object
746805b261ecSmrg
74694642e01fSmrg	    # A standard non-PIC object
74704642e01fSmrg	    func_append non_pic_objects " $non_pic_object"
747135c4bbdfSmrg	    if test -z "$pic_object" || test none = "$pic_object"; then
747235c4bbdfSmrg	      arg=$non_pic_object
74734642e01fSmrg	    fi
74744642e01fSmrg	  else
74754642e01fSmrg	    # If the PIC object exists, use it instead.
74764642e01fSmrg	    # $xdir was prepended to $pic_object above.
747735c4bbdfSmrg	    non_pic_object=$pic_object
74784642e01fSmrg	    func_append non_pic_objects " $non_pic_object"
74794642e01fSmrg	  fi
74804642e01fSmrg	else
74814642e01fSmrg	  # Only an error if not doing a dry-run.
74824642e01fSmrg	  if $opt_dry_run; then
74834642e01fSmrg	    # Extract subdirectory from the argument.
74844642e01fSmrg	    func_dirname "$arg" "/" ""
748535c4bbdfSmrg	    xdir=$func_dirname_result
74864642e01fSmrg
74874642e01fSmrg	    func_lo2o "$arg"
74884642e01fSmrg	    pic_object=$xdir$objdir/$func_lo2o_result
74894642e01fSmrg	    non_pic_object=$xdir$func_lo2o_result
74904642e01fSmrg	    func_append libobjs " $pic_object"
74914642e01fSmrg	    func_append non_pic_objects " $non_pic_object"
74924642e01fSmrg	  else
749335c4bbdfSmrg	    func_fatal_error "'$arg' is not a valid libtool object"
74944642e01fSmrg	  fi
74954642e01fSmrg	fi
74964642e01fSmrg	;;
74974642e01fSmrg
74984642e01fSmrg      *.$libext)
74994642e01fSmrg	# An archive.
750035c4bbdfSmrg	func_append deplibs " $arg"
750135c4bbdfSmrg	func_append old_deplibs " $arg"
75024642e01fSmrg	continue
75034642e01fSmrg	;;
75044642e01fSmrg
75054642e01fSmrg      *.la)
75064642e01fSmrg	# A libtool-controlled library.
75074642e01fSmrg
750835c4bbdfSmrg	func_resolve_sysroot "$arg"
750935c4bbdfSmrg	if test dlfiles = "$prev"; then
75104642e01fSmrg	  # This library was specified with -dlopen.
751135c4bbdfSmrg	  func_append dlfiles " $func_resolve_sysroot_result"
75124642e01fSmrg	  prev=
751335c4bbdfSmrg	elif test dlprefiles = "$prev"; then
75144642e01fSmrg	  # The library was specified with -dlpreopen.
751535c4bbdfSmrg	  func_append dlprefiles " $func_resolve_sysroot_result"
75164642e01fSmrg	  prev=
75174642e01fSmrg	else
751835c4bbdfSmrg	  func_append deplibs " $func_resolve_sysroot_result"
75194642e01fSmrg	fi
75204642e01fSmrg	continue
75214642e01fSmrg	;;
75224642e01fSmrg
75234642e01fSmrg      # Some other compiler argument.
75244642e01fSmrg      *)
75254642e01fSmrg	# Unknown arguments in both finalize_command and compile_command need
75264642e01fSmrg	# to be aesthetically quoted because they are evaled later.
75274642e01fSmrg	func_quote_for_eval "$arg"
752835c4bbdfSmrg	arg=$func_quote_for_eval_result
75294642e01fSmrg	;;
75304642e01fSmrg      esac # arg
75314642e01fSmrg
75324642e01fSmrg      # Now actually substitute the argument into the commands.
75334642e01fSmrg      if test -n "$arg"; then
75344642e01fSmrg	func_append compile_command " $arg"
75354642e01fSmrg	func_append finalize_command " $arg"
75364642e01fSmrg      fi
75374642e01fSmrg    done # argument parsing loop
75384642e01fSmrg
75394642e01fSmrg    test -n "$prev" && \
754035c4bbdfSmrg      func_fatal_help "the '$prevarg' option requires an argument"
75414642e01fSmrg
754235c4bbdfSmrg    if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then
75434642e01fSmrg      eval arg=\"$export_dynamic_flag_spec\"
75444642e01fSmrg      func_append compile_command " $arg"
75454642e01fSmrg      func_append finalize_command " $arg"
75464642e01fSmrg    fi
75474642e01fSmrg
75484642e01fSmrg    oldlibs=
75494642e01fSmrg    # calculate the name of the file, without its directory
75504642e01fSmrg    func_basename "$output"
755135c4bbdfSmrg    outputname=$func_basename_result
755235c4bbdfSmrg    libobjs_save=$libobjs
75534642e01fSmrg
75544642e01fSmrg    if test -n "$shlibpath_var"; then
75554642e01fSmrg      # get the directories listed in $shlibpath_var
755635c4bbdfSmrg      eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\`
75574642e01fSmrg    else
75584642e01fSmrg      shlib_search_path=
75594642e01fSmrg    fi
75604642e01fSmrg    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
75614642e01fSmrg    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
75624642e01fSmrg
756335c4bbdfSmrg    # Definition is injected by LT_CONFIG during libtool generation.
756435c4bbdfSmrg    func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH"
756535c4bbdfSmrg
75664642e01fSmrg    func_dirname "$output" "/" ""
756735c4bbdfSmrg    output_objdir=$func_dirname_result$objdir
756835c4bbdfSmrg    func_to_tool_file "$output_objdir/"
756935c4bbdfSmrg    tool_output_objdir=$func_to_tool_file_result
75704642e01fSmrg    # Create the object directory.
75714642e01fSmrg    func_mkdir_p "$output_objdir"
75724642e01fSmrg
75734642e01fSmrg    # Determine the type of output
75744642e01fSmrg    case $output in
75754642e01fSmrg    "")
75764642e01fSmrg      func_fatal_help "you must specify an output file"
75774642e01fSmrg      ;;
75784642e01fSmrg    *.$libext) linkmode=oldlib ;;
75794642e01fSmrg    *.lo | *.$objext) linkmode=obj ;;
75804642e01fSmrg    *.la) linkmode=lib ;;
75814642e01fSmrg    *) linkmode=prog ;; # Anything else should be a program.
75824642e01fSmrg    esac
75834642e01fSmrg
75844642e01fSmrg    specialdeplibs=
75854642e01fSmrg
75864642e01fSmrg    libs=
75874642e01fSmrg    # Find all interdependent deplibs by searching for libraries
75884642e01fSmrg    # that are linked more than once (e.g. -la -lb -la)
75894642e01fSmrg    for deplib in $deplibs; do
759035c4bbdfSmrg      if $opt_preserve_dup_deps; then
75914642e01fSmrg	case "$libs " in
759235c4bbdfSmrg	*" $deplib "*) func_append specialdeplibs " $deplib" ;;
75934642e01fSmrg	esac
75944642e01fSmrg      fi
759535c4bbdfSmrg      func_append libs " $deplib"
75964642e01fSmrg    done
75974642e01fSmrg
759835c4bbdfSmrg    if test lib = "$linkmode"; then
75994642e01fSmrg      libs="$predeps $libs $compiler_lib_search_path $postdeps"
76004642e01fSmrg
76014642e01fSmrg      # Compute libraries that are listed more than once in $predeps
76024642e01fSmrg      # $postdeps and mark them as special (i.e., whose duplicates are
76034642e01fSmrg      # not to be eliminated).
76044642e01fSmrg      pre_post_deps=
76054642e01fSmrg      if $opt_duplicate_compiler_generated_deps; then
76064642e01fSmrg	for pre_post_dep in $predeps $postdeps; do
76074642e01fSmrg	  case "$pre_post_deps " in
760835c4bbdfSmrg	  *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
76094642e01fSmrg	  esac
761035c4bbdfSmrg	  func_append pre_post_deps " $pre_post_dep"
76114642e01fSmrg	done
76124642e01fSmrg      fi
76134642e01fSmrg      pre_post_deps=
76144642e01fSmrg    fi
76154642e01fSmrg
76164642e01fSmrg    deplibs=
76174642e01fSmrg    newdependency_libs=
76184642e01fSmrg    newlib_search_path=
76194642e01fSmrg    need_relink=no # whether we're linking any uninstalled libtool libraries
76204642e01fSmrg    notinst_deplibs= # not-installed libtool libraries
76214642e01fSmrg    notinst_path= # paths that contain not-installed libtool libraries
76224642e01fSmrg
76234642e01fSmrg    case $linkmode in
76244642e01fSmrg    lib)
76254642e01fSmrg	passes="conv dlpreopen link"
76264642e01fSmrg	for file in $dlfiles $dlprefiles; do
76274642e01fSmrg	  case $file in
76284642e01fSmrg	  *.la) ;;
76294642e01fSmrg	  *)
763035c4bbdfSmrg	    func_fatal_help "libraries can '-dlopen' only libtool libraries: $file"
76314642e01fSmrg	    ;;
76324642e01fSmrg	  esac
76334642e01fSmrg	done
76344642e01fSmrg	;;
76354642e01fSmrg    prog)
76364642e01fSmrg	compile_deplibs=
76374642e01fSmrg	finalize_deplibs=
763835c4bbdfSmrg	alldeplibs=false
76394642e01fSmrg	newdlfiles=
76404642e01fSmrg	newdlprefiles=
76414642e01fSmrg	passes="conv scan dlopen dlpreopen link"
76424642e01fSmrg	;;
76434642e01fSmrg    *)  passes="conv"
76444642e01fSmrg	;;
76454642e01fSmrg    esac
76464642e01fSmrg
76474642e01fSmrg    for pass in $passes; do
76484642e01fSmrg      # The preopen pass in lib mode reverses $deplibs; put it back here
76494642e01fSmrg      # so that -L comes before libs that need it for instance...
765035c4bbdfSmrg      if test lib,link = "$linkmode,$pass"; then
76514642e01fSmrg	## FIXME: Find the place where the list is rebuilt in the wrong
76524642e01fSmrg	##        order, and fix it there properly
76534642e01fSmrg        tmp_deplibs=
76544642e01fSmrg	for deplib in $deplibs; do
76554642e01fSmrg	  tmp_deplibs="$deplib $tmp_deplibs"
76564642e01fSmrg	done
765735c4bbdfSmrg	deplibs=$tmp_deplibs
76584642e01fSmrg      fi
76594642e01fSmrg
766035c4bbdfSmrg      if test lib,link = "$linkmode,$pass" ||
766135c4bbdfSmrg	 test prog,scan = "$linkmode,$pass"; then
766235c4bbdfSmrg	libs=$deplibs
76634642e01fSmrg	deplibs=
76644642e01fSmrg      fi
766535c4bbdfSmrg      if test prog = "$linkmode"; then
76664642e01fSmrg	case $pass in
766735c4bbdfSmrg	dlopen) libs=$dlfiles ;;
766835c4bbdfSmrg	dlpreopen) libs=$dlprefiles ;;
7669ed6184dfSmrg	link)
7670ed6184dfSmrg	  libs="$deplibs %DEPLIBS%"
7671ed6184dfSmrg	  test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs"
7672ed6184dfSmrg	  ;;
76734642e01fSmrg	esac
76744642e01fSmrg      fi
767535c4bbdfSmrg      if test lib,dlpreopen = "$linkmode,$pass"; then
76764642e01fSmrg	# Collect and forward deplibs of preopened libtool libs
76774642e01fSmrg	for lib in $dlprefiles; do
76784642e01fSmrg	  # Ignore non-libtool-libs
76794642e01fSmrg	  dependency_libs=
768035c4bbdfSmrg	  func_resolve_sysroot "$lib"
76814642e01fSmrg	  case $lib in
768235c4bbdfSmrg	  *.la)	func_source "$func_resolve_sysroot_result" ;;
76834642e01fSmrg	  esac
76844642e01fSmrg
76854642e01fSmrg	  # Collect preopened libtool deplibs, except any this library
76864642e01fSmrg	  # has declared as weak libs
76874642e01fSmrg	  for deplib in $dependency_libs; do
76886747b715Smrg	    func_basename "$deplib"
76896747b715Smrg            deplib_base=$func_basename_result
76904642e01fSmrg	    case " $weak_libs " in
76914642e01fSmrg	    *" $deplib_base "*) ;;
769235c4bbdfSmrg	    *) func_append deplibs " $deplib" ;;
76934642e01fSmrg	    esac
76944642e01fSmrg	  done
76954642e01fSmrg	done
769635c4bbdfSmrg	libs=$dlprefiles
76974642e01fSmrg      fi
769835c4bbdfSmrg      if test dlopen = "$pass"; then
76994642e01fSmrg	# Collect dlpreopened libraries
770035c4bbdfSmrg	save_deplibs=$deplibs
77014642e01fSmrg	deplibs=
77024642e01fSmrg      fi
77034642e01fSmrg
77044642e01fSmrg      for deplib in $libs; do
77054642e01fSmrg	lib=
770635c4bbdfSmrg	found=false
77074642e01fSmrg	case $deplib in
770835c4bbdfSmrg	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
770935c4bbdfSmrg        |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
771035c4bbdfSmrg	  if test prog,link = "$linkmode,$pass"; then
77114642e01fSmrg	    compile_deplibs="$deplib $compile_deplibs"
77124642e01fSmrg	    finalize_deplibs="$deplib $finalize_deplibs"
77134642e01fSmrg	  else
771435c4bbdfSmrg	    func_append compiler_flags " $deplib"
771535c4bbdfSmrg	    if test lib = "$linkmode"; then
77164642e01fSmrg		case "$new_inherited_linker_flags " in
77174642e01fSmrg		    *" $deplib "*) ;;
771835c4bbdfSmrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
77194642e01fSmrg		esac
77204642e01fSmrg	    fi
77214642e01fSmrg	  fi
77224642e01fSmrg	  continue
77234642e01fSmrg	  ;;
77244642e01fSmrg	-l*)
772535c4bbdfSmrg	  if test lib != "$linkmode" && test prog != "$linkmode"; then
772635c4bbdfSmrg	    func_warning "'-l' is ignored for archives/objects"
77274642e01fSmrg	    continue
77284642e01fSmrg	  fi
77294642e01fSmrg	  func_stripname '-l' '' "$deplib"
77304642e01fSmrg	  name=$func_stripname_result
773135c4bbdfSmrg	  if test lib = "$linkmode"; then
77324642e01fSmrg	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
77334642e01fSmrg	  else
77344642e01fSmrg	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
77354642e01fSmrg	  fi
77364642e01fSmrg	  for searchdir in $searchdirs; do
77374642e01fSmrg	    for search_ext in .la $std_shrext .so .a; do
77384642e01fSmrg	      # Search the libtool library
773935c4bbdfSmrg	      lib=$searchdir/lib$name$search_ext
77404642e01fSmrg	      if test -f "$lib"; then
774135c4bbdfSmrg		if test .la = "$search_ext"; then
774235c4bbdfSmrg		  found=:
77434642e01fSmrg		else
774435c4bbdfSmrg		  found=false
77454642e01fSmrg		fi
77464642e01fSmrg		break 2
77474642e01fSmrg	      fi
77484642e01fSmrg	    done
77494642e01fSmrg	  done
775035c4bbdfSmrg	  if $found; then
775135c4bbdfSmrg	    # deplib is a libtool library
77524642e01fSmrg	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
77534642e01fSmrg	    # We need to do some special things here, and not later.
775435c4bbdfSmrg	    if test yes = "$allow_libtool_libs_with_static_runtimes"; then
77554642e01fSmrg	      case " $predeps $postdeps " in
77564642e01fSmrg	      *" $deplib "*)
77574642e01fSmrg		if func_lalib_p "$lib"; then
77584642e01fSmrg		  library_names=
77594642e01fSmrg		  old_library=
77604642e01fSmrg		  func_source "$lib"
77614642e01fSmrg		  for l in $old_library $library_names; do
776235c4bbdfSmrg		    ll=$l
77634642e01fSmrg		  done
776435c4bbdfSmrg		  if test "X$ll" = "X$old_library"; then # only static version available
776535c4bbdfSmrg		    found=false
77664642e01fSmrg		    func_dirname "$lib" "" "."
776735c4bbdfSmrg		    ladir=$func_dirname_result
77684642e01fSmrg		    lib=$ladir/$old_library
776935c4bbdfSmrg		    if test prog,link = "$linkmode,$pass"; then
77704642e01fSmrg		      compile_deplibs="$deplib $compile_deplibs"
77714642e01fSmrg		      finalize_deplibs="$deplib $finalize_deplibs"
77724642e01fSmrg		    else
77734642e01fSmrg		      deplibs="$deplib $deplibs"
777435c4bbdfSmrg		      test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
77754642e01fSmrg		    fi
77764642e01fSmrg		    continue
77774642e01fSmrg		  fi
77784642e01fSmrg		fi
77794642e01fSmrg		;;
77804642e01fSmrg	      *) ;;
77814642e01fSmrg	      esac
77824642e01fSmrg	    fi
778335c4bbdfSmrg	  else
778435c4bbdfSmrg	    # deplib doesn't seem to be a libtool library
778535c4bbdfSmrg	    if test prog,link = "$linkmode,$pass"; then
778635c4bbdfSmrg	      compile_deplibs="$deplib $compile_deplibs"
778735c4bbdfSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
778835c4bbdfSmrg	    else
778935c4bbdfSmrg	      deplibs="$deplib $deplibs"
779035c4bbdfSmrg	      test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
779135c4bbdfSmrg	    fi
779235c4bbdfSmrg	    continue
77934642e01fSmrg	  fi
77944642e01fSmrg	  ;; # -l
77954642e01fSmrg	*.ltframework)
779635c4bbdfSmrg	  if test prog,link = "$linkmode,$pass"; then
77974642e01fSmrg	    compile_deplibs="$deplib $compile_deplibs"
77984642e01fSmrg	    finalize_deplibs="$deplib $finalize_deplibs"
77994642e01fSmrg	  else
78004642e01fSmrg	    deplibs="$deplib $deplibs"
780135c4bbdfSmrg	    if test lib = "$linkmode"; then
78024642e01fSmrg		case "$new_inherited_linker_flags " in
78034642e01fSmrg		    *" $deplib "*) ;;
780435c4bbdfSmrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
78054642e01fSmrg		esac
78064642e01fSmrg	    fi
78074642e01fSmrg	  fi
78084642e01fSmrg	  continue
78094642e01fSmrg	  ;;
78104642e01fSmrg	-L*)
78114642e01fSmrg	  case $linkmode in
78124642e01fSmrg	  lib)
78134642e01fSmrg	    deplibs="$deplib $deplibs"
781435c4bbdfSmrg	    test conv = "$pass" && continue
78154642e01fSmrg	    newdependency_libs="$deplib $newdependency_libs"
78164642e01fSmrg	    func_stripname '-L' '' "$deplib"
781735c4bbdfSmrg	    func_resolve_sysroot "$func_stripname_result"
781835c4bbdfSmrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
78194642e01fSmrg	    ;;
78204642e01fSmrg	  prog)
782135c4bbdfSmrg	    if test conv = "$pass"; then
78224642e01fSmrg	      deplibs="$deplib $deplibs"
78234642e01fSmrg	      continue
78244642e01fSmrg	    fi
782535c4bbdfSmrg	    if test scan = "$pass"; then
78264642e01fSmrg	      deplibs="$deplib $deplibs"
78274642e01fSmrg	    else
78284642e01fSmrg	      compile_deplibs="$deplib $compile_deplibs"
78294642e01fSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
78304642e01fSmrg	    fi
78314642e01fSmrg	    func_stripname '-L' '' "$deplib"
783235c4bbdfSmrg	    func_resolve_sysroot "$func_stripname_result"
783335c4bbdfSmrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
78344642e01fSmrg	    ;;
78354642e01fSmrg	  *)
783635c4bbdfSmrg	    func_warning "'-L' is ignored for archives/objects"
78374642e01fSmrg	    ;;
78384642e01fSmrg	  esac # linkmode
78394642e01fSmrg	  continue
78404642e01fSmrg	  ;; # -L
78414642e01fSmrg	-R*)
784235c4bbdfSmrg	  if test link = "$pass"; then
78434642e01fSmrg	    func_stripname '-R' '' "$deplib"
784435c4bbdfSmrg	    func_resolve_sysroot "$func_stripname_result"
784535c4bbdfSmrg	    dir=$func_resolve_sysroot_result
78464642e01fSmrg	    # Make sure the xrpath contains only unique directories.
78474642e01fSmrg	    case "$xrpath " in
78484642e01fSmrg	    *" $dir "*) ;;
784935c4bbdfSmrg	    *) func_append xrpath " $dir" ;;
78504642e01fSmrg	    esac
78514642e01fSmrg	  fi
78524642e01fSmrg	  deplibs="$deplib $deplibs"
78534642e01fSmrg	  continue
78544642e01fSmrg	  ;;
785535c4bbdfSmrg	*.la)
785635c4bbdfSmrg	  func_resolve_sysroot "$deplib"
785735c4bbdfSmrg	  lib=$func_resolve_sysroot_result
785835c4bbdfSmrg	  ;;
78594642e01fSmrg	*.$libext)
786035c4bbdfSmrg	  if test conv = "$pass"; then
78614642e01fSmrg	    deplibs="$deplib $deplibs"
78624642e01fSmrg	    continue
78634642e01fSmrg	  fi
78644642e01fSmrg	  case $linkmode in
78654642e01fSmrg	  lib)
78664642e01fSmrg	    # Linking convenience modules into shared libraries is allowed,
78674642e01fSmrg	    # but linking other static libraries is non-portable.
78684642e01fSmrg	    case " $dlpreconveniencelibs " in
78694642e01fSmrg	    *" $deplib "*) ;;
78704642e01fSmrg	    *)
787135c4bbdfSmrg	      valid_a_lib=false
78724642e01fSmrg	      case $deplibs_check_method in
78734642e01fSmrg		match_pattern*)
78744642e01fSmrg		  set dummy $deplibs_check_method; shift
78754642e01fSmrg		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
78766747b715Smrg		  if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
78774642e01fSmrg		    | $EGREP "$match_pattern_regex" > /dev/null; then
787835c4bbdfSmrg		    valid_a_lib=:
78794642e01fSmrg		  fi
78804642e01fSmrg		;;
78814642e01fSmrg		pass_all)
788235c4bbdfSmrg		  valid_a_lib=:
78834642e01fSmrg		;;
78844642e01fSmrg	      esac
788535c4bbdfSmrg	      if $valid_a_lib; then
788635c4bbdfSmrg		echo
788735c4bbdfSmrg		$ECHO "*** Warning: Linking the shared library $output against the"
788835c4bbdfSmrg		$ECHO "*** static library $deplib is not portable!"
788935c4bbdfSmrg		deplibs="$deplib $deplibs"
789035c4bbdfSmrg	      else
78916747b715Smrg		echo
78924642e01fSmrg		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
78936747b715Smrg		echo "*** I have the capability to make that library automatically link in when"
78946747b715Smrg		echo "*** you link to this library.  But I can only do this if you have a"
78956747b715Smrg		echo "*** shared version of the library, which you do not appear to have"
78966747b715Smrg		echo "*** because the file extensions .$libext of this argument makes me believe"
78976747b715Smrg		echo "*** that it is just a static archive that I should not use here."
78984642e01fSmrg	      fi
78994642e01fSmrg	      ;;
79004642e01fSmrg	    esac
79014642e01fSmrg	    continue
79024642e01fSmrg	    ;;
79034642e01fSmrg	  prog)
790435c4bbdfSmrg	    if test link != "$pass"; then
79054642e01fSmrg	      deplibs="$deplib $deplibs"
79064642e01fSmrg	    else
79074642e01fSmrg	      compile_deplibs="$deplib $compile_deplibs"
79084642e01fSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
79094642e01fSmrg	    fi
79104642e01fSmrg	    continue
79114642e01fSmrg	    ;;
79124642e01fSmrg	  esac # linkmode
79134642e01fSmrg	  ;; # *.$libext
79144642e01fSmrg	*.lo | *.$objext)
791535c4bbdfSmrg	  if test conv = "$pass"; then
79164642e01fSmrg	    deplibs="$deplib $deplibs"
791735c4bbdfSmrg	  elif test prog = "$linkmode"; then
791835c4bbdfSmrg	    if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then
79194642e01fSmrg	      # If there is no dlopen support or we're linking statically,
79204642e01fSmrg	      # we need to preload.
792135c4bbdfSmrg	      func_append newdlprefiles " $deplib"
79224642e01fSmrg	      compile_deplibs="$deplib $compile_deplibs"
79234642e01fSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
79244642e01fSmrg	    else
792535c4bbdfSmrg	      func_append newdlfiles " $deplib"
79264642e01fSmrg	    fi
79274642e01fSmrg	  fi
79284642e01fSmrg	  continue
79294642e01fSmrg	  ;;
79304642e01fSmrg	%DEPLIBS%)
793135c4bbdfSmrg	  alldeplibs=:
79324642e01fSmrg	  continue
79334642e01fSmrg	  ;;
79344642e01fSmrg	esac # case $deplib
79354642e01fSmrg
793635c4bbdfSmrg	$found || test -f "$lib" \
793735c4bbdfSmrg	  || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'"
79384642e01fSmrg
79394642e01fSmrg	# Check to see that this really is a libtool archive.
79404642e01fSmrg	func_lalib_unsafe_p "$lib" \
794135c4bbdfSmrg	  || func_fatal_error "'$lib' is not a valid libtool archive"
79424642e01fSmrg
79434642e01fSmrg	func_dirname "$lib" "" "."
794435c4bbdfSmrg	ladir=$func_dirname_result
79454642e01fSmrg
79464642e01fSmrg	dlname=
79474642e01fSmrg	dlopen=
79484642e01fSmrg	dlpreopen=
79494642e01fSmrg	libdir=
79504642e01fSmrg	library_names=
79514642e01fSmrg	old_library=
79524642e01fSmrg	inherited_linker_flags=
79534642e01fSmrg	# If the library was installed with an old release of libtool,
79544642e01fSmrg	# it will not redefine variables installed, or shouldnotlink
79554642e01fSmrg	installed=yes
79564642e01fSmrg	shouldnotlink=no
79574642e01fSmrg	avoidtemprpath=
79584642e01fSmrg
79594642e01fSmrg
79604642e01fSmrg	# Read the .la file
79614642e01fSmrg	func_source "$lib"
79624642e01fSmrg
79634642e01fSmrg	# Convert "-framework foo" to "foo.ltframework"
79644642e01fSmrg	if test -n "$inherited_linker_flags"; then
79656747b715Smrg	  tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
79664642e01fSmrg	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
79674642e01fSmrg	    case " $new_inherited_linker_flags " in
79684642e01fSmrg	      *" $tmp_inherited_linker_flag "*) ;;
796935c4bbdfSmrg	      *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
79704642e01fSmrg	    esac
79714642e01fSmrg	  done
79724642e01fSmrg	fi
79736747b715Smrg	dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
797435c4bbdfSmrg	if test lib,link = "$linkmode,$pass" ||
797535c4bbdfSmrg	   test prog,scan = "$linkmode,$pass" ||
797635c4bbdfSmrg	   { test prog != "$linkmode" && test lib != "$linkmode"; }; then
797735c4bbdfSmrg	  test -n "$dlopen" && func_append dlfiles " $dlopen"
797835c4bbdfSmrg	  test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
79794642e01fSmrg	fi
79804642e01fSmrg
798135c4bbdfSmrg	if test conv = "$pass"; then
79824642e01fSmrg	  # Only check for convenience libraries
79834642e01fSmrg	  deplibs="$lib $deplibs"
79844642e01fSmrg	  if test -z "$libdir"; then
79854642e01fSmrg	    if test -z "$old_library"; then
798635c4bbdfSmrg	      func_fatal_error "cannot find name of link library for '$lib'"
79874642e01fSmrg	    fi
79884642e01fSmrg	    # It is a libtool convenience library, so add in its objects.
798935c4bbdfSmrg	    func_append convenience " $ladir/$objdir/$old_library"
799035c4bbdfSmrg	    func_append old_convenience " $ladir/$objdir/$old_library"
7991ed6184dfSmrg	    tmp_libs=
7992ed6184dfSmrg	    for deplib in $dependency_libs; do
7993ed6184dfSmrg	      deplibs="$deplib $deplibs"
7994ed6184dfSmrg	      if $opt_preserve_dup_deps; then
7995ed6184dfSmrg		case "$tmp_libs " in
7996ed6184dfSmrg		*" $deplib "*) func_append specialdeplibs " $deplib" ;;
7997ed6184dfSmrg		esac
7998ed6184dfSmrg	      fi
7999ed6184dfSmrg	      func_append tmp_libs " $deplib"
8000ed6184dfSmrg	    done
800135c4bbdfSmrg	  elif test prog != "$linkmode" && test lib != "$linkmode"; then
800235c4bbdfSmrg	    func_fatal_error "'$lib' is not a convenience library"
80034642e01fSmrg	  fi
80044642e01fSmrg	  continue
80054642e01fSmrg	fi # $pass = conv
80064642e01fSmrg
80074642e01fSmrg
80084642e01fSmrg	# Get the name of the library we link against.
80094642e01fSmrg	linklib=
801035c4bbdfSmrg	if test -n "$old_library" &&
801135c4bbdfSmrg	   { test yes = "$prefer_static_libs" ||
801235c4bbdfSmrg	     test built,no = "$prefer_static_libs,$installed"; }; then
801335c4bbdfSmrg	  linklib=$old_library
801435c4bbdfSmrg	else
801535c4bbdfSmrg	  for l in $old_library $library_names; do
801635c4bbdfSmrg	    linklib=$l
801735c4bbdfSmrg	  done
801835c4bbdfSmrg	fi
80194642e01fSmrg	if test -z "$linklib"; then
802035c4bbdfSmrg	  func_fatal_error "cannot find name of link library for '$lib'"
80214642e01fSmrg	fi
80224642e01fSmrg
80234642e01fSmrg	# This library was specified with -dlopen.
802435c4bbdfSmrg	if test dlopen = "$pass"; then
802535c4bbdfSmrg	  test -z "$libdir" \
802635c4bbdfSmrg	    && func_fatal_error "cannot -dlopen a convenience library: '$lib'"
80274642e01fSmrg	  if test -z "$dlname" ||
802835c4bbdfSmrg	     test yes != "$dlopen_support" ||
802935c4bbdfSmrg	     test no = "$build_libtool_libs"
803035c4bbdfSmrg	  then
80314642e01fSmrg	    # If there is no dlname, no dlopen support or we're linking
80324642e01fSmrg	    # statically, we need to preload.  We also need to preload any
80334642e01fSmrg	    # dependent libraries so libltdl's deplib preloader doesn't
80344642e01fSmrg	    # bomb out in the load deplibs phase.
803535c4bbdfSmrg	    func_append dlprefiles " $lib $dependency_libs"
80364642e01fSmrg	  else
803735c4bbdfSmrg	    func_append newdlfiles " $lib"
80384642e01fSmrg	  fi
80394642e01fSmrg	  continue
80404642e01fSmrg	fi # $pass = dlopen
80414642e01fSmrg
80424642e01fSmrg	# We need an absolute path.
80434642e01fSmrg	case $ladir in
804435c4bbdfSmrg	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;;
80454642e01fSmrg	*)
80464642e01fSmrg	  abs_ladir=`cd "$ladir" && pwd`
80474642e01fSmrg	  if test -z "$abs_ladir"; then
804835c4bbdfSmrg	    func_warning "cannot determine absolute directory name of '$ladir'"
80494642e01fSmrg	    func_warning "passing it literally to the linker, although it might fail"
805035c4bbdfSmrg	    abs_ladir=$ladir
80514642e01fSmrg	  fi
80524642e01fSmrg	  ;;
80534642e01fSmrg	esac
80544642e01fSmrg	func_basename "$lib"
805535c4bbdfSmrg	laname=$func_basename_result
80564642e01fSmrg
80574642e01fSmrg	# Find the relevant object directory and library name.
805835c4bbdfSmrg	if test yes = "$installed"; then
805935c4bbdfSmrg	  if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
806035c4bbdfSmrg	    func_warning "library '$lib' was moved."
806135c4bbdfSmrg	    dir=$ladir
806235c4bbdfSmrg	    absdir=$abs_ladir
806335c4bbdfSmrg	    libdir=$abs_ladir
80644642e01fSmrg	  else
806535c4bbdfSmrg	    dir=$lt_sysroot$libdir
806635c4bbdfSmrg	    absdir=$lt_sysroot$libdir
80674642e01fSmrg	  fi
806835c4bbdfSmrg	  test yes = "$hardcode_automatic" && avoidtemprpath=yes
80694642e01fSmrg	else
80704642e01fSmrg	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
807135c4bbdfSmrg	    dir=$ladir
807235c4bbdfSmrg	    absdir=$abs_ladir
80734642e01fSmrg	    # Remove this search path later
807435c4bbdfSmrg	    func_append notinst_path " $abs_ladir"
80754642e01fSmrg	  else
807635c4bbdfSmrg	    dir=$ladir/$objdir
807735c4bbdfSmrg	    absdir=$abs_ladir/$objdir
80784642e01fSmrg	    # Remove this search path later
807935c4bbdfSmrg	    func_append notinst_path " $abs_ladir"
80804642e01fSmrg	  fi
80814642e01fSmrg	fi # $installed = yes
80824642e01fSmrg	func_stripname 'lib' '.la' "$laname"
80834642e01fSmrg	name=$func_stripname_result
80844642e01fSmrg
80854642e01fSmrg	# This library was specified with -dlpreopen.
808635c4bbdfSmrg	if test dlpreopen = "$pass"; then
808735c4bbdfSmrg	  if test -z "$libdir" && test prog = "$linkmode"; then
808835c4bbdfSmrg	    func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'"
8089475c125cSmrg	  fi
809035c4bbdfSmrg	  case $host in
809135c4bbdfSmrg	    # special handling for platforms with PE-DLLs.
809235c4bbdfSmrg	    *cygwin* | *mingw* | *cegcc* )
809335c4bbdfSmrg	      # Linker will automatically link against shared library if both
809435c4bbdfSmrg	      # static and shared are present.  Therefore, ensure we extract
809535c4bbdfSmrg	      # symbols from the import library if a shared library is present
809635c4bbdfSmrg	      # (otherwise, the dlopen module name will be incorrect).  We do
809735c4bbdfSmrg	      # this by putting the import library name into $newdlprefiles.
809835c4bbdfSmrg	      # We recover the dlopen module name by 'saving' the la file
809935c4bbdfSmrg	      # name in a special purpose variable, and (later) extracting the
810035c4bbdfSmrg	      # dlname from the la file.
810135c4bbdfSmrg	      if test -n "$dlname"; then
810235c4bbdfSmrg	        func_tr_sh "$dir/$linklib"
810335c4bbdfSmrg	        eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
810435c4bbdfSmrg	        func_append newdlprefiles " $dir/$linklib"
810535c4bbdfSmrg	      else
810635c4bbdfSmrg	        func_append newdlprefiles " $dir/$old_library"
810735c4bbdfSmrg	        # Keep a list of preopened convenience libraries to check
810835c4bbdfSmrg	        # that they are being used correctly in the link pass.
810935c4bbdfSmrg	        test -z "$libdir" && \
811035c4bbdfSmrg	          func_append dlpreconveniencelibs " $dir/$old_library"
811135c4bbdfSmrg	      fi
811235c4bbdfSmrg	    ;;
811335c4bbdfSmrg	    * )
811435c4bbdfSmrg	      # Prefer using a static library (so that no silly _DYNAMIC symbols
811535c4bbdfSmrg	      # are required to link).
811635c4bbdfSmrg	      if test -n "$old_library"; then
811735c4bbdfSmrg	        func_append newdlprefiles " $dir/$old_library"
811835c4bbdfSmrg	        # Keep a list of preopened convenience libraries to check
811935c4bbdfSmrg	        # that they are being used correctly in the link pass.
812035c4bbdfSmrg	        test -z "$libdir" && \
812135c4bbdfSmrg	          func_append dlpreconveniencelibs " $dir/$old_library"
812235c4bbdfSmrg	      # Otherwise, use the dlname, so that lt_dlopen finds it.
812335c4bbdfSmrg	      elif test -n "$dlname"; then
812435c4bbdfSmrg	        func_append newdlprefiles " $dir/$dlname"
812535c4bbdfSmrg	      else
812635c4bbdfSmrg	        func_append newdlprefiles " $dir/$linklib"
812735c4bbdfSmrg	      fi
812835c4bbdfSmrg	    ;;
812935c4bbdfSmrg	  esac
81304642e01fSmrg	fi # $pass = dlpreopen
81314642e01fSmrg
81324642e01fSmrg	if test -z "$libdir"; then
81334642e01fSmrg	  # Link the convenience library
813435c4bbdfSmrg	  if test lib = "$linkmode"; then
81354642e01fSmrg	    deplibs="$dir/$old_library $deplibs"
813635c4bbdfSmrg	  elif test prog,link = "$linkmode,$pass"; then
81374642e01fSmrg	    compile_deplibs="$dir/$old_library $compile_deplibs"
81384642e01fSmrg	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
81394642e01fSmrg	  else
81404642e01fSmrg	    deplibs="$lib $deplibs" # used for prog,scan pass
81414642e01fSmrg	  fi
81424642e01fSmrg	  continue
81434642e01fSmrg	fi
81444642e01fSmrg
81454642e01fSmrg
814635c4bbdfSmrg	if test prog = "$linkmode" && test link != "$pass"; then
814735c4bbdfSmrg	  func_append newlib_search_path " $ladir"
81484642e01fSmrg	  deplibs="$lib $deplibs"
81494642e01fSmrg
815035c4bbdfSmrg	  linkalldeplibs=false
815135c4bbdfSmrg	  if test no != "$link_all_deplibs" || test -z "$library_names" ||
815235c4bbdfSmrg	     test no = "$build_libtool_libs"; then
815335c4bbdfSmrg	    linkalldeplibs=:
81544642e01fSmrg	  fi
81554642e01fSmrg
81564642e01fSmrg	  tmp_libs=
81574642e01fSmrg	  for deplib in $dependency_libs; do
81584642e01fSmrg	    case $deplib in
81594642e01fSmrg	    -L*) func_stripname '-L' '' "$deplib"
816035c4bbdfSmrg	         func_resolve_sysroot "$func_stripname_result"
816135c4bbdfSmrg	         func_append newlib_search_path " $func_resolve_sysroot_result"
81624642e01fSmrg		 ;;
81634642e01fSmrg	    esac
81644642e01fSmrg	    # Need to link against all dependency_libs?
816535c4bbdfSmrg	    if $linkalldeplibs; then
81664642e01fSmrg	      deplibs="$deplib $deplibs"
81674642e01fSmrg	    else
81684642e01fSmrg	      # Need to hardcode shared library paths
81694642e01fSmrg	      # or/and link against static libraries
81704642e01fSmrg	      newdependency_libs="$deplib $newdependency_libs"
81714642e01fSmrg	    fi
817235c4bbdfSmrg	    if $opt_preserve_dup_deps; then
81734642e01fSmrg	      case "$tmp_libs " in
817435c4bbdfSmrg	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
81754642e01fSmrg	      esac
81764642e01fSmrg	    fi
817735c4bbdfSmrg	    func_append tmp_libs " $deplib"
81784642e01fSmrg	  done # for deplib
81794642e01fSmrg	  continue
81804642e01fSmrg	fi # $linkmode = prog...
81814642e01fSmrg
818235c4bbdfSmrg	if test prog,link = "$linkmode,$pass"; then
81834642e01fSmrg	  if test -n "$library_names" &&
818435c4bbdfSmrg	     { { test no = "$prefer_static_libs" ||
818535c4bbdfSmrg	         test built,yes = "$prefer_static_libs,$installed"; } ||
81864642e01fSmrg	       test -z "$old_library"; }; then
81874642e01fSmrg	    # We need to hardcode the library path
818835c4bbdfSmrg	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then
81894642e01fSmrg	      # Make sure the rpath contains only unique directories.
819035c4bbdfSmrg	      case $temp_rpath: in
81914642e01fSmrg	      *"$absdir:"*) ;;
819235c4bbdfSmrg	      *) func_append temp_rpath "$absdir:" ;;
81934642e01fSmrg	      esac
81944642e01fSmrg	    fi
81954642e01fSmrg
81964642e01fSmrg	    # Hardcode the library path.
81974642e01fSmrg	    # Skip directories that are in the system default run-time
81984642e01fSmrg	    # search path.
81994642e01fSmrg	    case " $sys_lib_dlsearch_path " in
82004642e01fSmrg	    *" $absdir "*) ;;
82014642e01fSmrg	    *)
82024642e01fSmrg	      case "$compile_rpath " in
82034642e01fSmrg	      *" $absdir "*) ;;
820435c4bbdfSmrg	      *) func_append compile_rpath " $absdir" ;;
82054642e01fSmrg	      esac
82064642e01fSmrg	      ;;
82074642e01fSmrg	    esac
82084642e01fSmrg	    case " $sys_lib_dlsearch_path " in
82094642e01fSmrg	    *" $libdir "*) ;;
82104642e01fSmrg	    *)
82114642e01fSmrg	      case "$finalize_rpath " in
82124642e01fSmrg	      *" $libdir "*) ;;
821335c4bbdfSmrg	      *) func_append finalize_rpath " $libdir" ;;
82144642e01fSmrg	      esac
82154642e01fSmrg	      ;;
82164642e01fSmrg	    esac
82174642e01fSmrg	  fi # $linkmode,$pass = prog,link...
82184642e01fSmrg
821935c4bbdfSmrg	  if $alldeplibs &&
822035c4bbdfSmrg	     { test pass_all = "$deplibs_check_method" ||
822135c4bbdfSmrg	       { test yes = "$build_libtool_libs" &&
82224642e01fSmrg		 test -n "$library_names"; }; }; then
82234642e01fSmrg	    # We only need to search for static libraries
82244642e01fSmrg	    continue
82254642e01fSmrg	  fi
82264642e01fSmrg	fi
82274642e01fSmrg
82284642e01fSmrg	link_static=no # Whether the deplib will be linked statically
82294642e01fSmrg	use_static_libs=$prefer_static_libs
823035c4bbdfSmrg	if test built = "$use_static_libs" && test yes = "$installed"; then
82314642e01fSmrg	  use_static_libs=no
82324642e01fSmrg	fi
82334642e01fSmrg	if test -n "$library_names" &&
823435c4bbdfSmrg	   { test no = "$use_static_libs" || test -z "$old_library"; }; then
82354642e01fSmrg	  case $host in
823635c4bbdfSmrg	  *cygwin* | *mingw* | *cegcc* | *os2*)
82374642e01fSmrg	      # No point in relinking DLLs because paths are not encoded
823835c4bbdfSmrg	      func_append notinst_deplibs " $lib"
82394642e01fSmrg	      need_relink=no
82404642e01fSmrg	    ;;
82414642e01fSmrg	  *)
824235c4bbdfSmrg	    if test no = "$installed"; then
824335c4bbdfSmrg	      func_append notinst_deplibs " $lib"
82444642e01fSmrg	      need_relink=yes
82454642e01fSmrg	    fi
82464642e01fSmrg	    ;;
82474642e01fSmrg	  esac
82484642e01fSmrg	  # This is a shared library
82494642e01fSmrg
82504642e01fSmrg	  # Warn about portability, can't link against -module's on some
82514642e01fSmrg	  # systems (darwin).  Don't bleat about dlopened modules though!
825235c4bbdfSmrg	  dlopenmodule=
82534642e01fSmrg	  for dlpremoduletest in $dlprefiles; do
82544642e01fSmrg	    if test "X$dlpremoduletest" = "X$lib"; then
825535c4bbdfSmrg	      dlopenmodule=$dlpremoduletest
82564642e01fSmrg	      break
82574642e01fSmrg	    fi
82584642e01fSmrg	  done
825935c4bbdfSmrg	  if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then
82606747b715Smrg	    echo
826135c4bbdfSmrg	    if test prog = "$linkmode"; then
82624642e01fSmrg	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
82634642e01fSmrg	    else
82644642e01fSmrg	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
82654642e01fSmrg	    fi
82664642e01fSmrg	    $ECHO "*** $linklib is not portable!"
82674642e01fSmrg	  fi
826835c4bbdfSmrg	  if test lib = "$linkmode" &&
826935c4bbdfSmrg	     test yes = "$hardcode_into_libs"; then
82704642e01fSmrg	    # Hardcode the library path.
82714642e01fSmrg	    # Skip directories that are in the system default run-time
82724642e01fSmrg	    # search path.
82734642e01fSmrg	    case " $sys_lib_dlsearch_path " in
82744642e01fSmrg	    *" $absdir "*) ;;
82754642e01fSmrg	    *)
82764642e01fSmrg	      case "$compile_rpath " in
82774642e01fSmrg	      *" $absdir "*) ;;
827835c4bbdfSmrg	      *) func_append compile_rpath " $absdir" ;;
82794642e01fSmrg	      esac
82804642e01fSmrg	      ;;
82814642e01fSmrg	    esac
82824642e01fSmrg	    case " $sys_lib_dlsearch_path " in
82834642e01fSmrg	    *" $libdir "*) ;;
82844642e01fSmrg	    *)
82854642e01fSmrg	      case "$finalize_rpath " in
82864642e01fSmrg	      *" $libdir "*) ;;
828735c4bbdfSmrg	      *) func_append finalize_rpath " $libdir" ;;
82884642e01fSmrg	      esac
82894642e01fSmrg	      ;;
82904642e01fSmrg	    esac
82914642e01fSmrg	  fi
82924642e01fSmrg
82934642e01fSmrg	  if test -n "$old_archive_from_expsyms_cmds"; then
82944642e01fSmrg	    # figure out the soname
82954642e01fSmrg	    set dummy $library_names
82964642e01fSmrg	    shift
829735c4bbdfSmrg	    realname=$1
82984642e01fSmrg	    shift
82994642e01fSmrg	    libname=`eval "\\$ECHO \"$libname_spec\""`
83004642e01fSmrg	    # use dlname if we got it. it's perfectly good, no?
83014642e01fSmrg	    if test -n "$dlname"; then
830235c4bbdfSmrg	      soname=$dlname
83034642e01fSmrg	    elif test -n "$soname_spec"; then
83044642e01fSmrg	      # bleh windows
83054642e01fSmrg	      case $host in
830635c4bbdfSmrg	      *cygwin* | mingw* | *cegcc* | *os2*)
83074642e01fSmrg	        func_arith $current - $age
83084642e01fSmrg		major=$func_arith_result
830935c4bbdfSmrg		versuffix=-$major
83104642e01fSmrg		;;
83114642e01fSmrg	      esac
83124642e01fSmrg	      eval soname=\"$soname_spec\"
83134642e01fSmrg	    else
831435c4bbdfSmrg	      soname=$realname
83154642e01fSmrg	    fi
83164642e01fSmrg
83174642e01fSmrg	    # Make a new name for the extract_expsyms_cmds to use
831835c4bbdfSmrg	    soroot=$soname
83194642e01fSmrg	    func_basename "$soroot"
832035c4bbdfSmrg	    soname=$func_basename_result
83214642e01fSmrg	    func_stripname 'lib' '.dll' "$soname"
83224642e01fSmrg	    newlib=libimp-$func_stripname_result.a
83234642e01fSmrg
83244642e01fSmrg	    # If the library has no export list, then create one now
83254642e01fSmrg	    if test -f "$output_objdir/$soname-def"; then :
83264642e01fSmrg	    else
832735c4bbdfSmrg	      func_verbose "extracting exported symbol list from '$soname'"
83284642e01fSmrg	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
83294642e01fSmrg	    fi
83304642e01fSmrg
83314642e01fSmrg	    # Create $newlib
83324642e01fSmrg	    if test -f "$output_objdir/$newlib"; then :; else
833335c4bbdfSmrg	      func_verbose "generating import library for '$soname'"
83344642e01fSmrg	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
83354642e01fSmrg	    fi
83364642e01fSmrg	    # make sure the library variables are pointing to the new library
83374642e01fSmrg	    dir=$output_objdir
83384642e01fSmrg	    linklib=$newlib
83394642e01fSmrg	  fi # test -n "$old_archive_from_expsyms_cmds"
83404642e01fSmrg
834135c4bbdfSmrg	  if test prog = "$linkmode" || test relink != "$opt_mode"; then
83424642e01fSmrg	    add_shlibpath=
83434642e01fSmrg	    add_dir=
83444642e01fSmrg	    add=
83454642e01fSmrg	    lib_linked=yes
83464642e01fSmrg	    case $hardcode_action in
83474642e01fSmrg	    immediate | unsupported)
834835c4bbdfSmrg	      if test no = "$hardcode_direct"; then
834935c4bbdfSmrg		add=$dir/$linklib
83504642e01fSmrg		case $host in
835135c4bbdfSmrg		  *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;;
835235c4bbdfSmrg		  *-*-sysv4*uw2*) add_dir=-L$dir ;;
83534642e01fSmrg		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
835435c4bbdfSmrg		    *-*-unixware7*) add_dir=-L$dir ;;
83554642e01fSmrg		  *-*-darwin* )
835635c4bbdfSmrg		    # if the lib is a (non-dlopened) module then we cannot
83574642e01fSmrg		    # link against it, someone is ignoring the earlier warnings
83584642e01fSmrg		    if /usr/bin/file -L $add 2> /dev/null |
835935c4bbdfSmrg			 $GREP ": [^:]* bundle" >/dev/null; then
83604642e01fSmrg		      if test "X$dlopenmodule" != "X$lib"; then
83614642e01fSmrg			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
836235c4bbdfSmrg			if test -z "$old_library"; then
83636747b715Smrg			  echo
83646747b715Smrg			  echo "*** And there doesn't seem to be a static archive available"
83656747b715Smrg			  echo "*** The link will probably fail, sorry"
83664642e01fSmrg			else
836735c4bbdfSmrg			  add=$dir/$old_library
83684642e01fSmrg			fi
83694642e01fSmrg		      elif test -n "$old_library"; then
837035c4bbdfSmrg			add=$dir/$old_library
83714642e01fSmrg		      fi
83724642e01fSmrg		    fi
83734642e01fSmrg		esac
837435c4bbdfSmrg	      elif test no = "$hardcode_minus_L"; then
83754642e01fSmrg		case $host in
837635c4bbdfSmrg		*-*-sunos*) add_shlibpath=$dir ;;
83774642e01fSmrg		esac
837835c4bbdfSmrg		add_dir=-L$dir
837935c4bbdfSmrg		add=-l$name
838035c4bbdfSmrg	      elif test no = "$hardcode_shlibpath_var"; then
838135c4bbdfSmrg		add_shlibpath=$dir
838235c4bbdfSmrg		add=-l$name
83834642e01fSmrg	      else
83844642e01fSmrg		lib_linked=no
83854642e01fSmrg	      fi
83864642e01fSmrg	      ;;
83874642e01fSmrg	    relink)
838835c4bbdfSmrg	      if test yes = "$hardcode_direct" &&
838935c4bbdfSmrg	         test no = "$hardcode_direct_absolute"; then
839035c4bbdfSmrg		add=$dir/$linklib
839135c4bbdfSmrg	      elif test yes = "$hardcode_minus_L"; then
839235c4bbdfSmrg		add_dir=-L$absdir
83934642e01fSmrg		# Try looking first in the location we're being installed to.
83944642e01fSmrg		if test -n "$inst_prefix_dir"; then
83954642e01fSmrg		  case $libdir in
83964642e01fSmrg		    [\\/]*)
839735c4bbdfSmrg		      func_append add_dir " -L$inst_prefix_dir$libdir"
83984642e01fSmrg		      ;;
83994642e01fSmrg		  esac
84004642e01fSmrg		fi
840135c4bbdfSmrg		add=-l$name
840235c4bbdfSmrg	      elif test yes = "$hardcode_shlibpath_var"; then
840335c4bbdfSmrg		add_shlibpath=$dir
840435c4bbdfSmrg		add=-l$name
84054642e01fSmrg	      else
84064642e01fSmrg		lib_linked=no
84074642e01fSmrg	      fi
84084642e01fSmrg	      ;;
84094642e01fSmrg	    *) lib_linked=no ;;
84104642e01fSmrg	    esac
84114642e01fSmrg
841235c4bbdfSmrg	    if test yes != "$lib_linked"; then
84134642e01fSmrg	      func_fatal_configuration "unsupported hardcode properties"
84144642e01fSmrg	    fi
84154642e01fSmrg
84164642e01fSmrg	    if test -n "$add_shlibpath"; then
84174642e01fSmrg	      case :$compile_shlibpath: in
84184642e01fSmrg	      *":$add_shlibpath:"*) ;;
841935c4bbdfSmrg	      *) func_append compile_shlibpath "$add_shlibpath:" ;;
84204642e01fSmrg	      esac
84214642e01fSmrg	    fi
842235c4bbdfSmrg	    if test prog = "$linkmode"; then
84234642e01fSmrg	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
84244642e01fSmrg	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
84254642e01fSmrg	    else
84264642e01fSmrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
84274642e01fSmrg	      test -n "$add" && deplibs="$add $deplibs"
842835c4bbdfSmrg	      if test yes != "$hardcode_direct" &&
842935c4bbdfSmrg		 test yes != "$hardcode_minus_L" &&
843035c4bbdfSmrg		 test yes = "$hardcode_shlibpath_var"; then
84314642e01fSmrg		case :$finalize_shlibpath: in
84324642e01fSmrg		*":$libdir:"*) ;;
843335c4bbdfSmrg		*) func_append finalize_shlibpath "$libdir:" ;;
84344642e01fSmrg		esac
84354642e01fSmrg	      fi
84364642e01fSmrg	    fi
84374642e01fSmrg	  fi
84384642e01fSmrg
843935c4bbdfSmrg	  if test prog = "$linkmode" || test relink = "$opt_mode"; then
84404642e01fSmrg	    add_shlibpath=
84414642e01fSmrg	    add_dir=
84424642e01fSmrg	    add=
84434642e01fSmrg	    # Finalize command for both is simple: just hardcode it.
844435c4bbdfSmrg	    if test yes = "$hardcode_direct" &&
844535c4bbdfSmrg	       test no = "$hardcode_direct_absolute"; then
844635c4bbdfSmrg	      add=$libdir/$linklib
844735c4bbdfSmrg	    elif test yes = "$hardcode_minus_L"; then
844835c4bbdfSmrg	      add_dir=-L$libdir
844935c4bbdfSmrg	      add=-l$name
845035c4bbdfSmrg	    elif test yes = "$hardcode_shlibpath_var"; then
84514642e01fSmrg	      case :$finalize_shlibpath: in
84524642e01fSmrg	      *":$libdir:"*) ;;
845335c4bbdfSmrg	      *) func_append finalize_shlibpath "$libdir:" ;;
84544642e01fSmrg	      esac
845535c4bbdfSmrg	      add=-l$name
845635c4bbdfSmrg	    elif test yes = "$hardcode_automatic"; then
84574642e01fSmrg	      if test -n "$inst_prefix_dir" &&
845835c4bbdfSmrg		 test -f "$inst_prefix_dir$libdir/$linklib"; then
845935c4bbdfSmrg		add=$inst_prefix_dir$libdir/$linklib
84604642e01fSmrg	      else
846135c4bbdfSmrg		add=$libdir/$linklib
84624642e01fSmrg	      fi
84634642e01fSmrg	    else
84644642e01fSmrg	      # We cannot seem to hardcode it, guess we'll fake it.
846535c4bbdfSmrg	      add_dir=-L$libdir
84664642e01fSmrg	      # Try looking first in the location we're being installed to.
84674642e01fSmrg	      if test -n "$inst_prefix_dir"; then
84684642e01fSmrg		case $libdir in
84694642e01fSmrg		  [\\/]*)
847035c4bbdfSmrg		    func_append add_dir " -L$inst_prefix_dir$libdir"
84714642e01fSmrg		    ;;
84724642e01fSmrg		esac
84734642e01fSmrg	      fi
847435c4bbdfSmrg	      add=-l$name
84754642e01fSmrg	    fi
84764642e01fSmrg
847735c4bbdfSmrg	    if test prog = "$linkmode"; then
84784642e01fSmrg	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
84794642e01fSmrg	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
84804642e01fSmrg	    else
84814642e01fSmrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
84824642e01fSmrg	      test -n "$add" && deplibs="$add $deplibs"
84834642e01fSmrg	    fi
84844642e01fSmrg	  fi
848535c4bbdfSmrg	elif test prog = "$linkmode"; then
84864642e01fSmrg	  # Here we assume that one of hardcode_direct or hardcode_minus_L
84874642e01fSmrg	  # is not unsupported.  This is valid on all known static and
84884642e01fSmrg	  # shared platforms.
848935c4bbdfSmrg	  if test unsupported != "$hardcode_direct"; then
849035c4bbdfSmrg	    test -n "$old_library" && linklib=$old_library
84914642e01fSmrg	    compile_deplibs="$dir/$linklib $compile_deplibs"
84924642e01fSmrg	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
84934642e01fSmrg	  else
84944642e01fSmrg	    compile_deplibs="-l$name -L$dir $compile_deplibs"
84954642e01fSmrg	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
84964642e01fSmrg	  fi
849735c4bbdfSmrg	elif test yes = "$build_libtool_libs"; then
84984642e01fSmrg	  # Not a shared library
849935c4bbdfSmrg	  if test pass_all != "$deplibs_check_method"; then
85004642e01fSmrg	    # We're trying link a shared library against a static one
85014642e01fSmrg	    # but the system doesn't support it.
85024642e01fSmrg
85034642e01fSmrg	    # Just print a warning and add the library to dependency_libs so
85044642e01fSmrg	    # that the program can be linked against the static library.
85056747b715Smrg	    echo
850635c4bbdfSmrg	    $ECHO "*** Warning: This system cannot link to static lib archive $lib."
85076747b715Smrg	    echo "*** I have the capability to make that library automatically link in when"
85086747b715Smrg	    echo "*** you link to this library.  But I can only do this if you have a"
85096747b715Smrg	    echo "*** shared version of the library, which you do not appear to have."
851035c4bbdfSmrg	    if test yes = "$module"; then
85116747b715Smrg	      echo "*** But as you try to build a module library, libtool will still create "
85126747b715Smrg	      echo "*** a static module, that should work as long as the dlopening application"
85136747b715Smrg	      echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
85144642e01fSmrg	      if test -z "$global_symbol_pipe"; then
85156747b715Smrg		echo
85166747b715Smrg		echo "*** However, this would only work if libtool was able to extract symbol"
851735c4bbdfSmrg		echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
85186747b715Smrg		echo "*** not find such a program.  So, this module is probably useless."
851935c4bbdfSmrg		echo "*** 'nm' from GNU binutils and a full rebuild may help."
85204642e01fSmrg	      fi
852135c4bbdfSmrg	      if test no = "$build_old_libs"; then
85224642e01fSmrg		build_libtool_libs=module
85234642e01fSmrg		build_old_libs=yes
85244642e01fSmrg	      else
85254642e01fSmrg		build_libtool_libs=no
85264642e01fSmrg	      fi
85274642e01fSmrg	    fi
85284642e01fSmrg	  else
85294642e01fSmrg	    deplibs="$dir/$old_library $deplibs"
85304642e01fSmrg	    link_static=yes
85314642e01fSmrg	  fi
85324642e01fSmrg	fi # link shared/static library?
85334642e01fSmrg
853435c4bbdfSmrg	if test lib = "$linkmode"; then
85354642e01fSmrg	  if test -n "$dependency_libs" &&
853635c4bbdfSmrg	     { test yes != "$hardcode_into_libs" ||
853735c4bbdfSmrg	       test yes = "$build_old_libs" ||
853835c4bbdfSmrg	       test yes = "$link_static"; }; then
85394642e01fSmrg	    # Extract -R from dependency_libs
85404642e01fSmrg	    temp_deplibs=
85414642e01fSmrg	    for libdir in $dependency_libs; do
85424642e01fSmrg	      case $libdir in
85434642e01fSmrg	      -R*) func_stripname '-R' '' "$libdir"
85444642e01fSmrg	           temp_xrpath=$func_stripname_result
85454642e01fSmrg		   case " $xrpath " in
85464642e01fSmrg		   *" $temp_xrpath "*) ;;
854735c4bbdfSmrg		   *) func_append xrpath " $temp_xrpath";;
85484642e01fSmrg		   esac;;
854935c4bbdfSmrg	      *) func_append temp_deplibs " $libdir";;
85504642e01fSmrg	      esac
85514642e01fSmrg	    done
855235c4bbdfSmrg	    dependency_libs=$temp_deplibs
85534642e01fSmrg	  fi
85544642e01fSmrg
855535c4bbdfSmrg	  func_append newlib_search_path " $absdir"
85564642e01fSmrg	  # Link against this library
855735c4bbdfSmrg	  test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
85584642e01fSmrg	  # ... and its dependency_libs
85594642e01fSmrg	  tmp_libs=
85604642e01fSmrg	  for deplib in $dependency_libs; do
85614642e01fSmrg	    newdependency_libs="$deplib $newdependency_libs"
856235c4bbdfSmrg	    case $deplib in
856335c4bbdfSmrg              -L*) func_stripname '-L' '' "$deplib"
856435c4bbdfSmrg                   func_resolve_sysroot "$func_stripname_result";;
856535c4bbdfSmrg              *) func_resolve_sysroot "$deplib" ;;
856635c4bbdfSmrg            esac
856735c4bbdfSmrg	    if $opt_preserve_dup_deps; then
85684642e01fSmrg	      case "$tmp_libs " in
856935c4bbdfSmrg	      *" $func_resolve_sysroot_result "*)
857035c4bbdfSmrg                func_append specialdeplibs " $func_resolve_sysroot_result" ;;
85714642e01fSmrg	      esac
85724642e01fSmrg	    fi
857335c4bbdfSmrg	    func_append tmp_libs " $func_resolve_sysroot_result"
85744642e01fSmrg	  done
85754642e01fSmrg
857635c4bbdfSmrg	  if test no != "$link_all_deplibs"; then
85774642e01fSmrg	    # Add the search paths of all dependency libraries
85784642e01fSmrg	    for deplib in $dependency_libs; do
85794642e01fSmrg	      path=
85804642e01fSmrg	      case $deplib in
858135c4bbdfSmrg	      -L*) path=$deplib ;;
85824642e01fSmrg	      *.la)
858335c4bbdfSmrg	        func_resolve_sysroot "$deplib"
858435c4bbdfSmrg	        deplib=$func_resolve_sysroot_result
85854642e01fSmrg	        func_dirname "$deplib" "" "."
858635c4bbdfSmrg		dir=$func_dirname_result
85874642e01fSmrg		# We need an absolute path.
85884642e01fSmrg		case $dir in
858935c4bbdfSmrg		[\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;;
85904642e01fSmrg		*)
85914642e01fSmrg		  absdir=`cd "$dir" && pwd`
85924642e01fSmrg		  if test -z "$absdir"; then
859335c4bbdfSmrg		    func_warning "cannot determine absolute directory name of '$dir'"
859435c4bbdfSmrg		    absdir=$dir
85954642e01fSmrg		  fi
85964642e01fSmrg		  ;;
85974642e01fSmrg		esac
85984642e01fSmrg		if $GREP "^installed=no" $deplib > /dev/null; then
85994642e01fSmrg		case $host in
86004642e01fSmrg		*-*-darwin*)
86014642e01fSmrg		  depdepl=
860235c4bbdfSmrg		  eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
860335c4bbdfSmrg		  if test -n "$deplibrary_names"; then
860435c4bbdfSmrg		    for tmp in $deplibrary_names; do
86054642e01fSmrg		      depdepl=$tmp
86064642e01fSmrg		    done
860735c4bbdfSmrg		    if test -f "$absdir/$objdir/$depdepl"; then
860835c4bbdfSmrg		      depdepl=$absdir/$objdir/$depdepl
860935c4bbdfSmrg		      darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
86104642e01fSmrg                      if test -z "$darwin_install_name"; then
861135c4bbdfSmrg                          darwin_install_name=`$OTOOL64 -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
86124642e01fSmrg                      fi
861335c4bbdfSmrg		      func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl"
861435c4bbdfSmrg		      func_append linker_flags " -dylib_file $darwin_install_name:$depdepl"
86154642e01fSmrg		      path=
86164642e01fSmrg		    fi
86174642e01fSmrg		  fi
86184642e01fSmrg		  ;;
86194642e01fSmrg		*)
862035c4bbdfSmrg		  path=-L$absdir/$objdir
86214642e01fSmrg		  ;;
86224642e01fSmrg		esac
86234642e01fSmrg		else
862435c4bbdfSmrg		  eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
86254642e01fSmrg		  test -z "$libdir" && \
862635c4bbdfSmrg		    func_fatal_error "'$deplib' is not a valid libtool archive"
86274642e01fSmrg		  test "$absdir" != "$libdir" && \
862835c4bbdfSmrg		    func_warning "'$deplib' seems to be moved"
86294642e01fSmrg
863035c4bbdfSmrg		  path=-L$absdir
86314642e01fSmrg		fi
86324642e01fSmrg		;;
86334642e01fSmrg	      esac
86344642e01fSmrg	      case " $deplibs " in
86354642e01fSmrg	      *" $path "*) ;;
86364642e01fSmrg	      *) deplibs="$path $deplibs" ;;
86374642e01fSmrg	      esac
86384642e01fSmrg	    done
86394642e01fSmrg	  fi # link_all_deplibs != no
86404642e01fSmrg	fi # linkmode = lib
86414642e01fSmrg      done # for deplib in $libs
864235c4bbdfSmrg      if test link = "$pass"; then
864335c4bbdfSmrg	if test prog = "$linkmode"; then
86444642e01fSmrg	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
86454642e01fSmrg	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
86464642e01fSmrg	else
86476747b715Smrg	  compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
86484642e01fSmrg	fi
86494642e01fSmrg      fi
865035c4bbdfSmrg      dependency_libs=$newdependency_libs
865135c4bbdfSmrg      if test dlpreopen = "$pass"; then
86524642e01fSmrg	# Link the dlpreopened libraries before other libraries
86534642e01fSmrg	for deplib in $save_deplibs; do
86544642e01fSmrg	  deplibs="$deplib $deplibs"
86554642e01fSmrg	done
86564642e01fSmrg      fi
865735c4bbdfSmrg      if test dlopen != "$pass"; then
865835c4bbdfSmrg	test conv = "$pass" || {
86594642e01fSmrg	  # Make sure lib_search_path contains only unique directories.
86604642e01fSmrg	  lib_search_path=
86614642e01fSmrg	  for dir in $newlib_search_path; do
86624642e01fSmrg	    case "$lib_search_path " in
86634642e01fSmrg	    *" $dir "*) ;;
866435c4bbdfSmrg	    *) func_append lib_search_path " $dir" ;;
86654642e01fSmrg	    esac
86664642e01fSmrg	  done
86674642e01fSmrg	  newlib_search_path=
866835c4bbdfSmrg	}
86694642e01fSmrg
867035c4bbdfSmrg	if test prog,link = "$linkmode,$pass"; then
86714642e01fSmrg	  vars="compile_deplibs finalize_deplibs"
867235c4bbdfSmrg	else
867335c4bbdfSmrg	  vars=deplibs
86744642e01fSmrg	fi
86754642e01fSmrg	for var in $vars dependency_libs; do
86764642e01fSmrg	  # Add libraries to $var in reverse order
86774642e01fSmrg	  eval tmp_libs=\"\$$var\"
86784642e01fSmrg	  new_libs=
86794642e01fSmrg	  for deplib in $tmp_libs; do
86804642e01fSmrg	    # FIXME: Pedantically, this is the right thing to do, so
86814642e01fSmrg	    #        that some nasty dependency loop isn't accidentally
86824642e01fSmrg	    #        broken:
86834642e01fSmrg	    #new_libs="$deplib $new_libs"
86844642e01fSmrg	    # Pragmatically, this seems to cause very few problems in
86854642e01fSmrg	    # practice:
86864642e01fSmrg	    case $deplib in
86874642e01fSmrg	    -L*) new_libs="$deplib $new_libs" ;;
86884642e01fSmrg	    -R*) ;;
86894642e01fSmrg	    *)
86904642e01fSmrg	      # And here is the reason: when a library appears more
86914642e01fSmrg	      # than once as an explicit dependence of a library, or
86924642e01fSmrg	      # is implicitly linked in more than once by the
86934642e01fSmrg	      # compiler, it is considered special, and multiple
86944642e01fSmrg	      # occurrences thereof are not removed.  Compare this
86954642e01fSmrg	      # with having the same library being listed as a
86964642e01fSmrg	      # dependency of multiple other libraries: in this case,
86974642e01fSmrg	      # we know (pedantically, we assume) the library does not
86984642e01fSmrg	      # need to be listed more than once, so we keep only the
86994642e01fSmrg	      # last copy.  This is not always right, but it is rare
87004642e01fSmrg	      # enough that we require users that really mean to play
87014642e01fSmrg	      # such unportable linking tricks to link the library
87024642e01fSmrg	      # using -Wl,-lname, so that libtool does not consider it
87034642e01fSmrg	      # for duplicate removal.
87044642e01fSmrg	      case " $specialdeplibs " in
87054642e01fSmrg	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
87064642e01fSmrg	      *)
87074642e01fSmrg		case " $new_libs " in
87084642e01fSmrg		*" $deplib "*) ;;
87094642e01fSmrg		*) new_libs="$deplib $new_libs" ;;
87104642e01fSmrg		esac
87114642e01fSmrg		;;
87124642e01fSmrg	      esac
87134642e01fSmrg	      ;;
87144642e01fSmrg	    esac
87154642e01fSmrg	  done
87164642e01fSmrg	  tmp_libs=
87174642e01fSmrg	  for deplib in $new_libs; do
87184642e01fSmrg	    case $deplib in
87194642e01fSmrg	    -L*)
87204642e01fSmrg	      case " $tmp_libs " in
87214642e01fSmrg	      *" $deplib "*) ;;
872235c4bbdfSmrg	      *) func_append tmp_libs " $deplib" ;;
87234642e01fSmrg	      esac
87244642e01fSmrg	      ;;
872535c4bbdfSmrg	    *) func_append tmp_libs " $deplib" ;;
87264642e01fSmrg	    esac
87274642e01fSmrg	  done
87284642e01fSmrg	  eval $var=\"$tmp_libs\"
87294642e01fSmrg	done # for var
87304642e01fSmrg      fi
873135c4bbdfSmrg
873235c4bbdfSmrg      # Add Sun CC postdeps if required:
873335c4bbdfSmrg      test CXX = "$tagname" && {
873435c4bbdfSmrg        case $host_os in
873535c4bbdfSmrg        linux*)
873635c4bbdfSmrg          case `$CC -V 2>&1 | sed 5q` in
873735c4bbdfSmrg          *Sun\ C*) # Sun C++ 5.9
873835c4bbdfSmrg            func_suncc_cstd_abi
873935c4bbdfSmrg
874035c4bbdfSmrg            if test no != "$suncc_use_cstd_abi"; then
874135c4bbdfSmrg              func_append postdeps ' -library=Cstd -library=Crun'
874235c4bbdfSmrg            fi
874335c4bbdfSmrg            ;;
874435c4bbdfSmrg          esac
874535c4bbdfSmrg          ;;
874635c4bbdfSmrg
874735c4bbdfSmrg        solaris*)
874835c4bbdfSmrg          func_cc_basename "$CC"
874935c4bbdfSmrg          case $func_cc_basename_result in
875035c4bbdfSmrg          CC* | sunCC*)
875135c4bbdfSmrg            func_suncc_cstd_abi
875235c4bbdfSmrg
875335c4bbdfSmrg            if test no != "$suncc_use_cstd_abi"; then
875435c4bbdfSmrg              func_append postdeps ' -library=Cstd -library=Crun'
875535c4bbdfSmrg            fi
875635c4bbdfSmrg            ;;
875735c4bbdfSmrg          esac
875835c4bbdfSmrg          ;;
875935c4bbdfSmrg        esac
876035c4bbdfSmrg      }
876135c4bbdfSmrg
87624642e01fSmrg      # Last step: remove runtime libs from dependency_libs
87634642e01fSmrg      # (they stay in deplibs)
87644642e01fSmrg      tmp_libs=
876535c4bbdfSmrg      for i in $dependency_libs; do
87664642e01fSmrg	case " $predeps $postdeps $compiler_lib_search_path " in
87674642e01fSmrg	*" $i "*)
876835c4bbdfSmrg	  i=
87694642e01fSmrg	  ;;
87704642e01fSmrg	esac
877135c4bbdfSmrg	if test -n "$i"; then
877235c4bbdfSmrg	  func_append tmp_libs " $i"
87734642e01fSmrg	fi
87744642e01fSmrg      done
87754642e01fSmrg      dependency_libs=$tmp_libs
87764642e01fSmrg    done # for pass
877735c4bbdfSmrg    if test prog = "$linkmode"; then
877835c4bbdfSmrg      dlfiles=$newdlfiles
87794642e01fSmrg    fi
878035c4bbdfSmrg    if test prog = "$linkmode" || test lib = "$linkmode"; then
878135c4bbdfSmrg      dlprefiles=$newdlprefiles
87824642e01fSmrg    fi
87834642e01fSmrg
87844642e01fSmrg    case $linkmode in
87854642e01fSmrg    oldlib)
878635c4bbdfSmrg      if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
878735c4bbdfSmrg	func_warning "'-dlopen' is ignored for archives"
87884642e01fSmrg      fi
87894642e01fSmrg
87904642e01fSmrg      case " $deplibs" in
87914642e01fSmrg      *\ -l* | *\ -L*)
879235c4bbdfSmrg	func_warning "'-l' and '-L' are ignored for archives" ;;
87934642e01fSmrg      esac
87944642e01fSmrg
87954642e01fSmrg      test -n "$rpath" && \
879635c4bbdfSmrg	func_warning "'-rpath' is ignored for archives"
87974642e01fSmrg
87984642e01fSmrg      test -n "$xrpath" && \
879935c4bbdfSmrg	func_warning "'-R' is ignored for archives"
88004642e01fSmrg
88014642e01fSmrg      test -n "$vinfo" && \
880235c4bbdfSmrg	func_warning "'-version-info/-version-number' is ignored for archives"
88034642e01fSmrg
88044642e01fSmrg      test -n "$release" && \
880535c4bbdfSmrg	func_warning "'-release' is ignored for archives"
88064642e01fSmrg
88074642e01fSmrg      test -n "$export_symbols$export_symbols_regex" && \
880835c4bbdfSmrg	func_warning "'-export-symbols' is ignored for archives"
88094642e01fSmrg
88104642e01fSmrg      # Now set the variables for building old libraries.
88114642e01fSmrg      build_libtool_libs=no
881235c4bbdfSmrg      oldlibs=$output
881335c4bbdfSmrg      func_append objs "$old_deplibs"
88144642e01fSmrg      ;;
88154642e01fSmrg
88164642e01fSmrg    lib)
881735c4bbdfSmrg      # Make sure we only generate libraries of the form 'libNAME.la'.
88184642e01fSmrg      case $outputname in
88194642e01fSmrg      lib*)
88204642e01fSmrg	func_stripname 'lib' '.la' "$outputname"
88214642e01fSmrg	name=$func_stripname_result
88224642e01fSmrg	eval shared_ext=\"$shrext_cmds\"
88234642e01fSmrg	eval libname=\"$libname_spec\"
88244642e01fSmrg	;;
88254642e01fSmrg      *)
882635c4bbdfSmrg	test no = "$module" \
882735c4bbdfSmrg	  && func_fatal_help "libtool library '$output' must begin with 'lib'"
88284642e01fSmrg
882935c4bbdfSmrg	if test no != "$need_lib_prefix"; then
88304642e01fSmrg	  # Add the "lib" prefix for modules if required
88314642e01fSmrg	  func_stripname '' '.la' "$outputname"
88324642e01fSmrg	  name=$func_stripname_result
88334642e01fSmrg	  eval shared_ext=\"$shrext_cmds\"
88344642e01fSmrg	  eval libname=\"$libname_spec\"
88354642e01fSmrg	else
88364642e01fSmrg	  func_stripname '' '.la' "$outputname"
88374642e01fSmrg	  libname=$func_stripname_result
88384642e01fSmrg	fi
88394642e01fSmrg	;;
88404642e01fSmrg      esac
88414642e01fSmrg
88424642e01fSmrg      if test -n "$objs"; then
884335c4bbdfSmrg	if test pass_all != "$deplibs_check_method"; then
884435c4bbdfSmrg	  func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs"
88454642e01fSmrg	else
88466747b715Smrg	  echo
88474642e01fSmrg	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
88484642e01fSmrg	  $ECHO "*** objects $objs is not portable!"
884935c4bbdfSmrg	  func_append libobjs " $objs"
88504642e01fSmrg	fi
88514642e01fSmrg      fi
88524642e01fSmrg
885335c4bbdfSmrg      test no = "$dlself" \
885435c4bbdfSmrg	|| func_warning "'-dlopen self' is ignored for libtool libraries"
88554642e01fSmrg
88564642e01fSmrg      set dummy $rpath
88574642e01fSmrg      shift
885835c4bbdfSmrg      test 1 -lt "$#" \
885935c4bbdfSmrg	&& func_warning "ignoring multiple '-rpath's for a libtool library"
88604642e01fSmrg
886135c4bbdfSmrg      install_libdir=$1
88624642e01fSmrg
88634642e01fSmrg      oldlibs=
88644642e01fSmrg      if test -z "$rpath"; then
886535c4bbdfSmrg	if test yes = "$build_libtool_libs"; then
88664642e01fSmrg	  # Building a libtool convenience library.
886735c4bbdfSmrg	  # Some compilers have problems with a '.al' extension so
88684642e01fSmrg	  # convenience libraries should have the same extension an
88694642e01fSmrg	  # archive normally would.
88704642e01fSmrg	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
88714642e01fSmrg	  build_libtool_libs=convenience
88724642e01fSmrg	  build_old_libs=yes
88734642e01fSmrg	fi
88744642e01fSmrg
88754642e01fSmrg	test -n "$vinfo" && \
887635c4bbdfSmrg	  func_warning "'-version-info/-version-number' is ignored for convenience libraries"
88774642e01fSmrg
88784642e01fSmrg	test -n "$release" && \
887935c4bbdfSmrg	  func_warning "'-release' is ignored for convenience libraries"
88804642e01fSmrg      else
88814642e01fSmrg
88824642e01fSmrg	# Parse the version information argument.
888335c4bbdfSmrg	save_ifs=$IFS; IFS=:
88844642e01fSmrg	set dummy $vinfo 0 0 0
88854642e01fSmrg	shift
888635c4bbdfSmrg	IFS=$save_ifs
88874642e01fSmrg
88884642e01fSmrg	test -n "$7" && \
888935c4bbdfSmrg	  func_fatal_help "too many parameters to '-version-info'"
88904642e01fSmrg
88914642e01fSmrg	# convert absolute version numbers to libtool ages
88924642e01fSmrg	# this retains compatibility with .la files and attempts
88934642e01fSmrg	# to make the code below a bit more comprehensible
88944642e01fSmrg
88954642e01fSmrg	case $vinfo_number in
88964642e01fSmrg	yes)
889735c4bbdfSmrg	  number_major=$1
889835c4bbdfSmrg	  number_minor=$2
889935c4bbdfSmrg	  number_revision=$3
89004642e01fSmrg	  #
89014642e01fSmrg	  # There are really only two kinds -- those that
89024642e01fSmrg	  # use the current revision as the major version
89034642e01fSmrg	  # and those that subtract age and use age as
89044642e01fSmrg	  # a minor version.  But, then there is irix
890535c4bbdfSmrg	  # that has an extra 1 added just for fun
89064642e01fSmrg	  #
89074642e01fSmrg	  case $version_type in
890835c4bbdfSmrg	  # correct linux to gnu/linux during the next big refactor
890935c4bbdfSmrg	  darwin|freebsd-elf|linux|osf|windows|none)
89104642e01fSmrg	    func_arith $number_major + $number_minor
89114642e01fSmrg	    current=$func_arith_result
891235c4bbdfSmrg	    age=$number_minor
891335c4bbdfSmrg	    revision=$number_revision
89144642e01fSmrg	    ;;
891535c4bbdfSmrg	  freebsd-aout|qnx|sunos)
891635c4bbdfSmrg	    current=$number_major
891735c4bbdfSmrg	    revision=$number_minor
891835c4bbdfSmrg	    age=0
89194642e01fSmrg	    ;;
89204642e01fSmrg	  irix|nonstopux)
89214642e01fSmrg	    func_arith $number_major + $number_minor
89224642e01fSmrg	    current=$func_arith_result
892335c4bbdfSmrg	    age=$number_minor
892435c4bbdfSmrg	    revision=$number_minor
89254642e01fSmrg	    lt_irix_increment=no
89264642e01fSmrg	    ;;
8927ed6184dfSmrg	  *)
8928ed6184dfSmrg	    func_fatal_configuration "$modename: unknown library version type '$version_type'"
8929ed6184dfSmrg	    ;;
89304642e01fSmrg	  esac
89314642e01fSmrg	  ;;
89324642e01fSmrg	no)
893335c4bbdfSmrg	  current=$1
893435c4bbdfSmrg	  revision=$2
893535c4bbdfSmrg	  age=$3
89364642e01fSmrg	  ;;
89374642e01fSmrg	esac
89384642e01fSmrg
89394642e01fSmrg	# Check that each of the things are valid numbers.
89404642e01fSmrg	case $current in
89414642e01fSmrg	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]) ;;
89424642e01fSmrg	*)
894335c4bbdfSmrg	  func_error "CURRENT '$current' must be a nonnegative integer"
894435c4bbdfSmrg	  func_fatal_error "'$vinfo' is not valid version information"
89454642e01fSmrg	  ;;
89464642e01fSmrg	esac
89474642e01fSmrg
89484642e01fSmrg	case $revision in
89494642e01fSmrg	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]) ;;
89504642e01fSmrg	*)
895135c4bbdfSmrg	  func_error "REVISION '$revision' must be a nonnegative integer"
895235c4bbdfSmrg	  func_fatal_error "'$vinfo' is not valid version information"
89534642e01fSmrg	  ;;
89544642e01fSmrg	esac
89554642e01fSmrg
89564642e01fSmrg	case $age in
89574642e01fSmrg	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]) ;;
89584642e01fSmrg	*)
895935c4bbdfSmrg	  func_error "AGE '$age' must be a nonnegative integer"
896035c4bbdfSmrg	  func_fatal_error "'$vinfo' is not valid version information"
89614642e01fSmrg	  ;;
89624642e01fSmrg	esac
89634642e01fSmrg
89644642e01fSmrg	if test "$age" -gt "$current"; then
896535c4bbdfSmrg	  func_error "AGE '$age' is greater than the current interface number '$current'"
896635c4bbdfSmrg	  func_fatal_error "'$vinfo' is not valid version information"
89674642e01fSmrg	fi
89684642e01fSmrg
89694642e01fSmrg	# Calculate the version variables.
89704642e01fSmrg	major=
89714642e01fSmrg	versuffix=
89724642e01fSmrg	verstring=
89734642e01fSmrg	case $version_type in
89744642e01fSmrg	none) ;;
89754642e01fSmrg
89764642e01fSmrg	darwin)
89774642e01fSmrg	  # Like Linux, but with the current version available in
89784642e01fSmrg	  # verstring for coding it into the library header
89794642e01fSmrg	  func_arith $current - $age
89804642e01fSmrg	  major=.$func_arith_result
898135c4bbdfSmrg	  versuffix=$major.$age.$revision
89824642e01fSmrg	  # Darwin ld doesn't like 0 for these options...
89834642e01fSmrg	  func_arith $current + 1
89844642e01fSmrg	  minor_current=$func_arith_result
898535c4bbdfSmrg	  xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
89864642e01fSmrg	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
898735c4bbdfSmrg          # On Darwin other compilers
898835c4bbdfSmrg          case $CC in
898935c4bbdfSmrg              nagfor*)
899035c4bbdfSmrg                  verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
899135c4bbdfSmrg                  ;;
899235c4bbdfSmrg              *)
899335c4bbdfSmrg                  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
899435c4bbdfSmrg                  ;;
899535c4bbdfSmrg          esac
89964642e01fSmrg	  ;;
89974642e01fSmrg
89984642e01fSmrg	freebsd-aout)
899935c4bbdfSmrg	  major=.$current
900035c4bbdfSmrg	  versuffix=.$current.$revision
90014642e01fSmrg	  ;;
90024642e01fSmrg
90034642e01fSmrg	freebsd-elf)
900435c4bbdfSmrg	  func_arith $current - $age
900535c4bbdfSmrg	  major=.$func_arith_result
900635c4bbdfSmrg	  versuffix=$major.$age.$revision
90074642e01fSmrg	  ;;
90084642e01fSmrg
90094642e01fSmrg	irix | nonstopux)
901035c4bbdfSmrg	  if test no = "$lt_irix_increment"; then
90114642e01fSmrg	    func_arith $current - $age
90124642e01fSmrg	  else
90134642e01fSmrg	    func_arith $current - $age + 1
90144642e01fSmrg	  fi
90154642e01fSmrg	  major=$func_arith_result
90164642e01fSmrg
90174642e01fSmrg	  case $version_type in
90184642e01fSmrg	    nonstopux) verstring_prefix=nonstopux ;;
90194642e01fSmrg	    *)         verstring_prefix=sgi ;;
90204642e01fSmrg	  esac
902135c4bbdfSmrg	  verstring=$verstring_prefix$major.$revision
90224642e01fSmrg
90234642e01fSmrg	  # Add in all the interfaces that we are compatible with.
90244642e01fSmrg	  loop=$revision
902535c4bbdfSmrg	  while test 0 -ne "$loop"; do
90264642e01fSmrg	    func_arith $revision - $loop
90274642e01fSmrg	    iface=$func_arith_result
90284642e01fSmrg	    func_arith $loop - 1
90294642e01fSmrg	    loop=$func_arith_result
903035c4bbdfSmrg	    verstring=$verstring_prefix$major.$iface:$verstring
90314642e01fSmrg	  done
90324642e01fSmrg
903335c4bbdfSmrg	  # Before this point, $major must not contain '.'.
90344642e01fSmrg	  major=.$major
903535c4bbdfSmrg	  versuffix=$major.$revision
90364642e01fSmrg	  ;;
90374642e01fSmrg
903835c4bbdfSmrg	linux) # correct to gnu/linux during the next big refactor
90394642e01fSmrg	  func_arith $current - $age
90404642e01fSmrg	  major=.$func_arith_result
904135c4bbdfSmrg	  versuffix=$major.$age.$revision
90424642e01fSmrg	  ;;
90434642e01fSmrg
90444642e01fSmrg	osf)
90454642e01fSmrg	  func_arith $current - $age
90464642e01fSmrg	  major=.$func_arith_result
904735c4bbdfSmrg	  versuffix=.$current.$age.$revision
904835c4bbdfSmrg	  verstring=$current.$age.$revision
90494642e01fSmrg
90504642e01fSmrg	  # Add in all the interfaces that we are compatible with.
90514642e01fSmrg	  loop=$age
905235c4bbdfSmrg	  while test 0 -ne "$loop"; do
90534642e01fSmrg	    func_arith $current - $loop
90544642e01fSmrg	    iface=$func_arith_result
90554642e01fSmrg	    func_arith $loop - 1
90564642e01fSmrg	    loop=$func_arith_result
905735c4bbdfSmrg	    verstring=$verstring:$iface.0
90584642e01fSmrg	  done
90594642e01fSmrg
90604642e01fSmrg	  # Make executables depend on our current version.
906135c4bbdfSmrg	  func_append verstring ":$current.0"
90624642e01fSmrg	  ;;
90634642e01fSmrg
90644642e01fSmrg	qnx)
906535c4bbdfSmrg	  major=.$current
906635c4bbdfSmrg	  versuffix=.$current
906735c4bbdfSmrg	  ;;
906835c4bbdfSmrg
906935c4bbdfSmrg	sco)
907035c4bbdfSmrg	  major=.$current
907135c4bbdfSmrg	  versuffix=.$current
90724642e01fSmrg	  ;;
90734642e01fSmrg
90744642e01fSmrg	sunos)
907535c4bbdfSmrg	  major=.$current
907635c4bbdfSmrg	  versuffix=.$current.$revision
90774642e01fSmrg	  ;;
90784642e01fSmrg
90794642e01fSmrg	windows)
90804642e01fSmrg	  # Use '-' rather than '.', since we only want one
908135c4bbdfSmrg	  # extension on DOS 8.3 file systems.
90824642e01fSmrg	  func_arith $current - $age
90834642e01fSmrg	  major=$func_arith_result
908435c4bbdfSmrg	  versuffix=-$major
90854642e01fSmrg	  ;;
90864642e01fSmrg
90874642e01fSmrg	*)
908835c4bbdfSmrg	  func_fatal_configuration "unknown library version type '$version_type'"
90894642e01fSmrg	  ;;
90904642e01fSmrg	esac
90914642e01fSmrg
90924642e01fSmrg	# Clear the version info if we defaulted, and they specified a release.
90934642e01fSmrg	if test -z "$vinfo" && test -n "$release"; then
90944642e01fSmrg	  major=
90954642e01fSmrg	  case $version_type in
90964642e01fSmrg	  darwin)
90974642e01fSmrg	    # we can't check for "0.0" in archive_cmds due to quoting
90984642e01fSmrg	    # problems, so we reset it completely
90994642e01fSmrg	    verstring=
91004642e01fSmrg	    ;;
91014642e01fSmrg	  *)
910235c4bbdfSmrg	    verstring=0.0
91034642e01fSmrg	    ;;
91044642e01fSmrg	  esac
910535c4bbdfSmrg	  if test no = "$need_version"; then
91064642e01fSmrg	    versuffix=
91074642e01fSmrg	  else
910835c4bbdfSmrg	    versuffix=.0.0
91094642e01fSmrg	  fi
91104642e01fSmrg	fi
91114642e01fSmrg
91124642e01fSmrg	# Remove version info from name if versioning should be avoided
911335c4bbdfSmrg	if test yes,no = "$avoid_version,$need_version"; then
91144642e01fSmrg	  major=
91154642e01fSmrg	  versuffix=
911635c4bbdfSmrg	  verstring=
91174642e01fSmrg	fi
91184642e01fSmrg
91194642e01fSmrg	# Check to see if the archive will have undefined symbols.
912035c4bbdfSmrg	if test yes = "$allow_undefined"; then
912135c4bbdfSmrg	  if test unsupported = "$allow_undefined_flag"; then
912235c4bbdfSmrg	    if test yes = "$build_old_libs"; then
912335c4bbdfSmrg	      func_warning "undefined symbols not allowed in $host shared libraries; building static only"
912435c4bbdfSmrg	      build_libtool_libs=no
912535c4bbdfSmrg	    else
912635c4bbdfSmrg	      func_fatal_error "can't build $host shared library unless -no-undefined is specified"
912735c4bbdfSmrg	    fi
91284642e01fSmrg	  fi
91294642e01fSmrg	else
91304642e01fSmrg	  # Don't allow undefined symbols.
913135c4bbdfSmrg	  allow_undefined_flag=$no_undefined_flag
91324642e01fSmrg	fi
91334642e01fSmrg
91344642e01fSmrg      fi
91354642e01fSmrg
913635c4bbdfSmrg      func_generate_dlsyms "$libname" "$libname" :
913735c4bbdfSmrg      func_append libobjs " $symfileobj"
913835c4bbdfSmrg      test " " = "$libobjs" && libobjs=
91394642e01fSmrg
914035c4bbdfSmrg      if test relink != "$opt_mode"; then
91414642e01fSmrg	# Remove our outputs, but don't remove object files since they
91424642e01fSmrg	# may have been created when compiling PIC objects.
91434642e01fSmrg	removelist=
91444642e01fSmrg	tempremovelist=`$ECHO "$output_objdir/*"`
91454642e01fSmrg	for p in $tempremovelist; do
91464642e01fSmrg	  case $p in
91474642e01fSmrg	    *.$objext | *.gcno)
91484642e01fSmrg	       ;;
914935c4bbdfSmrg	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*)
915035c4bbdfSmrg	       if test -n "$precious_files_regex"; then
91514642e01fSmrg		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
91524642e01fSmrg		 then
91534642e01fSmrg		   continue
91544642e01fSmrg		 fi
91554642e01fSmrg	       fi
915635c4bbdfSmrg	       func_append removelist " $p"
91574642e01fSmrg	       ;;
91584642e01fSmrg	    *) ;;
91594642e01fSmrg	  esac
91604642e01fSmrg	done
91614642e01fSmrg	test -n "$removelist" && \
91624642e01fSmrg	  func_show_eval "${RM}r \$removelist"
91634642e01fSmrg      fi
91644642e01fSmrg
91654642e01fSmrg      # Now set the variables for building old libraries.
916635c4bbdfSmrg      if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then
916735c4bbdfSmrg	func_append oldlibs " $output_objdir/$libname.$libext"
91684642e01fSmrg
91694642e01fSmrg	# Transform .lo files to .o files.
917035c4bbdfSmrg	oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP`
91714642e01fSmrg      fi
91724642e01fSmrg
91734642e01fSmrg      # Eliminate all temporary directories.
91744642e01fSmrg      #for path in $notinst_path; do
91756747b715Smrg      #	lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
91766747b715Smrg      #	deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
91776747b715Smrg      #	dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
91784642e01fSmrg      #done
91794642e01fSmrg
91804642e01fSmrg      if test -n "$xrpath"; then
91814642e01fSmrg	# If the user specified any rpath flags, then add them.
91824642e01fSmrg	temp_xrpath=
91834642e01fSmrg	for libdir in $xrpath; do
918435c4bbdfSmrg	  func_replace_sysroot "$libdir"
918535c4bbdfSmrg	  func_append temp_xrpath " -R$func_replace_sysroot_result"
91864642e01fSmrg	  case "$finalize_rpath " in
91874642e01fSmrg	  *" $libdir "*) ;;
918835c4bbdfSmrg	  *) func_append finalize_rpath " $libdir" ;;
91894642e01fSmrg	  esac
91904642e01fSmrg	done
919135c4bbdfSmrg	if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then
91924642e01fSmrg	  dependency_libs="$temp_xrpath $dependency_libs"
91934642e01fSmrg	fi
91944642e01fSmrg      fi
91954642e01fSmrg
91964642e01fSmrg      # Make sure dlfiles contains only unique files that won't be dlpreopened
919735c4bbdfSmrg      old_dlfiles=$dlfiles
91984642e01fSmrg      dlfiles=
91994642e01fSmrg      for lib in $old_dlfiles; do
92004642e01fSmrg	case " $dlprefiles $dlfiles " in
92014642e01fSmrg	*" $lib "*) ;;
920235c4bbdfSmrg	*) func_append dlfiles " $lib" ;;
92034642e01fSmrg	esac
92044642e01fSmrg      done
92054642e01fSmrg
92064642e01fSmrg      # Make sure dlprefiles contains only unique files
920735c4bbdfSmrg      old_dlprefiles=$dlprefiles
92084642e01fSmrg      dlprefiles=
92094642e01fSmrg      for lib in $old_dlprefiles; do
92104642e01fSmrg	case "$dlprefiles " in
92114642e01fSmrg	*" $lib "*) ;;
921235c4bbdfSmrg	*) func_append dlprefiles " $lib" ;;
92134642e01fSmrg	esac
92144642e01fSmrg      done
92154642e01fSmrg
921635c4bbdfSmrg      if test yes = "$build_libtool_libs"; then
92174642e01fSmrg	if test -n "$rpath"; then
92184642e01fSmrg	  case $host in
92196747b715Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
92204642e01fSmrg	    # these systems don't actually have a c library (as such)!
92214642e01fSmrg	    ;;
92224642e01fSmrg	  *-*-rhapsody* | *-*-darwin1.[012])
92234642e01fSmrg	    # Rhapsody C library is in the System framework
922435c4bbdfSmrg	    func_append deplibs " System.ltframework"
92254642e01fSmrg	    ;;
92264642e01fSmrg	  *-*-netbsd*)
92274642e01fSmrg	    # Don't link with libc until the a.out ld.so is fixed.
92284642e01fSmrg	    ;;
92294642e01fSmrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
92304642e01fSmrg	    # Do not include libc due to us having libc/libc_r.
92314642e01fSmrg	    ;;
92324642e01fSmrg	  *-*-sco3.2v5* | *-*-sco5v6*)
92334642e01fSmrg	    # Causes problems with __ctype
92344642e01fSmrg	    ;;
92354642e01fSmrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
92364642e01fSmrg	    # Compiler inserts libc in the correct place for threads to work
92374642e01fSmrg	    ;;
92384642e01fSmrg	  *)
92394642e01fSmrg	    # Add libc to deplibs on all other systems if necessary.
924035c4bbdfSmrg	    if test yes = "$build_libtool_need_lc"; then
924135c4bbdfSmrg	      func_append deplibs " -lc"
92424642e01fSmrg	    fi
92434642e01fSmrg	    ;;
92444642e01fSmrg	  esac
92454642e01fSmrg	fi
92464642e01fSmrg
92474642e01fSmrg	# Transform deplibs into only deplibs that can be linked in shared.
92484642e01fSmrg	name_save=$name
92494642e01fSmrg	libname_save=$libname
92504642e01fSmrg	release_save=$release
92514642e01fSmrg	versuffix_save=$versuffix
92524642e01fSmrg	major_save=$major
92534642e01fSmrg	# I'm not sure if I'm treating the release correctly.  I think
92544642e01fSmrg	# release should show up in the -l (ie -lgmp5) so we don't want to
92554642e01fSmrg	# add it in twice.  Is that correct?
925635c4bbdfSmrg	release=
925735c4bbdfSmrg	versuffix=
925835c4bbdfSmrg	major=
92594642e01fSmrg	newdeplibs=
92604642e01fSmrg	droppeddeps=no
92614642e01fSmrg	case $deplibs_check_method in
92624642e01fSmrg	pass_all)
92634642e01fSmrg	  # Don't check for shared/static.  Everything works.
92644642e01fSmrg	  # This might be a little naive.  We might want to check
92654642e01fSmrg	  # whether the library exists or not.  But this is on
92664642e01fSmrg	  # osf3 & osf4 and I'm not really sure... Just
92674642e01fSmrg	  # implementing what was already the behavior.
92684642e01fSmrg	  newdeplibs=$deplibs
92694642e01fSmrg	  ;;
92704642e01fSmrg	test_compile)
92714642e01fSmrg	  # This code stresses the "libraries are programs" paradigm to its
92724642e01fSmrg	  # limits. Maybe even breaks it.  We compile a program, linking it
92734642e01fSmrg	  # against the deplibs as a proxy for the library.  Then we can check
92744642e01fSmrg	  # whether they linked in statically or dynamically with ldd.
92754642e01fSmrg	  $opt_dry_run || $RM conftest.c
92764642e01fSmrg	  cat > conftest.c <<EOF
92774642e01fSmrg	  int main() { return 0; }
92784642e01fSmrgEOF
92794642e01fSmrg	  $opt_dry_run || $RM conftest
92804642e01fSmrg	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
92814642e01fSmrg	    ldd_output=`ldd conftest`
92824642e01fSmrg	    for i in $deplibs; do
92834642e01fSmrg	      case $i in
92844642e01fSmrg	      -l*)
92854642e01fSmrg		func_stripname -l '' "$i"
92864642e01fSmrg		name=$func_stripname_result
928735c4bbdfSmrg		if test yes = "$allow_libtool_libs_with_static_runtimes"; then
92884642e01fSmrg		  case " $predeps $postdeps " in
92894642e01fSmrg		  *" $i "*)
929035c4bbdfSmrg		    func_append newdeplibs " $i"
929135c4bbdfSmrg		    i=
92924642e01fSmrg		    ;;
92934642e01fSmrg		  esac
92944642e01fSmrg		fi
929535c4bbdfSmrg		if test -n "$i"; then
92964642e01fSmrg		  libname=`eval "\\$ECHO \"$libname_spec\""`
92974642e01fSmrg		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
92984642e01fSmrg		  set dummy $deplib_matches; shift
92994642e01fSmrg		  deplib_match=$1
930035c4bbdfSmrg		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
930135c4bbdfSmrg		    func_append newdeplibs " $i"
93024642e01fSmrg		  else
93034642e01fSmrg		    droppeddeps=yes
93046747b715Smrg		    echo
93054642e01fSmrg		    $ECHO "*** Warning: dynamic linker does not accept needed library $i."
93066747b715Smrg		    echo "*** I have the capability to make that library automatically link in when"
93076747b715Smrg		    echo "*** you link to this library.  But I can only do this if you have a"
93086747b715Smrg		    echo "*** shared version of the library, which I believe you do not have"
93096747b715Smrg		    echo "*** because a test_compile did reveal that the linker did not use it for"
93106747b715Smrg		    echo "*** its dynamic dependency list that programs get resolved with at runtime."
93114642e01fSmrg		  fi
93124642e01fSmrg		fi
93134642e01fSmrg		;;
93144642e01fSmrg	      *)
931535c4bbdfSmrg		func_append newdeplibs " $i"
93164642e01fSmrg		;;
93174642e01fSmrg	      esac
93184642e01fSmrg	    done
93194642e01fSmrg	  else
93204642e01fSmrg	    # Error occurred in the first compile.  Let's try to salvage
93214642e01fSmrg	    # the situation: Compile a separate program for each library.
93224642e01fSmrg	    for i in $deplibs; do
93234642e01fSmrg	      case $i in
93244642e01fSmrg	      -l*)
93254642e01fSmrg		func_stripname -l '' "$i"
93264642e01fSmrg		name=$func_stripname_result
93274642e01fSmrg		$opt_dry_run || $RM conftest
93284642e01fSmrg		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
93294642e01fSmrg		  ldd_output=`ldd conftest`
933035c4bbdfSmrg		  if test yes = "$allow_libtool_libs_with_static_runtimes"; then
93314642e01fSmrg		    case " $predeps $postdeps " in
93324642e01fSmrg		    *" $i "*)
933335c4bbdfSmrg		      func_append newdeplibs " $i"
933435c4bbdfSmrg		      i=
93354642e01fSmrg		      ;;
93364642e01fSmrg		    esac
93374642e01fSmrg		  fi
933835c4bbdfSmrg		  if test -n "$i"; then
93394642e01fSmrg		    libname=`eval "\\$ECHO \"$libname_spec\""`
93404642e01fSmrg		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
93414642e01fSmrg		    set dummy $deplib_matches; shift
93424642e01fSmrg		    deplib_match=$1
934335c4bbdfSmrg		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
934435c4bbdfSmrg		      func_append newdeplibs " $i"
93454642e01fSmrg		    else
93464642e01fSmrg		      droppeddeps=yes
93476747b715Smrg		      echo
93484642e01fSmrg		      $ECHO "*** Warning: dynamic linker does not accept needed library $i."
93496747b715Smrg		      echo "*** I have the capability to make that library automatically link in when"
93506747b715Smrg		      echo "*** you link to this library.  But I can only do this if you have a"
93516747b715Smrg		      echo "*** shared version of the library, which you do not appear to have"
93526747b715Smrg		      echo "*** because a test_compile did reveal that the linker did not use this one"
93536747b715Smrg		      echo "*** as a dynamic dependency that programs can get resolved with at runtime."
93544642e01fSmrg		    fi
93554642e01fSmrg		  fi
93564642e01fSmrg		else
93574642e01fSmrg		  droppeddeps=yes
93586747b715Smrg		  echo
93594642e01fSmrg		  $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
93606747b715Smrg		  echo "*** make it link in!  You will probably need to install it or some"
93616747b715Smrg		  echo "*** library that it depends on before this library will be fully"
93626747b715Smrg		  echo "*** functional.  Installing it before continuing would be even better."
93634642e01fSmrg		fi
93644642e01fSmrg		;;
93654642e01fSmrg	      *)
936635c4bbdfSmrg		func_append newdeplibs " $i"
93674642e01fSmrg		;;
93684642e01fSmrg	      esac
93694642e01fSmrg	    done
93704642e01fSmrg	  fi
93714642e01fSmrg	  ;;
93724642e01fSmrg	file_magic*)
93734642e01fSmrg	  set dummy $deplibs_check_method; shift
93744642e01fSmrg	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
93754642e01fSmrg	  for a_deplib in $deplibs; do
93764642e01fSmrg	    case $a_deplib in
93774642e01fSmrg	    -l*)
93784642e01fSmrg	      func_stripname -l '' "$a_deplib"
93794642e01fSmrg	      name=$func_stripname_result
938035c4bbdfSmrg	      if test yes = "$allow_libtool_libs_with_static_runtimes"; then
93814642e01fSmrg		case " $predeps $postdeps " in
93824642e01fSmrg		*" $a_deplib "*)
938335c4bbdfSmrg		  func_append newdeplibs " $a_deplib"
938435c4bbdfSmrg		  a_deplib=
93854642e01fSmrg		  ;;
93864642e01fSmrg		esac
93874642e01fSmrg	      fi
938835c4bbdfSmrg	      if test -n "$a_deplib"; then
93894642e01fSmrg		libname=`eval "\\$ECHO \"$libname_spec\""`
939035c4bbdfSmrg		if test -n "$file_magic_glob"; then
939135c4bbdfSmrg		  libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
939235c4bbdfSmrg		else
939335c4bbdfSmrg		  libnameglob=$libname
939435c4bbdfSmrg		fi
939535c4bbdfSmrg		test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob`
93964642e01fSmrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
939735c4bbdfSmrg		  if test yes = "$want_nocaseglob"; then
939835c4bbdfSmrg		    shopt -s nocaseglob
939935c4bbdfSmrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
940035c4bbdfSmrg		    $nocaseglob
940135c4bbdfSmrg		  else
940235c4bbdfSmrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
940335c4bbdfSmrg		  fi
94044642e01fSmrg		  for potent_lib in $potential_libs; do
94054642e01fSmrg		      # Follow soft links.
94064642e01fSmrg		      if ls -lLd "$potent_lib" 2>/dev/null |
94074642e01fSmrg			 $GREP " -> " >/dev/null; then
94084642e01fSmrg			continue
94094642e01fSmrg		      fi
94104642e01fSmrg		      # The statement above tries to avoid entering an
94114642e01fSmrg		      # endless loop below, in case of cyclic links.
94124642e01fSmrg		      # We might still enter an endless loop, since a link
94134642e01fSmrg		      # loop can be closed while we follow links,
94144642e01fSmrg		      # but so what?
941535c4bbdfSmrg		      potlib=$potent_lib
94164642e01fSmrg		      while test -h "$potlib" 2>/dev/null; do
941735c4bbdfSmrg			potliblink=`ls -ld $potlib | $SED 's/.* -> //'`
94184642e01fSmrg			case $potliblink in
941935c4bbdfSmrg			[\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;;
942035c4bbdfSmrg			*) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";;
94214642e01fSmrg			esac
94224642e01fSmrg		      done
94234642e01fSmrg		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
94244642e01fSmrg			 $SED -e 10q |
94254642e01fSmrg			 $EGREP "$file_magic_regex" > /dev/null; then
942635c4bbdfSmrg			func_append newdeplibs " $a_deplib"
942735c4bbdfSmrg			a_deplib=
94284642e01fSmrg			break 2
94294642e01fSmrg		      fi
94304642e01fSmrg		  done
94314642e01fSmrg		done
94324642e01fSmrg	      fi
943335c4bbdfSmrg	      if test -n "$a_deplib"; then
94344642e01fSmrg		droppeddeps=yes
94356747b715Smrg		echo
94364642e01fSmrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
94376747b715Smrg		echo "*** I have the capability to make that library automatically link in when"
94386747b715Smrg		echo "*** you link to this library.  But I can only do this if you have a"
94396747b715Smrg		echo "*** shared version of the library, which you do not appear to have"
94406747b715Smrg		echo "*** because I did check the linker path looking for a file starting"
944135c4bbdfSmrg		if test -z "$potlib"; then
94424642e01fSmrg		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
94434642e01fSmrg		else
94444642e01fSmrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
94454642e01fSmrg		  $ECHO "*** using a file magic. Last file checked: $potlib"
94464642e01fSmrg		fi
94474642e01fSmrg	      fi
94484642e01fSmrg	      ;;
94494642e01fSmrg	    *)
94504642e01fSmrg	      # Add a -L argument.
945135c4bbdfSmrg	      func_append newdeplibs " $a_deplib"
94524642e01fSmrg	      ;;
94534642e01fSmrg	    esac
94544642e01fSmrg	  done # Gone through all deplibs.
94554642e01fSmrg	  ;;
94564642e01fSmrg	match_pattern*)
94574642e01fSmrg	  set dummy $deplibs_check_method; shift
94584642e01fSmrg	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
94594642e01fSmrg	  for a_deplib in $deplibs; do
94604642e01fSmrg	    case $a_deplib in
94614642e01fSmrg	    -l*)
94624642e01fSmrg	      func_stripname -l '' "$a_deplib"
94634642e01fSmrg	      name=$func_stripname_result
946435c4bbdfSmrg	      if test yes = "$allow_libtool_libs_with_static_runtimes"; then
94654642e01fSmrg		case " $predeps $postdeps " in
94664642e01fSmrg		*" $a_deplib "*)
946735c4bbdfSmrg		  func_append newdeplibs " $a_deplib"
946835c4bbdfSmrg		  a_deplib=
94694642e01fSmrg		  ;;
94704642e01fSmrg		esac
94714642e01fSmrg	      fi
947235c4bbdfSmrg	      if test -n "$a_deplib"; then
94734642e01fSmrg		libname=`eval "\\$ECHO \"$libname_spec\""`
94744642e01fSmrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
94754642e01fSmrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
94764642e01fSmrg		  for potent_lib in $potential_libs; do
947735c4bbdfSmrg		    potlib=$potent_lib # see symlink-check above in file_magic test
94786747b715Smrg		    if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
94794642e01fSmrg		       $EGREP "$match_pattern_regex" > /dev/null; then
948035c4bbdfSmrg		      func_append newdeplibs " $a_deplib"
948135c4bbdfSmrg		      a_deplib=
94824642e01fSmrg		      break 2
94834642e01fSmrg		    fi
94844642e01fSmrg		  done
94854642e01fSmrg		done
94864642e01fSmrg	      fi
948735c4bbdfSmrg	      if test -n "$a_deplib"; then
94884642e01fSmrg		droppeddeps=yes
94896747b715Smrg		echo
94904642e01fSmrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
94916747b715Smrg		echo "*** I have the capability to make that library automatically link in when"
94926747b715Smrg		echo "*** you link to this library.  But I can only do this if you have a"
94936747b715Smrg		echo "*** shared version of the library, which you do not appear to have"
94946747b715Smrg		echo "*** because I did check the linker path looking for a file starting"
949535c4bbdfSmrg		if test -z "$potlib"; then
94964642e01fSmrg		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
94974642e01fSmrg		else
94984642e01fSmrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
94994642e01fSmrg		  $ECHO "*** using a regex pattern. Last file checked: $potlib"
95004642e01fSmrg		fi
95014642e01fSmrg	      fi
95024642e01fSmrg	      ;;
95034642e01fSmrg	    *)
95044642e01fSmrg	      # Add a -L argument.
950535c4bbdfSmrg	      func_append newdeplibs " $a_deplib"
95064642e01fSmrg	      ;;
95074642e01fSmrg	    esac
95084642e01fSmrg	  done # Gone through all deplibs.
95094642e01fSmrg	  ;;
95104642e01fSmrg	none | unknown | *)
951135c4bbdfSmrg	  newdeplibs=
95126747b715Smrg	  tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
951335c4bbdfSmrg	  if test yes = "$allow_libtool_libs_with_static_runtimes"; then
951435c4bbdfSmrg	    for i in $predeps $postdeps; do
95154642e01fSmrg	      # can't use Xsed below, because $i might contain '/'
951635c4bbdfSmrg	      tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"`
95174642e01fSmrg	    done
95184642e01fSmrg	  fi
95196747b715Smrg	  case $tmp_deplibs in
95206747b715Smrg	  *[!\	\ ]*)
95216747b715Smrg	    echo
952235c4bbdfSmrg	    if test none = "$deplibs_check_method"; then
95236747b715Smrg	      echo "*** Warning: inter-library dependencies are not supported in this platform."
95244642e01fSmrg	    else
95256747b715Smrg	      echo "*** Warning: inter-library dependencies are not known to be supported."
95264642e01fSmrg	    fi
95276747b715Smrg	    echo "*** All declared inter-library dependencies are being dropped."
95284642e01fSmrg	    droppeddeps=yes
95296747b715Smrg	    ;;
95306747b715Smrg	  esac
95314642e01fSmrg	  ;;
95324642e01fSmrg	esac
95334642e01fSmrg	versuffix=$versuffix_save
95344642e01fSmrg	major=$major_save
95354642e01fSmrg	release=$release_save
95364642e01fSmrg	libname=$libname_save
95374642e01fSmrg	name=$name_save
95384642e01fSmrg
95394642e01fSmrg	case $host in
95404642e01fSmrg	*-*-rhapsody* | *-*-darwin1.[012])
95414642e01fSmrg	  # On Rhapsody replace the C library with the System framework
95426747b715Smrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
95434642e01fSmrg	  ;;
95444642e01fSmrg	esac
95454642e01fSmrg
954635c4bbdfSmrg	if test yes = "$droppeddeps"; then
954735c4bbdfSmrg	  if test yes = "$module"; then
95486747b715Smrg	    echo
95496747b715Smrg	    echo "*** Warning: libtool could not satisfy all declared inter-library"
95504642e01fSmrg	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
95516747b715Smrg	    echo "*** a static module, that should work as long as the dlopening"
95526747b715Smrg	    echo "*** application is linked with the -dlopen flag."
95534642e01fSmrg	    if test -z "$global_symbol_pipe"; then
95546747b715Smrg	      echo
95556747b715Smrg	      echo "*** However, this would only work if libtool was able to extract symbol"
955635c4bbdfSmrg	      echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
95576747b715Smrg	      echo "*** not find such a program.  So, this module is probably useless."
955835c4bbdfSmrg	      echo "*** 'nm' from GNU binutils and a full rebuild may help."
95594642e01fSmrg	    fi
956035c4bbdfSmrg	    if test no = "$build_old_libs"; then
956135c4bbdfSmrg	      oldlibs=$output_objdir/$libname.$libext
95624642e01fSmrg	      build_libtool_libs=module
95634642e01fSmrg	      build_old_libs=yes
95644642e01fSmrg	    else
95654642e01fSmrg	      build_libtool_libs=no
95664642e01fSmrg	    fi
95674642e01fSmrg	  else
95686747b715Smrg	    echo "*** The inter-library dependencies that have been dropped here will be"
95696747b715Smrg	    echo "*** automatically added whenever a program is linked with this library"
95706747b715Smrg	    echo "*** or is declared to -dlopen it."
95714642e01fSmrg
957235c4bbdfSmrg	    if test no = "$allow_undefined"; then
95736747b715Smrg	      echo
95746747b715Smrg	      echo "*** Since this library must not contain undefined symbols,"
95756747b715Smrg	      echo "*** because either the platform does not support them or"
95766747b715Smrg	      echo "*** it was explicitly requested with -no-undefined,"
95776747b715Smrg	      echo "*** libtool will only create a static version of it."
957835c4bbdfSmrg	      if test no = "$build_old_libs"; then
957935c4bbdfSmrg		oldlibs=$output_objdir/$libname.$libext
95804642e01fSmrg		build_libtool_libs=module
95814642e01fSmrg		build_old_libs=yes
95824642e01fSmrg	      else
95834642e01fSmrg		build_libtool_libs=no
95844642e01fSmrg	      fi
95854642e01fSmrg	    fi
95864642e01fSmrg	  fi
95874642e01fSmrg	fi
95884642e01fSmrg	# Done checking deplibs!
95894642e01fSmrg	deplibs=$newdeplibs
95904642e01fSmrg      fi
95914642e01fSmrg      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
95924642e01fSmrg      case $host in
95934642e01fSmrg	*-*-darwin*)
95946747b715Smrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
95956747b715Smrg	  new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
95966747b715Smrg	  deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
95974642e01fSmrg	  ;;
95984642e01fSmrg      esac
95994642e01fSmrg
96004642e01fSmrg      # move library search paths that coincide with paths to not yet
96014642e01fSmrg      # installed libraries to the beginning of the library search list
96024642e01fSmrg      new_libs=
96034642e01fSmrg      for path in $notinst_path; do
96044642e01fSmrg	case " $new_libs " in
96054642e01fSmrg	*" -L$path/$objdir "*) ;;
96064642e01fSmrg	*)
96074642e01fSmrg	  case " $deplibs " in
96084642e01fSmrg	  *" -L$path/$objdir "*)
960935c4bbdfSmrg	    func_append new_libs " -L$path/$objdir" ;;
96104642e01fSmrg	  esac
96114642e01fSmrg	  ;;
96124642e01fSmrg	esac
96134642e01fSmrg      done
96144642e01fSmrg      for deplib in $deplibs; do
96154642e01fSmrg	case $deplib in
96164642e01fSmrg	-L*)
96174642e01fSmrg	  case " $new_libs " in
96184642e01fSmrg	  *" $deplib "*) ;;
961935c4bbdfSmrg	  *) func_append new_libs " $deplib" ;;
96204642e01fSmrg	  esac
96214642e01fSmrg	  ;;
962235c4bbdfSmrg	*) func_append new_libs " $deplib" ;;
96234642e01fSmrg	esac
96244642e01fSmrg      done
962535c4bbdfSmrg      deplibs=$new_libs
96264642e01fSmrg
96274642e01fSmrg      # All the library-specific variables (install_libdir is set above).
96284642e01fSmrg      library_names=
96294642e01fSmrg      old_library=
96304642e01fSmrg      dlname=
96314642e01fSmrg
96324642e01fSmrg      # Test again, we may have decided not to build it any more
963335c4bbdfSmrg      if test yes = "$build_libtool_libs"; then
963435c4bbdfSmrg	# Remove $wl instances when linking with ld.
963535c4bbdfSmrg	# FIXME: should test the right _cmds variable.
963635c4bbdfSmrg	case $archive_cmds in
963735c4bbdfSmrg	  *\$LD\ *) wl= ;;
963835c4bbdfSmrg        esac
963935c4bbdfSmrg	if test yes = "$hardcode_into_libs"; then
96404642e01fSmrg	  # Hardcode the library paths
96414642e01fSmrg	  hardcode_libdirs=
96424642e01fSmrg	  dep_rpath=
964335c4bbdfSmrg	  rpath=$finalize_rpath
964435c4bbdfSmrg	  test relink = "$opt_mode" || rpath=$compile_rpath$rpath
96454642e01fSmrg	  for libdir in $rpath; do
96464642e01fSmrg	    if test -n "$hardcode_libdir_flag_spec"; then
96474642e01fSmrg	      if test -n "$hardcode_libdir_separator"; then
964835c4bbdfSmrg		func_replace_sysroot "$libdir"
964935c4bbdfSmrg		libdir=$func_replace_sysroot_result
96504642e01fSmrg		if test -z "$hardcode_libdirs"; then
965135c4bbdfSmrg		  hardcode_libdirs=$libdir
96524642e01fSmrg		else
96534642e01fSmrg		  # Just accumulate the unique libdirs.
96544642e01fSmrg		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
96554642e01fSmrg		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
96564642e01fSmrg		    ;;
96574642e01fSmrg		  *)
965835c4bbdfSmrg		    func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
96594642e01fSmrg		    ;;
96604642e01fSmrg		  esac
96614642e01fSmrg		fi
96624642e01fSmrg	      else
96634642e01fSmrg		eval flag=\"$hardcode_libdir_flag_spec\"
966435c4bbdfSmrg		func_append dep_rpath " $flag"
96654642e01fSmrg	      fi
96664642e01fSmrg	    elif test -n "$runpath_var"; then
96674642e01fSmrg	      case "$perm_rpath " in
96684642e01fSmrg	      *" $libdir "*) ;;
966935c4bbdfSmrg	      *) func_append perm_rpath " $libdir" ;;
96704642e01fSmrg	      esac
96714642e01fSmrg	    fi
96724642e01fSmrg	  done
96734642e01fSmrg	  # Substitute the hardcoded libdirs into the rpath.
96744642e01fSmrg	  if test -n "$hardcode_libdir_separator" &&
96754642e01fSmrg	     test -n "$hardcode_libdirs"; then
967635c4bbdfSmrg	    libdir=$hardcode_libdirs
967735c4bbdfSmrg	    eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
96784642e01fSmrg	  fi
96794642e01fSmrg	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
96804642e01fSmrg	    # We should set the runpath_var.
96814642e01fSmrg	    rpath=
96824642e01fSmrg	    for dir in $perm_rpath; do
968335c4bbdfSmrg	      func_append rpath "$dir:"
96844642e01fSmrg	    done
96854642e01fSmrg	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
96864642e01fSmrg	  fi
96874642e01fSmrg	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
96884642e01fSmrg	fi
968905b261ecSmrg
969035c4bbdfSmrg	shlibpath=$finalize_shlibpath
969135c4bbdfSmrg	test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath
96924642e01fSmrg	if test -n "$shlibpath"; then
96934642e01fSmrg	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
96944642e01fSmrg	fi
969505b261ecSmrg
96964642e01fSmrg	# Get the real and link names of the library.
96974642e01fSmrg	eval shared_ext=\"$shrext_cmds\"
96984642e01fSmrg	eval library_names=\"$library_names_spec\"
96994642e01fSmrg	set dummy $library_names
97004642e01fSmrg	shift
970135c4bbdfSmrg	realname=$1
97024642e01fSmrg	shift
970305b261ecSmrg
97044642e01fSmrg	if test -n "$soname_spec"; then
97054642e01fSmrg	  eval soname=\"$soname_spec\"
97064642e01fSmrg	else
970735c4bbdfSmrg	  soname=$realname
97084642e01fSmrg	fi
97094642e01fSmrg	if test -z "$dlname"; then
97104642e01fSmrg	  dlname=$soname
97114642e01fSmrg	fi
971205b261ecSmrg
971335c4bbdfSmrg	lib=$output_objdir/$realname
97144642e01fSmrg	linknames=
97154642e01fSmrg	for link
97164642e01fSmrg	do
971735c4bbdfSmrg	  func_append linknames " $link"
97184642e01fSmrg	done
971905b261ecSmrg
97204642e01fSmrg	# Use standard objects if they are pic
97216747b715Smrg	test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
97224642e01fSmrg	test "X$libobjs" = "X " && libobjs=
972305b261ecSmrg
97244642e01fSmrg	delfiles=
97254642e01fSmrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
97264642e01fSmrg	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
972735c4bbdfSmrg	  export_symbols=$output_objdir/$libname.uexp
972835c4bbdfSmrg	  func_append delfiles " $export_symbols"
97294642e01fSmrg	fi
973005b261ecSmrg
97314642e01fSmrg	orig_export_symbols=
97324642e01fSmrg	case $host_os in
97334642e01fSmrg	cygwin* | mingw* | cegcc*)
97344642e01fSmrg	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
97354642e01fSmrg	    # exporting using user supplied symfile
973635c4bbdfSmrg	    func_dll_def_p "$export_symbols" || {
97374642e01fSmrg	      # and it's NOT already a .def file. Must figure out
97384642e01fSmrg	      # which of the given symbols are data symbols and tag
97394642e01fSmrg	      # them as such. So, trigger use of export_symbols_cmds.
97404642e01fSmrg	      # export_symbols gets reassigned inside the "prepare
97414642e01fSmrg	      # the list of exported symbols" if statement, so the
97424642e01fSmrg	      # include_expsyms logic still works.
974335c4bbdfSmrg	      orig_export_symbols=$export_symbols
97444642e01fSmrg	      export_symbols=
97454642e01fSmrg	      always_export_symbols=yes
974635c4bbdfSmrg	    }
97474642e01fSmrg	  fi
97484642e01fSmrg	  ;;
97494642e01fSmrg	esac
975005b261ecSmrg
97514642e01fSmrg	# Prepare the list of exported symbols
97524642e01fSmrg	if test -z "$export_symbols"; then
975335c4bbdfSmrg	  if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then
975435c4bbdfSmrg	    func_verbose "generating symbol list for '$libname.la'"
975535c4bbdfSmrg	    export_symbols=$output_objdir/$libname.exp
97564642e01fSmrg	    $opt_dry_run || $RM $export_symbols
97574642e01fSmrg	    cmds=$export_symbols_cmds
975835c4bbdfSmrg	    save_ifs=$IFS; IFS='~'
975935c4bbdfSmrg	    for cmd1 in $cmds; do
976035c4bbdfSmrg	      IFS=$save_ifs
976135c4bbdfSmrg	      # Take the normal branch if the nm_file_list_spec branch
976235c4bbdfSmrg	      # doesn't work or if tool conversion is not needed.
976335c4bbdfSmrg	      case $nm_file_list_spec~$to_tool_file_cmd in
976435c4bbdfSmrg		*~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
976535c4bbdfSmrg		  try_normal_branch=yes
976635c4bbdfSmrg		  eval cmd=\"$cmd1\"
976735c4bbdfSmrg		  func_len " $cmd"
976835c4bbdfSmrg		  len=$func_len_result
976935c4bbdfSmrg		  ;;
977035c4bbdfSmrg		*)
977135c4bbdfSmrg		  try_normal_branch=no
977235c4bbdfSmrg		  ;;
977335c4bbdfSmrg	      esac
977435c4bbdfSmrg	      if test yes = "$try_normal_branch" \
977535c4bbdfSmrg		 && { test "$len" -lt "$max_cmd_len" \
977635c4bbdfSmrg		      || test "$max_cmd_len" -le -1; }
977735c4bbdfSmrg	      then
977835c4bbdfSmrg		func_show_eval "$cmd" 'exit $?'
977935c4bbdfSmrg		skipped_export=false
978035c4bbdfSmrg	      elif test -n "$nm_file_list_spec"; then
978135c4bbdfSmrg		func_basename "$output"
978235c4bbdfSmrg		output_la=$func_basename_result
978335c4bbdfSmrg		save_libobjs=$libobjs
978435c4bbdfSmrg		save_output=$output
978535c4bbdfSmrg		output=$output_objdir/$output_la.nm
978635c4bbdfSmrg		func_to_tool_file "$output"
978735c4bbdfSmrg		libobjs=$nm_file_list_spec$func_to_tool_file_result
978835c4bbdfSmrg		func_append delfiles " $output"
978935c4bbdfSmrg		func_verbose "creating $NM input file list: $output"
979035c4bbdfSmrg		for obj in $save_libobjs; do
979135c4bbdfSmrg		  func_to_tool_file "$obj"
979235c4bbdfSmrg		  $ECHO "$func_to_tool_file_result"
979335c4bbdfSmrg		done > "$output"
979435c4bbdfSmrg		eval cmd=\"$cmd1\"
97954642e01fSmrg		func_show_eval "$cmd" 'exit $?'
979635c4bbdfSmrg		output=$save_output
979735c4bbdfSmrg		libobjs=$save_libobjs
97984642e01fSmrg		skipped_export=false
97994642e01fSmrg	      else
98004642e01fSmrg		# The command line is too long to execute in one step.
98014642e01fSmrg		func_verbose "using reloadable object file for export list..."
98024642e01fSmrg		skipped_export=:
98034642e01fSmrg		# Break out early, otherwise skipped_export may be
98044642e01fSmrg		# set to false by a later but shorter cmd.
98054642e01fSmrg		break
98064642e01fSmrg	      fi
98074642e01fSmrg	    done
980835c4bbdfSmrg	    IFS=$save_ifs
980935c4bbdfSmrg	    if test -n "$export_symbols_regex" && test : != "$skipped_export"; then
98104642e01fSmrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
98114642e01fSmrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
98124642e01fSmrg	    fi
98134642e01fSmrg	  fi
981405b261ecSmrg	fi
981505b261ecSmrg
98164642e01fSmrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
981735c4bbdfSmrg	  tmp_export_symbols=$export_symbols
981835c4bbdfSmrg	  test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
98196747b715Smrg	  $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
98204642e01fSmrg	fi
982105b261ecSmrg
982235c4bbdfSmrg	if test : != "$skipped_export" && test -n "$orig_export_symbols"; then
98234642e01fSmrg	  # The given exports_symbols file has to be filtered, so filter it.
982435c4bbdfSmrg	  func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
98254642e01fSmrg	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
982635c4bbdfSmrg	  # 's' commands, which not all seds can handle. GNU sed should be fine
98274642e01fSmrg	  # though. Also, the filter scales superlinearly with the number of
98284642e01fSmrg	  # global variables. join(1) would be nice here, but unfortunately
98294642e01fSmrg	  # isn't a blessed tool.
98304642e01fSmrg	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
983135c4bbdfSmrg	  func_append delfiles " $export_symbols $output_objdir/$libname.filter"
98324642e01fSmrg	  export_symbols=$output_objdir/$libname.def
98334642e01fSmrg	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
98344642e01fSmrg	fi
983505b261ecSmrg
98364642e01fSmrg	tmp_deplibs=
98374642e01fSmrg	for test_deplib in $deplibs; do
98384642e01fSmrg	  case " $convenience " in
98394642e01fSmrg	  *" $test_deplib "*) ;;
98404642e01fSmrg	  *)
984135c4bbdfSmrg	    func_append tmp_deplibs " $test_deplib"
98424642e01fSmrg	    ;;
98434642e01fSmrg	  esac
98444642e01fSmrg	done
984535c4bbdfSmrg	deplibs=$tmp_deplibs
984605b261ecSmrg
98474642e01fSmrg	if test -n "$convenience"; then
98484642e01fSmrg	  if test -n "$whole_archive_flag_spec" &&
984935c4bbdfSmrg	    test yes = "$compiler_needs_object" &&
98504642e01fSmrg	    test -z "$libobjs"; then
98514642e01fSmrg	    # extract the archives, so we have objects to list.
98524642e01fSmrg	    # TODO: could optimize this to just extract one archive.
98534642e01fSmrg	    whole_archive_flag_spec=
98544642e01fSmrg	  fi
98554642e01fSmrg	  if test -n "$whole_archive_flag_spec"; then
98564642e01fSmrg	    save_libobjs=$libobjs
98574642e01fSmrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
98584642e01fSmrg	    test "X$libobjs" = "X " && libobjs=
98594642e01fSmrg	  else
986035c4bbdfSmrg	    gentop=$output_objdir/${outputname}x
986135c4bbdfSmrg	    func_append generated " $gentop"
986205b261ecSmrg
98634642e01fSmrg	    func_extract_archives $gentop $convenience
986435c4bbdfSmrg	    func_append libobjs " $func_extract_archives_result"
98654642e01fSmrg	    test "X$libobjs" = "X " && libobjs=
98664642e01fSmrg	  fi
986705b261ecSmrg	fi
986805b261ecSmrg
986935c4bbdfSmrg	if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then
98704642e01fSmrg	  eval flag=\"$thread_safe_flag_spec\"
987135c4bbdfSmrg	  func_append linker_flags " $flag"
987205b261ecSmrg	fi
987305b261ecSmrg
98744642e01fSmrg	# Make a backup of the uninstalled library when relinking
987535c4bbdfSmrg	if test relink = "$opt_mode"; then
98764642e01fSmrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
98774642e01fSmrg	fi
987805b261ecSmrg
98794642e01fSmrg	# Do each of the archive commands.
988035c4bbdfSmrg	if test yes = "$module" && test -n "$module_cmds"; then
98814642e01fSmrg	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
98824642e01fSmrg	    eval test_cmds=\"$module_expsym_cmds\"
98834642e01fSmrg	    cmds=$module_expsym_cmds
98844642e01fSmrg	  else
98854642e01fSmrg	    eval test_cmds=\"$module_cmds\"
98864642e01fSmrg	    cmds=$module_cmds
98874642e01fSmrg	  fi
988805b261ecSmrg	else
98894642e01fSmrg	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
98904642e01fSmrg	    eval test_cmds=\"$archive_expsym_cmds\"
98914642e01fSmrg	    cmds=$archive_expsym_cmds
98924642e01fSmrg	  else
98934642e01fSmrg	    eval test_cmds=\"$archive_cmds\"
98944642e01fSmrg	    cmds=$archive_cmds
98954642e01fSmrg	  fi
989605b261ecSmrg	fi
989705b261ecSmrg
989835c4bbdfSmrg	if test : != "$skipped_export" &&
98994642e01fSmrg	   func_len " $test_cmds" &&
99004642e01fSmrg	   len=$func_len_result &&
99014642e01fSmrg	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
99024642e01fSmrg	  :
99034642e01fSmrg	else
99044642e01fSmrg	  # The command line is too long to link in one step, link piecewise
99054642e01fSmrg	  # or, if using GNU ld and skipped_export is not :, use a linker
99064642e01fSmrg	  # script.
990705b261ecSmrg
99084642e01fSmrg	  # Save the value of $output and $libobjs because we want to
99094642e01fSmrg	  # use them later.  If we have whole_archive_flag_spec, we
99104642e01fSmrg	  # want to use save_libobjs as it was before
99114642e01fSmrg	  # whole_archive_flag_spec was expanded, because we can't
99124642e01fSmrg	  # assume the linker understands whole_archive_flag_spec.
99134642e01fSmrg	  # This may have to be revisited, in case too many
99144642e01fSmrg	  # convenience libraries get linked in and end up exceeding
99154642e01fSmrg	  # the spec.
99164642e01fSmrg	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
99174642e01fSmrg	    save_libobjs=$libobjs
99184642e01fSmrg	  fi
99194642e01fSmrg	  save_output=$output
99206747b715Smrg	  func_basename "$output"
99216747b715Smrg	  output_la=$func_basename_result
992205b261ecSmrg
99234642e01fSmrg	  # Clear the reloadable object creation command queue and
99244642e01fSmrg	  # initialize k to one.
99254642e01fSmrg	  test_cmds=
99264642e01fSmrg	  concat_cmds=
99274642e01fSmrg	  objlist=
99284642e01fSmrg	  last_robj=
99294642e01fSmrg	  k=1
99304642e01fSmrg
993135c4bbdfSmrg	  if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then
993235c4bbdfSmrg	    output=$output_objdir/$output_la.lnkscript
99334642e01fSmrg	    func_verbose "creating GNU ld script: $output"
99346747b715Smrg	    echo 'INPUT (' > $output
99354642e01fSmrg	    for obj in $save_libobjs
993605b261ecSmrg	    do
993735c4bbdfSmrg	      func_to_tool_file "$obj"
993835c4bbdfSmrg	      $ECHO "$func_to_tool_file_result" >> $output
99394642e01fSmrg	    done
99406747b715Smrg	    echo ')' >> $output
994135c4bbdfSmrg	    func_append delfiles " $output"
994235c4bbdfSmrg	    func_to_tool_file "$output"
994335c4bbdfSmrg	    output=$func_to_tool_file_result
994435c4bbdfSmrg	  elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then
994535c4bbdfSmrg	    output=$output_objdir/$output_la.lnk
99464642e01fSmrg	    func_verbose "creating linker input file list: $output"
99474642e01fSmrg	    : > $output
99484642e01fSmrg	    set x $save_libobjs
99494642e01fSmrg	    shift
99504642e01fSmrg	    firstobj=
995135c4bbdfSmrg	    if test yes = "$compiler_needs_object"; then
99524642e01fSmrg	      firstobj="$1 "
99534642e01fSmrg	      shift
99544642e01fSmrg	    fi
99554642e01fSmrg	    for obj
99564642e01fSmrg	    do
995735c4bbdfSmrg	      func_to_tool_file "$obj"
995835c4bbdfSmrg	      $ECHO "$func_to_tool_file_result" >> $output
99594642e01fSmrg	    done
996035c4bbdfSmrg	    func_append delfiles " $output"
996135c4bbdfSmrg	    func_to_tool_file "$output"
996235c4bbdfSmrg	    output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
99634642e01fSmrg	  else
99644642e01fSmrg	    if test -n "$save_libobjs"; then
99654642e01fSmrg	      func_verbose "creating reloadable object files..."
996635c4bbdfSmrg	      output=$output_objdir/$output_la-$k.$objext
99674642e01fSmrg	      eval test_cmds=\"$reload_cmds\"
99684642e01fSmrg	      func_len " $test_cmds"
99694642e01fSmrg	      len0=$func_len_result
99704642e01fSmrg	      len=$len0
99714642e01fSmrg
99724642e01fSmrg	      # Loop over the list of objects to be linked.
99734642e01fSmrg	      for obj in $save_libobjs
99744642e01fSmrg	      do
99754642e01fSmrg		func_len " $obj"
99764642e01fSmrg		func_arith $len + $func_len_result
99774642e01fSmrg		len=$func_arith_result
997835c4bbdfSmrg		if test -z "$objlist" ||
99794642e01fSmrg		   test "$len" -lt "$max_cmd_len"; then
99804642e01fSmrg		  func_append objlist " $obj"
99814642e01fSmrg		else
99824642e01fSmrg		  # The command $test_cmds is almost too long, add a
99834642e01fSmrg		  # command to the queue.
998435c4bbdfSmrg		  if test 1 -eq "$k"; then
99854642e01fSmrg		    # The first file doesn't have a previous command to add.
99866747b715Smrg		    reload_objs=$objlist
99876747b715Smrg		    eval concat_cmds=\"$reload_cmds\"
99884642e01fSmrg		  else
99894642e01fSmrg		    # All subsequent reloadable object files will link in
99904642e01fSmrg		    # the last one created.
99916747b715Smrg		    reload_objs="$objlist $last_robj"
99926747b715Smrg		    eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
99934642e01fSmrg		  fi
999435c4bbdfSmrg		  last_robj=$output_objdir/$output_la-$k.$objext
99954642e01fSmrg		  func_arith $k + 1
99964642e01fSmrg		  k=$func_arith_result
999735c4bbdfSmrg		  output=$output_objdir/$output_la-$k.$objext
99986747b715Smrg		  objlist=" $obj"
99994642e01fSmrg		  func_len " $last_robj"
100004642e01fSmrg		  func_arith $len0 + $func_len_result
100014642e01fSmrg		  len=$func_arith_result
100024642e01fSmrg		fi
100034642e01fSmrg	      done
100044642e01fSmrg	      # Handle the remaining objects by creating one last
100054642e01fSmrg	      # reloadable object file.  All subsequent reloadable object
100064642e01fSmrg	      # files will link in the last one created.
100074642e01fSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
100086747b715Smrg	      reload_objs="$objlist $last_robj"
1000935c4bbdfSmrg	      eval concat_cmds=\"\$concat_cmds$reload_cmds\"
100104642e01fSmrg	      if test -n "$last_robj"; then
1001135c4bbdfSmrg	        eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
100124642e01fSmrg	      fi
1001335c4bbdfSmrg	      func_append delfiles " $output"
1001405b261ecSmrg
100154642e01fSmrg	    else
100164642e01fSmrg	      output=
100174642e01fSmrg	    fi
1001805b261ecSmrg
1001935c4bbdfSmrg	    ${skipped_export-false} && {
1002035c4bbdfSmrg	      func_verbose "generating symbol list for '$libname.la'"
1002135c4bbdfSmrg	      export_symbols=$output_objdir/$libname.exp
100224642e01fSmrg	      $opt_dry_run || $RM $export_symbols
100234642e01fSmrg	      libobjs=$output
100244642e01fSmrg	      # Append the command to create the export file.
100254642e01fSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
100264642e01fSmrg	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
100274642e01fSmrg	      if test -n "$last_robj"; then
100284642e01fSmrg		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
100294642e01fSmrg	      fi
1003035c4bbdfSmrg	    }
1003105b261ecSmrg
100324642e01fSmrg	    test -n "$save_libobjs" &&
100334642e01fSmrg	      func_verbose "creating a temporary reloadable object file: $output"
1003405b261ecSmrg
100354642e01fSmrg	    # Loop through the commands generated above and execute them.
1003635c4bbdfSmrg	    save_ifs=$IFS; IFS='~'
100374642e01fSmrg	    for cmd in $concat_cmds; do
1003835c4bbdfSmrg	      IFS=$save_ifs
1003935c4bbdfSmrg	      $opt_quiet || {
100404642e01fSmrg		  func_quote_for_expand "$cmd"
100414642e01fSmrg		  eval "func_echo $func_quote_for_expand_result"
100424642e01fSmrg	      }
100434642e01fSmrg	      $opt_dry_run || eval "$cmd" || {
100444642e01fSmrg		lt_exit=$?
100454642e01fSmrg
100464642e01fSmrg		# Restore the uninstalled library and exit
1004735c4bbdfSmrg		if test relink = "$opt_mode"; then
100484642e01fSmrg		  ( cd "$output_objdir" && \
100494642e01fSmrg		    $RM "${realname}T" && \
100504642e01fSmrg		    $MV "${realname}U" "$realname" )
100514642e01fSmrg		fi
1005205b261ecSmrg
100534642e01fSmrg		exit $lt_exit
100544642e01fSmrg	      }
100554642e01fSmrg	    done
1005635c4bbdfSmrg	    IFS=$save_ifs
1005705b261ecSmrg
100584642e01fSmrg	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
100594642e01fSmrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
100604642e01fSmrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
1006105b261ecSmrg	    fi
1006205b261ecSmrg	  fi
1006305b261ecSmrg
1006435c4bbdfSmrg          ${skipped_export-false} && {
100654642e01fSmrg	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
1006635c4bbdfSmrg	      tmp_export_symbols=$export_symbols
1006735c4bbdfSmrg	      test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
100686747b715Smrg	      $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
100694642e01fSmrg	    fi
1007005b261ecSmrg
100714642e01fSmrg	    if test -n "$orig_export_symbols"; then
100724642e01fSmrg	      # The given exports_symbols file has to be filtered, so filter it.
1007335c4bbdfSmrg	      func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
100744642e01fSmrg	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
1007535c4bbdfSmrg	      # 's' commands, which not all seds can handle. GNU sed should be fine
100764642e01fSmrg	      # though. Also, the filter scales superlinearly with the number of
100774642e01fSmrg	      # global variables. join(1) would be nice here, but unfortunately
100784642e01fSmrg	      # isn't a blessed tool.
100794642e01fSmrg	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
1008035c4bbdfSmrg	      func_append delfiles " $export_symbols $output_objdir/$libname.filter"
100814642e01fSmrg	      export_symbols=$output_objdir/$libname.def
100824642e01fSmrg	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
100834642e01fSmrg	    fi
1008435c4bbdfSmrg	  }
1008505b261ecSmrg
100864642e01fSmrg	  libobjs=$output
100874642e01fSmrg	  # Restore the value of output.
100884642e01fSmrg	  output=$save_output
1008905b261ecSmrg
100904642e01fSmrg	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
100914642e01fSmrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
100924642e01fSmrg	    test "X$libobjs" = "X " && libobjs=
100934642e01fSmrg	  fi
100944642e01fSmrg	  # Expand the library linking commands again to reset the
100954642e01fSmrg	  # value of $libobjs for piecewise linking.
1009605b261ecSmrg
100974642e01fSmrg	  # Do each of the archive commands.
1009835c4bbdfSmrg	  if test yes = "$module" && test -n "$module_cmds"; then
100994642e01fSmrg	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
101004642e01fSmrg	      cmds=$module_expsym_cmds
101014642e01fSmrg	    else
101024642e01fSmrg	      cmds=$module_cmds
1010305b261ecSmrg	    fi
1010405b261ecSmrg	  else
101054642e01fSmrg	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
101064642e01fSmrg	      cmds=$archive_expsym_cmds
101074642e01fSmrg	    else
101084642e01fSmrg	      cmds=$archive_cmds
101094642e01fSmrg	    fi
1011005b261ecSmrg	  fi
101114642e01fSmrg	fi
1011205b261ecSmrg
101134642e01fSmrg	if test -n "$delfiles"; then
101144642e01fSmrg	  # Append the command to remove temporary files to $cmds.
101154642e01fSmrg	  eval cmds=\"\$cmds~\$RM $delfiles\"
101164642e01fSmrg	fi
1011705b261ecSmrg
101184642e01fSmrg	# Add any objects from preloaded convenience libraries
101194642e01fSmrg	if test -n "$dlprefiles"; then
1012035c4bbdfSmrg	  gentop=$output_objdir/${outputname}x
1012135c4bbdfSmrg	  func_append generated " $gentop"
1012205b261ecSmrg
101234642e01fSmrg	  func_extract_archives $gentop $dlprefiles
1012435c4bbdfSmrg	  func_append libobjs " $func_extract_archives_result"
101254642e01fSmrg	  test "X$libobjs" = "X " && libobjs=
101264642e01fSmrg	fi
1012705b261ecSmrg
1012835c4bbdfSmrg	save_ifs=$IFS; IFS='~'
101294642e01fSmrg	for cmd in $cmds; do
1013035c4bbdfSmrg	  IFS=$sp$nl
101314642e01fSmrg	  eval cmd=\"$cmd\"
1013235c4bbdfSmrg	  IFS=$save_ifs
1013335c4bbdfSmrg	  $opt_quiet || {
101344642e01fSmrg	    func_quote_for_expand "$cmd"
101354642e01fSmrg	    eval "func_echo $func_quote_for_expand_result"
101364642e01fSmrg	  }
101374642e01fSmrg	  $opt_dry_run || eval "$cmd" || {
101384642e01fSmrg	    lt_exit=$?
1013905b261ecSmrg
101404642e01fSmrg	    # Restore the uninstalled library and exit
1014135c4bbdfSmrg	    if test relink = "$opt_mode"; then
101424642e01fSmrg	      ( cd "$output_objdir" && \
101434642e01fSmrg	        $RM "${realname}T" && \
101444642e01fSmrg		$MV "${realname}U" "$realname" )
101454642e01fSmrg	    fi
1014605b261ecSmrg
101474642e01fSmrg	    exit $lt_exit
101484642e01fSmrg	  }
101494642e01fSmrg	done
1015035c4bbdfSmrg	IFS=$save_ifs
1015105b261ecSmrg
101524642e01fSmrg	# Restore the uninstalled library and exit
1015335c4bbdfSmrg	if test relink = "$opt_mode"; then
101544642e01fSmrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
1015505b261ecSmrg
101564642e01fSmrg	  if test -n "$convenience"; then
101574642e01fSmrg	    if test -z "$whole_archive_flag_spec"; then
101584642e01fSmrg	      func_show_eval '${RM}r "$gentop"'
101594642e01fSmrg	    fi
101604642e01fSmrg	  fi
1016105b261ecSmrg
101624642e01fSmrg	  exit $EXIT_SUCCESS
101634642e01fSmrg	fi
101644642e01fSmrg
101654642e01fSmrg	# Create links to the real library.
101664642e01fSmrg	for linkname in $linknames; do
101674642e01fSmrg	  if test "$realname" != "$linkname"; then
101684642e01fSmrg	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
1016905b261ecSmrg	  fi
1017005b261ecSmrg	done
1017105b261ecSmrg
101724642e01fSmrg	# If -module or -export-dynamic was specified, set the dlname.
1017335c4bbdfSmrg	if test yes = "$module" || test yes = "$export_dynamic"; then
101744642e01fSmrg	  # On all known operating systems, these are identical.
1017535c4bbdfSmrg	  dlname=$soname
101764642e01fSmrg	fi
101774642e01fSmrg      fi
1017805b261ecSmrg      ;;
1017905b261ecSmrg
101804642e01fSmrg    obj)
1018135c4bbdfSmrg      if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
1018235c4bbdfSmrg	func_warning "'-dlopen' is ignored for objects"
101834642e01fSmrg      fi
1018405b261ecSmrg
101854642e01fSmrg      case " $deplibs" in
101864642e01fSmrg      *\ -l* | *\ -L*)
1018735c4bbdfSmrg	func_warning "'-l' and '-L' are ignored for objects" ;;
1018805b261ecSmrg      esac
1018905b261ecSmrg
101904642e01fSmrg      test -n "$rpath" && \
1019135c4bbdfSmrg	func_warning "'-rpath' is ignored for objects"
101924642e01fSmrg
101934642e01fSmrg      test -n "$xrpath" && \
1019435c4bbdfSmrg	func_warning "'-R' is ignored for objects"
1019505b261ecSmrg
101964642e01fSmrg      test -n "$vinfo" && \
1019735c4bbdfSmrg	func_warning "'-version-info' is ignored for objects"
1019805b261ecSmrg
101994642e01fSmrg      test -n "$release" && \
1020035c4bbdfSmrg	func_warning "'-release' is ignored for objects"
102014642e01fSmrg
102024642e01fSmrg      case $output in
102034642e01fSmrg      *.lo)
102044642e01fSmrg	test -n "$objs$old_deplibs" && \
1020535c4bbdfSmrg	  func_fatal_error "cannot build library object '$output' from non-libtool objects"
102064642e01fSmrg
102074642e01fSmrg	libobj=$output
102084642e01fSmrg	func_lo2o "$libobj"
102094642e01fSmrg	obj=$func_lo2o_result
1021005b261ecSmrg	;;
1021105b261ecSmrg      *)
102124642e01fSmrg	libobj=
1021335c4bbdfSmrg	obj=$output
1021405b261ecSmrg	;;
1021505b261ecSmrg      esac
1021605b261ecSmrg
102174642e01fSmrg      # Delete the old objects.
102184642e01fSmrg      $opt_dry_run || $RM $obj $libobj
1021905b261ecSmrg
102204642e01fSmrg      # Objects from convenience libraries.  This assumes
102214642e01fSmrg      # single-version convenience libraries.  Whenever we create
102224642e01fSmrg      # different ones for PIC/non-PIC, this we'll have to duplicate
102234642e01fSmrg      # the extraction.
102244642e01fSmrg      reload_conv_objs=
102254642e01fSmrg      gentop=
1022635c4bbdfSmrg      # if reload_cmds runs $LD directly, get rid of -Wl from
1022735c4bbdfSmrg      # whole_archive_flag_spec and hope we can get by with turning comma
1022835c4bbdfSmrg      # into space.
1022935c4bbdfSmrg      case $reload_cmds in
1023035c4bbdfSmrg        *\$LD[\ \$]*) wl= ;;
1023135c4bbdfSmrg      esac
102324642e01fSmrg      if test -n "$convenience"; then
102334642e01fSmrg	if test -n "$whole_archive_flag_spec"; then
102344642e01fSmrg	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
1023535c4bbdfSmrg	  test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
1023635c4bbdfSmrg	  reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags
102374642e01fSmrg	else
1023835c4bbdfSmrg	  gentop=$output_objdir/${obj}x
1023935c4bbdfSmrg	  func_append generated " $gentop"
1024005b261ecSmrg
102414642e01fSmrg	  func_extract_archives $gentop $convenience
102424642e01fSmrg	  reload_conv_objs="$reload_objs $func_extract_archives_result"
102434642e01fSmrg	fi
1024405b261ecSmrg      fi
1024505b261ecSmrg
1024635c4bbdfSmrg      # If we're not building shared, we need to use non_pic_objs
1024735c4bbdfSmrg      test yes = "$build_libtool_libs" || libobjs=$non_pic_objects
1024835c4bbdfSmrg
102494642e01fSmrg      # Create the old-style object.
1025035c4bbdfSmrg      reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs
1025105b261ecSmrg
1025235c4bbdfSmrg      output=$obj
102534642e01fSmrg      func_execute_cmds "$reload_cmds" 'exit $?'
1025405b261ecSmrg
102554642e01fSmrg      # Exit if we aren't doing a library object file.
102564642e01fSmrg      if test -z "$libobj"; then
102574642e01fSmrg	if test -n "$gentop"; then
102584642e01fSmrg	  func_show_eval '${RM}r "$gentop"'
102594642e01fSmrg	fi
102604642e01fSmrg
102614642e01fSmrg	exit $EXIT_SUCCESS
1026205b261ecSmrg      fi
102634642e01fSmrg
1026435c4bbdfSmrg      test yes = "$build_libtool_libs" || {
102654642e01fSmrg	if test -n "$gentop"; then
102664642e01fSmrg	  func_show_eval '${RM}r "$gentop"'
102674642e01fSmrg	fi
102684642e01fSmrg
102694642e01fSmrg	# Create an invalid libtool object if no PIC, so that we don't
102704642e01fSmrg	# accidentally link it into a program.
102714642e01fSmrg	# $show "echo timestamp > $libobj"
102724642e01fSmrg	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
102734642e01fSmrg	exit $EXIT_SUCCESS
1027435c4bbdfSmrg      }
102754642e01fSmrg
1027635c4bbdfSmrg      if test -n "$pic_flag" || test default != "$pic_mode"; then
102774642e01fSmrg	# Only do commands if we really have different PIC objects.
102784642e01fSmrg	reload_objs="$libobjs $reload_conv_objs"
1027935c4bbdfSmrg	output=$libobj
102804642e01fSmrg	func_execute_cmds "$reload_cmds" 'exit $?'
102814642e01fSmrg      fi
102824642e01fSmrg
102834642e01fSmrg      if test -n "$gentop"; then
102844642e01fSmrg	func_show_eval '${RM}r "$gentop"'
102854642e01fSmrg      fi
102864642e01fSmrg
102874642e01fSmrg      exit $EXIT_SUCCESS
1028805b261ecSmrg      ;;
1028905b261ecSmrg
102904642e01fSmrg    prog)
102914642e01fSmrg      case $host in
102924642e01fSmrg	*cygwin*) func_stripname '' '.exe' "$output"
102934642e01fSmrg	          output=$func_stripname_result.exe;;
102944642e01fSmrg      esac
102954642e01fSmrg      test -n "$vinfo" && \
1029635c4bbdfSmrg	func_warning "'-version-info' is ignored for programs"
1029705b261ecSmrg
102984642e01fSmrg      test -n "$release" && \
1029935c4bbdfSmrg	func_warning "'-release' is ignored for programs"
1030005b261ecSmrg
1030135c4bbdfSmrg      $preload \
1030235c4bbdfSmrg	&& test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \
1030335c4bbdfSmrg	&& func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support."
103044642e01fSmrg
103054642e01fSmrg      case $host in
103064642e01fSmrg      *-*-rhapsody* | *-*-darwin1.[012])
103074642e01fSmrg	# On Rhapsody replace the C library is the System framework
103086747b715Smrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
103096747b715Smrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
1031005b261ecSmrg	;;
103114642e01fSmrg      esac
1031205b261ecSmrg
103134642e01fSmrg      case $host in
103144642e01fSmrg      *-*-darwin*)
103154642e01fSmrg	# Don't allow lazy linking, it breaks C++ global constructors
103164642e01fSmrg	# But is supposedly fixed on 10.4 or later (yay!).
1031735c4bbdfSmrg	if test CXX = "$tagname"; then
103184642e01fSmrg	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
103194642e01fSmrg	    10.[0123])
1032035c4bbdfSmrg	      func_append compile_command " $wl-bind_at_load"
1032135c4bbdfSmrg	      func_append finalize_command " $wl-bind_at_load"
103224642e01fSmrg	    ;;
103234642e01fSmrg	  esac
1032405b261ecSmrg	fi
103254642e01fSmrg	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
103266747b715Smrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
103276747b715Smrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
103284642e01fSmrg	;;
103294642e01fSmrg      esac
1033005b261ecSmrg
1033105b261ecSmrg
103324642e01fSmrg      # move library search paths that coincide with paths to not yet
103334642e01fSmrg      # installed libraries to the beginning of the library search list
103344642e01fSmrg      new_libs=
103354642e01fSmrg      for path in $notinst_path; do
103364642e01fSmrg	case " $new_libs " in
103374642e01fSmrg	*" -L$path/$objdir "*) ;;
103384642e01fSmrg	*)
103394642e01fSmrg	  case " $compile_deplibs " in
103404642e01fSmrg	  *" -L$path/$objdir "*)
1034135c4bbdfSmrg	    func_append new_libs " -L$path/$objdir" ;;
1034205b261ecSmrg	  esac
103434642e01fSmrg	  ;;
103444642e01fSmrg	esac
103454642e01fSmrg      done
103464642e01fSmrg      for deplib in $compile_deplibs; do
103474642e01fSmrg	case $deplib in
103484642e01fSmrg	-L*)
103494642e01fSmrg	  case " $new_libs " in
103504642e01fSmrg	  *" $deplib "*) ;;
1035135c4bbdfSmrg	  *) func_append new_libs " $deplib" ;;
1035205b261ecSmrg	  esac
103534642e01fSmrg	  ;;
1035435c4bbdfSmrg	*) func_append new_libs " $deplib" ;;
103554642e01fSmrg	esac
103564642e01fSmrg      done
1035735c4bbdfSmrg      compile_deplibs=$new_libs
1035805b261ecSmrg
1035905b261ecSmrg
1036035c4bbdfSmrg      func_append compile_command " $compile_deplibs"
1036135c4bbdfSmrg      func_append finalize_command " $finalize_deplibs"
1036205b261ecSmrg
103634642e01fSmrg      if test -n "$rpath$xrpath"; then
103644642e01fSmrg	# If the user specified any rpath flags, then add them.
103654642e01fSmrg	for libdir in $rpath $xrpath; do
103664642e01fSmrg	  # This is the magic to use -rpath.
103674642e01fSmrg	  case "$finalize_rpath " in
103684642e01fSmrg	  *" $libdir "*) ;;
1036935c4bbdfSmrg	  *) func_append finalize_rpath " $libdir" ;;
103704642e01fSmrg	  esac
103714642e01fSmrg	done
103724642e01fSmrg      fi
1037305b261ecSmrg
103744642e01fSmrg      # Now hardcode the library paths
103754642e01fSmrg      rpath=
103764642e01fSmrg      hardcode_libdirs=
103774642e01fSmrg      for libdir in $compile_rpath $finalize_rpath; do
103784642e01fSmrg	if test -n "$hardcode_libdir_flag_spec"; then
103794642e01fSmrg	  if test -n "$hardcode_libdir_separator"; then
103804642e01fSmrg	    if test -z "$hardcode_libdirs"; then
1038135c4bbdfSmrg	      hardcode_libdirs=$libdir
103824642e01fSmrg	    else
103834642e01fSmrg	      # Just accumulate the unique libdirs.
103844642e01fSmrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
103854642e01fSmrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
103864642e01fSmrg		;;
103874642e01fSmrg	      *)
1038835c4bbdfSmrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
103894642e01fSmrg		;;
103904642e01fSmrg	      esac
103914642e01fSmrg	    fi
1039205b261ecSmrg	  else
103934642e01fSmrg	    eval flag=\"$hardcode_libdir_flag_spec\"
1039435c4bbdfSmrg	    func_append rpath " $flag"
1039505b261ecSmrg	  fi
103964642e01fSmrg	elif test -n "$runpath_var"; then
103974642e01fSmrg	  case "$perm_rpath " in
103984642e01fSmrg	  *" $libdir "*) ;;
1039935c4bbdfSmrg	  *) func_append perm_rpath " $libdir" ;;
104004642e01fSmrg	  esac
104014642e01fSmrg	fi
104024642e01fSmrg	case $host in
104034642e01fSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
1040435c4bbdfSmrg	  testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'`
104054642e01fSmrg	  case :$dllsearchpath: in
104064642e01fSmrg	  *":$libdir:"*) ;;
104074642e01fSmrg	  ::) dllsearchpath=$libdir;;
1040835c4bbdfSmrg	  *) func_append dllsearchpath ":$libdir";;
104094642e01fSmrg	  esac
104104642e01fSmrg	  case :$dllsearchpath: in
104114642e01fSmrg	  *":$testbindir:"*) ;;
104124642e01fSmrg	  ::) dllsearchpath=$testbindir;;
1041335c4bbdfSmrg	  *) func_append dllsearchpath ":$testbindir";;
104144642e01fSmrg	  esac
104154642e01fSmrg	  ;;
104164642e01fSmrg	esac
104174642e01fSmrg      done
104184642e01fSmrg      # Substitute the hardcoded libdirs into the rpath.
104194642e01fSmrg      if test -n "$hardcode_libdir_separator" &&
104204642e01fSmrg	 test -n "$hardcode_libdirs"; then
1042135c4bbdfSmrg	libdir=$hardcode_libdirs
104224642e01fSmrg	eval rpath=\" $hardcode_libdir_flag_spec\"
104234642e01fSmrg      fi
1042435c4bbdfSmrg      compile_rpath=$rpath
1042505b261ecSmrg
104264642e01fSmrg      rpath=
104274642e01fSmrg      hardcode_libdirs=
104284642e01fSmrg      for libdir in $finalize_rpath; do
104294642e01fSmrg	if test -n "$hardcode_libdir_flag_spec"; then
104304642e01fSmrg	  if test -n "$hardcode_libdir_separator"; then
104314642e01fSmrg	    if test -z "$hardcode_libdirs"; then
1043235c4bbdfSmrg	      hardcode_libdirs=$libdir
104334642e01fSmrg	    else
104344642e01fSmrg	      # Just accumulate the unique libdirs.
104354642e01fSmrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
104364642e01fSmrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
104374642e01fSmrg		;;
104384642e01fSmrg	      *)
1043935c4bbdfSmrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
104404642e01fSmrg		;;
104414642e01fSmrg	      esac
104424642e01fSmrg	    fi
1044305b261ecSmrg	  else
104444642e01fSmrg	    eval flag=\"$hardcode_libdir_flag_spec\"
1044535c4bbdfSmrg	    func_append rpath " $flag"
1044605b261ecSmrg	  fi
104474642e01fSmrg	elif test -n "$runpath_var"; then
104484642e01fSmrg	  case "$finalize_perm_rpath " in
104494642e01fSmrg	  *" $libdir "*) ;;
1045035c4bbdfSmrg	  *) func_append finalize_perm_rpath " $libdir" ;;
104514642e01fSmrg	  esac
1045205b261ecSmrg	fi
104534642e01fSmrg      done
104544642e01fSmrg      # Substitute the hardcoded libdirs into the rpath.
104554642e01fSmrg      if test -n "$hardcode_libdir_separator" &&
104564642e01fSmrg	 test -n "$hardcode_libdirs"; then
1045735c4bbdfSmrg	libdir=$hardcode_libdirs
104584642e01fSmrg	eval rpath=\" $hardcode_libdir_flag_spec\"
104594642e01fSmrg      fi
1046035c4bbdfSmrg      finalize_rpath=$rpath
1046105b261ecSmrg
1046235c4bbdfSmrg      if test -n "$libobjs" && test yes = "$build_old_libs"; then
104634642e01fSmrg	# Transform all the library objects into standard objects.
104646747b715Smrg	compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
104656747b715Smrg	finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
104664642e01fSmrg      fi
1046705b261ecSmrg
1046835c4bbdfSmrg      func_generate_dlsyms "$outputname" "@PROGRAM@" false
1046905b261ecSmrg
104704642e01fSmrg      # template prelinking step
104714642e01fSmrg      if test -n "$prelink_cmds"; then
104724642e01fSmrg	func_execute_cmds "$prelink_cmds" 'exit $?'
104734642e01fSmrg      fi
1047405b261ecSmrg
1047535c4bbdfSmrg      wrappers_required=:
104764642e01fSmrg      case $host in
104776747b715Smrg      *cegcc* | *mingw32ce*)
104786747b715Smrg        # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
1047935c4bbdfSmrg        wrappers_required=false
104806747b715Smrg        ;;
104814642e01fSmrg      *cygwin* | *mingw* )
1048235c4bbdfSmrg        test yes = "$build_libtool_libs" || wrappers_required=false
104834642e01fSmrg        ;;
104844642e01fSmrg      *)
1048535c4bbdfSmrg        if test no = "$need_relink" || test yes != "$build_libtool_libs"; then
1048635c4bbdfSmrg          wrappers_required=false
104874642e01fSmrg        fi
104884642e01fSmrg        ;;
104894642e01fSmrg      esac
1049035c4bbdfSmrg      $wrappers_required || {
104914642e01fSmrg	# Replace the output file specification.
104926747b715Smrg	compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
1049335c4bbdfSmrg	link_command=$compile_command$compile_rpath
1049405b261ecSmrg
104954642e01fSmrg	# We have no uninstalled library dependencies, so finalize right now.
104964642e01fSmrg	exit_status=0
104974642e01fSmrg	func_show_eval "$link_command" 'exit_status=$?'
1049805b261ecSmrg
1049935c4bbdfSmrg	if test -n "$postlink_cmds"; then
1050035c4bbdfSmrg	  func_to_tool_file "$output"
1050135c4bbdfSmrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
1050235c4bbdfSmrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
1050335c4bbdfSmrg	fi
1050435c4bbdfSmrg
105054642e01fSmrg	# Delete the generated files.
1050635c4bbdfSmrg	if test -f "$output_objdir/${outputname}S.$objext"; then
1050735c4bbdfSmrg	  func_show_eval '$RM "$output_objdir/${outputname}S.$objext"'
1050805b261ecSmrg	fi
1050905b261ecSmrg
105104642e01fSmrg	exit $exit_status
1051135c4bbdfSmrg      }
1051205b261ecSmrg
105134642e01fSmrg      if test -n "$compile_shlibpath$finalize_shlibpath"; then
105144642e01fSmrg	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
105154642e01fSmrg      fi
105164642e01fSmrg      if test -n "$finalize_shlibpath"; then
105174642e01fSmrg	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
105184642e01fSmrg      fi
1051905b261ecSmrg
105204642e01fSmrg      compile_var=
105214642e01fSmrg      finalize_var=
105224642e01fSmrg      if test -n "$runpath_var"; then
105234642e01fSmrg	if test -n "$perm_rpath"; then
105244642e01fSmrg	  # We should set the runpath_var.
105254642e01fSmrg	  rpath=
105264642e01fSmrg	  for dir in $perm_rpath; do
1052735c4bbdfSmrg	    func_append rpath "$dir:"
105284642e01fSmrg	  done
105294642e01fSmrg	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
1053005b261ecSmrg	fi
105314642e01fSmrg	if test -n "$finalize_perm_rpath"; then
105324642e01fSmrg	  # We should set the runpath_var.
105334642e01fSmrg	  rpath=
105344642e01fSmrg	  for dir in $finalize_perm_rpath; do
1053535c4bbdfSmrg	    func_append rpath "$dir:"
105364642e01fSmrg	  done
105374642e01fSmrg	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
1053805b261ecSmrg	fi
105394642e01fSmrg      fi
1054005b261ecSmrg
1054135c4bbdfSmrg      if test yes = "$no_install"; then
105424642e01fSmrg	# We don't need to create a wrapper script.
1054335c4bbdfSmrg	link_command=$compile_var$compile_command$compile_rpath
105444642e01fSmrg	# Replace the output file specification.
105456747b715Smrg	link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
105464642e01fSmrg	# Delete the old output file.
105474642e01fSmrg	$opt_dry_run || $RM $output
105484642e01fSmrg	# Link the executable and exit
105494642e01fSmrg	func_show_eval "$link_command" 'exit $?'
1055035c4bbdfSmrg
1055135c4bbdfSmrg	if test -n "$postlink_cmds"; then
1055235c4bbdfSmrg	  func_to_tool_file "$output"
1055335c4bbdfSmrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
1055435c4bbdfSmrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
1055535c4bbdfSmrg	fi
1055635c4bbdfSmrg
1055705b261ecSmrg	exit $EXIT_SUCCESS
105584642e01fSmrg      fi
1055905b261ecSmrg
1056035c4bbdfSmrg      case $hardcode_action,$fast_install in
1056135c4bbdfSmrg        relink,*)
1056235c4bbdfSmrg	  # Fast installation is not supported
1056335c4bbdfSmrg	  link_command=$compile_var$compile_command$compile_rpath
1056435c4bbdfSmrg	  relink_command=$finalize_var$finalize_command$finalize_rpath
105654642e01fSmrg
1056635c4bbdfSmrg	  func_warning "this platform does not like uninstalled shared libraries"
1056735c4bbdfSmrg	  func_warning "'$output' will be relinked during installation"
1056835c4bbdfSmrg	  ;;
1056935c4bbdfSmrg        *,yes)
1057035c4bbdfSmrg	  link_command=$finalize_var$compile_command$finalize_rpath
1057135c4bbdfSmrg	  relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
1057235c4bbdfSmrg          ;;
1057335c4bbdfSmrg	*,no)
1057435c4bbdfSmrg	  link_command=$compile_var$compile_command$compile_rpath
1057535c4bbdfSmrg	  relink_command=$finalize_var$finalize_command$finalize_rpath
1057635c4bbdfSmrg          ;;
1057735c4bbdfSmrg	*,needless)
1057835c4bbdfSmrg	  link_command=$finalize_var$compile_command$finalize_rpath
1057935c4bbdfSmrg	  relink_command=
1058035c4bbdfSmrg          ;;
1058135c4bbdfSmrg      esac
1058205b261ecSmrg
105834642e01fSmrg      # Replace the output file specification.
105846747b715Smrg      link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
1058505b261ecSmrg
105864642e01fSmrg      # Delete the old output files.
105874642e01fSmrg      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
1058805b261ecSmrg
105894642e01fSmrg      func_show_eval "$link_command" 'exit $?'
1059005b261ecSmrg
1059135c4bbdfSmrg      if test -n "$postlink_cmds"; then
1059235c4bbdfSmrg	func_to_tool_file "$output_objdir/$outputname"
1059335c4bbdfSmrg	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'`
1059435c4bbdfSmrg	func_execute_cmds "$postlink_cmds" 'exit $?'
1059535c4bbdfSmrg      fi
1059635c4bbdfSmrg
105974642e01fSmrg      # Now create the wrapper script.
105984642e01fSmrg      func_verbose "creating $output"
1059905b261ecSmrg
106004642e01fSmrg      # Quote the relink command for shipping.
106014642e01fSmrg      if test -n "$relink_command"; then
106024642e01fSmrg	# Preserve any variables that may affect compiler behavior
106034642e01fSmrg	for var in $variables_saved_for_relink; do
106044642e01fSmrg	  if eval test -z \"\${$var+set}\"; then
106054642e01fSmrg	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
106064642e01fSmrg	  elif eval var_value=\$$var; test -z "$var_value"; then
106074642e01fSmrg	    relink_command="$var=; export $var; $relink_command"
1060805b261ecSmrg	  else
106094642e01fSmrg	    func_quote_for_eval "$var_value"
106104642e01fSmrg	    relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
1061105b261ecSmrg	  fi
106124642e01fSmrg	done
10613ed6184dfSmrg	relink_command="(cd `pwd`; $relink_command)"
10614ed6184dfSmrg	relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
106154642e01fSmrg      fi
106164642e01fSmrg
106174642e01fSmrg      # Only actually do things if not in dry run mode.
106184642e01fSmrg      $opt_dry_run || {
106194642e01fSmrg	# win32 will think the script is a binary if it has
106204642e01fSmrg	# a .exe suffix, so we strip it off here.
106214642e01fSmrg	case $output in
106224642e01fSmrg	  *.exe) func_stripname '' '.exe' "$output"
106234642e01fSmrg	         output=$func_stripname_result ;;
106244642e01fSmrg	esac
106254642e01fSmrg	# test for cygwin because mv fails w/o .exe extensions
106264642e01fSmrg	case $host in
106274642e01fSmrg	  *cygwin*)
106284642e01fSmrg	    exeext=.exe
106294642e01fSmrg	    func_stripname '' '.exe' "$outputname"
106304642e01fSmrg	    outputname=$func_stripname_result ;;
106314642e01fSmrg	  *) exeext= ;;
1063205b261ecSmrg	esac
106334642e01fSmrg	case $host in
106344642e01fSmrg	  *cygwin* | *mingw* )
106354642e01fSmrg	    func_dirname_and_basename "$output" "" "."
106364642e01fSmrg	    output_name=$func_basename_result
106374642e01fSmrg	    output_path=$func_dirname_result
1063835c4bbdfSmrg	    cwrappersource=$output_path/$objdir/lt-$output_name.c
1063935c4bbdfSmrg	    cwrapper=$output_path/$output_name.exe
106404642e01fSmrg	    $RM $cwrappersource $cwrapper
106414642e01fSmrg	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
106424642e01fSmrg
106434642e01fSmrg	    func_emit_cwrapperexe_src > $cwrappersource
106444642e01fSmrg
106454642e01fSmrg	    # The wrapper executable is built using the $host compiler,
106464642e01fSmrg	    # because it contains $host paths and files. If cross-
106474642e01fSmrg	    # compiling, it, like the target executable, must be
106484642e01fSmrg	    # executed on the $host or under an emulation environment.
106494642e01fSmrg	    $opt_dry_run || {
106504642e01fSmrg	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
106514642e01fSmrg	      $STRIP $cwrapper
106524642e01fSmrg	    }
1065305b261ecSmrg
106544642e01fSmrg	    # Now, create the wrapper script for func_source use:
106554642e01fSmrg	    func_ltwrapper_scriptname $cwrapper
106564642e01fSmrg	    $RM $func_ltwrapper_scriptname_result
106574642e01fSmrg	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
106584642e01fSmrg	    $opt_dry_run || {
106594642e01fSmrg	      # note: this script will not be executed, so do not chmod.
1066035c4bbdfSmrg	      if test "x$build" = "x$host"; then
106614642e01fSmrg		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
106624642e01fSmrg	      else
106634642e01fSmrg		func_emit_wrapper no > $func_ltwrapper_scriptname_result
106644642e01fSmrg	      fi
106654642e01fSmrg	    }
106664642e01fSmrg	  ;;
106674642e01fSmrg	  * )
106684642e01fSmrg	    $RM $output
106694642e01fSmrg	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
1067005b261ecSmrg
106714642e01fSmrg	    func_emit_wrapper no > $output
106724642e01fSmrg	    chmod +x $output
106734642e01fSmrg	  ;;
106744642e01fSmrg	esac
106754642e01fSmrg      }
106764642e01fSmrg      exit $EXIT_SUCCESS
106774642e01fSmrg      ;;
106784642e01fSmrg    esac
1067905b261ecSmrg
106804642e01fSmrg    # See if we need to build an old-fashioned archive.
106814642e01fSmrg    for oldlib in $oldlibs; do
1068205b261ecSmrg
1068335c4bbdfSmrg      case $build_libtool_libs in
1068435c4bbdfSmrg        convenience)
1068535c4bbdfSmrg	  oldobjs="$libobjs_save $symfileobj"
1068635c4bbdfSmrg	  addlibs=$convenience
106874642e01fSmrg	  build_libtool_libs=no
1068835c4bbdfSmrg	  ;;
1068935c4bbdfSmrg	module)
1069035c4bbdfSmrg	  oldobjs=$libobjs_save
1069135c4bbdfSmrg	  addlibs=$old_convenience
1069235c4bbdfSmrg	  build_libtool_libs=no
1069335c4bbdfSmrg          ;;
1069435c4bbdfSmrg	*)
106954642e01fSmrg	  oldobjs="$old_deplibs $non_pic_objects"
1069635c4bbdfSmrg	  $preload && test -f "$symfileobj" \
1069735c4bbdfSmrg	    && func_append oldobjs " $symfileobj"
1069835c4bbdfSmrg	  addlibs=$old_convenience
1069935c4bbdfSmrg	  ;;
1070035c4bbdfSmrg      esac
1070105b261ecSmrg
107024642e01fSmrg      if test -n "$addlibs"; then
1070335c4bbdfSmrg	gentop=$output_objdir/${outputname}x
1070435c4bbdfSmrg	func_append generated " $gentop"
1070505b261ecSmrg
107064642e01fSmrg	func_extract_archives $gentop $addlibs
1070735c4bbdfSmrg	func_append oldobjs " $func_extract_archives_result"
107084642e01fSmrg      fi
1070905b261ecSmrg
107104642e01fSmrg      # Do each command in the archive commands.
1071135c4bbdfSmrg      if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then
107124642e01fSmrg	cmds=$old_archive_from_new_cmds
107134642e01fSmrg      else
1071405b261ecSmrg
107154642e01fSmrg	# Add any objects from preloaded convenience libraries
107164642e01fSmrg	if test -n "$dlprefiles"; then
1071735c4bbdfSmrg	  gentop=$output_objdir/${outputname}x
1071835c4bbdfSmrg	  func_append generated " $gentop"
1071905b261ecSmrg
107204642e01fSmrg	  func_extract_archives $gentop $dlprefiles
1072135c4bbdfSmrg	  func_append oldobjs " $func_extract_archives_result"
107224642e01fSmrg	fi
1072305b261ecSmrg
107244642e01fSmrg	# POSIX demands no paths to be encoded in archives.  We have
107254642e01fSmrg	# to avoid creating archives with duplicate basenames if we
107264642e01fSmrg	# might have to extract them afterwards, e.g., when creating a
107274642e01fSmrg	# static archive out of a convenience library, or when linking
107284642e01fSmrg	# the entirety of a libtool archive into another (currently
107294642e01fSmrg	# not supported by libtool).
107304642e01fSmrg	if (for obj in $oldobjs
107314642e01fSmrg	    do
107324642e01fSmrg	      func_basename "$obj"
107334642e01fSmrg	      $ECHO "$func_basename_result"
107344642e01fSmrg	    done | sort | sort -uc >/dev/null 2>&1); then
107354642e01fSmrg	  :
107364642e01fSmrg	else
107376747b715Smrg	  echo "copying selected object files to avoid basename conflicts..."
1073835c4bbdfSmrg	  gentop=$output_objdir/${outputname}x
1073935c4bbdfSmrg	  func_append generated " $gentop"
107404642e01fSmrg	  func_mkdir_p "$gentop"
107414642e01fSmrg	  save_oldobjs=$oldobjs
107424642e01fSmrg	  oldobjs=
107434642e01fSmrg	  counter=1
107444642e01fSmrg	  for obj in $save_oldobjs
107454642e01fSmrg	  do
107464642e01fSmrg	    func_basename "$obj"
1074735c4bbdfSmrg	    objbase=$func_basename_result
107484642e01fSmrg	    case " $oldobjs " in
107494642e01fSmrg	    " ") oldobjs=$obj ;;
107504642e01fSmrg	    *[\ /]"$objbase "*)
107514642e01fSmrg	      while :; do
107524642e01fSmrg		# Make sure we don't pick an alternate name that also
107534642e01fSmrg		# overlaps.
107544642e01fSmrg		newobj=lt$counter-$objbase
107554642e01fSmrg		func_arith $counter + 1
107564642e01fSmrg		counter=$func_arith_result
107574642e01fSmrg		case " $oldobjs " in
107584642e01fSmrg		*[\ /]"$newobj "*) ;;
107594642e01fSmrg		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
107604642e01fSmrg		esac
107614642e01fSmrg	      done
107624642e01fSmrg	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
1076335c4bbdfSmrg	      func_append oldobjs " $gentop/$newobj"
107644642e01fSmrg	      ;;
1076535c4bbdfSmrg	    *) func_append oldobjs " $obj" ;;
107664642e01fSmrg	    esac
1076705b261ecSmrg	  done
1076805b261ecSmrg	fi
1076935c4bbdfSmrg	func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
1077035c4bbdfSmrg	tool_oldlib=$func_to_tool_file_result
107714642e01fSmrg	eval cmds=\"$old_archive_cmds\"
1077205b261ecSmrg
107734642e01fSmrg	func_len " $cmds"
107744642e01fSmrg	len=$func_len_result
107754642e01fSmrg	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
107764642e01fSmrg	  cmds=$old_archive_cmds
1077735c4bbdfSmrg	elif test -n "$archiver_list_spec"; then
1077835c4bbdfSmrg	  func_verbose "using command file archive linking..."
1077935c4bbdfSmrg	  for obj in $oldobjs
1078035c4bbdfSmrg	  do
1078135c4bbdfSmrg	    func_to_tool_file "$obj"
1078235c4bbdfSmrg	    $ECHO "$func_to_tool_file_result"
1078335c4bbdfSmrg	  done > $output_objdir/$libname.libcmd
1078435c4bbdfSmrg	  func_to_tool_file "$output_objdir/$libname.libcmd"
1078535c4bbdfSmrg	  oldobjs=" $archiver_list_spec$func_to_tool_file_result"
1078635c4bbdfSmrg	  cmds=$old_archive_cmds
107874642e01fSmrg	else
107884642e01fSmrg	  # the command line is too long to link in one step, link in parts
107894642e01fSmrg	  func_verbose "using piecewise archive linking..."
107904642e01fSmrg	  save_RANLIB=$RANLIB
107914642e01fSmrg	  RANLIB=:
107924642e01fSmrg	  objlist=
107934642e01fSmrg	  concat_cmds=
107944642e01fSmrg	  save_oldobjs=$oldobjs
107954642e01fSmrg	  oldobjs=
107964642e01fSmrg	  # Is there a better way of finding the last object in the list?
107974642e01fSmrg	  for obj in $save_oldobjs
107984642e01fSmrg	  do
107994642e01fSmrg	    last_oldobj=$obj
108004642e01fSmrg	  done
108014642e01fSmrg	  eval test_cmds=\"$old_archive_cmds\"
108024642e01fSmrg	  func_len " $test_cmds"
108034642e01fSmrg	  len0=$func_len_result
108044642e01fSmrg	  len=$len0
108054642e01fSmrg	  for obj in $save_oldobjs
108064642e01fSmrg	  do
108074642e01fSmrg	    func_len " $obj"
108084642e01fSmrg	    func_arith $len + $func_len_result
108094642e01fSmrg	    len=$func_arith_result
108104642e01fSmrg	    func_append objlist " $obj"
108114642e01fSmrg	    if test "$len" -lt "$max_cmd_len"; then
108124642e01fSmrg	      :
108134642e01fSmrg	    else
108144642e01fSmrg	      # the above command should be used before it gets too long
108154642e01fSmrg	      oldobjs=$objlist
1081635c4bbdfSmrg	      if test "$obj" = "$last_oldobj"; then
108174642e01fSmrg		RANLIB=$save_RANLIB
108184642e01fSmrg	      fi
108194642e01fSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
1082035c4bbdfSmrg	      eval concat_cmds=\"\$concat_cmds$old_archive_cmds\"
108214642e01fSmrg	      objlist=
108224642e01fSmrg	      len=$len0
108234642e01fSmrg	    fi
108244642e01fSmrg	  done
108254642e01fSmrg	  RANLIB=$save_RANLIB
108264642e01fSmrg	  oldobjs=$objlist
1082735c4bbdfSmrg	  if test -z "$oldobjs"; then
108284642e01fSmrg	    eval cmds=\"\$concat_cmds\"
108294642e01fSmrg	  else
108304642e01fSmrg	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
108314642e01fSmrg	  fi
108324642e01fSmrg	fi
108334642e01fSmrg      fi
108344642e01fSmrg      func_execute_cmds "$cmds" 'exit $?'
1083505b261ecSmrg    done
1083605b261ecSmrg
108374642e01fSmrg    test -n "$generated" && \
108384642e01fSmrg      func_show_eval "${RM}r$generated"
1083905b261ecSmrg
108404642e01fSmrg    # Now create the libtool archive.
108414642e01fSmrg    case $output in
108424642e01fSmrg    *.la)
108434642e01fSmrg      old_library=
1084435c4bbdfSmrg      test yes = "$build_old_libs" && old_library=$libname.$libext
108454642e01fSmrg      func_verbose "creating $output"
1084605b261ecSmrg
108474642e01fSmrg      # Preserve any variables that may affect compiler behavior
108484642e01fSmrg      for var in $variables_saved_for_relink; do
108494642e01fSmrg	if eval test -z \"\${$var+set}\"; then
108504642e01fSmrg	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
108514642e01fSmrg	elif eval var_value=\$$var; test -z "$var_value"; then
108524642e01fSmrg	  relink_command="$var=; export $var; $relink_command"
1085305b261ecSmrg	else
108544642e01fSmrg	  func_quote_for_eval "$var_value"
108554642e01fSmrg	  relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
1085605b261ecSmrg	fi
108574642e01fSmrg      done
108584642e01fSmrg      # Quote the link command for shipping.
1085935c4bbdfSmrg      relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
10860ed6184dfSmrg      relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
1086135c4bbdfSmrg      if test yes = "$hardcode_automatic"; then
108624642e01fSmrg	relink_command=
108634642e01fSmrg      fi
1086405b261ecSmrg
108654642e01fSmrg      # Only create the output if not a dry run.
108664642e01fSmrg      $opt_dry_run || {
108674642e01fSmrg	for installed in no yes; do
1086835c4bbdfSmrg	  if test yes = "$installed"; then
108694642e01fSmrg	    if test -z "$install_libdir"; then
108704642e01fSmrg	      break
108714642e01fSmrg	    fi
1087235c4bbdfSmrg	    output=$output_objdir/${outputname}i
108734642e01fSmrg	    # Replace all uninstalled libtool libraries with the installed ones
108744642e01fSmrg	    newdependency_libs=
108754642e01fSmrg	    for deplib in $dependency_libs; do
108764642e01fSmrg	      case $deplib in
108774642e01fSmrg	      *.la)
108784642e01fSmrg		func_basename "$deplib"
1087935c4bbdfSmrg		name=$func_basename_result
1088035c4bbdfSmrg		func_resolve_sysroot "$deplib"
1088135c4bbdfSmrg		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
108824642e01fSmrg		test -z "$libdir" && \
1088335c4bbdfSmrg		  func_fatal_error "'$deplib' is not a valid libtool archive"
1088435c4bbdfSmrg		func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
1088535c4bbdfSmrg		;;
1088635c4bbdfSmrg	      -L*)
1088735c4bbdfSmrg		func_stripname -L '' "$deplib"
1088835c4bbdfSmrg		func_replace_sysroot "$func_stripname_result"
1088935c4bbdfSmrg		func_append newdependency_libs " -L$func_replace_sysroot_result"
108906747b715Smrg		;;
1089135c4bbdfSmrg	      -R*)
1089235c4bbdfSmrg		func_stripname -R '' "$deplib"
1089335c4bbdfSmrg		func_replace_sysroot "$func_stripname_result"
1089435c4bbdfSmrg		func_append newdependency_libs " -R$func_replace_sysroot_result"
1089535c4bbdfSmrg		;;
1089635c4bbdfSmrg	      *) func_append newdependency_libs " $deplib" ;;
108974642e01fSmrg	      esac
108984642e01fSmrg	    done
1089935c4bbdfSmrg	    dependency_libs=$newdependency_libs
109004642e01fSmrg	    newdlfiles=
109014642e01fSmrg
109024642e01fSmrg	    for lib in $dlfiles; do
109034642e01fSmrg	      case $lib in
109044642e01fSmrg	      *.la)
109054642e01fSmrg	        func_basename "$lib"
1090635c4bbdfSmrg		name=$func_basename_result
1090735c4bbdfSmrg		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
109084642e01fSmrg		test -z "$libdir" && \
1090935c4bbdfSmrg		  func_fatal_error "'$lib' is not a valid libtool archive"
1091035c4bbdfSmrg		func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
109114642e01fSmrg		;;
1091235c4bbdfSmrg	      *) func_append newdlfiles " $lib" ;;
109134642e01fSmrg	      esac
109144642e01fSmrg	    done
1091535c4bbdfSmrg	    dlfiles=$newdlfiles
109164642e01fSmrg	    newdlprefiles=
109174642e01fSmrg	    for lib in $dlprefiles; do
109184642e01fSmrg	      case $lib in
109194642e01fSmrg	      *.la)
109204642e01fSmrg		# Only pass preopened files to the pseudo-archive (for
109214642e01fSmrg		# eventual linking with the app. that links it) if we
109224642e01fSmrg		# didn't already link the preopened objects directly into
109234642e01fSmrg		# the library:
109244642e01fSmrg		func_basename "$lib"
1092535c4bbdfSmrg		name=$func_basename_result
1092635c4bbdfSmrg		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
109274642e01fSmrg		test -z "$libdir" && \
1092835c4bbdfSmrg		  func_fatal_error "'$lib' is not a valid libtool archive"
1092935c4bbdfSmrg		func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
109304642e01fSmrg		;;
109314642e01fSmrg	      esac
109324642e01fSmrg	    done
1093335c4bbdfSmrg	    dlprefiles=$newdlprefiles
109344642e01fSmrg	  else
109354642e01fSmrg	    newdlfiles=
109364642e01fSmrg	    for lib in $dlfiles; do
109374642e01fSmrg	      case $lib in
1093835c4bbdfSmrg		[\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
109394642e01fSmrg		*) abs=`pwd`"/$lib" ;;
109404642e01fSmrg	      esac
1094135c4bbdfSmrg	      func_append newdlfiles " $abs"
109424642e01fSmrg	    done
1094335c4bbdfSmrg	    dlfiles=$newdlfiles
109444642e01fSmrg	    newdlprefiles=
109454642e01fSmrg	    for lib in $dlprefiles; do
109464642e01fSmrg	      case $lib in
1094735c4bbdfSmrg		[\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
109484642e01fSmrg		*) abs=`pwd`"/$lib" ;;
109494642e01fSmrg	      esac
1095035c4bbdfSmrg	      func_append newdlprefiles " $abs"
109514642e01fSmrg	    done
1095235c4bbdfSmrg	    dlprefiles=$newdlprefiles
109534642e01fSmrg	  fi
109544642e01fSmrg	  $RM $output
109554642e01fSmrg	  # place dlname in correct position for cygwin
109566747b715Smrg	  # In fact, it would be nice if we could use this code for all target
109576747b715Smrg	  # systems that can't hard-code library paths into their executables
109586747b715Smrg	  # and that have no shared library path variable independent of PATH,
109596747b715Smrg	  # but it turns out we can't easily determine that from inspecting
109606747b715Smrg	  # libtool variables, so we have to hard-code the OSs to which it
109616747b715Smrg	  # applies here; at the moment, that means platforms that use the PE
109626747b715Smrg	  # object format with DLL files.  See the long comment at the top of
109636747b715Smrg	  # tests/bindir.at for full details.
109644642e01fSmrg	  tdlname=$dlname
109654642e01fSmrg	  case $host,$output,$installed,$module,$dlname in
109666747b715Smrg	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
109676747b715Smrg	      # If a -bindir argument was supplied, place the dll there.
1096835c4bbdfSmrg	      if test -n "$bindir"; then
109696747b715Smrg		func_relative_path "$install_libdir" "$bindir"
1097035c4bbdfSmrg		tdlname=$func_relative_path_result/$dlname
109716747b715Smrg	      else
109726747b715Smrg		# Otherwise fall back on heuristic.
109736747b715Smrg		tdlname=../bin/$dlname
109746747b715Smrg	      fi
109756747b715Smrg	      ;;
109764642e01fSmrg	  esac
109774642e01fSmrg	  $ECHO > $output "\
109784642e01fSmrg# $outputname - a libtool library file
1097935c4bbdfSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
109804642e01fSmrg#
109814642e01fSmrg# Please DO NOT delete this file!
109824642e01fSmrg# It is necessary for linking the library.
1098305b261ecSmrg
109844642e01fSmrg# The name that we can dlopen(3).
109854642e01fSmrgdlname='$tdlname'
1098605b261ecSmrg
109874642e01fSmrg# Names of this library.
109884642e01fSmrglibrary_names='$library_names'
1098905b261ecSmrg
109904642e01fSmrg# The name of the static archive.
109914642e01fSmrgold_library='$old_library'
1099205b261ecSmrg
1099335c4bbdfSmrg# Linker flags that cannot go in dependency_libs.
109944642e01fSmrginherited_linker_flags='$new_inherited_linker_flags'
1099505b261ecSmrg
109964642e01fSmrg# Libraries that this one depends upon.
109974642e01fSmrgdependency_libs='$dependency_libs'
1099805b261ecSmrg
109994642e01fSmrg# Names of additional weak libraries provided by this library
110004642e01fSmrgweak_library_names='$weak_libs'
1100105b261ecSmrg
110024642e01fSmrg# Version information for $libname.
110034642e01fSmrgcurrent=$current
110044642e01fSmrgage=$age
110054642e01fSmrgrevision=$revision
1100605b261ecSmrg
110074642e01fSmrg# Is this an already installed library?
110084642e01fSmrginstalled=$installed
1100905b261ecSmrg
110104642e01fSmrg# Should we warn about portability when linking against -modules?
110114642e01fSmrgshouldnotlink=$module
1101205b261ecSmrg
110134642e01fSmrg# Files to dlopen/dlpreopen
110144642e01fSmrgdlopen='$dlfiles'
110154642e01fSmrgdlpreopen='$dlprefiles'
1101605b261ecSmrg
110174642e01fSmrg# Directory that this library needs to be installed in:
110184642e01fSmrglibdir='$install_libdir'"
1101935c4bbdfSmrg	  if test no,yes = "$installed,$need_relink"; then
110204642e01fSmrg	    $ECHO >> $output "\
110214642e01fSmrgrelink_command=\"$relink_command\""
110224642e01fSmrg	  fi
110234642e01fSmrg	done
110244642e01fSmrg      }
1102505b261ecSmrg
110264642e01fSmrg      # Do a symbolic link so that the libtool archive can be found in
110274642e01fSmrg      # LD_LIBRARY_PATH before the program is installed.
110284642e01fSmrg      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
110294642e01fSmrg      ;;
110304642e01fSmrg    esac
110314642e01fSmrg    exit $EXIT_SUCCESS
110324642e01fSmrg}
1103305b261ecSmrg
1103435c4bbdfSmrgif test link = "$opt_mode" || test relink = "$opt_mode"; then
1103535c4bbdfSmrg  func_mode_link ${1+"$@"}
1103635c4bbdfSmrgfi
1103705b261ecSmrg
1103805b261ecSmrg
110394642e01fSmrg# func_mode_uninstall arg...
110404642e01fSmrgfunc_mode_uninstall ()
110414642e01fSmrg{
1104235c4bbdfSmrg    $debug_cmd
1104335c4bbdfSmrg
1104435c4bbdfSmrg    RM=$nonopt
1104505b261ecSmrg    files=
1104635c4bbdfSmrg    rmforce=false
1104705b261ecSmrg    exit_status=0
1104805b261ecSmrg
1104905b261ecSmrg    # This variable tells wrapper scripts just to set variables rather
1105005b261ecSmrg    # than running their programs.
1105135c4bbdfSmrg    libtool_install_magic=$magic
1105205b261ecSmrg
1105305b261ecSmrg    for arg
1105405b261ecSmrg    do
1105505b261ecSmrg      case $arg in
1105635c4bbdfSmrg      -f) func_append RM " $arg"; rmforce=: ;;
1105735c4bbdfSmrg      -*) func_append RM " $arg" ;;
1105835c4bbdfSmrg      *) func_append files " $arg" ;;
1105905b261ecSmrg      esac
1106005b261ecSmrg    done
1106105b261ecSmrg
110624642e01fSmrg    test -z "$RM" && \
110634642e01fSmrg      func_fatal_help "you must specify an RM program"
1106405b261ecSmrg
1106505b261ecSmrg    rmdirs=
1106605b261ecSmrg
1106705b261ecSmrg    for file in $files; do
110684642e01fSmrg      func_dirname "$file" "" "."
1106935c4bbdfSmrg      dir=$func_dirname_result
1107035c4bbdfSmrg      if test . = "$dir"; then
1107135c4bbdfSmrg	odir=$objdir
1107205b261ecSmrg      else
1107335c4bbdfSmrg	odir=$dir/$objdir
1107405b261ecSmrg      fi
110754642e01fSmrg      func_basename "$file"
1107635c4bbdfSmrg      name=$func_basename_result
1107735c4bbdfSmrg      test uninstall = "$opt_mode" && odir=$dir
1107805b261ecSmrg
1107935c4bbdfSmrg      # Remember odir for removal later, being careful to avoid duplicates
1108035c4bbdfSmrg      if test clean = "$opt_mode"; then
1108105b261ecSmrg	case " $rmdirs " in
1108235c4bbdfSmrg	  *" $odir "*) ;;
1108335c4bbdfSmrg	  *) func_append rmdirs " $odir" ;;
1108405b261ecSmrg	esac
1108505b261ecSmrg      fi
1108605b261ecSmrg
1108705b261ecSmrg      # Don't error if the file doesn't exist and rm -f was used.
110884642e01fSmrg      if { test -L "$file"; } >/dev/null 2>&1 ||
110894642e01fSmrg	 { test -h "$file"; } >/dev/null 2>&1 ||
110904642e01fSmrg	 test -f "$file"; then
1109105b261ecSmrg	:
1109205b261ecSmrg      elif test -d "$file"; then
1109305b261ecSmrg	exit_status=1
1109405b261ecSmrg	continue
1109535c4bbdfSmrg      elif $rmforce; then
1109605b261ecSmrg	continue
1109705b261ecSmrg      fi
1109805b261ecSmrg
1109935c4bbdfSmrg      rmfiles=$file
1110005b261ecSmrg
1110105b261ecSmrg      case $name in
1110205b261ecSmrg      *.la)
1110305b261ecSmrg	# Possibly a libtool archive, so verify it.
111044642e01fSmrg	if func_lalib_p "$file"; then
111054642e01fSmrg	  func_source $dir/$name
1110605b261ecSmrg
1110705b261ecSmrg	  # Delete the libtool libraries and symlinks.
1110805b261ecSmrg	  for n in $library_names; do
1110935c4bbdfSmrg	    func_append rmfiles " $odir/$n"
1111005b261ecSmrg	  done
1111135c4bbdfSmrg	  test -n "$old_library" && func_append rmfiles " $odir/$old_library"
1111205b261ecSmrg
1111335c4bbdfSmrg	  case $opt_mode in
1111405b261ecSmrg	  clean)
1111535c4bbdfSmrg	    case " $library_names " in
1111605b261ecSmrg	    *" $dlname "*) ;;
1111735c4bbdfSmrg	    *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
1111805b261ecSmrg	    esac
1111935c4bbdfSmrg	    test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
1112005b261ecSmrg	    ;;
1112105b261ecSmrg	  uninstall)
1112205b261ecSmrg	    if test -n "$library_names"; then
1112305b261ecSmrg	      # Do each command in the postuninstall commands.
1112435c4bbdfSmrg	      func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1'
1112505b261ecSmrg	    fi
1112605b261ecSmrg
1112705b261ecSmrg	    if test -n "$old_library"; then
1112805b261ecSmrg	      # Do each command in the old_postuninstall commands.
1112935c4bbdfSmrg	      func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1'
1113005b261ecSmrg	    fi
1113105b261ecSmrg	    # FIXME: should reinstall the best remaining shared library.
1113205b261ecSmrg	    ;;
1113305b261ecSmrg	  esac
1113405b261ecSmrg	fi
1113505b261ecSmrg	;;
1113605b261ecSmrg
1113705b261ecSmrg      *.lo)
1113805b261ecSmrg	# Possibly a libtool object, so verify it.
111394642e01fSmrg	if func_lalib_p "$file"; then
1114005b261ecSmrg
1114105b261ecSmrg	  # Read the .lo file
111424642e01fSmrg	  func_source $dir/$name
1114305b261ecSmrg
1114405b261ecSmrg	  # Add PIC object to the list of files to remove.
1114535c4bbdfSmrg	  if test -n "$pic_object" && test none != "$pic_object"; then
1114635c4bbdfSmrg	    func_append rmfiles " $dir/$pic_object"
1114705b261ecSmrg	  fi
1114805b261ecSmrg
1114905b261ecSmrg	  # Add non-PIC object to the list of files to remove.
1115035c4bbdfSmrg	  if test -n "$non_pic_object" && test none != "$non_pic_object"; then
1115135c4bbdfSmrg	    func_append rmfiles " $dir/$non_pic_object"
1115205b261ecSmrg	  fi
1115305b261ecSmrg	fi
1115405b261ecSmrg	;;
1115505b261ecSmrg
1115605b261ecSmrg      *)
1115735c4bbdfSmrg	if test clean = "$opt_mode"; then
1115805b261ecSmrg	  noexename=$name
1115905b261ecSmrg	  case $file in
1116005b261ecSmrg	  *.exe)
111614642e01fSmrg	    func_stripname '' '.exe' "$file"
111624642e01fSmrg	    file=$func_stripname_result
111634642e01fSmrg	    func_stripname '' '.exe' "$name"
111644642e01fSmrg	    noexename=$func_stripname_result
1116505b261ecSmrg	    # $file with .exe has already been added to rmfiles,
1116605b261ecSmrg	    # add $file without .exe
1116735c4bbdfSmrg	    func_append rmfiles " $file"
1116805b261ecSmrg	    ;;
1116905b261ecSmrg	  esac
1117005b261ecSmrg	  # Do a test to see if this is a libtool program.
111714642e01fSmrg	  if func_ltwrapper_p "$file"; then
111724642e01fSmrg	    if func_ltwrapper_executable_p "$file"; then
111734642e01fSmrg	      func_ltwrapper_scriptname "$file"
111744642e01fSmrg	      relink_command=
111754642e01fSmrg	      func_source $func_ltwrapper_scriptname_result
1117635c4bbdfSmrg	      func_append rmfiles " $func_ltwrapper_scriptname_result"
111774642e01fSmrg	    else
111784642e01fSmrg	      relink_command=
111794642e01fSmrg	      func_source $dir/$noexename
111804642e01fSmrg	    fi
1118105b261ecSmrg
1118205b261ecSmrg	    # note $name still contains .exe if it was in $file originally
1118305b261ecSmrg	    # as does the version of $file that was added into $rmfiles
1118435c4bbdfSmrg	    func_append rmfiles " $odir/$name $odir/${name}S.$objext"
1118535c4bbdfSmrg	    if test yes = "$fast_install" && test -n "$relink_command"; then
1118635c4bbdfSmrg	      func_append rmfiles " $odir/lt-$name"
1118705b261ecSmrg	    fi
1118835c4bbdfSmrg	    if test "X$noexename" != "X$name"; then
1118935c4bbdfSmrg	      func_append rmfiles " $odir/lt-$noexename.c"
1119005b261ecSmrg	    fi
1119105b261ecSmrg	  fi
1119205b261ecSmrg	fi
1119305b261ecSmrg	;;
1119405b261ecSmrg      esac
111954642e01fSmrg      func_show_eval "$RM $rmfiles" 'exit_status=1'
1119605b261ecSmrg    done
1119705b261ecSmrg
1119835c4bbdfSmrg    # Try to remove the $objdir's in the directories where we deleted files
1119905b261ecSmrg    for dir in $rmdirs; do
1120005b261ecSmrg      if test -d "$dir"; then
112014642e01fSmrg	func_show_eval "rmdir $dir >/dev/null 2>&1"
1120205b261ecSmrg      fi
1120305b261ecSmrg    done
1120405b261ecSmrg
1120505b261ecSmrg    exit $exit_status
112064642e01fSmrg}
1120705b261ecSmrg
1120835c4bbdfSmrgif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then
1120935c4bbdfSmrg  func_mode_uninstall ${1+"$@"}
1121035c4bbdfSmrgfi
1121105b261ecSmrg
1121235c4bbdfSmrgtest -z "$opt_mode" && {
1121335c4bbdfSmrg  help=$generic_help
112144642e01fSmrg  func_fatal_help "you must specify a MODE"
112154642e01fSmrg}
112164642e01fSmrg
112174642e01fSmrgtest -z "$exec_cmd" && \
1121835c4bbdfSmrg  func_fatal_help "invalid operation mode '$opt_mode'"
1121905b261ecSmrg
1122005b261ecSmrgif test -n "$exec_cmd"; then
112214642e01fSmrg  eval exec "$exec_cmd"
1122205b261ecSmrg  exit $EXIT_FAILURE
1122305b261ecSmrgfi
1122405b261ecSmrg
112254642e01fSmrgexit $exit_status
1122605b261ecSmrg
1122705b261ecSmrg
1122805b261ecSmrg# The TAGs below are defined such that we never get into a situation
1122935c4bbdfSmrg# where we disable both kinds of libraries.  Given conflicting
1123005b261ecSmrg# choices, we go for a static library, that is the most portable,
1123105b261ecSmrg# since we can't tell whether shared libraries were disabled because
1123205b261ecSmrg# the user asked for that or because the platform doesn't support
1123305b261ecSmrg# them.  This is particularly important on AIX, because we don't
1123405b261ecSmrg# support having both static and shared libraries enabled at the same
1123505b261ecSmrg# time on that platform, so we default to a shared-only configuration.
1123605b261ecSmrg# If a disable-shared tag is given, we'll fallback to a static-only
1123705b261ecSmrg# configuration.  But we'll never go from static-only to shared-only.
1123805b261ecSmrg
1123905b261ecSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
112404642e01fSmrgbuild_libtool_libs=no
112414642e01fSmrgbuild_old_libs=yes
1124205b261ecSmrg# ### END LIBTOOL TAG CONFIG: disable-shared
1124305b261ecSmrg
1124405b261ecSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static
112454642e01fSmrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
1124605b261ecSmrg# ### END LIBTOOL TAG CONFIG: disable-static
1124705b261ecSmrg
1124805b261ecSmrg# Local Variables:
1124905b261ecSmrg# mode:shell-script
1125005b261ecSmrg# sh-indentation:2
1125105b261ecSmrg# End:
11252