ltmain.sh revision d422ce2e
1d422ce2eSmrg#! /usr/bin/env sh
26257f37dSmrg## DO NOT EDIT - This file generated from ./build-aux/ltmain.in
3d422ce2eSmrg##               by inline-source v2019-02-19.15
4f3561b8bSmrg
5d422ce2eSmrg# libtool (GNU libtool) 2.4.7
66257f37dSmrg# Provide generalized library-building support services.
7f3561b8bSmrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
8f3561b8bSmrg
9d422ce2eSmrg# Copyright (C) 1996-2019, 2021-2022 Free Software Foundation, Inc.
10f3561b8bSmrg# This is free software; see the source for copying conditions.  There is NO
11f3561b8bSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12f3561b8bSmrg
13f3561b8bSmrg# GNU Libtool is free software; you can redistribute it and/or modify
14fc5a983dSmrg# it under the terms of the GNU General Public License as published by
15fc5a983dSmrg# the Free Software Foundation; either version 2 of the License, or
16fc5a983dSmrg# (at your option) any later version.
17fc5a983dSmrg#
18f3561b8bSmrg# As a special exception to the GNU General Public License,
19f3561b8bSmrg# if you distribute this file as part of a program or library that
20f3561b8bSmrg# is built using GNU Libtool, you may include this file under the
21f3561b8bSmrg# same distribution terms that you use for the rest of that program.
22f3561b8bSmrg#
23f3561b8bSmrg# GNU Libtool is distributed in the hope that it will be useful, but
24fc5a983dSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of
25fc5a983dSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
26fc5a983dSmrg# General Public License for more details.
27fc5a983dSmrg#
28fc5a983dSmrg# You should have received a copy of the GNU General Public License
296257f37dSmrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
30fc5a983dSmrg
31fc5a983dSmrg
32bd304fc0SmrgPROGRAM=libtool
33fc5a983dSmrgPACKAGE=libtool
34d422ce2eSmrgVERSION=2.4.7
35d422ce2eSmrgpackage_revision=2.4.7
36fc5a983dSmrg
376257f37dSmrg
386257f37dSmrg## ------ ##
396257f37dSmrg## Usage. ##
406257f37dSmrg## ------ ##
416257f37dSmrg
426257f37dSmrg# Run './libtool --help' for help with using this script from the
436257f37dSmrg# command line.
446257f37dSmrg
456257f37dSmrg
466257f37dSmrg## ------------------------------- ##
476257f37dSmrg## User overridable command paths. ##
486257f37dSmrg## ------------------------------- ##
496257f37dSmrg
506257f37dSmrg# After configure completes, it has a better idea of some of the
516257f37dSmrg# shell tools we need than the defaults used by the functions shared
526257f37dSmrg# with bootstrap, so set those here where they can still be over-
536257f37dSmrg# ridden by the user, but otherwise take precedence.
546257f37dSmrg
556257f37dSmrg: ${AUTOCONF="autoconf"}
566257f37dSmrg: ${AUTOMAKE="automake"}
576257f37dSmrg
586257f37dSmrg
596257f37dSmrg## -------------------------- ##
606257f37dSmrg## Source external libraries. ##
616257f37dSmrg## -------------------------- ##
626257f37dSmrg
636257f37dSmrg# Much of our low-level functionality needs to be sourced from external
646257f37dSmrg# libraries, which are installed to $pkgauxdir.
656257f37dSmrg
666257f37dSmrg# Set a version string for this script.
67d422ce2eSmrgscriptversion=2019-02-19.15; # UTC
686257f37dSmrg
696257f37dSmrg# General shell script boiler plate, and helper functions.
706257f37dSmrg# Written by Gary V. Vaughan, 2004
716257f37dSmrg
72d422ce2eSmrg# This is free software.  There is NO warranty; not even for
73d422ce2eSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
74d422ce2eSmrg#
75d422ce2eSmrg# Copyright (C) 2004-2019, 2021 Bootstrap Authors
76d422ce2eSmrg#
77d422ce2eSmrg# This file is dual licensed under the terms of the MIT license
78d422ce2eSmrg# <https://opensource.org/license/MIT>, and GPL version 2 or later
79d422ce2eSmrg# <http://www.gnu.org/licenses/gpl-2.0.html>.  You must apply one of
80d422ce2eSmrg# these licenses when using or redistributing this software or any of
81d422ce2eSmrg# the files within it.  See the URLs above, or the file `LICENSE`
82d422ce2eSmrg# included in the Bootstrap distribution for the full license texts.
836257f37dSmrg
84d422ce2eSmrg# Please report bugs or propose patches to:
85d422ce2eSmrg# <https://github.com/gnulib-modules/bootstrap/issues>
866257f37dSmrg
876257f37dSmrg
886257f37dSmrg## ------ ##
896257f37dSmrg## Usage. ##
906257f37dSmrg## ------ ##
916257f37dSmrg
926257f37dSmrg# Evaluate this file near the top of your script to gain access to
936257f37dSmrg# the functions and variables defined here:
946257f37dSmrg#
956257f37dSmrg#   . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh
966257f37dSmrg#
976257f37dSmrg# If you need to override any of the default environment variable
986257f37dSmrg# settings, do that before evaluating this file.
996257f37dSmrg
1006257f37dSmrg
1016257f37dSmrg## -------------------- ##
1026257f37dSmrg## Shell normalisation. ##
1036257f37dSmrg## -------------------- ##
1046257f37dSmrg
1056257f37dSmrg# Some shells need a little help to be as Bourne compatible as possible.
1066257f37dSmrg# Before doing anything else, make sure all that help has been provided!
1076257f37dSmrg
1086257f37dSmrgDUALCASE=1; export DUALCASE # for MKS sh
1096257f37dSmrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
110fc5a983dSmrg  emulate sh
111fc5a983dSmrg  NULLCMD=:
1126257f37dSmrg  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
113fc5a983dSmrg  # is contrary to our usage.  Disable this feature.
114fc5a983dSmrg  alias -g '${1+"$@"}'='"$@"'
115fc5a983dSmrg  setopt NO_GLOB_SUBST
116fc5a983dSmrgelse
1176257f37dSmrg  case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac
118fc5a983dSmrgfi
119bd304fc0Smrg
1206257f37dSmrg# NLS nuisances: We save the old values in case they are required later.
1216257f37dSmrg_G_user_locale=
1226257f37dSmrg_G_safe_locale=
1236257f37dSmrgfor _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
124fc5a983dSmrgdo
1256257f37dSmrg  eval "if test set = \"\${$_G_var+set}\"; then
1266257f37dSmrg          save_$_G_var=\$$_G_var
1276257f37dSmrg          $_G_var=C
1286257f37dSmrg	  export $_G_var
1296257f37dSmrg	  _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\"
1306257f37dSmrg	  _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\"
131fc5a983dSmrg	fi"
132fc5a983dSmrgdone
133d422ce2eSmrg# These NLS vars are set unconditionally (bootstrap issue #24).  Unset those
134d422ce2eSmrg# in case the environment reset is needed later and the $save_* variant is not
135d422ce2eSmrg# defined (see the code above).
136d422ce2eSmrgLC_ALL=C
137d422ce2eSmrgLANGUAGE=C
138d422ce2eSmrgexport LANGUAGE LC_ALL
139f3561b8bSmrg
1406257f37dSmrg# Make sure IFS has a sensible default
1416257f37dSmrgsp=' '
1426257f37dSmrgnl='
1436257f37dSmrg'
1446257f37dSmrgIFS="$sp	$nl"
1456257f37dSmrg
1466257f37dSmrg# There are apparently some retarded systems that use ';' as a PATH separator!
1476257f37dSmrgif test "${PATH_SEPARATOR+set}" != set; then
1486257f37dSmrg  PATH_SEPARATOR=:
1496257f37dSmrg  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
1506257f37dSmrg    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
1516257f37dSmrg      PATH_SEPARATOR=';'
1526257f37dSmrg  }
1536257f37dSmrgfi
154f3561b8bSmrg
155f3561b8bSmrg
156d422ce2eSmrg# func_unset VAR
157d422ce2eSmrg# --------------
158d422ce2eSmrg# Portably unset VAR.
159d422ce2eSmrg# In some shells, an 'unset VAR' statement leaves a non-zero return
160d422ce2eSmrg# status if VAR is already unset, which might be problematic if the
161d422ce2eSmrg# statement is used at the end of a function (thus poisoning its return
162d422ce2eSmrg# value) or when 'set -e' is active (causing even a spurious abort of
163d422ce2eSmrg# the script in this case).
164d422ce2eSmrgfunc_unset ()
165d422ce2eSmrg{
166d422ce2eSmrg    { eval $1=; (eval unset $1) >/dev/null 2>&1 && eval unset $1 || : ; }
167d422ce2eSmrg}
168d422ce2eSmrg
169d422ce2eSmrg
170d422ce2eSmrg# Make sure CDPATH doesn't cause `cd` commands to output the target dir.
171d422ce2eSmrgfunc_unset CDPATH
172d422ce2eSmrg
173d422ce2eSmrg# Make sure ${,E,F}GREP behave sanely.
174d422ce2eSmrgfunc_unset GREP_OPTIONS
175d422ce2eSmrg
176f3561b8bSmrg
1776257f37dSmrg## ------------------------- ##
1786257f37dSmrg## Locate command utilities. ##
1796257f37dSmrg## ------------------------- ##
1806257f37dSmrg
1816257f37dSmrg
1826257f37dSmrg# func_executable_p FILE
1836257f37dSmrg# ----------------------
1846257f37dSmrg# Check that FILE is an executable regular file.
1856257f37dSmrgfunc_executable_p ()
1866257f37dSmrg{
1876257f37dSmrg    test -f "$1" && test -x "$1"
1886257f37dSmrg}
1896257f37dSmrg
1906257f37dSmrg
1916257f37dSmrg# func_path_progs PROGS_LIST CHECK_FUNC [PATH]
1926257f37dSmrg# --------------------------------------------
1936257f37dSmrg# Search for either a program that responds to --version with output
1946257f37dSmrg# containing "GNU", or else returned by CHECK_FUNC otherwise, by
1956257f37dSmrg# trying all the directories in PATH with each of the elements of
1966257f37dSmrg# PROGS_LIST.
1976257f37dSmrg#
1986257f37dSmrg# CHECK_FUNC should accept the path to a candidate program, and
1996257f37dSmrg# set $func_check_prog_result if it truncates its output less than
2006257f37dSmrg# $_G_path_prog_max characters.
2016257f37dSmrgfunc_path_progs ()
2026257f37dSmrg{
2036257f37dSmrg    _G_progs_list=$1
2046257f37dSmrg    _G_check_func=$2
2056257f37dSmrg    _G_PATH=${3-"$PATH"}
2066257f37dSmrg
2076257f37dSmrg    _G_path_prog_max=0
2086257f37dSmrg    _G_path_prog_found=false
2096257f37dSmrg    _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:}
2106257f37dSmrg    for _G_dir in $_G_PATH; do
2116257f37dSmrg      IFS=$_G_save_IFS
2126257f37dSmrg      test -z "$_G_dir" && _G_dir=.
2136257f37dSmrg      for _G_prog_name in $_G_progs_list; do
2146257f37dSmrg        for _exeext in '' .EXE; do
2156257f37dSmrg          _G_path_prog=$_G_dir/$_G_prog_name$_exeext
2166257f37dSmrg          func_executable_p "$_G_path_prog" || continue
2176257f37dSmrg          case `"$_G_path_prog" --version 2>&1` in
2186257f37dSmrg            *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;;
2196257f37dSmrg            *)     $_G_check_func $_G_path_prog
2206257f37dSmrg		   func_path_progs_result=$func_check_prog_result
2216257f37dSmrg		   ;;
2226257f37dSmrg          esac
2236257f37dSmrg          $_G_path_prog_found && break 3
2246257f37dSmrg        done
2256257f37dSmrg      done
2266257f37dSmrg    done
2276257f37dSmrg    IFS=$_G_save_IFS
2286257f37dSmrg    test -z "$func_path_progs_result" && {
2296257f37dSmrg      echo "no acceptable sed could be found in \$PATH" >&2
2306257f37dSmrg      exit 1
2316257f37dSmrg    }
2326257f37dSmrg}
2336257f37dSmrg
2346257f37dSmrg
2356257f37dSmrg# We want to be able to use the functions in this file before configure
2366257f37dSmrg# has figured out where the best binaries are kept, which means we have
2376257f37dSmrg# to search for them ourselves - except when the results are already set
2386257f37dSmrg# where we skip the searches.
2396257f37dSmrg
2406257f37dSmrg# Unless the user overrides by setting SED, search the path for either GNU
2416257f37dSmrg# sed, or the sed that truncates its output the least.
2426257f37dSmrgtest -z "$SED" && {
2436257f37dSmrg  _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
2446257f37dSmrg  for _G_i in 1 2 3 4 5 6 7; do
2456257f37dSmrg    _G_sed_script=$_G_sed_script$nl$_G_sed_script
2466257f37dSmrg  done
2476257f37dSmrg  echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed
2486257f37dSmrg  _G_sed_script=
2496257f37dSmrg
2506257f37dSmrg  func_check_prog_sed ()
2516257f37dSmrg  {
2526257f37dSmrg    _G_path_prog=$1
2536257f37dSmrg
2546257f37dSmrg    _G_count=0
2556257f37dSmrg    printf 0123456789 >conftest.in
2566257f37dSmrg    while :
2576257f37dSmrg    do
2586257f37dSmrg      cat conftest.in conftest.in >conftest.tmp
2596257f37dSmrg      mv conftest.tmp conftest.in
2606257f37dSmrg      cp conftest.in conftest.nl
2616257f37dSmrg      echo '' >> conftest.nl
2626257f37dSmrg      "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break
2636257f37dSmrg      diff conftest.out conftest.nl >/dev/null 2>&1 || break
2646257f37dSmrg      _G_count=`expr $_G_count + 1`
2656257f37dSmrg      if test "$_G_count" -gt "$_G_path_prog_max"; then
2666257f37dSmrg        # Best one so far, save it but keep looking for a better one
2676257f37dSmrg        func_check_prog_result=$_G_path_prog
2686257f37dSmrg        _G_path_prog_max=$_G_count
2696257f37dSmrg      fi
2706257f37dSmrg      # 10*(2^10) chars as input seems more than enough
2716257f37dSmrg      test 10 -lt "$_G_count" && break
2726257f37dSmrg    done
2736257f37dSmrg    rm -f conftest.in conftest.tmp conftest.nl conftest.out
2746257f37dSmrg  }
2756257f37dSmrg
276d422ce2eSmrg  func_path_progs "sed gsed" func_check_prog_sed "$PATH:/usr/xpg4/bin"
2776257f37dSmrg  rm -f conftest.sed
2786257f37dSmrg  SED=$func_path_progs_result
2796257f37dSmrg}
2806257f37dSmrg
2816257f37dSmrg
2826257f37dSmrg# Unless the user overrides by setting GREP, search the path for either GNU
2836257f37dSmrg# grep, or the grep that truncates its output the least.
2846257f37dSmrgtest -z "$GREP" && {
2856257f37dSmrg  func_check_prog_grep ()
2866257f37dSmrg  {
2876257f37dSmrg    _G_path_prog=$1
2886257f37dSmrg
2896257f37dSmrg    _G_count=0
2906257f37dSmrg    _G_path_prog_max=0
2916257f37dSmrg    printf 0123456789 >conftest.in
2926257f37dSmrg    while :
2936257f37dSmrg    do
2946257f37dSmrg      cat conftest.in conftest.in >conftest.tmp
2956257f37dSmrg      mv conftest.tmp conftest.in
2966257f37dSmrg      cp conftest.in conftest.nl
2976257f37dSmrg      echo 'GREP' >> conftest.nl
2986257f37dSmrg      "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break
2996257f37dSmrg      diff conftest.out conftest.nl >/dev/null 2>&1 || break
3006257f37dSmrg      _G_count=`expr $_G_count + 1`
3016257f37dSmrg      if test "$_G_count" -gt "$_G_path_prog_max"; then
3026257f37dSmrg        # Best one so far, save it but keep looking for a better one
3036257f37dSmrg        func_check_prog_result=$_G_path_prog
3046257f37dSmrg        _G_path_prog_max=$_G_count
3056257f37dSmrg      fi
3066257f37dSmrg      # 10*(2^10) chars as input seems more than enough
3076257f37dSmrg      test 10 -lt "$_G_count" && break
3086257f37dSmrg    done
3096257f37dSmrg    rm -f conftest.in conftest.tmp conftest.nl conftest.out
3106257f37dSmrg  }
3116257f37dSmrg
312d422ce2eSmrg  func_path_progs "grep ggrep" func_check_prog_grep "$PATH:/usr/xpg4/bin"
3136257f37dSmrg  GREP=$func_path_progs_result
3146257f37dSmrg}
3156257f37dSmrg
3166257f37dSmrg
3176257f37dSmrg## ------------------------------- ##
3186257f37dSmrg## User overridable command paths. ##
3196257f37dSmrg## ------------------------------- ##
3206257f37dSmrg
3216257f37dSmrg# All uppercase variable names are used for environment variables.  These
3226257f37dSmrg# variables can be overridden by the user before calling a script that
3236257f37dSmrg# uses them if a suitable command of that name is not already available
3246257f37dSmrg# in the command search PATH.
325f3561b8bSmrg
326f3561b8bSmrg: ${CP="cp -f"}
3276257f37dSmrg: ${ECHO="printf %s\n"}
3286257f37dSmrg: ${EGREP="$GREP -E"}
3296257f37dSmrg: ${FGREP="$GREP -F"}
3306257f37dSmrg: ${LN_S="ln -s"}
331f3561b8bSmrg: ${MAKE="make"}
332f3561b8bSmrg: ${MKDIR="mkdir"}
333f3561b8bSmrg: ${MV="mv -f"}
334f3561b8bSmrg: ${RM="rm -f"}
335f3561b8bSmrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
336fc5a983dSmrg
337f3561b8bSmrg
3386257f37dSmrg## -------------------- ##
3396257f37dSmrg## Useful sed snippets. ##
3406257f37dSmrg## -------------------- ##
341bd304fc0Smrg
3426257f37dSmrgsed_dirname='s|/[^/]*$||'
3436257f37dSmrgsed_basename='s|^.*/||'
344bd304fc0Smrg
3456257f37dSmrg# Sed substitution that helps us do robust quoting.  It backslashifies
3466257f37dSmrg# metacharacters that are still active within double-quoted strings.
3476257f37dSmrgsed_quote_subst='s|\([`"$\\]\)|\\\1|g'
348bd304fc0Smrg
3496257f37dSmrg# Same as above, but do not quote variable references.
3506257f37dSmrgsed_double_quote_subst='s/\(["`\\]\)/\\\1/g'
351bd304fc0Smrg
3526257f37dSmrg# Sed substitution that turns a string into a regex matching for the
3536257f37dSmrg# string literally.
3546257f37dSmrgsed_make_literal_regex='s|[].[^$\\*\/]|\\&|g'
355bd304fc0Smrg
3566257f37dSmrg# Sed substitution that converts a w32 file name or path
3576257f37dSmrg# that contains forward slashes, into one that contains
3586257f37dSmrg# (escaped) backslashes.  A very naive implementation.
3596257f37dSmrgsed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
3606257f37dSmrg
3616257f37dSmrg# Re-'\' parameter expansions in output of sed_double_quote_subst that
3626257f37dSmrg# were '\'-ed in input to the same.  If an odd number of '\' preceded a
3636257f37dSmrg# '$' in input to sed_double_quote_subst, that '$' was protected from
3646257f37dSmrg# expansion.  Since each input '\' is now two '\'s, look for any number
3656257f37dSmrg# of runs of four '\'s followed by two '\'s and then a '$'.  '\' that '$'.
3666257f37dSmrg_G_bs='\\'
3676257f37dSmrg_G_bs2='\\\\'
3686257f37dSmrg_G_bs4='\\\\\\\\'
3696257f37dSmrg_G_dollar='\$'
3706257f37dSmrgsed_double_backslash="\
3716257f37dSmrg  s/$_G_bs4/&\\
3726257f37dSmrg/g
3736257f37dSmrg  s/^$_G_bs2$_G_dollar/$_G_bs&/
3746257f37dSmrg  s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g
3756257f37dSmrg  s/\n//g"
376bd304fc0Smrg
377d422ce2eSmrg# require_check_ifs_backslash
378d422ce2eSmrg# ---------------------------
379d422ce2eSmrg# Check if we can use backslash as IFS='\' separator, and set
380d422ce2eSmrg# $check_ifs_backshlash_broken to ':' or 'false'.
381d422ce2eSmrgrequire_check_ifs_backslash=func_require_check_ifs_backslash
382d422ce2eSmrgfunc_require_check_ifs_backslash ()
383d422ce2eSmrg{
384d422ce2eSmrg  _G_save_IFS=$IFS
385d422ce2eSmrg  IFS='\'
386d422ce2eSmrg  _G_check_ifs_backshlash='a\\b'
387d422ce2eSmrg  for _G_i in $_G_check_ifs_backshlash
388d422ce2eSmrg  do
389d422ce2eSmrg  case $_G_i in
390d422ce2eSmrg  a)
391d422ce2eSmrg    check_ifs_backshlash_broken=false
392d422ce2eSmrg    ;;
393d422ce2eSmrg  '')
394d422ce2eSmrg    break
395d422ce2eSmrg    ;;
396d422ce2eSmrg  *)
397d422ce2eSmrg    check_ifs_backshlash_broken=:
398d422ce2eSmrg    break
399d422ce2eSmrg    ;;
400d422ce2eSmrg  esac
401d422ce2eSmrg  done
402d422ce2eSmrg  IFS=$_G_save_IFS
403d422ce2eSmrg  require_check_ifs_backslash=:
404d422ce2eSmrg}
405d422ce2eSmrg
406bd304fc0Smrg
4076257f37dSmrg## ----------------- ##
4086257f37dSmrg## Global variables. ##
4096257f37dSmrg## ----------------- ##
410bd304fc0Smrg
4116257f37dSmrg# Except for the global variables explicitly listed below, the following
4126257f37dSmrg# functions in the '^func_' namespace, and the '^require_' namespace
4136257f37dSmrg# variables initialised in the 'Resource management' section, sourcing
4146257f37dSmrg# this file will not pollute your global namespace with anything
4156257f37dSmrg# else. There's no portable way to scope variables in Bourne shell
4166257f37dSmrg# though, so actually running these functions will sometimes place
4176257f37dSmrg# results into a variable named after the function, and often use
4186257f37dSmrg# temporary variables in the '^_G_' namespace. If you are careful to
4196257f37dSmrg# avoid using those namespaces casually in your sourcing script, things
4206257f37dSmrg# should continue to work as you expect. And, of course, you can freely
4216257f37dSmrg# overwrite any of the functions or variables defined here before
4226257f37dSmrg# calling anything to customize them.
423bd304fc0Smrg
4246257f37dSmrgEXIT_SUCCESS=0
4256257f37dSmrgEXIT_FAILURE=1
4266257f37dSmrgEXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
4276257f37dSmrgEXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
428fc5a983dSmrg
4296257f37dSmrg# Allow overriding, eg assuming that you follow the convention of
4306257f37dSmrg# putting '$debug_cmd' at the start of all your functions, you can get
4316257f37dSmrg# bash to show function call trace with:
4326257f37dSmrg#
4336257f37dSmrg#    debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name
4346257f37dSmrgdebug_cmd=${debug_cmd-":"}
4356257f37dSmrgexit_cmd=:
436f3561b8bSmrg
4376257f37dSmrg# By convention, finish your script with:
4386257f37dSmrg#
4396257f37dSmrg#    exit $exit_status
4406257f37dSmrg#
4416257f37dSmrg# so that you can set exit_status to non-zero if you want to indicate
4426257f37dSmrg# something went wrong during execution without actually bailing out at
4436257f37dSmrg# the point of failure.
4446257f37dSmrgexit_status=$EXIT_SUCCESS
445bd304fc0Smrg
4466257f37dSmrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
4476257f37dSmrg# is ksh but when the shell is invoked as "sh" and the current value of
4486257f37dSmrg# the _XPG environment variable is not equal to 1 (one), the special
4496257f37dSmrg# positional parameter $0, within a function call, is the name of the
4506257f37dSmrg# function.
4516257f37dSmrgprogpath=$0
452f3561b8bSmrg
4536257f37dSmrg# The name of this program.
4546257f37dSmrgprogname=`$ECHO "$progpath" |$SED "$sed_basename"`
455f3561b8bSmrg
4566257f37dSmrg# Make sure we have an absolute progpath for reexecution:
457f3561b8bSmrgcase $progpath in
458f3561b8bSmrg  [\\/]*|[A-Za-z]:\\*) ;;
459f3561b8bSmrg  *[\\/]*)
4606257f37dSmrg     progdir=`$ECHO "$progpath" |$SED "$sed_dirname"`
461f3561b8bSmrg     progdir=`cd "$progdir" && pwd`
4626257f37dSmrg     progpath=$progdir/$progname
463f3561b8bSmrg     ;;
464f3561b8bSmrg  *)
4656257f37dSmrg     _G_IFS=$IFS
466bd304fc0Smrg     IFS=${PATH_SEPARATOR-:}
467f3561b8bSmrg     for progdir in $PATH; do
4686257f37dSmrg       IFS=$_G_IFS
469f3561b8bSmrg       test -x "$progdir/$progname" && break
470f3561b8bSmrg     done
4716257f37dSmrg     IFS=$_G_IFS
472f3561b8bSmrg     test -n "$progdir" || progdir=`pwd`
4736257f37dSmrg     progpath=$progdir/$progname
474f3561b8bSmrg     ;;
475f3561b8bSmrgesac
476f3561b8bSmrg
477f3561b8bSmrg
4786257f37dSmrg## ----------------- ##
4796257f37dSmrg## Standard options. ##
4806257f37dSmrg## ----------------- ##
481bd304fc0Smrg
4826257f37dSmrg# The following options affect the operation of the functions defined
4836257f37dSmrg# below, and should be set appropriately depending on run-time para-
4846257f37dSmrg# meters passed on the command line.
485f3561b8bSmrg
486f3561b8bSmrgopt_dry_run=false
487f3561b8bSmrgopt_quiet=false
488f3561b8bSmrgopt_verbose=false
489f3561b8bSmrg
4906257f37dSmrg# Categories 'all' and 'none' are always available.  Append any others
4916257f37dSmrg# you will pass as the first argument to func_warning from your own
4926257f37dSmrg# code.
4936257f37dSmrgwarning_categories=
494f3561b8bSmrg
4956257f37dSmrg# By default, display warnings according to 'opt_warning_types'.  Set
4966257f37dSmrg# 'warning_func'  to ':' to elide all warnings, or func_fatal_error to
4976257f37dSmrg# treat the next displayed warning as a fatal error.
4986257f37dSmrgwarning_func=func_warn_and_continue
499f3561b8bSmrg
5006257f37dSmrg# Set to 'all' to display all warnings, 'none' to suppress all
5016257f37dSmrg# warnings, or a space delimited list of some subset of
5026257f37dSmrg# 'warning_categories' to display only the listed warnings.
5036257f37dSmrgopt_warning_types=all
504f3561b8bSmrg
505bd304fc0Smrg
5066257f37dSmrg## -------------------- ##
5076257f37dSmrg## Resource management. ##
5086257f37dSmrg## -------------------- ##
509f3561b8bSmrg
5106257f37dSmrg# This section contains definitions for functions that each ensure a
5116257f37dSmrg# particular resource (a file, or a non-empty configuration variable for
5126257f37dSmrg# example) is available, and if appropriate to extract default values
5136257f37dSmrg# from pertinent package files. Call them using their associated
5146257f37dSmrg# 'require_*' variable to ensure that they are executed, at most, once.
5156257f37dSmrg#
5166257f37dSmrg# It's entirely deliberate that calling these functions can set
5176257f37dSmrg# variables that don't obey the namespace limitations obeyed by the rest
5186257f37dSmrg# of this file, in order that that they be as useful as possible to
5196257f37dSmrg# callers.
520f3561b8bSmrg
521f3561b8bSmrg
5226257f37dSmrg# require_term_colors
5236257f37dSmrg# -------------------
5246257f37dSmrg# Allow display of bold text on terminals that support it.
5256257f37dSmrgrequire_term_colors=func_require_term_colors
5266257f37dSmrgfunc_require_term_colors ()
527f3561b8bSmrg{
5286257f37dSmrg    $debug_cmd
5296257f37dSmrg
5306257f37dSmrg    test -t 1 && {
5316257f37dSmrg      # COLORTERM and USE_ANSI_COLORS environment variables take
5326257f37dSmrg      # precedence, because most terminfo databases neglect to describe
5336257f37dSmrg      # whether color sequences are supported.
5346257f37dSmrg      test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"}
5356257f37dSmrg
5366257f37dSmrg      if test 1 = "$USE_ANSI_COLORS"; then
5376257f37dSmrg        # Standard ANSI escape sequences
5386257f37dSmrg        tc_reset='[0m'
5396257f37dSmrg        tc_bold='[1m';   tc_standout='[7m'
5406257f37dSmrg        tc_red='[31m';   tc_green='[32m'
5416257f37dSmrg        tc_blue='[34m';  tc_cyan='[36m'
5426257f37dSmrg      else
5436257f37dSmrg        # Otherwise trust the terminfo database after all.
5446257f37dSmrg        test -n "`tput sgr0 2>/dev/null`" && {
5456257f37dSmrg          tc_reset=`tput sgr0`
5466257f37dSmrg          test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold`
5476257f37dSmrg          tc_standout=$tc_bold
5486257f37dSmrg          test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso`
5496257f37dSmrg          test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1`
5506257f37dSmrg          test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2`
5516257f37dSmrg          test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4`
5526257f37dSmrg          test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5`
5536257f37dSmrg        }
5546257f37dSmrg      fi
5556257f37dSmrg    }
556f3561b8bSmrg
5576257f37dSmrg    require_term_colors=:
558f3561b8bSmrg}
559f3561b8bSmrg
560f3561b8bSmrg
5616257f37dSmrg## ----------------- ##
5626257f37dSmrg## Function library. ##
5636257f37dSmrg## ----------------- ##
5646257f37dSmrg
5656257f37dSmrg# This section contains a variety of useful functions to call in your
5666257f37dSmrg# scripts. Take note of the portable wrappers for features provided by
5676257f37dSmrg# some modern shells, which will fall back to slower equivalents on
5686257f37dSmrg# less featureful shells.
5696257f37dSmrg
5706257f37dSmrg
5716257f37dSmrg# func_append VAR VALUE
5726257f37dSmrg# ---------------------
5736257f37dSmrg# Append VALUE onto the existing contents of VAR.
5746257f37dSmrg
5756257f37dSmrg  # We should try to minimise forks, especially on Windows where they are
5766257f37dSmrg  # unreasonably slow, so skip the feature probes when bash or zsh are
5776257f37dSmrg  # being used:
5786257f37dSmrg  if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then
5796257f37dSmrg    : ${_G_HAVE_ARITH_OP="yes"}
5806257f37dSmrg    : ${_G_HAVE_XSI_OPS="yes"}
5816257f37dSmrg    # The += operator was introduced in bash 3.1
5826257f37dSmrg    case $BASH_VERSION in
5836257f37dSmrg      [12].* | 3.0 | 3.0*) ;;
5846257f37dSmrg      *)
5856257f37dSmrg        : ${_G_HAVE_PLUSEQ_OP="yes"}
5866257f37dSmrg        ;;
5876257f37dSmrg    esac
5886257f37dSmrg  fi
5896257f37dSmrg
5906257f37dSmrg  # _G_HAVE_PLUSEQ_OP
5916257f37dSmrg  # Can be empty, in which case the shell is probed, "yes" if += is
5926257f37dSmrg  # useable or anything else if it does not work.
5936257f37dSmrg  test -z "$_G_HAVE_PLUSEQ_OP" \
5946257f37dSmrg    && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \
5956257f37dSmrg    && _G_HAVE_PLUSEQ_OP=yes
5966257f37dSmrg
5976257f37dSmrgif test yes = "$_G_HAVE_PLUSEQ_OP"
5986257f37dSmrgthen
5996257f37dSmrg  # This is an XSI compatible shell, allowing a faster implementation...
6006257f37dSmrg  eval 'func_append ()
6016257f37dSmrg  {
6026257f37dSmrg    $debug_cmd
6036257f37dSmrg
6046257f37dSmrg    eval "$1+=\$2"
6056257f37dSmrg  }'
6066257f37dSmrgelse
6076257f37dSmrg  # ...otherwise fall back to using expr, which is often a shell builtin.
6086257f37dSmrg  func_append ()
6096257f37dSmrg  {
6106257f37dSmrg    $debug_cmd
6116257f37dSmrg
6126257f37dSmrg    eval "$1=\$$1\$2"
6136257f37dSmrg  }
6146257f37dSmrgfi
6156257f37dSmrg
6166257f37dSmrg
6176257f37dSmrg# func_append_quoted VAR VALUE
6186257f37dSmrg# ----------------------------
6196257f37dSmrg# Quote VALUE and append to the end of shell variable VAR, separated
6206257f37dSmrg# by a space.
6216257f37dSmrgif test yes = "$_G_HAVE_PLUSEQ_OP"; then
6226257f37dSmrg  eval 'func_append_quoted ()
6236257f37dSmrg  {
6246257f37dSmrg    $debug_cmd
6256257f37dSmrg
626d422ce2eSmrg    func_quote_arg pretty "$2"
627d422ce2eSmrg    eval "$1+=\\ \$func_quote_arg_result"
6286257f37dSmrg  }'
6296257f37dSmrgelse
6306257f37dSmrg  func_append_quoted ()
6316257f37dSmrg  {
6326257f37dSmrg    $debug_cmd
6336257f37dSmrg
634d422ce2eSmrg    func_quote_arg pretty "$2"
635d422ce2eSmrg    eval "$1=\$$1\\ \$func_quote_arg_result"
6366257f37dSmrg  }
6376257f37dSmrgfi
6386257f37dSmrg
6396257f37dSmrg
6406257f37dSmrg# func_append_uniq VAR VALUE
6416257f37dSmrg# --------------------------
6426257f37dSmrg# Append unique VALUE onto the existing contents of VAR, assuming
6436257f37dSmrg# entries are delimited by the first character of VALUE.  For example:
6446257f37dSmrg#
6456257f37dSmrg#   func_append_uniq options " --another-option option-argument"
6466257f37dSmrg#
6476257f37dSmrg# will only append to $options if " --another-option option-argument "
6486257f37dSmrg# is not already present somewhere in $options already (note spaces at
6496257f37dSmrg# each end implied by leading space in second argument).
6506257f37dSmrgfunc_append_uniq ()
6516257f37dSmrg{
6526257f37dSmrg    $debug_cmd
6536257f37dSmrg
6546257f37dSmrg    eval _G_current_value='`$ECHO $'$1'`'
6556257f37dSmrg    _G_delim=`expr "$2" : '\(.\)'`
6566257f37dSmrg
6576257f37dSmrg    case $_G_delim$_G_current_value$_G_delim in
6586257f37dSmrg      *"$2$_G_delim"*) ;;
6596257f37dSmrg      *) func_append "$@" ;;
6606257f37dSmrg    esac
6616257f37dSmrg}
6626257f37dSmrg
6636257f37dSmrg
6646257f37dSmrg# func_arith TERM...
6656257f37dSmrg# ------------------
6666257f37dSmrg# Set func_arith_result to the result of evaluating TERMs.
6676257f37dSmrg  test -z "$_G_HAVE_ARITH_OP" \
6686257f37dSmrg    && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \
6696257f37dSmrg    && _G_HAVE_ARITH_OP=yes
6706257f37dSmrg
6716257f37dSmrgif test yes = "$_G_HAVE_ARITH_OP"; then
6726257f37dSmrg  eval 'func_arith ()
6736257f37dSmrg  {
6746257f37dSmrg    $debug_cmd
6756257f37dSmrg
6766257f37dSmrg    func_arith_result=$(( $* ))
6776257f37dSmrg  }'
6786257f37dSmrgelse
6796257f37dSmrg  func_arith ()
6806257f37dSmrg  {
6816257f37dSmrg    $debug_cmd
6826257f37dSmrg
6836257f37dSmrg    func_arith_result=`expr "$@"`
6846257f37dSmrg  }
6856257f37dSmrgfi
6866257f37dSmrg
6876257f37dSmrg
6886257f37dSmrg# func_basename FILE
6896257f37dSmrg# ------------------
6906257f37dSmrg# Set func_basename_result to FILE with everything up to and including
6916257f37dSmrg# the last / stripped.
6926257f37dSmrgif test yes = "$_G_HAVE_XSI_OPS"; then
6936257f37dSmrg  # If this shell supports suffix pattern removal, then use it to avoid
6946257f37dSmrg  # forking. Hide the definitions single quotes in case the shell chokes
6956257f37dSmrg  # on unsupported syntax...
6966257f37dSmrg  _b='func_basename_result=${1##*/}'
6976257f37dSmrg  _d='case $1 in
6986257f37dSmrg        */*) func_dirname_result=${1%/*}$2 ;;
6996257f37dSmrg        *  ) func_dirname_result=$3        ;;
7006257f37dSmrg      esac'
7016257f37dSmrg
7026257f37dSmrgelse
7036257f37dSmrg  # ...otherwise fall back to using sed.
7046257f37dSmrg  _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`'
7056257f37dSmrg  _d='func_dirname_result=`$ECHO "$1"  |$SED "$sed_dirname"`
7066257f37dSmrg      if test "X$func_dirname_result" = "X$1"; then
7076257f37dSmrg        func_dirname_result=$3
7086257f37dSmrg      else
7096257f37dSmrg        func_append func_dirname_result "$2"
7106257f37dSmrg      fi'
7116257f37dSmrgfi
7126257f37dSmrg
7136257f37dSmrgeval 'func_basename ()
7146257f37dSmrg{
7156257f37dSmrg    $debug_cmd
7166257f37dSmrg
7176257f37dSmrg    '"$_b"'
7186257f37dSmrg}'
7196257f37dSmrg
7206257f37dSmrg
7216257f37dSmrg# func_dirname FILE APPEND NONDIR_REPLACEMENT
7226257f37dSmrg# -------------------------------------------
7236257f37dSmrg# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
7246257f37dSmrg# otherwise set result to NONDIR_REPLACEMENT.
7256257f37dSmrgeval 'func_dirname ()
7266257f37dSmrg{
7276257f37dSmrg    $debug_cmd
7286257f37dSmrg
7296257f37dSmrg    '"$_d"'
7306257f37dSmrg}'
7316257f37dSmrg
7326257f37dSmrg
7336257f37dSmrg# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT
7346257f37dSmrg# --------------------------------------------------------
7356257f37dSmrg# Perform func_basename and func_dirname in a single function
7366257f37dSmrg# call:
7376257f37dSmrg#   dirname:  Compute the dirname of FILE.  If nonempty,
7386257f37dSmrg#             add APPEND to the result, otherwise set result
7396257f37dSmrg#             to NONDIR_REPLACEMENT.
7406257f37dSmrg#             value returned in "$func_dirname_result"
7416257f37dSmrg#   basename: Compute filename of FILE.
7426257f37dSmrg#             value retuned in "$func_basename_result"
7436257f37dSmrg# For efficiency, we do not delegate to the functions above but instead
7446257f37dSmrg# duplicate the functionality here.
7456257f37dSmrgeval 'func_dirname_and_basename ()
7466257f37dSmrg{
7476257f37dSmrg    $debug_cmd
7486257f37dSmrg
7496257f37dSmrg    '"$_b"'
7506257f37dSmrg    '"$_d"'
7516257f37dSmrg}'
7526257f37dSmrg
7536257f37dSmrg
7546257f37dSmrg# func_echo ARG...
7556257f37dSmrg# ----------------
7566257f37dSmrg# Echo program name prefixed message.
7576257f37dSmrgfunc_echo ()
7586257f37dSmrg{
7596257f37dSmrg    $debug_cmd
7606257f37dSmrg
7616257f37dSmrg    _G_message=$*
7626257f37dSmrg
7636257f37dSmrg    func_echo_IFS=$IFS
7646257f37dSmrg    IFS=$nl
7656257f37dSmrg    for _G_line in $_G_message; do
7666257f37dSmrg      IFS=$func_echo_IFS
7676257f37dSmrg      $ECHO "$progname: $_G_line"
7686257f37dSmrg    done
7696257f37dSmrg    IFS=$func_echo_IFS
7706257f37dSmrg}
7716257f37dSmrg
7726257f37dSmrg
7736257f37dSmrg# func_echo_all ARG...
7746257f37dSmrg# --------------------
7756257f37dSmrg# Invoke $ECHO with all args, space-separated.
7766257f37dSmrgfunc_echo_all ()
7776257f37dSmrg{
7786257f37dSmrg    $ECHO "$*"
7796257f37dSmrg}
7806257f37dSmrg
7816257f37dSmrg
7826257f37dSmrg# func_echo_infix_1 INFIX ARG...
7836257f37dSmrg# ------------------------------
7846257f37dSmrg# Echo program name, followed by INFIX on the first line, with any
7856257f37dSmrg# additional lines not showing INFIX.
7866257f37dSmrgfunc_echo_infix_1 ()
7876257f37dSmrg{
7886257f37dSmrg    $debug_cmd
7896257f37dSmrg
7906257f37dSmrg    $require_term_colors
7916257f37dSmrg
7926257f37dSmrg    _G_infix=$1; shift
7936257f37dSmrg    _G_indent=$_G_infix
7946257f37dSmrg    _G_prefix="$progname: $_G_infix: "
7956257f37dSmrg    _G_message=$*
7966257f37dSmrg
7976257f37dSmrg    # Strip color escape sequences before counting printable length
7986257f37dSmrg    for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan"
7996257f37dSmrg    do
8006257f37dSmrg      test -n "$_G_tc" && {
8016257f37dSmrg        _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"`
8026257f37dSmrg        _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"`
8036257f37dSmrg      }
8046257f37dSmrg    done
8056257f37dSmrg    _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`"  " ## exclude from sc_prohibit_nested_quotes
8066257f37dSmrg
8076257f37dSmrg    func_echo_infix_1_IFS=$IFS
8086257f37dSmrg    IFS=$nl
8096257f37dSmrg    for _G_line in $_G_message; do
8106257f37dSmrg      IFS=$func_echo_infix_1_IFS
8116257f37dSmrg      $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2
8126257f37dSmrg      _G_prefix=$_G_indent
8136257f37dSmrg    done
8146257f37dSmrg    IFS=$func_echo_infix_1_IFS
8156257f37dSmrg}
8166257f37dSmrg
8176257f37dSmrg
8186257f37dSmrg# func_error ARG...
8196257f37dSmrg# -----------------
8206257f37dSmrg# Echo program name prefixed message to standard error.
8216257f37dSmrgfunc_error ()
8226257f37dSmrg{
8236257f37dSmrg    $debug_cmd
8246257f37dSmrg
8256257f37dSmrg    $require_term_colors
8266257f37dSmrg
8276257f37dSmrg    func_echo_infix_1 "  $tc_standout${tc_red}error$tc_reset" "$*" >&2
8286257f37dSmrg}
8296257f37dSmrg
8306257f37dSmrg
8316257f37dSmrg# func_fatal_error ARG...
8326257f37dSmrg# -----------------------
8336257f37dSmrg# Echo program name prefixed message to standard error, and exit.
8346257f37dSmrgfunc_fatal_error ()
8356257f37dSmrg{
8366257f37dSmrg    $debug_cmd
8376257f37dSmrg
8386257f37dSmrg    func_error "$*"
8396257f37dSmrg    exit $EXIT_FAILURE
8406257f37dSmrg}
8416257f37dSmrg
8426257f37dSmrg
8436257f37dSmrg# func_grep EXPRESSION FILENAME
8446257f37dSmrg# -----------------------------
845f3561b8bSmrg# Check whether EXPRESSION matches any line of FILENAME, without output.
846f3561b8bSmrgfunc_grep ()
847f3561b8bSmrg{
8486257f37dSmrg    $debug_cmd
8496257f37dSmrg
850f3561b8bSmrg    $GREP "$1" "$2" >/dev/null 2>&1
851f3561b8bSmrg}
852f3561b8bSmrg
853f3561b8bSmrg
8546257f37dSmrg# func_len STRING
8556257f37dSmrg# ---------------
8566257f37dSmrg# Set func_len_result to the length of STRING. STRING may not
8576257f37dSmrg# start with a hyphen.
8586257f37dSmrg  test -z "$_G_HAVE_XSI_OPS" \
8596257f37dSmrg    && (eval 'x=a/b/c;
8606257f37dSmrg      test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
8616257f37dSmrg    && _G_HAVE_XSI_OPS=yes
8626257f37dSmrg
8636257f37dSmrgif test yes = "$_G_HAVE_XSI_OPS"; then
8646257f37dSmrg  eval 'func_len ()
8656257f37dSmrg  {
8666257f37dSmrg    $debug_cmd
8676257f37dSmrg
8686257f37dSmrg    func_len_result=${#1}
8696257f37dSmrg  }'
8706257f37dSmrgelse
8716257f37dSmrg  func_len ()
8726257f37dSmrg  {
8736257f37dSmrg    $debug_cmd
8746257f37dSmrg
8756257f37dSmrg    func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len`
8766257f37dSmrg  }
8776257f37dSmrgfi
8786257f37dSmrg
8796257f37dSmrg
8806257f37dSmrg# func_mkdir_p DIRECTORY-PATH
8816257f37dSmrg# ---------------------------
882f3561b8bSmrg# Make sure the entire path to DIRECTORY-PATH is available.
883f3561b8bSmrgfunc_mkdir_p ()
884f3561b8bSmrg{
8856257f37dSmrg    $debug_cmd
886f3561b8bSmrg
8876257f37dSmrg    _G_directory_path=$1
8886257f37dSmrg    _G_dir_list=
889f3561b8bSmrg
8906257f37dSmrg    if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then
8916257f37dSmrg
8926257f37dSmrg      # Protect directory names starting with '-'
8936257f37dSmrg      case $_G_directory_path in
8946257f37dSmrg        -*) _G_directory_path=./$_G_directory_path ;;
895f3561b8bSmrg      esac
896f3561b8bSmrg
897f3561b8bSmrg      # While some portion of DIR does not yet exist...
8986257f37dSmrg      while test ! -d "$_G_directory_path"; do
899f3561b8bSmrg        # ...make a list in topmost first order.  Use a colon delimited
900f3561b8bSmrg	# list incase some portion of path contains whitespace.
9016257f37dSmrg        _G_dir_list=$_G_directory_path:$_G_dir_list
902f3561b8bSmrg
903f3561b8bSmrg        # If the last portion added has no slash in it, the list is done
9046257f37dSmrg        case $_G_directory_path in */*) ;; *) break ;; esac
905f3561b8bSmrg
906f3561b8bSmrg        # ...otherwise throw away the child directory and loop
9076257f37dSmrg        _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"`
908f3561b8bSmrg      done
9096257f37dSmrg      _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'`
910f3561b8bSmrg
9116257f37dSmrg      func_mkdir_p_IFS=$IFS; IFS=:
9126257f37dSmrg      for _G_dir in $_G_dir_list; do
9136257f37dSmrg	IFS=$func_mkdir_p_IFS
9146257f37dSmrg        # mkdir can fail with a 'File exist' error if two processes
915f3561b8bSmrg        # try to create one of the directories concurrently.  Don't
916f3561b8bSmrg        # stop in that case!
9176257f37dSmrg        $MKDIR "$_G_dir" 2>/dev/null || :
918f3561b8bSmrg      done
9196257f37dSmrg      IFS=$func_mkdir_p_IFS
920f3561b8bSmrg
921f3561b8bSmrg      # Bail out if we (or some other process) failed to create a directory.
9226257f37dSmrg      test -d "$_G_directory_path" || \
9236257f37dSmrg        func_fatal_error "Failed to create '$1'"
924f3561b8bSmrg    fi
925f3561b8bSmrg}
926fc5a983dSmrg
927fc5a983dSmrg
9286257f37dSmrg# func_mktempdir [BASENAME]
9296257f37dSmrg# -------------------------
930fc5a983dSmrg# Make a temporary directory that won't clash with other running
931fc5a983dSmrg# libtool processes, and avoids race conditions if possible.  If
9326257f37dSmrg# given, BASENAME is the basename for that directory.
933fc5a983dSmrgfunc_mktempdir ()
934fc5a983dSmrg{
9356257f37dSmrg    $debug_cmd
9366257f37dSmrg
9376257f37dSmrg    _G_template=${TMPDIR-/tmp}/${1-$progname}
938fc5a983dSmrg
9396257f37dSmrg    if test : = "$opt_dry_run"; then
940fc5a983dSmrg      # Return a directory name, but don't create it in dry-run mode
9416257f37dSmrg      _G_tmpdir=$_G_template-$$
942fc5a983dSmrg    else
943fc5a983dSmrg
944fc5a983dSmrg      # If mktemp works, use that first and foremost
9456257f37dSmrg      _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null`
946fc5a983dSmrg
9476257f37dSmrg      if test ! -d "$_G_tmpdir"; then
948f3561b8bSmrg        # Failing that, at least try and use $RANDOM to avoid a race
9496257f37dSmrg        _G_tmpdir=$_G_template-${RANDOM-0}$$
950fc5a983dSmrg
9516257f37dSmrg        func_mktempdir_umask=`umask`
952f3561b8bSmrg        umask 0077
9536257f37dSmrg        $MKDIR "$_G_tmpdir"
9546257f37dSmrg        umask $func_mktempdir_umask
955fc5a983dSmrg      fi
956fc5a983dSmrg
957fc5a983dSmrg      # If we're not in dry-run mode, bomb out on failure
9586257f37dSmrg      test -d "$_G_tmpdir" || \
9596257f37dSmrg        func_fatal_error "cannot create temporary directory '$_G_tmpdir'"
9606257f37dSmrg    fi
9616257f37dSmrg
9626257f37dSmrg    $ECHO "$_G_tmpdir"
9636257f37dSmrg}
9646257f37dSmrg
9656257f37dSmrg
9666257f37dSmrg# func_normal_abspath PATH
9676257f37dSmrg# ------------------------
9686257f37dSmrg# Remove doubled-up and trailing slashes, "." path components,
9696257f37dSmrg# and cancel out any ".." path components in PATH after making
9706257f37dSmrg# it an absolute path.
9716257f37dSmrgfunc_normal_abspath ()
9726257f37dSmrg{
9736257f37dSmrg    $debug_cmd
9746257f37dSmrg
9756257f37dSmrg    # These SED scripts presuppose an absolute path with a trailing slash.
9766257f37dSmrg    _G_pathcar='s|^/\([^/]*\).*$|\1|'
9776257f37dSmrg    _G_pathcdr='s|^/[^/]*||'
9786257f37dSmrg    _G_removedotparts=':dotsl
9796257f37dSmrg		s|/\./|/|g
9806257f37dSmrg		t dotsl
9816257f37dSmrg		s|/\.$|/|'
9826257f37dSmrg    _G_collapseslashes='s|/\{1,\}|/|g'
9836257f37dSmrg    _G_finalslash='s|/*$|/|'
9846257f37dSmrg
9856257f37dSmrg    # Start from root dir and reassemble the path.
9866257f37dSmrg    func_normal_abspath_result=
9876257f37dSmrg    func_normal_abspath_tpath=$1
9886257f37dSmrg    func_normal_abspath_altnamespace=
9896257f37dSmrg    case $func_normal_abspath_tpath in
9906257f37dSmrg      "")
9916257f37dSmrg        # Empty path, that just means $cwd.
9926257f37dSmrg        func_stripname '' '/' "`pwd`"
9936257f37dSmrg        func_normal_abspath_result=$func_stripname_result
9946257f37dSmrg        return
9956257f37dSmrg        ;;
9966257f37dSmrg      # The next three entries are used to spot a run of precisely
9976257f37dSmrg      # two leading slashes without using negated character classes;
9986257f37dSmrg      # we take advantage of case's first-match behaviour.
9996257f37dSmrg      ///*)
10006257f37dSmrg        # Unusual form of absolute path, do nothing.
10016257f37dSmrg        ;;
10026257f37dSmrg      //*)
10036257f37dSmrg        # Not necessarily an ordinary path; POSIX reserves leading '//'
10046257f37dSmrg        # and for example Cygwin uses it to access remote file shares
10056257f37dSmrg        # over CIFS/SMB, so we conserve a leading double slash if found.
10066257f37dSmrg        func_normal_abspath_altnamespace=/
10076257f37dSmrg        ;;
10086257f37dSmrg      /*)
10096257f37dSmrg        # Absolute path, do nothing.
10106257f37dSmrg        ;;
10116257f37dSmrg      *)
10126257f37dSmrg        # Relative path, prepend $cwd.
10136257f37dSmrg        func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
10146257f37dSmrg        ;;
10156257f37dSmrg    esac
10166257f37dSmrg
10176257f37dSmrg    # Cancel out all the simple stuff to save iterations.  We also want
10186257f37dSmrg    # the path to end with a slash for ease of parsing, so make sure
10196257f37dSmrg    # there is one (and only one) here.
10206257f37dSmrg    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
10216257f37dSmrg          -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"`
10226257f37dSmrg    while :; do
10236257f37dSmrg      # Processed it all yet?
10246257f37dSmrg      if test / = "$func_normal_abspath_tpath"; then
10256257f37dSmrg        # If we ascended to the root using ".." the result may be empty now.
10266257f37dSmrg        if test -z "$func_normal_abspath_result"; then
10276257f37dSmrg          func_normal_abspath_result=/
10286257f37dSmrg        fi
10296257f37dSmrg        break
10306257f37dSmrg      fi
10316257f37dSmrg      func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
10326257f37dSmrg          -e "$_G_pathcar"`
10336257f37dSmrg      func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
10346257f37dSmrg          -e "$_G_pathcdr"`
10356257f37dSmrg      # Figure out what to do with it
10366257f37dSmrg      case $func_normal_abspath_tcomponent in
10376257f37dSmrg        "")
10386257f37dSmrg          # Trailing empty path component, ignore it.
10396257f37dSmrg          ;;
10406257f37dSmrg        ..)
10416257f37dSmrg          # Parent dir; strip last assembled component from result.
10426257f37dSmrg          func_dirname "$func_normal_abspath_result"
10436257f37dSmrg          func_normal_abspath_result=$func_dirname_result
10446257f37dSmrg          ;;
10456257f37dSmrg        *)
10466257f37dSmrg          # Actual path component, append it.
10476257f37dSmrg          func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent"
10486257f37dSmrg          ;;
10496257f37dSmrg      esac
10506257f37dSmrg    done
10516257f37dSmrg    # Restore leading double-slash if one was found on entry.
10526257f37dSmrg    func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
10536257f37dSmrg}
10546257f37dSmrg
10556257f37dSmrg
10566257f37dSmrg# func_notquiet ARG...
10576257f37dSmrg# --------------------
10586257f37dSmrg# Echo program name prefixed message only when not in quiet mode.
10596257f37dSmrgfunc_notquiet ()
10606257f37dSmrg{
10616257f37dSmrg    $debug_cmd
10626257f37dSmrg
10636257f37dSmrg    $opt_quiet || func_echo ${1+"$@"}
10646257f37dSmrg
10656257f37dSmrg    # A bug in bash halts the script if the last line of a function
10666257f37dSmrg    # fails when set -e is in force, so we need another command to
10676257f37dSmrg    # work around that:
10686257f37dSmrg    :
10696257f37dSmrg}
10706257f37dSmrg
10716257f37dSmrg
10726257f37dSmrg# func_relative_path SRCDIR DSTDIR
10736257f37dSmrg# --------------------------------
10746257f37dSmrg# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR.
10756257f37dSmrgfunc_relative_path ()
10766257f37dSmrg{
10776257f37dSmrg    $debug_cmd
10786257f37dSmrg
10796257f37dSmrg    func_relative_path_result=
10806257f37dSmrg    func_normal_abspath "$1"
10816257f37dSmrg    func_relative_path_tlibdir=$func_normal_abspath_result
10826257f37dSmrg    func_normal_abspath "$2"
10836257f37dSmrg    func_relative_path_tbindir=$func_normal_abspath_result
10846257f37dSmrg
10856257f37dSmrg    # Ascend the tree starting from libdir
10866257f37dSmrg    while :; do
10876257f37dSmrg      # check if we have found a prefix of bindir
10886257f37dSmrg      case $func_relative_path_tbindir in
10896257f37dSmrg        $func_relative_path_tlibdir)
10906257f37dSmrg          # found an exact match
10916257f37dSmrg          func_relative_path_tcancelled=
10926257f37dSmrg          break
10936257f37dSmrg          ;;
10946257f37dSmrg        $func_relative_path_tlibdir*)
10956257f37dSmrg          # found a matching prefix
10966257f37dSmrg          func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
10976257f37dSmrg          func_relative_path_tcancelled=$func_stripname_result
10986257f37dSmrg          if test -z "$func_relative_path_result"; then
10996257f37dSmrg            func_relative_path_result=.
11006257f37dSmrg          fi
11016257f37dSmrg          break
11026257f37dSmrg          ;;
11036257f37dSmrg        *)
11046257f37dSmrg          func_dirname $func_relative_path_tlibdir
11056257f37dSmrg          func_relative_path_tlibdir=$func_dirname_result
11066257f37dSmrg          if test -z "$func_relative_path_tlibdir"; then
11076257f37dSmrg            # Have to descend all the way to the root!
11086257f37dSmrg            func_relative_path_result=../$func_relative_path_result
11096257f37dSmrg            func_relative_path_tcancelled=$func_relative_path_tbindir
11106257f37dSmrg            break
11116257f37dSmrg          fi
11126257f37dSmrg          func_relative_path_result=../$func_relative_path_result
11136257f37dSmrg          ;;
11146257f37dSmrg      esac
11156257f37dSmrg    done
11166257f37dSmrg
11176257f37dSmrg    # Now calculate path; take care to avoid doubling-up slashes.
11186257f37dSmrg    func_stripname '' '/' "$func_relative_path_result"
11196257f37dSmrg    func_relative_path_result=$func_stripname_result
11206257f37dSmrg    func_stripname '/' '/' "$func_relative_path_tcancelled"
11216257f37dSmrg    if test -n "$func_stripname_result"; then
11226257f37dSmrg      func_append func_relative_path_result "/$func_stripname_result"
11236257f37dSmrg    fi
11246257f37dSmrg
11256257f37dSmrg    # Normalisation. If bindir is libdir, return '.' else relative path.
11266257f37dSmrg    if test -n "$func_relative_path_result"; then
11276257f37dSmrg      func_stripname './' '' "$func_relative_path_result"
11286257f37dSmrg      func_relative_path_result=$func_stripname_result
1129fc5a983dSmrg    fi
1130fc5a983dSmrg
11316257f37dSmrg    test -n "$func_relative_path_result" || func_relative_path_result=.
11326257f37dSmrg
11336257f37dSmrg    :
11346257f37dSmrg}
11356257f37dSmrg
11366257f37dSmrg
1137d422ce2eSmrg# func_quote_portable EVAL ARG
1138d422ce2eSmrg# ----------------------------
1139d422ce2eSmrg# Internal function to portably implement func_quote_arg.  Note that we still
1140d422ce2eSmrg# keep attention to performance here so we as much as possible try to avoid
1141d422ce2eSmrg# calling sed binary (so far O(N) complexity as long as func_append is O(1)).
1142d422ce2eSmrgfunc_quote_portable ()
11436257f37dSmrg{
11446257f37dSmrg    $debug_cmd
11456257f37dSmrg
1146d422ce2eSmrg    $require_check_ifs_backslash
1147d422ce2eSmrg
1148d422ce2eSmrg    func_quote_portable_result=$2
1149d422ce2eSmrg
1150d422ce2eSmrg    # one-time-loop (easy break)
1151d422ce2eSmrg    while true
1152d422ce2eSmrg    do
1153d422ce2eSmrg      if $1; then
1154d422ce2eSmrg        func_quote_portable_result=`$ECHO "$2" | $SED \
1155d422ce2eSmrg          -e "$sed_double_quote_subst" -e "$sed_double_backslash"`
1156d422ce2eSmrg        break
11576257f37dSmrg      fi
11586257f37dSmrg
1159d422ce2eSmrg      # Quote for eval.
1160d422ce2eSmrg      case $func_quote_portable_result in
1161d422ce2eSmrg        *[\\\`\"\$]*)
1162d422ce2eSmrg          # Fallback to sed for $func_check_bs_ifs_broken=:, or when the string
1163d422ce2eSmrg          # contains the shell wildcard characters.
1164d422ce2eSmrg          case $check_ifs_backshlash_broken$func_quote_portable_result in
1165d422ce2eSmrg            :*|*[\[\*\?]*)
1166d422ce2eSmrg              func_quote_portable_result=`$ECHO "$func_quote_portable_result" \
1167d422ce2eSmrg                  | $SED "$sed_quote_subst"`
1168d422ce2eSmrg              break
1169d422ce2eSmrg              ;;
1170d422ce2eSmrg          esac
1171d422ce2eSmrg
1172d422ce2eSmrg          func_quote_portable_old_IFS=$IFS
1173d422ce2eSmrg          for _G_char in '\' '`' '"' '$'
1174d422ce2eSmrg          do
1175d422ce2eSmrg            # STATE($1) PREV($2) SEPARATOR($3)
1176d422ce2eSmrg            set start "" ""
1177d422ce2eSmrg            func_quote_portable_result=dummy"$_G_char$func_quote_portable_result$_G_char"dummy
1178d422ce2eSmrg            IFS=$_G_char
1179d422ce2eSmrg            for _G_part in $func_quote_portable_result
1180d422ce2eSmrg            do
1181d422ce2eSmrg              case $1 in
1182d422ce2eSmrg              quote)
1183d422ce2eSmrg                func_append func_quote_portable_result "$3$2"
1184d422ce2eSmrg                set quote "$_G_part" "\\$_G_char"
1185d422ce2eSmrg                ;;
1186d422ce2eSmrg              start)
1187d422ce2eSmrg                set first "" ""
1188d422ce2eSmrg                func_quote_portable_result=
1189d422ce2eSmrg                ;;
1190d422ce2eSmrg              first)
1191d422ce2eSmrg                set quote "$_G_part" ""
1192d422ce2eSmrg                ;;
1193d422ce2eSmrg              esac
1194d422ce2eSmrg            done
1195d422ce2eSmrg          done
1196d422ce2eSmrg          IFS=$func_quote_portable_old_IFS
11976257f37dSmrg          ;;
1198d422ce2eSmrg        *) ;;
11996257f37dSmrg      esac
1200d422ce2eSmrg      break
12016257f37dSmrg    done
1202d422ce2eSmrg
1203d422ce2eSmrg    func_quote_portable_unquoted_result=$func_quote_portable_result
1204d422ce2eSmrg    case $func_quote_portable_result in
1205d422ce2eSmrg      # double-quote args containing shell metacharacters to delay
1206d422ce2eSmrg      # word splitting, command substitution and variable expansion
1207d422ce2eSmrg      # for a subsequent eval.
1208d422ce2eSmrg      # many bourne shells cannot handle close brackets correctly
1209d422ce2eSmrg      # in scan sets, so we specify it separately.
1210d422ce2eSmrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
1211d422ce2eSmrg        func_quote_portable_result=\"$func_quote_portable_result\"
1212d422ce2eSmrg        ;;
1213d422ce2eSmrg    esac
12146257f37dSmrg}
12156257f37dSmrg
12166257f37dSmrg
1217d422ce2eSmrg# func_quotefast_eval ARG
1218d422ce2eSmrg# -----------------------
1219d422ce2eSmrg# Quote one ARG (internal).  This is equivalent to 'func_quote_arg eval ARG',
1220d422ce2eSmrg# but optimized for speed.  Result is stored in $func_quotefast_eval.
1221d422ce2eSmrgif test xyes = `(x=; printf -v x %q yes; echo x"$x") 2>/dev/null`; then
1222d422ce2eSmrg  printf -v _GL_test_printf_tilde %q '~'
1223d422ce2eSmrg  if test '\~' = "$_GL_test_printf_tilde"; then
1224d422ce2eSmrg    func_quotefast_eval ()
1225d422ce2eSmrg    {
1226d422ce2eSmrg      printf -v func_quotefast_eval_result %q "$1"
1227d422ce2eSmrg    }
1228d422ce2eSmrg  else
1229d422ce2eSmrg    # Broken older Bash implementations.  Make those faster too if possible.
1230d422ce2eSmrg    func_quotefast_eval ()
1231d422ce2eSmrg    {
1232d422ce2eSmrg      case $1 in
1233d422ce2eSmrg        '~'*)
1234d422ce2eSmrg          func_quote_portable false "$1"
1235d422ce2eSmrg          func_quotefast_eval_result=$func_quote_portable_result
1236d422ce2eSmrg          ;;
1237d422ce2eSmrg        *)
1238d422ce2eSmrg          printf -v func_quotefast_eval_result %q "$1"
1239d422ce2eSmrg          ;;
1240d422ce2eSmrg      esac
1241d422ce2eSmrg    }
1242d422ce2eSmrg  fi
1243d422ce2eSmrgelse
1244d422ce2eSmrg  func_quotefast_eval ()
1245d422ce2eSmrg  {
1246d422ce2eSmrg    func_quote_portable false "$1"
1247d422ce2eSmrg    func_quotefast_eval_result=$func_quote_portable_result
1248d422ce2eSmrg  }
1249d422ce2eSmrgfi
12506257f37dSmrg
1251d422ce2eSmrg
1252d422ce2eSmrg# func_quote_arg MODEs ARG
1253d422ce2eSmrg# ------------------------
1254d422ce2eSmrg# Quote one ARG to be evaled later.  MODEs argument may contain zero or more
1255d422ce2eSmrg# specifiers listed below separated by ',' character.  This function returns two
1256d422ce2eSmrg# values:
1257d422ce2eSmrg#   i) func_quote_arg_result
1258d422ce2eSmrg#      double-quoted (when needed), suitable for a subsequent eval
1259d422ce2eSmrg#  ii) func_quote_arg_unquoted_result
1260d422ce2eSmrg#      has all characters that are still active within double
1261d422ce2eSmrg#      quotes backslashified.  Available only if 'unquoted' is specified.
1262d422ce2eSmrg#
1263d422ce2eSmrg# Available modes:
1264d422ce2eSmrg# ----------------
1265d422ce2eSmrg# 'eval' (default)
1266d422ce2eSmrg#       - escape shell special characters
1267d422ce2eSmrg# 'expand'
1268d422ce2eSmrg#       - the same as 'eval';  but do not quote variable references
1269d422ce2eSmrg# 'pretty'
1270d422ce2eSmrg#       - request aesthetic output, i.e. '"a b"' instead of 'a\ b'.  This might
1271d422ce2eSmrg#         be used later in func_quote to get output like: 'echo "a b"' instead
1272d422ce2eSmrg#         of 'echo a\ b'.  This is slower than default on some shells.
1273d422ce2eSmrg# 'unquoted'
1274d422ce2eSmrg#       - produce also $func_quote_arg_unquoted_result which does not contain
1275d422ce2eSmrg#         wrapping double-quotes.
1276d422ce2eSmrg#
1277d422ce2eSmrg# Examples for 'func_quote_arg pretty,unquoted string':
1278d422ce2eSmrg#
1279d422ce2eSmrg#   string      | *_result              | *_unquoted_result
1280d422ce2eSmrg#   ------------+-----------------------+-------------------
1281d422ce2eSmrg#   "           | \"                    | \"
1282d422ce2eSmrg#   a b         | "a b"                 | a b
1283d422ce2eSmrg#   "a b"       | "\"a b\""             | \"a b\"
1284d422ce2eSmrg#   *           | "*"                   | *
1285d422ce2eSmrg#   z="${x-$y}" | "z=\"\${x-\$y}\""     | z=\"\${x-\$y}\"
1286d422ce2eSmrg#
1287d422ce2eSmrg# Examples for 'func_quote_arg pretty,unquoted,expand string':
1288d422ce2eSmrg#
1289d422ce2eSmrg#   string        |   *_result          |  *_unquoted_result
1290d422ce2eSmrg#   --------------+---------------------+--------------------
1291d422ce2eSmrg#   z="${x-$y}"   | "z=\"${x-$y}\""     | z=\"${x-$y}\"
1292d422ce2eSmrgfunc_quote_arg ()
1293d422ce2eSmrg{
1294d422ce2eSmrg    _G_quote_expand=false
1295d422ce2eSmrg    case ,$1, in
1296d422ce2eSmrg      *,expand,*)
1297d422ce2eSmrg        _G_quote_expand=:
1298d422ce2eSmrg        ;;
12996257f37dSmrg    esac
13006257f37dSmrg
1301d422ce2eSmrg    case ,$1, in
1302d422ce2eSmrg      *,pretty,*|*,expand,*|*,unquoted,*)
1303d422ce2eSmrg        func_quote_portable $_G_quote_expand "$2"
1304d422ce2eSmrg        func_quote_arg_result=$func_quote_portable_result
1305d422ce2eSmrg        func_quote_arg_unquoted_result=$func_quote_portable_unquoted_result
1306d422ce2eSmrg        ;;
1307d422ce2eSmrg      *)
1308d422ce2eSmrg        # Faster quote-for-eval for some shells.
1309d422ce2eSmrg        func_quotefast_eval "$2"
1310d422ce2eSmrg        func_quote_arg_result=$func_quotefast_eval_result
13116257f37dSmrg        ;;
13126257f37dSmrg    esac
1313d422ce2eSmrg}
1314d422ce2eSmrg
13156257f37dSmrg
1316d422ce2eSmrg# func_quote MODEs ARGs...
1317d422ce2eSmrg# ------------------------
1318d422ce2eSmrg# Quote all ARGs to be evaled later and join them into single command.  See
1319d422ce2eSmrg# func_quote_arg's description for more info.
1320d422ce2eSmrgfunc_quote ()
1321d422ce2eSmrg{
1322d422ce2eSmrg    $debug_cmd
1323d422ce2eSmrg    _G_func_quote_mode=$1 ; shift
1324d422ce2eSmrg    func_quote_result=
1325d422ce2eSmrg    while test 0 -lt $#; do
1326d422ce2eSmrg      func_quote_arg "$_G_func_quote_mode" "$1"
1327d422ce2eSmrg      if test -n "$func_quote_result"; then
1328d422ce2eSmrg        func_append func_quote_result " $func_quote_arg_result"
1329d422ce2eSmrg      else
1330d422ce2eSmrg        func_append func_quote_result "$func_quote_arg_result"
1331d422ce2eSmrg      fi
1332d422ce2eSmrg      shift
1333d422ce2eSmrg    done
13346257f37dSmrg}
13356257f37dSmrg
13366257f37dSmrg
13376257f37dSmrg# func_stripname PREFIX SUFFIX NAME
13386257f37dSmrg# ---------------------------------
13396257f37dSmrg# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result.
13406257f37dSmrg# PREFIX and SUFFIX must not contain globbing or regex special
13416257f37dSmrg# characters, hashes, percent signs, but SUFFIX may contain a leading
13426257f37dSmrg# dot (in which case that matches only a dot).
13436257f37dSmrgif test yes = "$_G_HAVE_XSI_OPS"; then
13446257f37dSmrg  eval 'func_stripname ()
13456257f37dSmrg  {
13466257f37dSmrg    $debug_cmd
13476257f37dSmrg
13486257f37dSmrg    # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
13496257f37dSmrg    # positional parameters, so assign one to ordinary variable first.
13506257f37dSmrg    func_stripname_result=$3
13516257f37dSmrg    func_stripname_result=${func_stripname_result#"$1"}
13526257f37dSmrg    func_stripname_result=${func_stripname_result%"$2"}
13536257f37dSmrg  }'
13546257f37dSmrgelse
13556257f37dSmrg  func_stripname ()
13566257f37dSmrg  {
13576257f37dSmrg    $debug_cmd
13586257f37dSmrg
13596257f37dSmrg    case $2 in
13606257f37dSmrg      .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;;
13616257f37dSmrg      *)  func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;;
13626257f37dSmrg    esac
13636257f37dSmrg  }
13646257f37dSmrgfi
13656257f37dSmrg
13666257f37dSmrg
13676257f37dSmrg# func_show_eval CMD [FAIL_EXP]
13686257f37dSmrg# -----------------------------
13696257f37dSmrg# Unless opt_quiet is true, then output CMD.  Then, if opt_dryrun is
13706257f37dSmrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
13716257f37dSmrg# is given, then evaluate it.
13726257f37dSmrgfunc_show_eval ()
13736257f37dSmrg{
13746257f37dSmrg    $debug_cmd
13756257f37dSmrg
13766257f37dSmrg    _G_cmd=$1
13776257f37dSmrg    _G_fail_exp=${2-':'}
13786257f37dSmrg
1379d422ce2eSmrg    func_quote_arg pretty,expand "$_G_cmd"
1380d422ce2eSmrg    eval "func_notquiet $func_quote_arg_result"
13816257f37dSmrg
13826257f37dSmrg    $opt_dry_run || {
13836257f37dSmrg      eval "$_G_cmd"
13846257f37dSmrg      _G_status=$?
13856257f37dSmrg      if test 0 -ne "$_G_status"; then
13866257f37dSmrg	eval "(exit $_G_status); $_G_fail_exp"
13876257f37dSmrg      fi
13886257f37dSmrg    }
13896257f37dSmrg}
13906257f37dSmrg
13916257f37dSmrg
13926257f37dSmrg# func_show_eval_locale CMD [FAIL_EXP]
13936257f37dSmrg# ------------------------------------
13946257f37dSmrg# Unless opt_quiet is true, then output CMD.  Then, if opt_dryrun is
13956257f37dSmrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
13966257f37dSmrg# is given, then evaluate it.  Use the saved locale for evaluation.
13976257f37dSmrgfunc_show_eval_locale ()
13986257f37dSmrg{
13996257f37dSmrg    $debug_cmd
14006257f37dSmrg
14016257f37dSmrg    _G_cmd=$1
14026257f37dSmrg    _G_fail_exp=${2-':'}
14036257f37dSmrg
14046257f37dSmrg    $opt_quiet || {
1405d422ce2eSmrg      func_quote_arg expand,pretty "$_G_cmd"
1406d422ce2eSmrg      eval "func_echo $func_quote_arg_result"
14076257f37dSmrg    }
14086257f37dSmrg
14096257f37dSmrg    $opt_dry_run || {
14106257f37dSmrg      eval "$_G_user_locale
14116257f37dSmrg	    $_G_cmd"
14126257f37dSmrg      _G_status=$?
14136257f37dSmrg      eval "$_G_safe_locale"
14146257f37dSmrg      if test 0 -ne "$_G_status"; then
14156257f37dSmrg	eval "(exit $_G_status); $_G_fail_exp"
14166257f37dSmrg      fi
14176257f37dSmrg    }
14186257f37dSmrg}
14196257f37dSmrg
14206257f37dSmrg
14216257f37dSmrg# func_tr_sh
14226257f37dSmrg# ----------
14236257f37dSmrg# Turn $1 into a string suitable for a shell variable name.
14246257f37dSmrg# Result is stored in $func_tr_sh_result.  All characters
14256257f37dSmrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
14266257f37dSmrg# if $1 begins with a digit, a '_' is prepended as well.
14276257f37dSmrgfunc_tr_sh ()
14286257f37dSmrg{
14296257f37dSmrg    $debug_cmd
14306257f37dSmrg
14316257f37dSmrg    case $1 in
14326257f37dSmrg    [0-9]* | *[!a-zA-Z0-9_]*)
14336257f37dSmrg      func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'`
14346257f37dSmrg      ;;
14356257f37dSmrg    * )
14366257f37dSmrg      func_tr_sh_result=$1
14376257f37dSmrg      ;;
14386257f37dSmrg    esac
14396257f37dSmrg}
14406257f37dSmrg
14416257f37dSmrg
14426257f37dSmrg# func_verbose ARG...
14436257f37dSmrg# -------------------
14446257f37dSmrg# Echo program name prefixed message in verbose mode only.
14456257f37dSmrgfunc_verbose ()
14466257f37dSmrg{
14476257f37dSmrg    $debug_cmd
14486257f37dSmrg
14496257f37dSmrg    $opt_verbose && func_echo "$*"
14506257f37dSmrg
14516257f37dSmrg    :
14526257f37dSmrg}
14536257f37dSmrg
14546257f37dSmrg
14556257f37dSmrg# func_warn_and_continue ARG...
14566257f37dSmrg# -----------------------------
14576257f37dSmrg# Echo program name prefixed warning message to standard error.
14586257f37dSmrgfunc_warn_and_continue ()
14596257f37dSmrg{
14606257f37dSmrg    $debug_cmd
14616257f37dSmrg
14626257f37dSmrg    $require_term_colors
14636257f37dSmrg
14646257f37dSmrg    func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2
14656257f37dSmrg}
14666257f37dSmrg
14676257f37dSmrg
14686257f37dSmrg# func_warning CATEGORY ARG...
14696257f37dSmrg# ----------------------------
14706257f37dSmrg# Echo program name prefixed warning message to standard error. Warning
14716257f37dSmrg# messages can be filtered according to CATEGORY, where this function
14726257f37dSmrg# elides messages where CATEGORY is not listed in the global variable
14736257f37dSmrg# 'opt_warning_types'.
14746257f37dSmrgfunc_warning ()
14756257f37dSmrg{
14766257f37dSmrg    $debug_cmd
14776257f37dSmrg
14786257f37dSmrg    # CATEGORY must be in the warning_categories list!
14796257f37dSmrg    case " $warning_categories " in
14806257f37dSmrg      *" $1 "*) ;;
14816257f37dSmrg      *) func_internal_error "invalid warning category '$1'" ;;
14826257f37dSmrg    esac
14836257f37dSmrg
14846257f37dSmrg    _G_category=$1
14856257f37dSmrg    shift
14866257f37dSmrg
14876257f37dSmrg    case " $opt_warning_types " in
14886257f37dSmrg      *" $_G_category "*) $warning_func ${1+"$@"} ;;
14896257f37dSmrg    esac
14906257f37dSmrg}
14916257f37dSmrg
14926257f37dSmrg
14936257f37dSmrg# func_sort_ver VER1 VER2
14946257f37dSmrg# -----------------------
14956257f37dSmrg# 'sort -V' is not generally available.
14966257f37dSmrg# Note this deviates from the version comparison in automake
14976257f37dSmrg# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a
14986257f37dSmrg# but this should suffice as we won't be specifying old
14996257f37dSmrg# version formats or redundant trailing .0 in bootstrap.conf.
15006257f37dSmrg# If we did want full compatibility then we should probably
15016257f37dSmrg# use m4_version_compare from autoconf.
15026257f37dSmrgfunc_sort_ver ()
15036257f37dSmrg{
15046257f37dSmrg    $debug_cmd
15056257f37dSmrg
15066257f37dSmrg    printf '%s\n%s\n' "$1" "$2" \
15076257f37dSmrg      | 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
15086257f37dSmrg}
15096257f37dSmrg
15106257f37dSmrg# func_lt_ver PREV CURR
15116257f37dSmrg# ---------------------
15126257f37dSmrg# Return true if PREV and CURR are in the correct order according to
15136257f37dSmrg# func_sort_ver, otherwise false.  Use it like this:
15146257f37dSmrg#
15156257f37dSmrg#  func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..."
15166257f37dSmrgfunc_lt_ver ()
15176257f37dSmrg{
15186257f37dSmrg    $debug_cmd
15196257f37dSmrg
15206257f37dSmrg    test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q`
15216257f37dSmrg}
15226257f37dSmrg
15236257f37dSmrg
15246257f37dSmrg# Local variables:
15256257f37dSmrg# mode: shell-script
15266257f37dSmrg# sh-indentation: 2
15276257f37dSmrg# eval: (add-hook 'before-save-hook 'time-stamp)
15286257f37dSmrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
15296257f37dSmrg# time-stamp-time-zone: "UTC"
15306257f37dSmrg# End:
15316257f37dSmrg#! /bin/sh
15326257f37dSmrg
15336257f37dSmrg# A portable, pluggable option parser for Bourne shell.
15346257f37dSmrg# Written by Gary V. Vaughan, 2010
15356257f37dSmrg
1536d422ce2eSmrg# This is free software.  There is NO warranty; not even for
1537d422ce2eSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1538d422ce2eSmrg#
1539d422ce2eSmrg# Copyright (C) 2010-2019, 2021 Bootstrap Authors
1540d422ce2eSmrg#
1541d422ce2eSmrg# This file is dual licensed under the terms of the MIT license
1542d422ce2eSmrg# <https://opensource.org/license/MIT>, and GPL version 2 or later
1543d422ce2eSmrg# <http://www.gnu.org/licenses/gpl-2.0.html>.  You must apply one of
1544d422ce2eSmrg# these licenses when using or redistributing this software or any of
1545d422ce2eSmrg# the files within it.  See the URLs above, or the file `LICENSE`
1546d422ce2eSmrg# included in the Bootstrap distribution for the full license texts.
15476257f37dSmrg
1548d422ce2eSmrg# Please report bugs or propose patches to:
1549d422ce2eSmrg# <https://github.com/gnulib-modules/bootstrap/issues>
15506257f37dSmrg
1551d422ce2eSmrg# Set a version string for this script.
1552d422ce2eSmrgscriptversion=2019-02-19.15; # UTC
15536257f37dSmrg
15546257f37dSmrg
15556257f37dSmrg## ------ ##
15566257f37dSmrg## Usage. ##
15576257f37dSmrg## ------ ##
15586257f37dSmrg
15596257f37dSmrg# This file is a library for parsing options in your shell scripts along
15606257f37dSmrg# with assorted other useful supporting features that you can make use
15616257f37dSmrg# of too.
15626257f37dSmrg#
15636257f37dSmrg# For the simplest scripts you might need only:
15646257f37dSmrg#
15656257f37dSmrg#   #!/bin/sh
15666257f37dSmrg#   . relative/path/to/funclib.sh
15676257f37dSmrg#   . relative/path/to/options-parser
15686257f37dSmrg#   scriptversion=1.0
15696257f37dSmrg#   func_options ${1+"$@"}
15706257f37dSmrg#   eval set dummy "$func_options_result"; shift
15716257f37dSmrg#   ...rest of your script...
15726257f37dSmrg#
15736257f37dSmrg# In order for the '--version' option to work, you will need to have a
15746257f37dSmrg# suitably formatted comment like the one at the top of this file
1575d422ce2eSmrg# starting with '# Written by ' and ending with '# Copyright'.
15766257f37dSmrg#
15776257f37dSmrg# For '-h' and '--help' to work, you will also need a one line
15786257f37dSmrg# description of your script's purpose in a comment directly above the
15796257f37dSmrg# '# Written by ' line, like the one at the top of this file.
15806257f37dSmrg#
15816257f37dSmrg# The default options also support '--debug', which will turn on shell
15826257f37dSmrg# execution tracing (see the comment above debug_cmd below for another
15836257f37dSmrg# use), and '--verbose' and the func_verbose function to allow your script
15846257f37dSmrg# to display verbose messages only when your user has specified
15856257f37dSmrg# '--verbose'.
15866257f37dSmrg#
1587d422ce2eSmrg# After sourcing this file, you can plug in processing for additional
15886257f37dSmrg# options by amending the variables from the 'Configuration' section
15896257f37dSmrg# below, and following the instructions in the 'Option parsing'
15906257f37dSmrg# section further down.
15916257f37dSmrg
15926257f37dSmrg## -------------- ##
15936257f37dSmrg## Configuration. ##
15946257f37dSmrg## -------------- ##
15956257f37dSmrg
15966257f37dSmrg# You should override these variables in your script after sourcing this
15976257f37dSmrg# file so that they reflect the customisations you have added to the
15986257f37dSmrg# option parser.
15996257f37dSmrg
16006257f37dSmrg# The usage line for option parsing errors and the start of '-h' and
16016257f37dSmrg# '--help' output messages. You can embed shell variables for delayed
16026257f37dSmrg# expansion at the time the message is displayed, but you will need to
16036257f37dSmrg# quote other shell meta-characters carefully to prevent them being
16046257f37dSmrg# expanded when the contents are evaled.
16056257f37dSmrgusage='$progpath [OPTION]...'
16066257f37dSmrg
16076257f37dSmrg# Short help message in response to '-h' and '--help'.  Add to this or
16086257f37dSmrg# override it after sourcing this library to reflect the full set of
16096257f37dSmrg# options your script accepts.
16106257f37dSmrgusage_message="\
16116257f37dSmrg       --debug        enable verbose shell tracing
16126257f37dSmrg   -W, --warnings=CATEGORY
16136257f37dSmrg                      report the warnings falling in CATEGORY [all]
16146257f37dSmrg   -v, --verbose      verbosely report processing
16156257f37dSmrg       --version      print version information and exit
16166257f37dSmrg   -h, --help         print short or long help message and exit
16176257f37dSmrg"
16186257f37dSmrg
16196257f37dSmrg# Additional text appended to 'usage_message' in response to '--help'.
16206257f37dSmrglong_help_message="
16216257f37dSmrgWarning categories include:
16226257f37dSmrg       'all'          show all warnings
16236257f37dSmrg       'none'         turn off all the warnings
16246257f37dSmrg       'error'        warnings are treated as fatal errors"
16256257f37dSmrg
16266257f37dSmrg# Help message printed before fatal option parsing errors.
16276257f37dSmrgfatal_help="Try '\$progname --help' for more information."
16286257f37dSmrg
16296257f37dSmrg
16306257f37dSmrg
16316257f37dSmrg## ------------------------- ##
16326257f37dSmrg## Hook function management. ##
16336257f37dSmrg## ------------------------- ##
16346257f37dSmrg
16356257f37dSmrg# This section contains functions for adding, removing, and running hooks
1636d422ce2eSmrg# in the main code.  A hook is just a list of function names that can be
1637d422ce2eSmrg# run in order later on.
16386257f37dSmrg
16396257f37dSmrg# func_hookable FUNC_NAME
16406257f37dSmrg# -----------------------
16416257f37dSmrg# Declare that FUNC_NAME will run hooks added with
16426257f37dSmrg# 'func_add_hook FUNC_NAME ...'.
16436257f37dSmrgfunc_hookable ()
16446257f37dSmrg{
16456257f37dSmrg    $debug_cmd
16466257f37dSmrg
16476257f37dSmrg    func_append hookable_fns " $1"
16486257f37dSmrg}
16496257f37dSmrg
16506257f37dSmrg
16516257f37dSmrg# func_add_hook FUNC_NAME HOOK_FUNC
16526257f37dSmrg# ---------------------------------
16536257f37dSmrg# Request that FUNC_NAME call HOOK_FUNC before it returns.  FUNC_NAME must
16546257f37dSmrg# first have been declared "hookable" by a call to 'func_hookable'.
16556257f37dSmrgfunc_add_hook ()
16566257f37dSmrg{
16576257f37dSmrg    $debug_cmd
16586257f37dSmrg
16596257f37dSmrg    case " $hookable_fns " in
16606257f37dSmrg      *" $1 "*) ;;
16616257f37dSmrg      *) func_fatal_error "'$1' does not accept hook functions." ;;
16626257f37dSmrg    esac
16636257f37dSmrg
16646257f37dSmrg    eval func_append ${1}_hooks '" $2"'
16656257f37dSmrg}
16666257f37dSmrg
16676257f37dSmrg
16686257f37dSmrg# func_remove_hook FUNC_NAME HOOK_FUNC
16696257f37dSmrg# ------------------------------------
1670d422ce2eSmrg# Remove HOOK_FUNC from the list of hook functions to be called by
1671d422ce2eSmrg# FUNC_NAME.
16726257f37dSmrgfunc_remove_hook ()
16736257f37dSmrg{
16746257f37dSmrg    $debug_cmd
16756257f37dSmrg
16766257f37dSmrg    eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`'
16776257f37dSmrg}
16786257f37dSmrg
16796257f37dSmrg
1680d422ce2eSmrg# func_propagate_result FUNC_NAME_A FUNC_NAME_B
1681d422ce2eSmrg# ---------------------------------------------
1682d422ce2eSmrg# If the *_result variable of FUNC_NAME_A _is set_, assign its value to
1683d422ce2eSmrg# *_result variable of FUNC_NAME_B.
1684d422ce2eSmrgfunc_propagate_result ()
1685d422ce2eSmrg{
1686d422ce2eSmrg    $debug_cmd
1687d422ce2eSmrg
1688d422ce2eSmrg    func_propagate_result_result=:
1689d422ce2eSmrg    if eval "test \"\${${1}_result+set}\" = set"
1690d422ce2eSmrg    then
1691d422ce2eSmrg      eval "${2}_result=\$${1}_result"
1692d422ce2eSmrg    else
1693d422ce2eSmrg      func_propagate_result_result=false
1694d422ce2eSmrg    fi
1695d422ce2eSmrg}
1696d422ce2eSmrg
1697d422ce2eSmrg
16986257f37dSmrg# func_run_hooks FUNC_NAME [ARG]...
16996257f37dSmrg# ---------------------------------
17006257f37dSmrg# Run all hook functions registered to FUNC_NAME.
1701d422ce2eSmrg# It's assumed that the list of hook functions contains nothing more
17026257f37dSmrg# than a whitespace-delimited list of legal shell function names, and
17036257f37dSmrg# no effort is wasted trying to catch shell meta-characters or preserve
17046257f37dSmrg# whitespace.
17056257f37dSmrgfunc_run_hooks ()
17066257f37dSmrg{
17076257f37dSmrg    $debug_cmd
17086257f37dSmrg
17096257f37dSmrg    case " $hookable_fns " in
17106257f37dSmrg      *" $1 "*) ;;
1711d422ce2eSmrg      *) func_fatal_error "'$1' does not support hook functions." ;;
17126257f37dSmrg    esac
17136257f37dSmrg
17146257f37dSmrg    eval _G_hook_fns=\$$1_hooks; shift
17156257f37dSmrg
17166257f37dSmrg    for _G_hook in $_G_hook_fns; do
1717d422ce2eSmrg      func_unset "${_G_hook}_result"
1718d422ce2eSmrg      eval $_G_hook '${1+"$@"}'
1719d422ce2eSmrg      func_propagate_result $_G_hook func_run_hooks
1720d422ce2eSmrg      if $func_propagate_result_result; then
1721d422ce2eSmrg        eval set dummy "$func_run_hooks_result"; shift
1722d422ce2eSmrg      fi
17236257f37dSmrg    done
17246257f37dSmrg}
17256257f37dSmrg
17266257f37dSmrg
17276257f37dSmrg
17286257f37dSmrg## --------------- ##
17296257f37dSmrg## Option parsing. ##
17306257f37dSmrg## --------------- ##
17316257f37dSmrg
17326257f37dSmrg# In order to add your own option parsing hooks, you must accept the
1733d422ce2eSmrg# full positional parameter list from your hook function.  You may remove
1734d422ce2eSmrg# or edit any options that you action, and then pass back the remaining
1735d422ce2eSmrg# unprocessed options in '<hooked_function_name>_result', escaped
1736d422ce2eSmrg# suitably for 'eval'.
1737d422ce2eSmrg#
1738d422ce2eSmrg# The '<hooked_function_name>_result' variable is automatically unset
1739d422ce2eSmrg# before your hook gets called; for best performance, only set the
1740d422ce2eSmrg# *_result variable when necessary (i.e. don't call the 'func_quote'
1741d422ce2eSmrg# function unnecessarily because it can be an expensive operation on some
1742d422ce2eSmrg# machines).
1743d422ce2eSmrg#
1744d422ce2eSmrg# Like this:
17456257f37dSmrg#
17466257f37dSmrg#    my_options_prep ()
17476257f37dSmrg#    {
17486257f37dSmrg#        $debug_cmd
17496257f37dSmrg#
17506257f37dSmrg#        # Extend the existing usage message.
17516257f37dSmrg#        usage_message=$usage_message'
17526257f37dSmrg#      -s, --silent       don'\''t print informational messages
17536257f37dSmrg#    '
1754d422ce2eSmrg#        # No change in '$@' (ignored completely by this hook).  Leave
1755d422ce2eSmrg#        # my_options_prep_result variable intact.
17566257f37dSmrg#    }
17576257f37dSmrg#    func_add_hook func_options_prep my_options_prep
17586257f37dSmrg#
17596257f37dSmrg#
17606257f37dSmrg#    my_silent_option ()
17616257f37dSmrg#    {
17626257f37dSmrg#        $debug_cmd
17636257f37dSmrg#
1764d422ce2eSmrg#        args_changed=false
1765d422ce2eSmrg#
1766d422ce2eSmrg#        # Note that, for efficiency, we parse as many options as we can
17676257f37dSmrg#        # recognise in a loop before passing the remainder back to the
17686257f37dSmrg#        # caller on the first unrecognised argument we encounter.
17696257f37dSmrg#        while test $# -gt 0; do
17706257f37dSmrg#          opt=$1; shift
17716257f37dSmrg#          case $opt in
1772d422ce2eSmrg#            --silent|-s) opt_silent=:
1773d422ce2eSmrg#                         args_changed=:
1774d422ce2eSmrg#                         ;;
17756257f37dSmrg#            # Separate non-argument short options:
17766257f37dSmrg#            -s*)         func_split_short_opt "$_G_opt"
17776257f37dSmrg#                         set dummy "$func_split_short_opt_name" \
17786257f37dSmrg#                             "-$func_split_short_opt_arg" ${1+"$@"}
17796257f37dSmrg#                         shift
1780d422ce2eSmrg#                         args_changed=:
17816257f37dSmrg#                         ;;
1782d422ce2eSmrg#            *)           # Make sure the first unrecognised option "$_G_opt"
1783d422ce2eSmrg#                         # is added back to "$@" in case we need it later,
1784d422ce2eSmrg#                         # if $args_changed was set to 'true'.
1785d422ce2eSmrg#                         set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
17866257f37dSmrg#          esac
17876257f37dSmrg#        done
17886257f37dSmrg#
1789d422ce2eSmrg#        # Only call 'func_quote' here if we processed at least one argument.
1790d422ce2eSmrg#        if $args_changed; then
1791d422ce2eSmrg#          func_quote eval ${1+"$@"}
1792d422ce2eSmrg#          my_silent_option_result=$func_quote_result
1793d422ce2eSmrg#        fi
17946257f37dSmrg#    }
17956257f37dSmrg#    func_add_hook func_parse_options my_silent_option
17966257f37dSmrg#
17976257f37dSmrg#
17986257f37dSmrg#    my_option_validation ()
17996257f37dSmrg#    {
18006257f37dSmrg#        $debug_cmd
18016257f37dSmrg#
18026257f37dSmrg#        $opt_silent && $opt_verbose && func_fatal_help "\
18036257f37dSmrg#    '--silent' and '--verbose' options are mutually exclusive."
18046257f37dSmrg#    }
18056257f37dSmrg#    func_add_hook func_validate_options my_option_validation
18066257f37dSmrg#
1807d422ce2eSmrg# You'll also need to manually amend $usage_message to reflect the extra
18086257f37dSmrg# options you parse.  It's preferable to append if you can, so that
18096257f37dSmrg# multiple option parsing hooks can be added safely.
18106257f37dSmrg
18116257f37dSmrg
1812d422ce2eSmrg# func_options_finish [ARG]...
1813d422ce2eSmrg# ----------------------------
1814d422ce2eSmrg# Finishing the option parse loop (call 'func_options' hooks ATM).
1815d422ce2eSmrgfunc_options_finish ()
1816d422ce2eSmrg{
1817d422ce2eSmrg    $debug_cmd
1818d422ce2eSmrg
1819d422ce2eSmrg    func_run_hooks func_options ${1+"$@"}
1820d422ce2eSmrg    func_propagate_result func_run_hooks func_options_finish
1821d422ce2eSmrg}
1822d422ce2eSmrg
1823d422ce2eSmrg
18246257f37dSmrg# func_options [ARG]...
18256257f37dSmrg# ---------------------
18266257f37dSmrg# All the functions called inside func_options are hookable. See the
18276257f37dSmrg# individual implementations for details.
18286257f37dSmrgfunc_hookable func_options
18296257f37dSmrgfunc_options ()
18306257f37dSmrg{
18316257f37dSmrg    $debug_cmd
18326257f37dSmrg
1833d422ce2eSmrg    _G_options_quoted=false
18346257f37dSmrg
1835d422ce2eSmrg    for my_func in options_prep parse_options validate_options options_finish
1836d422ce2eSmrg    do
1837d422ce2eSmrg      func_unset func_${my_func}_result
1838d422ce2eSmrg      func_unset func_run_hooks_result
1839d422ce2eSmrg      eval func_$my_func '${1+"$@"}'
1840d422ce2eSmrg      func_propagate_result func_$my_func func_options
1841d422ce2eSmrg      if $func_propagate_result_result; then
1842d422ce2eSmrg        eval set dummy "$func_options_result"; shift
1843d422ce2eSmrg        _G_options_quoted=:
1844d422ce2eSmrg      fi
1845d422ce2eSmrg    done
18466257f37dSmrg
1847d422ce2eSmrg    $_G_options_quoted || {
1848d422ce2eSmrg      # As we (func_options) are top-level options-parser function and
1849d422ce2eSmrg      # nobody quoted "$@" for us yet, we need to do it explicitly for
1850d422ce2eSmrg      # caller.
1851d422ce2eSmrg      func_quote eval ${1+"$@"}
1852d422ce2eSmrg      func_options_result=$func_quote_result
1853d422ce2eSmrg    }
1854fc5a983dSmrg}
1855fc5a983dSmrg
1856fc5a983dSmrg
18576257f37dSmrg# func_options_prep [ARG]...
18586257f37dSmrg# --------------------------
18596257f37dSmrg# All initialisations required before starting the option parse loop.
18606257f37dSmrg# Note that when calling hook functions, we pass through the list of
18616257f37dSmrg# positional parameters.  If a hook function modifies that list, and
1862d422ce2eSmrg# needs to propagate that back to rest of this script, then the complete
1863d422ce2eSmrg# modified list must be put in 'func_run_hooks_result' before returning.
18646257f37dSmrgfunc_hookable func_options_prep
18656257f37dSmrgfunc_options_prep ()
1866fc5a983dSmrg{
18676257f37dSmrg    $debug_cmd
1868f3561b8bSmrg
18696257f37dSmrg    # Option defaults:
18706257f37dSmrg    opt_verbose=false
18716257f37dSmrg    opt_warning_types=
18726257f37dSmrg
18736257f37dSmrg    func_run_hooks func_options_prep ${1+"$@"}
1874d422ce2eSmrg    func_propagate_result func_run_hooks func_options_prep
1875fc5a983dSmrg}
1876fc5a983dSmrg
1877fc5a983dSmrg
18786257f37dSmrg# func_parse_options [ARG]...
18796257f37dSmrg# ---------------------------
18806257f37dSmrg# The main option parsing loop.
18816257f37dSmrgfunc_hookable func_parse_options
18826257f37dSmrgfunc_parse_options ()
1883fc5a983dSmrg{
18846257f37dSmrg    $debug_cmd
1885f3561b8bSmrg
1886d422ce2eSmrg    _G_parse_options_requote=false
18876257f37dSmrg    # this just eases exit handling
18886257f37dSmrg    while test $# -gt 0; do
18896257f37dSmrg      # Defer to hook functions for initial option parsing, so they
18906257f37dSmrg      # get priority in the event of reusing an option name.
18916257f37dSmrg      func_run_hooks func_parse_options ${1+"$@"}
1892d422ce2eSmrg      func_propagate_result func_run_hooks func_parse_options
1893d422ce2eSmrg      if $func_propagate_result_result; then
1894d422ce2eSmrg        eval set dummy "$func_parse_options_result"; shift
1895d422ce2eSmrg        # Even though we may have changed "$@", we passed the "$@" array
1896d422ce2eSmrg        # down into the hook and it quoted it for us (because we are in
1897d422ce2eSmrg        # this if-branch).  No need to quote it again.
1898d422ce2eSmrg        _G_parse_options_requote=false
1899d422ce2eSmrg      fi
1900fc5a983dSmrg
19016257f37dSmrg      # Break out of the loop if we already parsed every option.
19026257f37dSmrg      test $# -gt 0 || break
1903fc5a983dSmrg
1904d422ce2eSmrg      # We expect that one of the options parsed in this function matches
1905d422ce2eSmrg      # and thus we remove _G_opt from "$@" and need to re-quote.
1906d422ce2eSmrg      _G_match_parse_options=:
19076257f37dSmrg      _G_opt=$1
19086257f37dSmrg      shift
19096257f37dSmrg      case $_G_opt in
19106257f37dSmrg        --debug|-x)   debug_cmd='set -x'
1911d422ce2eSmrg                      func_echo "enabling shell trace mode" >&2
19126257f37dSmrg                      $debug_cmd
19136257f37dSmrg                      ;;
19146257f37dSmrg
19156257f37dSmrg        --no-warnings|--no-warning|--no-warn)
19166257f37dSmrg                      set dummy --warnings none ${1+"$@"}
19176257f37dSmrg                      shift
19186257f37dSmrg		      ;;
1919f3561b8bSmrg
19206257f37dSmrg        --warnings|--warning|-W)
1921d422ce2eSmrg                      if test $# = 0 && func_missing_arg $_G_opt; then
1922d422ce2eSmrg                        _G_parse_options_requote=:
1923d422ce2eSmrg                        break
1924d422ce2eSmrg                      fi
19256257f37dSmrg                      case " $warning_categories $1" in
19266257f37dSmrg                        *" $1 "*)
19276257f37dSmrg                          # trailing space prevents matching last $1 above
19286257f37dSmrg                          func_append_uniq opt_warning_types " $1"
19296257f37dSmrg                          ;;
19306257f37dSmrg                        *all)
19316257f37dSmrg                          opt_warning_types=$warning_categories
19326257f37dSmrg                          ;;
19336257f37dSmrg                        *none)
19346257f37dSmrg                          opt_warning_types=none
19356257f37dSmrg                          warning_func=:
19366257f37dSmrg                          ;;
19376257f37dSmrg                        *error)
19386257f37dSmrg                          opt_warning_types=$warning_categories
19396257f37dSmrg                          warning_func=func_fatal_error
19406257f37dSmrg                          ;;
19416257f37dSmrg                        *)
19426257f37dSmrg                          func_fatal_error \
19436257f37dSmrg                             "unsupported warning category: '$1'"
19446257f37dSmrg                          ;;
19456257f37dSmrg                      esac
19466257f37dSmrg                      shift
19476257f37dSmrg                      ;;
19486257f37dSmrg
19496257f37dSmrg        --verbose|-v) opt_verbose=: ;;
19506257f37dSmrg        --version)    func_version ;;
19516257f37dSmrg        -\?|-h)       func_usage ;;
19526257f37dSmrg        --help)       func_help ;;
19536257f37dSmrg
19546257f37dSmrg	# Separate optargs to long options (plugins may need this):
19556257f37dSmrg	--*=*)        func_split_equals "$_G_opt"
19566257f37dSmrg	              set dummy "$func_split_equals_lhs" \
19576257f37dSmrg                          "$func_split_equals_rhs" ${1+"$@"}
19586257f37dSmrg                      shift
19596257f37dSmrg                      ;;
19606257f37dSmrg
19616257f37dSmrg       # Separate optargs to short options:
19626257f37dSmrg        -W*)
19636257f37dSmrg                      func_split_short_opt "$_G_opt"
19646257f37dSmrg                      set dummy "$func_split_short_opt_name" \
19656257f37dSmrg                          "$func_split_short_opt_arg" ${1+"$@"}
19666257f37dSmrg                      shift
19676257f37dSmrg                      ;;
19686257f37dSmrg
19696257f37dSmrg        # Separate non-argument short options:
19706257f37dSmrg        -\?*|-h*|-v*|-x*)
19716257f37dSmrg                      func_split_short_opt "$_G_opt"
19726257f37dSmrg                      set dummy "$func_split_short_opt_name" \
19736257f37dSmrg                          "-$func_split_short_opt_arg" ${1+"$@"}
19746257f37dSmrg                      shift
19756257f37dSmrg                      ;;
19766257f37dSmrg
1977d422ce2eSmrg        --)           _G_parse_options_requote=: ; break ;;
19786257f37dSmrg        -*)           func_fatal_help "unrecognised option: '$_G_opt'" ;;
1979d422ce2eSmrg        *)            set dummy "$_G_opt" ${1+"$@"}; shift
1980d422ce2eSmrg                      _G_match_parse_options=false
1981d422ce2eSmrg                      break
1982d422ce2eSmrg                      ;;
19836257f37dSmrg      esac
1984d422ce2eSmrg
1985d422ce2eSmrg      if $_G_match_parse_options; then
1986d422ce2eSmrg        _G_parse_options_requote=:
1987d422ce2eSmrg      fi
19886257f37dSmrg    done
19896257f37dSmrg
1990d422ce2eSmrg    if $_G_parse_options_requote; then
1991d422ce2eSmrg      # save modified positional parameters for caller
1992d422ce2eSmrg      func_quote eval ${1+"$@"}
1993d422ce2eSmrg      func_parse_options_result=$func_quote_result
1994d422ce2eSmrg    fi
1995fc5a983dSmrg}
1996fc5a983dSmrg
1997f3561b8bSmrg
19986257f37dSmrg# func_validate_options [ARG]...
19996257f37dSmrg# ------------------------------
20006257f37dSmrg# Perform any sanity checks on option settings and/or unconsumed
20016257f37dSmrg# arguments.
20026257f37dSmrgfunc_hookable func_validate_options
20036257f37dSmrgfunc_validate_options ()
2004fc5a983dSmrg{
20056257f37dSmrg    $debug_cmd
2006f3561b8bSmrg
20076257f37dSmrg    # Display all warnings if -W was not given.
20086257f37dSmrg    test -n "$opt_warning_types" || opt_warning_types=" $warning_categories"
2009f3561b8bSmrg
20106257f37dSmrg    func_run_hooks func_validate_options ${1+"$@"}
2011d422ce2eSmrg    func_propagate_result func_run_hooks func_validate_options
2012fc5a983dSmrg
20136257f37dSmrg    # Bail if the options were screwed!
20146257f37dSmrg    $exit_cmd $EXIT_FAILURE
2015bd304fc0Smrg}
2016f3561b8bSmrg
2017f3561b8bSmrg
2018bd304fc0Smrg
20196257f37dSmrg## ----------------- ##
20206257f37dSmrg## Helper functions. ##
20216257f37dSmrg## ----------------- ##
2022f3561b8bSmrg
20236257f37dSmrg# This section contains the helper functions used by the rest of the
20246257f37dSmrg# hookable option parser framework in ascii-betical order.
20256257f37dSmrg
20266257f37dSmrg
20276257f37dSmrg# func_fatal_help ARG...
20286257f37dSmrg# ----------------------
20296257f37dSmrg# Echo program name prefixed message to standard error, followed by
20306257f37dSmrg# a help hint, and exit.
20316257f37dSmrgfunc_fatal_help ()
2032f3561b8bSmrg{
20336257f37dSmrg    $debug_cmd
2034bd304fc0Smrg
20356257f37dSmrg    eval \$ECHO \""Usage: $usage"\"
20366257f37dSmrg    eval \$ECHO \""$fatal_help"\"
20376257f37dSmrg    func_error ${1+"$@"}
20386257f37dSmrg    exit $EXIT_FAILURE
2039f3561b8bSmrg}
2040f3561b8bSmrg
20416257f37dSmrg
20426257f37dSmrg# func_help
20436257f37dSmrg# ---------
20446257f37dSmrg# Echo long help message to standard output and exit.
2045f3561b8bSmrgfunc_help ()
2046f3561b8bSmrg{
20476257f37dSmrg    $debug_cmd
20486257f37dSmrg
20496257f37dSmrg    func_usage_message
20506257f37dSmrg    $ECHO "$long_help_message"
20516257f37dSmrg    exit 0
2052f3561b8bSmrg}
2053f3561b8bSmrg
20546257f37dSmrg
20556257f37dSmrg# func_missing_arg ARGNAME
20566257f37dSmrg# ------------------------
2057f3561b8bSmrg# Echo program name prefixed message to standard error and set global
2058f3561b8bSmrg# exit_cmd.
2059f3561b8bSmrgfunc_missing_arg ()
2060f3561b8bSmrg{
20616257f37dSmrg    $debug_cmd
2062bd304fc0Smrg
20636257f37dSmrg    func_error "Missing argument for '$1'."
2064f3561b8bSmrg    exit_cmd=exit
2065fc5a983dSmrg}
2066fc5a983dSmrg
2067fc5a983dSmrg
20686257f37dSmrg# func_split_equals STRING
20696257f37dSmrg# ------------------------
2070d422ce2eSmrg# Set func_split_equals_lhs and func_split_equals_rhs shell variables
2071d422ce2eSmrg# after splitting STRING at the '=' sign.
20726257f37dSmrgtest -z "$_G_HAVE_XSI_OPS" \
20736257f37dSmrg    && (eval 'x=a/b/c;
20746257f37dSmrg      test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
20756257f37dSmrg    && _G_HAVE_XSI_OPS=yes
20766257f37dSmrg
20776257f37dSmrgif test yes = "$_G_HAVE_XSI_OPS"
20786257f37dSmrgthen
20796257f37dSmrg  # This is an XSI compatible shell, allowing a faster implementation...
20806257f37dSmrg  eval 'func_split_equals ()
20816257f37dSmrg  {
20826257f37dSmrg      $debug_cmd
20836257f37dSmrg
20846257f37dSmrg      func_split_equals_lhs=${1%%=*}
20856257f37dSmrg      func_split_equals_rhs=${1#*=}
2086d422ce2eSmrg      if test "x$func_split_equals_lhs" = "x$1"; then
2087d422ce2eSmrg        func_split_equals_rhs=
2088d422ce2eSmrg      fi
20896257f37dSmrg  }'
20906257f37dSmrgelse
20916257f37dSmrg  # ...otherwise fall back to using expr, which is often a shell builtin.
20926257f37dSmrg  func_split_equals ()
20936257f37dSmrg  {
20946257f37dSmrg      $debug_cmd
20956257f37dSmrg
20966257f37dSmrg      func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'`
20976257f37dSmrg      func_split_equals_rhs=
2098d422ce2eSmrg      test "x$func_split_equals_lhs=" = "x$1" \
20996257f37dSmrg        || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'`
21006257f37dSmrg  }
21016257f37dSmrgfi #func_split_equals
21026257f37dSmrg
21036257f37dSmrg
21046257f37dSmrg# func_split_short_opt SHORTOPT
21056257f37dSmrg# -----------------------------
2106bd304fc0Smrg# Set func_split_short_opt_name and func_split_short_opt_arg shell
2107bd304fc0Smrg# variables after splitting SHORTOPT after the 2nd character.
21086257f37dSmrgif test yes = "$_G_HAVE_XSI_OPS"
21096257f37dSmrgthen
21106257f37dSmrg  # This is an XSI compatible shell, allowing a faster implementation...
21116257f37dSmrg  eval 'func_split_short_opt ()
21126257f37dSmrg  {
21136257f37dSmrg      $debug_cmd
21146257f37dSmrg
21156257f37dSmrg      func_split_short_opt_arg=${1#??}
21166257f37dSmrg      func_split_short_opt_name=${1%"$func_split_short_opt_arg"}
21176257f37dSmrg  }'
21186257f37dSmrgelse
21196257f37dSmrg  # ...otherwise fall back to using expr, which is often a shell builtin.
21206257f37dSmrg  func_split_short_opt ()
21216257f37dSmrg  {
21226257f37dSmrg      $debug_cmd
21236257f37dSmrg
2124d422ce2eSmrg      func_split_short_opt_name=`expr "x$1" : 'x\(-.\)'`
21256257f37dSmrg      func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'`
21266257f37dSmrg  }
21276257f37dSmrgfi #func_split_short_opt
21286257f37dSmrg
21296257f37dSmrg
21306257f37dSmrg# func_usage
21316257f37dSmrg# ----------
21326257f37dSmrg# Echo short help message to standard output and exit.
21336257f37dSmrgfunc_usage ()
2134bd304fc0Smrg{
21356257f37dSmrg    $debug_cmd
2136bd304fc0Smrg
21376257f37dSmrg    func_usage_message
21386257f37dSmrg    $ECHO "Run '$progname --help |${PAGER-more}' for full usage"
21396257f37dSmrg    exit 0
21406257f37dSmrg}
2141fc5a983dSmrg
2142f3561b8bSmrg
21436257f37dSmrg# func_usage_message
21446257f37dSmrg# ------------------
21456257f37dSmrg# Echo short help message to standard output.
21466257f37dSmrgfunc_usage_message ()
2147bd304fc0Smrg{
21486257f37dSmrg    $debug_cmd
2149bd304fc0Smrg
21506257f37dSmrg    eval \$ECHO \""Usage: $usage"\"
21516257f37dSmrg    echo
21526257f37dSmrg    $SED -n 's|^# ||
21536257f37dSmrg        /^Written by/{
21546257f37dSmrg          x;p;x
21556257f37dSmrg        }
21566257f37dSmrg	h
21576257f37dSmrg	/^Written by/q' < "$progpath"
21586257f37dSmrg    echo
21596257f37dSmrg    eval \$ECHO \""$usage_message"\"
21606257f37dSmrg}
2161bd304fc0Smrg
2162bd304fc0Smrg
21636257f37dSmrg# func_version
21646257f37dSmrg# ------------
21656257f37dSmrg# Echo version message to standard output and exit.
2166d422ce2eSmrg# The version message is extracted from the calling file's header
2167d422ce2eSmrg# comments, with leading '# ' stripped:
2168d422ce2eSmrg#   1. First display the progname and version
2169d422ce2eSmrg#   2. Followed by the header comment line matching  /^# Written by /
2170d422ce2eSmrg#   3. Then a blank line followed by the first following line matching
2171d422ce2eSmrg#      /^# Copyright /
2172d422ce2eSmrg#   4. Immediately followed by any lines between the previous matches,
2173d422ce2eSmrg#      except lines preceding the intervening completely blank line.
2174d422ce2eSmrg# For example, see the header comments of this file.
21756257f37dSmrgfunc_version ()
21766257f37dSmrg{
21776257f37dSmrg    $debug_cmd
2178f3561b8bSmrg
21796257f37dSmrg    printf '%s\n' "$progname $scriptversion"
21806257f37dSmrg    $SED -n '
2181d422ce2eSmrg        /^# Written by /!b
2182d422ce2eSmrg        s|^# ||; p; n
2183d422ce2eSmrg
2184d422ce2eSmrg        :fwd2blnk
2185d422ce2eSmrg        /./ {
2186d422ce2eSmrg          n
2187d422ce2eSmrg          b fwd2blnk
21886257f37dSmrg        }
2189d422ce2eSmrg        p; n
2190d422ce2eSmrg
2191d422ce2eSmrg        :holdwrnt
2192d422ce2eSmrg        s|^# ||
2193d422ce2eSmrg        s|^# *$||
2194d422ce2eSmrg        /^Copyright /!{
2195d422ce2eSmrg          /./H
2196d422ce2eSmrg          n
2197d422ce2eSmrg          b holdwrnt
21986257f37dSmrg        }
2199d422ce2eSmrg
2200d422ce2eSmrg        s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2|
2201d422ce2eSmrg        G
2202d422ce2eSmrg        s|\(\n\)\n*|\1|g
2203d422ce2eSmrg        p; q' < "$progpath"
2204f3561b8bSmrg
22056257f37dSmrg    exit $?
22066257f37dSmrg}
2207fc5a983dSmrg
2208fc5a983dSmrg
22096257f37dSmrg# Local variables:
22106257f37dSmrg# mode: shell-script
22116257f37dSmrg# sh-indentation: 2
22126257f37dSmrg# eval: (add-hook 'before-save-hook 'time-stamp)
2213d422ce2eSmrg# time-stamp-pattern: "30/scriptversion=%:y-%02m-%02d.%02H; # UTC"
22146257f37dSmrg# time-stamp-time-zone: "UTC"
22156257f37dSmrg# End:
2216fc5a983dSmrg
22176257f37dSmrg# Set a version string.
2218d422ce2eSmrgscriptversion='(GNU libtool) 2.4.7'
2219fc5a983dSmrg
2220f3561b8bSmrg
22216257f37dSmrg# func_echo ARG...
22226257f37dSmrg# ----------------
22236257f37dSmrg# Libtool also displays the current mode in messages, so override
22246257f37dSmrg# funclib.sh func_echo with this custom definition.
22256257f37dSmrgfunc_echo ()
2226bd304fc0Smrg{
22276257f37dSmrg    $debug_cmd
2228bd304fc0Smrg
22296257f37dSmrg    _G_message=$*
2230bd304fc0Smrg
22316257f37dSmrg    func_echo_IFS=$IFS
22326257f37dSmrg    IFS=$nl
22336257f37dSmrg    for _G_line in $_G_message; do
22346257f37dSmrg      IFS=$func_echo_IFS
22356257f37dSmrg      $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line"
22366257f37dSmrg    done
22376257f37dSmrg    IFS=$func_echo_IFS
22386257f37dSmrg}
2239bd304fc0Smrg
22406257f37dSmrg
22416257f37dSmrg# func_warning ARG...
22426257f37dSmrg# -------------------
22436257f37dSmrg# Libtool warnings are not categorized, so override funclib.sh
22446257f37dSmrg# func_warning with this simpler definition.
22456257f37dSmrgfunc_warning ()
2246bd304fc0Smrg{
22476257f37dSmrg    $debug_cmd
2248bd304fc0Smrg
22496257f37dSmrg    $warning_func ${1+"$@"}
22506257f37dSmrg}
2251bd304fc0Smrg
2252bd304fc0Smrg
22536257f37dSmrg## ---------------- ##
22546257f37dSmrg## Options parsing. ##
22556257f37dSmrg## ---------------- ##
22566257f37dSmrg
22576257f37dSmrg# Hook in the functions to make sure our own options are parsed during
22586257f37dSmrg# the option parsing loop.
22596257f37dSmrg
22606257f37dSmrgusage='$progpath [OPTION]... [MODE-ARG]...'
22616257f37dSmrg
22626257f37dSmrg# Short help message in response to '-h'.
22636257f37dSmrgusage_message="Options:
22646257f37dSmrg       --config             show all configuration variables
22656257f37dSmrg       --debug              enable verbose shell tracing
22666257f37dSmrg   -n, --dry-run            display commands without modifying any files
22676257f37dSmrg       --features           display basic configuration information and exit
22686257f37dSmrg       --mode=MODE          use operation mode MODE
22696257f37dSmrg       --no-warnings        equivalent to '-Wnone'
22706257f37dSmrg       --preserve-dup-deps  don't remove duplicate dependency libraries
22716257f37dSmrg       --quiet, --silent    don't print informational messages
22726257f37dSmrg       --tag=TAG            use configuration variables from tag TAG
22736257f37dSmrg   -v, --verbose            print more informational messages than default
22746257f37dSmrg       --version            print version information
22756257f37dSmrg   -W, --warnings=CATEGORY  report the warnings falling in CATEGORY [all]
22766257f37dSmrg   -h, --help, --help-all   print short, long, or detailed help message
22776257f37dSmrg"
2278bd304fc0Smrg
22796257f37dSmrg# Additional text appended to 'usage_message' in response to '--help'.
22806257f37dSmrgfunc_help ()
2281bd304fc0Smrg{
22826257f37dSmrg    $debug_cmd
22836257f37dSmrg
22846257f37dSmrg    func_usage_message
22856257f37dSmrg    $ECHO "$long_help_message
22866257f37dSmrg
22876257f37dSmrgMODE must be one of the following:
22886257f37dSmrg
22896257f37dSmrg       clean           remove files from the build directory
22906257f37dSmrg       compile         compile a source file into a libtool object
22916257f37dSmrg       execute         automatically set library path, then run a program
22926257f37dSmrg       finish          complete the installation of libtool libraries
22936257f37dSmrg       install         install libraries or executables
22946257f37dSmrg       link            create a library or an executable
22956257f37dSmrg       uninstall       remove libraries from an installed directory
22966257f37dSmrg
22976257f37dSmrgMODE-ARGS vary depending on the MODE.  When passed as first option,
22986257f37dSmrg'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that.
22996257f37dSmrgTry '$progname --help --mode=MODE' for a more detailed description of MODE.
23006257f37dSmrg
23016257f37dSmrgWhen reporting a bug, please describe a test case to reproduce it and
23026257f37dSmrginclude the following information:
23036257f37dSmrg
23046257f37dSmrg       host-triplet:   $host
23056257f37dSmrg       shell:          $SHELL
23066257f37dSmrg       compiler:       $LTCC
23076257f37dSmrg       compiler flags: $LTCFLAGS
23086257f37dSmrg       linker:         $LD (gnu? $with_gnu_ld)
2309d422ce2eSmrg       version:        $progname (GNU libtool) 2.4.7
23106257f37dSmrg       automake:       `($AUTOMAKE --version) 2>/dev/null |$SED 1q`
23116257f37dSmrg       autoconf:       `($AUTOCONF --version) 2>/dev/null |$SED 1q`
23126257f37dSmrg
23136257f37dSmrgReport bugs to <bug-libtool@gnu.org>.
23146257f37dSmrgGNU libtool home page: <http://www.gnu.org/software/libtool/>.
23156257f37dSmrgGeneral help using GNU software: <http://www.gnu.org/gethelp/>."
23166257f37dSmrg    exit 0
23176257f37dSmrg}
2318bd304fc0Smrg
2319bd304fc0Smrg
23206257f37dSmrg# func_lo2o OBJECT-NAME
23216257f37dSmrg# ---------------------
23226257f37dSmrg# Transform OBJECT-NAME from a '.lo' suffix to the platform specific
23236257f37dSmrg# object suffix.
23246257f37dSmrg
23256257f37dSmrglo2o=s/\\.lo\$/.$objext/
23266257f37dSmrgo2lo=s/\\.$objext\$/.lo/
23276257f37dSmrg
23286257f37dSmrgif test yes = "$_G_HAVE_XSI_OPS"; then
23296257f37dSmrg  eval 'func_lo2o ()
23306257f37dSmrg  {
23316257f37dSmrg    case $1 in
23326257f37dSmrg      *.lo) func_lo2o_result=${1%.lo}.$objext ;;
23336257f37dSmrg      *   ) func_lo2o_result=$1               ;;
23346257f37dSmrg    esac
23356257f37dSmrg  }'
23366257f37dSmrg
23376257f37dSmrg  # func_xform LIBOBJ-OR-SOURCE
23386257f37dSmrg  # ---------------------------
23396257f37dSmrg  # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise)
23406257f37dSmrg  # suffix to a '.lo' libtool-object suffix.
23416257f37dSmrg  eval 'func_xform ()
23426257f37dSmrg  {
23436257f37dSmrg    func_xform_result=${1%.*}.lo
23446257f37dSmrg  }'
23456257f37dSmrgelse
23466257f37dSmrg  # ...otherwise fall back to using sed.
23476257f37dSmrg  func_lo2o ()
23486257f37dSmrg  {
23496257f37dSmrg    func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"`
23506257f37dSmrg  }
23516257f37dSmrg
23526257f37dSmrg  func_xform ()
23536257f37dSmrg  {
23546257f37dSmrg    func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'`
23556257f37dSmrg  }
23566257f37dSmrgfi
2357bd304fc0Smrg
2358bd304fc0Smrg
23596257f37dSmrg# func_fatal_configuration ARG...
23606257f37dSmrg# -------------------------------
2361f3561b8bSmrg# Echo program name prefixed message to standard error, followed by
2362f3561b8bSmrg# a configuration failure hint, and exit.
2363f3561b8bSmrgfunc_fatal_configuration ()
2364f3561b8bSmrg{
2365d422ce2eSmrg    func_fatal_error ${1+"$@"} \
23666257f37dSmrg      "See the $PACKAGE documentation for more information." \
23676257f37dSmrg      "Fatal configuration error."
2368f3561b8bSmrg}
2369fc5a983dSmrg
2370fc5a983dSmrg
2371f3561b8bSmrg# func_config
23726257f37dSmrg# -----------
2373f3561b8bSmrg# Display the configuration for all the tags in this script.
2374f3561b8bSmrgfunc_config ()
2375f3561b8bSmrg{
2376f3561b8bSmrg    re_begincf='^# ### BEGIN LIBTOOL'
2377f3561b8bSmrg    re_endcf='^# ### END LIBTOOL'
2378f3561b8bSmrg
2379f3561b8bSmrg    # Default configuration.
2380f3561b8bSmrg    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
2381fc5a983dSmrg
2382fc5a983dSmrg    # Now print the configurations for the tags.
2383fc5a983dSmrg    for tagname in $taglist; do
2384f3561b8bSmrg      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
2385fc5a983dSmrg    done
2386fc5a983dSmrg
2387f3561b8bSmrg    exit $?
2388f3561b8bSmrg}
2389fc5a983dSmrg
23906257f37dSmrg
2391f3561b8bSmrg# func_features
23926257f37dSmrg# -------------
2393f3561b8bSmrg# Display the features supported by this script.
2394f3561b8bSmrgfunc_features ()
2395f3561b8bSmrg{
2396bd304fc0Smrg    echo "host: $host"
23976257f37dSmrg    if test yes = "$build_libtool_libs"; then
2398bd304fc0Smrg      echo "enable shared libraries"
2399fc5a983dSmrg    else
2400bd304fc0Smrg      echo "disable shared libraries"
2401fc5a983dSmrg    fi
24026257f37dSmrg    if test yes = "$build_old_libs"; then
2403bd304fc0Smrg      echo "enable static libraries"
2404fc5a983dSmrg    else
2405bd304fc0Smrg      echo "disable static libraries"
2406fc5a983dSmrg    fi
2407f3561b8bSmrg
2408fc5a983dSmrg    exit $?
2409f3561b8bSmrg}
2410fc5a983dSmrg
24116257f37dSmrg
24126257f37dSmrg# func_enable_tag TAGNAME
24136257f37dSmrg# -----------------------
2414f3561b8bSmrg# Verify that TAGNAME is valid, and either flag an error and exit, or
2415f3561b8bSmrg# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
2416f3561b8bSmrg# variable here.
2417f3561b8bSmrgfunc_enable_tag ()
2418f3561b8bSmrg{
24196257f37dSmrg    # Global variable:
24206257f37dSmrg    tagname=$1
2421fc5a983dSmrg
24226257f37dSmrg    re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
24236257f37dSmrg    re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
24246257f37dSmrg    sed_extractcf=/$re_begincf/,/$re_endcf/p
2425fc5a983dSmrg
24266257f37dSmrg    # Validate tagname.
24276257f37dSmrg    case $tagname in
24286257f37dSmrg      *[!-_A-Za-z0-9,/]*)
24296257f37dSmrg        func_fatal_error "invalid tag name: $tagname"
24306257f37dSmrg        ;;
24316257f37dSmrg    esac
2432fc5a983dSmrg
24336257f37dSmrg    # Don't test for the "default" C tag, as we know it's
24346257f37dSmrg    # there but not specially marked.
24356257f37dSmrg    case $tagname in
24366257f37dSmrg        CC) ;;
2437f3561b8bSmrg    *)
24386257f37dSmrg        if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
24396257f37dSmrg	  taglist="$taglist $tagname"
24406257f37dSmrg
24416257f37dSmrg	  # Evaluate the configuration.  Be careful to quote the path
24426257f37dSmrg	  # and the sed script, to avoid splitting on whitespace, but
24436257f37dSmrg	  # also don't use non-portable quotes within backquotes within
24446257f37dSmrg	  # quotes we have to do it in 2 steps:
24456257f37dSmrg	  extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
24466257f37dSmrg	  eval "$extractedcf"
24476257f37dSmrg        else
24486257f37dSmrg	  func_error "ignoring unknown tag $tagname"
24496257f37dSmrg        fi
24506257f37dSmrg        ;;
24516257f37dSmrg    esac
2452f3561b8bSmrg}
2453f3561b8bSmrg
24546257f37dSmrg
2455bd304fc0Smrg# func_check_version_match
24566257f37dSmrg# ------------------------
2457bd304fc0Smrg# Ensure that we are using m4 macros, and libtool script from the same
2458bd304fc0Smrg# release of libtool.
2459bd304fc0Smrgfunc_check_version_match ()
2460f3561b8bSmrg{
24616257f37dSmrg    if test "$package_revision" != "$macro_revision"; then
24626257f37dSmrg      if test "$VERSION" != "$macro_version"; then
24636257f37dSmrg        if test -z "$macro_version"; then
24646257f37dSmrg          cat >&2 <<_LT_EOF
2465bd304fc0Smrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
2466bd304fc0Smrg$progname: definition of this LT_INIT comes from an older release.
2467bd304fc0Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
2468bd304fc0Smrg$progname: and run autoconf again.
2469bd304fc0Smrg_LT_EOF
24706257f37dSmrg        else
24716257f37dSmrg          cat >&2 <<_LT_EOF
2472bd304fc0Smrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
2473bd304fc0Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
2474bd304fc0Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
2475bd304fc0Smrg$progname: and run autoconf again.
2476bd304fc0Smrg_LT_EOF
24776257f37dSmrg        fi
24786257f37dSmrg      else
24796257f37dSmrg        cat >&2 <<_LT_EOF
2480bd304fc0Smrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
2481bd304fc0Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision.
2482bd304fc0Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision
2483bd304fc0Smrg$progname: of $PACKAGE $VERSION and run autoconf again.
2484bd304fc0Smrg_LT_EOF
24856257f37dSmrg      fi
2486bd304fc0Smrg
24876257f37dSmrg      exit $EXIT_MISMATCH
24886257f37dSmrg    fi
2489bd304fc0Smrg}
2490bd304fc0Smrg
2491bd304fc0Smrg
24926257f37dSmrg# libtool_options_prep [ARG]...
24936257f37dSmrg# -----------------------------
24946257f37dSmrg# Preparation for options parsed by libtool.
24956257f37dSmrglibtool_options_prep ()
24966257f37dSmrg{
24976257f37dSmrg    $debug_mode
2498fc5a983dSmrg
24996257f37dSmrg    # Option defaults:
25006257f37dSmrg    opt_config=false
25016257f37dSmrg    opt_dlopen=
25026257f37dSmrg    opt_dry_run=false
25036257f37dSmrg    opt_help=false
25046257f37dSmrg    opt_mode=
25056257f37dSmrg    opt_preserve_dup_deps=false
25066257f37dSmrg    opt_quiet=false
2507fc5a983dSmrg
25086257f37dSmrg    nonopt=
25096257f37dSmrg    preserve_args=
2510bd304fc0Smrg
2511d422ce2eSmrg    _G_rc_lt_options_prep=:
2512d422ce2eSmrg
25136257f37dSmrg    # Shorthand for --mode=foo, only valid as the first argument
25146257f37dSmrg    case $1 in
25156257f37dSmrg    clean|clea|cle|cl)
25166257f37dSmrg      shift; set dummy --mode clean ${1+"$@"}; shift
25176257f37dSmrg      ;;
25186257f37dSmrg    compile|compil|compi|comp|com|co|c)
25196257f37dSmrg      shift; set dummy --mode compile ${1+"$@"}; shift
25206257f37dSmrg      ;;
25216257f37dSmrg    execute|execut|execu|exec|exe|ex|e)
25226257f37dSmrg      shift; set dummy --mode execute ${1+"$@"}; shift
25236257f37dSmrg      ;;
25246257f37dSmrg    finish|finis|fini|fin|fi|f)
25256257f37dSmrg      shift; set dummy --mode finish ${1+"$@"}; shift
25266257f37dSmrg      ;;
25276257f37dSmrg    install|instal|insta|inst|ins|in|i)
25286257f37dSmrg      shift; set dummy --mode install ${1+"$@"}; shift
25296257f37dSmrg      ;;
25306257f37dSmrg    link|lin|li|l)
25316257f37dSmrg      shift; set dummy --mode link ${1+"$@"}; shift
25326257f37dSmrg      ;;
25336257f37dSmrg    uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
25346257f37dSmrg      shift; set dummy --mode uninstall ${1+"$@"}; shift
25356257f37dSmrg      ;;
2536d422ce2eSmrg    *)
2537d422ce2eSmrg      _G_rc_lt_options_prep=false
2538d422ce2eSmrg      ;;
25396257f37dSmrg    esac
25406257f37dSmrg
2541d422ce2eSmrg    if $_G_rc_lt_options_prep; then
2542d422ce2eSmrg      # Pass back the list of options.
2543d422ce2eSmrg      func_quote eval ${1+"$@"}
2544d422ce2eSmrg      libtool_options_prep_result=$func_quote_result
2545d422ce2eSmrg    fi
25466257f37dSmrg}
25476257f37dSmrgfunc_add_hook func_options_prep libtool_options_prep
2548bd304fc0Smrg
2549bd304fc0Smrg
25506257f37dSmrg# libtool_parse_options [ARG]...
25516257f37dSmrg# ---------------------------------
25526257f37dSmrg# Provide handling for libtool specific options.
25536257f37dSmrglibtool_parse_options ()
2554bd304fc0Smrg{
25556257f37dSmrg    $debug_cmd
2556f3561b8bSmrg
2557d422ce2eSmrg    _G_rc_lt_parse_options=false
2558d422ce2eSmrg
25596257f37dSmrg    # Perform our own loop to consume as many options as possible in
25606257f37dSmrg    # each iteration.
25616257f37dSmrg    while test $# -gt 0; do
2562d422ce2eSmrg      _G_match_lt_parse_options=:
25636257f37dSmrg      _G_opt=$1
25646257f37dSmrg      shift
25656257f37dSmrg      case $_G_opt in
25666257f37dSmrg        --dry-run|--dryrun|-n)
25676257f37dSmrg                        opt_dry_run=:
25686257f37dSmrg                        ;;
25696257f37dSmrg
25706257f37dSmrg        --config)       func_config ;;
25716257f37dSmrg
25726257f37dSmrg        --dlopen|-dlopen)
25736257f37dSmrg                        opt_dlopen="${opt_dlopen+$opt_dlopen
25746257f37dSmrg}$1"
25756257f37dSmrg                        shift
25766257f37dSmrg                        ;;
25776257f37dSmrg
25786257f37dSmrg        --preserve-dup-deps)
25796257f37dSmrg                        opt_preserve_dup_deps=: ;;
25806257f37dSmrg
25816257f37dSmrg        --features)     func_features ;;
25826257f37dSmrg
25836257f37dSmrg        --finish)       set dummy --mode finish ${1+"$@"}; shift ;;
25846257f37dSmrg
25856257f37dSmrg        --help)         opt_help=: ;;
25866257f37dSmrg
25876257f37dSmrg        --help-all)     opt_help=': help-all' ;;
25886257f37dSmrg
25896257f37dSmrg        --mode)         test $# = 0 && func_missing_arg $_G_opt && break
25906257f37dSmrg                        opt_mode=$1
25916257f37dSmrg                        case $1 in
25926257f37dSmrg                          # Valid mode arguments:
25936257f37dSmrg                          clean|compile|execute|finish|install|link|relink|uninstall) ;;
25946257f37dSmrg
25956257f37dSmrg                          # Catch anything else as an error
25966257f37dSmrg                          *) func_error "invalid argument for $_G_opt"
25976257f37dSmrg                             exit_cmd=exit
25986257f37dSmrg                             break
25996257f37dSmrg                             ;;
26006257f37dSmrg                        esac
26016257f37dSmrg                        shift
26026257f37dSmrg                        ;;
26036257f37dSmrg
26046257f37dSmrg        --no-silent|--no-quiet)
26056257f37dSmrg                        opt_quiet=false
26066257f37dSmrg                        func_append preserve_args " $_G_opt"
26076257f37dSmrg                        ;;
26086257f37dSmrg
26096257f37dSmrg        --no-warnings|--no-warning|--no-warn)
26106257f37dSmrg                        opt_warning=false
26116257f37dSmrg                        func_append preserve_args " $_G_opt"
26126257f37dSmrg                        ;;
26136257f37dSmrg
26146257f37dSmrg        --no-verbose)
26156257f37dSmrg                        opt_verbose=false
26166257f37dSmrg                        func_append preserve_args " $_G_opt"
26176257f37dSmrg                        ;;
26186257f37dSmrg
26196257f37dSmrg        --silent|--quiet)
26206257f37dSmrg                        opt_quiet=:
26216257f37dSmrg                        opt_verbose=false
26226257f37dSmrg                        func_append preserve_args " $_G_opt"
26236257f37dSmrg                        ;;
26246257f37dSmrg
26256257f37dSmrg        --tag)          test $# = 0 && func_missing_arg $_G_opt && break
26266257f37dSmrg                        opt_tag=$1
26276257f37dSmrg                        func_append preserve_args " $_G_opt $1"
26286257f37dSmrg                        func_enable_tag "$1"
26296257f37dSmrg                        shift
26306257f37dSmrg                        ;;
26316257f37dSmrg
26326257f37dSmrg        --verbose|-v)   opt_quiet=false
26336257f37dSmrg                        opt_verbose=:
26346257f37dSmrg                        func_append preserve_args " $_G_opt"
26356257f37dSmrg                        ;;
26366257f37dSmrg
2637d422ce2eSmrg        # An option not handled by this hook function:
2638d422ce2eSmrg        *)              set dummy "$_G_opt" ${1+"$@"} ; shift
2639d422ce2eSmrg                        _G_match_lt_parse_options=false
2640d422ce2eSmrg                        break
2641d422ce2eSmrg                        ;;
26426257f37dSmrg      esac
2643d422ce2eSmrg      $_G_match_lt_parse_options && _G_rc_lt_parse_options=:
26446257f37dSmrg    done
2645bd304fc0Smrg
2646d422ce2eSmrg    if $_G_rc_lt_parse_options; then
2647d422ce2eSmrg      # save modified positional parameters for caller
2648d422ce2eSmrg      func_quote eval ${1+"$@"}
2649d422ce2eSmrg      libtool_parse_options_result=$func_quote_result
2650d422ce2eSmrg    fi
26516257f37dSmrg}
26526257f37dSmrgfunc_add_hook func_parse_options libtool_parse_options
2653f3561b8bSmrg
2654fc5a983dSmrg
2655f3561b8bSmrg
26566257f37dSmrg# libtool_validate_options [ARG]...
26576257f37dSmrg# ---------------------------------
26586257f37dSmrg# Perform any sanity checks on option settings and/or unconsumed
26596257f37dSmrg# arguments.
26606257f37dSmrglibtool_validate_options ()
26616257f37dSmrg{
26626257f37dSmrg    # save first non-option argument
26636257f37dSmrg    if test 0 -lt $#; then
26646257f37dSmrg      nonopt=$1
26656257f37dSmrg      shift
2666f3561b8bSmrg    fi
2667f3561b8bSmrg
26686257f37dSmrg    # preserve --debug
26696257f37dSmrg    test : = "$debug_cmd" || func_append preserve_args " --debug"
2670f3561b8bSmrg
26716257f37dSmrg    case $host in
26726257f37dSmrg      # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452
26736257f37dSmrg      # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788
26746257f37dSmrg      *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*)
26756257f37dSmrg        # don't eliminate duplications in $postdeps and $predeps
26766257f37dSmrg        opt_duplicate_compiler_generated_deps=:
26776257f37dSmrg        ;;
26786257f37dSmrg      *)
26796257f37dSmrg        opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
26806257f37dSmrg        ;;
26816257f37dSmrg    esac
2682fc5a983dSmrg
26836257f37dSmrg    $opt_help || {
26846257f37dSmrg      # Sanity checks first:
26856257f37dSmrg      func_check_version_match
26866257f37dSmrg
26876257f37dSmrg      test yes != "$build_libtool_libs" \
26886257f37dSmrg        && test yes != "$build_old_libs" \
26896257f37dSmrg        && func_fatal_configuration "not configured to build any kind of library"
26906257f37dSmrg
26916257f37dSmrg      # Darwin sucks
26926257f37dSmrg      eval std_shrext=\"$shrext_cmds\"
26936257f37dSmrg
26946257f37dSmrg      # Only execute mode is allowed to have -dlopen flags.
26956257f37dSmrg      if test -n "$opt_dlopen" && test execute != "$opt_mode"; then
26966257f37dSmrg        func_error "unrecognized option '-dlopen'"
26976257f37dSmrg        $ECHO "$help" 1>&2
26986257f37dSmrg        exit $EXIT_FAILURE
26996257f37dSmrg      fi
2700f3561b8bSmrg
27016257f37dSmrg      # Change the help message to a mode-specific one.
27026257f37dSmrg      generic_help=$help
27036257f37dSmrg      help="Try '$progname --help --mode=$opt_mode' for more information."
27046257f37dSmrg    }
2705f3561b8bSmrg
27066257f37dSmrg    # Pass back the unparsed argument list
2707d422ce2eSmrg    func_quote eval ${1+"$@"}
2708d422ce2eSmrg    libtool_validate_options_result=$func_quote_result
2709bd304fc0Smrg}
27106257f37dSmrgfunc_add_hook func_validate_options libtool_validate_options
2711f3561b8bSmrg
2712f3561b8bSmrg
27136257f37dSmrg# Process options as early as possible so that --help and --version
27146257f37dSmrg# can return quickly.
27156257f37dSmrgfunc_options ${1+"$@"}
27166257f37dSmrgeval set dummy "$func_options_result"; shift
27176257f37dSmrg
2718fc5a983dSmrg
2719fc5a983dSmrg
2720bd304fc0Smrg## ----------- ##
2721bd304fc0Smrg##    Main.    ##
2722bd304fc0Smrg## ----------- ##
2723fc5a983dSmrg
27246257f37dSmrgmagic='%%%MAGIC variable%%%'
27256257f37dSmrgmagic_exe='%%%MAGIC EXE variable%%%'
27266257f37dSmrg
27276257f37dSmrg# Global variables.
27286257f37dSmrgextracted_archives=
27296257f37dSmrgextracted_serial=0
27306257f37dSmrg
27316257f37dSmrg# If this variable is set in any of the actions, the command in it
27326257f37dSmrg# will be execed at the end.  This prevents here-documents from being
27336257f37dSmrg# left over by shells.
27346257f37dSmrgexec_cmd=
27356257f37dSmrg
27366257f37dSmrg
27376257f37dSmrg# A function that is used when there is no print builtin or printf.
27386257f37dSmrgfunc_fallback_echo ()
27396257f37dSmrg{
27406257f37dSmrg  eval 'cat <<_LTECHO_EOF
27416257f37dSmrg$1
27426257f37dSmrg_LTECHO_EOF'
27436257f37dSmrg}
27446257f37dSmrg
27456257f37dSmrg# func_generated_by_libtool
27466257f37dSmrg# True iff stdin has been generated by Libtool. This function is only
27476257f37dSmrg# a basic sanity check; it will hardly flush out determined imposters.
27486257f37dSmrgfunc_generated_by_libtool_p ()
27496257f37dSmrg{
27506257f37dSmrg  $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
27516257f37dSmrg}
27526257f37dSmrg
2753f3561b8bSmrg# func_lalib_p file
27546257f37dSmrg# True iff FILE is a libtool '.la' library or '.lo' object file.
2755f3561b8bSmrg# This function is only a basic sanity check; it will hardly flush out
2756f3561b8bSmrg# determined imposters.
2757f3561b8bSmrgfunc_lalib_p ()
2758f3561b8bSmrg{
2759f3561b8bSmrg    test -f "$1" &&
27606257f37dSmrg      $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p
2761f3561b8bSmrg}
2762fc5a983dSmrg
2763f3561b8bSmrg# func_lalib_unsafe_p file
27646257f37dSmrg# True iff FILE is a libtool '.la' library or '.lo' object file.
2765f3561b8bSmrg# This function implements the same check as func_lalib_p without
2766f3561b8bSmrg# resorting to external programs.  To this end, it redirects stdin and
2767f3561b8bSmrg# closes it afterwards, without saving the original file descriptor.
2768f3561b8bSmrg# As a safety measure, use it only where a negative result would be
27696257f37dSmrg# fatal anyway.  Works if 'file' does not exist.
2770f3561b8bSmrgfunc_lalib_unsafe_p ()
2771f3561b8bSmrg{
2772f3561b8bSmrg    lalib_p=no
2773f3561b8bSmrg    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
2774f3561b8bSmrg	for lalib_p_l in 1 2 3 4
2775f3561b8bSmrg	do
2776f3561b8bSmrg	    read lalib_p_line
27776257f37dSmrg	    case $lalib_p_line in
2778f3561b8bSmrg		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
2779f3561b8bSmrg	    esac
2780f3561b8bSmrg	done
2781f3561b8bSmrg	exec 0<&5 5<&-
2782f3561b8bSmrg    fi
27836257f37dSmrg    test yes = "$lalib_p"
2784f3561b8bSmrg}
2785fc5a983dSmrg
2786f3561b8bSmrg# func_ltwrapper_script_p file
2787f3561b8bSmrg# True iff FILE is a libtool wrapper script
2788f3561b8bSmrg# This function is only a basic sanity check; it will hardly flush out
2789f3561b8bSmrg# determined imposters.
2790f3561b8bSmrgfunc_ltwrapper_script_p ()
2791f3561b8bSmrg{
27926257f37dSmrg    test -f "$1" &&
27936257f37dSmrg      $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p
2794f3561b8bSmrg}
2795fc5a983dSmrg
2796f3561b8bSmrg# func_ltwrapper_executable_p file
2797f3561b8bSmrg# True iff FILE is a libtool wrapper executable
2798f3561b8bSmrg# This function is only a basic sanity check; it will hardly flush out
2799f3561b8bSmrg# determined imposters.
2800f3561b8bSmrgfunc_ltwrapper_executable_p ()
2801f3561b8bSmrg{
2802f3561b8bSmrg    func_ltwrapper_exec_suffix=
2803f3561b8bSmrg    case $1 in
2804f3561b8bSmrg    *.exe) ;;
2805f3561b8bSmrg    *) func_ltwrapper_exec_suffix=.exe ;;
2806f3561b8bSmrg    esac
2807f3561b8bSmrg    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
2808f3561b8bSmrg}
2809fc5a983dSmrg
2810f3561b8bSmrg# func_ltwrapper_scriptname file
2811f3561b8bSmrg# Assumes file is an ltwrapper_executable
2812f3561b8bSmrg# uses $file to determine the appropriate filename for a
2813f3561b8bSmrg# temporary ltwrapper_script.
2814f3561b8bSmrgfunc_ltwrapper_scriptname ()
2815f3561b8bSmrg{
2816bd304fc0Smrg    func_dirname_and_basename "$1" "" "."
2817bd304fc0Smrg    func_stripname '' '.exe' "$func_basename_result"
28186257f37dSmrg    func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper
2819f3561b8bSmrg}
2820f3561b8bSmrg
2821f3561b8bSmrg# func_ltwrapper_p file
2822f3561b8bSmrg# True iff FILE is a libtool wrapper script or wrapper executable
2823f3561b8bSmrg# This function is only a basic sanity check; it will hardly flush out
2824f3561b8bSmrg# determined imposters.
2825f3561b8bSmrgfunc_ltwrapper_p ()
2826f3561b8bSmrg{
2827f3561b8bSmrg    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
2828f3561b8bSmrg}
2829f3561b8bSmrg
2830f3561b8bSmrg
2831f3561b8bSmrg# func_execute_cmds commands fail_cmd
2832f3561b8bSmrg# Execute tilde-delimited COMMANDS.
2833f3561b8bSmrg# If FAIL_CMD is given, eval that upon failure.
2834f3561b8bSmrg# FAIL_CMD may read-access the current command in variable CMD!
2835f3561b8bSmrgfunc_execute_cmds ()
2836f3561b8bSmrg{
28376257f37dSmrg    $debug_cmd
28386257f37dSmrg
2839f3561b8bSmrg    save_ifs=$IFS; IFS='~'
2840f3561b8bSmrg    for cmd in $1; do
28416257f37dSmrg      IFS=$sp$nl
2842f3561b8bSmrg      eval cmd=\"$cmd\"
28436257f37dSmrg      IFS=$save_ifs
2844f3561b8bSmrg      func_show_eval "$cmd" "${2-:}"
2845f3561b8bSmrg    done
2846f3561b8bSmrg    IFS=$save_ifs
2847f3561b8bSmrg}
2848f3561b8bSmrg
2849f3561b8bSmrg
2850f3561b8bSmrg# func_source file
2851f3561b8bSmrg# Source FILE, adding directory component if necessary.
2852f3561b8bSmrg# Note that it is not necessary on cygwin/mingw to append a dot to
2853f3561b8bSmrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
2854f3561b8bSmrg# behavior happens only for exec(3), not for open(2)!  Also, sourcing
28556257f37dSmrg# 'FILE.' does not work on cygwin managed mounts.
2856f3561b8bSmrgfunc_source ()
2857f3561b8bSmrg{
28586257f37dSmrg    $debug_cmd
28596257f37dSmrg
2860f3561b8bSmrg    case $1 in
2861f3561b8bSmrg    */* | *\\*)	. "$1" ;;
2862f3561b8bSmrg    *)		. "./$1" ;;
2863f3561b8bSmrg    esac
2864f3561b8bSmrg}
2865f3561b8bSmrg
2866f3561b8bSmrg
2867bd304fc0Smrg# func_resolve_sysroot PATH
2868bd304fc0Smrg# Replace a leading = in PATH with a sysroot.  Store the result into
2869bd304fc0Smrg# func_resolve_sysroot_result
2870bd304fc0Smrgfunc_resolve_sysroot ()
2871bd304fc0Smrg{
2872bd304fc0Smrg  func_resolve_sysroot_result=$1
2873bd304fc0Smrg  case $func_resolve_sysroot_result in
2874bd304fc0Smrg  =*)
2875bd304fc0Smrg    func_stripname '=' '' "$func_resolve_sysroot_result"
2876bd304fc0Smrg    func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
2877bd304fc0Smrg    ;;
2878bd304fc0Smrg  esac
2879bd304fc0Smrg}
2880bd304fc0Smrg
2881bd304fc0Smrg# func_replace_sysroot PATH
2882bd304fc0Smrg# If PATH begins with the sysroot, replace it with = and
2883bd304fc0Smrg# store the result into func_replace_sysroot_result.
2884bd304fc0Smrgfunc_replace_sysroot ()
2885bd304fc0Smrg{
28866257f37dSmrg  case $lt_sysroot:$1 in
2887bd304fc0Smrg  ?*:"$lt_sysroot"*)
2888bd304fc0Smrg    func_stripname "$lt_sysroot" '' "$1"
28896257f37dSmrg    func_replace_sysroot_result='='$func_stripname_result
2890bd304fc0Smrg    ;;
2891bd304fc0Smrg  *)
2892bd304fc0Smrg    # Including no sysroot.
2893bd304fc0Smrg    func_replace_sysroot_result=$1
2894bd304fc0Smrg    ;;
2895bd304fc0Smrg  esac
2896bd304fc0Smrg}
2897bd304fc0Smrg
2898f3561b8bSmrg# func_infer_tag arg
2899f3561b8bSmrg# Infer tagged configuration to use if any are available and
2900f3561b8bSmrg# if one wasn't chosen via the "--tag" command line option.
2901f3561b8bSmrg# Only attempt this if the compiler in the base compile
2902f3561b8bSmrg# command doesn't match the default compiler.
2903f3561b8bSmrg# arg is usually of the form 'gcc ...'
2904f3561b8bSmrgfunc_infer_tag ()
2905f3561b8bSmrg{
29066257f37dSmrg    $debug_cmd
29076257f37dSmrg
2908f3561b8bSmrg    if test -n "$available_tags" && test -z "$tagname"; then
2909f3561b8bSmrg      CC_quoted=
2910f3561b8bSmrg      for arg in $CC; do
2911bd304fc0Smrg	func_append_quoted CC_quoted "$arg"
2912f3561b8bSmrg      done
2913bd304fc0Smrg      CC_expanded=`func_echo_all $CC`
2914bd304fc0Smrg      CC_quoted_expanded=`func_echo_all $CC_quoted`
2915f3561b8bSmrg      case $@ in
2916f3561b8bSmrg      # Blanks in the command may have been stripped by the calling shell,
2917f3561b8bSmrg      # but not from the CC environment variable when configure was run.
2918bd304fc0Smrg      " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
2919bd304fc0Smrg      " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
2920f3561b8bSmrg      # Blanks at the start of $base_compile will cause this to fail
2921f3561b8bSmrg      # if we don't check for them as well.
2922f3561b8bSmrg      *)
2923f3561b8bSmrg	for z in $available_tags; do
2924f3561b8bSmrg	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
2925f3561b8bSmrg	    # Evaluate the configuration.
29266257f37dSmrg	    eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
2927f3561b8bSmrg	    CC_quoted=
2928f3561b8bSmrg	    for arg in $CC; do
2929f3561b8bSmrg	      # Double-quote args containing other shell metacharacters.
2930bd304fc0Smrg	      func_append_quoted CC_quoted "$arg"
2931f3561b8bSmrg	    done
2932bd304fc0Smrg	    CC_expanded=`func_echo_all $CC`
2933bd304fc0Smrg	    CC_quoted_expanded=`func_echo_all $CC_quoted`
2934f3561b8bSmrg	    case "$@ " in
2935bd304fc0Smrg	    " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
2936bd304fc0Smrg	    " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
2937f3561b8bSmrg	      # The compiler in the base compile command matches
2938f3561b8bSmrg	      # the one in the tagged configuration.
2939f3561b8bSmrg	      # Assume this is the tagged configuration we want.
2940f3561b8bSmrg	      tagname=$z
2941f3561b8bSmrg	      break
2942f3561b8bSmrg	      ;;
2943f3561b8bSmrg	    esac
2944f3561b8bSmrg	  fi
2945f3561b8bSmrg	done
2946f3561b8bSmrg	# If $tagname still isn't set, then no tagged configuration
2947f3561b8bSmrg	# was found and let the user know that the "--tag" command
2948f3561b8bSmrg	# line option must be used.
2949f3561b8bSmrg	if test -z "$tagname"; then
2950f3561b8bSmrg	  func_echo "unable to infer tagged configuration"
29516257f37dSmrg	  func_fatal_error "specify a tag with '--tag'"
2952f3561b8bSmrg#	else
2953f3561b8bSmrg#	  func_verbose "using $tagname tagged configuration"
2954f3561b8bSmrg	fi
2955f3561b8bSmrg	;;
2956f3561b8bSmrg      esac
2957f3561b8bSmrg    fi
2958f3561b8bSmrg}
2959f3561b8bSmrg
2960f3561b8bSmrg
2961f3561b8bSmrg
2962f3561b8bSmrg# func_write_libtool_object output_name pic_name nonpic_name
2963f3561b8bSmrg# Create a libtool object file (analogous to a ".la" file),
2964f3561b8bSmrg# but don't create it if we're doing a dry run.
2965f3561b8bSmrgfunc_write_libtool_object ()
2966f3561b8bSmrg{
29676257f37dSmrg    write_libobj=$1
29686257f37dSmrg    if test yes = "$build_libtool_libs"; then
29696257f37dSmrg      write_lobj=\'$2\'
2970f3561b8bSmrg    else
2971f3561b8bSmrg      write_lobj=none
2972f3561b8bSmrg    fi
2973f3561b8bSmrg
29746257f37dSmrg    if test yes = "$build_old_libs"; then
29756257f37dSmrg      write_oldobj=\'$3\'
2976f3561b8bSmrg    else
2977f3561b8bSmrg      write_oldobj=none
2978f3561b8bSmrg    fi
2979f3561b8bSmrg
2980f3561b8bSmrg    $opt_dry_run || {
2981f3561b8bSmrg      cat >${write_libobj}T <<EOF
2982f3561b8bSmrg# $write_libobj - a libtool object file
29836257f37dSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
2984f3561b8bSmrg#
2985f3561b8bSmrg# Please DO NOT delete this file!
2986f3561b8bSmrg# It is necessary for linking the library.
2987f3561b8bSmrg
2988f3561b8bSmrg# Name of the PIC object.
2989f3561b8bSmrgpic_object=$write_lobj
2990f3561b8bSmrg
2991f3561b8bSmrg# Name of the non-PIC object
2992f3561b8bSmrgnon_pic_object=$write_oldobj
2993f3561b8bSmrg
2994f3561b8bSmrgEOF
29956257f37dSmrg      $MV "${write_libobj}T" "$write_libobj"
2996f3561b8bSmrg    }
2997f3561b8bSmrg}
2998f3561b8bSmrg
2999bd304fc0Smrg
3000bd304fc0Smrg##################################################
3001bd304fc0Smrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
3002bd304fc0Smrg##################################################
3003bd304fc0Smrg
3004bd304fc0Smrg# func_convert_core_file_wine_to_w32 ARG
3005bd304fc0Smrg# Helper function used by file name conversion functions when $build is *nix,
3006bd304fc0Smrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a
3007bd304fc0Smrg# correctly configured wine environment available, with the winepath program
3008bd304fc0Smrg# in $build's $PATH.
3009bd304fc0Smrg#
3010bd304fc0Smrg# ARG is the $build file name to be converted to w32 format.
3011bd304fc0Smrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will
3012bd304fc0Smrg# be empty on error (or when ARG is empty)
3013bd304fc0Smrgfunc_convert_core_file_wine_to_w32 ()
3014bd304fc0Smrg{
30156257f37dSmrg  $debug_cmd
30166257f37dSmrg
30176257f37dSmrg  func_convert_core_file_wine_to_w32_result=$1
3018bd304fc0Smrg  if test -n "$1"; then
3019bd304fc0Smrg    # Unfortunately, winepath does not exit with a non-zero error code, so we
3020bd304fc0Smrg    # are forced to check the contents of stdout. On the other hand, if the
3021bd304fc0Smrg    # command is not found, the shell will set an exit code of 127 and print
3022bd304fc0Smrg    # *an error message* to stdout. So we must check for both error code of
3023bd304fc0Smrg    # zero AND non-empty stdout, which explains the odd construction:
3024bd304fc0Smrg    func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
30256257f37dSmrg    if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then
3026bd304fc0Smrg      func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
30276257f37dSmrg        $SED -e "$sed_naive_backslashify"`
3028bd304fc0Smrg    else
3029bd304fc0Smrg      func_convert_core_file_wine_to_w32_result=
3030bd304fc0Smrg    fi
3031bd304fc0Smrg  fi
3032bd304fc0Smrg}
3033bd304fc0Smrg# end: func_convert_core_file_wine_to_w32
3034bd304fc0Smrg
3035bd304fc0Smrg
3036bd304fc0Smrg# func_convert_core_path_wine_to_w32 ARG
3037bd304fc0Smrg# Helper function used by path conversion functions when $build is *nix, and
3038bd304fc0Smrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
3039bd304fc0Smrg# configured wine environment available, with the winepath program in $build's
3040bd304fc0Smrg# $PATH. Assumes ARG has no leading or trailing path separator characters.
3041bd304fc0Smrg#
3042bd304fc0Smrg# ARG is path to be converted from $build format to win32.
3043bd304fc0Smrg# Result is available in $func_convert_core_path_wine_to_w32_result.
3044bd304fc0Smrg# Unconvertible file (directory) names in ARG are skipped; if no directory names
3045bd304fc0Smrg# are convertible, then the result may be empty.
3046bd304fc0Smrgfunc_convert_core_path_wine_to_w32 ()
3047bd304fc0Smrg{
30486257f37dSmrg  $debug_cmd
30496257f37dSmrg
3050bd304fc0Smrg  # unfortunately, winepath doesn't convert paths, only file names
30516257f37dSmrg  func_convert_core_path_wine_to_w32_result=
3052bd304fc0Smrg  if test -n "$1"; then
3053bd304fc0Smrg    oldIFS=$IFS
3054bd304fc0Smrg    IFS=:
3055bd304fc0Smrg    for func_convert_core_path_wine_to_w32_f in $1; do
3056bd304fc0Smrg      IFS=$oldIFS
3057bd304fc0Smrg      func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
30586257f37dSmrg      if test -n "$func_convert_core_file_wine_to_w32_result"; then
3059bd304fc0Smrg        if test -z "$func_convert_core_path_wine_to_w32_result"; then
30606257f37dSmrg          func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result
3061bd304fc0Smrg        else
3062bd304fc0Smrg          func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
3063bd304fc0Smrg        fi
3064bd304fc0Smrg      fi
3065bd304fc0Smrg    done
3066bd304fc0Smrg    IFS=$oldIFS
3067bd304fc0Smrg  fi
3068bd304fc0Smrg}
3069bd304fc0Smrg# end: func_convert_core_path_wine_to_w32
3070bd304fc0Smrg
3071bd304fc0Smrg
3072bd304fc0Smrg# func_cygpath ARGS...
3073bd304fc0Smrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
3074bd304fc0Smrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
3075bd304fc0Smrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
3076bd304fc0Smrg# (2), returns the Cygwin file name or path in func_cygpath_result (input
3077bd304fc0Smrg# file name or path is assumed to be in w32 format, as previously converted
3078bd304fc0Smrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name
3079bd304fc0Smrg# or path in func_cygpath_result (input file name or path is assumed to be in
3080bd304fc0Smrg# Cygwin format). Returns an empty string on error.
3081bd304fc0Smrg#
3082bd304fc0Smrg# ARGS are passed to cygpath, with the last one being the file name or path to
3083bd304fc0Smrg# be converted.
3084bd304fc0Smrg#
3085bd304fc0Smrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
3086bd304fc0Smrg# environment variable; do not put it in $PATH.
3087bd304fc0Smrgfunc_cygpath ()
3088bd304fc0Smrg{
30896257f37dSmrg  $debug_cmd
30906257f37dSmrg
3091bd304fc0Smrg  if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
3092bd304fc0Smrg    func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
3093bd304fc0Smrg    if test "$?" -ne 0; then
3094bd304fc0Smrg      # on failure, ensure result is empty
3095bd304fc0Smrg      func_cygpath_result=
3096bd304fc0Smrg    fi
3097bd304fc0Smrg  else
3098bd304fc0Smrg    func_cygpath_result=
30996257f37dSmrg    func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'"
3100bd304fc0Smrg  fi
3101bd304fc0Smrg}
3102bd304fc0Smrg#end: func_cygpath
3103bd304fc0Smrg
3104bd304fc0Smrg
3105bd304fc0Smrg# func_convert_core_msys_to_w32 ARG
3106bd304fc0Smrg# Convert file name or path ARG from MSYS format to w32 format.  Return
3107bd304fc0Smrg# result in func_convert_core_msys_to_w32_result.
3108bd304fc0Smrgfunc_convert_core_msys_to_w32 ()
3109bd304fc0Smrg{
31106257f37dSmrg  $debug_cmd
31116257f37dSmrg
3112bd304fc0Smrg  # awkward: cmd appends spaces to result
3113bd304fc0Smrg  func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
31146257f37dSmrg    $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"`
3115bd304fc0Smrg}
3116bd304fc0Smrg#end: func_convert_core_msys_to_w32
3117bd304fc0Smrg
3118bd304fc0Smrg
3119bd304fc0Smrg# func_convert_file_check ARG1 ARG2
3120bd304fc0Smrg# Verify that ARG1 (a file name in $build format) was converted to $host
3121bd304fc0Smrg# format in ARG2. Otherwise, emit an error message, but continue (resetting
3122bd304fc0Smrg# func_to_host_file_result to ARG1).
3123bd304fc0Smrgfunc_convert_file_check ()
3124bd304fc0Smrg{
31256257f37dSmrg  $debug_cmd
31266257f37dSmrg
31276257f37dSmrg  if test -z "$2" && test -n "$1"; then
3128bd304fc0Smrg    func_error "Could not determine host file name corresponding to"
31296257f37dSmrg    func_error "  '$1'"
3130bd304fc0Smrg    func_error "Continuing, but uninstalled executables may not work."
3131bd304fc0Smrg    # Fallback:
31326257f37dSmrg    func_to_host_file_result=$1
3133bd304fc0Smrg  fi
3134bd304fc0Smrg}
3135bd304fc0Smrg# end func_convert_file_check
3136bd304fc0Smrg
3137bd304fc0Smrg
3138bd304fc0Smrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
3139bd304fc0Smrg# Verify that FROM_PATH (a path in $build format) was converted to $host
3140bd304fc0Smrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting
3141bd304fc0Smrg# func_to_host_file_result to a simplistic fallback value (see below).
3142bd304fc0Smrgfunc_convert_path_check ()
3143bd304fc0Smrg{
31446257f37dSmrg  $debug_cmd
31456257f37dSmrg
3146bd304fc0Smrg  if test -z "$4" && test -n "$3"; then
3147bd304fc0Smrg    func_error "Could not determine the host path corresponding to"
31486257f37dSmrg    func_error "  '$3'"
3149bd304fc0Smrg    func_error "Continuing, but uninstalled executables may not work."
3150bd304fc0Smrg    # Fallback.  This is a deliberately simplistic "conversion" and
3151bd304fc0Smrg    # should not be "improved".  See libtool.info.
3152bd304fc0Smrg    if test "x$1" != "x$2"; then
3153bd304fc0Smrg      lt_replace_pathsep_chars="s|$1|$2|g"
3154bd304fc0Smrg      func_to_host_path_result=`echo "$3" |
3155bd304fc0Smrg        $SED -e "$lt_replace_pathsep_chars"`
3156bd304fc0Smrg    else
31576257f37dSmrg      func_to_host_path_result=$3
3158bd304fc0Smrg    fi
3159bd304fc0Smrg  fi
3160bd304fc0Smrg}
3161bd304fc0Smrg# end func_convert_path_check
3162bd304fc0Smrg
3163bd304fc0Smrg
3164bd304fc0Smrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
3165bd304fc0Smrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
3166bd304fc0Smrg# and appending REPL if ORIG matches BACKPAT.
3167bd304fc0Smrgfunc_convert_path_front_back_pathsep ()
3168bd304fc0Smrg{
31696257f37dSmrg  $debug_cmd
31706257f37dSmrg
3171bd304fc0Smrg  case $4 in
31726257f37dSmrg  $1 ) func_to_host_path_result=$3$func_to_host_path_result
3173bd304fc0Smrg    ;;
3174bd304fc0Smrg  esac
3175bd304fc0Smrg  case $4 in
3176bd304fc0Smrg  $2 ) func_append func_to_host_path_result "$3"
3177bd304fc0Smrg    ;;
3178bd304fc0Smrg  esac
3179bd304fc0Smrg}
3180bd304fc0Smrg# end func_convert_path_front_back_pathsep
3181bd304fc0Smrg
3182bd304fc0Smrg
3183bd304fc0Smrg##################################################
3184bd304fc0Smrg# $build to $host FILE NAME CONVERSION FUNCTIONS #
3185bd304fc0Smrg##################################################
31866257f37dSmrg# invoked via '$to_host_file_cmd ARG'
3187bd304fc0Smrg#
3188bd304fc0Smrg# In each case, ARG is the path to be converted from $build to $host format.
3189bd304fc0Smrg# Result will be available in $func_to_host_file_result.
3190bd304fc0Smrg
3191bd304fc0Smrg
3192bd304fc0Smrg# func_to_host_file ARG
3193bd304fc0Smrg# Converts the file name ARG from $build format to $host format. Return result
3194bd304fc0Smrg# in func_to_host_file_result.
3195bd304fc0Smrgfunc_to_host_file ()
3196bd304fc0Smrg{
31976257f37dSmrg  $debug_cmd
31986257f37dSmrg
3199bd304fc0Smrg  $to_host_file_cmd "$1"
3200bd304fc0Smrg}
3201bd304fc0Smrg# end func_to_host_file
3202bd304fc0Smrg
3203bd304fc0Smrg
3204bd304fc0Smrg# func_to_tool_file ARG LAZY
3205bd304fc0Smrg# converts the file name ARG from $build format to toolchain format. Return
3206bd304fc0Smrg# result in func_to_tool_file_result.  If the conversion in use is listed
3207bd304fc0Smrg# in (the comma separated) LAZY, no conversion takes place.
3208bd304fc0Smrgfunc_to_tool_file ()
3209bd304fc0Smrg{
32106257f37dSmrg  $debug_cmd
32116257f37dSmrg
3212bd304fc0Smrg  case ,$2, in
3213bd304fc0Smrg    *,"$to_tool_file_cmd",*)
3214bd304fc0Smrg      func_to_tool_file_result=$1
3215bd304fc0Smrg      ;;
3216bd304fc0Smrg    *)
3217bd304fc0Smrg      $to_tool_file_cmd "$1"
3218bd304fc0Smrg      func_to_tool_file_result=$func_to_host_file_result
3219bd304fc0Smrg      ;;
3220bd304fc0Smrg  esac
3221bd304fc0Smrg}
3222bd304fc0Smrg# end func_to_tool_file
3223bd304fc0Smrg
3224bd304fc0Smrg
3225bd304fc0Smrg# func_convert_file_noop ARG
3226bd304fc0Smrg# Copy ARG to func_to_host_file_result.
3227bd304fc0Smrgfunc_convert_file_noop ()
3228bd304fc0Smrg{
32296257f37dSmrg  func_to_host_file_result=$1
3230bd304fc0Smrg}
3231bd304fc0Smrg# end func_convert_file_noop
3232bd304fc0Smrg
3233bd304fc0Smrg
3234bd304fc0Smrg# func_convert_file_msys_to_w32 ARG
3235bd304fc0Smrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
3236bd304fc0Smrg# conversion to w32 is not available inside the cwrapper.  Returns result in
3237bd304fc0Smrg# func_to_host_file_result.
3238bd304fc0Smrgfunc_convert_file_msys_to_w32 ()
3239bd304fc0Smrg{
32406257f37dSmrg  $debug_cmd
32416257f37dSmrg
32426257f37dSmrg  func_to_host_file_result=$1
3243bd304fc0Smrg  if test -n "$1"; then
3244bd304fc0Smrg    func_convert_core_msys_to_w32 "$1"
32456257f37dSmrg    func_to_host_file_result=$func_convert_core_msys_to_w32_result
3246bd304fc0Smrg  fi
3247bd304fc0Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
3248bd304fc0Smrg}
3249bd304fc0Smrg# end func_convert_file_msys_to_w32
3250bd304fc0Smrg
3251bd304fc0Smrg
3252bd304fc0Smrg# func_convert_file_cygwin_to_w32 ARG
3253bd304fc0Smrg# Convert file name ARG from Cygwin to w32 format.  Returns result in
3254bd304fc0Smrg# func_to_host_file_result.
3255bd304fc0Smrgfunc_convert_file_cygwin_to_w32 ()
3256bd304fc0Smrg{
32576257f37dSmrg  $debug_cmd
32586257f37dSmrg
32596257f37dSmrg  func_to_host_file_result=$1
3260bd304fc0Smrg  if test -n "$1"; then
3261bd304fc0Smrg    # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
3262bd304fc0Smrg    # LT_CYGPATH in this case.
3263bd304fc0Smrg    func_to_host_file_result=`cygpath -m "$1"`
3264bd304fc0Smrg  fi
3265bd304fc0Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
3266bd304fc0Smrg}
3267bd304fc0Smrg# end func_convert_file_cygwin_to_w32
3268bd304fc0Smrg
3269bd304fc0Smrg
3270bd304fc0Smrg# func_convert_file_nix_to_w32 ARG
3271bd304fc0Smrg# Convert file name ARG from *nix to w32 format.  Requires a wine environment
3272bd304fc0Smrg# and a working winepath. Returns result in func_to_host_file_result.
3273bd304fc0Smrgfunc_convert_file_nix_to_w32 ()
3274bd304fc0Smrg{
32756257f37dSmrg  $debug_cmd
32766257f37dSmrg
32776257f37dSmrg  func_to_host_file_result=$1
3278bd304fc0Smrg  if test -n "$1"; then
3279bd304fc0Smrg    func_convert_core_file_wine_to_w32 "$1"
32806257f37dSmrg    func_to_host_file_result=$func_convert_core_file_wine_to_w32_result
3281bd304fc0Smrg  fi
3282bd304fc0Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
3283bd304fc0Smrg}
3284bd304fc0Smrg# end func_convert_file_nix_to_w32
3285bd304fc0Smrg
3286bd304fc0Smrg
3287bd304fc0Smrg# func_convert_file_msys_to_cygwin ARG
3288bd304fc0Smrg# Convert file name ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
3289bd304fc0Smrg# Returns result in func_to_host_file_result.
3290bd304fc0Smrgfunc_convert_file_msys_to_cygwin ()
3291bd304fc0Smrg{
32926257f37dSmrg  $debug_cmd
32936257f37dSmrg
32946257f37dSmrg  func_to_host_file_result=$1
3295bd304fc0Smrg  if test -n "$1"; then
3296bd304fc0Smrg    func_convert_core_msys_to_w32 "$1"
3297bd304fc0Smrg    func_cygpath -u "$func_convert_core_msys_to_w32_result"
32986257f37dSmrg    func_to_host_file_result=$func_cygpath_result
3299bd304fc0Smrg  fi
3300bd304fc0Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
3301bd304fc0Smrg}
3302bd304fc0Smrg# end func_convert_file_msys_to_cygwin
3303bd304fc0Smrg
3304bd304fc0Smrg
3305bd304fc0Smrg# func_convert_file_nix_to_cygwin ARG
3306bd304fc0Smrg# Convert file name ARG from *nix to Cygwin format.  Requires Cygwin installed
3307bd304fc0Smrg# in a wine environment, working winepath, and LT_CYGPATH set.  Returns result
3308bd304fc0Smrg# in func_to_host_file_result.
3309bd304fc0Smrgfunc_convert_file_nix_to_cygwin ()
3310bd304fc0Smrg{
33116257f37dSmrg  $debug_cmd
33126257f37dSmrg
33136257f37dSmrg  func_to_host_file_result=$1
3314bd304fc0Smrg  if test -n "$1"; then
3315bd304fc0Smrg    # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
3316bd304fc0Smrg    func_convert_core_file_wine_to_w32 "$1"
3317bd304fc0Smrg    func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
33186257f37dSmrg    func_to_host_file_result=$func_cygpath_result
3319bd304fc0Smrg  fi
3320bd304fc0Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
3321bd304fc0Smrg}
3322bd304fc0Smrg# end func_convert_file_nix_to_cygwin
3323bd304fc0Smrg
3324bd304fc0Smrg
3325bd304fc0Smrg#############################################
3326bd304fc0Smrg# $build to $host PATH CONVERSION FUNCTIONS #
3327bd304fc0Smrg#############################################
33286257f37dSmrg# invoked via '$to_host_path_cmd ARG'
3329bd304fc0Smrg#
3330bd304fc0Smrg# In each case, ARG is the path to be converted from $build to $host format.
3331bd304fc0Smrg# The result will be available in $func_to_host_path_result.
3332bd304fc0Smrg#
3333bd304fc0Smrg# Path separators are also converted from $build format to $host format.  If
3334bd304fc0Smrg# ARG begins or ends with a path separator character, it is preserved (but
3335bd304fc0Smrg# converted to $host format) on output.
3336bd304fc0Smrg#
3337bd304fc0Smrg# All path conversion functions are named using the following convention:
3338bd304fc0Smrg#   file name conversion function    : func_convert_file_X_to_Y ()
3339bd304fc0Smrg#   path conversion function         : func_convert_path_X_to_Y ()
3340bd304fc0Smrg# where, for any given $build/$host combination the 'X_to_Y' value is the
3341bd304fc0Smrg# same.  If conversion functions are added for new $build/$host combinations,
3342bd304fc0Smrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd
3343bd304fc0Smrg# will break.
3344bd304fc0Smrg
3345bd304fc0Smrg
3346bd304fc0Smrg# func_init_to_host_path_cmd
3347bd304fc0Smrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the
3348bd304fc0Smrg# appropriate value, based on the value of $to_host_file_cmd.
3349bd304fc0Smrgto_host_path_cmd=
3350bd304fc0Smrgfunc_init_to_host_path_cmd ()
3351bd304fc0Smrg{
33526257f37dSmrg  $debug_cmd
33536257f37dSmrg
3354bd304fc0Smrg  if test -z "$to_host_path_cmd"; then
3355bd304fc0Smrg    func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
33566257f37dSmrg    to_host_path_cmd=func_convert_path_$func_stripname_result
3357bd304fc0Smrg  fi
3358bd304fc0Smrg}
3359bd304fc0Smrg
3360bd304fc0Smrg
3361bd304fc0Smrg# func_to_host_path ARG
3362bd304fc0Smrg# Converts the path ARG from $build format to $host format. Return result
3363bd304fc0Smrg# in func_to_host_path_result.
3364bd304fc0Smrgfunc_to_host_path ()
3365bd304fc0Smrg{
33666257f37dSmrg  $debug_cmd
33676257f37dSmrg
3368bd304fc0Smrg  func_init_to_host_path_cmd
3369bd304fc0Smrg  $to_host_path_cmd "$1"
3370bd304fc0Smrg}
3371bd304fc0Smrg# end func_to_host_path
3372bd304fc0Smrg
3373bd304fc0Smrg
3374bd304fc0Smrg# func_convert_path_noop ARG
3375bd304fc0Smrg# Copy ARG to func_to_host_path_result.
3376bd304fc0Smrgfunc_convert_path_noop ()
3377bd304fc0Smrg{
33786257f37dSmrg  func_to_host_path_result=$1
3379bd304fc0Smrg}
3380bd304fc0Smrg# end func_convert_path_noop
3381bd304fc0Smrg
3382bd304fc0Smrg
3383bd304fc0Smrg# func_convert_path_msys_to_w32 ARG
3384bd304fc0Smrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
3385bd304fc0Smrg# conversion to w32 is not available inside the cwrapper.  Returns result in
3386bd304fc0Smrg# func_to_host_path_result.
3387bd304fc0Smrgfunc_convert_path_msys_to_w32 ()
3388bd304fc0Smrg{
33896257f37dSmrg  $debug_cmd
33906257f37dSmrg
33916257f37dSmrg  func_to_host_path_result=$1
3392bd304fc0Smrg  if test -n "$1"; then
3393bd304fc0Smrg    # Remove leading and trailing path separator characters from ARG.  MSYS
3394bd304fc0Smrg    # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
3395bd304fc0Smrg    # and winepath ignores them completely.
3396bd304fc0Smrg    func_stripname : : "$1"
3397bd304fc0Smrg    func_to_host_path_tmp1=$func_stripname_result
3398bd304fc0Smrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
33996257f37dSmrg    func_to_host_path_result=$func_convert_core_msys_to_w32_result
3400bd304fc0Smrg    func_convert_path_check : ";" \
3401bd304fc0Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
3402bd304fc0Smrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
3403bd304fc0Smrg  fi
3404bd304fc0Smrg}
3405bd304fc0Smrg# end func_convert_path_msys_to_w32
3406bd304fc0Smrg
3407bd304fc0Smrg
3408bd304fc0Smrg# func_convert_path_cygwin_to_w32 ARG
3409bd304fc0Smrg# Convert path ARG from Cygwin to w32 format.  Returns result in
3410bd304fc0Smrg# func_to_host_file_result.
3411bd304fc0Smrgfunc_convert_path_cygwin_to_w32 ()
3412bd304fc0Smrg{
34136257f37dSmrg  $debug_cmd
34146257f37dSmrg
34156257f37dSmrg  func_to_host_path_result=$1
3416bd304fc0Smrg  if test -n "$1"; then
3417bd304fc0Smrg    # See func_convert_path_msys_to_w32:
3418bd304fc0Smrg    func_stripname : : "$1"
3419bd304fc0Smrg    func_to_host_path_tmp1=$func_stripname_result
3420bd304fc0Smrg    func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
3421bd304fc0Smrg    func_convert_path_check : ";" \
3422bd304fc0Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
3423bd304fc0Smrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
3424bd304fc0Smrg  fi
3425bd304fc0Smrg}
3426bd304fc0Smrg# end func_convert_path_cygwin_to_w32
3427bd304fc0Smrg
3428bd304fc0Smrg
3429bd304fc0Smrg# func_convert_path_nix_to_w32 ARG
3430bd304fc0Smrg# Convert path ARG from *nix to w32 format.  Requires a wine environment and
3431bd304fc0Smrg# a working winepath.  Returns result in func_to_host_file_result.
3432bd304fc0Smrgfunc_convert_path_nix_to_w32 ()
3433bd304fc0Smrg{
34346257f37dSmrg  $debug_cmd
34356257f37dSmrg
34366257f37dSmrg  func_to_host_path_result=$1
3437bd304fc0Smrg  if test -n "$1"; then
3438bd304fc0Smrg    # See func_convert_path_msys_to_w32:
3439bd304fc0Smrg    func_stripname : : "$1"
3440bd304fc0Smrg    func_to_host_path_tmp1=$func_stripname_result
3441bd304fc0Smrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
34426257f37dSmrg    func_to_host_path_result=$func_convert_core_path_wine_to_w32_result
3443bd304fc0Smrg    func_convert_path_check : ";" \
3444bd304fc0Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
3445bd304fc0Smrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
3446bd304fc0Smrg  fi
3447bd304fc0Smrg}
3448bd304fc0Smrg# end func_convert_path_nix_to_w32
3449bd304fc0Smrg
3450bd304fc0Smrg
3451bd304fc0Smrg# func_convert_path_msys_to_cygwin ARG
3452bd304fc0Smrg# Convert path ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
3453bd304fc0Smrg# Returns result in func_to_host_file_result.
3454bd304fc0Smrgfunc_convert_path_msys_to_cygwin ()
3455bd304fc0Smrg{
34566257f37dSmrg  $debug_cmd
34576257f37dSmrg
34586257f37dSmrg  func_to_host_path_result=$1
3459bd304fc0Smrg  if test -n "$1"; then
3460bd304fc0Smrg    # See func_convert_path_msys_to_w32:
3461bd304fc0Smrg    func_stripname : : "$1"
3462bd304fc0Smrg    func_to_host_path_tmp1=$func_stripname_result
3463bd304fc0Smrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
3464bd304fc0Smrg    func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
34656257f37dSmrg    func_to_host_path_result=$func_cygpath_result
3466bd304fc0Smrg    func_convert_path_check : : \
3467bd304fc0Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
3468bd304fc0Smrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
3469bd304fc0Smrg  fi
3470bd304fc0Smrg}
3471bd304fc0Smrg# end func_convert_path_msys_to_cygwin
3472bd304fc0Smrg
3473bd304fc0Smrg
3474bd304fc0Smrg# func_convert_path_nix_to_cygwin ARG
3475bd304fc0Smrg# Convert path ARG from *nix to Cygwin format.  Requires Cygwin installed in a
3476bd304fc0Smrg# a wine environment, working winepath, and LT_CYGPATH set.  Returns result in
3477bd304fc0Smrg# func_to_host_file_result.
3478bd304fc0Smrgfunc_convert_path_nix_to_cygwin ()
3479bd304fc0Smrg{
34806257f37dSmrg  $debug_cmd
34816257f37dSmrg
34826257f37dSmrg  func_to_host_path_result=$1
3483bd304fc0Smrg  if test -n "$1"; then
3484bd304fc0Smrg    # Remove leading and trailing path separator characters from
3485bd304fc0Smrg    # ARG. msys behavior is inconsistent here, cygpath turns them
3486bd304fc0Smrg    # into '.;' and ';.', and winepath ignores them completely.
3487bd304fc0Smrg    func_stripname : : "$1"
3488bd304fc0Smrg    func_to_host_path_tmp1=$func_stripname_result
3489bd304fc0Smrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
3490bd304fc0Smrg    func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
34916257f37dSmrg    func_to_host_path_result=$func_cygpath_result
3492bd304fc0Smrg    func_convert_path_check : : \
3493bd304fc0Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
3494bd304fc0Smrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
3495bd304fc0Smrg  fi
3496bd304fc0Smrg}
3497bd304fc0Smrg# end func_convert_path_nix_to_cygwin
3498bd304fc0Smrg
3499bd304fc0Smrg
35006257f37dSmrg# func_dll_def_p FILE
35016257f37dSmrg# True iff FILE is a Windows DLL '.def' file.
35026257f37dSmrg# Keep in sync with _LT_DLL_DEF_P in libtool.m4
35036257f37dSmrgfunc_dll_def_p ()
35046257f37dSmrg{
35056257f37dSmrg  $debug_cmd
35066257f37dSmrg
35076257f37dSmrg  func_dll_def_p_tmp=`$SED -n \
35086257f37dSmrg    -e 's/^[	 ]*//' \
35096257f37dSmrg    -e '/^\(;.*\)*$/d' \
35106257f37dSmrg    -e 's/^\(EXPORTS\|LIBRARY\)\([	 ].*\)*$/DEF/p' \
35116257f37dSmrg    -e q \
35126257f37dSmrg    "$1"`
35136257f37dSmrg  test DEF = "$func_dll_def_p_tmp"
35146257f37dSmrg}
35156257f37dSmrg
35166257f37dSmrg
3517f3561b8bSmrg# func_mode_compile arg...
3518f3561b8bSmrgfunc_mode_compile ()
3519f3561b8bSmrg{
35206257f37dSmrg    $debug_cmd
35216257f37dSmrg
3522f3561b8bSmrg    # Get the compilation command and the source file.
3523f3561b8bSmrg    base_compile=
35246257f37dSmrg    srcfile=$nonopt  #  always keep a non-empty value in "srcfile"
3525f3561b8bSmrg    suppress_opt=yes
3526f3561b8bSmrg    suppress_output=
3527f3561b8bSmrg    arg_mode=normal
3528f3561b8bSmrg    libobj=
3529f3561b8bSmrg    later=
3530f3561b8bSmrg    pie_flag=
3531f3561b8bSmrg
3532f3561b8bSmrg    for arg
3533f3561b8bSmrg    do
3534f3561b8bSmrg      case $arg_mode in
3535f3561b8bSmrg      arg  )
3536f3561b8bSmrg	# do not "continue".  Instead, add this to base_compile
35376257f37dSmrg	lastarg=$arg
3538f3561b8bSmrg	arg_mode=normal
3539f3561b8bSmrg	;;
3540f3561b8bSmrg
3541f3561b8bSmrg      target )
35426257f37dSmrg	libobj=$arg
3543f3561b8bSmrg	arg_mode=normal
3544f3561b8bSmrg	continue
3545f3561b8bSmrg	;;
3546f3561b8bSmrg
3547f3561b8bSmrg      normal )
3548f3561b8bSmrg	# Accept any command-line options.
3549f3561b8bSmrg	case $arg in
3550f3561b8bSmrg	-o)
3551f3561b8bSmrg	  test -n "$libobj" && \
35526257f37dSmrg	    func_fatal_error "you cannot specify '-o' more than once"
3553f3561b8bSmrg	  arg_mode=target
3554f3561b8bSmrg	  continue
3555f3561b8bSmrg	  ;;
3556f3561b8bSmrg
3557f3561b8bSmrg	-pie | -fpie | -fPIE)
3558bd304fc0Smrg          func_append pie_flag " $arg"
3559f3561b8bSmrg	  continue
3560f3561b8bSmrg	  ;;
3561f3561b8bSmrg
3562f3561b8bSmrg	-shared | -static | -prefer-pic | -prefer-non-pic)
3563bd304fc0Smrg	  func_append later " $arg"
3564f3561b8bSmrg	  continue
3565f3561b8bSmrg	  ;;
3566f3561b8bSmrg
3567f3561b8bSmrg	-no-suppress)
3568fc5a983dSmrg	  suppress_opt=no
3569fc5a983dSmrg	  continue
3570fc5a983dSmrg	  ;;
3571fc5a983dSmrg
3572fc5a983dSmrg	-Xcompiler)
3573fc5a983dSmrg	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
3574fc5a983dSmrg	  continue      #  The current "srcfile" will either be retained or
3575fc5a983dSmrg	  ;;            #  replaced later.  I would guess that would be a bug.
3576fc5a983dSmrg
3577fc5a983dSmrg	-Wc,*)
3578f3561b8bSmrg	  func_stripname '-Wc,' '' "$arg"
3579f3561b8bSmrg	  args=$func_stripname_result
3580fc5a983dSmrg	  lastarg=
35816257f37dSmrg	  save_ifs=$IFS; IFS=,
3582f3561b8bSmrg	  for arg in $args; do
35836257f37dSmrg	    IFS=$save_ifs
3584bd304fc0Smrg	    func_append_quoted lastarg "$arg"
3585fc5a983dSmrg	  done
35866257f37dSmrg	  IFS=$save_ifs
3587f3561b8bSmrg	  func_stripname ' ' '' "$lastarg"
3588f3561b8bSmrg	  lastarg=$func_stripname_result
3589fc5a983dSmrg
3590fc5a983dSmrg	  # Add the arguments to base_compile.
3591bd304fc0Smrg	  func_append base_compile " $lastarg"
3592fc5a983dSmrg	  continue
3593fc5a983dSmrg	  ;;
3594fc5a983dSmrg
3595f3561b8bSmrg	*)
3596fc5a983dSmrg	  # Accept the current argument as the source file.
3597fc5a983dSmrg	  # The previous "srcfile" becomes the current argument.
3598fc5a983dSmrg	  #
35996257f37dSmrg	  lastarg=$srcfile
36006257f37dSmrg	  srcfile=$arg
3601fc5a983dSmrg	  ;;
3602fc5a983dSmrg	esac  #  case $arg
3603fc5a983dSmrg	;;
3604fc5a983dSmrg      esac    #  case $arg_mode
3605fc5a983dSmrg
3606fc5a983dSmrg      # Aesthetically quote the previous argument.
3607bd304fc0Smrg      func_append_quoted base_compile "$lastarg"
3608fc5a983dSmrg    done # for arg
3609fc5a983dSmrg
3610fc5a983dSmrg    case $arg_mode in
3611fc5a983dSmrg    arg)
3612f3561b8bSmrg      func_fatal_error "you must specify an argument for -Xcompile"
3613fc5a983dSmrg      ;;
3614fc5a983dSmrg    target)
36156257f37dSmrg      func_fatal_error "you must specify a target with '-o'"
3616fc5a983dSmrg      ;;
3617fc5a983dSmrg    *)
3618fc5a983dSmrg      # Get the name of the library object.
3619f3561b8bSmrg      test -z "$libobj" && {
3620f3561b8bSmrg	func_basename "$srcfile"
36216257f37dSmrg	libobj=$func_basename_result
3622f3561b8bSmrg      }
3623fc5a983dSmrg      ;;
3624fc5a983dSmrg    esac
3625fc5a983dSmrg
3626fc5a983dSmrg    # Recognize several different file suffixes.
3627fc5a983dSmrg    # If the user specifies -o file.o, it is replaced with file.lo
3628fc5a983dSmrg    case $libobj in
3629f3561b8bSmrg    *.[cCFSifmso] | \
3630f3561b8bSmrg    *.ada | *.adb | *.ads | *.asm | \
3631f3561b8bSmrg    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
3632bd304fc0Smrg    *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
3633f3561b8bSmrg      func_xform "$libobj"
3634f3561b8bSmrg      libobj=$func_xform_result
3635f3561b8bSmrg      ;;
3636fc5a983dSmrg    esac
3637fc5a983dSmrg
3638fc5a983dSmrg    case $libobj in
3639f3561b8bSmrg    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
3640fc5a983dSmrg    *)
36416257f37dSmrg      func_fatal_error "cannot determine name of library object from '$libobj'"
3642fc5a983dSmrg      ;;
3643fc5a983dSmrg    esac
3644fc5a983dSmrg
3645fc5a983dSmrg    func_infer_tag $base_compile
3646fc5a983dSmrg
3647fc5a983dSmrg    for arg in $later; do
3648fc5a983dSmrg      case $arg in
3649f3561b8bSmrg      -shared)
36506257f37dSmrg	test yes = "$build_libtool_libs" \
36516257f37dSmrg	  || func_fatal_configuration "cannot build a shared library"
3652f3561b8bSmrg	build_old_libs=no
3653f3561b8bSmrg	continue
3654f3561b8bSmrg	;;
3655f3561b8bSmrg
3656fc5a983dSmrg      -static)
3657f3561b8bSmrg	build_libtool_libs=no
3658fc5a983dSmrg	build_old_libs=yes
3659fc5a983dSmrg	continue
3660fc5a983dSmrg	;;
3661fc5a983dSmrg
3662fc5a983dSmrg      -prefer-pic)
3663fc5a983dSmrg	pic_mode=yes
3664fc5a983dSmrg	continue
3665fc5a983dSmrg	;;
3666fc5a983dSmrg
3667fc5a983dSmrg      -prefer-non-pic)
3668fc5a983dSmrg	pic_mode=no
3669fc5a983dSmrg	continue
3670fc5a983dSmrg	;;
3671fc5a983dSmrg      esac
3672fc5a983dSmrg    done
3673fc5a983dSmrg
3674d422ce2eSmrg    func_quote_arg pretty "$libobj"
3675d422ce2eSmrg    test "X$libobj" != "X$func_quote_arg_result" \
3676f3561b8bSmrg      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
36776257f37dSmrg      && func_warning "libobj name '$libobj' may not contain shell special characters."
3678f3561b8bSmrg    func_dirname_and_basename "$obj" "/" ""
36796257f37dSmrg    objname=$func_basename_result
36806257f37dSmrg    xdir=$func_dirname_result
36816257f37dSmrg    lobj=$xdir$objdir/$objname
3682fc5a983dSmrg
3683f3561b8bSmrg    test -z "$base_compile" && \
3684f3561b8bSmrg      func_fatal_help "you must specify a compilation command"
3685fc5a983dSmrg
3686fc5a983dSmrg    # Delete any leftover library objects.
36876257f37dSmrg    if test yes = "$build_old_libs"; then
3688fc5a983dSmrg      removelist="$obj $lobj $libobj ${libobj}T"
3689fc5a983dSmrg    else
3690fc5a983dSmrg      removelist="$lobj $libobj ${libobj}T"
3691fc5a983dSmrg    fi
3692fc5a983dSmrg
3693fc5a983dSmrg    # On Cygwin there's no "real" PIC flag so we must build both object types
3694fc5a983dSmrg    case $host_os in
3695f3561b8bSmrg    cygwin* | mingw* | pw32* | os2* | cegcc*)
3696fc5a983dSmrg      pic_mode=default
3697fc5a983dSmrg      ;;
3698fc5a983dSmrg    esac
36996257f37dSmrg    if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then
3700fc5a983dSmrg      # non-PIC code in shared libraries is not supported
3701fc5a983dSmrg      pic_mode=default
3702fc5a983dSmrg    fi
3703fc5a983dSmrg
3704fc5a983dSmrg    # Calculate the filename of the output object if compiler does
3705fc5a983dSmrg    # not support -o with -c
37066257f37dSmrg    if test no = "$compiler_c_o"; then
37076257f37dSmrg      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext
37086257f37dSmrg      lockfile=$output_obj.lock
3709fc5a983dSmrg    else
3710fc5a983dSmrg      output_obj=
3711fc5a983dSmrg      need_locks=no
3712fc5a983dSmrg      lockfile=
3713fc5a983dSmrg    fi
3714fc5a983dSmrg
3715fc5a983dSmrg    # Lock this critical section if it is needed
3716fc5a983dSmrg    # We use this script file to make the link, it avoids creating a new file
37176257f37dSmrg    if test yes = "$need_locks"; then
3718f3561b8bSmrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
3719f3561b8bSmrg	func_echo "Waiting for $lockfile to be removed"
3720fc5a983dSmrg	sleep 2
3721fc5a983dSmrg      done
37226257f37dSmrg    elif test warn = "$need_locks"; then
3723fc5a983dSmrg      if test -f "$lockfile"; then
3724f3561b8bSmrg	$ECHO "\
3725fc5a983dSmrg*** ERROR, $lockfile exists and contains:
3726fc5a983dSmrg`cat $lockfile 2>/dev/null`
3727fc5a983dSmrg
3728fc5a983dSmrgThis indicates that another process is trying to use the same
3729fc5a983dSmrgtemporary object file, and libtool could not work around it because
37306257f37dSmrgyour compiler does not support '-c' and '-o' together.  If you
3731fc5a983dSmrgrepeat this compilation, it may succeed, by chance, but you had better
3732fc5a983dSmrgavoid parallel builds (make -j) in this platform, or get a better
3733fc5a983dSmrgcompiler."
3734fc5a983dSmrg
3735f3561b8bSmrg	$opt_dry_run || $RM $removelist
3736fc5a983dSmrg	exit $EXIT_FAILURE
3737fc5a983dSmrg      fi
3738bd304fc0Smrg      func_append removelist " $output_obj"
3739f3561b8bSmrg      $ECHO "$srcfile" > "$lockfile"
3740fc5a983dSmrg    fi
3741fc5a983dSmrg
3742f3561b8bSmrg    $opt_dry_run || $RM $removelist
3743bd304fc0Smrg    func_append removelist " $lockfile"
3744f3561b8bSmrg    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
3745f3561b8bSmrg
3746bd304fc0Smrg    func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
3747bd304fc0Smrg    srcfile=$func_to_tool_file_result
3748d422ce2eSmrg    func_quote_arg pretty "$srcfile"
3749d422ce2eSmrg    qsrcfile=$func_quote_arg_result
3750fc5a983dSmrg
3751fc5a983dSmrg    # Only build a PIC object if we are building libtool libraries.
37526257f37dSmrg    if test yes = "$build_libtool_libs"; then
3753fc5a983dSmrg      # Without this assignment, base_compile gets emptied.
3754fc5a983dSmrg      fbsd_hideous_sh_bug=$base_compile
3755fc5a983dSmrg
37566257f37dSmrg      if test no != "$pic_mode"; then
3757fc5a983dSmrg	command="$base_compile $qsrcfile $pic_flag"
3758fc5a983dSmrg      else
3759fc5a983dSmrg	# Don't build PIC code
3760fc5a983dSmrg	command="$base_compile $qsrcfile"
3761fc5a983dSmrg      fi
3762fc5a983dSmrg
3763f3561b8bSmrg      func_mkdir_p "$xdir$objdir"
3764fc5a983dSmrg
3765fc5a983dSmrg      if test -z "$output_obj"; then
3766fc5a983dSmrg	# Place PIC objects in $objdir
3767bd304fc0Smrg	func_append command " -o $lobj"
3768fc5a983dSmrg      fi
3769fc5a983dSmrg
3770f3561b8bSmrg      func_show_eval_locale "$command"	\
3771f3561b8bSmrg          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
3772fc5a983dSmrg
37736257f37dSmrg      if test warn = "$need_locks" &&
3774fc5a983dSmrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
3775f3561b8bSmrg	$ECHO "\
3776fc5a983dSmrg*** ERROR, $lockfile contains:
3777fc5a983dSmrg`cat $lockfile 2>/dev/null`
3778fc5a983dSmrg
3779fc5a983dSmrgbut it should contain:
3780fc5a983dSmrg$srcfile
3781fc5a983dSmrg
3782fc5a983dSmrgThis indicates that another process is trying to use the same
3783fc5a983dSmrgtemporary object file, and libtool could not work around it because
37846257f37dSmrgyour compiler does not support '-c' and '-o' together.  If you
3785fc5a983dSmrgrepeat this compilation, it may succeed, by chance, but you had better
3786fc5a983dSmrgavoid parallel builds (make -j) in this platform, or get a better
3787fc5a983dSmrgcompiler."
3788fc5a983dSmrg
3789f3561b8bSmrg	$opt_dry_run || $RM $removelist
3790fc5a983dSmrg	exit $EXIT_FAILURE
3791fc5a983dSmrg      fi
3792fc5a983dSmrg
3793fc5a983dSmrg      # Just move the object if needed, then go on to compile the next one
3794fc5a983dSmrg      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
3795f3561b8bSmrg	func_show_eval '$MV "$output_obj" "$lobj"' \
3796f3561b8bSmrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
3797fc5a983dSmrg      fi
3798fc5a983dSmrg
3799fc5a983dSmrg      # Allow error messages only from the first compilation.
38006257f37dSmrg      if test yes = "$suppress_opt"; then
3801f3561b8bSmrg	suppress_output=' >/dev/null 2>&1'
3802fc5a983dSmrg      fi
3803fc5a983dSmrg    fi
3804fc5a983dSmrg
3805fc5a983dSmrg    # Only build a position-dependent object if we build old libraries.
38066257f37dSmrg    if test yes = "$build_old_libs"; then
38076257f37dSmrg      if test yes != "$pic_mode"; then
3808fc5a983dSmrg	# Don't build PIC code
3809f3561b8bSmrg	command="$base_compile $qsrcfile$pie_flag"
3810fc5a983dSmrg      else
3811fc5a983dSmrg	command="$base_compile $qsrcfile $pic_flag"
3812fc5a983dSmrg      fi
38136257f37dSmrg      if test yes = "$compiler_c_o"; then
3814bd304fc0Smrg	func_append command " -o $obj"
3815fc5a983dSmrg      fi
3816fc5a983dSmrg
3817fc5a983dSmrg      # Suppress compiler output if we already did a PIC compilation.
3818bd304fc0Smrg      func_append command "$suppress_output"
3819f3561b8bSmrg      func_show_eval_locale "$command" \
3820f3561b8bSmrg        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
3821fc5a983dSmrg
38226257f37dSmrg      if test warn = "$need_locks" &&
3823fc5a983dSmrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
3824f3561b8bSmrg	$ECHO "\
3825fc5a983dSmrg*** ERROR, $lockfile contains:
3826fc5a983dSmrg`cat $lockfile 2>/dev/null`
3827fc5a983dSmrg
3828fc5a983dSmrgbut it should contain:
3829fc5a983dSmrg$srcfile
3830fc5a983dSmrg
3831fc5a983dSmrgThis indicates that another process is trying to use the same
3832fc5a983dSmrgtemporary object file, and libtool could not work around it because
38336257f37dSmrgyour compiler does not support '-c' and '-o' together.  If you
3834fc5a983dSmrgrepeat this compilation, it may succeed, by chance, but you had better
3835fc5a983dSmrgavoid parallel builds (make -j) in this platform, or get a better
3836fc5a983dSmrgcompiler."
3837fc5a983dSmrg
3838f3561b8bSmrg	$opt_dry_run || $RM $removelist
3839fc5a983dSmrg	exit $EXIT_FAILURE
3840fc5a983dSmrg      fi
3841fc5a983dSmrg
3842fc5a983dSmrg      # Just move the object if needed
3843fc5a983dSmrg      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
3844f3561b8bSmrg	func_show_eval '$MV "$output_obj" "$obj"' \
3845f3561b8bSmrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
3846fc5a983dSmrg      fi
3847fc5a983dSmrg    fi
3848fc5a983dSmrg
3849f3561b8bSmrg    $opt_dry_run || {
3850f3561b8bSmrg      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
3851fc5a983dSmrg
3852f3561b8bSmrg      # Unlock the critical section if it was locked
38536257f37dSmrg      if test no != "$need_locks"; then
3854f3561b8bSmrg	removelist=$lockfile
3855f3561b8bSmrg        $RM "$lockfile"
3856f3561b8bSmrg      fi
3857f3561b8bSmrg    }
3858fc5a983dSmrg
3859fc5a983dSmrg    exit $EXIT_SUCCESS
3860f3561b8bSmrg}
3861fc5a983dSmrg
3862f3561b8bSmrg$opt_help || {
38636257f37dSmrg  test compile = "$opt_mode" && func_mode_compile ${1+"$@"}
3864f3561b8bSmrg}
3865fc5a983dSmrg
3866f3561b8bSmrgfunc_mode_help ()
3867f3561b8bSmrg{
3868f3561b8bSmrg    # We need to display help for each of the modes.
3869bd304fc0Smrg    case $opt_mode in
3870f3561b8bSmrg      "")
3871f3561b8bSmrg        # Generic help is extracted from the usage comments
3872f3561b8bSmrg        # at the start of this file.
3873f3561b8bSmrg        func_help
3874f3561b8bSmrg        ;;
3875fc5a983dSmrg
3876f3561b8bSmrg      clean)
3877f3561b8bSmrg        $ECHO \
3878f3561b8bSmrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
3879fc5a983dSmrg
3880f3561b8bSmrgRemove files from the build directory.
3881fc5a983dSmrg
3882f3561b8bSmrgRM is the name of the program to use to delete files associated with each FILE
38836257f37dSmrg(typically '/bin/rm').  RM-OPTIONS are options (such as '-f') to be passed
3884f3561b8bSmrgto RM.
3885fc5a983dSmrg
3886f3561b8bSmrgIf FILE is a libtool library, object or program, all the files associated
3887f3561b8bSmrgwith it are deleted. Otherwise, only FILE itself is deleted using RM."
3888f3561b8bSmrg        ;;
3889fc5a983dSmrg
3890f3561b8bSmrg      compile)
3891f3561b8bSmrg      $ECHO \
3892f3561b8bSmrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
3893fc5a983dSmrg
3894f3561b8bSmrgCompile a source file into a libtool library object.
3895fc5a983dSmrg
3896f3561b8bSmrgThis mode accepts the following additional options:
3897fc5a983dSmrg
3898f3561b8bSmrg  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
3899f3561b8bSmrg  -no-suppress      do not suppress compiler output for multiple passes
3900bd304fc0Smrg  -prefer-pic       try to build PIC objects only
3901bd304fc0Smrg  -prefer-non-pic   try to build non-PIC objects only
39026257f37dSmrg  -shared           do not build a '.o' file suitable for static linking
39036257f37dSmrg  -static           only build a '.o' file suitable for static linking
3904d422ce2eSmrg  -Wc,FLAG
3905d422ce2eSmrg  -Xcompiler FLAG   pass FLAG directly to the compiler
3906fc5a983dSmrg
39076257f37dSmrgCOMPILE-COMMAND is a command to be used in creating a 'standard' object file
3908f3561b8bSmrgfrom the given SOURCEFILE.
3909fc5a983dSmrg
3910f3561b8bSmrgThe output file name is determined by removing the directory component from
39116257f37dSmrgSOURCEFILE, then substituting the C source code suffix '.c' with the
39126257f37dSmrglibrary object suffix, '.lo'."
3913f3561b8bSmrg        ;;
3914fc5a983dSmrg
3915f3561b8bSmrg      execute)
3916f3561b8bSmrg        $ECHO \
3917f3561b8bSmrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
3918fc5a983dSmrg
3919f3561b8bSmrgAutomatically set library path, then run a program.
3920fc5a983dSmrg
3921f3561b8bSmrgThis mode accepts the following additional options:
3922fc5a983dSmrg
3923f3561b8bSmrg  -dlopen FILE      add the directory containing FILE to the library path
3924fc5a983dSmrg
39256257f37dSmrgThis mode sets the library path environment variable according to '-dlopen'
3926f3561b8bSmrgflags.
3927fc5a983dSmrg
3928f3561b8bSmrgIf any of the ARGS are libtool executable wrappers, then they are translated
3929f3561b8bSmrginto their corresponding uninstalled binary, and any of their required library
3930f3561b8bSmrgdirectories are added to the library path.
3931fc5a983dSmrg
3932f3561b8bSmrgThen, COMMAND is executed, with ARGS as arguments."
3933f3561b8bSmrg        ;;
3934fc5a983dSmrg
3935f3561b8bSmrg      finish)
3936f3561b8bSmrg        $ECHO \
3937f3561b8bSmrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
3938fc5a983dSmrg
3939f3561b8bSmrgComplete the installation of libtool libraries.
3940fc5a983dSmrg
3941f3561b8bSmrgEach LIBDIR is a directory that contains libtool libraries.
3942fc5a983dSmrg
3943f3561b8bSmrgThe commands that this mode executes may require superuser privileges.  Use
39446257f37dSmrgthe '--dry-run' option if you just want to see what would be executed."
3945f3561b8bSmrg        ;;
3946fc5a983dSmrg
3947f3561b8bSmrg      install)
3948f3561b8bSmrg        $ECHO \
3949f3561b8bSmrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
3950fc5a983dSmrg
3951f3561b8bSmrgInstall executables or libraries.
3952fc5a983dSmrg
3953f3561b8bSmrgINSTALL-COMMAND is the installation command.  The first component should be
39546257f37dSmrgeither the 'install' or 'cp' program.
3955fc5a983dSmrg
3956f3561b8bSmrgThe following components of INSTALL-COMMAND are treated specially:
3957fc5a983dSmrg
3958bd304fc0Smrg  -inst-prefix-dir PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
3959fc5a983dSmrg
3960f3561b8bSmrgThe rest of the components are interpreted as arguments to that command (only
3961f3561b8bSmrgBSD-compatible install options are recognized)."
3962f3561b8bSmrg        ;;
3963fc5a983dSmrg
3964f3561b8bSmrg      link)
3965f3561b8bSmrg        $ECHO \
3966f3561b8bSmrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
3967fc5a983dSmrg
3968f3561b8bSmrgLink object files or libraries together to form another library, or to
3969f3561b8bSmrgcreate an executable program.
3970fc5a983dSmrg
3971f3561b8bSmrgLINK-COMMAND is a command using the C compiler that you would use to create
3972f3561b8bSmrga program from several object files.
3973fc5a983dSmrg
3974f3561b8bSmrgThe following components of LINK-COMMAND are treated specially:
3975fc5a983dSmrg
3976f3561b8bSmrg  -all-static       do not do any dynamic linking at all
3977f3561b8bSmrg  -avoid-version    do not add a version suffix if possible
3978bd304fc0Smrg  -bindir BINDIR    specify path to binaries directory (for systems where
3979bd304fc0Smrg                    libraries must be found in the PATH setting at runtime)
39806257f37dSmrg  -dlopen FILE      '-dlpreopen' FILE if it cannot be dlopened at runtime
3981f3561b8bSmrg  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
3982f3561b8bSmrg  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
3983f3561b8bSmrg  -export-symbols SYMFILE
3984f3561b8bSmrg                    try to export only the symbols listed in SYMFILE
3985f3561b8bSmrg  -export-symbols-regex REGEX
3986f3561b8bSmrg                    try to export only the symbols matching REGEX
3987f3561b8bSmrg  -LLIBDIR          search LIBDIR for required installed libraries
3988f3561b8bSmrg  -lNAME            OUTPUT-FILE requires the installed library libNAME
3989f3561b8bSmrg  -module           build a library that can dlopened
3990f3561b8bSmrg  -no-fast-install  disable the fast-install mode
3991f3561b8bSmrg  -no-install       link a not-installable executable
3992f3561b8bSmrg  -no-undefined     declare that a library does not refer to external symbols
3993f3561b8bSmrg  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
39946257f37dSmrg  -objectlist FILE  use a list of object files found in FILE to specify objects
39956257f37dSmrg  -os2dllname NAME  force a short DLL name on OS/2 (no effect on other OSes)
3996f3561b8bSmrg  -precious-files-regex REGEX
3997f3561b8bSmrg                    don't remove output files matching REGEX
3998f3561b8bSmrg  -release RELEASE  specify package release information
3999f3561b8bSmrg  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
4000f3561b8bSmrg  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
4001f3561b8bSmrg  -shared           only do dynamic linking of libtool libraries
4002f3561b8bSmrg  -shrext SUFFIX    override the standard shared library file extension
4003f3561b8bSmrg  -static           do not do any dynamic linking of uninstalled libtool libraries
4004f3561b8bSmrg  -static-libtool-libs
4005f3561b8bSmrg                    do not do any dynamic linking of libtool libraries
4006f3561b8bSmrg  -version-info CURRENT[:REVISION[:AGE]]
4007f3561b8bSmrg                    specify library version info [each variable defaults to 0]
4008f3561b8bSmrg  -weak LIBNAME     declare that the target provides the LIBNAME interface
4009bd304fc0Smrg  -Wc,FLAG
4010bd304fc0Smrg  -Xcompiler FLAG   pass linker-specific FLAG directly to the compiler
4011d422ce2eSmrg  -Wa,FLAG
4012d422ce2eSmrg  -Xassembler FLAG  pass linker-specific FLAG directly to the assembler
4013bd304fc0Smrg  -Wl,FLAG
4014bd304fc0Smrg  -Xlinker FLAG     pass linker-specific FLAG directly to the linker
4015bd304fc0Smrg  -XCClinker FLAG   pass link-specific FLAG to the compiler driver (CC)
4016fc5a983dSmrg
40176257f37dSmrgAll other options (arguments beginning with '-') are ignored.
4018fc5a983dSmrg
40196257f37dSmrgEvery other argument is treated as a filename.  Files ending in '.la' are
4020f3561b8bSmrgtreated as uninstalled libtool libraries, other files are standard or library
4021f3561b8bSmrgobject files.
4022fc5a983dSmrg
40236257f37dSmrgIf the OUTPUT-FILE ends in '.la', then a libtool library is created,
40246257f37dSmrgonly library objects ('.lo' files) may be specified, and '-rpath' is
4025f3561b8bSmrgrequired, except when creating a convenience library.
4026fc5a983dSmrg
40276257f37dSmrgIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created
40286257f37dSmrgusing 'ar' and 'ranlib', or on Windows using 'lib'.
4029fc5a983dSmrg
40306257f37dSmrgIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file
4031f3561b8bSmrgis created, otherwise an executable program is created."
4032fc5a983dSmrg        ;;
4033fc5a983dSmrg
4034f3561b8bSmrg      uninstall)
4035f3561b8bSmrg        $ECHO \
4036f3561b8bSmrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
4037fc5a983dSmrg
4038f3561b8bSmrgRemove libraries from an installation directory.
4039fc5a983dSmrg
4040f3561b8bSmrgRM is the name of the program to use to delete files associated with each FILE
40416257f37dSmrg(typically '/bin/rm').  RM-OPTIONS are options (such as '-f') to be passed
4042f3561b8bSmrgto RM.
4043fc5a983dSmrg
4044f3561b8bSmrgIf FILE is a libtool library, all the files associated with it are deleted.
4045f3561b8bSmrgOtherwise, only FILE itself is deleted using RM."
4046f3561b8bSmrg        ;;
4047fc5a983dSmrg
4048f3561b8bSmrg      *)
40496257f37dSmrg        func_fatal_help "invalid operation mode '$opt_mode'"
4050f3561b8bSmrg        ;;
4051f3561b8bSmrg    esac
4052fc5a983dSmrg
4053bd304fc0Smrg    echo
40546257f37dSmrg    $ECHO "Try '$progname --help' for more information about other modes."
4055f3561b8bSmrg}
4056fc5a983dSmrg
4057bd304fc0Smrg# Now that we've collected a possible --mode arg, show help if necessary
4058bd304fc0Smrgif $opt_help; then
40596257f37dSmrg  if test : = "$opt_help"; then
4060bd304fc0Smrg    func_mode_help
4061bd304fc0Smrg  else
4062bd304fc0Smrg    {
4063bd304fc0Smrg      func_help noexit
4064bd304fc0Smrg      for opt_mode in compile link execute install finish uninstall clean; do
4065bd304fc0Smrg	func_mode_help
4066bd304fc0Smrg      done
40676257f37dSmrg    } | $SED -n '1p; 2,$s/^Usage:/  or: /p'
4068bd304fc0Smrg    {
4069bd304fc0Smrg      func_help noexit
4070bd304fc0Smrg      for opt_mode in compile link execute install finish uninstall clean; do
4071bd304fc0Smrg	echo
4072bd304fc0Smrg	func_mode_help
4073bd304fc0Smrg      done
4074bd304fc0Smrg    } |
40756257f37dSmrg    $SED '1d
4076bd304fc0Smrg      /^When reporting/,/^Report/{
4077bd304fc0Smrg	H
4078bd304fc0Smrg	d
4079bd304fc0Smrg      }
4080bd304fc0Smrg      $x
4081bd304fc0Smrg      /information about other modes/d
4082bd304fc0Smrg      /more detailed .*MODE/d
4083bd304fc0Smrg      s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
4084bd304fc0Smrg  fi
4085bd304fc0Smrg  exit $?
4086bd304fc0Smrgfi
4087fc5a983dSmrg
4088fc5a983dSmrg
4089f3561b8bSmrg# func_mode_execute arg...
4090f3561b8bSmrgfunc_mode_execute ()
4091f3561b8bSmrg{
40926257f37dSmrg    $debug_cmd
40936257f37dSmrg
4094f3561b8bSmrg    # The first argument is the command name.
40956257f37dSmrg    cmd=$nonopt
4096f3561b8bSmrg    test -z "$cmd" && \
4097f3561b8bSmrg      func_fatal_help "you must specify a COMMAND"
4098fc5a983dSmrg
4099f3561b8bSmrg    # Handle -dlopen flags immediately.
4100bd304fc0Smrg    for file in $opt_dlopen; do
4101f3561b8bSmrg      test -f "$file" \
41026257f37dSmrg	|| func_fatal_help "'$file' is not a file"
4103fc5a983dSmrg
4104f3561b8bSmrg      dir=
4105f3561b8bSmrg      case $file in
4106f3561b8bSmrg      *.la)
4107bd304fc0Smrg	func_resolve_sysroot "$file"
4108bd304fc0Smrg	file=$func_resolve_sysroot_result
4109bd304fc0Smrg
4110f3561b8bSmrg	# Check to see that this really is a libtool archive.
4111f3561b8bSmrg	func_lalib_unsafe_p "$file" \
41126257f37dSmrg	  || func_fatal_help "'$lib' is not a valid libtool archive"
4113fc5a983dSmrg
4114f3561b8bSmrg	# Read the libtool library.
4115f3561b8bSmrg	dlname=
4116f3561b8bSmrg	library_names=
4117f3561b8bSmrg	func_source "$file"
4118fc5a983dSmrg
4119f3561b8bSmrg	# Skip this library if it cannot be dlopened.
4120f3561b8bSmrg	if test -z "$dlname"; then
4121f3561b8bSmrg	  # Warn if it was a shared library.
4122f3561b8bSmrg	  test -n "$library_names" && \
41236257f37dSmrg	    func_warning "'$file' was not linked with '-export-dynamic'"
4124f3561b8bSmrg	  continue
4125f3561b8bSmrg	fi
4126fc5a983dSmrg
4127f3561b8bSmrg	func_dirname "$file" "" "."
41286257f37dSmrg	dir=$func_dirname_result
4129fc5a983dSmrg
4130f3561b8bSmrg	if test -f "$dir/$objdir/$dlname"; then
4131bd304fc0Smrg	  func_append dir "/$objdir"
4132f3561b8bSmrg	else
4133f3561b8bSmrg	  if test ! -f "$dir/$dlname"; then
41346257f37dSmrg	    func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'"
4135f3561b8bSmrg	  fi
4136f3561b8bSmrg	fi
4137fc5a983dSmrg	;;
4138fc5a983dSmrg
4139f3561b8bSmrg      *.lo)
4140f3561b8bSmrg	# Just add the directory containing the .lo file.
4141f3561b8bSmrg	func_dirname "$file" "" "."
41426257f37dSmrg	dir=$func_dirname_result
4143fc5a983dSmrg	;;
4144fc5a983dSmrg
4145f3561b8bSmrg      *)
41466257f37dSmrg	func_warning "'-dlopen' is ignored for non-libtool libraries and objects"
4147fc5a983dSmrg	continue
4148fc5a983dSmrg	;;
4149f3561b8bSmrg      esac
4150fc5a983dSmrg
4151f3561b8bSmrg      # Get the absolute pathname.
4152f3561b8bSmrg      absdir=`cd "$dir" && pwd`
41536257f37dSmrg      test -n "$absdir" && dir=$absdir
4154fc5a983dSmrg
4155f3561b8bSmrg      # Now add the directory to shlibpath_var.
4156f3561b8bSmrg      if eval "test -z \"\$$shlibpath_var\""; then
4157f3561b8bSmrg	eval "$shlibpath_var=\"\$dir\""
4158f3561b8bSmrg      else
4159f3561b8bSmrg	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
4160f3561b8bSmrg      fi
4161f3561b8bSmrg    done
4162fc5a983dSmrg
4163f3561b8bSmrg    # This variable tells wrapper scripts just to set shlibpath_var
4164f3561b8bSmrg    # rather than running their programs.
41656257f37dSmrg    libtool_execute_magic=$magic
4166fc5a983dSmrg
4167f3561b8bSmrg    # Check if any of the arguments is a wrapper script.
4168f3561b8bSmrg    args=
4169f3561b8bSmrg    for file
4170f3561b8bSmrg    do
4171f3561b8bSmrg      case $file in
4172bd304fc0Smrg      -* | *.la | *.lo ) ;;
4173f3561b8bSmrg      *)
4174f3561b8bSmrg	# Do a test to see if this is really a libtool program.
4175f3561b8bSmrg	if func_ltwrapper_script_p "$file"; then
4176f3561b8bSmrg	  func_source "$file"
4177f3561b8bSmrg	  # Transform arg to wrapped name.
41786257f37dSmrg	  file=$progdir/$program
4179f3561b8bSmrg	elif func_ltwrapper_executable_p "$file"; then
4180f3561b8bSmrg	  func_ltwrapper_scriptname "$file"
4181f3561b8bSmrg	  func_source "$func_ltwrapper_scriptname_result"
4182f3561b8bSmrg	  # Transform arg to wrapped name.
41836257f37dSmrg	  file=$progdir/$program
4184f3561b8bSmrg	fi
4185f3561b8bSmrg	;;
4186f3561b8bSmrg      esac
4187f3561b8bSmrg      # Quote arguments (to preserve shell metacharacters).
4188bd304fc0Smrg      func_append_quoted args "$file"
4189f3561b8bSmrg    done
4190fc5a983dSmrg
41916257f37dSmrg    if $opt_dry_run; then
41926257f37dSmrg      # Display what would be done.
41936257f37dSmrg      if test -n "$shlibpath_var"; then
41946257f37dSmrg	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
41956257f37dSmrg	echo "export $shlibpath_var"
41966257f37dSmrg      fi
41976257f37dSmrg      $ECHO "$cmd$args"
41986257f37dSmrg      exit $EXIT_SUCCESS
41996257f37dSmrg    else
4200f3561b8bSmrg      if test -n "$shlibpath_var"; then
4201f3561b8bSmrg	# Export the shlibpath_var.
4202f3561b8bSmrg	eval "export $shlibpath_var"
4203f3561b8bSmrg      fi
4204fc5a983dSmrg
4205f3561b8bSmrg      # Restore saved environment variables
4206f3561b8bSmrg      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
4207f3561b8bSmrg      do
4208f3561b8bSmrg	eval "if test \"\${save_$lt_var+set}\" = set; then
4209f3561b8bSmrg                $lt_var=\$save_$lt_var; export $lt_var
4210fc5a983dSmrg	      else
4211f3561b8bSmrg		$lt_unset $lt_var
4212f3561b8bSmrg	      fi"
4213f3561b8bSmrg      done
4214fc5a983dSmrg
4215f3561b8bSmrg      # Now prepare to actually exec the command.
42166257f37dSmrg      exec_cmd=\$cmd$args
4217f3561b8bSmrg    fi
4218f3561b8bSmrg}
4219fc5a983dSmrg
42206257f37dSmrgtest execute = "$opt_mode" && func_mode_execute ${1+"$@"}
4221fc5a983dSmrg
4222fc5a983dSmrg
4223f3561b8bSmrg# func_mode_finish arg...
4224f3561b8bSmrgfunc_mode_finish ()
4225f3561b8bSmrg{
42266257f37dSmrg    $debug_cmd
42276257f37dSmrg
4228bd304fc0Smrg    libs=
4229bd304fc0Smrg    libdirs=
4230f3561b8bSmrg    admincmds=
4231fc5a983dSmrg
4232bd304fc0Smrg    for opt in "$nonopt" ${1+"$@"}
4233bd304fc0Smrg    do
4234bd304fc0Smrg      if test -d "$opt"; then
4235bd304fc0Smrg	func_append libdirs " $opt"
4236bd304fc0Smrg
4237bd304fc0Smrg      elif test -f "$opt"; then
4238bd304fc0Smrg	if func_lalib_unsafe_p "$opt"; then
4239bd304fc0Smrg	  func_append libs " $opt"
4240bd304fc0Smrg	else
42416257f37dSmrg	  func_warning "'$opt' is not a valid libtool archive"
4242bd304fc0Smrg	fi
4243bd304fc0Smrg
4244bd304fc0Smrg      else
42456257f37dSmrg	func_fatal_error "invalid argument '$opt'"
4246bd304fc0Smrg      fi
4247bd304fc0Smrg    done
4248bd304fc0Smrg
4249bd304fc0Smrg    if test -n "$libs"; then
4250bd304fc0Smrg      if test -n "$lt_sysroot"; then
4251bd304fc0Smrg        sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
4252bd304fc0Smrg        sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
4253bd304fc0Smrg      else
4254bd304fc0Smrg        sysroot_cmd=
4255bd304fc0Smrg      fi
4256bd304fc0Smrg
4257bd304fc0Smrg      # Remove sysroot references
4258bd304fc0Smrg      if $opt_dry_run; then
4259bd304fc0Smrg        for lib in $libs; do
42606257f37dSmrg          echo "removing references to $lt_sysroot and '=' prefixes from $lib"
4261bd304fc0Smrg        done
4262bd304fc0Smrg      else
4263bd304fc0Smrg        tmpdir=`func_mktempdir`
4264bd304fc0Smrg        for lib in $libs; do
42656257f37dSmrg	  $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
4266bd304fc0Smrg	    > $tmpdir/tmp-la
4267bd304fc0Smrg	  mv -f $tmpdir/tmp-la $lib
4268bd304fc0Smrg	done
4269bd304fc0Smrg        ${RM}r "$tmpdir"
4270bd304fc0Smrg      fi
4271bd304fc0Smrg    fi
4272fc5a983dSmrg
4273bd304fc0Smrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
4274f3561b8bSmrg      for libdir in $libdirs; do
4275f3561b8bSmrg	if test -n "$finish_cmds"; then
4276f3561b8bSmrg	  # Do each command in the finish commands.
4277f3561b8bSmrg	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
4278f3561b8bSmrg'"$cmd"'"'
4279fc5a983dSmrg	fi
4280f3561b8bSmrg	if test -n "$finish_eval"; then
4281f3561b8bSmrg	  # Do the single finish_eval.
4282f3561b8bSmrg	  eval cmds=\"$finish_eval\"
4283bd304fc0Smrg	  $opt_dry_run || eval "$cmds" || func_append admincmds "
4284f3561b8bSmrg       $cmds"
4285f3561b8bSmrg	fi
4286f3561b8bSmrg      done
4287f3561b8bSmrg    fi
4288fc5a983dSmrg
4289f3561b8bSmrg    # Exit here if they wanted silent mode.
42906257f37dSmrg    $opt_quiet && exit $EXIT_SUCCESS
4291fc5a983dSmrg
4292bd304fc0Smrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
4293bd304fc0Smrg      echo "----------------------------------------------------------------------"
4294bd304fc0Smrg      echo "Libraries have been installed in:"
4295bd304fc0Smrg      for libdir in $libdirs; do
4296bd304fc0Smrg	$ECHO "   $libdir"
4297bd304fc0Smrg      done
4298bd304fc0Smrg      echo
4299bd304fc0Smrg      echo "If you ever happen to want to link against installed libraries"
4300bd304fc0Smrg      echo "in a given directory, LIBDIR, you must either use libtool, and"
43016257f37dSmrg      echo "specify the full pathname of the library, or use the '-LLIBDIR'"
4302bd304fc0Smrg      echo "flag during linking and do at least one of the following:"
4303bd304fc0Smrg      if test -n "$shlibpath_var"; then
43046257f37dSmrg	echo "   - add LIBDIR to the '$shlibpath_var' environment variable"
4305bd304fc0Smrg	echo "     during execution"
4306bd304fc0Smrg      fi
4307bd304fc0Smrg      if test -n "$runpath_var"; then
43086257f37dSmrg	echo "   - add LIBDIR to the '$runpath_var' environment variable"
4309bd304fc0Smrg	echo "     during linking"
4310bd304fc0Smrg      fi
4311bd304fc0Smrg      if test -n "$hardcode_libdir_flag_spec"; then
4312bd304fc0Smrg	libdir=LIBDIR
4313bd304fc0Smrg	eval flag=\"$hardcode_libdir_flag_spec\"
4314bd304fc0Smrg
43156257f37dSmrg	$ECHO "   - use the '$flag' linker flag"
4316bd304fc0Smrg      fi
4317bd304fc0Smrg      if test -n "$admincmds"; then
4318bd304fc0Smrg	$ECHO "   - have your system administrator run these commands:$admincmds"
4319bd304fc0Smrg      fi
4320bd304fc0Smrg      if test -f /etc/ld.so.conf; then
43216257f37dSmrg	echo "   - have your system administrator add LIBDIR to '/etc/ld.so.conf'"
4322bd304fc0Smrg      fi
4323bd304fc0Smrg      echo
4324f3561b8bSmrg
4325bd304fc0Smrg      echo "See any operating system documentation about shared libraries for"
4326bd304fc0Smrg      case $host in
4327bd304fc0Smrg	solaris2.[6789]|solaris2.1[0-9])
4328bd304fc0Smrg	  echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
4329bd304fc0Smrg	  echo "pages."
4330bd304fc0Smrg	  ;;
4331bd304fc0Smrg	*)
4332bd304fc0Smrg	  echo "more information, such as the ld(1) and ld.so(8) manual pages."
4333bd304fc0Smrg	  ;;
4334bd304fc0Smrg      esac
4335bd304fc0Smrg      echo "----------------------------------------------------------------------"
4336f3561b8bSmrg    fi
4337f3561b8bSmrg    exit $EXIT_SUCCESS
4338f3561b8bSmrg}
4339f3561b8bSmrg
43406257f37dSmrgtest finish = "$opt_mode" && func_mode_finish ${1+"$@"}
4341f3561b8bSmrg
4342f3561b8bSmrg
4343f3561b8bSmrg# func_mode_install arg...
4344f3561b8bSmrgfunc_mode_install ()
4345f3561b8bSmrg{
43466257f37dSmrg    $debug_cmd
43476257f37dSmrg
4348f3561b8bSmrg    # There may be an optional sh(1) argument at the beginning of
4349f3561b8bSmrg    # install_prog (especially on Windows NT).
43506257f37dSmrg    if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" ||
4351f3561b8bSmrg       # Allow the use of GNU shtool's install command.
43526257f37dSmrg       case $nonopt in *shtool*) :;; *) false;; esac
43536257f37dSmrg    then
4354f3561b8bSmrg      # Aesthetically quote it.
4355d422ce2eSmrg      func_quote_arg pretty "$nonopt"
4356d422ce2eSmrg      install_prog="$func_quote_arg_result "
4357f3561b8bSmrg      arg=$1
4358f3561b8bSmrg      shift
4359f3561b8bSmrg    else
4360f3561b8bSmrg      install_prog=
4361f3561b8bSmrg      arg=$nonopt
4362f3561b8bSmrg    fi
4363f3561b8bSmrg
4364f3561b8bSmrg    # The real first argument should be the name of the installation program.
4365f3561b8bSmrg    # Aesthetically quote it.
4366d422ce2eSmrg    func_quote_arg pretty "$arg"
4367d422ce2eSmrg    func_append install_prog "$func_quote_arg_result"
4368bd304fc0Smrg    install_shared_prog=$install_prog
4369bd304fc0Smrg    case " $install_prog " in
4370bd304fc0Smrg      *[\\\ /]cp\ *) install_cp=: ;;
4371bd304fc0Smrg      *) install_cp=false ;;
4372bd304fc0Smrg    esac
4373f3561b8bSmrg
4374f3561b8bSmrg    # We need to accept at least all the BSD install flags.
4375f3561b8bSmrg    dest=
4376f3561b8bSmrg    files=
4377f3561b8bSmrg    opts=
4378f3561b8bSmrg    prev=
4379f3561b8bSmrg    install_type=
43806257f37dSmrg    isdir=false
4381f3561b8bSmrg    stripme=
4382bd304fc0Smrg    no_mode=:
4383f3561b8bSmrg    for arg
4384f3561b8bSmrg    do
4385bd304fc0Smrg      arg2=
4386f3561b8bSmrg      if test -n "$dest"; then
4387bd304fc0Smrg	func_append files " $dest"
4388f3561b8bSmrg	dest=$arg
4389f3561b8bSmrg	continue
4390f3561b8bSmrg      fi
4391f3561b8bSmrg
4392f3561b8bSmrg      case $arg in
43936257f37dSmrg      -d) isdir=: ;;
4394f3561b8bSmrg      -f)
4395bd304fc0Smrg	if $install_cp; then :; else
4396bd304fc0Smrg	  prev=$arg
4397bd304fc0Smrg	fi
4398f3561b8bSmrg	;;
4399f3561b8bSmrg      -g | -m | -o)
4400f3561b8bSmrg	prev=$arg
4401f3561b8bSmrg	;;
4402f3561b8bSmrg      -s)
4403f3561b8bSmrg	stripme=" -s"
4404f3561b8bSmrg	continue
4405f3561b8bSmrg	;;
4406f3561b8bSmrg      -*)
4407f3561b8bSmrg	;;
4408f3561b8bSmrg      *)
4409f3561b8bSmrg	# If the previous option needed an argument, then skip it.
4410f3561b8bSmrg	if test -n "$prev"; then
44116257f37dSmrg	  if test X-m = "X$prev" && test -n "$install_override_mode"; then
4412bd304fc0Smrg	    arg2=$install_override_mode
4413bd304fc0Smrg	    no_mode=false
4414bd304fc0Smrg	  fi
4415fc5a983dSmrg	  prev=
4416fc5a983dSmrg	else
4417f3561b8bSmrg	  dest=$arg
4418f3561b8bSmrg	  continue
4419fc5a983dSmrg	fi
4420fc5a983dSmrg	;;
4421f3561b8bSmrg      esac
4422fc5a983dSmrg
4423f3561b8bSmrg      # Aesthetically quote the argument.
4424d422ce2eSmrg      func_quote_arg pretty "$arg"
4425d422ce2eSmrg      func_append install_prog " $func_quote_arg_result"
4426bd304fc0Smrg      if test -n "$arg2"; then
4427d422ce2eSmrg	func_quote_arg pretty "$arg2"
4428bd304fc0Smrg      fi
4429d422ce2eSmrg      func_append install_shared_prog " $func_quote_arg_result"
4430f3561b8bSmrg    done
4431fc5a983dSmrg
4432f3561b8bSmrg    test -z "$install_prog" && \
4433f3561b8bSmrg      func_fatal_help "you must specify an install program"
4434fc5a983dSmrg
4435f3561b8bSmrg    test -n "$prev" && \
44366257f37dSmrg      func_fatal_help "the '$prev' option requires an argument"
4437fc5a983dSmrg
4438bd304fc0Smrg    if test -n "$install_override_mode" && $no_mode; then
4439bd304fc0Smrg      if $install_cp; then :; else
4440d422ce2eSmrg	func_quote_arg pretty "$install_override_mode"
4441d422ce2eSmrg	func_append install_shared_prog " -m $func_quote_arg_result"
4442bd304fc0Smrg      fi
4443bd304fc0Smrg    fi
4444bd304fc0Smrg
4445f3561b8bSmrg    if test -z "$files"; then
4446f3561b8bSmrg      if test -z "$dest"; then
4447f3561b8bSmrg	func_fatal_help "no file or destination specified"
4448f3561b8bSmrg      else
4449f3561b8bSmrg	func_fatal_help "you must specify a destination"
4450f3561b8bSmrg      fi
4451fc5a983dSmrg    fi
4452fc5a983dSmrg
4453f3561b8bSmrg    # Strip any trailing slash from the destination.
4454f3561b8bSmrg    func_stripname '' '/' "$dest"
4455f3561b8bSmrg    dest=$func_stripname_result
4456fc5a983dSmrg
4457f3561b8bSmrg    # Check to see that the destination is a directory.
44586257f37dSmrg    test -d "$dest" && isdir=:
44596257f37dSmrg    if $isdir; then
44606257f37dSmrg      destdir=$dest
4461f3561b8bSmrg      destname=
4462fc5a983dSmrg    else
4463f3561b8bSmrg      func_dirname_and_basename "$dest" "" "."
44646257f37dSmrg      destdir=$func_dirname_result
44656257f37dSmrg      destname=$func_basename_result
4466fc5a983dSmrg
4467f3561b8bSmrg      # Not a directory, so check to see that there is only one file specified.
4468f3561b8bSmrg      set dummy $files; shift
4469f3561b8bSmrg      test "$#" -gt 1 && \
44706257f37dSmrg	func_fatal_help "'$dest' is not a directory"
4471fc5a983dSmrg    fi
4472f3561b8bSmrg    case $destdir in
4473f3561b8bSmrg    [\\/]* | [A-Za-z]:[\\/]*) ;;
4474fc5a983dSmrg    *)
4475f3561b8bSmrg      for file in $files; do
4476f3561b8bSmrg	case $file in
4477f3561b8bSmrg	*.lo) ;;
4478f3561b8bSmrg	*)
44796257f37dSmrg	  func_fatal_help "'$destdir' must be an absolute directory name"
4480f3561b8bSmrg	  ;;
4481f3561b8bSmrg	esac
4482f3561b8bSmrg      done
4483fc5a983dSmrg      ;;
4484fc5a983dSmrg    esac
4485fc5a983dSmrg
4486f3561b8bSmrg    # This variable tells wrapper scripts just to set variables rather
4487f3561b8bSmrg    # than running their programs.
44886257f37dSmrg    libtool_install_magic=$magic
4489fc5a983dSmrg
4490f3561b8bSmrg    staticlibs=
4491f3561b8bSmrg    future_libdirs=
4492f3561b8bSmrg    current_libdirs=
4493f3561b8bSmrg    for file in $files; do
4494fc5a983dSmrg
4495f3561b8bSmrg      # Do each installation.
4496f3561b8bSmrg      case $file in
4497f3561b8bSmrg      *.$libext)
4498f3561b8bSmrg	# Do the static libraries later.
4499bd304fc0Smrg	func_append staticlibs " $file"
4500f3561b8bSmrg	;;
4501f3561b8bSmrg
4502f3561b8bSmrg      *.la)
4503bd304fc0Smrg	func_resolve_sysroot "$file"
4504bd304fc0Smrg	file=$func_resolve_sysroot_result
4505bd304fc0Smrg
4506f3561b8bSmrg	# Check to see that this really is a libtool archive.
4507f3561b8bSmrg	func_lalib_unsafe_p "$file" \
45086257f37dSmrg	  || func_fatal_help "'$file' is not a valid libtool archive"
4509f3561b8bSmrg
4510f3561b8bSmrg	library_names=
4511f3561b8bSmrg	old_library=
4512f3561b8bSmrg	relink_command=
4513f3561b8bSmrg	func_source "$file"
4514f3561b8bSmrg
4515f3561b8bSmrg	# Add the libdir to current_libdirs if it is the destination.
4516f3561b8bSmrg	if test "X$destdir" = "X$libdir"; then
4517f3561b8bSmrg	  case "$current_libdirs " in
4518f3561b8bSmrg	  *" $libdir "*) ;;
4519bd304fc0Smrg	  *) func_append current_libdirs " $libdir" ;;
4520fc5a983dSmrg	  esac
4521f3561b8bSmrg	else
4522f3561b8bSmrg	  # Note the libdir as a future libdir.
4523f3561b8bSmrg	  case "$future_libdirs " in
4524f3561b8bSmrg	  *" $libdir "*) ;;
4525bd304fc0Smrg	  *) func_append future_libdirs " $libdir" ;;
4526f3561b8bSmrg	  esac
4527f3561b8bSmrg	fi
4528fc5a983dSmrg
4529f3561b8bSmrg	func_dirname "$file" "/" ""
45306257f37dSmrg	dir=$func_dirname_result
4531bd304fc0Smrg	func_append dir "$objdir"
4532f3561b8bSmrg
4533f3561b8bSmrg	if test -n "$relink_command"; then
4534f3561b8bSmrg	  # Determine the prefix the user has applied to our future dir.
4535bd304fc0Smrg	  inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
4536f3561b8bSmrg
4537f3561b8bSmrg	  # Don't allow the user to place us outside of our expected
4538f3561b8bSmrg	  # location b/c this prevents finding dependent libraries that
4539f3561b8bSmrg	  # are installed to the same prefix.
4540f3561b8bSmrg	  # At present, this check doesn't affect windows .dll's that
4541f3561b8bSmrg	  # are installed into $libdir/../bin (currently, that works fine)
4542f3561b8bSmrg	  # but it's something to keep an eye on.
4543f3561b8bSmrg	  test "$inst_prefix_dir" = "$destdir" && \
45446257f37dSmrg	    func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir"
4545f3561b8bSmrg
4546f3561b8bSmrg	  if test -n "$inst_prefix_dir"; then
4547f3561b8bSmrg	    # Stick the inst_prefix_dir data into the link command.
4548bd304fc0Smrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
4549f3561b8bSmrg	  else
4550bd304fc0Smrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
4551f3561b8bSmrg	  fi
4552f3561b8bSmrg
45536257f37dSmrg	  func_warning "relinking '$file'"
4554f3561b8bSmrg	  func_show_eval "$relink_command" \
45556257f37dSmrg	    'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"'
4556f3561b8bSmrg	fi
4557f3561b8bSmrg
4558f3561b8bSmrg	# See the names of the shared library.
4559f3561b8bSmrg	set dummy $library_names; shift
4560f3561b8bSmrg	if test -n "$1"; then
45616257f37dSmrg	  realname=$1
4562f3561b8bSmrg	  shift
4563f3561b8bSmrg
45646257f37dSmrg	  srcname=$realname
45656257f37dSmrg	  test -n "$relink_command" && srcname=${realname}T
4566f3561b8bSmrg
4567f3561b8bSmrg	  # Install the shared library and build the symlinks.
4568bd304fc0Smrg	  func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
4569f3561b8bSmrg	      'exit $?'
45706257f37dSmrg	  tstripme=$stripme
4571f3561b8bSmrg	  case $host_os in
4572f3561b8bSmrg	  cygwin* | mingw* | pw32* | cegcc*)
4573f3561b8bSmrg	    case $realname in
4574f3561b8bSmrg	    *.dll.a)
45756257f37dSmrg	      tstripme=
45766257f37dSmrg	      ;;
45776257f37dSmrg	    esac
45786257f37dSmrg	    ;;
45796257f37dSmrg	  os2*)
45806257f37dSmrg	    case $realname in
45816257f37dSmrg	    *_dll.a)
45826257f37dSmrg	      tstripme=
4583f3561b8bSmrg	      ;;
4584f3561b8bSmrg	    esac
4585fc5a983dSmrg	    ;;
4586fc5a983dSmrg	  esac
4587f3561b8bSmrg	  if test -n "$tstripme" && test -n "$striplib"; then
4588f3561b8bSmrg	    func_show_eval "$striplib $destdir/$realname" 'exit $?'
4589fc5a983dSmrg	  fi
4590f3561b8bSmrg
4591f3561b8bSmrg	  if test "$#" -gt 0; then
4592f3561b8bSmrg	    # Delete the old symlinks, and create new ones.
45936257f37dSmrg	    # Try 'ln -sf' first, because the 'ln' binary might depend on
4594f3561b8bSmrg	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
4595f3561b8bSmrg	    # so we also need to try rm && ln -s.
4596f3561b8bSmrg	    for linkname
4597f3561b8bSmrg	    do
4598f3561b8bSmrg	      test "$linkname" != "$realname" \
4599f3561b8bSmrg		&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
4600fc5a983dSmrg	    done
4601fc5a983dSmrg	  fi
4602fc5a983dSmrg
4603f3561b8bSmrg	  # Do each command in the postinstall commands.
46046257f37dSmrg	  lib=$destdir/$realname
4605f3561b8bSmrg	  func_execute_cmds "$postinstall_cmds" 'exit $?'
4606fc5a983dSmrg	fi
4607fc5a983dSmrg
4608f3561b8bSmrg	# Install the pseudo-library for information purposes.
4609f3561b8bSmrg	func_basename "$file"
46106257f37dSmrg	name=$func_basename_result
46116257f37dSmrg	instname=$dir/${name}i
4612f3561b8bSmrg	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
4613fc5a983dSmrg
4614f3561b8bSmrg	# Maybe install the static library, too.
4615bd304fc0Smrg	test -n "$old_library" && func_append staticlibs " $dir/$old_library"
4616f3561b8bSmrg	;;
4617fc5a983dSmrg
4618f3561b8bSmrg      *.lo)
4619f3561b8bSmrg	# Install (i.e. copy) a libtool object.
4620fc5a983dSmrg
4621f3561b8bSmrg	# Figure out destination file name, if it wasn't already specified.
4622f3561b8bSmrg	if test -n "$destname"; then
46236257f37dSmrg	  destfile=$destdir/$destname
4624f3561b8bSmrg	else
4625f3561b8bSmrg	  func_basename "$file"
46266257f37dSmrg	  destfile=$func_basename_result
46276257f37dSmrg	  destfile=$destdir/$destfile
4628fc5a983dSmrg	fi
4629fc5a983dSmrg
4630f3561b8bSmrg	# Deduce the name of the destination old-style object file.
4631f3561b8bSmrg	case $destfile in
4632f3561b8bSmrg	*.lo)
4633f3561b8bSmrg	  func_lo2o "$destfile"
4634f3561b8bSmrg	  staticdest=$func_lo2o_result
4635f3561b8bSmrg	  ;;
4636f3561b8bSmrg	*.$objext)
46376257f37dSmrg	  staticdest=$destfile
4638f3561b8bSmrg	  destfile=
4639f3561b8bSmrg	  ;;
4640f3561b8bSmrg	*)
46416257f37dSmrg	  func_fatal_help "cannot copy a libtool object to '$destfile'"
4642f3561b8bSmrg	  ;;
4643f3561b8bSmrg	esac
4644fc5a983dSmrg
4645f3561b8bSmrg	# Install the libtool object if requested.
4646f3561b8bSmrg	test -n "$destfile" && \
4647f3561b8bSmrg	  func_show_eval "$install_prog $file $destfile" 'exit $?'
4648fc5a983dSmrg
4649f3561b8bSmrg	# Install the old object if enabled.
46506257f37dSmrg	if test yes = "$build_old_libs"; then
4651f3561b8bSmrg	  # Deduce the name of the old-style object file.
4652f3561b8bSmrg	  func_lo2o "$file"
4653f3561b8bSmrg	  staticobj=$func_lo2o_result
4654f3561b8bSmrg	  func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
4655fc5a983dSmrg	fi
4656f3561b8bSmrg	exit $EXIT_SUCCESS
4657f3561b8bSmrg	;;
4658fc5a983dSmrg
4659f3561b8bSmrg      *)
4660f3561b8bSmrg	# Figure out destination file name, if it wasn't already specified.
4661f3561b8bSmrg	if test -n "$destname"; then
46626257f37dSmrg	  destfile=$destdir/$destname
4663f3561b8bSmrg	else
4664f3561b8bSmrg	  func_basename "$file"
46656257f37dSmrg	  destfile=$func_basename_result
46666257f37dSmrg	  destfile=$destdir/$destfile
4667f3561b8bSmrg	fi
4668fc5a983dSmrg
4669f3561b8bSmrg	# If the file is missing, and there is a .exe on the end, strip it
4670f3561b8bSmrg	# because it is most likely a libtool script we actually want to
4671f3561b8bSmrg	# install
46726257f37dSmrg	stripped_ext=
4673f3561b8bSmrg	case $file in
4674f3561b8bSmrg	  *.exe)
4675f3561b8bSmrg	    if test ! -f "$file"; then
4676f3561b8bSmrg	      func_stripname '' '.exe' "$file"
4677f3561b8bSmrg	      file=$func_stripname_result
46786257f37dSmrg	      stripped_ext=.exe
4679f3561b8bSmrg	    fi
4680f3561b8bSmrg	    ;;
4681f3561b8bSmrg	esac
4682f3561b8bSmrg
4683f3561b8bSmrg	# Do a test to see if this is really a libtool program.
4684f3561b8bSmrg	case $host in
4685f3561b8bSmrg	*cygwin* | *mingw*)
4686f3561b8bSmrg	    if func_ltwrapper_executable_p "$file"; then
4687f3561b8bSmrg	      func_ltwrapper_scriptname "$file"
4688f3561b8bSmrg	      wrapper=$func_ltwrapper_scriptname_result
4689f3561b8bSmrg	    else
4690f3561b8bSmrg	      func_stripname '' '.exe' "$file"
4691f3561b8bSmrg	      wrapper=$func_stripname_result
4692f3561b8bSmrg	    fi
4693f3561b8bSmrg	    ;;
4694fc5a983dSmrg	*)
4695f3561b8bSmrg	    wrapper=$file
4696f3561b8bSmrg	    ;;
4697f3561b8bSmrg	esac
4698f3561b8bSmrg	if func_ltwrapper_script_p "$wrapper"; then
4699f3561b8bSmrg	  notinst_deplibs=
4700f3561b8bSmrg	  relink_command=
4701f3561b8bSmrg
4702f3561b8bSmrg	  func_source "$wrapper"
4703f3561b8bSmrg
4704f3561b8bSmrg	  # Check the variables that should have been set.
4705f3561b8bSmrg	  test -z "$generated_by_libtool_version" && \
47066257f37dSmrg	    func_fatal_error "invalid libtool wrapper script '$wrapper'"
4707f3561b8bSmrg
47086257f37dSmrg	  finalize=:
4709f3561b8bSmrg	  for lib in $notinst_deplibs; do
4710f3561b8bSmrg	    # Check to see that each library is installed.
4711f3561b8bSmrg	    libdir=
4712f3561b8bSmrg	    if test -f "$lib"; then
4713f3561b8bSmrg	      func_source "$lib"
4714f3561b8bSmrg	    fi
47156257f37dSmrg	    libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'`
4716f3561b8bSmrg	    if test -n "$libdir" && test ! -f "$libfile"; then
47176257f37dSmrg	      func_warning "'$lib' has not been installed in '$libdir'"
47186257f37dSmrg	      finalize=false
4719f3561b8bSmrg	    fi
4720f3561b8bSmrg	  done
4721f3561b8bSmrg
4722f3561b8bSmrg	  relink_command=
4723f3561b8bSmrg	  func_source "$wrapper"
4724f3561b8bSmrg
4725f3561b8bSmrg	  outputname=
47266257f37dSmrg	  if test no = "$fast_install" && test -n "$relink_command"; then
4727f3561b8bSmrg	    $opt_dry_run || {
47286257f37dSmrg	      if $finalize; then
4729f3561b8bSmrg	        tmpdir=`func_mktempdir`
4730f3561b8bSmrg		func_basename "$file$stripped_ext"
47316257f37dSmrg		file=$func_basename_result
47326257f37dSmrg	        outputname=$tmpdir/$file
4733f3561b8bSmrg	        # Replace the output file specification.
4734bd304fc0Smrg	        relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
4735f3561b8bSmrg
47366257f37dSmrg	        $opt_quiet || {
4737d422ce2eSmrg	          func_quote_arg expand,pretty "$relink_command"
4738d422ce2eSmrg		  eval "func_echo $func_quote_arg_result"
4739f3561b8bSmrg	        }
4740f3561b8bSmrg	        if eval "$relink_command"; then :
4741f3561b8bSmrg	          else
47426257f37dSmrg		  func_error "error: relink '$file' with the above command before installing it"
4743f3561b8bSmrg		  $opt_dry_run || ${RM}r "$tmpdir"
4744f3561b8bSmrg		  continue
4745f3561b8bSmrg	        fi
47466257f37dSmrg	        file=$outputname
4747f3561b8bSmrg	      else
47486257f37dSmrg	        func_warning "cannot relink '$file'"
4749f3561b8bSmrg	      fi
4750f3561b8bSmrg	    }
4751f3561b8bSmrg	  else
4752f3561b8bSmrg	    # Install the binary that we compiled earlier.
4753bd304fc0Smrg	    file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
4754fc5a983dSmrg	  fi
4755f3561b8bSmrg	fi
4756f3561b8bSmrg
4757f3561b8bSmrg	# remove .exe since cygwin /usr/bin/install will append another
4758f3561b8bSmrg	# one anyway
4759f3561b8bSmrg	case $install_prog,$host in
4760f3561b8bSmrg	*/usr/bin/install*,*cygwin*)
4761f3561b8bSmrg	  case $file:$destfile in
4762f3561b8bSmrg	  *.exe:*.exe)
4763f3561b8bSmrg	    # this is ok
4764f3561b8bSmrg	    ;;
4765f3561b8bSmrg	  *.exe:*)
4766f3561b8bSmrg	    destfile=$destfile.exe
4767f3561b8bSmrg	    ;;
4768f3561b8bSmrg	  *:*.exe)
4769f3561b8bSmrg	    func_stripname '' '.exe' "$destfile"
4770f3561b8bSmrg	    destfile=$func_stripname_result
4771f3561b8bSmrg	    ;;
4772f3561b8bSmrg	  esac
4773fc5a983dSmrg	  ;;
4774fc5a983dSmrg	esac
4775f3561b8bSmrg	func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
4776f3561b8bSmrg	$opt_dry_run || if test -n "$outputname"; then
4777f3561b8bSmrg	  ${RM}r "$tmpdir"
4778f3561b8bSmrg	fi
4779f3561b8bSmrg	;;
4780f3561b8bSmrg      esac
4781f3561b8bSmrg    done
4782fc5a983dSmrg
4783f3561b8bSmrg    for file in $staticlibs; do
4784f3561b8bSmrg      func_basename "$file"
47856257f37dSmrg      name=$func_basename_result
4786f3561b8bSmrg
4787f3561b8bSmrg      # Set up the ranlib parameters.
47886257f37dSmrg      oldlib=$destdir/$name
4789bd304fc0Smrg      func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
4790bd304fc0Smrg      tool_oldlib=$func_to_tool_file_result
4791f3561b8bSmrg
4792f3561b8bSmrg      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
4793f3561b8bSmrg
4794f3561b8bSmrg      if test -n "$stripme" && test -n "$old_striplib"; then
4795bd304fc0Smrg	func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
4796f3561b8bSmrg      fi
4797f3561b8bSmrg
4798f3561b8bSmrg      # Do each command in the postinstall commands.
4799f3561b8bSmrg      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
4800f3561b8bSmrg    done
4801f3561b8bSmrg
4802f3561b8bSmrg    test -n "$future_libdirs" && \
48036257f37dSmrg      func_warning "remember to run '$progname --finish$future_libdirs'"
4804f3561b8bSmrg
4805f3561b8bSmrg    if test -n "$current_libdirs"; then
4806f3561b8bSmrg      # Maybe just do a dry run.
4807f3561b8bSmrg      $opt_dry_run && current_libdirs=" -n$current_libdirs"
48086257f37dSmrg      exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs'
4809f3561b8bSmrg    else
4810f3561b8bSmrg      exit $EXIT_SUCCESS
4811f3561b8bSmrg    fi
4812f3561b8bSmrg}
4813f3561b8bSmrg
48146257f37dSmrgtest install = "$opt_mode" && func_mode_install ${1+"$@"}
4815f3561b8bSmrg
4816f3561b8bSmrg
4817f3561b8bSmrg# func_generate_dlsyms outputname originator pic_p
4818f3561b8bSmrg# Extract symbols from dlprefiles and create ${outputname}S.o with
4819f3561b8bSmrg# a dlpreopen symbol table.
4820f3561b8bSmrgfunc_generate_dlsyms ()
4821f3561b8bSmrg{
48226257f37dSmrg    $debug_cmd
48236257f37dSmrg
48246257f37dSmrg    my_outputname=$1
48256257f37dSmrg    my_originator=$2
48266257f37dSmrg    my_pic_p=${3-false}
48276257f37dSmrg    my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'`
4828f3561b8bSmrg    my_dlsyms=
4829f3561b8bSmrg
48306257f37dSmrg    if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
4831f3561b8bSmrg      if test -n "$NM" && test -n "$global_symbol_pipe"; then
48326257f37dSmrg	my_dlsyms=${my_outputname}S.c
4833f3561b8bSmrg      else
4834f3561b8bSmrg	func_error "not configured to extract global symbols from dlpreopened files"
4835f3561b8bSmrg      fi
4836f3561b8bSmrg    fi
4837f3561b8bSmrg
4838f3561b8bSmrg    if test -n "$my_dlsyms"; then
4839f3561b8bSmrg      case $my_dlsyms in
4840f3561b8bSmrg      "") ;;
4841f3561b8bSmrg      *.c)
4842f3561b8bSmrg	# Discover the nlist of each of the dlfiles.
48436257f37dSmrg	nlist=$output_objdir/$my_outputname.nm
4844f3561b8bSmrg
4845f3561b8bSmrg	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
4846f3561b8bSmrg
4847f3561b8bSmrg	# Parse the name list into a source file.
4848f3561b8bSmrg	func_verbose "creating $output_objdir/$my_dlsyms"
4849f3561b8bSmrg
4850f3561b8bSmrg	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
48516257f37dSmrg/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */
48526257f37dSmrg/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */
4853f3561b8bSmrg
4854f3561b8bSmrg#ifdef __cplusplus
4855f3561b8bSmrgextern \"C\" {
4856f3561b8bSmrg#endif
4857f3561b8bSmrg
48586257f37dSmrg#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
4859bd304fc0Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
4860bd304fc0Smrg#endif
4861bd304fc0Smrg
4862bd304fc0Smrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
48636257f37dSmrg#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE
48646257f37dSmrg/* DATA imports from DLLs on WIN32 can't be const, because runtime
4865bd304fc0Smrg   relocations are performed -- see ld's documentation on pseudo-relocs.  */
4866bd304fc0Smrg# define LT_DLSYM_CONST
48676257f37dSmrg#elif defined __osf__
4868bd304fc0Smrg/* This system does not cope well with relocations in const data.  */
4869bd304fc0Smrg# define LT_DLSYM_CONST
4870bd304fc0Smrg#else
4871bd304fc0Smrg# define LT_DLSYM_CONST const
4872bd304fc0Smrg#endif
4873bd304fc0Smrg
48746257f37dSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
48756257f37dSmrg
4876f3561b8bSmrg/* External symbol declarations for the compiler. */\
4877f3561b8bSmrg"
4878f3561b8bSmrg
48796257f37dSmrg	if test yes = "$dlself"; then
48806257f37dSmrg	  func_verbose "generating symbol list for '$output'"
4881f3561b8bSmrg
4882f3561b8bSmrg	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
4883f3561b8bSmrg
4884f3561b8bSmrg	  # Add our own program objects to the symbol list.
4885bd304fc0Smrg	  progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
4886f3561b8bSmrg	  for progfile in $progfiles; do
4887bd304fc0Smrg	    func_to_tool_file "$progfile" func_convert_file_msys_to_w32
48886257f37dSmrg	    func_verbose "extracting global C symbols from '$func_to_tool_file_result'"
4889bd304fc0Smrg	    $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
4890f3561b8bSmrg	  done
4891f3561b8bSmrg
4892f3561b8bSmrg	  if test -n "$exclude_expsyms"; then
4893f3561b8bSmrg	    $opt_dry_run || {
4894f3561b8bSmrg	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
4895f3561b8bSmrg	      eval '$MV "$nlist"T "$nlist"'
4896f3561b8bSmrg	    }
4897fc5a983dSmrg	  fi
4898f3561b8bSmrg
4899f3561b8bSmrg	  if test -n "$export_symbols_regex"; then
4900f3561b8bSmrg	    $opt_dry_run || {
4901f3561b8bSmrg	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
4902f3561b8bSmrg	      eval '$MV "$nlist"T "$nlist"'
4903f3561b8bSmrg	    }
4904f3561b8bSmrg	  fi
4905f3561b8bSmrg
4906f3561b8bSmrg	  # Prepare the list of exported symbols
4907f3561b8bSmrg	  if test -z "$export_symbols"; then
49086257f37dSmrg	    export_symbols=$output_objdir/$outputname.exp
4909f3561b8bSmrg	    $opt_dry_run || {
4910f3561b8bSmrg	      $RM $export_symbols
49116257f37dSmrg	      eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
4912f3561b8bSmrg	      case $host in
4913f3561b8bSmrg	      *cygwin* | *mingw* | *cegcc* )
4914f3561b8bSmrg                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
4915f3561b8bSmrg                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
4916f3561b8bSmrg	        ;;
4917f3561b8bSmrg	      esac
4918f3561b8bSmrg	    }
4919fc5a983dSmrg	  else
4920f3561b8bSmrg	    $opt_dry_run || {
49216257f37dSmrg	      eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
4922f3561b8bSmrg	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
4923f3561b8bSmrg	      eval '$MV "$nlist"T "$nlist"'
4924f3561b8bSmrg	      case $host in
4925bd304fc0Smrg	        *cygwin* | *mingw* | *cegcc* )
4926f3561b8bSmrg	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
4927f3561b8bSmrg	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
4928f3561b8bSmrg	          ;;
4929f3561b8bSmrg	      esac
4930f3561b8bSmrg	    }
4931fc5a983dSmrg	  fi
4932f3561b8bSmrg	fi
4933fc5a983dSmrg
4934f3561b8bSmrg	for dlprefile in $dlprefiles; do
49356257f37dSmrg	  func_verbose "extracting global C symbols from '$dlprefile'"
4936f3561b8bSmrg	  func_basename "$dlprefile"
49376257f37dSmrg	  name=$func_basename_result
4938bd304fc0Smrg          case $host in
4939bd304fc0Smrg	    *cygwin* | *mingw* | *cegcc* )
4940bd304fc0Smrg	      # if an import library, we need to obtain dlname
4941bd304fc0Smrg	      if func_win32_import_lib_p "$dlprefile"; then
4942bd304fc0Smrg	        func_tr_sh "$dlprefile"
4943bd304fc0Smrg	        eval "curr_lafile=\$libfile_$func_tr_sh_result"
49446257f37dSmrg	        dlprefile_dlbasename=
4945bd304fc0Smrg	        if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
4946bd304fc0Smrg	          # Use subshell, to avoid clobbering current variable values
4947bd304fc0Smrg	          dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
49486257f37dSmrg	          if test -n "$dlprefile_dlname"; then
4949bd304fc0Smrg	            func_basename "$dlprefile_dlname"
49506257f37dSmrg	            dlprefile_dlbasename=$func_basename_result
4951bd304fc0Smrg	          else
4952bd304fc0Smrg	            # no lafile. user explicitly requested -dlpreopen <import library>.
4953bd304fc0Smrg	            $sharedlib_from_linklib_cmd "$dlprefile"
4954bd304fc0Smrg	            dlprefile_dlbasename=$sharedlib_from_linklib_result
4955bd304fc0Smrg	          fi
4956bd304fc0Smrg	        fi
4957bd304fc0Smrg	        $opt_dry_run || {
49586257f37dSmrg	          if test -n "$dlprefile_dlbasename"; then
4959bd304fc0Smrg	            eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
4960bd304fc0Smrg	          else
4961bd304fc0Smrg	            func_warning "Could not compute DLL name from $name"
4962bd304fc0Smrg	            eval '$ECHO ": $name " >> "$nlist"'
4963bd304fc0Smrg	          fi
4964bd304fc0Smrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
4965bd304fc0Smrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
4966bd304fc0Smrg	            $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
4967bd304fc0Smrg	        }
4968bd304fc0Smrg	      else # not an import lib
4969bd304fc0Smrg	        $opt_dry_run || {
4970bd304fc0Smrg	          eval '$ECHO ": $name " >> "$nlist"'
4971bd304fc0Smrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
4972bd304fc0Smrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
4973bd304fc0Smrg	        }
4974bd304fc0Smrg	      fi
4975bd304fc0Smrg	    ;;
4976bd304fc0Smrg	    *)
4977bd304fc0Smrg	      $opt_dry_run || {
4978bd304fc0Smrg	        eval '$ECHO ": $name " >> "$nlist"'
4979bd304fc0Smrg	        func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
4980bd304fc0Smrg	        eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
4981bd304fc0Smrg	      }
4982bd304fc0Smrg	    ;;
4983bd304fc0Smrg          esac
4984f3561b8bSmrg	done
4985f3561b8bSmrg
4986f3561b8bSmrg	$opt_dry_run || {
4987f3561b8bSmrg	  # Make sure we have at least an empty file.
4988f3561b8bSmrg	  test -f "$nlist" || : > "$nlist"
4989f3561b8bSmrg
4990f3561b8bSmrg	  if test -n "$exclude_expsyms"; then
4991f3561b8bSmrg	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
4992f3561b8bSmrg	    $MV "$nlist"T "$nlist"
4993fc5a983dSmrg	  fi
4994f3561b8bSmrg
4995f3561b8bSmrg	  # Try sorting and uniquifying the output.
4996f3561b8bSmrg	  if $GREP -v "^: " < "$nlist" |
4997f3561b8bSmrg	      if sort -k 3 </dev/null >/dev/null 2>&1; then
4998f3561b8bSmrg		sort -k 3
4999f3561b8bSmrg	      else
5000f3561b8bSmrg		sort +2
5001f3561b8bSmrg	      fi |
5002f3561b8bSmrg	      uniq > "$nlist"S; then
5003f3561b8bSmrg	    :
5004fc5a983dSmrg	  else
5005f3561b8bSmrg	    $GREP -v "^: " < "$nlist" > "$nlist"S
5006fc5a983dSmrg	  fi
5007fc5a983dSmrg
5008f3561b8bSmrg	  if test -f "$nlist"S; then
5009f3561b8bSmrg	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
5010fc5a983dSmrg	  else
5011bd304fc0Smrg	    echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
5012fc5a983dSmrg	  fi
5013fc5a983dSmrg
50146257f37dSmrg	  func_show_eval '$RM "${nlist}I"'
50156257f37dSmrg	  if test -n "$global_symbol_to_import"; then
50166257f37dSmrg	    eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I'
50176257f37dSmrg	  fi
50186257f37dSmrg
5019bd304fc0Smrg	  echo >> "$output_objdir/$my_dlsyms" "\
5020fc5a983dSmrg
5021f3561b8bSmrg/* The mapping between symbol names and symbols.  */
5022f3561b8bSmrgtypedef struct {
5023f3561b8bSmrg  const char *name;
5024f3561b8bSmrg  void *address;
5025f3561b8bSmrg} lt_dlsymlist;
5026bd304fc0Smrgextern LT_DLSYM_CONST lt_dlsymlist
50276257f37dSmrglt_${my_prefix}_LTX_preloaded_symbols[];\
50286257f37dSmrg"
50296257f37dSmrg
50306257f37dSmrg	  if test -s "$nlist"I; then
50316257f37dSmrg	    echo >> "$output_objdir/$my_dlsyms" "\
50326257f37dSmrgstatic void lt_syminit(void)
50336257f37dSmrg{
50346257f37dSmrg  LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols;
50356257f37dSmrg  for (; symbol->name; ++symbol)
50366257f37dSmrg    {"
50376257f37dSmrg	    $SED 's/.*/      if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms"
50386257f37dSmrg	    echo >> "$output_objdir/$my_dlsyms" "\
50396257f37dSmrg    }
50406257f37dSmrg}"
50416257f37dSmrg	  fi
50426257f37dSmrg	  echo >> "$output_objdir/$my_dlsyms" "\
5043bd304fc0SmrgLT_DLSYM_CONST lt_dlsymlist
5044f3561b8bSmrglt_${my_prefix}_LTX_preloaded_symbols[] =
50456257f37dSmrg{ {\"$my_originator\", (void *) 0},"
50466257f37dSmrg
50476257f37dSmrg	  if test -s "$nlist"I; then
50486257f37dSmrg	    echo >> "$output_objdir/$my_dlsyms" "\
50496257f37dSmrg  {\"@INIT@\", (void *) &lt_syminit},"
50506257f37dSmrg	  fi
5051fc5a983dSmrg
5052f3561b8bSmrg	  case $need_lib_prefix in
5053f3561b8bSmrg	  no)
5054f3561b8bSmrg	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
5055f3561b8bSmrg	    ;;
5056f3561b8bSmrg	  *)
5057f3561b8bSmrg	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
5058f3561b8bSmrg	    ;;
5059f3561b8bSmrg	  esac
5060bd304fc0Smrg	  echo >> "$output_objdir/$my_dlsyms" "\
5061f3561b8bSmrg  {0, (void *) 0}
5062f3561b8bSmrg};
5063fc5a983dSmrg
5064f3561b8bSmrg/* This works around a problem in FreeBSD linker */
5065f3561b8bSmrg#ifdef FREEBSD_WORKAROUND
5066f3561b8bSmrgstatic const void *lt_preloaded_setup() {
5067f3561b8bSmrg  return lt_${my_prefix}_LTX_preloaded_symbols;
5068f3561b8bSmrg}
5069f3561b8bSmrg#endif
5070f3561b8bSmrg
5071f3561b8bSmrg#ifdef __cplusplus
5072f3561b8bSmrg}
5073f3561b8bSmrg#endif\
5074f3561b8bSmrg"
5075f3561b8bSmrg	} # !$opt_dry_run
5076f3561b8bSmrg
5077f3561b8bSmrg	pic_flag_for_symtable=
5078f3561b8bSmrg	case "$compile_command " in
5079f3561b8bSmrg	*" -static "*) ;;
5080f3561b8bSmrg	*)
5081f3561b8bSmrg	  case $host in
5082f3561b8bSmrg	  # compiling the symbol table file with pic_flag works around
5083f3561b8bSmrg	  # a FreeBSD bug that causes programs to crash when -lm is
5084f3561b8bSmrg	  # linked before any other PIC object.  But we must not use
5085f3561b8bSmrg	  # pic_flag when linking with -static.  The problem exists in
5086f3561b8bSmrg	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
5087bd304fc0Smrg	  *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
5088f3561b8bSmrg	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
5089f3561b8bSmrg	  *-*-hpux*)
5090f3561b8bSmrg	    pic_flag_for_symtable=" $pic_flag"  ;;
5091f3561b8bSmrg	  *)
50926257f37dSmrg	    $my_pic_p && pic_flag_for_symtable=" $pic_flag"
5093f3561b8bSmrg	    ;;
5094f3561b8bSmrg	  esac
5095f3561b8bSmrg	  ;;
5096f3561b8bSmrg	esac
5097f3561b8bSmrg	symtab_cflags=
5098f3561b8bSmrg	for arg in $LTCFLAGS; do
5099f3561b8bSmrg	  case $arg in
5100f3561b8bSmrg	  -pie | -fpie | -fPIE) ;;
5101bd304fc0Smrg	  *) func_append symtab_cflags " $arg" ;;
5102f3561b8bSmrg	  esac
5103f3561b8bSmrg	done
5104fc5a983dSmrg
5105f3561b8bSmrg	# Now compile the dynamic symbol file.
5106f3561b8bSmrg	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
5107fc5a983dSmrg
5108f3561b8bSmrg	# Clean up the generated files.
51096257f37dSmrg	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"'
5110fc5a983dSmrg
5111f3561b8bSmrg	# Transform the symbol file into the correct name.
51126257f37dSmrg	symfileobj=$output_objdir/${my_outputname}S.$objext
5113f3561b8bSmrg	case $host in
5114f3561b8bSmrg	*cygwin* | *mingw* | *cegcc* )
5115f3561b8bSmrg	  if test -f "$output_objdir/$my_outputname.def"; then
5116bd304fc0Smrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
5117bd304fc0Smrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
5118f3561b8bSmrg	  else
5119bd304fc0Smrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
5120bd304fc0Smrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
5121fc5a983dSmrg	  fi
5122f3561b8bSmrg	  ;;
5123f3561b8bSmrg	*)
5124bd304fc0Smrg	  compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
5125bd304fc0Smrg	  finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
5126f3561b8bSmrg	  ;;
5127f3561b8bSmrg	esac
5128f3561b8bSmrg	;;
5129f3561b8bSmrg      *)
51306257f37dSmrg	func_fatal_error "unknown suffix for '$my_dlsyms'"
5131f3561b8bSmrg	;;
5132f3561b8bSmrg      esac
5133f3561b8bSmrg    else
5134f3561b8bSmrg      # We keep going just in case the user didn't refer to
5135f3561b8bSmrg      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
5136f3561b8bSmrg      # really was required.
5137fc5a983dSmrg
5138f3561b8bSmrg      # Nullify the symbol file.
5139bd304fc0Smrg      compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
5140bd304fc0Smrg      finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
5141f3561b8bSmrg    fi
5142f3561b8bSmrg}
5143fc5a983dSmrg
51446257f37dSmrg# func_cygming_gnu_implib_p ARG
51456257f37dSmrg# This predicate returns with zero status (TRUE) if
51466257f37dSmrg# ARG is a GNU/binutils-style import library. Returns
51476257f37dSmrg# with nonzero status (FALSE) otherwise.
51486257f37dSmrgfunc_cygming_gnu_implib_p ()
51496257f37dSmrg{
51506257f37dSmrg  $debug_cmd
51516257f37dSmrg
51526257f37dSmrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
51536257f37dSmrg  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)$'`
51546257f37dSmrg  test -n "$func_cygming_gnu_implib_tmp"
51556257f37dSmrg}
51566257f37dSmrg
51576257f37dSmrg# func_cygming_ms_implib_p ARG
51586257f37dSmrg# This predicate returns with zero status (TRUE) if
51596257f37dSmrg# ARG is an MS-style import library. Returns
51606257f37dSmrg# with nonzero status (FALSE) otherwise.
51616257f37dSmrgfunc_cygming_ms_implib_p ()
51626257f37dSmrg{
51636257f37dSmrg  $debug_cmd
51646257f37dSmrg
51656257f37dSmrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
51666257f37dSmrg  func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
51676257f37dSmrg  test -n "$func_cygming_ms_implib_tmp"
51686257f37dSmrg}
51696257f37dSmrg
5170f3561b8bSmrg# func_win32_libid arg
5171f3561b8bSmrg# return the library type of file 'arg'
5172f3561b8bSmrg#
5173f3561b8bSmrg# Need a lot of goo to handle *both* DLLs and import libs
5174f3561b8bSmrg# Has to be a shell function in order to 'eat' the argument
5175f3561b8bSmrg# that is supplied when $file_magic_command is called.
5176bd304fc0Smrg# Despite the name, also deal with 64 bit binaries.
5177f3561b8bSmrgfunc_win32_libid ()
5178f3561b8bSmrg{
51796257f37dSmrg  $debug_cmd
51806257f37dSmrg
51816257f37dSmrg  win32_libid_type=unknown
5182f3561b8bSmrg  win32_fileres=`file -L $1 2>/dev/null`
5183f3561b8bSmrg  case $win32_fileres in
5184f3561b8bSmrg  *ar\ archive\ import\ library*) # definitely import
5185f3561b8bSmrg    win32_libid_type="x86 archive import"
5186f3561b8bSmrg    ;;
5187f3561b8bSmrg  *ar\ archive*) # could be an import, or static
5188bd304fc0Smrg    # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
5189f3561b8bSmrg    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
5190bd304fc0Smrg       $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
51916257f37dSmrg      case $nm_interface in
51926257f37dSmrg      "MS dumpbin")
51936257f37dSmrg	if func_cygming_ms_implib_p "$1" ||
51946257f37dSmrg	   func_cygming_gnu_implib_p "$1"
51956257f37dSmrg	then
51966257f37dSmrg	  win32_nmres=import
51976257f37dSmrg	else
51986257f37dSmrg	  win32_nmres=
51996257f37dSmrg	fi
52006257f37dSmrg	;;
52016257f37dSmrg      *)
52026257f37dSmrg	func_to_tool_file "$1" func_convert_file_msys_to_w32
52036257f37dSmrg	win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
52046257f37dSmrg	  $SED -n -e '
5205f3561b8bSmrg	    1,100{
5206f3561b8bSmrg		/ I /{
52076257f37dSmrg		    s|.*|import|
5208f3561b8bSmrg		    p
5209f3561b8bSmrg		    q
5210f3561b8bSmrg		}
5211f3561b8bSmrg	    }'`
52126257f37dSmrg	;;
52136257f37dSmrg      esac
5214f3561b8bSmrg      case $win32_nmres in
5215f3561b8bSmrg      import*)  win32_libid_type="x86 archive import";;
5216f3561b8bSmrg      *)        win32_libid_type="x86 archive static";;
5217f3561b8bSmrg      esac
5218f3561b8bSmrg    fi
5219f3561b8bSmrg    ;;
5220f3561b8bSmrg  *DLL*)
5221f3561b8bSmrg    win32_libid_type="x86 DLL"
5222f3561b8bSmrg    ;;
5223f3561b8bSmrg  *executable*) # but shell scripts are "executable" too...
5224f3561b8bSmrg    case $win32_fileres in
5225f3561b8bSmrg    *MS\ Windows\ PE\ Intel*)
5226f3561b8bSmrg      win32_libid_type="x86 DLL"
5227f3561b8bSmrg      ;;
5228f3561b8bSmrg    esac
5229f3561b8bSmrg    ;;
5230f3561b8bSmrg  esac
5231f3561b8bSmrg  $ECHO "$win32_libid_type"
5232f3561b8bSmrg}
5233fc5a983dSmrg
5234bd304fc0Smrg# func_cygming_dll_for_implib ARG
5235bd304fc0Smrg#
5236bd304fc0Smrg# Platform-specific function to extract the
5237bd304fc0Smrg# name of the DLL associated with the specified
5238bd304fc0Smrg# import library ARG.
5239bd304fc0Smrg# Invoked by eval'ing the libtool variable
5240bd304fc0Smrg#    $sharedlib_from_linklib_cmd
5241bd304fc0Smrg# Result is available in the variable
5242bd304fc0Smrg#    $sharedlib_from_linklib_result
5243bd304fc0Smrgfunc_cygming_dll_for_implib ()
5244bd304fc0Smrg{
52456257f37dSmrg  $debug_cmd
52466257f37dSmrg
5247bd304fc0Smrg  sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
5248bd304fc0Smrg}
5249bd304fc0Smrg
5250bd304fc0Smrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
5251bd304fc0Smrg#
5252bd304fc0Smrg# The is the core of a fallback implementation of a
5253bd304fc0Smrg# platform-specific function to extract the name of the
5254bd304fc0Smrg# DLL associated with the specified import library LIBNAME.
5255bd304fc0Smrg#
5256bd304fc0Smrg# SECTION_NAME is either .idata$6 or .idata$7, depending
5257bd304fc0Smrg# on the platform and compiler that created the implib.
5258bd304fc0Smrg#
5259bd304fc0Smrg# Echos the name of the DLL associated with the
5260bd304fc0Smrg# specified import library.
5261bd304fc0Smrgfunc_cygming_dll_for_implib_fallback_core ()
5262bd304fc0Smrg{
52636257f37dSmrg  $debug_cmd
52646257f37dSmrg
5265bd304fc0Smrg  match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
5266bd304fc0Smrg  $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
5267bd304fc0Smrg    $SED '/^Contents of section '"$match_literal"':/{
5268bd304fc0Smrg      # Place marker at beginning of archive member dllname section
5269bd304fc0Smrg      s/.*/====MARK====/
5270bd304fc0Smrg      p
5271bd304fc0Smrg      d
5272bd304fc0Smrg    }
5273bd304fc0Smrg    # These lines can sometimes be longer than 43 characters, but
5274bd304fc0Smrg    # are always uninteresting
5275bd304fc0Smrg    /:[	 ]*file format pe[i]\{,1\}-/d
5276bd304fc0Smrg    /^In archive [^:]*:/d
5277bd304fc0Smrg    # Ensure marker is printed
5278bd304fc0Smrg    /^====MARK====/p
5279bd304fc0Smrg    # Remove all lines with less than 43 characters
5280bd304fc0Smrg    /^.\{43\}/!d
5281bd304fc0Smrg    # From remaining lines, remove first 43 characters
5282bd304fc0Smrg    s/^.\{43\}//' |
5283bd304fc0Smrg    $SED -n '
5284bd304fc0Smrg      # Join marker and all lines until next marker into a single line
5285bd304fc0Smrg      /^====MARK====/ b para
5286bd304fc0Smrg      H
5287bd304fc0Smrg      $ b para
5288bd304fc0Smrg      b
5289bd304fc0Smrg      :para
5290bd304fc0Smrg      x
5291bd304fc0Smrg      s/\n//g
5292bd304fc0Smrg      # Remove the marker
5293bd304fc0Smrg      s/^====MARK====//
5294bd304fc0Smrg      # Remove trailing dots and whitespace
5295bd304fc0Smrg      s/[\. \t]*$//
5296bd304fc0Smrg      # Print
5297bd304fc0Smrg      /./p' |
5298bd304fc0Smrg    # we now have a list, one entry per line, of the stringified
5299bd304fc0Smrg    # contents of the appropriate section of all members of the
53006257f37dSmrg    # archive that possess that section. Heuristic: eliminate
53016257f37dSmrg    # all those that have a first or second character that is
5302bd304fc0Smrg    # a '.' (that is, objdump's representation of an unprintable
5303bd304fc0Smrg    # character.) This should work for all archives with less than
5304bd304fc0Smrg    # 0x302f exports -- but will fail for DLLs whose name actually
5305bd304fc0Smrg    # begins with a literal '.' or a single character followed by
5306bd304fc0Smrg    # a '.'.
5307bd304fc0Smrg    #
5308bd304fc0Smrg    # Of those that remain, print the first one.
5309bd304fc0Smrg    $SED -e '/^\./d;/^.\./d;q'
5310bd304fc0Smrg}
5311bd304fc0Smrg
5312bd304fc0Smrg# func_cygming_dll_for_implib_fallback ARG
5313bd304fc0Smrg# Platform-specific function to extract the
5314bd304fc0Smrg# name of the DLL associated with the specified
5315bd304fc0Smrg# import library ARG.
5316bd304fc0Smrg#
5317bd304fc0Smrg# This fallback implementation is for use when $DLLTOOL
5318bd304fc0Smrg# does not support the --identify-strict option.
5319bd304fc0Smrg# Invoked by eval'ing the libtool variable
5320bd304fc0Smrg#    $sharedlib_from_linklib_cmd
5321bd304fc0Smrg# Result is available in the variable
5322bd304fc0Smrg#    $sharedlib_from_linklib_result
5323bd304fc0Smrgfunc_cygming_dll_for_implib_fallback ()
5324bd304fc0Smrg{
53256257f37dSmrg  $debug_cmd
53266257f37dSmrg
53276257f37dSmrg  if func_cygming_gnu_implib_p "$1"; then
5328bd304fc0Smrg    # binutils import library
5329bd304fc0Smrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
53306257f37dSmrg  elif func_cygming_ms_implib_p "$1"; then
5331bd304fc0Smrg    # ms-generated import library
5332bd304fc0Smrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
5333bd304fc0Smrg  else
5334bd304fc0Smrg    # unknown
53356257f37dSmrg    sharedlib_from_linklib_result=
5336bd304fc0Smrg  fi
5337bd304fc0Smrg}
5338fc5a983dSmrg
5339fc5a983dSmrg
5340f3561b8bSmrg# func_extract_an_archive dir oldlib
5341f3561b8bSmrgfunc_extract_an_archive ()
5342f3561b8bSmrg{
53436257f37dSmrg    $debug_cmd
53446257f37dSmrg
53456257f37dSmrg    f_ex_an_ar_dir=$1; shift
53466257f37dSmrg    f_ex_an_ar_oldlib=$1
53476257f37dSmrg    if test yes = "$lock_old_archive_extraction"; then
5348bd304fc0Smrg      lockfile=$f_ex_an_ar_oldlib.lock
5349bd304fc0Smrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
5350bd304fc0Smrg	func_echo "Waiting for $lockfile to be removed"
5351bd304fc0Smrg	sleep 2
5352bd304fc0Smrg      done
5353bd304fc0Smrg    fi
5354bd304fc0Smrg    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
5355bd304fc0Smrg		   'stat=$?; rm -f "$lockfile"; exit $stat'
53566257f37dSmrg    if test yes = "$lock_old_archive_extraction"; then
5357bd304fc0Smrg      $opt_dry_run || rm -f "$lockfile"
5358bd304fc0Smrg    fi
5359f3561b8bSmrg    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
5360f3561b8bSmrg     :
5361f3561b8bSmrg    else
5362f3561b8bSmrg      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
5363f3561b8bSmrg    fi
5364f3561b8bSmrg}
5365fc5a983dSmrg
5366fc5a983dSmrg
5367f3561b8bSmrg# func_extract_archives gentop oldlib ...
5368f3561b8bSmrgfunc_extract_archives ()
5369f3561b8bSmrg{
53706257f37dSmrg    $debug_cmd
53716257f37dSmrg
53726257f37dSmrg    my_gentop=$1; shift
5373f3561b8bSmrg    my_oldlibs=${1+"$@"}
53746257f37dSmrg    my_oldobjs=
53756257f37dSmrg    my_xlib=
53766257f37dSmrg    my_xabs=
53776257f37dSmrg    my_xdir=
5378fc5a983dSmrg
5379f3561b8bSmrg    for my_xlib in $my_oldlibs; do
5380f3561b8bSmrg      # Extract the objects.
5381f3561b8bSmrg      case $my_xlib in
53826257f37dSmrg	[\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;;
5383f3561b8bSmrg	*) my_xabs=`pwd`"/$my_xlib" ;;
5384f3561b8bSmrg      esac
5385f3561b8bSmrg      func_basename "$my_xlib"
53866257f37dSmrg      my_xlib=$func_basename_result
5387f3561b8bSmrg      my_xlib_u=$my_xlib
5388f3561b8bSmrg      while :; do
5389f3561b8bSmrg        case " $extracted_archives " in
5390f3561b8bSmrg	*" $my_xlib_u "*)
5391f3561b8bSmrg	  func_arith $extracted_serial + 1
5392f3561b8bSmrg	  extracted_serial=$func_arith_result
5393f3561b8bSmrg	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
5394f3561b8bSmrg	*) break ;;
5395f3561b8bSmrg	esac
5396f3561b8bSmrg      done
5397f3561b8bSmrg      extracted_archives="$extracted_archives $my_xlib_u"
53986257f37dSmrg      my_xdir=$my_gentop/$my_xlib_u
5399fc5a983dSmrg
5400f3561b8bSmrg      func_mkdir_p "$my_xdir"
5401fc5a983dSmrg
5402f3561b8bSmrg      case $host in
5403f3561b8bSmrg      *-darwin*)
5404f3561b8bSmrg	func_verbose "Extracting $my_xabs"
5405f3561b8bSmrg	# Do not bother doing anything if just a dry run
5406f3561b8bSmrg	$opt_dry_run || {
5407f3561b8bSmrg	  darwin_orig_dir=`pwd`
5408f3561b8bSmrg	  cd $my_xdir || exit $?
5409f3561b8bSmrg	  darwin_archive=$my_xabs
5410f3561b8bSmrg	  darwin_curdir=`pwd`
54116257f37dSmrg	  func_basename "$darwin_archive"
54126257f37dSmrg	  darwin_base_archive=$func_basename_result
5413f3561b8bSmrg	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
5414f3561b8bSmrg	  if test -n "$darwin_arches"; then
5415f3561b8bSmrg	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
5416f3561b8bSmrg	    darwin_arch=
5417f3561b8bSmrg	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
54186257f37dSmrg	    for darwin_arch in  $darwin_arches; do
54196257f37dSmrg	      func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch"
54206257f37dSmrg	      $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive"
54216257f37dSmrg	      cd "unfat-$$/$darwin_base_archive-$darwin_arch"
54226257f37dSmrg	      func_extract_an_archive "`pwd`" "$darwin_base_archive"
5423f3561b8bSmrg	      cd "$darwin_curdir"
54246257f37dSmrg	      $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive"
5425f3561b8bSmrg	    done # $darwin_arches
5426f3561b8bSmrg            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
54276257f37dSmrg	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u`
5428f3561b8bSmrg	    darwin_file=
5429f3561b8bSmrg	    darwin_files=
5430f3561b8bSmrg	    for darwin_file in $darwin_filelist; do
5431bd304fc0Smrg	      darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
5432f3561b8bSmrg	      $LIPO -create -output "$darwin_file" $darwin_files
5433f3561b8bSmrg	    done # $darwin_filelist
5434f3561b8bSmrg	    $RM -rf unfat-$$
5435f3561b8bSmrg	    cd "$darwin_orig_dir"
5436fc5a983dSmrg	  else
5437f3561b8bSmrg	    cd $darwin_orig_dir
5438f3561b8bSmrg	    func_extract_an_archive "$my_xdir" "$my_xabs"
5439f3561b8bSmrg	  fi # $darwin_arches
5440f3561b8bSmrg	} # !$opt_dry_run
5441f3561b8bSmrg	;;
5442f3561b8bSmrg      *)
5443f3561b8bSmrg        func_extract_an_archive "$my_xdir" "$my_xabs"
5444f3561b8bSmrg	;;
5445f3561b8bSmrg      esac
5446bd304fc0Smrg      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
5447f3561b8bSmrg    done
5448fc5a983dSmrg
54496257f37dSmrg    func_extract_archives_result=$my_oldobjs
5450f3561b8bSmrg}
5451fc5a983dSmrg
5452fc5a983dSmrg
5453bd304fc0Smrg# func_emit_wrapper [arg=no]
5454bd304fc0Smrg#
5455bd304fc0Smrg# Emit a libtool wrapper script on stdout.
5456bd304fc0Smrg# Don't directly open a file because we may want to
5457bd304fc0Smrg# incorporate the script contents within a cygwin/mingw
5458bd304fc0Smrg# wrapper executable.  Must ONLY be called from within
5459bd304fc0Smrg# func_mode_link because it depends on a number of variables
5460bd304fc0Smrg# set therein.
5461f3561b8bSmrg#
5462bd304fc0Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
5463bd304fc0Smrg# variable will take.  If 'yes', then the emitted script
54646257f37dSmrg# will assume that the directory where it is stored is
5465bd304fc0Smrg# the $objdir directory.  This is a cygwin/mingw-specific
5466bd304fc0Smrg# behavior.
5467bd304fc0Smrgfunc_emit_wrapper ()
5468f3561b8bSmrg{
5469bd304fc0Smrg	func_emit_wrapper_arg1=${1-no}
5470fc5a983dSmrg
5471f3561b8bSmrg	$ECHO "\
5472f3561b8bSmrg#! $SHELL
5473fc5a983dSmrg
5474f3561b8bSmrg# $output - temporary wrapper script for $objdir/$outputname
54756257f37dSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
5476f3561b8bSmrg#
5477f3561b8bSmrg# The $output program cannot be directly executed until all the libtool
5478f3561b8bSmrg# libraries that it depends on are installed.
5479f3561b8bSmrg#
5480f3561b8bSmrg# This wrapper script should never be moved out of the build directory.
5481f3561b8bSmrg# If it is, it will not operate correctly.
5482fc5a983dSmrg
5483f3561b8bSmrg# Sed substitution that helps us do robust quoting.  It backslashifies
5484f3561b8bSmrg# metacharacters that are still active within double-quoted strings.
5485f3561b8bSmrgsed_quote_subst='$sed_quote_subst'
5486fc5a983dSmrg
5487f3561b8bSmrg# Be Bourne compatible
5488f3561b8bSmrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
5489f3561b8bSmrg  emulate sh
5490f3561b8bSmrg  NULLCMD=:
5491f3561b8bSmrg  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
5492f3561b8bSmrg  # is contrary to our usage.  Disable this feature.
5493f3561b8bSmrg  alias -g '\${1+\"\$@\"}'='\"\$@\"'
5494f3561b8bSmrg  setopt NO_GLOB_SUBST
5495f3561b8bSmrgelse
5496f3561b8bSmrg  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
5497f3561b8bSmrgfi
5498f3561b8bSmrgBIN_SH=xpg4; export BIN_SH # for Tru64
5499f3561b8bSmrgDUALCASE=1; export DUALCASE # for MKS sh
5500fc5a983dSmrg
5501f3561b8bSmrg# The HP-UX ksh and POSIX shell print the target directory to stdout
5502f3561b8bSmrg# if CDPATH is set.
5503f3561b8bSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
5504fc5a983dSmrg
5505f3561b8bSmrgrelink_command=\"$relink_command\"
5506fc5a983dSmrg
5507f3561b8bSmrg# This environment variable determines our operation mode.
5508f3561b8bSmrgif test \"\$libtool_install_magic\" = \"$magic\"; then
5509f3561b8bSmrg  # install mode needs the following variables:
5510f3561b8bSmrg  generated_by_libtool_version='$macro_version'
5511f3561b8bSmrg  notinst_deplibs='$notinst_deplibs'
5512f3561b8bSmrgelse
5513f3561b8bSmrg  # When we are sourced in execute mode, \$file and \$ECHO are already set.
5514f3561b8bSmrg  if test \"\$libtool_execute_magic\" != \"$magic\"; then
5515bd304fc0Smrg    file=\"\$0\""
5516bd304fc0Smrg
5517d422ce2eSmrg    func_quote_arg pretty "$ECHO"
5518d422ce2eSmrg    qECHO=$func_quote_arg_result
5519bd304fc0Smrg    $ECHO "\
5520bd304fc0Smrg
5521bd304fc0Smrg# A function that is used when there is no print builtin or printf.
5522bd304fc0Smrgfunc_fallback_echo ()
5523bd304fc0Smrg{
5524bd304fc0Smrg  eval 'cat <<_LTECHO_EOF
5525bd304fc0Smrg\$1
5526bd304fc0Smrg_LTECHO_EOF'
5527bd304fc0Smrg}
5528d422ce2eSmrg    ECHO=$qECHO
5529bd304fc0Smrg  fi
5530bd304fc0Smrg
5531bd304fc0Smrg# Very basic option parsing. These options are (a) specific to
5532bd304fc0Smrg# the libtool wrapper, (b) are identical between the wrapper
55336257f37dSmrg# /script/ and the wrapper /executable/ that is used only on
5534bd304fc0Smrg# windows platforms, and (c) all begin with the string "--lt-"
55356257f37dSmrg# (application programs are unlikely to have options that match
5536bd304fc0Smrg# this pattern).
5537bd304fc0Smrg#
5538bd304fc0Smrg# There are only two supported options: --lt-debug and
5539bd304fc0Smrg# --lt-dump-script. There is, deliberately, no --lt-help.
5540bd304fc0Smrg#
5541bd304fc0Smrg# The first argument to this parsing function should be the
5542bd304fc0Smrg# script's $0 value, followed by "$@".
5543bd304fc0Smrglt_option_debug=
5544bd304fc0Smrgfunc_parse_lt_options ()
5545bd304fc0Smrg{
5546bd304fc0Smrg  lt_script_arg0=\$0
5547bd304fc0Smrg  shift
5548bd304fc0Smrg  for lt_opt
5549bd304fc0Smrg  do
5550bd304fc0Smrg    case \"\$lt_opt\" in
5551bd304fc0Smrg    --lt-debug) lt_option_debug=1 ;;
5552bd304fc0Smrg    --lt-dump-script)
5553bd304fc0Smrg        lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
5554bd304fc0Smrg        test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
5555bd304fc0Smrg        lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
5556bd304fc0Smrg        cat \"\$lt_dump_D/\$lt_dump_F\"
5557bd304fc0Smrg        exit 0
5558bd304fc0Smrg      ;;
5559bd304fc0Smrg    --lt-*)
5560bd304fc0Smrg        \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
5561bd304fc0Smrg        exit 1
5562bd304fc0Smrg      ;;
5563bd304fc0Smrg    esac
5564bd304fc0Smrg  done
5565bd304fc0Smrg
5566bd304fc0Smrg  # Print the debug banner immediately:
5567bd304fc0Smrg  if test -n \"\$lt_option_debug\"; then
55686257f37dSmrg    echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2
5569bd304fc0Smrg  fi
5570bd304fc0Smrg}
5571bd304fc0Smrg
5572bd304fc0Smrg# Used when --lt-debug. Prints its arguments to stdout
5573bd304fc0Smrg# (redirection is the responsibility of the caller)
5574bd304fc0Smrgfunc_lt_dump_args ()
5575bd304fc0Smrg{
5576bd304fc0Smrg  lt_dump_args_N=1;
5577bd304fc0Smrg  for lt_arg
5578bd304fc0Smrg  do
55796257f37dSmrg    \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\"
5580bd304fc0Smrg    lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
5581bd304fc0Smrg  done
5582bd304fc0Smrg}
5583bd304fc0Smrg
5584bd304fc0Smrg# Core function for launching the target application
5585bd304fc0Smrgfunc_exec_program_core ()
5586bd304fc0Smrg{
5587f3561b8bSmrg"
5588bd304fc0Smrg  case $host in
5589bd304fc0Smrg  # Backslashes separate directories on plain windows
5590bd304fc0Smrg  *-*-mingw | *-*-os2* | *-cegcc*)
5591bd304fc0Smrg    $ECHO "\
5592bd304fc0Smrg      if test -n \"\$lt_option_debug\"; then
55936257f37dSmrg        \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2
5594bd304fc0Smrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
5595bd304fc0Smrg      fi
5596bd304fc0Smrg      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
5597bd304fc0Smrg"
5598bd304fc0Smrg    ;;
5599bd304fc0Smrg
5600bd304fc0Smrg  *)
5601bd304fc0Smrg    $ECHO "\
5602bd304fc0Smrg      if test -n \"\$lt_option_debug\"; then
56036257f37dSmrg        \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2
5604bd304fc0Smrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
5605bd304fc0Smrg      fi
5606bd304fc0Smrg      exec \"\$progdir/\$program\" \${1+\"\$@\"}
5607bd304fc0Smrg"
5608bd304fc0Smrg    ;;
5609bd304fc0Smrg  esac
5610bd304fc0Smrg  $ECHO "\
5611bd304fc0Smrg      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
5612bd304fc0Smrg      exit 1
5613bd304fc0Smrg}
5614bd304fc0Smrg
5615bd304fc0Smrg# A function to encapsulate launching the target application
5616bd304fc0Smrg# Strips options in the --lt-* namespace from \$@ and
5617bd304fc0Smrg# launches target application with the remaining arguments.
5618bd304fc0Smrgfunc_exec_program ()
5619bd304fc0Smrg{
5620bd304fc0Smrg  case \" \$* \" in
5621bd304fc0Smrg  *\\ --lt-*)
5622bd304fc0Smrg    for lt_wr_arg
5623bd304fc0Smrg    do
5624bd304fc0Smrg      case \$lt_wr_arg in
5625bd304fc0Smrg      --lt-*) ;;
5626bd304fc0Smrg      *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
5627bd304fc0Smrg      esac
5628bd304fc0Smrg      shift
5629bd304fc0Smrg    done ;;
5630bd304fc0Smrg  esac
5631bd304fc0Smrg  func_exec_program_core \${1+\"\$@\"}
5632bd304fc0Smrg}
5633bd304fc0Smrg
5634bd304fc0Smrg  # Parse options
5635bd304fc0Smrg  func_parse_lt_options \"\$0\" \${1+\"\$@\"}
5636fc5a983dSmrg
5637f3561b8bSmrg  # Find the directory that this script lives in.
5638bd304fc0Smrg  thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
5639f3561b8bSmrg  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
5640fc5a983dSmrg
5641f3561b8bSmrg  # Follow symbolic links until we get to the real thisdir.
5642bd304fc0Smrg  file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
5643f3561b8bSmrg  while test -n \"\$file\"; do
5644bd304fc0Smrg    destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
5645fc5a983dSmrg
5646f3561b8bSmrg    # If there was a directory component, then change thisdir.
5647f3561b8bSmrg    if test \"x\$destdir\" != \"x\$file\"; then
5648f3561b8bSmrg      case \"\$destdir\" in
5649f3561b8bSmrg      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
5650f3561b8bSmrg      *) thisdir=\"\$thisdir/\$destdir\" ;;
5651fc5a983dSmrg      esac
5652f3561b8bSmrg    fi
5653fc5a983dSmrg
5654bd304fc0Smrg    file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
5655bd304fc0Smrg    file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
5656f3561b8bSmrg  done
5657fc5a983dSmrg
5658f3561b8bSmrg  # Usually 'no', except on cygwin/mingw when embedded into
5659f3561b8bSmrg  # the cwrapper.
5660bd304fc0Smrg  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
5661f3561b8bSmrg  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
5662f3561b8bSmrg    # special case for '.'
5663f3561b8bSmrg    if test \"\$thisdir\" = \".\"; then
5664f3561b8bSmrg      thisdir=\`pwd\`
5665f3561b8bSmrg    fi
5666f3561b8bSmrg    # remove .libs from thisdir
5667f3561b8bSmrg    case \"\$thisdir\" in
5668bd304fc0Smrg    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
5669f3561b8bSmrg    $objdir )   thisdir=. ;;
5670f3561b8bSmrg    esac
5671f3561b8bSmrg  fi
5672f3561b8bSmrg
5673f3561b8bSmrg  # Try to get the absolute directory name.
5674f3561b8bSmrg  absdir=\`cd \"\$thisdir\" && pwd\`
5675f3561b8bSmrg  test -n \"\$absdir\" && thisdir=\"\$absdir\"
5676f3561b8bSmrg"
5677f3561b8bSmrg
56786257f37dSmrg	if test yes = "$fast_install"; then
5679f3561b8bSmrg	  $ECHO "\
5680f3561b8bSmrg  program=lt-'$outputname'$exeext
5681f3561b8bSmrg  progdir=\"\$thisdir/$objdir\"
5682f3561b8bSmrg
5683f3561b8bSmrg  if test ! -f \"\$progdir/\$program\" ||
56846257f37dSmrg     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\
5685f3561b8bSmrg       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
5686f3561b8bSmrg
5687f3561b8bSmrg    file=\"\$\$-\$program\"
5688f3561b8bSmrg
5689f3561b8bSmrg    if test ! -d \"\$progdir\"; then
5690f3561b8bSmrg      $MKDIR \"\$progdir\"
5691f3561b8bSmrg    else
5692f3561b8bSmrg      $RM \"\$progdir/\$file\"
5693f3561b8bSmrg    fi"
5694f3561b8bSmrg
5695f3561b8bSmrg	  $ECHO "\
5696f3561b8bSmrg
5697f3561b8bSmrg    # relink executable if necessary
5698f3561b8bSmrg    if test -n \"\$relink_command\"; then
5699f3561b8bSmrg      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
5700f3561b8bSmrg      else
57016257f37dSmrg	\$ECHO \"\$relink_command_output\" >&2
5702f3561b8bSmrg	$RM \"\$progdir/\$file\"
5703f3561b8bSmrg	exit 1
5704fc5a983dSmrg      fi
5705f3561b8bSmrg    fi
5706fc5a983dSmrg
5707f3561b8bSmrg    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
5708f3561b8bSmrg    { $RM \"\$progdir/\$program\";
5709f3561b8bSmrg      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
5710f3561b8bSmrg    $RM \"\$progdir/\$file\"
5711f3561b8bSmrg  fi"
5712f3561b8bSmrg	else
5713f3561b8bSmrg	  $ECHO "\
5714f3561b8bSmrg  program='$outputname'
5715f3561b8bSmrg  progdir=\"\$thisdir/$objdir\"
5716f3561b8bSmrg"
5717fc5a983dSmrg	fi
5718fc5a983dSmrg
5719f3561b8bSmrg	$ECHO "\
5720fc5a983dSmrg
5721f3561b8bSmrg  if test -f \"\$progdir/\$program\"; then"
5722fc5a983dSmrg
5723bd304fc0Smrg	# fixup the dll searchpath if we need to.
5724bd304fc0Smrg	#
5725bd304fc0Smrg	# Fix the DLL searchpath if we need to.  Do this before prepending
5726bd304fc0Smrg	# to shlibpath, because on Windows, both are PATH and uninstalled
5727bd304fc0Smrg	# libraries must come first.
5728bd304fc0Smrg	if test -n "$dllsearchpath"; then
5729bd304fc0Smrg	  $ECHO "\
5730bd304fc0Smrg    # Add the dll search path components to the executable PATH
5731bd304fc0Smrg    PATH=$dllsearchpath:\$PATH
5732bd304fc0Smrg"
5733bd304fc0Smrg	fi
5734bd304fc0Smrg
5735f3561b8bSmrg	# Export our shlibpath_var if we have one.
57366257f37dSmrg	if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
5737f3561b8bSmrg	  $ECHO "\
5738f3561b8bSmrg    # Add our own library path to $shlibpath_var
5739f3561b8bSmrg    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
5740f3561b8bSmrg
5741f3561b8bSmrg    # Some systems cannot cope with colon-terminated $shlibpath_var
5742f3561b8bSmrg    # The second colon is a workaround for a bug in BeOS R4 sed
5743bd304fc0Smrg    $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
5744fc5a983dSmrg
5745f3561b8bSmrg    export $shlibpath_var
5746f3561b8bSmrg"
5747fc5a983dSmrg	fi
5748fc5a983dSmrg
5749f3561b8bSmrg	$ECHO "\
5750f3561b8bSmrg    if test \"\$libtool_execute_magic\" != \"$magic\"; then
5751f3561b8bSmrg      # Run the actual program with our arguments.
5752bd304fc0Smrg      func_exec_program \${1+\"\$@\"}
5753f3561b8bSmrg    fi
5754f3561b8bSmrg  else
5755f3561b8bSmrg    # The program doesn't exist.
57566257f37dSmrg    \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2
5757f3561b8bSmrg    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
5758bd304fc0Smrg    \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
5759f3561b8bSmrg    exit 1
5760f3561b8bSmrg  fi
5761f3561b8bSmrgfi\
5762f3561b8bSmrg"
5763f3561b8bSmrg}
5764fc5a983dSmrg
5765fc5a983dSmrg
5766f3561b8bSmrg# func_emit_cwrapperexe_src
5767f3561b8bSmrg# emit the source code for a wrapper executable on stdout
5768f3561b8bSmrg# Must ONLY be called from within func_mode_link because
5769f3561b8bSmrg# it depends on a number of variable set therein.
5770f3561b8bSmrgfunc_emit_cwrapperexe_src ()
5771f3561b8bSmrg{
5772f3561b8bSmrg	cat <<EOF
5773fc5a983dSmrg
5774f3561b8bSmrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
57756257f37dSmrg   Generated by $PROGRAM (GNU $PACKAGE) $VERSION
5776fc5a983dSmrg
5777f3561b8bSmrg   The $output program cannot be directly executed until all the libtool
5778f3561b8bSmrg   libraries that it depends on are installed.
5779fc5a983dSmrg
5780f3561b8bSmrg   This wrapper executable should never be moved out of the build directory.
5781f3561b8bSmrg   If it is, it will not operate correctly.
5782f3561b8bSmrg*/
5783f3561b8bSmrgEOF
5784f3561b8bSmrg	    cat <<"EOF"
5785bd304fc0Smrg#ifdef _MSC_VER
5786bd304fc0Smrg# define _CRT_SECURE_NO_DEPRECATE 1
5787bd304fc0Smrg#endif
5788f3561b8bSmrg#include <stdio.h>
5789f3561b8bSmrg#include <stdlib.h>
5790f3561b8bSmrg#ifdef _MSC_VER
5791f3561b8bSmrg# include <direct.h>
5792f3561b8bSmrg# include <process.h>
5793f3561b8bSmrg# include <io.h>
5794f3561b8bSmrg#else
5795f3561b8bSmrg# include <unistd.h>
5796f3561b8bSmrg# include <stdint.h>
5797f3561b8bSmrg# ifdef __CYGWIN__
5798f3561b8bSmrg#  include <io.h>
5799f3561b8bSmrg# endif
5800f3561b8bSmrg#endif
5801f3561b8bSmrg#include <malloc.h>
5802f3561b8bSmrg#include <stdarg.h>
5803f3561b8bSmrg#include <assert.h>
5804f3561b8bSmrg#include <string.h>
5805f3561b8bSmrg#include <ctype.h>
5806f3561b8bSmrg#include <errno.h>
5807f3561b8bSmrg#include <fcntl.h>
5808f3561b8bSmrg#include <sys/stat.h>
5809fc5a983dSmrg
58106257f37dSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
58116257f37dSmrg
5812bd304fc0Smrg/* declarations of non-ANSI functions */
58136257f37dSmrg#if defined __MINGW32__
5814bd304fc0Smrg# ifdef __STRICT_ANSI__
5815bd304fc0Smrgint _putenv (const char *);
5816bd304fc0Smrg# endif
58176257f37dSmrg#elif defined __CYGWIN__
5818bd304fc0Smrg# ifdef __STRICT_ANSI__
5819bd304fc0Smrgchar *realpath (const char *, char *);
5820bd304fc0Smrgint putenv (char *);
5821bd304fc0Smrgint setenv (const char *, const char *, int);
5822bd304fc0Smrg# endif
58236257f37dSmrg/* #elif defined other_platform || defined ... */
5824bd304fc0Smrg#endif
5825bd304fc0Smrg
5826bd304fc0Smrg/* portability defines, excluding path handling macros */
58276257f37dSmrg#if defined _MSC_VER
5828bd304fc0Smrg# define setmode _setmode
5829bd304fc0Smrg# define stat    _stat
5830bd304fc0Smrg# define chmod   _chmod
5831bd304fc0Smrg# define getcwd  _getcwd
5832bd304fc0Smrg# define putenv  _putenv
5833bd304fc0Smrg# define S_IXUSR _S_IEXEC
58346257f37dSmrg#elif defined __MINGW32__
5835bd304fc0Smrg# define setmode _setmode
5836bd304fc0Smrg# define stat    _stat
5837bd304fc0Smrg# define chmod   _chmod
5838bd304fc0Smrg# define getcwd  _getcwd
5839bd304fc0Smrg# define putenv  _putenv
58406257f37dSmrg#elif defined __CYGWIN__
5841bd304fc0Smrg# define HAVE_SETENV
5842bd304fc0Smrg# define FOPEN_WB "wb"
58436257f37dSmrg/* #elif defined other platforms ... */
5844bd304fc0Smrg#endif
5845bd304fc0Smrg
58466257f37dSmrg#if defined PATH_MAX
5847f3561b8bSmrg# define LT_PATHMAX PATH_MAX
58486257f37dSmrg#elif defined MAXPATHLEN
5849f3561b8bSmrg# define LT_PATHMAX MAXPATHLEN
5850f3561b8bSmrg#else
5851f3561b8bSmrg# define LT_PATHMAX 1024
5852f3561b8bSmrg#endif
5853fc5a983dSmrg
5854f3561b8bSmrg#ifndef S_IXOTH
5855f3561b8bSmrg# define S_IXOTH 0
5856f3561b8bSmrg#endif
5857f3561b8bSmrg#ifndef S_IXGRP
5858f3561b8bSmrg# define S_IXGRP 0
5859f3561b8bSmrg#endif
5860fc5a983dSmrg
5861bd304fc0Smrg/* path handling portability macros */
5862f3561b8bSmrg#ifndef DIR_SEPARATOR
5863f3561b8bSmrg# define DIR_SEPARATOR '/'
5864f3561b8bSmrg# define PATH_SEPARATOR ':'
5865f3561b8bSmrg#endif
5866fc5a983dSmrg
58676257f37dSmrg#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \
58686257f37dSmrg  defined __OS2__
5869f3561b8bSmrg# define HAVE_DOS_BASED_FILE_SYSTEM
5870f3561b8bSmrg# define FOPEN_WB "wb"
5871f3561b8bSmrg# ifndef DIR_SEPARATOR_2
5872f3561b8bSmrg#  define DIR_SEPARATOR_2 '\\'
5873f3561b8bSmrg# endif
5874f3561b8bSmrg# ifndef PATH_SEPARATOR_2
5875f3561b8bSmrg#  define PATH_SEPARATOR_2 ';'
5876f3561b8bSmrg# endif
5877f3561b8bSmrg#endif
5878fc5a983dSmrg
5879f3561b8bSmrg#ifndef DIR_SEPARATOR_2
5880f3561b8bSmrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
5881f3561b8bSmrg#else /* DIR_SEPARATOR_2 */
5882f3561b8bSmrg# define IS_DIR_SEPARATOR(ch) \
5883f3561b8bSmrg	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
5884f3561b8bSmrg#endif /* DIR_SEPARATOR_2 */
5885fc5a983dSmrg
5886f3561b8bSmrg#ifndef PATH_SEPARATOR_2
5887f3561b8bSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
5888f3561b8bSmrg#else /* PATH_SEPARATOR_2 */
5889f3561b8bSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
5890f3561b8bSmrg#endif /* PATH_SEPARATOR_2 */
5891fc5a983dSmrg
5892f3561b8bSmrg#ifndef FOPEN_WB
5893f3561b8bSmrg# define FOPEN_WB "w"
5894f3561b8bSmrg#endif
5895f3561b8bSmrg#ifndef _O_BINARY
5896f3561b8bSmrg# define _O_BINARY 0
5897f3561b8bSmrg#endif
5898fc5a983dSmrg
5899f3561b8bSmrg#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
5900f3561b8bSmrg#define XFREE(stale) do { \
59016257f37dSmrg  if (stale) { free (stale); stale = 0; } \
5902f3561b8bSmrg} while (0)
5903fc5a983dSmrg
59046257f37dSmrg#if defined LT_DEBUGWRAPPER
5905bd304fc0Smrgstatic int lt_debug = 1;
5906f3561b8bSmrg#else
5907bd304fc0Smrgstatic int lt_debug = 0;
5908f3561b8bSmrg#endif
5909fc5a983dSmrg
5910bd304fc0Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
5911fc5a983dSmrg
5912f3561b8bSmrgvoid *xmalloc (size_t num);
5913f3561b8bSmrgchar *xstrdup (const char *string);
5914f3561b8bSmrgconst char *base_name (const char *name);
5915f3561b8bSmrgchar *find_executable (const char *wrapper);
5916f3561b8bSmrgchar *chase_symlinks (const char *pathspec);
5917f3561b8bSmrgint make_executable (const char *path);
5918f3561b8bSmrgint check_executable (const char *path);
5919f3561b8bSmrgchar *strendzap (char *str, const char *pat);
5920bd304fc0Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...);
5921bd304fc0Smrgvoid lt_fatal (const char *file, int line, const char *message, ...);
5922bd304fc0Smrgstatic const char *nonnull (const char *s);
5923bd304fc0Smrgstatic const char *nonempty (const char *s);
5924f3561b8bSmrgvoid lt_setenv (const char *name, const char *value);
5925f3561b8bSmrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end);
5926f3561b8bSmrgvoid lt_update_exe_path (const char *name, const char *value);
5927f3561b8bSmrgvoid lt_update_lib_path (const char *name, const char *value);
5928bd304fc0Smrgchar **prepare_spawn (char **argv);
5929bd304fc0Smrgvoid lt_dump_script (FILE *f);
5930f3561b8bSmrgEOF
5931f3561b8bSmrg
5932f3561b8bSmrg	    cat <<EOF
59336257f37dSmrg#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5)
59346257f37dSmrg# define externally_visible volatile
59356257f37dSmrg#else
59366257f37dSmrg# define externally_visible __attribute__((externally_visible)) volatile
59376257f37dSmrg#endif
59386257f37dSmrgexternally_visible const char * MAGIC_EXE = "$magic_exe";
5939f3561b8bSmrgconst char * LIB_PATH_VARNAME = "$shlibpath_var";
5940f3561b8bSmrgEOF
5941fc5a983dSmrg
59426257f37dSmrg	    if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
5943bd304fc0Smrg              func_to_host_path "$temp_rpath"
5944f3561b8bSmrg	      cat <<EOF
5945bd304fc0Smrgconst char * LIB_PATH_VALUE   = "$func_to_host_path_result";
5946f3561b8bSmrgEOF
5947f3561b8bSmrg	    else
5948f3561b8bSmrg	      cat <<"EOF"
5949f3561b8bSmrgconst char * LIB_PATH_VALUE   = "";
5950f3561b8bSmrgEOF
5951fc5a983dSmrg	    fi
5952fc5a983dSmrg
5953f3561b8bSmrg	    if test -n "$dllsearchpath"; then
5954bd304fc0Smrg              func_to_host_path "$dllsearchpath:"
5955f3561b8bSmrg	      cat <<EOF
5956f3561b8bSmrgconst char * EXE_PATH_VARNAME = "PATH";
5957bd304fc0Smrgconst char * EXE_PATH_VALUE   = "$func_to_host_path_result";
5958fc5a983dSmrgEOF
5959fc5a983dSmrg	    else
5960f3561b8bSmrg	      cat <<"EOF"
5961f3561b8bSmrgconst char * EXE_PATH_VARNAME = "";
5962f3561b8bSmrgconst char * EXE_PATH_VALUE   = "";
5963f3561b8bSmrgEOF
5964fc5a983dSmrg	    fi
5965f3561b8bSmrg
59666257f37dSmrg	    if test yes = "$fast_install"; then
5967f3561b8bSmrg	      cat <<EOF
5968f3561b8bSmrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
5969f3561b8bSmrgEOF
5970fc5a983dSmrg	    else
5971f3561b8bSmrg	      cat <<EOF
5972f3561b8bSmrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
5973f3561b8bSmrgEOF
5974fc5a983dSmrg	    fi
5975fc5a983dSmrg
5976fc5a983dSmrg
5977f3561b8bSmrg	    cat <<"EOF"
5978fc5a983dSmrg
5979f3561b8bSmrg#define LTWRAPPER_OPTION_PREFIX         "--lt-"
5980fc5a983dSmrg
5981f3561b8bSmrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
5982f3561b8bSmrgstatic const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
5983bd304fc0Smrgstatic const char *debug_opt            = LTWRAPPER_OPTION_PREFIX "debug";
5984fc5a983dSmrg
5985f3561b8bSmrgint
5986f3561b8bSmrgmain (int argc, char *argv[])
5987f3561b8bSmrg{
5988f3561b8bSmrg  char **newargz;
5989f3561b8bSmrg  int  newargc;
5990f3561b8bSmrg  char *tmp_pathspec;
5991f3561b8bSmrg  char *actual_cwrapper_path;
5992f3561b8bSmrg  char *actual_cwrapper_name;
5993f3561b8bSmrg  char *target_name;
5994f3561b8bSmrg  char *lt_argv_zero;
59956257f37dSmrg  int rval = 127;
5996fc5a983dSmrg
5997f3561b8bSmrg  int i;
5998fc5a983dSmrg
5999f3561b8bSmrg  program_name = (char *) xstrdup (base_name (argv[0]));
60006257f37dSmrg  newargz = XMALLOC (char *, (size_t) argc + 1);
6001fc5a983dSmrg
6002bd304fc0Smrg  /* very simple arg parsing; don't want to rely on getopt
6003bd304fc0Smrg   * also, copy all non cwrapper options to newargz, except
6004bd304fc0Smrg   * argz[0], which is handled differently
6005bd304fc0Smrg   */
6006bd304fc0Smrg  newargc=0;
6007f3561b8bSmrg  for (i = 1; i < argc; i++)
6008f3561b8bSmrg    {
60096257f37dSmrg      if (STREQ (argv[i], dumpscript_opt))
6010f3561b8bSmrg	{
6011f3561b8bSmrgEOF
60126257f37dSmrg	    case $host in
6013f3561b8bSmrg	      *mingw* | *cygwin* )
6014f3561b8bSmrg		# make stdout use "unix" line endings
6015f3561b8bSmrg		echo "          setmode(1,_O_BINARY);"
6016f3561b8bSmrg		;;
6017f3561b8bSmrg	      esac
6018fc5a983dSmrg
6019f3561b8bSmrg	    cat <<"EOF"
6020bd304fc0Smrg	  lt_dump_script (stdout);
6021f3561b8bSmrg	  return 0;
6022f3561b8bSmrg	}
60236257f37dSmrg      if (STREQ (argv[i], debug_opt))
6024bd304fc0Smrg	{
6025bd304fc0Smrg          lt_debug = 1;
6026bd304fc0Smrg          continue;
6027bd304fc0Smrg	}
60286257f37dSmrg      if (STREQ (argv[i], ltwrapper_option_prefix))
6029bd304fc0Smrg        {
6030bd304fc0Smrg          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
6031bd304fc0Smrg             namespace, but it is not one of the ones we know about and
6032bd304fc0Smrg             have already dealt with, above (inluding dump-script), then
6033bd304fc0Smrg             report an error. Otherwise, targets might begin to believe
6034bd304fc0Smrg             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
6035bd304fc0Smrg             namespace. The first time any user complains about this, we'll
6036bd304fc0Smrg             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
6037bd304fc0Smrg             or a configure.ac-settable value.
6038bd304fc0Smrg           */
6039bd304fc0Smrg          lt_fatal (__FILE__, __LINE__,
6040bd304fc0Smrg		    "unrecognized %s option: '%s'",
6041bd304fc0Smrg                    ltwrapper_option_prefix, argv[i]);
6042bd304fc0Smrg        }
6043bd304fc0Smrg      /* otherwise ... */
6044bd304fc0Smrg      newargz[++newargc] = xstrdup (argv[i]);
6045f3561b8bSmrg    }
6046bd304fc0Smrg  newargz[++newargc] = NULL;
6047bd304fc0Smrg
6048bd304fc0SmrgEOF
6049bd304fc0Smrg	    cat <<EOF
6050bd304fc0Smrg  /* The GNU banner must be the first non-error debug message */
60516257f37dSmrg  lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n");
6052bd304fc0SmrgEOF
6053bd304fc0Smrg	    cat <<"EOF"
6054bd304fc0Smrg  lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
6055bd304fc0Smrg  lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
6056fc5a983dSmrg
6057f3561b8bSmrg  tmp_pathspec = find_executable (argv[0]);
6058f3561b8bSmrg  if (tmp_pathspec == NULL)
6059bd304fc0Smrg    lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
6060bd304fc0Smrg  lt_debugprintf (__FILE__, __LINE__,
6061bd304fc0Smrg                  "(main) found exe (before symlink chase) at: %s\n",
6062bd304fc0Smrg		  tmp_pathspec);
6063f3561b8bSmrg
6064f3561b8bSmrg  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
6065bd304fc0Smrg  lt_debugprintf (__FILE__, __LINE__,
6066bd304fc0Smrg                  "(main) found exe (after symlink chase) at: %s\n",
6067bd304fc0Smrg		  actual_cwrapper_path);
6068f3561b8bSmrg  XFREE (tmp_pathspec);
6069f3561b8bSmrg
6070bd304fc0Smrg  actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
6071f3561b8bSmrg  strendzap (actual_cwrapper_path, actual_cwrapper_name);
6072f3561b8bSmrg
6073f3561b8bSmrg  /* wrapper name transforms */
6074f3561b8bSmrg  strendzap (actual_cwrapper_name, ".exe");
6075f3561b8bSmrg  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
6076f3561b8bSmrg  XFREE (actual_cwrapper_name);
6077f3561b8bSmrg  actual_cwrapper_name = tmp_pathspec;
6078f3561b8bSmrg  tmp_pathspec = 0;
6079f3561b8bSmrg
6080f3561b8bSmrg  /* target_name transforms -- use actual target program name; might have lt- prefix */
6081f3561b8bSmrg  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
6082f3561b8bSmrg  strendzap (target_name, ".exe");
6083f3561b8bSmrg  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
6084f3561b8bSmrg  XFREE (target_name);
6085f3561b8bSmrg  target_name = tmp_pathspec;
6086f3561b8bSmrg  tmp_pathspec = 0;
6087f3561b8bSmrg
6088bd304fc0Smrg  lt_debugprintf (__FILE__, __LINE__,
6089bd304fc0Smrg		  "(main) libtool target name: %s\n",
6090bd304fc0Smrg		  target_name);
6091f3561b8bSmrgEOF
6092fc5a983dSmrg
6093f3561b8bSmrg	    cat <<EOF
6094f3561b8bSmrg  newargz[0] =
6095f3561b8bSmrg    XMALLOC (char, (strlen (actual_cwrapper_path) +
6096f3561b8bSmrg		    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
6097f3561b8bSmrg  strcpy (newargz[0], actual_cwrapper_path);
6098f3561b8bSmrg  strcat (newargz[0], "$objdir");
6099f3561b8bSmrg  strcat (newargz[0], "/");
6100f3561b8bSmrgEOF
6101fc5a983dSmrg
6102f3561b8bSmrg	    cat <<"EOF"
6103f3561b8bSmrg  /* stop here, and copy so we don't have to do this twice */
6104f3561b8bSmrg  tmp_pathspec = xstrdup (newargz[0]);
6105fc5a983dSmrg
6106f3561b8bSmrg  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
6107f3561b8bSmrg  strcat (newargz[0], actual_cwrapper_name);
6108fc5a983dSmrg
6109f3561b8bSmrg  /* DO want the lt- prefix here if it exists, so use target_name */
6110f3561b8bSmrg  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
6111f3561b8bSmrg  XFREE (tmp_pathspec);
6112f3561b8bSmrg  tmp_pathspec = NULL;
6113f3561b8bSmrgEOF
6114fc5a983dSmrg
6115f3561b8bSmrg	    case $host_os in
6116f3561b8bSmrg	      mingw*)
6117f3561b8bSmrg	    cat <<"EOF"
6118f3561b8bSmrg  {
6119f3561b8bSmrg    char* p;
6120f3561b8bSmrg    while ((p = strchr (newargz[0], '\\')) != NULL)
6121f3561b8bSmrg      {
6122f3561b8bSmrg	*p = '/';
6123f3561b8bSmrg      }
6124f3561b8bSmrg    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
6125f3561b8bSmrg      {
6126f3561b8bSmrg	*p = '/';
6127f3561b8bSmrg      }
6128f3561b8bSmrg  }
6129f3561b8bSmrgEOF
6130f3561b8bSmrg	    ;;
6131f3561b8bSmrg	    esac
6132fc5a983dSmrg
6133f3561b8bSmrg	    cat <<"EOF"
6134f3561b8bSmrg  XFREE (target_name);
6135f3561b8bSmrg  XFREE (actual_cwrapper_path);
6136f3561b8bSmrg  XFREE (actual_cwrapper_name);
6137fc5a983dSmrg
6138f3561b8bSmrg  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
6139f3561b8bSmrg  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
6140bd304fc0Smrg  /* Update the DLL searchpath.  EXE_PATH_VALUE ($dllsearchpath) must
6141bd304fc0Smrg     be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
6142bd304fc0Smrg     because on Windows, both *_VARNAMEs are PATH but uninstalled
6143bd304fc0Smrg     libraries must come first. */
6144f3561b8bSmrg  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
6145bd304fc0Smrg  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
6146fc5a983dSmrg
6147bd304fc0Smrg  lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
6148bd304fc0Smrg		  nonnull (lt_argv_zero));
6149f3561b8bSmrg  for (i = 0; i < newargc; i++)
6150f3561b8bSmrg    {
6151bd304fc0Smrg      lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
6152bd304fc0Smrg		      i, nonnull (newargz[i]));
6153f3561b8bSmrg    }
6154fc5a983dSmrg
6155f3561b8bSmrgEOF
6156fc5a983dSmrg
6157f3561b8bSmrg	    case $host_os in
6158f3561b8bSmrg	      mingw*)
6159f3561b8bSmrg		cat <<"EOF"
6160f3561b8bSmrg  /* execv doesn't actually work on mingw as expected on unix */
6161bd304fc0Smrg  newargz = prepare_spawn (newargz);
61626257f37dSmrg  rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
6163f3561b8bSmrg  if (rval == -1)
6164f3561b8bSmrg    {
6165f3561b8bSmrg      /* failed to start process */
6166bd304fc0Smrg      lt_debugprintf (__FILE__, __LINE__,
6167bd304fc0Smrg		      "(main) failed to launch target \"%s\": %s\n",
6168bd304fc0Smrg		      lt_argv_zero, nonnull (strerror (errno)));
6169f3561b8bSmrg      return 127;
6170f3561b8bSmrg    }
6171f3561b8bSmrg  return rval;
6172f3561b8bSmrgEOF
6173f3561b8bSmrg		;;
6174f3561b8bSmrg	      *)
6175f3561b8bSmrg		cat <<"EOF"
6176f3561b8bSmrg  execv (lt_argv_zero, newargz);
6177f3561b8bSmrg  return rval; /* =127, but avoids unused variable warning */
6178f3561b8bSmrgEOF
6179f3561b8bSmrg		;;
6180f3561b8bSmrg	    esac
6181fc5a983dSmrg
6182f3561b8bSmrg	    cat <<"EOF"
6183f3561b8bSmrg}
6184fc5a983dSmrg
6185f3561b8bSmrgvoid *
6186f3561b8bSmrgxmalloc (size_t num)
6187f3561b8bSmrg{
6188f3561b8bSmrg  void *p = (void *) malloc (num);
6189f3561b8bSmrg  if (!p)
6190bd304fc0Smrg    lt_fatal (__FILE__, __LINE__, "memory exhausted");
6191fc5a983dSmrg
6192f3561b8bSmrg  return p;
6193f3561b8bSmrg}
6194fc5a983dSmrg
6195f3561b8bSmrgchar *
6196f3561b8bSmrgxstrdup (const char *string)
6197f3561b8bSmrg{
6198f3561b8bSmrg  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
6199f3561b8bSmrg			  string) : NULL;
6200f3561b8bSmrg}
6201fc5a983dSmrg
6202f3561b8bSmrgconst char *
6203f3561b8bSmrgbase_name (const char *name)
6204f3561b8bSmrg{
6205f3561b8bSmrg  const char *base;
6206fc5a983dSmrg
62076257f37dSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM
6208f3561b8bSmrg  /* Skip over the disk name in MSDOS pathnames. */
6209f3561b8bSmrg  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
6210f3561b8bSmrg    name += 2;
6211f3561b8bSmrg#endif
6212fc5a983dSmrg
6213f3561b8bSmrg  for (base = name; *name; name++)
6214f3561b8bSmrg    if (IS_DIR_SEPARATOR (*name))
6215f3561b8bSmrg      base = name + 1;
6216f3561b8bSmrg  return base;
6217f3561b8bSmrg}
6218fc5a983dSmrg
6219f3561b8bSmrgint
6220f3561b8bSmrgcheck_executable (const char *path)
6221f3561b8bSmrg{
6222f3561b8bSmrg  struct stat st;
6223fc5a983dSmrg
6224bd304fc0Smrg  lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
6225bd304fc0Smrg                  nonempty (path));
6226f3561b8bSmrg  if ((!path) || (!*path))
6227f3561b8bSmrg    return 0;
6228fc5a983dSmrg
6229f3561b8bSmrg  if ((stat (path, &st) >= 0)
6230f3561b8bSmrg      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
6231f3561b8bSmrg    return 1;
6232f3561b8bSmrg  else
6233f3561b8bSmrg    return 0;
6234f3561b8bSmrg}
6235fc5a983dSmrg
6236f3561b8bSmrgint
6237f3561b8bSmrgmake_executable (const char *path)
6238f3561b8bSmrg{
6239f3561b8bSmrg  int rval = 0;
6240f3561b8bSmrg  struct stat st;
6241fc5a983dSmrg
6242bd304fc0Smrg  lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
6243bd304fc0Smrg                  nonempty (path));
6244f3561b8bSmrg  if ((!path) || (!*path))
6245f3561b8bSmrg    return 0;
6246fc5a983dSmrg
6247f3561b8bSmrg  if (stat (path, &st) >= 0)
6248f3561b8bSmrg    {
6249f3561b8bSmrg      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
6250f3561b8bSmrg    }
6251f3561b8bSmrg  return rval;
6252f3561b8bSmrg}
6253fc5a983dSmrg
6254f3561b8bSmrg/* Searches for the full path of the wrapper.  Returns
6255f3561b8bSmrg   newly allocated full path name if found, NULL otherwise
6256f3561b8bSmrg   Does not chase symlinks, even on platforms that support them.
6257f3561b8bSmrg*/
6258f3561b8bSmrgchar *
6259f3561b8bSmrgfind_executable (const char *wrapper)
6260f3561b8bSmrg{
6261f3561b8bSmrg  int has_slash = 0;
6262f3561b8bSmrg  const char *p;
6263f3561b8bSmrg  const char *p_next;
6264f3561b8bSmrg  /* static buffer for getcwd */
6265f3561b8bSmrg  char tmp[LT_PATHMAX + 1];
62666257f37dSmrg  size_t tmp_len;
6267f3561b8bSmrg  char *concat_name;
6268fc5a983dSmrg
6269bd304fc0Smrg  lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
6270bd304fc0Smrg                  nonempty (wrapper));
6271fc5a983dSmrg
6272f3561b8bSmrg  if ((wrapper == NULL) || (*wrapper == '\0'))
6273f3561b8bSmrg    return NULL;
6274fc5a983dSmrg
6275f3561b8bSmrg  /* Absolute path? */
62766257f37dSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM
6277f3561b8bSmrg  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
6278f3561b8bSmrg    {
6279f3561b8bSmrg      concat_name = xstrdup (wrapper);
6280f3561b8bSmrg      if (check_executable (concat_name))
6281f3561b8bSmrg	return concat_name;
6282f3561b8bSmrg      XFREE (concat_name);
6283f3561b8bSmrg    }
6284f3561b8bSmrg  else
6285f3561b8bSmrg    {
6286f3561b8bSmrg#endif
6287f3561b8bSmrg      if (IS_DIR_SEPARATOR (wrapper[0]))
6288f3561b8bSmrg	{
6289f3561b8bSmrg	  concat_name = xstrdup (wrapper);
6290f3561b8bSmrg	  if (check_executable (concat_name))
6291f3561b8bSmrg	    return concat_name;
6292f3561b8bSmrg	  XFREE (concat_name);
6293f3561b8bSmrg	}
62946257f37dSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM
6295f3561b8bSmrg    }
6296f3561b8bSmrg#endif
6297fc5a983dSmrg
6298f3561b8bSmrg  for (p = wrapper; *p; p++)
6299f3561b8bSmrg    if (*p == '/')
6300f3561b8bSmrg      {
6301f3561b8bSmrg	has_slash = 1;
6302f3561b8bSmrg	break;
6303f3561b8bSmrg      }
6304f3561b8bSmrg  if (!has_slash)
6305f3561b8bSmrg    {
6306f3561b8bSmrg      /* no slashes; search PATH */
6307f3561b8bSmrg      const char *path = getenv ("PATH");
6308f3561b8bSmrg      if (path != NULL)
6309f3561b8bSmrg	{
6310f3561b8bSmrg	  for (p = path; *p; p = p_next)
6311f3561b8bSmrg	    {
6312f3561b8bSmrg	      const char *q;
6313f3561b8bSmrg	      size_t p_len;
6314f3561b8bSmrg	      for (q = p; *q; q++)
6315f3561b8bSmrg		if (IS_PATH_SEPARATOR (*q))
6316f3561b8bSmrg		  break;
63176257f37dSmrg	      p_len = (size_t) (q - p);
6318f3561b8bSmrg	      p_next = (*q == '\0' ? q : q + 1);
6319f3561b8bSmrg	      if (p_len == 0)
6320f3561b8bSmrg		{
6321f3561b8bSmrg		  /* empty path: current directory */
6322f3561b8bSmrg		  if (getcwd (tmp, LT_PATHMAX) == NULL)
6323bd304fc0Smrg		    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
6324bd304fc0Smrg                              nonnull (strerror (errno)));
6325f3561b8bSmrg		  tmp_len = strlen (tmp);
6326f3561b8bSmrg		  concat_name =
6327f3561b8bSmrg		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
6328f3561b8bSmrg		  memcpy (concat_name, tmp, tmp_len);
6329f3561b8bSmrg		  concat_name[tmp_len] = '/';
6330f3561b8bSmrg		  strcpy (concat_name + tmp_len + 1, wrapper);
6331f3561b8bSmrg		}
6332f3561b8bSmrg	      else
6333f3561b8bSmrg		{
6334f3561b8bSmrg		  concat_name =
6335f3561b8bSmrg		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
6336f3561b8bSmrg		  memcpy (concat_name, p, p_len);
6337f3561b8bSmrg		  concat_name[p_len] = '/';
6338f3561b8bSmrg		  strcpy (concat_name + p_len + 1, wrapper);
6339f3561b8bSmrg		}
6340f3561b8bSmrg	      if (check_executable (concat_name))
6341f3561b8bSmrg		return concat_name;
6342f3561b8bSmrg	      XFREE (concat_name);
6343f3561b8bSmrg	    }
6344f3561b8bSmrg	}
6345f3561b8bSmrg      /* not found in PATH; assume curdir */
6346f3561b8bSmrg    }
6347f3561b8bSmrg  /* Relative path | not found in path: prepend cwd */
6348f3561b8bSmrg  if (getcwd (tmp, LT_PATHMAX) == NULL)
6349bd304fc0Smrg    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
6350bd304fc0Smrg              nonnull (strerror (errno)));
6351f3561b8bSmrg  tmp_len = strlen (tmp);
6352f3561b8bSmrg  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
6353f3561b8bSmrg  memcpy (concat_name, tmp, tmp_len);
6354f3561b8bSmrg  concat_name[tmp_len] = '/';
6355f3561b8bSmrg  strcpy (concat_name + tmp_len + 1, wrapper);
6356fc5a983dSmrg
6357f3561b8bSmrg  if (check_executable (concat_name))
6358f3561b8bSmrg    return concat_name;
6359f3561b8bSmrg  XFREE (concat_name);
6360f3561b8bSmrg  return NULL;
6361f3561b8bSmrg}
6362fc5a983dSmrg
6363f3561b8bSmrgchar *
6364f3561b8bSmrgchase_symlinks (const char *pathspec)
6365f3561b8bSmrg{
6366f3561b8bSmrg#ifndef S_ISLNK
6367f3561b8bSmrg  return xstrdup (pathspec);
6368f3561b8bSmrg#else
6369f3561b8bSmrg  char buf[LT_PATHMAX];
6370f3561b8bSmrg  struct stat s;
6371f3561b8bSmrg  char *tmp_pathspec = xstrdup (pathspec);
6372f3561b8bSmrg  char *p;
6373f3561b8bSmrg  int has_symlinks = 0;
6374f3561b8bSmrg  while (strlen (tmp_pathspec) && !has_symlinks)
6375f3561b8bSmrg    {
6376bd304fc0Smrg      lt_debugprintf (__FILE__, __LINE__,
6377bd304fc0Smrg		      "checking path component for symlinks: %s\n",
6378bd304fc0Smrg		      tmp_pathspec);
6379f3561b8bSmrg      if (lstat (tmp_pathspec, &s) == 0)
6380f3561b8bSmrg	{
6381f3561b8bSmrg	  if (S_ISLNK (s.st_mode) != 0)
6382f3561b8bSmrg	    {
6383f3561b8bSmrg	      has_symlinks = 1;
6384f3561b8bSmrg	      break;
6385f3561b8bSmrg	    }
6386fc5a983dSmrg
6387f3561b8bSmrg	  /* search backwards for last DIR_SEPARATOR */
6388f3561b8bSmrg	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
6389f3561b8bSmrg	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
6390f3561b8bSmrg	    p--;
6391f3561b8bSmrg	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
6392f3561b8bSmrg	    {
6393f3561b8bSmrg	      /* no more DIR_SEPARATORS left */
6394f3561b8bSmrg	      break;
6395f3561b8bSmrg	    }
6396f3561b8bSmrg	  *p = '\0';
6397f3561b8bSmrg	}
6398f3561b8bSmrg      else
6399f3561b8bSmrg	{
6400bd304fc0Smrg	  lt_fatal (__FILE__, __LINE__,
6401bd304fc0Smrg		    "error accessing file \"%s\": %s",
6402bd304fc0Smrg		    tmp_pathspec, nonnull (strerror (errno)));
6403f3561b8bSmrg	}
6404f3561b8bSmrg    }
6405f3561b8bSmrg  XFREE (tmp_pathspec);
6406fc5a983dSmrg
6407f3561b8bSmrg  if (!has_symlinks)
6408f3561b8bSmrg    {
6409f3561b8bSmrg      return xstrdup (pathspec);
6410f3561b8bSmrg    }
6411fc5a983dSmrg
6412f3561b8bSmrg  tmp_pathspec = realpath (pathspec, buf);
6413f3561b8bSmrg  if (tmp_pathspec == 0)
6414f3561b8bSmrg    {
6415bd304fc0Smrg      lt_fatal (__FILE__, __LINE__,
6416bd304fc0Smrg		"could not follow symlinks for %s", pathspec);
6417f3561b8bSmrg    }
6418f3561b8bSmrg  return xstrdup (tmp_pathspec);
6419f3561b8bSmrg#endif
6420f3561b8bSmrg}
6421fc5a983dSmrg
6422f3561b8bSmrgchar *
6423f3561b8bSmrgstrendzap (char *str, const char *pat)
6424f3561b8bSmrg{
6425f3561b8bSmrg  size_t len, patlen;
6426fc5a983dSmrg
6427f3561b8bSmrg  assert (str != NULL);
6428f3561b8bSmrg  assert (pat != NULL);
6429fc5a983dSmrg
6430f3561b8bSmrg  len = strlen (str);
6431f3561b8bSmrg  patlen = strlen (pat);
6432fc5a983dSmrg
6433f3561b8bSmrg  if (patlen <= len)
6434f3561b8bSmrg    {
6435f3561b8bSmrg      str += len - patlen;
64366257f37dSmrg      if (STREQ (str, pat))
6437f3561b8bSmrg	*str = '\0';
6438f3561b8bSmrg    }
6439f3561b8bSmrg  return str;
6440f3561b8bSmrg}
6441fc5a983dSmrg
6442bd304fc0Smrgvoid
6443bd304fc0Smrglt_debugprintf (const char *file, int line, const char *fmt, ...)
6444bd304fc0Smrg{
6445bd304fc0Smrg  va_list args;
6446bd304fc0Smrg  if (lt_debug)
6447bd304fc0Smrg    {
6448bd304fc0Smrg      (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
6449bd304fc0Smrg      va_start (args, fmt);
6450bd304fc0Smrg      (void) vfprintf (stderr, fmt, args);
6451bd304fc0Smrg      va_end (args);
6452bd304fc0Smrg    }
6453bd304fc0Smrg}
6454bd304fc0Smrg
6455f3561b8bSmrgstatic void
6456bd304fc0Smrglt_error_core (int exit_status, const char *file,
6457bd304fc0Smrg	       int line, const char *mode,
6458f3561b8bSmrg	       const char *message, va_list ap)
6459f3561b8bSmrg{
6460bd304fc0Smrg  fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
6461f3561b8bSmrg  vfprintf (stderr, message, ap);
6462f3561b8bSmrg  fprintf (stderr, ".\n");
6463fc5a983dSmrg
6464f3561b8bSmrg  if (exit_status >= 0)
6465f3561b8bSmrg    exit (exit_status);
6466f3561b8bSmrg}
6467fc5a983dSmrg
6468f3561b8bSmrgvoid
6469bd304fc0Smrglt_fatal (const char *file, int line, const char *message, ...)
6470f3561b8bSmrg{
6471f3561b8bSmrg  va_list ap;
6472f3561b8bSmrg  va_start (ap, message);
6473bd304fc0Smrg  lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
6474f3561b8bSmrg  va_end (ap);
6475f3561b8bSmrg}
6476fc5a983dSmrg
6477bd304fc0Smrgstatic const char *
6478bd304fc0Smrgnonnull (const char *s)
6479bd304fc0Smrg{
6480bd304fc0Smrg  return s ? s : "(null)";
6481bd304fc0Smrg}
6482bd304fc0Smrg
6483bd304fc0Smrgstatic const char *
6484bd304fc0Smrgnonempty (const char *s)
6485bd304fc0Smrg{
6486bd304fc0Smrg  return (s && !*s) ? "(empty)" : nonnull (s);
6487bd304fc0Smrg}
6488bd304fc0Smrg
6489f3561b8bSmrgvoid
6490f3561b8bSmrglt_setenv (const char *name, const char *value)
6491f3561b8bSmrg{
6492bd304fc0Smrg  lt_debugprintf (__FILE__, __LINE__,
6493bd304fc0Smrg		  "(lt_setenv) setting '%s' to '%s'\n",
6494bd304fc0Smrg                  nonnull (name), nonnull (value));
6495f3561b8bSmrg  {
6496f3561b8bSmrg#ifdef HAVE_SETENV
6497f3561b8bSmrg    /* always make a copy, for consistency with !HAVE_SETENV */
6498f3561b8bSmrg    char *str = xstrdup (value);
6499f3561b8bSmrg    setenv (name, str, 1);
6500f3561b8bSmrg#else
65016257f37dSmrg    size_t len = strlen (name) + 1 + strlen (value) + 1;
6502f3561b8bSmrg    char *str = XMALLOC (char, len);
6503f3561b8bSmrg    sprintf (str, "%s=%s", name, value);
6504f3561b8bSmrg    if (putenv (str) != EXIT_SUCCESS)
6505f3561b8bSmrg      {
6506f3561b8bSmrg        XFREE (str);
6507f3561b8bSmrg      }
6508f3561b8bSmrg#endif
6509f3561b8bSmrg  }
6510f3561b8bSmrg}
6511fc5a983dSmrg
6512f3561b8bSmrgchar *
6513f3561b8bSmrglt_extend_str (const char *orig_value, const char *add, int to_end)
6514f3561b8bSmrg{
6515f3561b8bSmrg  char *new_value;
6516f3561b8bSmrg  if (orig_value && *orig_value)
6517f3561b8bSmrg    {
65186257f37dSmrg      size_t orig_value_len = strlen (orig_value);
65196257f37dSmrg      size_t add_len = strlen (add);
6520f3561b8bSmrg      new_value = XMALLOC (char, add_len + orig_value_len + 1);
6521f3561b8bSmrg      if (to_end)
6522f3561b8bSmrg        {
6523f3561b8bSmrg          strcpy (new_value, orig_value);
6524f3561b8bSmrg          strcpy (new_value + orig_value_len, add);
6525f3561b8bSmrg        }
6526f3561b8bSmrg      else
6527f3561b8bSmrg        {
6528f3561b8bSmrg          strcpy (new_value, add);
6529f3561b8bSmrg          strcpy (new_value + add_len, orig_value);
6530f3561b8bSmrg        }
6531f3561b8bSmrg    }
6532f3561b8bSmrg  else
6533f3561b8bSmrg    {
6534f3561b8bSmrg      new_value = xstrdup (add);
6535f3561b8bSmrg    }
6536f3561b8bSmrg  return new_value;
6537f3561b8bSmrg}
6538fc5a983dSmrg
6539f3561b8bSmrgvoid
6540f3561b8bSmrglt_update_exe_path (const char *name, const char *value)
6541f3561b8bSmrg{
6542bd304fc0Smrg  lt_debugprintf (__FILE__, __LINE__,
6543bd304fc0Smrg		  "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
6544bd304fc0Smrg                  nonnull (name), nonnull (value));
6545fc5a983dSmrg
6546f3561b8bSmrg  if (name && *name && value && *value)
6547f3561b8bSmrg    {
6548f3561b8bSmrg      char *new_value = lt_extend_str (getenv (name), value, 0);
6549f3561b8bSmrg      /* some systems can't cope with a ':'-terminated path #' */
65506257f37dSmrg      size_t len = strlen (new_value);
65516257f37dSmrg      while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
6552f3561b8bSmrg        {
65536257f37dSmrg          new_value[--len] = '\0';
6554f3561b8bSmrg        }
6555f3561b8bSmrg      lt_setenv (name, new_value);
6556f3561b8bSmrg      XFREE (new_value);
6557f3561b8bSmrg    }
6558f3561b8bSmrg}
6559fc5a983dSmrg
6560f3561b8bSmrgvoid
6561f3561b8bSmrglt_update_lib_path (const char *name, const char *value)
6562f3561b8bSmrg{
6563bd304fc0Smrg  lt_debugprintf (__FILE__, __LINE__,
6564bd304fc0Smrg		  "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
6565bd304fc0Smrg                  nonnull (name), nonnull (value));
6566fc5a983dSmrg
6567f3561b8bSmrg  if (name && *name && value && *value)
6568f3561b8bSmrg    {
6569f3561b8bSmrg      char *new_value = lt_extend_str (getenv (name), value, 0);
6570f3561b8bSmrg      lt_setenv (name, new_value);
6571f3561b8bSmrg      XFREE (new_value);
6572f3561b8bSmrg    }
6573f3561b8bSmrg}
6574fc5a983dSmrg
6575bd304fc0SmrgEOF
6576bd304fc0Smrg	    case $host_os in
6577bd304fc0Smrg	      mingw*)
6578bd304fc0Smrg		cat <<"EOF"
6579bd304fc0Smrg
6580bd304fc0Smrg/* Prepares an argument vector before calling spawn().
6581bd304fc0Smrg   Note that spawn() does not by itself call the command interpreter
6582bd304fc0Smrg     (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
6583bd304fc0Smrg      ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
6584bd304fc0Smrg         GetVersionEx(&v);
6585bd304fc0Smrg         v.dwPlatformId == VER_PLATFORM_WIN32_NT;
6586bd304fc0Smrg      }) ? "cmd.exe" : "command.com").
6587bd304fc0Smrg   Instead it simply concatenates the arguments, separated by ' ', and calls
6588bd304fc0Smrg   CreateProcess().  We must quote the arguments since Win32 CreateProcess()
6589bd304fc0Smrg   interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
6590bd304fc0Smrg   special way:
6591bd304fc0Smrg   - Space and tab are interpreted as delimiters. They are not treated as
6592bd304fc0Smrg     delimiters if they are surrounded by double quotes: "...".
6593bd304fc0Smrg   - Unescaped double quotes are removed from the input. Their only effect is
6594bd304fc0Smrg     that within double quotes, space and tab are treated like normal
6595bd304fc0Smrg     characters.
6596bd304fc0Smrg   - Backslashes not followed by double quotes are not special.
6597bd304fc0Smrg   - But 2*n+1 backslashes followed by a double quote become
6598bd304fc0Smrg     n backslashes followed by a double quote (n >= 0):
6599bd304fc0Smrg       \" -> "
6600bd304fc0Smrg       \\\" -> \"
6601bd304fc0Smrg       \\\\\" -> \\"
6602bd304fc0Smrg */
6603bd304fc0Smrg#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"
6604bd304fc0Smrg#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"
6605bd304fc0Smrgchar **
6606bd304fc0Smrgprepare_spawn (char **argv)
6607bd304fc0Smrg{
6608bd304fc0Smrg  size_t argc;
6609bd304fc0Smrg  char **new_argv;
6610bd304fc0Smrg  size_t i;
6611bd304fc0Smrg
6612bd304fc0Smrg  /* Count number of arguments.  */
6613bd304fc0Smrg  for (argc = 0; argv[argc] != NULL; argc++)
6614bd304fc0Smrg    ;
6615bd304fc0Smrg
6616bd304fc0Smrg  /* Allocate new argument vector.  */
6617bd304fc0Smrg  new_argv = XMALLOC (char *, argc + 1);
6618bd304fc0Smrg
6619bd304fc0Smrg  /* Put quoted arguments into the new argument vector.  */
6620bd304fc0Smrg  for (i = 0; i < argc; i++)
6621bd304fc0Smrg    {
6622bd304fc0Smrg      const char *string = argv[i];
6623bd304fc0Smrg
6624bd304fc0Smrg      if (string[0] == '\0')
6625bd304fc0Smrg	new_argv[i] = xstrdup ("\"\"");
6626bd304fc0Smrg      else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
6627bd304fc0Smrg	{
6628bd304fc0Smrg	  int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
6629bd304fc0Smrg	  size_t length;
6630bd304fc0Smrg	  unsigned int backslashes;
6631bd304fc0Smrg	  const char *s;
6632bd304fc0Smrg	  char *quoted_string;
6633bd304fc0Smrg	  char *p;
6634bd304fc0Smrg
6635bd304fc0Smrg	  length = 0;
6636bd304fc0Smrg	  backslashes = 0;
6637bd304fc0Smrg	  if (quote_around)
6638bd304fc0Smrg	    length++;
6639bd304fc0Smrg	  for (s = string; *s != '\0'; s++)
6640bd304fc0Smrg	    {
6641bd304fc0Smrg	      char c = *s;
6642bd304fc0Smrg	      if (c == '"')
6643bd304fc0Smrg		length += backslashes + 1;
6644bd304fc0Smrg	      length++;
6645bd304fc0Smrg	      if (c == '\\')
6646bd304fc0Smrg		backslashes++;
6647bd304fc0Smrg	      else
6648bd304fc0Smrg		backslashes = 0;
6649bd304fc0Smrg	    }
6650bd304fc0Smrg	  if (quote_around)
6651bd304fc0Smrg	    length += backslashes + 1;
6652bd304fc0Smrg
6653bd304fc0Smrg	  quoted_string = XMALLOC (char, length + 1);
6654bd304fc0Smrg
6655bd304fc0Smrg	  p = quoted_string;
6656bd304fc0Smrg	  backslashes = 0;
6657bd304fc0Smrg	  if (quote_around)
6658bd304fc0Smrg	    *p++ = '"';
6659bd304fc0Smrg	  for (s = string; *s != '\0'; s++)
6660bd304fc0Smrg	    {
6661bd304fc0Smrg	      char c = *s;
6662bd304fc0Smrg	      if (c == '"')
6663bd304fc0Smrg		{
6664bd304fc0Smrg		  unsigned int j;
6665bd304fc0Smrg		  for (j = backslashes + 1; j > 0; j--)
6666bd304fc0Smrg		    *p++ = '\\';
6667bd304fc0Smrg		}
6668bd304fc0Smrg	      *p++ = c;
6669bd304fc0Smrg	      if (c == '\\')
6670bd304fc0Smrg		backslashes++;
6671bd304fc0Smrg	      else
6672bd304fc0Smrg		backslashes = 0;
6673bd304fc0Smrg	    }
6674bd304fc0Smrg	  if (quote_around)
6675bd304fc0Smrg	    {
6676bd304fc0Smrg	      unsigned int j;
6677bd304fc0Smrg	      for (j = backslashes; j > 0; j--)
6678bd304fc0Smrg		*p++ = '\\';
6679bd304fc0Smrg	      *p++ = '"';
6680bd304fc0Smrg	    }
6681bd304fc0Smrg	  *p = '\0';
6682bd304fc0Smrg
6683bd304fc0Smrg	  new_argv[i] = quoted_string;
6684bd304fc0Smrg	}
6685bd304fc0Smrg      else
6686bd304fc0Smrg	new_argv[i] = (char *) string;
6687bd304fc0Smrg    }
6688bd304fc0Smrg  new_argv[argc] = NULL;
6689bd304fc0Smrg
6690bd304fc0Smrg  return new_argv;
6691bd304fc0Smrg}
6692bd304fc0SmrgEOF
6693bd304fc0Smrg		;;
6694bd304fc0Smrg	    esac
6695fc5a983dSmrg
6696bd304fc0Smrg            cat <<"EOF"
6697bd304fc0Smrgvoid lt_dump_script (FILE* f)
6698bd304fc0Smrg{
6699bd304fc0SmrgEOF
6700bd304fc0Smrg	    func_emit_wrapper yes |
6701bd304fc0Smrg	      $SED -n -e '
6702bd304fc0Smrgs/^\(.\{79\}\)\(..*\)/\1\
6703bd304fc0Smrg\2/
6704bd304fc0Smrgh
6705bd304fc0Smrgs/\([\\"]\)/\\\1/g
6706bd304fc0Smrgs/$/\\n/
6707bd304fc0Smrgs/\([^\n]*\).*/  fputs ("\1", f);/p
6708bd304fc0Smrgg
6709bd304fc0SmrgD'
6710bd304fc0Smrg            cat <<"EOF"
6711bd304fc0Smrg}
6712f3561b8bSmrgEOF
6713f3561b8bSmrg}
6714f3561b8bSmrg# end: func_emit_cwrapperexe_src
6715fc5a983dSmrg
6716bd304fc0Smrg# func_win32_import_lib_p ARG
6717bd304fc0Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd
6718bd304fc0Smrgfunc_win32_import_lib_p ()
6719bd304fc0Smrg{
67206257f37dSmrg    $debug_cmd
67216257f37dSmrg
6722bd304fc0Smrg    case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
6723bd304fc0Smrg    *import*) : ;;
6724bd304fc0Smrg    *) false ;;
6725bd304fc0Smrg    esac
6726bd304fc0Smrg}
6727bd304fc0Smrg
67286257f37dSmrg# func_suncc_cstd_abi
67296257f37dSmrg# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!!
67306257f37dSmrg# Several compiler flags select an ABI that is incompatible with the
67316257f37dSmrg# Cstd library. Avoid specifying it if any are in CXXFLAGS.
67326257f37dSmrgfunc_suncc_cstd_abi ()
67336257f37dSmrg{
67346257f37dSmrg    $debug_cmd
67356257f37dSmrg
67366257f37dSmrg    case " $compile_command " in
67376257f37dSmrg    *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*)
67386257f37dSmrg      suncc_use_cstd_abi=no
67396257f37dSmrg      ;;
67406257f37dSmrg    *)
67416257f37dSmrg      suncc_use_cstd_abi=yes
67426257f37dSmrg      ;;
67436257f37dSmrg    esac
67446257f37dSmrg}
67456257f37dSmrg
6746f3561b8bSmrg# func_mode_link arg...
6747f3561b8bSmrgfunc_mode_link ()
6748f3561b8bSmrg{
67496257f37dSmrg    $debug_cmd
67506257f37dSmrg
6751f3561b8bSmrg    case $host in
6752f3561b8bSmrg    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
6753f3561b8bSmrg      # It is impossible to link a dll without this setting, and
6754f3561b8bSmrg      # we shouldn't force the makefile maintainer to figure out
67556257f37dSmrg      # what system we are compiling for in order to pass an extra
6756f3561b8bSmrg      # flag for every libtool invocation.
6757f3561b8bSmrg      # allow_undefined=no
6758fc5a983dSmrg
6759f3561b8bSmrg      # FIXME: Unfortunately, there are problems with the above when trying
67606257f37dSmrg      # to make a dll that has undefined symbols, in which case not
6761f3561b8bSmrg      # even a static library is built.  For now, we need to specify
6762f3561b8bSmrg      # -no-undefined on the libtool link line when we can be certain
6763f3561b8bSmrg      # that all symbols are satisfied, otherwise we get a static library.
6764f3561b8bSmrg      allow_undefined=yes
6765f3561b8bSmrg      ;;
6766f3561b8bSmrg    *)
6767f3561b8bSmrg      allow_undefined=yes
6768f3561b8bSmrg      ;;
6769f3561b8bSmrg    esac
6770f3561b8bSmrg    libtool_args=$nonopt
6771f3561b8bSmrg    base_compile="$nonopt $@"
6772f3561b8bSmrg    compile_command=$nonopt
6773f3561b8bSmrg    finalize_command=$nonopt
6774fc5a983dSmrg
6775f3561b8bSmrg    compile_rpath=
6776f3561b8bSmrg    finalize_rpath=
6777f3561b8bSmrg    compile_shlibpath=
6778f3561b8bSmrg    finalize_shlibpath=
6779f3561b8bSmrg    convenience=
6780f3561b8bSmrg    old_convenience=
6781f3561b8bSmrg    deplibs=
6782f3561b8bSmrg    old_deplibs=
6783f3561b8bSmrg    compiler_flags=
6784f3561b8bSmrg    linker_flags=
6785f3561b8bSmrg    dllsearchpath=
6786f3561b8bSmrg    lib_search_path=`pwd`
6787f3561b8bSmrg    inst_prefix_dir=
6788f3561b8bSmrg    new_inherited_linker_flags=
6789fc5a983dSmrg
6790f3561b8bSmrg    avoid_version=no
6791bd304fc0Smrg    bindir=
6792f3561b8bSmrg    dlfiles=
6793f3561b8bSmrg    dlprefiles=
6794f3561b8bSmrg    dlself=no
6795f3561b8bSmrg    export_dynamic=no
6796f3561b8bSmrg    export_symbols=
6797f3561b8bSmrg    export_symbols_regex=
6798f3561b8bSmrg    generated=
6799f3561b8bSmrg    libobjs=
6800f3561b8bSmrg    ltlibs=
6801f3561b8bSmrg    module=no
6802f3561b8bSmrg    no_install=no
6803f3561b8bSmrg    objs=
68046257f37dSmrg    os2dllname=
6805f3561b8bSmrg    non_pic_objects=
6806f3561b8bSmrg    precious_files_regex=
6807f3561b8bSmrg    prefer_static_libs=no
68086257f37dSmrg    preload=false
6809f3561b8bSmrg    prev=
6810f3561b8bSmrg    prevarg=
6811f3561b8bSmrg    release=
6812f3561b8bSmrg    rpath=
6813f3561b8bSmrg    xrpath=
6814f3561b8bSmrg    perm_rpath=
6815f3561b8bSmrg    temp_rpath=
6816f3561b8bSmrg    thread_safe=no
6817f3561b8bSmrg    vinfo=
6818f3561b8bSmrg    vinfo_number=no
6819f3561b8bSmrg    weak_libs=
68206257f37dSmrg    single_module=$wl-single_module
6821f3561b8bSmrg    func_infer_tag $base_compile
6822f3561b8bSmrg
6823f3561b8bSmrg    # We need to know -static, to get the right output filenames.
6824f3561b8bSmrg    for arg
6825f3561b8bSmrg    do
6826f3561b8bSmrg      case $arg in
6827f3561b8bSmrg      -shared)
68286257f37dSmrg	test yes != "$build_libtool_libs" \
68296257f37dSmrg	  && func_fatal_configuration "cannot build a shared library"
6830f3561b8bSmrg	build_old_libs=no
6831f3561b8bSmrg	break
6832f3561b8bSmrg	;;
6833f3561b8bSmrg      -all-static | -static | -static-libtool-libs)
6834f3561b8bSmrg	case $arg in
6835f3561b8bSmrg	-all-static)
68366257f37dSmrg	  if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then
6837f3561b8bSmrg	    func_warning "complete static linking is impossible in this configuration"
6838f3561b8bSmrg	  fi
6839f3561b8bSmrg	  if test -n "$link_static_flag"; then
6840f3561b8bSmrg	    dlopen_self=$dlopen_self_static
6841f3561b8bSmrg	  fi
6842f3561b8bSmrg	  prefer_static_libs=yes
6843f3561b8bSmrg	  ;;
6844f3561b8bSmrg	-static)
6845f3561b8bSmrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
6846f3561b8bSmrg	    dlopen_self=$dlopen_self_static
6847f3561b8bSmrg	  fi
6848f3561b8bSmrg	  prefer_static_libs=built
6849f3561b8bSmrg	  ;;
6850f3561b8bSmrg	-static-libtool-libs)
6851f3561b8bSmrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
6852f3561b8bSmrg	    dlopen_self=$dlopen_self_static
6853fc5a983dSmrg	  fi
6854f3561b8bSmrg	  prefer_static_libs=yes
6855f3561b8bSmrg	  ;;
6856f3561b8bSmrg	esac
6857f3561b8bSmrg	build_libtool_libs=no
6858f3561b8bSmrg	build_old_libs=yes
6859f3561b8bSmrg	break
6860f3561b8bSmrg	;;
6861f3561b8bSmrg      esac
6862f3561b8bSmrg    done
6863fc5a983dSmrg
6864f3561b8bSmrg    # See if our shared archives depend on static archives.
6865f3561b8bSmrg    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
6866fc5a983dSmrg
6867f3561b8bSmrg    # Go through the arguments, transforming them on the way.
6868f3561b8bSmrg    while test "$#" -gt 0; do
68696257f37dSmrg      arg=$1
6870f3561b8bSmrg      shift
6871d422ce2eSmrg      func_quote_arg pretty,unquoted "$arg"
6872d422ce2eSmrg      qarg=$func_quote_arg_unquoted_result
6873d422ce2eSmrg      func_append libtool_args " $func_quote_arg_result"
6874fc5a983dSmrg
6875f3561b8bSmrg      # If the previous option needs an argument, assign it.
6876f3561b8bSmrg      if test -n "$prev"; then
6877f3561b8bSmrg	case $prev in
6878f3561b8bSmrg	output)
6879f3561b8bSmrg	  func_append compile_command " @OUTPUT@"
6880f3561b8bSmrg	  func_append finalize_command " @OUTPUT@"
6881f3561b8bSmrg	  ;;
6882f3561b8bSmrg	esac
6883fc5a983dSmrg
6884f3561b8bSmrg	case $prev in
6885bd304fc0Smrg	bindir)
68866257f37dSmrg	  bindir=$arg
6887bd304fc0Smrg	  prev=
6888bd304fc0Smrg	  continue
6889bd304fc0Smrg	  ;;
6890f3561b8bSmrg	dlfiles|dlprefiles)
68916257f37dSmrg	  $preload || {
6892f3561b8bSmrg	    # Add the symbol object into the linking commands.
6893f3561b8bSmrg	    func_append compile_command " @SYMFILE@"
6894f3561b8bSmrg	    func_append finalize_command " @SYMFILE@"
68956257f37dSmrg	    preload=:
68966257f37dSmrg	  }
6897f3561b8bSmrg	  case $arg in
6898f3561b8bSmrg	  *.la | *.lo) ;;  # We handle these cases below.
6899f3561b8bSmrg	  force)
69006257f37dSmrg	    if test no = "$dlself"; then
6901f3561b8bSmrg	      dlself=needless
6902f3561b8bSmrg	      export_dynamic=yes
6903f3561b8bSmrg	    fi
6904f3561b8bSmrg	    prev=
6905f3561b8bSmrg	    continue
6906f3561b8bSmrg	    ;;
6907f3561b8bSmrg	  self)
69086257f37dSmrg	    if test dlprefiles = "$prev"; then
6909f3561b8bSmrg	      dlself=yes
69106257f37dSmrg	    elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then
6911f3561b8bSmrg	      dlself=yes
6912fc5a983dSmrg	    else
6913f3561b8bSmrg	      dlself=needless
6914f3561b8bSmrg	      export_dynamic=yes
6915fc5a983dSmrg	    fi
6916f3561b8bSmrg	    prev=
6917f3561b8bSmrg	    continue
6918f3561b8bSmrg	    ;;
6919f3561b8bSmrg	  *)
69206257f37dSmrg	    if test dlfiles = "$prev"; then
6921bd304fc0Smrg	      func_append dlfiles " $arg"
6922fc5a983dSmrg	    else
6923bd304fc0Smrg	      func_append dlprefiles " $arg"
6924fc5a983dSmrg	    fi
6925f3561b8bSmrg	    prev=
6926f3561b8bSmrg	    continue
6927f3561b8bSmrg	    ;;
6928f3561b8bSmrg	  esac
6929f3561b8bSmrg	  ;;
6930f3561b8bSmrg	expsyms)
69316257f37dSmrg	  export_symbols=$arg
6932f3561b8bSmrg	  test -f "$arg" \
69336257f37dSmrg	    || func_fatal_error "symbol file '$arg' does not exist"
6934f3561b8bSmrg	  prev=
6935f3561b8bSmrg	  continue
6936f3561b8bSmrg	  ;;
6937f3561b8bSmrg	expsyms_regex)
69386257f37dSmrg	  export_symbols_regex=$arg
6939f3561b8bSmrg	  prev=
6940f3561b8bSmrg	  continue
6941f3561b8bSmrg	  ;;
6942f3561b8bSmrg	framework)
6943fc5a983dSmrg	  case $host in
6944f3561b8bSmrg	    *-*-darwin*)
6945f3561b8bSmrg	      case "$deplibs " in
6946f3561b8bSmrg		*" $qarg.ltframework "*) ;;
6947bd304fc0Smrg		*) func_append deplibs " $qarg.ltframework" # this is fixed later
6948f3561b8bSmrg		   ;;
6949f3561b8bSmrg	      esac
6950f3561b8bSmrg	      ;;
6951fc5a983dSmrg	  esac
6952f3561b8bSmrg	  prev=
6953f3561b8bSmrg	  continue
6954fc5a983dSmrg	  ;;
6955f3561b8bSmrg	inst_prefix)
69566257f37dSmrg	  inst_prefix_dir=$arg
69576257f37dSmrg	  prev=
69586257f37dSmrg	  continue
69596257f37dSmrg	  ;;
69606257f37dSmrg	mllvm)
69616257f37dSmrg	  # Clang does not use LLVM to link, so we can simply discard any
69626257f37dSmrg	  # '-mllvm $arg' options when doing the link step.
6963f3561b8bSmrg	  prev=
6964f3561b8bSmrg	  continue
6965fc5a983dSmrg	  ;;
6966f3561b8bSmrg	objectlist)
6967f3561b8bSmrg	  if test -f "$arg"; then
6968f3561b8bSmrg	    save_arg=$arg
6969f3561b8bSmrg	    moreargs=
6970f3561b8bSmrg	    for fil in `cat "$save_arg"`
6971f3561b8bSmrg	    do
6972bd304fc0Smrg#	      func_append moreargs " $fil"
6973f3561b8bSmrg	      arg=$fil
6974f3561b8bSmrg	      # A libtool-controlled object.
6975fc5a983dSmrg
6976f3561b8bSmrg	      # Check to see that this really is a libtool object.
6977f3561b8bSmrg	      if func_lalib_unsafe_p "$arg"; then
6978f3561b8bSmrg		pic_object=
6979f3561b8bSmrg		non_pic_object=
6980fc5a983dSmrg
6981f3561b8bSmrg		# Read the .lo file
6982f3561b8bSmrg		func_source "$arg"
6983fc5a983dSmrg
6984f3561b8bSmrg		if test -z "$pic_object" ||
6985f3561b8bSmrg		   test -z "$non_pic_object" ||
69866257f37dSmrg		   test none = "$pic_object" &&
69876257f37dSmrg		   test none = "$non_pic_object"; then
69886257f37dSmrg		  func_fatal_error "cannot find name of object for '$arg'"
6989f3561b8bSmrg		fi
6990fc5a983dSmrg
6991f3561b8bSmrg		# Extract subdirectory from the argument.
6992f3561b8bSmrg		func_dirname "$arg" "/" ""
69936257f37dSmrg		xdir=$func_dirname_result
6994fc5a983dSmrg
69956257f37dSmrg		if test none != "$pic_object"; then
6996f3561b8bSmrg		  # Prepend the subdirectory the object is found in.
69976257f37dSmrg		  pic_object=$xdir$pic_object
6998fc5a983dSmrg
69996257f37dSmrg		  if test dlfiles = "$prev"; then
70006257f37dSmrg		    if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
7001bd304fc0Smrg		      func_append dlfiles " $pic_object"
7002f3561b8bSmrg		      prev=
7003f3561b8bSmrg		      continue
7004f3561b8bSmrg		    else
7005f3561b8bSmrg		      # If libtool objects are unsupported, then we need to preload.
7006f3561b8bSmrg		      prev=dlprefiles
7007f3561b8bSmrg		    fi
7008f3561b8bSmrg		  fi
7009fc5a983dSmrg
7010f3561b8bSmrg		  # CHECK ME:  I think I busted this.  -Ossama
70116257f37dSmrg		  if test dlprefiles = "$prev"; then
7012f3561b8bSmrg		    # Preload the old-style object.
7013bd304fc0Smrg		    func_append dlprefiles " $pic_object"
7014f3561b8bSmrg		    prev=
7015f3561b8bSmrg		  fi
7016fc5a983dSmrg
7017f3561b8bSmrg		  # A PIC object.
7018f3561b8bSmrg		  func_append libobjs " $pic_object"
70196257f37dSmrg		  arg=$pic_object
7020f3561b8bSmrg		fi
7021fc5a983dSmrg
7022f3561b8bSmrg		# Non-PIC object.
70236257f37dSmrg		if test none != "$non_pic_object"; then
7024f3561b8bSmrg		  # Prepend the subdirectory the object is found in.
70256257f37dSmrg		  non_pic_object=$xdir$non_pic_object
7026fc5a983dSmrg
7027f3561b8bSmrg		  # A standard non-PIC object
7028f3561b8bSmrg		  func_append non_pic_objects " $non_pic_object"
70296257f37dSmrg		  if test -z "$pic_object" || test none = "$pic_object"; then
70306257f37dSmrg		    arg=$non_pic_object
7031f3561b8bSmrg		  fi
7032f3561b8bSmrg		else
7033f3561b8bSmrg		  # If the PIC object exists, use it instead.
7034f3561b8bSmrg		  # $xdir was prepended to $pic_object above.
70356257f37dSmrg		  non_pic_object=$pic_object
7036f3561b8bSmrg		  func_append non_pic_objects " $non_pic_object"
7037f3561b8bSmrg		fi
7038f3561b8bSmrg	      else
7039f3561b8bSmrg		# Only an error if not doing a dry-run.
7040f3561b8bSmrg		if $opt_dry_run; then
7041f3561b8bSmrg		  # Extract subdirectory from the argument.
7042f3561b8bSmrg		  func_dirname "$arg" "/" ""
70436257f37dSmrg		  xdir=$func_dirname_result
7044f3561b8bSmrg
7045f3561b8bSmrg		  func_lo2o "$arg"
7046f3561b8bSmrg		  pic_object=$xdir$objdir/$func_lo2o_result
7047f3561b8bSmrg		  non_pic_object=$xdir$func_lo2o_result
7048f3561b8bSmrg		  func_append libobjs " $pic_object"
7049f3561b8bSmrg		  func_append non_pic_objects " $non_pic_object"
7050f3561b8bSmrg	        else
70516257f37dSmrg		  func_fatal_error "'$arg' is not a valid libtool object"
7052f3561b8bSmrg		fi
7053f3561b8bSmrg	      fi
7054f3561b8bSmrg	    done
7055fc5a983dSmrg	  else
70566257f37dSmrg	    func_fatal_error "link input file '$arg' does not exist"
7057fc5a983dSmrg	  fi
7058f3561b8bSmrg	  arg=$save_arg
7059f3561b8bSmrg	  prev=
7060f3561b8bSmrg	  continue
7061f3561b8bSmrg	  ;;
70626257f37dSmrg	os2dllname)
70636257f37dSmrg	  os2dllname=$arg
70646257f37dSmrg	  prev=
70656257f37dSmrg	  continue
70666257f37dSmrg	  ;;
7067f3561b8bSmrg	precious_regex)
70686257f37dSmrg	  precious_files_regex=$arg
7069f3561b8bSmrg	  prev=
7070f3561b8bSmrg	  continue
7071f3561b8bSmrg	  ;;
7072f3561b8bSmrg	release)
70736257f37dSmrg	  release=-$arg
7074f3561b8bSmrg	  prev=
7075f3561b8bSmrg	  continue
7076f3561b8bSmrg	  ;;
7077f3561b8bSmrg	rpath | xrpath)
7078f3561b8bSmrg	  # We need an absolute path.
7079f3561b8bSmrg	  case $arg in
7080f3561b8bSmrg	  [\\/]* | [A-Za-z]:[\\/]*) ;;
7081f3561b8bSmrg	  *)
7082f3561b8bSmrg	    func_fatal_error "only absolute run-paths are allowed"
7083f3561b8bSmrg	    ;;
7084f3561b8bSmrg	  esac
70856257f37dSmrg	  if test rpath = "$prev"; then
7086f3561b8bSmrg	    case "$rpath " in
7087f3561b8bSmrg	    *" $arg "*) ;;
7088bd304fc0Smrg	    *) func_append rpath " $arg" ;;
7089f3561b8bSmrg	    esac
7090fc5a983dSmrg	  else
7091f3561b8bSmrg	    case "$xrpath " in
7092f3561b8bSmrg	    *" $arg "*) ;;
7093bd304fc0Smrg	    *) func_append xrpath " $arg" ;;
7094f3561b8bSmrg	    esac
7095fc5a983dSmrg	  fi
7096f3561b8bSmrg	  prev=
7097f3561b8bSmrg	  continue
7098f3561b8bSmrg	  ;;
7099f3561b8bSmrg	shrext)
71006257f37dSmrg	  shrext_cmds=$arg
7101f3561b8bSmrg	  prev=
7102f3561b8bSmrg	  continue
7103f3561b8bSmrg	  ;;
7104f3561b8bSmrg	weak)
7105bd304fc0Smrg	  func_append weak_libs " $arg"
7106f3561b8bSmrg	  prev=
7107f3561b8bSmrg	  continue
7108f3561b8bSmrg	  ;;
7109d422ce2eSmrg	xassembler)
7110d422ce2eSmrg	  func_append compiler_flags " -Xassembler $qarg"
7111d422ce2eSmrg	  prev=
7112d422ce2eSmrg	  func_append compile_command " -Xassembler $qarg"
7113d422ce2eSmrg	  func_append finalize_command " -Xassembler $qarg"
7114d422ce2eSmrg	  continue
7115d422ce2eSmrg	  ;;
7116f3561b8bSmrg	xcclinker)
7117bd304fc0Smrg	  func_append linker_flags " $qarg"
7118bd304fc0Smrg	  func_append compiler_flags " $qarg"
7119f3561b8bSmrg	  prev=
7120f3561b8bSmrg	  func_append compile_command " $qarg"
7121f3561b8bSmrg	  func_append finalize_command " $qarg"
7122f3561b8bSmrg	  continue
7123f3561b8bSmrg	  ;;
7124f3561b8bSmrg	xcompiler)
7125bd304fc0Smrg	  func_append compiler_flags " $qarg"
7126f3561b8bSmrg	  prev=
7127f3561b8bSmrg	  func_append compile_command " $qarg"
7128f3561b8bSmrg	  func_append finalize_command " $qarg"
7129f3561b8bSmrg	  continue
7130f3561b8bSmrg	  ;;
7131f3561b8bSmrg	xlinker)
7132bd304fc0Smrg	  func_append linker_flags " $qarg"
7133bd304fc0Smrg	  func_append compiler_flags " $wl$qarg"
7134f3561b8bSmrg	  prev=
7135f3561b8bSmrg	  func_append compile_command " $wl$qarg"
7136f3561b8bSmrg	  func_append finalize_command " $wl$qarg"
7137f3561b8bSmrg	  continue
7138f3561b8bSmrg	  ;;
7139f3561b8bSmrg	*)
7140f3561b8bSmrg	  eval "$prev=\"\$arg\""
7141f3561b8bSmrg	  prev=
7142f3561b8bSmrg	  continue
7143f3561b8bSmrg	  ;;
7144fc5a983dSmrg	esac
7145f3561b8bSmrg      fi # test -n "$prev"
7146fc5a983dSmrg
71476257f37dSmrg      prevarg=$arg
7148fc5a983dSmrg
7149f3561b8bSmrg      case $arg in
7150f3561b8bSmrg      -all-static)
7151f3561b8bSmrg	if test -n "$link_static_flag"; then
7152f3561b8bSmrg	  # See comment for -static flag below, for more details.
7153f3561b8bSmrg	  func_append compile_command " $link_static_flag"
7154f3561b8bSmrg	  func_append finalize_command " $link_static_flag"
7155f3561b8bSmrg	fi
7156f3561b8bSmrg	continue
7157f3561b8bSmrg	;;
7158fc5a983dSmrg
7159f3561b8bSmrg      -allow-undefined)
7160f3561b8bSmrg	# FIXME: remove this flag sometime in the future.
71616257f37dSmrg	func_fatal_error "'-allow-undefined' must not be used because it is the default"
7162f3561b8bSmrg	;;
7163fc5a983dSmrg
7164f3561b8bSmrg      -avoid-version)
7165f3561b8bSmrg	avoid_version=yes
7166f3561b8bSmrg	continue
7167f3561b8bSmrg	;;
7168fc5a983dSmrg
7169bd304fc0Smrg      -bindir)
7170bd304fc0Smrg	prev=bindir
7171bd304fc0Smrg	continue
7172bd304fc0Smrg	;;
7173bd304fc0Smrg
7174f3561b8bSmrg      -dlopen)
7175f3561b8bSmrg	prev=dlfiles
7176f3561b8bSmrg	continue
7177f3561b8bSmrg	;;
7178fc5a983dSmrg
7179f3561b8bSmrg      -dlpreopen)
7180f3561b8bSmrg	prev=dlprefiles
7181f3561b8bSmrg	continue
7182f3561b8bSmrg	;;
7183fc5a983dSmrg
7184f3561b8bSmrg      -export-dynamic)
7185f3561b8bSmrg	export_dynamic=yes
7186f3561b8bSmrg	continue
7187f3561b8bSmrg	;;
7188fc5a983dSmrg
7189f3561b8bSmrg      -export-symbols | -export-symbols-regex)
7190f3561b8bSmrg	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
7191f3561b8bSmrg	  func_fatal_error "more than one -exported-symbols argument is not allowed"
7192f3561b8bSmrg	fi
71936257f37dSmrg	if test X-export-symbols = "X$arg"; then
7194f3561b8bSmrg	  prev=expsyms
7195f3561b8bSmrg	else
7196f3561b8bSmrg	  prev=expsyms_regex
7197f3561b8bSmrg	fi
7198f3561b8bSmrg	continue
7199f3561b8bSmrg	;;
7200fc5a983dSmrg
7201f3561b8bSmrg      -framework)
7202f3561b8bSmrg	prev=framework
7203f3561b8bSmrg	continue
7204f3561b8bSmrg	;;
7205fc5a983dSmrg
7206f3561b8bSmrg      -inst-prefix-dir)
7207f3561b8bSmrg	prev=inst_prefix
7208f3561b8bSmrg	continue
7209f3561b8bSmrg	;;
7210fc5a983dSmrg
7211f3561b8bSmrg      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
7212f3561b8bSmrg      # so, if we see these flags be careful not to treat them like -L
7213f3561b8bSmrg      -L[A-Z][A-Z]*:*)
7214f3561b8bSmrg	case $with_gcc/$host in
7215f3561b8bSmrg	no/*-*-irix* | /*-*-irix*)
7216f3561b8bSmrg	  func_append compile_command " $arg"
7217f3561b8bSmrg	  func_append finalize_command " $arg"
7218f3561b8bSmrg	  ;;
7219f3561b8bSmrg	esac
7220f3561b8bSmrg	continue
7221f3561b8bSmrg	;;
7222fc5a983dSmrg
7223f3561b8bSmrg      -L*)
7224bd304fc0Smrg	func_stripname "-L" '' "$arg"
7225bd304fc0Smrg	if test -z "$func_stripname_result"; then
7226f3561b8bSmrg	  if test "$#" -gt 0; then
72276257f37dSmrg	    func_fatal_error "require no space between '-L' and '$1'"
7228f3561b8bSmrg	  else
72296257f37dSmrg	    func_fatal_error "need path for '-L' option"
7230f3561b8bSmrg	  fi
7231f3561b8bSmrg	fi
7232bd304fc0Smrg	func_resolve_sysroot "$func_stripname_result"
7233bd304fc0Smrg	dir=$func_resolve_sysroot_result
7234f3561b8bSmrg	# We need an absolute path.
7235f3561b8bSmrg	case $dir in
7236f3561b8bSmrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
7237f3561b8bSmrg	*)
7238f3561b8bSmrg	  absdir=`cd "$dir" && pwd`
7239f3561b8bSmrg	  test -z "$absdir" && \
72406257f37dSmrg	    func_fatal_error "cannot determine absolute directory name of '$dir'"
72416257f37dSmrg	  dir=$absdir
7242f3561b8bSmrg	  ;;
7243f3561b8bSmrg	esac
7244f3561b8bSmrg	case "$deplibs " in
7245bd304fc0Smrg	*" -L$dir "* | *" $arg "*)
7246bd304fc0Smrg	  # Will only happen for absolute or sysroot arguments
7247bd304fc0Smrg	  ;;
7248f3561b8bSmrg	*)
7249bd304fc0Smrg	  # Preserve sysroot, but never include relative directories
7250bd304fc0Smrg	  case $dir in
7251bd304fc0Smrg	    [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
7252bd304fc0Smrg	    *) func_append deplibs " -L$dir" ;;
7253bd304fc0Smrg	  esac
7254bd304fc0Smrg	  func_append lib_search_path " $dir"
7255f3561b8bSmrg	  ;;
7256f3561b8bSmrg	esac
7257f3561b8bSmrg	case $host in
7258f3561b8bSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
7259bd304fc0Smrg	  testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
7260f3561b8bSmrg	  case :$dllsearchpath: in
7261f3561b8bSmrg	  *":$dir:"*) ;;
7262f3561b8bSmrg	  ::) dllsearchpath=$dir;;
7263bd304fc0Smrg	  *) func_append dllsearchpath ":$dir";;
7264f3561b8bSmrg	  esac
7265f3561b8bSmrg	  case :$dllsearchpath: in
7266f3561b8bSmrg	  *":$testbindir:"*) ;;
7267f3561b8bSmrg	  ::) dllsearchpath=$testbindir;;
7268bd304fc0Smrg	  *) func_append dllsearchpath ":$testbindir";;
7269f3561b8bSmrg	  esac
7270f3561b8bSmrg	  ;;
7271f3561b8bSmrg	esac
7272f3561b8bSmrg	continue
7273f3561b8bSmrg	;;
7274fc5a983dSmrg
7275f3561b8bSmrg      -l*)
72766257f37dSmrg	if test X-lc = "X$arg" || test X-lm = "X$arg"; then
7277f3561b8bSmrg	  case $host in
7278bd304fc0Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
7279f3561b8bSmrg	    # These systems don't actually have a C or math library (as such)
7280f3561b8bSmrg	    continue
7281f3561b8bSmrg	    ;;
7282f3561b8bSmrg	  *-*-os2*)
7283f3561b8bSmrg	    # These systems don't actually have a C library (as such)
72846257f37dSmrg	    test X-lc = "X$arg" && continue
7285f3561b8bSmrg	    ;;
7286d422ce2eSmrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig* | *-*-midnightbsd*)
7287f3561b8bSmrg	    # Do not include libc due to us having libc/libc_r.
72886257f37dSmrg	    test X-lc = "X$arg" && continue
7289f3561b8bSmrg	    ;;
7290f3561b8bSmrg	  *-*-rhapsody* | *-*-darwin1.[012])
7291f3561b8bSmrg	    # Rhapsody C and math libraries are in the System framework
7292bd304fc0Smrg	    func_append deplibs " System.ltframework"
7293f3561b8bSmrg	    continue
7294f3561b8bSmrg	    ;;
7295f3561b8bSmrg	  *-*-sco3.2v5* | *-*-sco5v6*)
7296f3561b8bSmrg	    # Causes problems with __ctype
72976257f37dSmrg	    test X-lc = "X$arg" && continue
7298f3561b8bSmrg	    ;;
7299f3561b8bSmrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
7300f3561b8bSmrg	    # Compiler inserts libc in the correct place for threads to work
73016257f37dSmrg	    test X-lc = "X$arg" && continue
7302f3561b8bSmrg	    ;;
7303f3561b8bSmrg	  esac
73046257f37dSmrg	elif test X-lc_r = "X$arg"; then
7305f3561b8bSmrg	 case $host in
7306d422ce2eSmrg	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig* | *-*-midnightbsd*)
7307f3561b8bSmrg	   # Do not include libc_r directly, use -pthread flag.
7308f3561b8bSmrg	   continue
7309f3561b8bSmrg	   ;;
7310f3561b8bSmrg	 esac
7311f3561b8bSmrg	fi
7312bd304fc0Smrg	func_append deplibs " $arg"
7313f3561b8bSmrg	continue
7314f3561b8bSmrg	;;
7315fc5a983dSmrg
73166257f37dSmrg      -mllvm)
73176257f37dSmrg	prev=mllvm
73186257f37dSmrg	continue
73196257f37dSmrg	;;
73206257f37dSmrg
7321f3561b8bSmrg      -module)
7322f3561b8bSmrg	module=yes
7323f3561b8bSmrg	continue
7324f3561b8bSmrg	;;
7325fc5a983dSmrg
7326f3561b8bSmrg      # Tru64 UNIX uses -model [arg] to determine the layout of C++
7327f3561b8bSmrg      # classes, name mangling, and exception handling.
7328f3561b8bSmrg      # Darwin uses the -arch flag to determine output architecture.
7329bd304fc0Smrg      -model|-arch|-isysroot|--sysroot)
7330bd304fc0Smrg	func_append compiler_flags " $arg"
7331f3561b8bSmrg	func_append compile_command " $arg"
7332f3561b8bSmrg	func_append finalize_command " $arg"
7333f3561b8bSmrg	prev=xcompiler
7334f3561b8bSmrg	continue
7335f3561b8bSmrg	;;
7336d422ce2eSmrg     # Solaris ld rejects as of 11.4. Refer to Oracle bug 22985199.
7337d422ce2eSmrg     -pthread)
7338d422ce2eSmrg	case $host in
7339d422ce2eSmrg	  *solaris2*) ;;
7340d422ce2eSmrg	  *)
7341d422ce2eSmrg	    case "$new_inherited_linker_flags " in
7342d422ce2eSmrg	        *" $arg "*) ;;
7343d422ce2eSmrg	        * ) func_append new_inherited_linker_flags " $arg" ;;
7344d422ce2eSmrg	    esac
7345d422ce2eSmrg	  ;;
7346d422ce2eSmrg	esac
7347d422ce2eSmrg	continue
7348d422ce2eSmrg	;;
7349d422ce2eSmrg      -mt|-mthreads|-kthread|-Kthread|-pthreads|--thread-safe \
7350bd304fc0Smrg      |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
7351bd304fc0Smrg	func_append compiler_flags " $arg"
7352f3561b8bSmrg	func_append compile_command " $arg"
7353f3561b8bSmrg	func_append finalize_command " $arg"
7354f3561b8bSmrg	case "$new_inherited_linker_flags " in
7355f3561b8bSmrg	    *" $arg "*) ;;
7356bd304fc0Smrg	    * ) func_append new_inherited_linker_flags " $arg" ;;
7357f3561b8bSmrg	esac
7358f3561b8bSmrg	continue
7359f3561b8bSmrg	;;
7360fc5a983dSmrg
7361f3561b8bSmrg      -multi_module)
73626257f37dSmrg	single_module=$wl-multi_module
7363f3561b8bSmrg	continue
7364f3561b8bSmrg	;;
7365fc5a983dSmrg
7366f3561b8bSmrg      -no-fast-install)
7367f3561b8bSmrg	fast_install=no
7368f3561b8bSmrg	continue
7369f3561b8bSmrg	;;
7370fc5a983dSmrg
7371f3561b8bSmrg      -no-install)
7372f3561b8bSmrg	case $host in
7373f3561b8bSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
7374f3561b8bSmrg	  # The PATH hackery in wrapper scripts is required on Windows
7375f3561b8bSmrg	  # and Darwin in order for the loader to find any dlls it needs.
73766257f37dSmrg	  func_warning "'-no-install' is ignored for $host"
73776257f37dSmrg	  func_warning "assuming '-no-fast-install' instead"
7378f3561b8bSmrg	  fast_install=no
7379f3561b8bSmrg	  ;;
7380f3561b8bSmrg	*) no_install=yes ;;
7381f3561b8bSmrg	esac
7382f3561b8bSmrg	continue
7383f3561b8bSmrg	;;
7384fc5a983dSmrg
7385f3561b8bSmrg      -no-undefined)
7386f3561b8bSmrg	allow_undefined=no
7387f3561b8bSmrg	continue
7388f3561b8bSmrg	;;
7389fc5a983dSmrg
7390f3561b8bSmrg      -objectlist)
7391f3561b8bSmrg	prev=objectlist
7392f3561b8bSmrg	continue
7393f3561b8bSmrg	;;
7394fc5a983dSmrg
73956257f37dSmrg      -os2dllname)
73966257f37dSmrg	prev=os2dllname
73976257f37dSmrg	continue
73986257f37dSmrg	;;
73996257f37dSmrg
7400f3561b8bSmrg      -o) prev=output ;;
7401fc5a983dSmrg
7402f3561b8bSmrg      -precious-files-regex)
7403f3561b8bSmrg	prev=precious_regex
7404f3561b8bSmrg	continue
7405f3561b8bSmrg	;;
7406fc5a983dSmrg
7407f3561b8bSmrg      -release)
7408f3561b8bSmrg	prev=release
7409f3561b8bSmrg	continue
7410f3561b8bSmrg	;;
7411fc5a983dSmrg
7412f3561b8bSmrg      -rpath)
7413f3561b8bSmrg	prev=rpath
7414f3561b8bSmrg	continue
7415f3561b8bSmrg	;;
7416fc5a983dSmrg
7417f3561b8bSmrg      -R)
7418f3561b8bSmrg	prev=xrpath
7419f3561b8bSmrg	continue
7420f3561b8bSmrg	;;
7421fc5a983dSmrg
7422f3561b8bSmrg      -R*)
7423f3561b8bSmrg	func_stripname '-R' '' "$arg"
7424f3561b8bSmrg	dir=$func_stripname_result
7425f3561b8bSmrg	# We need an absolute path.
7426f3561b8bSmrg	case $dir in
7427f3561b8bSmrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
7428bd304fc0Smrg	=*)
7429bd304fc0Smrg	  func_stripname '=' '' "$dir"
7430bd304fc0Smrg	  dir=$lt_sysroot$func_stripname_result
7431bd304fc0Smrg	  ;;
7432f3561b8bSmrg	*)
7433f3561b8bSmrg	  func_fatal_error "only absolute run-paths are allowed"
7434f3561b8bSmrg	  ;;
7435f3561b8bSmrg	esac
7436f3561b8bSmrg	case "$xrpath " in
7437f3561b8bSmrg	*" $dir "*) ;;
7438bd304fc0Smrg	*) func_append xrpath " $dir" ;;
7439f3561b8bSmrg	esac
7440f3561b8bSmrg	continue
7441f3561b8bSmrg	;;
7442fc5a983dSmrg
7443f3561b8bSmrg      -shared)
7444f3561b8bSmrg	# The effects of -shared are defined in a previous loop.
7445f3561b8bSmrg	continue
7446f3561b8bSmrg	;;
7447fc5a983dSmrg
7448f3561b8bSmrg      -shrext)
7449f3561b8bSmrg	prev=shrext
7450f3561b8bSmrg	continue
7451f3561b8bSmrg	;;
7452fc5a983dSmrg
7453f3561b8bSmrg      -static | -static-libtool-libs)
7454f3561b8bSmrg	# The effects of -static are defined in a previous loop.
7455f3561b8bSmrg	# We used to do the same as -all-static on platforms that
7456f3561b8bSmrg	# didn't have a PIC flag, but the assumption that the effects
7457f3561b8bSmrg	# would be equivalent was wrong.  It would break on at least
7458f3561b8bSmrg	# Digital Unix and AIX.
7459f3561b8bSmrg	continue
7460f3561b8bSmrg	;;
7461fc5a983dSmrg
7462f3561b8bSmrg      -thread-safe)
7463f3561b8bSmrg	thread_safe=yes
7464f3561b8bSmrg	continue
7465f3561b8bSmrg	;;
7466fc5a983dSmrg
7467f3561b8bSmrg      -version-info)
7468f3561b8bSmrg	prev=vinfo
7469f3561b8bSmrg	continue
7470f3561b8bSmrg	;;
7471fc5a983dSmrg
7472f3561b8bSmrg      -version-number)
7473f3561b8bSmrg	prev=vinfo
7474f3561b8bSmrg	vinfo_number=yes
7475f3561b8bSmrg	continue
7476f3561b8bSmrg	;;
7477fc5a983dSmrg
7478f3561b8bSmrg      -weak)
7479f3561b8bSmrg        prev=weak
7480f3561b8bSmrg	continue
7481f3561b8bSmrg	;;
7482fc5a983dSmrg
7483f3561b8bSmrg      -Wc,*)
7484f3561b8bSmrg	func_stripname '-Wc,' '' "$arg"
7485f3561b8bSmrg	args=$func_stripname_result
7486f3561b8bSmrg	arg=
74876257f37dSmrg	save_ifs=$IFS; IFS=,
7488f3561b8bSmrg	for flag in $args; do
74896257f37dSmrg	  IFS=$save_ifs
7490d422ce2eSmrg          func_quote_arg pretty "$flag"
7491d422ce2eSmrg	  func_append arg " $func_quote_arg_result"
7492d422ce2eSmrg	  func_append compiler_flags " $func_quote_arg_result"
7493f3561b8bSmrg	done
74946257f37dSmrg	IFS=$save_ifs
7495f3561b8bSmrg	func_stripname ' ' '' "$arg"
7496f3561b8bSmrg	arg=$func_stripname_result
7497f3561b8bSmrg	;;
7498fc5a983dSmrg
7499f3561b8bSmrg      -Wl,*)
7500f3561b8bSmrg	func_stripname '-Wl,' '' "$arg"
7501f3561b8bSmrg	args=$func_stripname_result
7502f3561b8bSmrg	arg=
75036257f37dSmrg	save_ifs=$IFS; IFS=,
7504f3561b8bSmrg	for flag in $args; do
75056257f37dSmrg	  IFS=$save_ifs
7506d422ce2eSmrg          func_quote_arg pretty "$flag"
7507d422ce2eSmrg	  func_append arg " $wl$func_quote_arg_result"
7508d422ce2eSmrg	  func_append compiler_flags " $wl$func_quote_arg_result"
7509d422ce2eSmrg	  func_append linker_flags " $func_quote_arg_result"
7510f3561b8bSmrg	done
75116257f37dSmrg	IFS=$save_ifs
7512f3561b8bSmrg	func_stripname ' ' '' "$arg"
7513f3561b8bSmrg	arg=$func_stripname_result
7514f3561b8bSmrg	;;
7515fc5a983dSmrg
7516d422ce2eSmrg      -Xassembler)
7517d422ce2eSmrg        prev=xassembler
7518d422ce2eSmrg        continue
7519d422ce2eSmrg        ;;
7520d422ce2eSmrg
7521f3561b8bSmrg      -Xcompiler)
7522f3561b8bSmrg	prev=xcompiler
7523f3561b8bSmrg	continue
7524f3561b8bSmrg	;;
7525fc5a983dSmrg
7526f3561b8bSmrg      -Xlinker)
7527f3561b8bSmrg	prev=xlinker
7528f3561b8bSmrg	continue
7529f3561b8bSmrg	;;
7530fc5a983dSmrg
7531f3561b8bSmrg      -XCClinker)
7532f3561b8bSmrg	prev=xcclinker
7533f3561b8bSmrg	continue
7534f3561b8bSmrg	;;
7535fc5a983dSmrg
7536f3561b8bSmrg      # -msg_* for osf cc
7537f3561b8bSmrg      -msg_*)
7538d422ce2eSmrg	func_quote_arg pretty "$arg"
7539d422ce2eSmrg	arg=$func_quote_arg_result
7540f3561b8bSmrg	;;
7541fc5a983dSmrg
7542bd304fc0Smrg      # Flags to be passed through unchanged, with rationale:
7543bd304fc0Smrg      # -64, -mips[0-9]      enable 64-bit mode for the SGI compiler
7544bd304fc0Smrg      # -r[0-9][0-9]*        specify processor for the SGI compiler
7545bd304fc0Smrg      # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
7546bd304fc0Smrg      # +DA*, +DD*           enable 64-bit mode for the HP compiler
7547bd304fc0Smrg      # -q*                  compiler args for the IBM compiler
7548bd304fc0Smrg      # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
7549bd304fc0Smrg      # -F/path              path to uninstalled frameworks, gcc on darwin
7550bd304fc0Smrg      # -p, -pg, --coverage, -fprofile-*  profiling flags for GCC
75516257f37dSmrg      # -fstack-protector*   stack protector flags for GCC
7552bd304fc0Smrg      # @file                GCC response files
7553bd304fc0Smrg      # -tp=*                Portland pgcc target processor selection
7554bd304fc0Smrg      # --sysroot=*          for sysroot support
75556257f37dSmrg      # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
7556d422ce2eSmrg      # -specs=*             GCC specs files
75576257f37dSmrg      # -stdlib=*            select c++ std lib with clang
7558d422ce2eSmrg      # -fsanitize=*         Clang/GCC memory and address sanitizer
7559d422ce2eSmrg      # -fuse-ld=*           Linker select flags for GCC
7560d422ce2eSmrg      # -Wa,*                Pass flags directly to the assembler
7561f3561b8bSmrg      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
7562bd304fc0Smrg      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
7563d422ce2eSmrg      -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \
7564d422ce2eSmrg      -specs=*|-fsanitize=*|-fuse-ld=*|-Wa,*)
7565d422ce2eSmrg        func_quote_arg pretty "$arg"
7566d422ce2eSmrg	arg=$func_quote_arg_result
7567f3561b8bSmrg        func_append compile_command " $arg"
7568f3561b8bSmrg        func_append finalize_command " $arg"
7569bd304fc0Smrg        func_append compiler_flags " $arg"
7570f3561b8bSmrg        continue
7571f3561b8bSmrg        ;;
7572fc5a983dSmrg
75736257f37dSmrg      -Z*)
75746257f37dSmrg        if test os2 = "`expr $host : '.*\(os2\)'`"; then
75756257f37dSmrg          # OS/2 uses -Zxxx to specify OS/2-specific options
75766257f37dSmrg	  compiler_flags="$compiler_flags $arg"
75776257f37dSmrg	  func_append compile_command " $arg"
75786257f37dSmrg	  func_append finalize_command " $arg"
75796257f37dSmrg	  case $arg in
75806257f37dSmrg	  -Zlinker | -Zstack)
75816257f37dSmrg	    prev=xcompiler
75826257f37dSmrg	    ;;
75836257f37dSmrg	  esac
75846257f37dSmrg	  continue
75856257f37dSmrg        else
75866257f37dSmrg	  # Otherwise treat like 'Some other compiler flag' below
7587d422ce2eSmrg	  func_quote_arg pretty "$arg"
7588d422ce2eSmrg	  arg=$func_quote_arg_result
75896257f37dSmrg        fi
75906257f37dSmrg	;;
75916257f37dSmrg
7592f3561b8bSmrg      # Some other compiler flag.
7593f3561b8bSmrg      -* | +*)
7594d422ce2eSmrg        func_quote_arg pretty "$arg"
7595d422ce2eSmrg	arg=$func_quote_arg_result
7596f3561b8bSmrg	;;
7597fc5a983dSmrg
7598f3561b8bSmrg      *.$objext)
7599f3561b8bSmrg	# A standard object.
7600bd304fc0Smrg	func_append objs " $arg"
7601f3561b8bSmrg	;;
7602fc5a983dSmrg
7603f3561b8bSmrg      *.lo)
7604f3561b8bSmrg	# A libtool-controlled object.
7605fc5a983dSmrg
7606f3561b8bSmrg	# Check to see that this really is a libtool object.
7607f3561b8bSmrg	if func_lalib_unsafe_p "$arg"; then
7608f3561b8bSmrg	  pic_object=
7609f3561b8bSmrg	  non_pic_object=
7610fc5a983dSmrg
7611f3561b8bSmrg	  # Read the .lo file
7612f3561b8bSmrg	  func_source "$arg"
7613fc5a983dSmrg
7614f3561b8bSmrg	  if test -z "$pic_object" ||
7615f3561b8bSmrg	     test -z "$non_pic_object" ||
76166257f37dSmrg	     test none = "$pic_object" &&
76176257f37dSmrg	     test none = "$non_pic_object"; then
76186257f37dSmrg	    func_fatal_error "cannot find name of object for '$arg'"
7619f3561b8bSmrg	  fi
7620fc5a983dSmrg
7621f3561b8bSmrg	  # Extract subdirectory from the argument.
7622f3561b8bSmrg	  func_dirname "$arg" "/" ""
76236257f37dSmrg	  xdir=$func_dirname_result
7624fc5a983dSmrg
76256257f37dSmrg	  test none = "$pic_object" || {
7626f3561b8bSmrg	    # Prepend the subdirectory the object is found in.
76276257f37dSmrg	    pic_object=$xdir$pic_object
7628fc5a983dSmrg
76296257f37dSmrg	    if test dlfiles = "$prev"; then
76306257f37dSmrg	      if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
7631bd304fc0Smrg		func_append dlfiles " $pic_object"
7632f3561b8bSmrg		prev=
7633f3561b8bSmrg		continue
7634f3561b8bSmrg	      else
7635f3561b8bSmrg		# If libtool objects are unsupported, then we need to preload.
7636f3561b8bSmrg		prev=dlprefiles
7637f3561b8bSmrg	      fi
7638f3561b8bSmrg	    fi
7639fc5a983dSmrg
7640f3561b8bSmrg	    # CHECK ME:  I think I busted this.  -Ossama
76416257f37dSmrg	    if test dlprefiles = "$prev"; then
7642f3561b8bSmrg	      # Preload the old-style object.
7643bd304fc0Smrg	      func_append dlprefiles " $pic_object"
7644f3561b8bSmrg	      prev=
7645f3561b8bSmrg	    fi
7646fc5a983dSmrg
7647f3561b8bSmrg	    # A PIC object.
7648f3561b8bSmrg	    func_append libobjs " $pic_object"
76496257f37dSmrg	    arg=$pic_object
76506257f37dSmrg	  }
7651fc5a983dSmrg
7652f3561b8bSmrg	  # Non-PIC object.
76536257f37dSmrg	  if test none != "$non_pic_object"; then
7654f3561b8bSmrg	    # Prepend the subdirectory the object is found in.
76556257f37dSmrg	    non_pic_object=$xdir$non_pic_object
7656fc5a983dSmrg
7657f3561b8bSmrg	    # A standard non-PIC object
7658f3561b8bSmrg	    func_append non_pic_objects " $non_pic_object"
76596257f37dSmrg	    if test -z "$pic_object" || test none = "$pic_object"; then
76606257f37dSmrg	      arg=$non_pic_object
7661f3561b8bSmrg	    fi
7662f3561b8bSmrg	  else
7663f3561b8bSmrg	    # If the PIC object exists, use it instead.
7664f3561b8bSmrg	    # $xdir was prepended to $pic_object above.
76656257f37dSmrg	    non_pic_object=$pic_object
7666f3561b8bSmrg	    func_append non_pic_objects " $non_pic_object"
7667f3561b8bSmrg	  fi
7668f3561b8bSmrg	else
7669f3561b8bSmrg	  # Only an error if not doing a dry-run.
7670f3561b8bSmrg	  if $opt_dry_run; then
7671f3561b8bSmrg	    # Extract subdirectory from the argument.
7672f3561b8bSmrg	    func_dirname "$arg" "/" ""
76736257f37dSmrg	    xdir=$func_dirname_result
7674f3561b8bSmrg
7675f3561b8bSmrg	    func_lo2o "$arg"
7676f3561b8bSmrg	    pic_object=$xdir$objdir/$func_lo2o_result
7677f3561b8bSmrg	    non_pic_object=$xdir$func_lo2o_result
7678f3561b8bSmrg	    func_append libobjs " $pic_object"
7679f3561b8bSmrg	    func_append non_pic_objects " $non_pic_object"
7680f3561b8bSmrg	  else
76816257f37dSmrg	    func_fatal_error "'$arg' is not a valid libtool object"
7682f3561b8bSmrg	  fi
7683f3561b8bSmrg	fi
7684f3561b8bSmrg	;;
7685fc5a983dSmrg
7686f3561b8bSmrg      *.$libext)
7687f3561b8bSmrg	# An archive.
7688bd304fc0Smrg	func_append deplibs " $arg"
7689bd304fc0Smrg	func_append old_deplibs " $arg"
7690f3561b8bSmrg	continue
7691f3561b8bSmrg	;;
7692fc5a983dSmrg
7693f3561b8bSmrg      *.la)
7694f3561b8bSmrg	# A libtool-controlled library.
7695fc5a983dSmrg
7696bd304fc0Smrg	func_resolve_sysroot "$arg"
76976257f37dSmrg	if test dlfiles = "$prev"; then
7698f3561b8bSmrg	  # This library was specified with -dlopen.
7699bd304fc0Smrg	  func_append dlfiles " $func_resolve_sysroot_result"
7700f3561b8bSmrg	  prev=
77016257f37dSmrg	elif test dlprefiles = "$prev"; then
7702f3561b8bSmrg	  # The library was specified with -dlpreopen.
7703bd304fc0Smrg	  func_append dlprefiles " $func_resolve_sysroot_result"
7704f3561b8bSmrg	  prev=
7705f3561b8bSmrg	else
7706bd304fc0Smrg	  func_append deplibs " $func_resolve_sysroot_result"
7707f3561b8bSmrg	fi
7708f3561b8bSmrg	continue
7709f3561b8bSmrg	;;
7710fc5a983dSmrg
7711f3561b8bSmrg      # Some other compiler argument.
7712f3561b8bSmrg      *)
7713f3561b8bSmrg	# Unknown arguments in both finalize_command and compile_command need
7714f3561b8bSmrg	# to be aesthetically quoted because they are evaled later.
7715d422ce2eSmrg	func_quote_arg pretty "$arg"
7716d422ce2eSmrg	arg=$func_quote_arg_result
7717f3561b8bSmrg	;;
7718f3561b8bSmrg      esac # arg
7719f3561b8bSmrg
7720f3561b8bSmrg      # Now actually substitute the argument into the commands.
7721f3561b8bSmrg      if test -n "$arg"; then
7722f3561b8bSmrg	func_append compile_command " $arg"
7723f3561b8bSmrg	func_append finalize_command " $arg"
7724f3561b8bSmrg      fi
7725f3561b8bSmrg    done # argument parsing loop
7726f3561b8bSmrg
7727f3561b8bSmrg    test -n "$prev" && \
77286257f37dSmrg      func_fatal_help "the '$prevarg' option requires an argument"
7729f3561b8bSmrg
77306257f37dSmrg    if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then
7731f3561b8bSmrg      eval arg=\"$export_dynamic_flag_spec\"
7732f3561b8bSmrg      func_append compile_command " $arg"
7733f3561b8bSmrg      func_append finalize_command " $arg"
7734f3561b8bSmrg    fi
7735f3561b8bSmrg
7736f3561b8bSmrg    oldlibs=
7737f3561b8bSmrg    # calculate the name of the file, without its directory
7738f3561b8bSmrg    func_basename "$output"
77396257f37dSmrg    outputname=$func_basename_result
77406257f37dSmrg    libobjs_save=$libobjs
7741f3561b8bSmrg
7742f3561b8bSmrg    if test -n "$shlibpath_var"; then
7743f3561b8bSmrg      # get the directories listed in $shlibpath_var
77446257f37dSmrg      eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\`
7745f3561b8bSmrg    else
7746f3561b8bSmrg      shlib_search_path=
7747f3561b8bSmrg    fi
7748f3561b8bSmrg    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
7749f3561b8bSmrg    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
7750f3561b8bSmrg
77516257f37dSmrg    # Definition is injected by LT_CONFIG during libtool generation.
77526257f37dSmrg    func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH"
77536257f37dSmrg
7754f3561b8bSmrg    func_dirname "$output" "/" ""
77556257f37dSmrg    output_objdir=$func_dirname_result$objdir
7756bd304fc0Smrg    func_to_tool_file "$output_objdir/"
7757bd304fc0Smrg    tool_output_objdir=$func_to_tool_file_result
7758f3561b8bSmrg    # Create the object directory.
7759f3561b8bSmrg    func_mkdir_p "$output_objdir"
7760f3561b8bSmrg
7761f3561b8bSmrg    # Determine the type of output
7762f3561b8bSmrg    case $output in
7763f3561b8bSmrg    "")
7764f3561b8bSmrg      func_fatal_help "you must specify an output file"
7765f3561b8bSmrg      ;;
7766f3561b8bSmrg    *.$libext) linkmode=oldlib ;;
7767f3561b8bSmrg    *.lo | *.$objext) linkmode=obj ;;
7768f3561b8bSmrg    *.la) linkmode=lib ;;
7769f3561b8bSmrg    *) linkmode=prog ;; # Anything else should be a program.
7770f3561b8bSmrg    esac
7771f3561b8bSmrg
7772f3561b8bSmrg    specialdeplibs=
7773f3561b8bSmrg
7774f3561b8bSmrg    libs=
7775f3561b8bSmrg    # Find all interdependent deplibs by searching for libraries
7776f3561b8bSmrg    # that are linked more than once (e.g. -la -lb -la)
7777f3561b8bSmrg    for deplib in $deplibs; do
77786257f37dSmrg      if $opt_preserve_dup_deps; then
7779f3561b8bSmrg	case "$libs " in
7780bd304fc0Smrg	*" $deplib "*) func_append specialdeplibs " $deplib" ;;
7781f3561b8bSmrg	esac
7782f3561b8bSmrg      fi
7783bd304fc0Smrg      func_append libs " $deplib"
7784f3561b8bSmrg    done
7785f3561b8bSmrg
77866257f37dSmrg    if test lib = "$linkmode"; then
7787f3561b8bSmrg      libs="$predeps $libs $compiler_lib_search_path $postdeps"
7788f3561b8bSmrg
7789f3561b8bSmrg      # Compute libraries that are listed more than once in $predeps
7790f3561b8bSmrg      # $postdeps and mark them as special (i.e., whose duplicates are
7791f3561b8bSmrg      # not to be eliminated).
7792f3561b8bSmrg      pre_post_deps=
7793f3561b8bSmrg      if $opt_duplicate_compiler_generated_deps; then
7794f3561b8bSmrg	for pre_post_dep in $predeps $postdeps; do
7795f3561b8bSmrg	  case "$pre_post_deps " in
7796bd304fc0Smrg	  *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
7797f3561b8bSmrg	  esac
7798bd304fc0Smrg	  func_append pre_post_deps " $pre_post_dep"
7799f3561b8bSmrg	done
7800f3561b8bSmrg      fi
7801f3561b8bSmrg      pre_post_deps=
7802f3561b8bSmrg    fi
7803f3561b8bSmrg
7804f3561b8bSmrg    deplibs=
7805f3561b8bSmrg    newdependency_libs=
7806f3561b8bSmrg    newlib_search_path=
7807f3561b8bSmrg    need_relink=no # whether we're linking any uninstalled libtool libraries
7808f3561b8bSmrg    notinst_deplibs= # not-installed libtool libraries
7809f3561b8bSmrg    notinst_path= # paths that contain not-installed libtool libraries
7810f3561b8bSmrg
7811f3561b8bSmrg    case $linkmode in
7812f3561b8bSmrg    lib)
7813f3561b8bSmrg	passes="conv dlpreopen link"
7814f3561b8bSmrg	for file in $dlfiles $dlprefiles; do
7815f3561b8bSmrg	  case $file in
7816f3561b8bSmrg	  *.la) ;;
7817f3561b8bSmrg	  *)
78186257f37dSmrg	    func_fatal_help "libraries can '-dlopen' only libtool libraries: $file"
7819f3561b8bSmrg	    ;;
7820f3561b8bSmrg	  esac
7821f3561b8bSmrg	done
7822f3561b8bSmrg	;;
7823f3561b8bSmrg    prog)
7824f3561b8bSmrg	compile_deplibs=
7825f3561b8bSmrg	finalize_deplibs=
78266257f37dSmrg	alldeplibs=false
7827f3561b8bSmrg	newdlfiles=
7828f3561b8bSmrg	newdlprefiles=
7829f3561b8bSmrg	passes="conv scan dlopen dlpreopen link"
7830f3561b8bSmrg	;;
7831f3561b8bSmrg    *)  passes="conv"
7832f3561b8bSmrg	;;
7833f3561b8bSmrg    esac
7834f3561b8bSmrg
7835f3561b8bSmrg    for pass in $passes; do
7836f3561b8bSmrg      # The preopen pass in lib mode reverses $deplibs; put it back here
7837f3561b8bSmrg      # so that -L comes before libs that need it for instance...
78386257f37dSmrg      if test lib,link = "$linkmode,$pass"; then
7839f3561b8bSmrg	## FIXME: Find the place where the list is rebuilt in the wrong
7840f3561b8bSmrg	##        order, and fix it there properly
7841f3561b8bSmrg        tmp_deplibs=
7842f3561b8bSmrg	for deplib in $deplibs; do
7843f3561b8bSmrg	  tmp_deplibs="$deplib $tmp_deplibs"
7844f3561b8bSmrg	done
78456257f37dSmrg	deplibs=$tmp_deplibs
7846f3561b8bSmrg      fi
7847f3561b8bSmrg
78486257f37dSmrg      if test lib,link = "$linkmode,$pass" ||
78496257f37dSmrg	 test prog,scan = "$linkmode,$pass"; then
78506257f37dSmrg	libs=$deplibs
7851f3561b8bSmrg	deplibs=
7852f3561b8bSmrg      fi
78536257f37dSmrg      if test prog = "$linkmode"; then
7854f3561b8bSmrg	case $pass in
78556257f37dSmrg	dlopen) libs=$dlfiles ;;
78566257f37dSmrg	dlpreopen) libs=$dlprefiles ;;
7857bd304fc0Smrg	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
7858f3561b8bSmrg	esac
7859f3561b8bSmrg      fi
78606257f37dSmrg      if test lib,dlpreopen = "$linkmode,$pass"; then
7861f3561b8bSmrg	# Collect and forward deplibs of preopened libtool libs
7862f3561b8bSmrg	for lib in $dlprefiles; do
7863f3561b8bSmrg	  # Ignore non-libtool-libs
7864f3561b8bSmrg	  dependency_libs=
7865bd304fc0Smrg	  func_resolve_sysroot "$lib"
7866f3561b8bSmrg	  case $lib in
7867bd304fc0Smrg	  *.la)	func_source "$func_resolve_sysroot_result" ;;
7868f3561b8bSmrg	  esac
7869f3561b8bSmrg
7870f3561b8bSmrg	  # Collect preopened libtool deplibs, except any this library
7871f3561b8bSmrg	  # has declared as weak libs
7872f3561b8bSmrg	  for deplib in $dependency_libs; do
7873bd304fc0Smrg	    func_basename "$deplib"
7874bd304fc0Smrg            deplib_base=$func_basename_result
7875f3561b8bSmrg	    case " $weak_libs " in
7876f3561b8bSmrg	    *" $deplib_base "*) ;;
7877bd304fc0Smrg	    *) func_append deplibs " $deplib" ;;
7878f3561b8bSmrg	    esac
7879f3561b8bSmrg	  done
7880f3561b8bSmrg	done
78816257f37dSmrg	libs=$dlprefiles
7882f3561b8bSmrg      fi
78836257f37dSmrg      if test dlopen = "$pass"; then
7884f3561b8bSmrg	# Collect dlpreopened libraries
78856257f37dSmrg	save_deplibs=$deplibs
7886f3561b8bSmrg	deplibs=
7887f3561b8bSmrg      fi
7888f3561b8bSmrg
7889f3561b8bSmrg      for deplib in $libs; do
7890f3561b8bSmrg	lib=
78916257f37dSmrg	found=false
7892f3561b8bSmrg	case $deplib in
7893bd304fc0Smrg	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
7894bd304fc0Smrg        |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
78956257f37dSmrg	  if test prog,link = "$linkmode,$pass"; then
7896f3561b8bSmrg	    compile_deplibs="$deplib $compile_deplibs"
7897f3561b8bSmrg	    finalize_deplibs="$deplib $finalize_deplibs"
7898f3561b8bSmrg	  else
7899bd304fc0Smrg	    func_append compiler_flags " $deplib"
79006257f37dSmrg	    if test lib = "$linkmode"; then
7901f3561b8bSmrg		case "$new_inherited_linker_flags " in
7902f3561b8bSmrg		    *" $deplib "*) ;;
7903bd304fc0Smrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
7904f3561b8bSmrg		esac
7905f3561b8bSmrg	    fi
7906f3561b8bSmrg	  fi
7907f3561b8bSmrg	  continue
7908f3561b8bSmrg	  ;;
7909f3561b8bSmrg	-l*)
79106257f37dSmrg	  if test lib != "$linkmode" && test prog != "$linkmode"; then
79116257f37dSmrg	    func_warning "'-l' is ignored for archives/objects"
7912f3561b8bSmrg	    continue
7913f3561b8bSmrg	  fi
7914f3561b8bSmrg	  func_stripname '-l' '' "$deplib"
7915f3561b8bSmrg	  name=$func_stripname_result
79166257f37dSmrg	  if test lib = "$linkmode"; then
7917f3561b8bSmrg	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
7918f3561b8bSmrg	  else
7919f3561b8bSmrg	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
7920f3561b8bSmrg	  fi
7921f3561b8bSmrg	  for searchdir in $searchdirs; do
7922f3561b8bSmrg	    for search_ext in .la $std_shrext .so .a; do
7923f3561b8bSmrg	      # Search the libtool library
79246257f37dSmrg	      lib=$searchdir/lib$name$search_ext
7925f3561b8bSmrg	      if test -f "$lib"; then
79266257f37dSmrg		if test .la = "$search_ext"; then
79276257f37dSmrg		  found=:
7928f3561b8bSmrg		else
79296257f37dSmrg		  found=false
7930f3561b8bSmrg		fi
7931f3561b8bSmrg		break 2
7932f3561b8bSmrg	      fi
7933f3561b8bSmrg	    done
7934f3561b8bSmrg	  done
79356257f37dSmrg	  if $found; then
79366257f37dSmrg	    # deplib is a libtool library
7937f3561b8bSmrg	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
7938f3561b8bSmrg	    # We need to do some special things here, and not later.
79396257f37dSmrg	    if test yes = "$allow_libtool_libs_with_static_runtimes"; then
7940f3561b8bSmrg	      case " $predeps $postdeps " in
7941f3561b8bSmrg	      *" $deplib "*)
7942f3561b8bSmrg		if func_lalib_p "$lib"; then
7943f3561b8bSmrg		  library_names=
7944f3561b8bSmrg		  old_library=
7945f3561b8bSmrg		  func_source "$lib"
7946f3561b8bSmrg		  for l in $old_library $library_names; do
79476257f37dSmrg		    ll=$l
7948f3561b8bSmrg		  done
79496257f37dSmrg		  if test "X$ll" = "X$old_library"; then # only static version available
79506257f37dSmrg		    found=false
7951f3561b8bSmrg		    func_dirname "$lib" "" "."
79526257f37dSmrg		    ladir=$func_dirname_result
7953f3561b8bSmrg		    lib=$ladir/$old_library
79546257f37dSmrg		    if test prog,link = "$linkmode,$pass"; then
7955f3561b8bSmrg		      compile_deplibs="$deplib $compile_deplibs"
7956f3561b8bSmrg		      finalize_deplibs="$deplib $finalize_deplibs"
7957f3561b8bSmrg		    else
7958f3561b8bSmrg		      deplibs="$deplib $deplibs"
79596257f37dSmrg		      test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
7960f3561b8bSmrg		    fi
7961f3561b8bSmrg		    continue
7962f3561b8bSmrg		  fi
7963f3561b8bSmrg		fi
7964f3561b8bSmrg		;;
7965f3561b8bSmrg	      *) ;;
7966f3561b8bSmrg	      esac
7967f3561b8bSmrg	    fi
79686257f37dSmrg	  else
79696257f37dSmrg	    # deplib doesn't seem to be a libtool library
79706257f37dSmrg	    if test prog,link = "$linkmode,$pass"; then
79716257f37dSmrg	      compile_deplibs="$deplib $compile_deplibs"
79726257f37dSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
79736257f37dSmrg	    else
79746257f37dSmrg	      deplibs="$deplib $deplibs"
79756257f37dSmrg	      test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
79766257f37dSmrg	    fi
79776257f37dSmrg	    continue
7978f3561b8bSmrg	  fi
7979f3561b8bSmrg	  ;; # -l
7980f3561b8bSmrg	*.ltframework)
79816257f37dSmrg	  if test prog,link = "$linkmode,$pass"; then
7982f3561b8bSmrg	    compile_deplibs="$deplib $compile_deplibs"
7983f3561b8bSmrg	    finalize_deplibs="$deplib $finalize_deplibs"
7984f3561b8bSmrg	  else
7985f3561b8bSmrg	    deplibs="$deplib $deplibs"
79866257f37dSmrg	    if test lib = "$linkmode"; then
7987f3561b8bSmrg		case "$new_inherited_linker_flags " in
7988f3561b8bSmrg		    *" $deplib "*) ;;
7989bd304fc0Smrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
7990f3561b8bSmrg		esac
7991f3561b8bSmrg	    fi
7992f3561b8bSmrg	  fi
7993f3561b8bSmrg	  continue
7994f3561b8bSmrg	  ;;
7995f3561b8bSmrg	-L*)
7996f3561b8bSmrg	  case $linkmode in
7997f3561b8bSmrg	  lib)
7998f3561b8bSmrg	    deplibs="$deplib $deplibs"
79996257f37dSmrg	    test conv = "$pass" && continue
8000f3561b8bSmrg	    newdependency_libs="$deplib $newdependency_libs"
8001f3561b8bSmrg	    func_stripname '-L' '' "$deplib"
8002bd304fc0Smrg	    func_resolve_sysroot "$func_stripname_result"
8003bd304fc0Smrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
8004f3561b8bSmrg	    ;;
8005f3561b8bSmrg	  prog)
80066257f37dSmrg	    if test conv = "$pass"; then
8007f3561b8bSmrg	      deplibs="$deplib $deplibs"
8008f3561b8bSmrg	      continue
8009f3561b8bSmrg	    fi
80106257f37dSmrg	    if test scan = "$pass"; then
8011f3561b8bSmrg	      deplibs="$deplib $deplibs"
8012f3561b8bSmrg	    else
8013f3561b8bSmrg	      compile_deplibs="$deplib $compile_deplibs"
8014f3561b8bSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
8015f3561b8bSmrg	    fi
8016f3561b8bSmrg	    func_stripname '-L' '' "$deplib"
8017bd304fc0Smrg	    func_resolve_sysroot "$func_stripname_result"
8018bd304fc0Smrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
8019f3561b8bSmrg	    ;;
8020f3561b8bSmrg	  *)
80216257f37dSmrg	    func_warning "'-L' is ignored for archives/objects"
8022f3561b8bSmrg	    ;;
8023f3561b8bSmrg	  esac # linkmode
8024f3561b8bSmrg	  continue
8025f3561b8bSmrg	  ;; # -L
8026f3561b8bSmrg	-R*)
80276257f37dSmrg	  if test link = "$pass"; then
8028f3561b8bSmrg	    func_stripname '-R' '' "$deplib"
8029bd304fc0Smrg	    func_resolve_sysroot "$func_stripname_result"
8030bd304fc0Smrg	    dir=$func_resolve_sysroot_result
8031f3561b8bSmrg	    # Make sure the xrpath contains only unique directories.
8032f3561b8bSmrg	    case "$xrpath " in
8033f3561b8bSmrg	    *" $dir "*) ;;
8034bd304fc0Smrg	    *) func_append xrpath " $dir" ;;
8035f3561b8bSmrg	    esac
8036f3561b8bSmrg	  fi
8037f3561b8bSmrg	  deplibs="$deplib $deplibs"
8038f3561b8bSmrg	  continue
8039f3561b8bSmrg	  ;;
8040bd304fc0Smrg	*.la)
8041bd304fc0Smrg	  func_resolve_sysroot "$deplib"
8042bd304fc0Smrg	  lib=$func_resolve_sysroot_result
8043bd304fc0Smrg	  ;;
8044f3561b8bSmrg	*.$libext)
80456257f37dSmrg	  if test conv = "$pass"; then
8046f3561b8bSmrg	    deplibs="$deplib $deplibs"
8047f3561b8bSmrg	    continue
8048f3561b8bSmrg	  fi
8049f3561b8bSmrg	  case $linkmode in
8050f3561b8bSmrg	  lib)
8051f3561b8bSmrg	    # Linking convenience modules into shared libraries is allowed,
8052f3561b8bSmrg	    # but linking other static libraries is non-portable.
8053f3561b8bSmrg	    case " $dlpreconveniencelibs " in
8054f3561b8bSmrg	    *" $deplib "*) ;;
8055f3561b8bSmrg	    *)
80566257f37dSmrg	      valid_a_lib=false
8057f3561b8bSmrg	      case $deplibs_check_method in
8058f3561b8bSmrg		match_pattern*)
8059f3561b8bSmrg		  set dummy $deplibs_check_method; shift
8060f3561b8bSmrg		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
8061bd304fc0Smrg		  if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
8062f3561b8bSmrg		    | $EGREP "$match_pattern_regex" > /dev/null; then
80636257f37dSmrg		    valid_a_lib=:
8064f3561b8bSmrg		  fi
8065f3561b8bSmrg		;;
8066f3561b8bSmrg		pass_all)
80676257f37dSmrg		  valid_a_lib=:
8068f3561b8bSmrg		;;
8069f3561b8bSmrg	      esac
80706257f37dSmrg	      if $valid_a_lib; then
80716257f37dSmrg		echo
80726257f37dSmrg		$ECHO "*** Warning: Linking the shared library $output against the"
80736257f37dSmrg		$ECHO "*** static library $deplib is not portable!"
80746257f37dSmrg		deplibs="$deplib $deplibs"
80756257f37dSmrg	      else
8076bd304fc0Smrg		echo
8077f3561b8bSmrg		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
8078bd304fc0Smrg		echo "*** I have the capability to make that library automatically link in when"
8079bd304fc0Smrg		echo "*** you link to this library.  But I can only do this if you have a"
8080bd304fc0Smrg		echo "*** shared version of the library, which you do not appear to have"
8081bd304fc0Smrg		echo "*** because the file extensions .$libext of this argument makes me believe"
8082bd304fc0Smrg		echo "*** that it is just a static archive that I should not use here."
8083f3561b8bSmrg	      fi
8084f3561b8bSmrg	      ;;
8085f3561b8bSmrg	    esac
8086f3561b8bSmrg	    continue
8087f3561b8bSmrg	    ;;
8088f3561b8bSmrg	  prog)
80896257f37dSmrg	    if test link != "$pass"; then
8090f3561b8bSmrg	      deplibs="$deplib $deplibs"
8091f3561b8bSmrg	    else
8092f3561b8bSmrg	      compile_deplibs="$deplib $compile_deplibs"
8093f3561b8bSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
8094f3561b8bSmrg	    fi
8095f3561b8bSmrg	    continue
8096f3561b8bSmrg	    ;;
8097f3561b8bSmrg	  esac # linkmode
8098f3561b8bSmrg	  ;; # *.$libext
8099f3561b8bSmrg	*.lo | *.$objext)
81006257f37dSmrg	  if test conv = "$pass"; then
8101f3561b8bSmrg	    deplibs="$deplib $deplibs"
81026257f37dSmrg	  elif test prog = "$linkmode"; then
81036257f37dSmrg	    if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then
8104f3561b8bSmrg	      # If there is no dlopen support or we're linking statically,
8105f3561b8bSmrg	      # we need to preload.
8106bd304fc0Smrg	      func_append newdlprefiles " $deplib"
8107f3561b8bSmrg	      compile_deplibs="$deplib $compile_deplibs"
8108f3561b8bSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
8109f3561b8bSmrg	    else
8110bd304fc0Smrg	      func_append newdlfiles " $deplib"
8111f3561b8bSmrg	    fi
8112f3561b8bSmrg	  fi
8113f3561b8bSmrg	  continue
8114f3561b8bSmrg	  ;;
8115f3561b8bSmrg	%DEPLIBS%)
81166257f37dSmrg	  alldeplibs=:
8117f3561b8bSmrg	  continue
8118f3561b8bSmrg	  ;;
8119f3561b8bSmrg	esac # case $deplib
8120f3561b8bSmrg
81216257f37dSmrg	$found || test -f "$lib" \
81226257f37dSmrg	  || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'"
8123f3561b8bSmrg
8124f3561b8bSmrg	# Check to see that this really is a libtool archive.
8125f3561b8bSmrg	func_lalib_unsafe_p "$lib" \
81266257f37dSmrg	  || func_fatal_error "'$lib' is not a valid libtool archive"
8127f3561b8bSmrg
8128f3561b8bSmrg	func_dirname "$lib" "" "."
81296257f37dSmrg	ladir=$func_dirname_result
8130f3561b8bSmrg
8131f3561b8bSmrg	dlname=
8132f3561b8bSmrg	dlopen=
8133f3561b8bSmrg	dlpreopen=
8134f3561b8bSmrg	libdir=
8135f3561b8bSmrg	library_names=
8136f3561b8bSmrg	old_library=
8137f3561b8bSmrg	inherited_linker_flags=
8138f3561b8bSmrg	# If the library was installed with an old release of libtool,
8139f3561b8bSmrg	# it will not redefine variables installed, or shouldnotlink
8140f3561b8bSmrg	installed=yes
8141f3561b8bSmrg	shouldnotlink=no
8142f3561b8bSmrg	avoidtemprpath=
8143f3561b8bSmrg
8144f3561b8bSmrg
8145f3561b8bSmrg	# Read the .la file
8146f3561b8bSmrg	func_source "$lib"
8147f3561b8bSmrg
8148f3561b8bSmrg	# Convert "-framework foo" to "foo.ltframework"
8149f3561b8bSmrg	if test -n "$inherited_linker_flags"; then
8150bd304fc0Smrg	  tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
8151f3561b8bSmrg	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
8152f3561b8bSmrg	    case " $new_inherited_linker_flags " in
8153f3561b8bSmrg	      *" $tmp_inherited_linker_flag "*) ;;
8154bd304fc0Smrg	      *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
8155f3561b8bSmrg	    esac
8156f3561b8bSmrg	  done
8157f3561b8bSmrg	fi
8158bd304fc0Smrg	dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
81596257f37dSmrg	if test lib,link = "$linkmode,$pass" ||
81606257f37dSmrg	   test prog,scan = "$linkmode,$pass" ||
81616257f37dSmrg	   { test prog != "$linkmode" && test lib != "$linkmode"; }; then
8162bd304fc0Smrg	  test -n "$dlopen" && func_append dlfiles " $dlopen"
8163bd304fc0Smrg	  test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
8164f3561b8bSmrg	fi
8165f3561b8bSmrg
81666257f37dSmrg	if test conv = "$pass"; then
8167f3561b8bSmrg	  # Only check for convenience libraries
8168f3561b8bSmrg	  deplibs="$lib $deplibs"
8169f3561b8bSmrg	  if test -z "$libdir"; then
8170f3561b8bSmrg	    if test -z "$old_library"; then
81716257f37dSmrg	      func_fatal_error "cannot find name of link library for '$lib'"
8172f3561b8bSmrg	    fi
8173f3561b8bSmrg	    # It is a libtool convenience library, so add in its objects.
8174bd304fc0Smrg	    func_append convenience " $ladir/$objdir/$old_library"
8175bd304fc0Smrg	    func_append old_convenience " $ladir/$objdir/$old_library"
81766257f37dSmrg	  elif test prog != "$linkmode" && test lib != "$linkmode"; then
81776257f37dSmrg	    func_fatal_error "'$lib' is not a convenience library"
8178f3561b8bSmrg	  fi
8179bd304fc0Smrg	  tmp_libs=
8180bd304fc0Smrg	  for deplib in $dependency_libs; do
8181bd304fc0Smrg	    deplibs="$deplib $deplibs"
81826257f37dSmrg	    if $opt_preserve_dup_deps; then
8183bd304fc0Smrg	      case "$tmp_libs " in
8184bd304fc0Smrg	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
8185bd304fc0Smrg	      esac
8186bd304fc0Smrg	    fi
8187bd304fc0Smrg	    func_append tmp_libs " $deplib"
8188bd304fc0Smrg	  done
8189f3561b8bSmrg	  continue
8190f3561b8bSmrg	fi # $pass = conv
8191f3561b8bSmrg
8192f3561b8bSmrg
8193f3561b8bSmrg	# Get the name of the library we link against.
8194f3561b8bSmrg	linklib=
8195bd304fc0Smrg	if test -n "$old_library" &&
81966257f37dSmrg	   { test yes = "$prefer_static_libs" ||
81976257f37dSmrg	     test built,no = "$prefer_static_libs,$installed"; }; then
8198bd304fc0Smrg	  linklib=$old_library
8199bd304fc0Smrg	else
8200bd304fc0Smrg	  for l in $old_library $library_names; do
82016257f37dSmrg	    linklib=$l
8202bd304fc0Smrg	  done
8203bd304fc0Smrg	fi
8204f3561b8bSmrg	if test -z "$linklib"; then
82056257f37dSmrg	  func_fatal_error "cannot find name of link library for '$lib'"
8206f3561b8bSmrg	fi
8207f3561b8bSmrg
8208f3561b8bSmrg	# This library was specified with -dlopen.
82096257f37dSmrg	if test dlopen = "$pass"; then
82106257f37dSmrg	  test -z "$libdir" \
82116257f37dSmrg	    && func_fatal_error "cannot -dlopen a convenience library: '$lib'"
8212f3561b8bSmrg	  if test -z "$dlname" ||
82136257f37dSmrg	     test yes != "$dlopen_support" ||
82146257f37dSmrg	     test no = "$build_libtool_libs"
82156257f37dSmrg	  then
8216f3561b8bSmrg	    # If there is no dlname, no dlopen support or we're linking
8217f3561b8bSmrg	    # statically, we need to preload.  We also need to preload any
8218f3561b8bSmrg	    # dependent libraries so libltdl's deplib preloader doesn't
8219f3561b8bSmrg	    # bomb out in the load deplibs phase.
8220bd304fc0Smrg	    func_append dlprefiles " $lib $dependency_libs"
8221f3561b8bSmrg	  else
8222bd304fc0Smrg	    func_append newdlfiles " $lib"
8223f3561b8bSmrg	  fi
8224f3561b8bSmrg	  continue
8225f3561b8bSmrg	fi # $pass = dlopen
8226f3561b8bSmrg
8227f3561b8bSmrg	# We need an absolute path.
8228f3561b8bSmrg	case $ladir in
82296257f37dSmrg	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;;
8230f3561b8bSmrg	*)
8231f3561b8bSmrg	  abs_ladir=`cd "$ladir" && pwd`
8232f3561b8bSmrg	  if test -z "$abs_ladir"; then
82336257f37dSmrg	    func_warning "cannot determine absolute directory name of '$ladir'"
8234f3561b8bSmrg	    func_warning "passing it literally to the linker, although it might fail"
82356257f37dSmrg	    abs_ladir=$ladir
8236f3561b8bSmrg	  fi
8237f3561b8bSmrg	  ;;
8238f3561b8bSmrg	esac
8239f3561b8bSmrg	func_basename "$lib"
82406257f37dSmrg	laname=$func_basename_result
8241f3561b8bSmrg
8242f3561b8bSmrg	# Find the relevant object directory and library name.
82436257f37dSmrg	if test yes = "$installed"; then
8244bd304fc0Smrg	  if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
82456257f37dSmrg	    func_warning "library '$lib' was moved."
82466257f37dSmrg	    dir=$ladir
82476257f37dSmrg	    absdir=$abs_ladir
82486257f37dSmrg	    libdir=$abs_ladir
8249f3561b8bSmrg	  else
82506257f37dSmrg	    dir=$lt_sysroot$libdir
82516257f37dSmrg	    absdir=$lt_sysroot$libdir
8252f3561b8bSmrg	  fi
82536257f37dSmrg	  test yes = "$hardcode_automatic" && avoidtemprpath=yes
8254f3561b8bSmrg	else
8255f3561b8bSmrg	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
82566257f37dSmrg	    dir=$ladir
82576257f37dSmrg	    absdir=$abs_ladir
8258f3561b8bSmrg	    # Remove this search path later
8259bd304fc0Smrg	    func_append notinst_path " $abs_ladir"
8260f3561b8bSmrg	  else
82616257f37dSmrg	    dir=$ladir/$objdir
82626257f37dSmrg	    absdir=$abs_ladir/$objdir
8263f3561b8bSmrg	    # Remove this search path later
8264bd304fc0Smrg	    func_append notinst_path " $abs_ladir"
8265f3561b8bSmrg	  fi
8266f3561b8bSmrg	fi # $installed = yes
8267f3561b8bSmrg	func_stripname 'lib' '.la' "$laname"
8268f3561b8bSmrg	name=$func_stripname_result
8269f3561b8bSmrg
8270f3561b8bSmrg	# This library was specified with -dlpreopen.
82716257f37dSmrg	if test dlpreopen = "$pass"; then
82726257f37dSmrg	  if test -z "$libdir" && test prog = "$linkmode"; then
82736257f37dSmrg	    func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'"
8274f3561b8bSmrg	  fi
82756257f37dSmrg	  case $host in
8276bd304fc0Smrg	    # special handling for platforms with PE-DLLs.
8277bd304fc0Smrg	    *cygwin* | *mingw* | *cegcc* )
8278bd304fc0Smrg	      # Linker will automatically link against shared library if both
8279bd304fc0Smrg	      # static and shared are present.  Therefore, ensure we extract
8280bd304fc0Smrg	      # symbols from the import library if a shared library is present
8281bd304fc0Smrg	      # (otherwise, the dlopen module name will be incorrect).  We do
8282bd304fc0Smrg	      # this by putting the import library name into $newdlprefiles.
8283bd304fc0Smrg	      # We recover the dlopen module name by 'saving' the la file
8284bd304fc0Smrg	      # name in a special purpose variable, and (later) extracting the
8285bd304fc0Smrg	      # dlname from the la file.
8286bd304fc0Smrg	      if test -n "$dlname"; then
8287bd304fc0Smrg	        func_tr_sh "$dir/$linklib"
8288bd304fc0Smrg	        eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
8289bd304fc0Smrg	        func_append newdlprefiles " $dir/$linklib"
8290bd304fc0Smrg	      else
8291bd304fc0Smrg	        func_append newdlprefiles " $dir/$old_library"
8292bd304fc0Smrg	        # Keep a list of preopened convenience libraries to check
8293bd304fc0Smrg	        # that they are being used correctly in the link pass.
8294bd304fc0Smrg	        test -z "$libdir" && \
8295bd304fc0Smrg	          func_append dlpreconveniencelibs " $dir/$old_library"
8296bd304fc0Smrg	      fi
8297bd304fc0Smrg	    ;;
8298bd304fc0Smrg	    * )
8299bd304fc0Smrg	      # Prefer using a static library (so that no silly _DYNAMIC symbols
8300bd304fc0Smrg	      # are required to link).
8301bd304fc0Smrg	      if test -n "$old_library"; then
8302bd304fc0Smrg	        func_append newdlprefiles " $dir/$old_library"
8303bd304fc0Smrg	        # Keep a list of preopened convenience libraries to check
8304bd304fc0Smrg	        # that they are being used correctly in the link pass.
8305bd304fc0Smrg	        test -z "$libdir" && \
8306bd304fc0Smrg	          func_append dlpreconveniencelibs " $dir/$old_library"
8307bd304fc0Smrg	      # Otherwise, use the dlname, so that lt_dlopen finds it.
8308bd304fc0Smrg	      elif test -n "$dlname"; then
8309bd304fc0Smrg	        func_append newdlprefiles " $dir/$dlname"
8310bd304fc0Smrg	      else
8311bd304fc0Smrg	        func_append newdlprefiles " $dir/$linklib"
8312bd304fc0Smrg	      fi
8313bd304fc0Smrg	    ;;
8314bd304fc0Smrg	  esac
8315f3561b8bSmrg	fi # $pass = dlpreopen
8316f3561b8bSmrg
8317f3561b8bSmrg	if test -z "$libdir"; then
8318f3561b8bSmrg	  # Link the convenience library
83196257f37dSmrg	  if test lib = "$linkmode"; then
8320f3561b8bSmrg	    deplibs="$dir/$old_library $deplibs"
83216257f37dSmrg	  elif test prog,link = "$linkmode,$pass"; then
8322f3561b8bSmrg	    compile_deplibs="$dir/$old_library $compile_deplibs"
8323f3561b8bSmrg	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
8324f3561b8bSmrg	  else
8325f3561b8bSmrg	    deplibs="$lib $deplibs" # used for prog,scan pass
8326f3561b8bSmrg	  fi
8327f3561b8bSmrg	  continue
8328f3561b8bSmrg	fi
8329f3561b8bSmrg
8330f3561b8bSmrg
83316257f37dSmrg	if test prog = "$linkmode" && test link != "$pass"; then
8332bd304fc0Smrg	  func_append newlib_search_path " $ladir"
8333f3561b8bSmrg	  deplibs="$lib $deplibs"
8334f3561b8bSmrg
83356257f37dSmrg	  linkalldeplibs=false
83366257f37dSmrg	  if test no != "$link_all_deplibs" || test -z "$library_names" ||
83376257f37dSmrg	     test no = "$build_libtool_libs"; then
83386257f37dSmrg	    linkalldeplibs=:
8339f3561b8bSmrg	  fi
8340f3561b8bSmrg
8341f3561b8bSmrg	  tmp_libs=
8342f3561b8bSmrg	  for deplib in $dependency_libs; do
8343f3561b8bSmrg	    case $deplib in
8344f3561b8bSmrg	    -L*) func_stripname '-L' '' "$deplib"
8345bd304fc0Smrg	         func_resolve_sysroot "$func_stripname_result"
8346bd304fc0Smrg	         func_append newlib_search_path " $func_resolve_sysroot_result"
8347f3561b8bSmrg		 ;;
8348f3561b8bSmrg	    esac
8349f3561b8bSmrg	    # Need to link against all dependency_libs?
83506257f37dSmrg	    if $linkalldeplibs; then
8351f3561b8bSmrg	      deplibs="$deplib $deplibs"
8352f3561b8bSmrg	    else
8353f3561b8bSmrg	      # Need to hardcode shared library paths
8354f3561b8bSmrg	      # or/and link against static libraries
8355f3561b8bSmrg	      newdependency_libs="$deplib $newdependency_libs"
8356f3561b8bSmrg	    fi
83576257f37dSmrg	    if $opt_preserve_dup_deps; then
8358f3561b8bSmrg	      case "$tmp_libs " in
8359bd304fc0Smrg	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
8360f3561b8bSmrg	      esac
8361f3561b8bSmrg	    fi
8362bd304fc0Smrg	    func_append tmp_libs " $deplib"
8363f3561b8bSmrg	  done # for deplib
8364f3561b8bSmrg	  continue
8365f3561b8bSmrg	fi # $linkmode = prog...
8366f3561b8bSmrg
83676257f37dSmrg	if test prog,link = "$linkmode,$pass"; then
8368f3561b8bSmrg	  if test -n "$library_names" &&
83696257f37dSmrg	     { { test no = "$prefer_static_libs" ||
83706257f37dSmrg	         test built,yes = "$prefer_static_libs,$installed"; } ||
8371f3561b8bSmrg	       test -z "$old_library"; }; then
8372f3561b8bSmrg	    # We need to hardcode the library path
83736257f37dSmrg	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then
8374f3561b8bSmrg	      # Make sure the rpath contains only unique directories.
83756257f37dSmrg	      case $temp_rpath: in
8376f3561b8bSmrg	      *"$absdir:"*) ;;
8377bd304fc0Smrg	      *) func_append temp_rpath "$absdir:" ;;
8378f3561b8bSmrg	      esac
8379f3561b8bSmrg	    fi
8380f3561b8bSmrg
8381f3561b8bSmrg	    # Hardcode the library path.
8382f3561b8bSmrg	    # Skip directories that are in the system default run-time
8383f3561b8bSmrg	    # search path.
8384f3561b8bSmrg	    case " $sys_lib_dlsearch_path " in
8385f3561b8bSmrg	    *" $absdir "*) ;;
8386f3561b8bSmrg	    *)
8387f3561b8bSmrg	      case "$compile_rpath " in
8388f3561b8bSmrg	      *" $absdir "*) ;;
8389bd304fc0Smrg	      *) func_append compile_rpath " $absdir" ;;
8390f3561b8bSmrg	      esac
8391f3561b8bSmrg	      ;;
8392f3561b8bSmrg	    esac
8393f3561b8bSmrg	    case " $sys_lib_dlsearch_path " in
8394f3561b8bSmrg	    *" $libdir "*) ;;
8395f3561b8bSmrg	    *)
8396f3561b8bSmrg	      case "$finalize_rpath " in
8397f3561b8bSmrg	      *" $libdir "*) ;;
8398bd304fc0Smrg	      *) func_append finalize_rpath " $libdir" ;;
8399f3561b8bSmrg	      esac
8400f3561b8bSmrg	      ;;
8401f3561b8bSmrg	    esac
8402f3561b8bSmrg	  fi # $linkmode,$pass = prog,link...
8403f3561b8bSmrg
84046257f37dSmrg	  if $alldeplibs &&
84056257f37dSmrg	     { test pass_all = "$deplibs_check_method" ||
84066257f37dSmrg	       { test yes = "$build_libtool_libs" &&
8407f3561b8bSmrg		 test -n "$library_names"; }; }; then
8408f3561b8bSmrg	    # We only need to search for static libraries
8409f3561b8bSmrg	    continue
8410f3561b8bSmrg	  fi
8411f3561b8bSmrg	fi
8412f3561b8bSmrg
8413f3561b8bSmrg	link_static=no # Whether the deplib will be linked statically
8414f3561b8bSmrg	use_static_libs=$prefer_static_libs
84156257f37dSmrg	if test built = "$use_static_libs" && test yes = "$installed"; then
8416f3561b8bSmrg	  use_static_libs=no
8417f3561b8bSmrg	fi
8418f3561b8bSmrg	if test -n "$library_names" &&
84196257f37dSmrg	   { test no = "$use_static_libs" || test -z "$old_library"; }; then
8420f3561b8bSmrg	  case $host in
84216257f37dSmrg	  *cygwin* | *mingw* | *cegcc* | *os2*)
8422f3561b8bSmrg	      # No point in relinking DLLs because paths are not encoded
8423bd304fc0Smrg	      func_append notinst_deplibs " $lib"
8424f3561b8bSmrg	      need_relink=no
8425f3561b8bSmrg	    ;;
8426f3561b8bSmrg	  *)
84276257f37dSmrg	    if test no = "$installed"; then
8428bd304fc0Smrg	      func_append notinst_deplibs " $lib"
8429f3561b8bSmrg	      need_relink=yes
8430f3561b8bSmrg	    fi
8431f3561b8bSmrg	    ;;
8432f3561b8bSmrg	  esac
8433f3561b8bSmrg	  # This is a shared library
8434f3561b8bSmrg
8435f3561b8bSmrg	  # Warn about portability, can't link against -module's on some
8436f3561b8bSmrg	  # systems (darwin).  Don't bleat about dlopened modules though!
84376257f37dSmrg	  dlopenmodule=
8438f3561b8bSmrg	  for dlpremoduletest in $dlprefiles; do
8439f3561b8bSmrg	    if test "X$dlpremoduletest" = "X$lib"; then
84406257f37dSmrg	      dlopenmodule=$dlpremoduletest
8441f3561b8bSmrg	      break
8442f3561b8bSmrg	    fi
8443f3561b8bSmrg	  done
84446257f37dSmrg	  if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then
8445bd304fc0Smrg	    echo
84466257f37dSmrg	    if test prog = "$linkmode"; then
8447f3561b8bSmrg	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
8448f3561b8bSmrg	    else
8449f3561b8bSmrg	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
8450f3561b8bSmrg	    fi
8451f3561b8bSmrg	    $ECHO "*** $linklib is not portable!"
8452f3561b8bSmrg	  fi
84536257f37dSmrg	  if test lib = "$linkmode" &&
84546257f37dSmrg	     test yes = "$hardcode_into_libs"; then
8455f3561b8bSmrg	    # Hardcode the library path.
8456f3561b8bSmrg	    # Skip directories that are in the system default run-time
8457f3561b8bSmrg	    # search path.
8458f3561b8bSmrg	    case " $sys_lib_dlsearch_path " in
8459f3561b8bSmrg	    *" $absdir "*) ;;
8460f3561b8bSmrg	    *)
8461f3561b8bSmrg	      case "$compile_rpath " in
8462f3561b8bSmrg	      *" $absdir "*) ;;
8463bd304fc0Smrg	      *) func_append compile_rpath " $absdir" ;;
8464f3561b8bSmrg	      esac
8465f3561b8bSmrg	      ;;
8466f3561b8bSmrg	    esac
8467f3561b8bSmrg	    case " $sys_lib_dlsearch_path " in
8468f3561b8bSmrg	    *" $libdir "*) ;;
8469f3561b8bSmrg	    *)
8470f3561b8bSmrg	      case "$finalize_rpath " in
8471f3561b8bSmrg	      *" $libdir "*) ;;
8472bd304fc0Smrg	      *) func_append finalize_rpath " $libdir" ;;
8473f3561b8bSmrg	      esac
8474f3561b8bSmrg	      ;;
8475f3561b8bSmrg	    esac
8476f3561b8bSmrg	  fi
8477f3561b8bSmrg
8478f3561b8bSmrg	  if test -n "$old_archive_from_expsyms_cmds"; then
8479f3561b8bSmrg	    # figure out the soname
8480f3561b8bSmrg	    set dummy $library_names
8481f3561b8bSmrg	    shift
84826257f37dSmrg	    realname=$1
8483f3561b8bSmrg	    shift
8484f3561b8bSmrg	    libname=`eval "\\$ECHO \"$libname_spec\""`
8485f3561b8bSmrg	    # use dlname if we got it. it's perfectly good, no?
8486f3561b8bSmrg	    if test -n "$dlname"; then
84876257f37dSmrg	      soname=$dlname
8488f3561b8bSmrg	    elif test -n "$soname_spec"; then
8489f3561b8bSmrg	      # bleh windows
8490f3561b8bSmrg	      case $host in
84916257f37dSmrg	      *cygwin* | mingw* | *cegcc* | *os2*)
8492f3561b8bSmrg	        func_arith $current - $age
8493f3561b8bSmrg		major=$func_arith_result
84946257f37dSmrg		versuffix=-$major
8495f3561b8bSmrg		;;
8496f3561b8bSmrg	      esac
8497f3561b8bSmrg	      eval soname=\"$soname_spec\"
8498f3561b8bSmrg	    else
84996257f37dSmrg	      soname=$realname
8500f3561b8bSmrg	    fi
8501f3561b8bSmrg
8502f3561b8bSmrg	    # Make a new name for the extract_expsyms_cmds to use
85036257f37dSmrg	    soroot=$soname
8504f3561b8bSmrg	    func_basename "$soroot"
85056257f37dSmrg	    soname=$func_basename_result
8506f3561b8bSmrg	    func_stripname 'lib' '.dll' "$soname"
8507f3561b8bSmrg	    newlib=libimp-$func_stripname_result.a
8508f3561b8bSmrg
8509f3561b8bSmrg	    # If the library has no export list, then create one now
8510f3561b8bSmrg	    if test -f "$output_objdir/$soname-def"; then :
8511f3561b8bSmrg	    else
85126257f37dSmrg	      func_verbose "extracting exported symbol list from '$soname'"
8513f3561b8bSmrg	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
8514f3561b8bSmrg	    fi
8515f3561b8bSmrg
8516f3561b8bSmrg	    # Create $newlib
8517f3561b8bSmrg	    if test -f "$output_objdir/$newlib"; then :; else
85186257f37dSmrg	      func_verbose "generating import library for '$soname'"
8519f3561b8bSmrg	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
8520f3561b8bSmrg	    fi
8521f3561b8bSmrg	    # make sure the library variables are pointing to the new library
8522f3561b8bSmrg	    dir=$output_objdir
8523f3561b8bSmrg	    linklib=$newlib
8524f3561b8bSmrg	  fi # test -n "$old_archive_from_expsyms_cmds"
8525f3561b8bSmrg
85266257f37dSmrg	  if test prog = "$linkmode" || test relink != "$opt_mode"; then
8527f3561b8bSmrg	    add_shlibpath=
8528f3561b8bSmrg	    add_dir=
8529f3561b8bSmrg	    add=
8530f3561b8bSmrg	    lib_linked=yes
8531f3561b8bSmrg	    case $hardcode_action in
8532f3561b8bSmrg	    immediate | unsupported)
85336257f37dSmrg	      if test no = "$hardcode_direct"; then
85346257f37dSmrg		add=$dir/$linklib
8535f3561b8bSmrg		case $host in
85366257f37dSmrg		  *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;;
85376257f37dSmrg		  *-*-sysv4*uw2*) add_dir=-L$dir ;;
8538f3561b8bSmrg		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
85396257f37dSmrg		    *-*-unixware7*) add_dir=-L$dir ;;
8540f3561b8bSmrg		  *-*-darwin* )
85416257f37dSmrg		    # if the lib is a (non-dlopened) module then we cannot
8542f3561b8bSmrg		    # link against it, someone is ignoring the earlier warnings
8543f3561b8bSmrg		    if /usr/bin/file -L $add 2> /dev/null |
85446257f37dSmrg			 $GREP ": [^:]* bundle" >/dev/null; then
8545f3561b8bSmrg		      if test "X$dlopenmodule" != "X$lib"; then
8546f3561b8bSmrg			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
85476257f37dSmrg			if test -z "$old_library"; then
8548bd304fc0Smrg			  echo
8549bd304fc0Smrg			  echo "*** And there doesn't seem to be a static archive available"
8550bd304fc0Smrg			  echo "*** The link will probably fail, sorry"
8551f3561b8bSmrg			else
85526257f37dSmrg			  add=$dir/$old_library
8553f3561b8bSmrg			fi
8554f3561b8bSmrg		      elif test -n "$old_library"; then
85556257f37dSmrg			add=$dir/$old_library
8556f3561b8bSmrg		      fi
8557f3561b8bSmrg		    fi
8558f3561b8bSmrg		esac
85596257f37dSmrg	      elif test no = "$hardcode_minus_L"; then
8560f3561b8bSmrg		case $host in
85616257f37dSmrg		*-*-sunos*) add_shlibpath=$dir ;;
8562f3561b8bSmrg		esac
85636257f37dSmrg		add_dir=-L$dir
85646257f37dSmrg		add=-l$name
85656257f37dSmrg	      elif test no = "$hardcode_shlibpath_var"; then
85666257f37dSmrg		add_shlibpath=$dir
85676257f37dSmrg		add=-l$name
8568f3561b8bSmrg	      else
8569f3561b8bSmrg		lib_linked=no
8570f3561b8bSmrg	      fi
8571f3561b8bSmrg	      ;;
8572f3561b8bSmrg	    relink)
85736257f37dSmrg	      if test yes = "$hardcode_direct" &&
85746257f37dSmrg	         test no = "$hardcode_direct_absolute"; then
85756257f37dSmrg		add=$dir/$linklib
85766257f37dSmrg	      elif test yes = "$hardcode_minus_L"; then
85776257f37dSmrg		add_dir=-L$absdir
8578f3561b8bSmrg		# Try looking first in the location we're being installed to.
8579f3561b8bSmrg		if test -n "$inst_prefix_dir"; then
8580f3561b8bSmrg		  case $libdir in
8581f3561b8bSmrg		    [\\/]*)
8582bd304fc0Smrg		      func_append add_dir " -L$inst_prefix_dir$libdir"
8583f3561b8bSmrg		      ;;
8584f3561b8bSmrg		  esac
8585f3561b8bSmrg		fi
85866257f37dSmrg		add=-l$name
85876257f37dSmrg	      elif test yes = "$hardcode_shlibpath_var"; then
85886257f37dSmrg		add_shlibpath=$dir
85896257f37dSmrg		add=-l$name
8590f3561b8bSmrg	      else
8591f3561b8bSmrg		lib_linked=no
8592f3561b8bSmrg	      fi
8593f3561b8bSmrg	      ;;
8594f3561b8bSmrg	    *) lib_linked=no ;;
8595f3561b8bSmrg	    esac
8596f3561b8bSmrg
85976257f37dSmrg	    if test yes != "$lib_linked"; then
8598f3561b8bSmrg	      func_fatal_configuration "unsupported hardcode properties"
8599f3561b8bSmrg	    fi
8600f3561b8bSmrg
8601f3561b8bSmrg	    if test -n "$add_shlibpath"; then
8602f3561b8bSmrg	      case :$compile_shlibpath: in
8603f3561b8bSmrg	      *":$add_shlibpath:"*) ;;
8604bd304fc0Smrg	      *) func_append compile_shlibpath "$add_shlibpath:" ;;
8605f3561b8bSmrg	      esac
8606f3561b8bSmrg	    fi
86076257f37dSmrg	    if test prog = "$linkmode"; then
8608f3561b8bSmrg	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
8609f3561b8bSmrg	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
8610f3561b8bSmrg	    else
8611f3561b8bSmrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
8612f3561b8bSmrg	      test -n "$add" && deplibs="$add $deplibs"
86136257f37dSmrg	      if test yes != "$hardcode_direct" &&
86146257f37dSmrg		 test yes != "$hardcode_minus_L" &&
86156257f37dSmrg		 test yes = "$hardcode_shlibpath_var"; then
8616f3561b8bSmrg		case :$finalize_shlibpath: in
8617f3561b8bSmrg		*":$libdir:"*) ;;
8618bd304fc0Smrg		*) func_append finalize_shlibpath "$libdir:" ;;
8619f3561b8bSmrg		esac
8620f3561b8bSmrg	      fi
8621f3561b8bSmrg	    fi
8622f3561b8bSmrg	  fi
8623f3561b8bSmrg
86246257f37dSmrg	  if test prog = "$linkmode" || test relink = "$opt_mode"; then
8625f3561b8bSmrg	    add_shlibpath=
8626f3561b8bSmrg	    add_dir=
8627f3561b8bSmrg	    add=
8628f3561b8bSmrg	    # Finalize command for both is simple: just hardcode it.
86296257f37dSmrg	    if test yes = "$hardcode_direct" &&
86306257f37dSmrg	       test no = "$hardcode_direct_absolute"; then
86316257f37dSmrg	      add=$libdir/$linklib
86326257f37dSmrg	    elif test yes = "$hardcode_minus_L"; then
86336257f37dSmrg	      add_dir=-L$libdir
86346257f37dSmrg	      add=-l$name
86356257f37dSmrg	    elif test yes = "$hardcode_shlibpath_var"; then
8636f3561b8bSmrg	      case :$finalize_shlibpath: in
8637f3561b8bSmrg	      *":$libdir:"*) ;;
8638bd304fc0Smrg	      *) func_append finalize_shlibpath "$libdir:" ;;
8639f3561b8bSmrg	      esac
86406257f37dSmrg	      add=-l$name
86416257f37dSmrg	    elif test yes = "$hardcode_automatic"; then
8642f3561b8bSmrg	      if test -n "$inst_prefix_dir" &&
86436257f37dSmrg		 test -f "$inst_prefix_dir$libdir/$linklib"; then
86446257f37dSmrg		add=$inst_prefix_dir$libdir/$linklib
8645f3561b8bSmrg	      else
86466257f37dSmrg		add=$libdir/$linklib
8647f3561b8bSmrg	      fi
8648f3561b8bSmrg	    else
8649f3561b8bSmrg	      # We cannot seem to hardcode it, guess we'll fake it.
86506257f37dSmrg	      add_dir=-L$libdir
8651f3561b8bSmrg	      # Try looking first in the location we're being installed to.
8652f3561b8bSmrg	      if test -n "$inst_prefix_dir"; then
8653f3561b8bSmrg		case $libdir in
8654f3561b8bSmrg		  [\\/]*)
8655bd304fc0Smrg		    func_append add_dir " -L$inst_prefix_dir$libdir"
8656f3561b8bSmrg		    ;;
8657f3561b8bSmrg		esac
8658f3561b8bSmrg	      fi
86596257f37dSmrg	      add=-l$name
8660f3561b8bSmrg	    fi
8661f3561b8bSmrg
86626257f37dSmrg	    if test prog = "$linkmode"; then
8663f3561b8bSmrg	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
8664f3561b8bSmrg	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
8665f3561b8bSmrg	    else
8666f3561b8bSmrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
8667f3561b8bSmrg	      test -n "$add" && deplibs="$add $deplibs"
8668f3561b8bSmrg	    fi
8669f3561b8bSmrg	  fi
86706257f37dSmrg	elif test prog = "$linkmode"; then
8671f3561b8bSmrg	  # Here we assume that one of hardcode_direct or hardcode_minus_L
8672f3561b8bSmrg	  # is not unsupported.  This is valid on all known static and
8673f3561b8bSmrg	  # shared platforms.
86746257f37dSmrg	  if test unsupported != "$hardcode_direct"; then
86756257f37dSmrg	    test -n "$old_library" && linklib=$old_library
8676f3561b8bSmrg	    compile_deplibs="$dir/$linklib $compile_deplibs"
8677f3561b8bSmrg	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
8678f3561b8bSmrg	  else
8679f3561b8bSmrg	    compile_deplibs="-l$name -L$dir $compile_deplibs"
8680f3561b8bSmrg	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
8681f3561b8bSmrg	  fi
86826257f37dSmrg	elif test yes = "$build_libtool_libs"; then
8683f3561b8bSmrg	  # Not a shared library
86846257f37dSmrg	  if test pass_all != "$deplibs_check_method"; then
8685f3561b8bSmrg	    # We're trying link a shared library against a static one
8686f3561b8bSmrg	    # but the system doesn't support it.
8687f3561b8bSmrg
8688f3561b8bSmrg	    # Just print a warning and add the library to dependency_libs so
8689f3561b8bSmrg	    # that the program can be linked against the static library.
8690bd304fc0Smrg	    echo
86916257f37dSmrg	    $ECHO "*** Warning: This system cannot link to static lib archive $lib."
8692bd304fc0Smrg	    echo "*** I have the capability to make that library automatically link in when"
8693bd304fc0Smrg	    echo "*** you link to this library.  But I can only do this if you have a"
8694bd304fc0Smrg	    echo "*** shared version of the library, which you do not appear to have."
86956257f37dSmrg	    if test yes = "$module"; then
8696bd304fc0Smrg	      echo "*** But as you try to build a module library, libtool will still create "
8697bd304fc0Smrg	      echo "*** a static module, that should work as long as the dlopening application"
8698bd304fc0Smrg	      echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
8699f3561b8bSmrg	      if test -z "$global_symbol_pipe"; then
8700bd304fc0Smrg		echo
8701bd304fc0Smrg		echo "*** However, this would only work if libtool was able to extract symbol"
87026257f37dSmrg		echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
8703bd304fc0Smrg		echo "*** not find such a program.  So, this module is probably useless."
87046257f37dSmrg		echo "*** 'nm' from GNU binutils and a full rebuild may help."
8705f3561b8bSmrg	      fi
87066257f37dSmrg	      if test no = "$build_old_libs"; then
8707f3561b8bSmrg		build_libtool_libs=module
8708f3561b8bSmrg		build_old_libs=yes
8709f3561b8bSmrg	      else
8710f3561b8bSmrg		build_libtool_libs=no
8711f3561b8bSmrg	      fi
8712f3561b8bSmrg	    fi
8713f3561b8bSmrg	  else
8714f3561b8bSmrg	    deplibs="$dir/$old_library $deplibs"
8715f3561b8bSmrg	    link_static=yes
8716f3561b8bSmrg	  fi
8717f3561b8bSmrg	fi # link shared/static library?
8718f3561b8bSmrg
87196257f37dSmrg	if test lib = "$linkmode"; then
8720f3561b8bSmrg	  if test -n "$dependency_libs" &&
87216257f37dSmrg	     { test yes != "$hardcode_into_libs" ||
87226257f37dSmrg	       test yes = "$build_old_libs" ||
87236257f37dSmrg	       test yes = "$link_static"; }; then
8724f3561b8bSmrg	    # Extract -R from dependency_libs
8725f3561b8bSmrg	    temp_deplibs=
8726f3561b8bSmrg	    for libdir in $dependency_libs; do
8727f3561b8bSmrg	      case $libdir in
8728f3561b8bSmrg	      -R*) func_stripname '-R' '' "$libdir"
8729f3561b8bSmrg	           temp_xrpath=$func_stripname_result
8730f3561b8bSmrg		   case " $xrpath " in
8731f3561b8bSmrg		   *" $temp_xrpath "*) ;;
8732bd304fc0Smrg		   *) func_append xrpath " $temp_xrpath";;
8733f3561b8bSmrg		   esac;;
8734bd304fc0Smrg	      *) func_append temp_deplibs " $libdir";;
8735f3561b8bSmrg	      esac
8736f3561b8bSmrg	    done
87376257f37dSmrg	    dependency_libs=$temp_deplibs
8738f3561b8bSmrg	  fi
8739f3561b8bSmrg
8740bd304fc0Smrg	  func_append newlib_search_path " $absdir"
8741f3561b8bSmrg	  # Link against this library
87426257f37dSmrg	  test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
8743f3561b8bSmrg	  # ... and its dependency_libs
8744f3561b8bSmrg	  tmp_libs=
8745f3561b8bSmrg	  for deplib in $dependency_libs; do
8746f3561b8bSmrg	    newdependency_libs="$deplib $newdependency_libs"
8747bd304fc0Smrg	    case $deplib in
8748bd304fc0Smrg              -L*) func_stripname '-L' '' "$deplib"
8749bd304fc0Smrg                   func_resolve_sysroot "$func_stripname_result";;
8750bd304fc0Smrg              *) func_resolve_sysroot "$deplib" ;;
8751bd304fc0Smrg            esac
87526257f37dSmrg	    if $opt_preserve_dup_deps; then
8753f3561b8bSmrg	      case "$tmp_libs " in
8754bd304fc0Smrg	      *" $func_resolve_sysroot_result "*)
8755bd304fc0Smrg                func_append specialdeplibs " $func_resolve_sysroot_result" ;;
8756f3561b8bSmrg	      esac
8757f3561b8bSmrg	    fi
8758bd304fc0Smrg	    func_append tmp_libs " $func_resolve_sysroot_result"
8759f3561b8bSmrg	  done
8760f3561b8bSmrg
87616257f37dSmrg	  if test no != "$link_all_deplibs"; then
8762f3561b8bSmrg	    # Add the search paths of all dependency libraries
8763f3561b8bSmrg	    for deplib in $dependency_libs; do
87646086d97eSmrg	      path=
8765f3561b8bSmrg	      case $deplib in
87666257f37dSmrg	      -L*) path=$deplib ;;
8767f3561b8bSmrg	      *.la)
8768bd304fc0Smrg	        func_resolve_sysroot "$deplib"
8769bd304fc0Smrg	        deplib=$func_resolve_sysroot_result
8770f3561b8bSmrg	        func_dirname "$deplib" "" "."
8771bd304fc0Smrg		dir=$func_dirname_result
8772f3561b8bSmrg		# We need an absolute path.
8773f3561b8bSmrg		case $dir in
87746257f37dSmrg		[\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;;
8775f3561b8bSmrg		*)
8776f3561b8bSmrg		  absdir=`cd "$dir" && pwd`
8777f3561b8bSmrg		  if test -z "$absdir"; then
87786257f37dSmrg		    func_warning "cannot determine absolute directory name of '$dir'"
87796257f37dSmrg		    absdir=$dir
8780f3561b8bSmrg		  fi
8781f3561b8bSmrg		  ;;
8782f3561b8bSmrg		esac
8783f3561b8bSmrg		if $GREP "^installed=no" $deplib > /dev/null; then
8784f3561b8bSmrg		case $host in
8785f3561b8bSmrg		*-*-darwin*)
8786f3561b8bSmrg		  depdepl=
87876257f37dSmrg		  eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
87886257f37dSmrg		  if test -n "$deplibrary_names"; then
87896257f37dSmrg		    for tmp in $deplibrary_names; do
8790f3561b8bSmrg		      depdepl=$tmp
8791f3561b8bSmrg		    done
87926257f37dSmrg		    if test -f "$absdir/$objdir/$depdepl"; then
87936257f37dSmrg		      depdepl=$absdir/$objdir/$depdepl
87946257f37dSmrg		      darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
8795f3561b8bSmrg                      if test -z "$darwin_install_name"; then
87966257f37dSmrg                          darwin_install_name=`$OTOOL64 -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
8797f3561b8bSmrg                      fi
87986257f37dSmrg		      func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl"
87996257f37dSmrg		      func_append linker_flags " -dylib_file $darwin_install_name:$depdepl"
8800f3561b8bSmrg		      path=
8801f3561b8bSmrg		    fi
8802f3561b8bSmrg		  fi
8803f3561b8bSmrg		  ;;
8804f3561b8bSmrg		*)
88056257f37dSmrg		  path=-L$absdir/$objdir
8806f3561b8bSmrg		  ;;
8807f3561b8bSmrg		esac
8808f3561b8bSmrg		else
88096257f37dSmrg		  eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
8810f3561b8bSmrg		  test -z "$libdir" && \
88116257f37dSmrg		    func_fatal_error "'$deplib' is not a valid libtool archive"
8812f3561b8bSmrg		  test "$absdir" != "$libdir" && \
88136257f37dSmrg		    func_warning "'$deplib' seems to be moved"
8814f3561b8bSmrg
88156257f37dSmrg		  path=-L$absdir
8816f3561b8bSmrg		fi
8817f3561b8bSmrg		;;
8818f3561b8bSmrg	      esac
8819f3561b8bSmrg	      case " $deplibs " in
8820f3561b8bSmrg	      *" $path "*) ;;
8821f3561b8bSmrg	      *) deplibs="$path $deplibs" ;;
8822f3561b8bSmrg	      esac
8823f3561b8bSmrg	    done
8824f3561b8bSmrg	  fi # link_all_deplibs != no
8825f3561b8bSmrg	fi # linkmode = lib
8826f3561b8bSmrg      done # for deplib in $libs
88276257f37dSmrg      if test link = "$pass"; then
88286257f37dSmrg	if test prog = "$linkmode"; then
8829f3561b8bSmrg	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
8830f3561b8bSmrg	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
8831f3561b8bSmrg	else
8832bd304fc0Smrg	  compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8833f3561b8bSmrg	fi
8834f3561b8bSmrg      fi
88356257f37dSmrg      dependency_libs=$newdependency_libs
88366257f37dSmrg      if test dlpreopen = "$pass"; then
8837f3561b8bSmrg	# Link the dlpreopened libraries before other libraries
8838f3561b8bSmrg	for deplib in $save_deplibs; do
8839f3561b8bSmrg	  deplibs="$deplib $deplibs"
8840f3561b8bSmrg	done
8841f3561b8bSmrg      fi
88426257f37dSmrg      if test dlopen != "$pass"; then
88436257f37dSmrg	test conv = "$pass" || {
8844f3561b8bSmrg	  # Make sure lib_search_path contains only unique directories.
8845f3561b8bSmrg	  lib_search_path=
8846f3561b8bSmrg	  for dir in $newlib_search_path; do
8847f3561b8bSmrg	    case "$lib_search_path " in
8848f3561b8bSmrg	    *" $dir "*) ;;
8849bd304fc0Smrg	    *) func_append lib_search_path " $dir" ;;
8850f3561b8bSmrg	    esac
8851f3561b8bSmrg	  done
8852f3561b8bSmrg	  newlib_search_path=
88536257f37dSmrg	}
8854f3561b8bSmrg
88556257f37dSmrg	if test prog,link = "$linkmode,$pass"; then
8856f3561b8bSmrg	  vars="compile_deplibs finalize_deplibs"
88576257f37dSmrg	else
88586257f37dSmrg	  vars=deplibs
8859f3561b8bSmrg	fi
8860f3561b8bSmrg	for var in $vars dependency_libs; do
8861f3561b8bSmrg	  # Add libraries to $var in reverse order
8862f3561b8bSmrg	  eval tmp_libs=\"\$$var\"
8863f3561b8bSmrg	  new_libs=
8864f3561b8bSmrg	  for deplib in $tmp_libs; do
8865f3561b8bSmrg	    # FIXME: Pedantically, this is the right thing to do, so
8866f3561b8bSmrg	    #        that some nasty dependency loop isn't accidentally
8867f3561b8bSmrg	    #        broken:
8868f3561b8bSmrg	    #new_libs="$deplib $new_libs"
8869f3561b8bSmrg	    # Pragmatically, this seems to cause very few problems in
8870f3561b8bSmrg	    # practice:
8871f3561b8bSmrg	    case $deplib in
8872f3561b8bSmrg	    -L*) new_libs="$deplib $new_libs" ;;
8873f3561b8bSmrg	    -R*) ;;
8874f3561b8bSmrg	    *)
8875f3561b8bSmrg	      # And here is the reason: when a library appears more
8876f3561b8bSmrg	      # than once as an explicit dependence of a library, or
8877f3561b8bSmrg	      # is implicitly linked in more than once by the
8878f3561b8bSmrg	      # compiler, it is considered special, and multiple
8879f3561b8bSmrg	      # occurrences thereof are not removed.  Compare this
8880f3561b8bSmrg	      # with having the same library being listed as a
8881f3561b8bSmrg	      # dependency of multiple other libraries: in this case,
8882f3561b8bSmrg	      # we know (pedantically, we assume) the library does not
8883f3561b8bSmrg	      # need to be listed more than once, so we keep only the
8884f3561b8bSmrg	      # last copy.  This is not always right, but it is rare
8885f3561b8bSmrg	      # enough that we require users that really mean to play
8886f3561b8bSmrg	      # such unportable linking tricks to link the library
8887f3561b8bSmrg	      # using -Wl,-lname, so that libtool does not consider it
8888f3561b8bSmrg	      # for duplicate removal.
8889f3561b8bSmrg	      case " $specialdeplibs " in
8890f3561b8bSmrg	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
8891f3561b8bSmrg	      *)
8892f3561b8bSmrg		case " $new_libs " in
8893f3561b8bSmrg		*" $deplib "*) ;;
8894f3561b8bSmrg		*) new_libs="$deplib $new_libs" ;;
8895f3561b8bSmrg		esac
8896f3561b8bSmrg		;;
8897f3561b8bSmrg	      esac
8898f3561b8bSmrg	      ;;
8899f3561b8bSmrg	    esac
8900f3561b8bSmrg	  done
8901f3561b8bSmrg	  tmp_libs=
8902f3561b8bSmrg	  for deplib in $new_libs; do
8903f3561b8bSmrg	    case $deplib in
8904f3561b8bSmrg	    -L*)
8905f3561b8bSmrg	      case " $tmp_libs " in
8906f3561b8bSmrg	      *" $deplib "*) ;;
8907bd304fc0Smrg	      *) func_append tmp_libs " $deplib" ;;
8908f3561b8bSmrg	      esac
8909f3561b8bSmrg	      ;;
8910bd304fc0Smrg	    *) func_append tmp_libs " $deplib" ;;
8911f3561b8bSmrg	    esac
8912f3561b8bSmrg	  done
8913f3561b8bSmrg	  eval $var=\"$tmp_libs\"
8914f3561b8bSmrg	done # for var
8915f3561b8bSmrg      fi
89166257f37dSmrg
89176257f37dSmrg      # Add Sun CC postdeps if required:
89186257f37dSmrg      test CXX = "$tagname" && {
89196257f37dSmrg        case $host_os in
89206257f37dSmrg        linux*)
8921d422ce2eSmrg          case `$CC -V 2>&1 | $SED 5q` in
89226257f37dSmrg          *Sun\ C*) # Sun C++ 5.9
89236257f37dSmrg            func_suncc_cstd_abi
89246257f37dSmrg
89256257f37dSmrg            if test no != "$suncc_use_cstd_abi"; then
89266257f37dSmrg              func_append postdeps ' -library=Cstd -library=Crun'
89276257f37dSmrg            fi
89286257f37dSmrg            ;;
89296257f37dSmrg          esac
89306257f37dSmrg          ;;
89316257f37dSmrg
89326257f37dSmrg        solaris*)
89336257f37dSmrg          func_cc_basename "$CC"
89346257f37dSmrg          case $func_cc_basename_result in
89356257f37dSmrg          CC* | sunCC*)
89366257f37dSmrg            func_suncc_cstd_abi
89376257f37dSmrg
89386257f37dSmrg            if test no != "$suncc_use_cstd_abi"; then
89396257f37dSmrg              func_append postdeps ' -library=Cstd -library=Crun'
89406257f37dSmrg            fi
89416257f37dSmrg            ;;
89426257f37dSmrg          esac
89436257f37dSmrg          ;;
89446257f37dSmrg        esac
89456257f37dSmrg      }
89466257f37dSmrg
8947f3561b8bSmrg      # Last step: remove runtime libs from dependency_libs
8948f3561b8bSmrg      # (they stay in deplibs)
8949f3561b8bSmrg      tmp_libs=
89506257f37dSmrg      for i in $dependency_libs; do
8951f3561b8bSmrg	case " $predeps $postdeps $compiler_lib_search_path " in
8952f3561b8bSmrg	*" $i "*)
89536257f37dSmrg	  i=
8954f3561b8bSmrg	  ;;
8955f3561b8bSmrg	esac
89566257f37dSmrg	if test -n "$i"; then
8957bd304fc0Smrg	  func_append tmp_libs " $i"
8958f3561b8bSmrg	fi
8959f3561b8bSmrg      done
8960f3561b8bSmrg      dependency_libs=$tmp_libs
8961f3561b8bSmrg    done # for pass
89626257f37dSmrg    if test prog = "$linkmode"; then
89636257f37dSmrg      dlfiles=$newdlfiles
8964f3561b8bSmrg    fi
89656257f37dSmrg    if test prog = "$linkmode" || test lib = "$linkmode"; then
89666257f37dSmrg      dlprefiles=$newdlprefiles
8967f3561b8bSmrg    fi
8968f3561b8bSmrg
8969f3561b8bSmrg    case $linkmode in
8970f3561b8bSmrg    oldlib)
89716257f37dSmrg      if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
89726257f37dSmrg	func_warning "'-dlopen' is ignored for archives"
8973f3561b8bSmrg      fi
8974f3561b8bSmrg
8975f3561b8bSmrg      case " $deplibs" in
8976f3561b8bSmrg      *\ -l* | *\ -L*)
89776257f37dSmrg	func_warning "'-l' and '-L' are ignored for archives" ;;
8978f3561b8bSmrg      esac
8979f3561b8bSmrg
8980f3561b8bSmrg      test -n "$rpath" && \
89816257f37dSmrg	func_warning "'-rpath' is ignored for archives"
8982f3561b8bSmrg
8983f3561b8bSmrg      test -n "$xrpath" && \
89846257f37dSmrg	func_warning "'-R' is ignored for archives"
8985f3561b8bSmrg
8986f3561b8bSmrg      test -n "$vinfo" && \
89876257f37dSmrg	func_warning "'-version-info/-version-number' is ignored for archives"
8988f3561b8bSmrg
8989f3561b8bSmrg      test -n "$release" && \
89906257f37dSmrg	func_warning "'-release' is ignored for archives"
8991f3561b8bSmrg
8992f3561b8bSmrg      test -n "$export_symbols$export_symbols_regex" && \
89936257f37dSmrg	func_warning "'-export-symbols' is ignored for archives"
8994f3561b8bSmrg
8995f3561b8bSmrg      # Now set the variables for building old libraries.
8996f3561b8bSmrg      build_libtool_libs=no
89976257f37dSmrg      oldlibs=$output
8998bd304fc0Smrg      func_append objs "$old_deplibs"
8999f3561b8bSmrg      ;;
9000f3561b8bSmrg
9001f3561b8bSmrg    lib)
90026257f37dSmrg      # Make sure we only generate libraries of the form 'libNAME.la'.
9003f3561b8bSmrg      case $outputname in
9004f3561b8bSmrg      lib*)
9005f3561b8bSmrg	func_stripname 'lib' '.la' "$outputname"
9006f3561b8bSmrg	name=$func_stripname_result
9007f3561b8bSmrg	eval shared_ext=\"$shrext_cmds\"
9008f3561b8bSmrg	eval libname=\"$libname_spec\"
9009f3561b8bSmrg	;;
9010f3561b8bSmrg      *)
90116257f37dSmrg	test no = "$module" \
90126257f37dSmrg	  && func_fatal_help "libtool library '$output' must begin with 'lib'"
9013f3561b8bSmrg
90146257f37dSmrg	if test no != "$need_lib_prefix"; then
9015f3561b8bSmrg	  # Add the "lib" prefix for modules if required
9016f3561b8bSmrg	  func_stripname '' '.la' "$outputname"
9017f3561b8bSmrg	  name=$func_stripname_result
9018f3561b8bSmrg	  eval shared_ext=\"$shrext_cmds\"
9019f3561b8bSmrg	  eval libname=\"$libname_spec\"
9020f3561b8bSmrg	else
9021f3561b8bSmrg	  func_stripname '' '.la' "$outputname"
9022f3561b8bSmrg	  libname=$func_stripname_result
9023f3561b8bSmrg	fi
9024f3561b8bSmrg	;;
9025f3561b8bSmrg      esac
9026f3561b8bSmrg
9027f3561b8bSmrg      if test -n "$objs"; then
90286257f37dSmrg	if test pass_all != "$deplibs_check_method"; then
90296257f37dSmrg	  func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs"
9030f3561b8bSmrg	else
9031bd304fc0Smrg	  echo
9032f3561b8bSmrg	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
9033f3561b8bSmrg	  $ECHO "*** objects $objs is not portable!"
9034bd304fc0Smrg	  func_append libobjs " $objs"
9035f3561b8bSmrg	fi
9036f3561b8bSmrg      fi
9037f3561b8bSmrg
90386257f37dSmrg      test no = "$dlself" \
90396257f37dSmrg	|| func_warning "'-dlopen self' is ignored for libtool libraries"
9040f3561b8bSmrg
9041f3561b8bSmrg      set dummy $rpath
9042f3561b8bSmrg      shift
90436257f37dSmrg      test 1 -lt "$#" \
90446257f37dSmrg	&& func_warning "ignoring multiple '-rpath's for a libtool library"
9045f3561b8bSmrg
90466257f37dSmrg      install_libdir=$1
9047f3561b8bSmrg
9048f3561b8bSmrg      oldlibs=
9049f3561b8bSmrg      if test -z "$rpath"; then
90506257f37dSmrg	if test yes = "$build_libtool_libs"; then
9051f3561b8bSmrg	  # Building a libtool convenience library.
90526257f37dSmrg	  # Some compilers have problems with a '.al' extension so
9053f3561b8bSmrg	  # convenience libraries should have the same extension an
9054f3561b8bSmrg	  # archive normally would.
9055f3561b8bSmrg	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
9056f3561b8bSmrg	  build_libtool_libs=convenience
9057f3561b8bSmrg	  build_old_libs=yes
9058f3561b8bSmrg	fi
9059f3561b8bSmrg
9060f3561b8bSmrg	test -n "$vinfo" && \
90616257f37dSmrg	  func_warning "'-version-info/-version-number' is ignored for convenience libraries"
9062f3561b8bSmrg
9063f3561b8bSmrg	test -n "$release" && \
90646257f37dSmrg	  func_warning "'-release' is ignored for convenience libraries"
9065f3561b8bSmrg      else
9066f3561b8bSmrg
9067f3561b8bSmrg	# Parse the version information argument.
90686257f37dSmrg	save_ifs=$IFS; IFS=:
9069f3561b8bSmrg	set dummy $vinfo 0 0 0
9070f3561b8bSmrg	shift
90716257f37dSmrg	IFS=$save_ifs
9072f3561b8bSmrg
9073f3561b8bSmrg	test -n "$7" && \
90746257f37dSmrg	  func_fatal_help "too many parameters to '-version-info'"
9075f3561b8bSmrg
9076f3561b8bSmrg	# convert absolute version numbers to libtool ages
9077f3561b8bSmrg	# this retains compatibility with .la files and attempts
9078f3561b8bSmrg	# to make the code below a bit more comprehensible
9079f3561b8bSmrg
9080f3561b8bSmrg	case $vinfo_number in
9081f3561b8bSmrg	yes)
90826257f37dSmrg	  number_major=$1
90836257f37dSmrg	  number_minor=$2
90846257f37dSmrg	  number_revision=$3
9085f3561b8bSmrg	  #
9086f3561b8bSmrg	  # There are really only two kinds -- those that
9087f3561b8bSmrg	  # use the current revision as the major version
9088f3561b8bSmrg	  # and those that subtract age and use age as
9089f3561b8bSmrg	  # a minor version.  But, then there is irix
90906257f37dSmrg	  # that has an extra 1 added just for fun
9091f3561b8bSmrg	  #
9092f3561b8bSmrg	  case $version_type in
9093bd304fc0Smrg	  # correct linux to gnu/linux during the next big refactor
9094d422ce2eSmrg	  darwin|freebsd-elf|linux|midnightbsd-elf|osf|windows|none)
9095f3561b8bSmrg	    func_arith $number_major + $number_minor
9096f3561b8bSmrg	    current=$func_arith_result
90976257f37dSmrg	    age=$number_minor
90986257f37dSmrg	    revision=$number_revision
9099f3561b8bSmrg	    ;;
91006257f37dSmrg	  freebsd-aout|qnx|sunos)
91016257f37dSmrg	    current=$number_major
91026257f37dSmrg	    revision=$number_minor
91036257f37dSmrg	    age=0
9104f3561b8bSmrg	    ;;
9105f3561b8bSmrg	  irix|nonstopux)
9106f3561b8bSmrg	    func_arith $number_major + $number_minor
9107f3561b8bSmrg	    current=$func_arith_result
91086257f37dSmrg	    age=$number_minor
91096257f37dSmrg	    revision=$number_minor
9110f3561b8bSmrg	    lt_irix_increment=no
9111f3561b8bSmrg	    ;;
9112f3561b8bSmrg	  esac
9113f3561b8bSmrg	  ;;
9114f3561b8bSmrg	no)
91156257f37dSmrg	  current=$1
91166257f37dSmrg	  revision=$2
91176257f37dSmrg	  age=$3
9118f3561b8bSmrg	  ;;
9119f3561b8bSmrg	esac
9120f3561b8bSmrg
9121f3561b8bSmrg	# Check that each of the things are valid numbers.
9122f3561b8bSmrg	case $current in
9123f3561b8bSmrg	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]) ;;
9124f3561b8bSmrg	*)
91256257f37dSmrg	  func_error "CURRENT '$current' must be a nonnegative integer"
91266257f37dSmrg	  func_fatal_error "'$vinfo' is not valid version information"
9127f3561b8bSmrg	  ;;
9128f3561b8bSmrg	esac
9129f3561b8bSmrg
9130f3561b8bSmrg	case $revision in
9131f3561b8bSmrg	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]) ;;
9132f3561b8bSmrg	*)
91336257f37dSmrg	  func_error "REVISION '$revision' must be a nonnegative integer"
91346257f37dSmrg	  func_fatal_error "'$vinfo' is not valid version information"
9135f3561b8bSmrg	  ;;
9136f3561b8bSmrg	esac
9137f3561b8bSmrg
9138f3561b8bSmrg	case $age in
9139f3561b8bSmrg	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]) ;;
9140f3561b8bSmrg	*)
91416257f37dSmrg	  func_error "AGE '$age' must be a nonnegative integer"
91426257f37dSmrg	  func_fatal_error "'$vinfo' is not valid version information"
9143f3561b8bSmrg	  ;;
9144f3561b8bSmrg	esac
9145f3561b8bSmrg
9146f3561b8bSmrg	if test "$age" -gt "$current"; then
91476257f37dSmrg	  func_error "AGE '$age' is greater than the current interface number '$current'"
91486257f37dSmrg	  func_fatal_error "'$vinfo' is not valid version information"
9149f3561b8bSmrg	fi
9150f3561b8bSmrg
9151f3561b8bSmrg	# Calculate the version variables.
9152f3561b8bSmrg	major=
9153f3561b8bSmrg	versuffix=
9154f3561b8bSmrg	verstring=
9155f3561b8bSmrg	case $version_type in
9156f3561b8bSmrg	none) ;;
9157f3561b8bSmrg
9158f3561b8bSmrg	darwin)
9159f3561b8bSmrg	  # Like Linux, but with the current version available in
9160f3561b8bSmrg	  # verstring for coding it into the library header
9161f3561b8bSmrg	  func_arith $current - $age
9162f3561b8bSmrg	  major=.$func_arith_result
91636257f37dSmrg	  versuffix=$major.$age.$revision
9164f3561b8bSmrg	  # Darwin ld doesn't like 0 for these options...
9165f3561b8bSmrg	  func_arith $current + 1
9166f3561b8bSmrg	  minor_current=$func_arith_result
91676257f37dSmrg	  xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
9168f3561b8bSmrg	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
91696257f37dSmrg          # On Darwin other compilers
91706257f37dSmrg          case $CC in
91716257f37dSmrg              nagfor*)
91726257f37dSmrg                  verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
91736257f37dSmrg                  ;;
91746257f37dSmrg              *)
91756257f37dSmrg                  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
91766257f37dSmrg                  ;;
91776257f37dSmrg          esac
9178f3561b8bSmrg	  ;;
9179f3561b8bSmrg
9180f3561b8bSmrg	freebsd-aout)
91816257f37dSmrg	  major=.$current
91826257f37dSmrg	  versuffix=.$current.$revision
9183f3561b8bSmrg	  ;;
9184f3561b8bSmrg
9185d422ce2eSmrg	freebsd-elf | midnightbsd-elf)
91866257f37dSmrg	  func_arith $current - $age
91876257f37dSmrg	  major=.$func_arith_result
91886257f37dSmrg	  versuffix=$major.$age.$revision
9189f3561b8bSmrg	  ;;
9190f3561b8bSmrg
9191f3561b8bSmrg	irix | nonstopux)
91926257f37dSmrg	  if test no = "$lt_irix_increment"; then
9193f3561b8bSmrg	    func_arith $current - $age
9194f3561b8bSmrg	  else
9195f3561b8bSmrg	    func_arith $current - $age + 1
9196f3561b8bSmrg	  fi
9197f3561b8bSmrg	  major=$func_arith_result
9198f3561b8bSmrg
9199f3561b8bSmrg	  case $version_type in
9200f3561b8bSmrg	    nonstopux) verstring_prefix=nonstopux ;;
9201f3561b8bSmrg	    *)         verstring_prefix=sgi ;;
9202f3561b8bSmrg	  esac
92036257f37dSmrg	  verstring=$verstring_prefix$major.$revision
9204f3561b8bSmrg
9205f3561b8bSmrg	  # Add in all the interfaces that we are compatible with.
9206f3561b8bSmrg	  loop=$revision
92076257f37dSmrg	  while test 0 -ne "$loop"; do
9208f3561b8bSmrg	    func_arith $revision - $loop
9209f3561b8bSmrg	    iface=$func_arith_result
9210f3561b8bSmrg	    func_arith $loop - 1
9211f3561b8bSmrg	    loop=$func_arith_result
92126257f37dSmrg	    verstring=$verstring_prefix$major.$iface:$verstring
9213f3561b8bSmrg	  done
9214f3561b8bSmrg
92156257f37dSmrg	  # Before this point, $major must not contain '.'.
9216f3561b8bSmrg	  major=.$major
92176257f37dSmrg	  versuffix=$major.$revision
9218f3561b8bSmrg	  ;;
9219f3561b8bSmrg
9220bd304fc0Smrg	linux) # correct to gnu/linux during the next big refactor
9221f3561b8bSmrg	  func_arith $current - $age
9222f3561b8bSmrg	  major=.$func_arith_result
92236257f37dSmrg	  versuffix=$major.$age.$revision
9224f3561b8bSmrg	  ;;
9225f3561b8bSmrg
9226f3561b8bSmrg	osf)
9227f3561b8bSmrg	  func_arith $current - $age
9228f3561b8bSmrg	  major=.$func_arith_result
92296257f37dSmrg	  versuffix=.$current.$age.$revision
92306257f37dSmrg	  verstring=$current.$age.$revision
9231f3561b8bSmrg
9232f3561b8bSmrg	  # Add in all the interfaces that we are compatible with.
9233f3561b8bSmrg	  loop=$age
92346257f37dSmrg	  while test 0 -ne "$loop"; do
9235f3561b8bSmrg	    func_arith $current - $loop
9236f3561b8bSmrg	    iface=$func_arith_result
9237f3561b8bSmrg	    func_arith $loop - 1
9238f3561b8bSmrg	    loop=$func_arith_result
92396257f37dSmrg	    verstring=$verstring:$iface.0
9240f3561b8bSmrg	  done
9241f3561b8bSmrg
9242f3561b8bSmrg	  # Make executables depend on our current version.
92436257f37dSmrg	  func_append verstring ":$current.0"
9244f3561b8bSmrg	  ;;
9245f3561b8bSmrg
9246f3561b8bSmrg	qnx)
92476257f37dSmrg	  major=.$current
92486257f37dSmrg	  versuffix=.$current
92496257f37dSmrg	  ;;
92506257f37dSmrg
92516257f37dSmrg	sco)
92526257f37dSmrg	  major=.$current
92536257f37dSmrg	  versuffix=.$current
9254f3561b8bSmrg	  ;;
9255f3561b8bSmrg
9256f3561b8bSmrg	sunos)
92576257f37dSmrg	  major=.$current
92586257f37dSmrg	  versuffix=.$current.$revision
9259f3561b8bSmrg	  ;;
9260f3561b8bSmrg
9261f3561b8bSmrg	windows)
9262f3561b8bSmrg	  # Use '-' rather than '.', since we only want one
92636257f37dSmrg	  # extension on DOS 8.3 file systems.
9264f3561b8bSmrg	  func_arith $current - $age
9265f3561b8bSmrg	  major=$func_arith_result
92666257f37dSmrg	  versuffix=-$major
9267f3561b8bSmrg	  ;;
9268f3561b8bSmrg
9269f3561b8bSmrg	*)
92706257f37dSmrg	  func_fatal_configuration "unknown library version type '$version_type'"
9271f3561b8bSmrg	  ;;
9272f3561b8bSmrg	esac
9273f3561b8bSmrg
9274f3561b8bSmrg	# Clear the version info if we defaulted, and they specified a release.
9275f3561b8bSmrg	if test -z "$vinfo" && test -n "$release"; then
9276f3561b8bSmrg	  major=
9277f3561b8bSmrg	  case $version_type in
9278f3561b8bSmrg	  darwin)
9279f3561b8bSmrg	    # we can't check for "0.0" in archive_cmds due to quoting
9280f3561b8bSmrg	    # problems, so we reset it completely
9281f3561b8bSmrg	    verstring=
9282f3561b8bSmrg	    ;;
9283f3561b8bSmrg	  *)
92846257f37dSmrg	    verstring=0.0
9285f3561b8bSmrg	    ;;
9286f3561b8bSmrg	  esac
92876257f37dSmrg	  if test no = "$need_version"; then
9288f3561b8bSmrg	    versuffix=
9289f3561b8bSmrg	  else
92906257f37dSmrg	    versuffix=.0.0
9291f3561b8bSmrg	  fi
9292f3561b8bSmrg	fi
9293f3561b8bSmrg
9294f3561b8bSmrg	# Remove version info from name if versioning should be avoided
92956257f37dSmrg	if test yes,no = "$avoid_version,$need_version"; then
9296f3561b8bSmrg	  major=
9297f3561b8bSmrg	  versuffix=
92986257f37dSmrg	  verstring=
9299f3561b8bSmrg	fi
9300f3561b8bSmrg
9301f3561b8bSmrg	# Check to see if the archive will have undefined symbols.
93026257f37dSmrg	if test yes = "$allow_undefined"; then
93036257f37dSmrg	  if test unsupported = "$allow_undefined_flag"; then
93046257f37dSmrg	    if test yes = "$build_old_libs"; then
93056257f37dSmrg	      func_warning "undefined symbols not allowed in $host shared libraries; building static only"
93066257f37dSmrg	      build_libtool_libs=no
93076257f37dSmrg	    else
93086257f37dSmrg	      func_fatal_error "can't build $host shared library unless -no-undefined is specified"
93096257f37dSmrg	    fi
9310f3561b8bSmrg	  fi
9311f3561b8bSmrg	else
9312f3561b8bSmrg	  # Don't allow undefined symbols.
93136257f37dSmrg	  allow_undefined_flag=$no_undefined_flag
9314f3561b8bSmrg	fi
9315f3561b8bSmrg
9316f3561b8bSmrg      fi
9317f3561b8bSmrg
93186257f37dSmrg      func_generate_dlsyms "$libname" "$libname" :
9319bd304fc0Smrg      func_append libobjs " $symfileobj"
93206257f37dSmrg      test " " = "$libobjs" && libobjs=
9321f3561b8bSmrg
93226257f37dSmrg      if test relink != "$opt_mode"; then
9323f3561b8bSmrg	# Remove our outputs, but don't remove object files since they
9324f3561b8bSmrg	# may have been created when compiling PIC objects.
9325f3561b8bSmrg	removelist=
9326f3561b8bSmrg	tempremovelist=`$ECHO "$output_objdir/*"`
9327f3561b8bSmrg	for p in $tempremovelist; do
9328f3561b8bSmrg	  case $p in
9329f3561b8bSmrg	    *.$objext | *.gcno)
9330f3561b8bSmrg	       ;;
93316257f37dSmrg	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*)
93326257f37dSmrg	       if test -n "$precious_files_regex"; then
9333f3561b8bSmrg		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
9334f3561b8bSmrg		 then
9335f3561b8bSmrg		   continue
9336f3561b8bSmrg		 fi
9337f3561b8bSmrg	       fi
9338bd304fc0Smrg	       func_append removelist " $p"
9339f3561b8bSmrg	       ;;
9340f3561b8bSmrg	    *) ;;
9341f3561b8bSmrg	  esac
9342f3561b8bSmrg	done
9343f3561b8bSmrg	test -n "$removelist" && \
9344f3561b8bSmrg	  func_show_eval "${RM}r \$removelist"
9345f3561b8bSmrg      fi
9346f3561b8bSmrg
9347f3561b8bSmrg      # Now set the variables for building old libraries.
93486257f37dSmrg      if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then
9349bd304fc0Smrg	func_append oldlibs " $output_objdir/$libname.$libext"
9350f3561b8bSmrg
9351f3561b8bSmrg	# Transform .lo files to .o files.
93526257f37dSmrg	oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP`
9353f3561b8bSmrg      fi
9354f3561b8bSmrg
9355f3561b8bSmrg      # Eliminate all temporary directories.
9356f3561b8bSmrg      #for path in $notinst_path; do
9357bd304fc0Smrg      #	lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
9358bd304fc0Smrg      #	deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
9359bd304fc0Smrg      #	dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
9360f3561b8bSmrg      #done
9361f3561b8bSmrg
9362f3561b8bSmrg      if test -n "$xrpath"; then
9363f3561b8bSmrg	# If the user specified any rpath flags, then add them.
9364f3561b8bSmrg	temp_xrpath=
9365f3561b8bSmrg	for libdir in $xrpath; do
9366bd304fc0Smrg	  func_replace_sysroot "$libdir"
9367bd304fc0Smrg	  func_append temp_xrpath " -R$func_replace_sysroot_result"
9368f3561b8bSmrg	  case "$finalize_rpath " in
9369f3561b8bSmrg	  *" $libdir "*) ;;
9370bd304fc0Smrg	  *) func_append finalize_rpath " $libdir" ;;
9371f3561b8bSmrg	  esac
9372f3561b8bSmrg	done
93736257f37dSmrg	if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then
9374f3561b8bSmrg	  dependency_libs="$temp_xrpath $dependency_libs"
9375f3561b8bSmrg	fi
9376f3561b8bSmrg      fi
9377f3561b8bSmrg
9378f3561b8bSmrg      # Make sure dlfiles contains only unique files that won't be dlpreopened
93796257f37dSmrg      old_dlfiles=$dlfiles
9380f3561b8bSmrg      dlfiles=
9381f3561b8bSmrg      for lib in $old_dlfiles; do
9382f3561b8bSmrg	case " $dlprefiles $dlfiles " in
9383f3561b8bSmrg	*" $lib "*) ;;
9384bd304fc0Smrg	*) func_append dlfiles " $lib" ;;
9385f3561b8bSmrg	esac
9386f3561b8bSmrg      done
9387f3561b8bSmrg
9388f3561b8bSmrg      # Make sure dlprefiles contains only unique files
93896257f37dSmrg      old_dlprefiles=$dlprefiles
9390f3561b8bSmrg      dlprefiles=
9391f3561b8bSmrg      for lib in $old_dlprefiles; do
9392f3561b8bSmrg	case "$dlprefiles " in
9393f3561b8bSmrg	*" $lib "*) ;;
9394bd304fc0Smrg	*) func_append dlprefiles " $lib" ;;
9395f3561b8bSmrg	esac
9396f3561b8bSmrg      done
9397f3561b8bSmrg
93986257f37dSmrg      if test yes = "$build_libtool_libs"; then
9399f3561b8bSmrg	if test -n "$rpath"; then
9400f3561b8bSmrg	  case $host in
9401bd304fc0Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
9402f3561b8bSmrg	    # these systems don't actually have a c library (as such)!
9403f3561b8bSmrg	    ;;
9404f3561b8bSmrg	  *-*-rhapsody* | *-*-darwin1.[012])
9405f3561b8bSmrg	    # Rhapsody C library is in the System framework
9406bd304fc0Smrg	    func_append deplibs " System.ltframework"
9407f3561b8bSmrg	    ;;
9408f3561b8bSmrg	  *-*-netbsd*)
9409f3561b8bSmrg	    # Don't link with libc until the a.out ld.so is fixed.
9410f3561b8bSmrg	    ;;
9411d422ce2eSmrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-midnightbsd*)
9412f3561b8bSmrg	    # Do not include libc due to us having libc/libc_r.
9413f3561b8bSmrg	    ;;
9414f3561b8bSmrg	  *-*-sco3.2v5* | *-*-sco5v6*)
9415f3561b8bSmrg	    # Causes problems with __ctype
9416f3561b8bSmrg	    ;;
9417f3561b8bSmrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
9418f3561b8bSmrg	    # Compiler inserts libc in the correct place for threads to work
9419f3561b8bSmrg	    ;;
9420f3561b8bSmrg	  *)
9421f3561b8bSmrg	    # Add libc to deplibs on all other systems if necessary.
94226257f37dSmrg	    if test yes = "$build_libtool_need_lc"; then
9423bd304fc0Smrg	      func_append deplibs " -lc"
9424f3561b8bSmrg	    fi
9425f3561b8bSmrg	    ;;
9426f3561b8bSmrg	  esac
9427f3561b8bSmrg	fi
9428f3561b8bSmrg
9429f3561b8bSmrg	# Transform deplibs into only deplibs that can be linked in shared.
9430f3561b8bSmrg	name_save=$name
9431f3561b8bSmrg	libname_save=$libname
9432f3561b8bSmrg	release_save=$release
9433f3561b8bSmrg	versuffix_save=$versuffix
9434f3561b8bSmrg	major_save=$major
9435f3561b8bSmrg	# I'm not sure if I'm treating the release correctly.  I think
9436f3561b8bSmrg	# release should show up in the -l (ie -lgmp5) so we don't want to
9437f3561b8bSmrg	# add it in twice.  Is that correct?
94386257f37dSmrg	release=
94396257f37dSmrg	versuffix=
94406257f37dSmrg	major=
9441f3561b8bSmrg	newdeplibs=
9442f3561b8bSmrg	droppeddeps=no
9443f3561b8bSmrg	case $deplibs_check_method in
9444f3561b8bSmrg	pass_all)
9445f3561b8bSmrg	  # Don't check for shared/static.  Everything works.
9446f3561b8bSmrg	  # This might be a little naive.  We might want to check
9447f3561b8bSmrg	  # whether the library exists or not.  But this is on
9448f3561b8bSmrg	  # osf3 & osf4 and I'm not really sure... Just
9449f3561b8bSmrg	  # implementing what was already the behavior.
9450f3561b8bSmrg	  newdeplibs=$deplibs
9451f3561b8bSmrg	  ;;
9452f3561b8bSmrg	test_compile)
9453f3561b8bSmrg	  # This code stresses the "libraries are programs" paradigm to its
9454f3561b8bSmrg	  # limits. Maybe even breaks it.  We compile a program, linking it
9455f3561b8bSmrg	  # against the deplibs as a proxy for the library.  Then we can check
9456f3561b8bSmrg	  # whether they linked in statically or dynamically with ldd.
9457f3561b8bSmrg	  $opt_dry_run || $RM conftest.c
9458f3561b8bSmrg	  cat > conftest.c <<EOF
9459f3561b8bSmrg	  int main() { return 0; }
9460f3561b8bSmrgEOF
9461f3561b8bSmrg	  $opt_dry_run || $RM conftest
9462f3561b8bSmrg	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
9463f3561b8bSmrg	    ldd_output=`ldd conftest`
9464f3561b8bSmrg	    for i in $deplibs; do
9465f3561b8bSmrg	      case $i in
9466f3561b8bSmrg	      -l*)
9467f3561b8bSmrg		func_stripname -l '' "$i"
9468f3561b8bSmrg		name=$func_stripname_result
94696257f37dSmrg		if test yes = "$allow_libtool_libs_with_static_runtimes"; then
9470f3561b8bSmrg		  case " $predeps $postdeps " in
9471f3561b8bSmrg		  *" $i "*)
9472bd304fc0Smrg		    func_append newdeplibs " $i"
94736257f37dSmrg		    i=
9474f3561b8bSmrg		    ;;
9475f3561b8bSmrg		  esac
9476f3561b8bSmrg		fi
94776257f37dSmrg		if test -n "$i"; then
9478f3561b8bSmrg		  libname=`eval "\\$ECHO \"$libname_spec\""`
9479f3561b8bSmrg		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
9480f3561b8bSmrg		  set dummy $deplib_matches; shift
9481f3561b8bSmrg		  deplib_match=$1
94826257f37dSmrg		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
9483bd304fc0Smrg		    func_append newdeplibs " $i"
9484f3561b8bSmrg		  else
9485f3561b8bSmrg		    droppeddeps=yes
9486bd304fc0Smrg		    echo
9487f3561b8bSmrg		    $ECHO "*** Warning: dynamic linker does not accept needed library $i."
9488bd304fc0Smrg		    echo "*** I have the capability to make that library automatically link in when"
9489bd304fc0Smrg		    echo "*** you link to this library.  But I can only do this if you have a"
9490bd304fc0Smrg		    echo "*** shared version of the library, which I believe you do not have"
9491bd304fc0Smrg		    echo "*** because a test_compile did reveal that the linker did not use it for"
9492bd304fc0Smrg		    echo "*** its dynamic dependency list that programs get resolved with at runtime."
9493f3561b8bSmrg		  fi
9494f3561b8bSmrg		fi
9495f3561b8bSmrg		;;
9496f3561b8bSmrg	      *)
9497bd304fc0Smrg		func_append newdeplibs " $i"
9498f3561b8bSmrg		;;
9499f3561b8bSmrg	      esac
9500f3561b8bSmrg	    done
9501f3561b8bSmrg	  else
9502f3561b8bSmrg	    # Error occurred in the first compile.  Let's try to salvage
9503f3561b8bSmrg	    # the situation: Compile a separate program for each library.
9504f3561b8bSmrg	    for i in $deplibs; do
9505f3561b8bSmrg	      case $i in
9506f3561b8bSmrg	      -l*)
9507f3561b8bSmrg		func_stripname -l '' "$i"
9508f3561b8bSmrg		name=$func_stripname_result
9509f3561b8bSmrg		$opt_dry_run || $RM conftest
9510f3561b8bSmrg		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
9511f3561b8bSmrg		  ldd_output=`ldd conftest`
95126257f37dSmrg		  if test yes = "$allow_libtool_libs_with_static_runtimes"; then
9513f3561b8bSmrg		    case " $predeps $postdeps " in
9514f3561b8bSmrg		    *" $i "*)
9515bd304fc0Smrg		      func_append newdeplibs " $i"
95166257f37dSmrg		      i=
9517f3561b8bSmrg		      ;;
9518f3561b8bSmrg		    esac
9519f3561b8bSmrg		  fi
95206257f37dSmrg		  if test -n "$i"; then
9521f3561b8bSmrg		    libname=`eval "\\$ECHO \"$libname_spec\""`
9522f3561b8bSmrg		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
9523f3561b8bSmrg		    set dummy $deplib_matches; shift
9524f3561b8bSmrg		    deplib_match=$1
95256257f37dSmrg		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
9526bd304fc0Smrg		      func_append newdeplibs " $i"
9527f3561b8bSmrg		    else
9528f3561b8bSmrg		      droppeddeps=yes
9529bd304fc0Smrg		      echo
9530f3561b8bSmrg		      $ECHO "*** Warning: dynamic linker does not accept needed library $i."
9531bd304fc0Smrg		      echo "*** I have the capability to make that library automatically link in when"
9532bd304fc0Smrg		      echo "*** you link to this library.  But I can only do this if you have a"
9533bd304fc0Smrg		      echo "*** shared version of the library, which you do not appear to have"
9534bd304fc0Smrg		      echo "*** because a test_compile did reveal that the linker did not use this one"
9535bd304fc0Smrg		      echo "*** as a dynamic dependency that programs can get resolved with at runtime."
9536f3561b8bSmrg		    fi
9537f3561b8bSmrg		  fi
9538f3561b8bSmrg		else
9539f3561b8bSmrg		  droppeddeps=yes
9540bd304fc0Smrg		  echo
9541f3561b8bSmrg		  $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
9542bd304fc0Smrg		  echo "*** make it link in!  You will probably need to install it or some"
9543bd304fc0Smrg		  echo "*** library that it depends on before this library will be fully"
9544bd304fc0Smrg		  echo "*** functional.  Installing it before continuing would be even better."
9545f3561b8bSmrg		fi
9546f3561b8bSmrg		;;
9547f3561b8bSmrg	      *)
9548bd304fc0Smrg		func_append newdeplibs " $i"
9549f3561b8bSmrg		;;
9550f3561b8bSmrg	      esac
9551f3561b8bSmrg	    done
9552f3561b8bSmrg	  fi
9553f3561b8bSmrg	  ;;
9554f3561b8bSmrg	file_magic*)
9555f3561b8bSmrg	  set dummy $deplibs_check_method; shift
9556f3561b8bSmrg	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
9557f3561b8bSmrg	  for a_deplib in $deplibs; do
9558f3561b8bSmrg	    case $a_deplib in
9559f3561b8bSmrg	    -l*)
9560f3561b8bSmrg	      func_stripname -l '' "$a_deplib"
9561f3561b8bSmrg	      name=$func_stripname_result
95626257f37dSmrg	      if test yes = "$allow_libtool_libs_with_static_runtimes"; then
9563f3561b8bSmrg		case " $predeps $postdeps " in
9564f3561b8bSmrg		*" $a_deplib "*)
9565bd304fc0Smrg		  func_append newdeplibs " $a_deplib"
95666257f37dSmrg		  a_deplib=
9567f3561b8bSmrg		  ;;
9568f3561b8bSmrg		esac
9569f3561b8bSmrg	      fi
95706257f37dSmrg	      if test -n "$a_deplib"; then
9571f3561b8bSmrg		libname=`eval "\\$ECHO \"$libname_spec\""`
9572bd304fc0Smrg		if test -n "$file_magic_glob"; then
9573bd304fc0Smrg		  libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
9574bd304fc0Smrg		else
9575bd304fc0Smrg		  libnameglob=$libname
9576bd304fc0Smrg		fi
95776257f37dSmrg		test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob`
9578f3561b8bSmrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
95796257f37dSmrg		  if test yes = "$want_nocaseglob"; then
9580bd304fc0Smrg		    shopt -s nocaseglob
9581bd304fc0Smrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
9582bd304fc0Smrg		    $nocaseglob
9583bd304fc0Smrg		  else
9584bd304fc0Smrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
9585bd304fc0Smrg		  fi
9586f3561b8bSmrg		  for potent_lib in $potential_libs; do
9587f3561b8bSmrg		      # Follow soft links.
9588f3561b8bSmrg		      if ls -lLd "$potent_lib" 2>/dev/null |
9589f3561b8bSmrg			 $GREP " -> " >/dev/null; then
9590f3561b8bSmrg			continue
9591f3561b8bSmrg		      fi
9592f3561b8bSmrg		      # The statement above tries to avoid entering an
9593f3561b8bSmrg		      # endless loop below, in case of cyclic links.
9594f3561b8bSmrg		      # We might still enter an endless loop, since a link
9595f3561b8bSmrg		      # loop can be closed while we follow links,
9596f3561b8bSmrg		      # but so what?
95976257f37dSmrg		      potlib=$potent_lib
9598f3561b8bSmrg		      while test -h "$potlib" 2>/dev/null; do
95996257f37dSmrg			potliblink=`ls -ld $potlib | $SED 's/.* -> //'`
9600f3561b8bSmrg			case $potliblink in
96016257f37dSmrg			[\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;;
96026257f37dSmrg			*) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";;
9603f3561b8bSmrg			esac
9604f3561b8bSmrg		      done
9605f3561b8bSmrg		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
9606f3561b8bSmrg			 $SED -e 10q |
9607f3561b8bSmrg			 $EGREP "$file_magic_regex" > /dev/null; then
9608bd304fc0Smrg			func_append newdeplibs " $a_deplib"
96096257f37dSmrg			a_deplib=
9610f3561b8bSmrg			break 2
9611f3561b8bSmrg		      fi
9612f3561b8bSmrg		  done
9613f3561b8bSmrg		done
9614f3561b8bSmrg	      fi
96156257f37dSmrg	      if test -n "$a_deplib"; then
9616f3561b8bSmrg		droppeddeps=yes
9617bd304fc0Smrg		echo
9618f3561b8bSmrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
9619bd304fc0Smrg		echo "*** I have the capability to make that library automatically link in when"
9620bd304fc0Smrg		echo "*** you link to this library.  But I can only do this if you have a"
9621bd304fc0Smrg		echo "*** shared version of the library, which you do not appear to have"
9622bd304fc0Smrg		echo "*** because I did check the linker path looking for a file starting"
96236257f37dSmrg		if test -z "$potlib"; then
9624f3561b8bSmrg		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
9625f3561b8bSmrg		else
9626f3561b8bSmrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
9627f3561b8bSmrg		  $ECHO "*** using a file magic. Last file checked: $potlib"
9628f3561b8bSmrg		fi
9629f3561b8bSmrg	      fi
9630f3561b8bSmrg	      ;;
9631f3561b8bSmrg	    *)
9632f3561b8bSmrg	      # Add a -L argument.
9633bd304fc0Smrg	      func_append newdeplibs " $a_deplib"
9634f3561b8bSmrg	      ;;
9635f3561b8bSmrg	    esac
9636f3561b8bSmrg	  done # Gone through all deplibs.
9637f3561b8bSmrg	  ;;
9638f3561b8bSmrg	match_pattern*)
9639f3561b8bSmrg	  set dummy $deplibs_check_method; shift
9640f3561b8bSmrg	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
9641f3561b8bSmrg	  for a_deplib in $deplibs; do
9642f3561b8bSmrg	    case $a_deplib in
9643f3561b8bSmrg	    -l*)
9644f3561b8bSmrg	      func_stripname -l '' "$a_deplib"
9645f3561b8bSmrg	      name=$func_stripname_result
96466257f37dSmrg	      if test yes = "$allow_libtool_libs_with_static_runtimes"; then
9647f3561b8bSmrg		case " $predeps $postdeps " in
9648f3561b8bSmrg		*" $a_deplib "*)
9649bd304fc0Smrg		  func_append newdeplibs " $a_deplib"
96506257f37dSmrg		  a_deplib=
9651f3561b8bSmrg		  ;;
9652f3561b8bSmrg		esac
9653f3561b8bSmrg	      fi
96546257f37dSmrg	      if test -n "$a_deplib"; then
9655f3561b8bSmrg		libname=`eval "\\$ECHO \"$libname_spec\""`
9656f3561b8bSmrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
9657f3561b8bSmrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
9658f3561b8bSmrg		  for potent_lib in $potential_libs; do
96596257f37dSmrg		    potlib=$potent_lib # see symlink-check above in file_magic test
9660bd304fc0Smrg		    if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
9661f3561b8bSmrg		       $EGREP "$match_pattern_regex" > /dev/null; then
9662bd304fc0Smrg		      func_append newdeplibs " $a_deplib"
96636257f37dSmrg		      a_deplib=
9664f3561b8bSmrg		      break 2
9665f3561b8bSmrg		    fi
9666f3561b8bSmrg		  done
9667f3561b8bSmrg		done
9668f3561b8bSmrg	      fi
96696257f37dSmrg	      if test -n "$a_deplib"; then
9670f3561b8bSmrg		droppeddeps=yes
9671bd304fc0Smrg		echo
9672f3561b8bSmrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
9673bd304fc0Smrg		echo "*** I have the capability to make that library automatically link in when"
9674bd304fc0Smrg		echo "*** you link to this library.  But I can only do this if you have a"
9675bd304fc0Smrg		echo "*** shared version of the library, which you do not appear to have"
9676bd304fc0Smrg		echo "*** because I did check the linker path looking for a file starting"
96776257f37dSmrg		if test -z "$potlib"; then
9678f3561b8bSmrg		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
9679f3561b8bSmrg		else
9680f3561b8bSmrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
9681f3561b8bSmrg		  $ECHO "*** using a regex pattern. Last file checked: $potlib"
9682f3561b8bSmrg		fi
9683f3561b8bSmrg	      fi
9684f3561b8bSmrg	      ;;
9685f3561b8bSmrg	    *)
9686f3561b8bSmrg	      # Add a -L argument.
9687bd304fc0Smrg	      func_append newdeplibs " $a_deplib"
9688f3561b8bSmrg	      ;;
9689f3561b8bSmrg	    esac
9690f3561b8bSmrg	  done # Gone through all deplibs.
9691f3561b8bSmrg	  ;;
9692f3561b8bSmrg	none | unknown | *)
96936257f37dSmrg	  newdeplibs=
9694bd304fc0Smrg	  tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
96956257f37dSmrg	  if test yes = "$allow_libtool_libs_with_static_runtimes"; then
96966257f37dSmrg	    for i in $predeps $postdeps; do
9697f3561b8bSmrg	      # can't use Xsed below, because $i might contain '/'
96986257f37dSmrg	      tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"`
9699f3561b8bSmrg	    done
9700f3561b8bSmrg	  fi
9701bd304fc0Smrg	  case $tmp_deplibs in
9702bd304fc0Smrg	  *[!\	\ ]*)
9703bd304fc0Smrg	    echo
97046257f37dSmrg	    if test none = "$deplibs_check_method"; then
9705bd304fc0Smrg	      echo "*** Warning: inter-library dependencies are not supported in this platform."
9706f3561b8bSmrg	    else
9707bd304fc0Smrg	      echo "*** Warning: inter-library dependencies are not known to be supported."
9708f3561b8bSmrg	    fi
9709bd304fc0Smrg	    echo "*** All declared inter-library dependencies are being dropped."
9710f3561b8bSmrg	    droppeddeps=yes
9711bd304fc0Smrg	    ;;
9712bd304fc0Smrg	  esac
9713f3561b8bSmrg	  ;;
9714f3561b8bSmrg	esac
9715f3561b8bSmrg	versuffix=$versuffix_save
9716f3561b8bSmrg	major=$major_save
9717f3561b8bSmrg	release=$release_save
9718f3561b8bSmrg	libname=$libname_save
9719f3561b8bSmrg	name=$name_save
9720f3561b8bSmrg
9721f3561b8bSmrg	case $host in
9722f3561b8bSmrg	*-*-rhapsody* | *-*-darwin1.[012])
9723f3561b8bSmrg	  # On Rhapsody replace the C library with the System framework
9724bd304fc0Smrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
9725f3561b8bSmrg	  ;;
9726f3561b8bSmrg	esac
9727f3561b8bSmrg
97286257f37dSmrg	if test yes = "$droppeddeps"; then
97296257f37dSmrg	  if test yes = "$module"; then
9730bd304fc0Smrg	    echo
9731bd304fc0Smrg	    echo "*** Warning: libtool could not satisfy all declared inter-library"
9732f3561b8bSmrg	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
9733bd304fc0Smrg	    echo "*** a static module, that should work as long as the dlopening"
9734bd304fc0Smrg	    echo "*** application is linked with the -dlopen flag."
9735f3561b8bSmrg	    if test -z "$global_symbol_pipe"; then
9736bd304fc0Smrg	      echo
9737bd304fc0Smrg	      echo "*** However, this would only work if libtool was able to extract symbol"
97386257f37dSmrg	      echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
9739bd304fc0Smrg	      echo "*** not find such a program.  So, this module is probably useless."
97406257f37dSmrg	      echo "*** 'nm' from GNU binutils and a full rebuild may help."
9741f3561b8bSmrg	    fi
97426257f37dSmrg	    if test no = "$build_old_libs"; then
97436257f37dSmrg	      oldlibs=$output_objdir/$libname.$libext
9744f3561b8bSmrg	      build_libtool_libs=module
9745f3561b8bSmrg	      build_old_libs=yes
9746f3561b8bSmrg	    else
9747f3561b8bSmrg	      build_libtool_libs=no
9748f3561b8bSmrg	    fi
9749f3561b8bSmrg	  else
9750bd304fc0Smrg	    echo "*** The inter-library dependencies that have been dropped here will be"
9751bd304fc0Smrg	    echo "*** automatically added whenever a program is linked with this library"
9752bd304fc0Smrg	    echo "*** or is declared to -dlopen it."
9753f3561b8bSmrg
97546257f37dSmrg	    if test no = "$allow_undefined"; then
9755bd304fc0Smrg	      echo
9756bd304fc0Smrg	      echo "*** Since this library must not contain undefined symbols,"
9757bd304fc0Smrg	      echo "*** because either the platform does not support them or"
9758bd304fc0Smrg	      echo "*** it was explicitly requested with -no-undefined,"
9759bd304fc0Smrg	      echo "*** libtool will only create a static version of it."
97606257f37dSmrg	      if test no = "$build_old_libs"; then
97616257f37dSmrg		oldlibs=$output_objdir/$libname.$libext
9762f3561b8bSmrg		build_libtool_libs=module
9763f3561b8bSmrg		build_old_libs=yes
9764f3561b8bSmrg	      else
9765f3561b8bSmrg		build_libtool_libs=no
9766f3561b8bSmrg	      fi
9767f3561b8bSmrg	    fi
9768f3561b8bSmrg	  fi
9769f3561b8bSmrg	fi
9770f3561b8bSmrg	# Done checking deplibs!
9771f3561b8bSmrg	deplibs=$newdeplibs
9772f3561b8bSmrg      fi
9773f3561b8bSmrg      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
9774f3561b8bSmrg      case $host in
9775f3561b8bSmrg	*-*-darwin*)
9776bd304fc0Smrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
9777bd304fc0Smrg	  new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
9778bd304fc0Smrg	  deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
9779f3561b8bSmrg	  ;;
9780f3561b8bSmrg      esac
9781f3561b8bSmrg
9782f3561b8bSmrg      # move library search paths that coincide with paths to not yet
9783f3561b8bSmrg      # installed libraries to the beginning of the library search list
9784f3561b8bSmrg      new_libs=
9785f3561b8bSmrg      for path in $notinst_path; do
9786f3561b8bSmrg	case " $new_libs " in
9787f3561b8bSmrg	*" -L$path/$objdir "*) ;;
9788f3561b8bSmrg	*)
9789f3561b8bSmrg	  case " $deplibs " in
9790f3561b8bSmrg	  *" -L$path/$objdir "*)
9791bd304fc0Smrg	    func_append new_libs " -L$path/$objdir" ;;
9792f3561b8bSmrg	  esac
9793f3561b8bSmrg	  ;;
9794f3561b8bSmrg	esac
9795f3561b8bSmrg      done
9796f3561b8bSmrg      for deplib in $deplibs; do
9797f3561b8bSmrg	case $deplib in
9798f3561b8bSmrg	-L*)
9799f3561b8bSmrg	  case " $new_libs " in
9800f3561b8bSmrg	  *" $deplib "*) ;;
9801bd304fc0Smrg	  *) func_append new_libs " $deplib" ;;
9802f3561b8bSmrg	  esac
9803f3561b8bSmrg	  ;;
9804bd304fc0Smrg	*) func_append new_libs " $deplib" ;;
9805f3561b8bSmrg	esac
9806f3561b8bSmrg      done
98076257f37dSmrg      deplibs=$new_libs
9808f3561b8bSmrg
9809f3561b8bSmrg      # All the library-specific variables (install_libdir is set above).
9810f3561b8bSmrg      library_names=
9811f3561b8bSmrg      old_library=
9812f3561b8bSmrg      dlname=
9813fc5a983dSmrg
9814f3561b8bSmrg      # Test again, we may have decided not to build it any more
98156257f37dSmrg      if test yes = "$build_libtool_libs"; then
98166257f37dSmrg	# Remove $wl instances when linking with ld.
9817bd304fc0Smrg	# FIXME: should test the right _cmds variable.
9818bd304fc0Smrg	case $archive_cmds in
9819bd304fc0Smrg	  *\$LD\ *) wl= ;;
9820bd304fc0Smrg        esac
98216257f37dSmrg	if test yes = "$hardcode_into_libs"; then
9822f3561b8bSmrg	  # Hardcode the library paths
9823f3561b8bSmrg	  hardcode_libdirs=
9824f3561b8bSmrg	  dep_rpath=
98256257f37dSmrg	  rpath=$finalize_rpath
98266257f37dSmrg	  test relink = "$opt_mode" || rpath=$compile_rpath$rpath
9827f3561b8bSmrg	  for libdir in $rpath; do
9828f3561b8bSmrg	    if test -n "$hardcode_libdir_flag_spec"; then
9829f3561b8bSmrg	      if test -n "$hardcode_libdir_separator"; then
9830bd304fc0Smrg		func_replace_sysroot "$libdir"
9831bd304fc0Smrg		libdir=$func_replace_sysroot_result
9832f3561b8bSmrg		if test -z "$hardcode_libdirs"; then
98336257f37dSmrg		  hardcode_libdirs=$libdir
9834f3561b8bSmrg		else
9835f3561b8bSmrg		  # Just accumulate the unique libdirs.
9836f3561b8bSmrg		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
9837f3561b8bSmrg		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
9838f3561b8bSmrg		    ;;
9839f3561b8bSmrg		  *)
9840bd304fc0Smrg		    func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
9841f3561b8bSmrg		    ;;
9842f3561b8bSmrg		  esac
9843f3561b8bSmrg		fi
9844f3561b8bSmrg	      else
9845f3561b8bSmrg		eval flag=\"$hardcode_libdir_flag_spec\"
9846bd304fc0Smrg		func_append dep_rpath " $flag"
9847f3561b8bSmrg	      fi
9848f3561b8bSmrg	    elif test -n "$runpath_var"; then
9849f3561b8bSmrg	      case "$perm_rpath " in
9850f3561b8bSmrg	      *" $libdir "*) ;;
9851bd304fc0Smrg	      *) func_append perm_rpath " $libdir" ;;
9852f3561b8bSmrg	      esac
9853f3561b8bSmrg	    fi
9854f3561b8bSmrg	  done
9855f3561b8bSmrg	  # Substitute the hardcoded libdirs into the rpath.
9856f3561b8bSmrg	  if test -n "$hardcode_libdir_separator" &&
9857f3561b8bSmrg	     test -n "$hardcode_libdirs"; then
98586257f37dSmrg	    libdir=$hardcode_libdirs
9859bd304fc0Smrg	    eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
9860f3561b8bSmrg	  fi
9861f3561b8bSmrg	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
9862f3561b8bSmrg	    # We should set the runpath_var.
9863f3561b8bSmrg	    rpath=
9864f3561b8bSmrg	    for dir in $perm_rpath; do
9865bd304fc0Smrg	      func_append rpath "$dir:"
9866f3561b8bSmrg	    done
9867f3561b8bSmrg	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
9868f3561b8bSmrg	  fi
9869f3561b8bSmrg	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
9870f3561b8bSmrg	fi
9871fc5a983dSmrg
98726257f37dSmrg	shlibpath=$finalize_shlibpath
98736257f37dSmrg	test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath
9874f3561b8bSmrg	if test -n "$shlibpath"; then
9875f3561b8bSmrg	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
9876f3561b8bSmrg	fi
9877fc5a983dSmrg
9878f3561b8bSmrg	# Get the real and link names of the library.
9879f3561b8bSmrg	eval shared_ext=\"$shrext_cmds\"
9880f3561b8bSmrg	eval library_names=\"$library_names_spec\"
9881f3561b8bSmrg	set dummy $library_names
9882f3561b8bSmrg	shift
98836257f37dSmrg	realname=$1
9884f3561b8bSmrg	shift
9885fc5a983dSmrg
9886f3561b8bSmrg	if test -n "$soname_spec"; then
9887f3561b8bSmrg	  eval soname=\"$soname_spec\"
9888fc5a983dSmrg	else
98896257f37dSmrg	  soname=$realname
9890f3561b8bSmrg	fi
9891f3561b8bSmrg	if test -z "$dlname"; then
9892f3561b8bSmrg	  dlname=$soname
9893fc5a983dSmrg	fi
9894fc5a983dSmrg
98956257f37dSmrg	lib=$output_objdir/$realname
9896f3561b8bSmrg	linknames=
9897f3561b8bSmrg	for link
9898f3561b8bSmrg	do
9899bd304fc0Smrg	  func_append linknames " $link"
9900f3561b8bSmrg	done
9901fc5a983dSmrg
9902f3561b8bSmrg	# Use standard objects if they are pic
9903bd304fc0Smrg	test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
9904f3561b8bSmrg	test "X$libobjs" = "X " && libobjs=
9905fc5a983dSmrg
9906f3561b8bSmrg	delfiles=
9907f3561b8bSmrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
9908f3561b8bSmrg	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
99096257f37dSmrg	  export_symbols=$output_objdir/$libname.uexp
9910bd304fc0Smrg	  func_append delfiles " $export_symbols"
9911f3561b8bSmrg	fi
9912fc5a983dSmrg
9913f3561b8bSmrg	orig_export_symbols=
9914f3561b8bSmrg	case $host_os in
9915f3561b8bSmrg	cygwin* | mingw* | cegcc*)
9916f3561b8bSmrg	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
9917f3561b8bSmrg	    # exporting using user supplied symfile
99186257f37dSmrg	    func_dll_def_p "$export_symbols" || {
9919f3561b8bSmrg	      # and it's NOT already a .def file. Must figure out
9920f3561b8bSmrg	      # which of the given symbols are data symbols and tag
9921f3561b8bSmrg	      # them as such. So, trigger use of export_symbols_cmds.
9922f3561b8bSmrg	      # export_symbols gets reassigned inside the "prepare
9923f3561b8bSmrg	      # the list of exported symbols" if statement, so the
9924f3561b8bSmrg	      # include_expsyms logic still works.
99256257f37dSmrg	      orig_export_symbols=$export_symbols
9926f3561b8bSmrg	      export_symbols=
9927f3561b8bSmrg	      always_export_symbols=yes
99286257f37dSmrg	    }
9929f3561b8bSmrg	  fi
9930f3561b8bSmrg	  ;;
9931f3561b8bSmrg	esac
9932fc5a983dSmrg
9933f3561b8bSmrg	# Prepare the list of exported symbols
9934f3561b8bSmrg	if test -z "$export_symbols"; then
99356257f37dSmrg	  if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then
99366257f37dSmrg	    func_verbose "generating symbol list for '$libname.la'"
99376257f37dSmrg	    export_symbols=$output_objdir/$libname.exp
9938f3561b8bSmrg	    $opt_dry_run || $RM $export_symbols
9939f3561b8bSmrg	    cmds=$export_symbols_cmds
99406257f37dSmrg	    save_ifs=$IFS; IFS='~'
9941bd304fc0Smrg	    for cmd1 in $cmds; do
99426257f37dSmrg	      IFS=$save_ifs
9943bd304fc0Smrg	      # Take the normal branch if the nm_file_list_spec branch
9944bd304fc0Smrg	      # doesn't work or if tool conversion is not needed.
9945bd304fc0Smrg	      case $nm_file_list_spec~$to_tool_file_cmd in
9946bd304fc0Smrg		*~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
9947bd304fc0Smrg		  try_normal_branch=yes
9948bd304fc0Smrg		  eval cmd=\"$cmd1\"
9949bd304fc0Smrg		  func_len " $cmd"
9950bd304fc0Smrg		  len=$func_len_result
9951bd304fc0Smrg		  ;;
9952bd304fc0Smrg		*)
9953bd304fc0Smrg		  try_normal_branch=no
9954bd304fc0Smrg		  ;;
9955bd304fc0Smrg	      esac
99566257f37dSmrg	      if test yes = "$try_normal_branch" \
9957bd304fc0Smrg		 && { test "$len" -lt "$max_cmd_len" \
9958bd304fc0Smrg		      || test "$max_cmd_len" -le -1; }
9959bd304fc0Smrg	      then
9960bd304fc0Smrg		func_show_eval "$cmd" 'exit $?'
9961bd304fc0Smrg		skipped_export=false
9962bd304fc0Smrg	      elif test -n "$nm_file_list_spec"; then
9963bd304fc0Smrg		func_basename "$output"
9964bd304fc0Smrg		output_la=$func_basename_result
9965bd304fc0Smrg		save_libobjs=$libobjs
9966bd304fc0Smrg		save_output=$output
99676257f37dSmrg		output=$output_objdir/$output_la.nm
9968bd304fc0Smrg		func_to_tool_file "$output"
9969bd304fc0Smrg		libobjs=$nm_file_list_spec$func_to_tool_file_result
9970bd304fc0Smrg		func_append delfiles " $output"
9971bd304fc0Smrg		func_verbose "creating $NM input file list: $output"
9972bd304fc0Smrg		for obj in $save_libobjs; do
9973bd304fc0Smrg		  func_to_tool_file "$obj"
9974bd304fc0Smrg		  $ECHO "$func_to_tool_file_result"
9975bd304fc0Smrg		done > "$output"
9976bd304fc0Smrg		eval cmd=\"$cmd1\"
9977f3561b8bSmrg		func_show_eval "$cmd" 'exit $?'
9978bd304fc0Smrg		output=$save_output
9979bd304fc0Smrg		libobjs=$save_libobjs
9980f3561b8bSmrg		skipped_export=false
9981f3561b8bSmrg	      else
9982f3561b8bSmrg		# The command line is too long to execute in one step.
9983f3561b8bSmrg		func_verbose "using reloadable object file for export list..."
9984f3561b8bSmrg		skipped_export=:
9985f3561b8bSmrg		# Break out early, otherwise skipped_export may be
9986f3561b8bSmrg		# set to false by a later but shorter cmd.
9987f3561b8bSmrg		break
9988f3561b8bSmrg	      fi
9989f3561b8bSmrg	    done
99906257f37dSmrg	    IFS=$save_ifs
99916257f37dSmrg	    if test -n "$export_symbols_regex" && test : != "$skipped_export"; then
9992f3561b8bSmrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
9993f3561b8bSmrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
9994f3561b8bSmrg	    fi
9995f3561b8bSmrg	  fi
9996fc5a983dSmrg	fi
9997fc5a983dSmrg
9998f3561b8bSmrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
99996257f37dSmrg	  tmp_export_symbols=$export_symbols
100006257f37dSmrg	  test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
10001bd304fc0Smrg	  $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
10002fc5a983dSmrg	fi
10003fc5a983dSmrg
100046257f37dSmrg	if test : != "$skipped_export" && test -n "$orig_export_symbols"; then
10005f3561b8bSmrg	  # The given exports_symbols file has to be filtered, so filter it.
100066257f37dSmrg	  func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
10007f3561b8bSmrg	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
100086257f37dSmrg	  # 's' commands, which not all seds can handle. GNU sed should be fine
10009f3561b8bSmrg	  # though. Also, the filter scales superlinearly with the number of
10010f3561b8bSmrg	  # global variables. join(1) would be nice here, but unfortunately
10011f3561b8bSmrg	  # isn't a blessed tool.
10012f3561b8bSmrg	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
10013bd304fc0Smrg	  func_append delfiles " $export_symbols $output_objdir/$libname.filter"
10014f3561b8bSmrg	  export_symbols=$output_objdir/$libname.def
10015f3561b8bSmrg	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
10016f3561b8bSmrg	fi
10017fc5a983dSmrg
10018f3561b8bSmrg	tmp_deplibs=
10019f3561b8bSmrg	for test_deplib in $deplibs; do
10020f3561b8bSmrg	  case " $convenience " in
10021f3561b8bSmrg	  *" $test_deplib "*) ;;
10022f3561b8bSmrg	  *)
10023bd304fc0Smrg	    func_append tmp_deplibs " $test_deplib"
10024f3561b8bSmrg	    ;;
10025f3561b8bSmrg	  esac
10026f3561b8bSmrg	done
100276257f37dSmrg	deplibs=$tmp_deplibs
10028fc5a983dSmrg
10029f3561b8bSmrg	if test -n "$convenience"; then
10030f3561b8bSmrg	  if test -n "$whole_archive_flag_spec" &&
100316257f37dSmrg	    test yes = "$compiler_needs_object" &&
10032f3561b8bSmrg	    test -z "$libobjs"; then
10033f3561b8bSmrg	    # extract the archives, so we have objects to list.
10034f3561b8bSmrg	    # TODO: could optimize this to just extract one archive.
10035f3561b8bSmrg	    whole_archive_flag_spec=
10036f3561b8bSmrg	  fi
10037f3561b8bSmrg	  if test -n "$whole_archive_flag_spec"; then
10038f3561b8bSmrg	    save_libobjs=$libobjs
10039f3561b8bSmrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
10040f3561b8bSmrg	    test "X$libobjs" = "X " && libobjs=
10041f3561b8bSmrg	  else
100426257f37dSmrg	    gentop=$output_objdir/${outputname}x
10043bd304fc0Smrg	    func_append generated " $gentop"
10044fc5a983dSmrg
10045f3561b8bSmrg	    func_extract_archives $gentop $convenience
10046bd304fc0Smrg	    func_append libobjs " $func_extract_archives_result"
10047f3561b8bSmrg	    test "X$libobjs" = "X " && libobjs=
10048f3561b8bSmrg	  fi
10049f3561b8bSmrg	fi
10050fc5a983dSmrg
100516257f37dSmrg	if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then
10052f3561b8bSmrg	  eval flag=\"$thread_safe_flag_spec\"
10053bd304fc0Smrg	  func_append linker_flags " $flag"
10054fc5a983dSmrg	fi
10055fc5a983dSmrg
10056f3561b8bSmrg	# Make a backup of the uninstalled library when relinking
100576257f37dSmrg	if test relink = "$opt_mode"; then
10058f3561b8bSmrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
10059f3561b8bSmrg	fi
10060fc5a983dSmrg
10061f3561b8bSmrg	# Do each of the archive commands.
100626257f37dSmrg	if test yes = "$module" && test -n "$module_cmds"; then
10063f3561b8bSmrg	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
10064f3561b8bSmrg	    eval test_cmds=\"$module_expsym_cmds\"
10065f3561b8bSmrg	    cmds=$module_expsym_cmds
10066f3561b8bSmrg	  else
10067f3561b8bSmrg	    eval test_cmds=\"$module_cmds\"
10068f3561b8bSmrg	    cmds=$module_cmds
10069f3561b8bSmrg	  fi
10070f3561b8bSmrg	else
10071f3561b8bSmrg	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
10072f3561b8bSmrg	    eval test_cmds=\"$archive_expsym_cmds\"
10073f3561b8bSmrg	    cmds=$archive_expsym_cmds
10074f3561b8bSmrg	  else
10075f3561b8bSmrg	    eval test_cmds=\"$archive_cmds\"
10076f3561b8bSmrg	    cmds=$archive_cmds
10077f3561b8bSmrg	  fi
10078f3561b8bSmrg	fi
10079fc5a983dSmrg
100806257f37dSmrg	if test : != "$skipped_export" &&
10081f3561b8bSmrg	   func_len " $test_cmds" &&
10082f3561b8bSmrg	   len=$func_len_result &&
10083f3561b8bSmrg	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
10084fc5a983dSmrg	  :
10085fc5a983dSmrg	else
10086f3561b8bSmrg	  # The command line is too long to link in one step, link piecewise
10087f3561b8bSmrg	  # or, if using GNU ld and skipped_export is not :, use a linker
10088f3561b8bSmrg	  # script.
10089f3561b8bSmrg
10090f3561b8bSmrg	  # Save the value of $output and $libobjs because we want to
10091f3561b8bSmrg	  # use them later.  If we have whole_archive_flag_spec, we
10092f3561b8bSmrg	  # want to use save_libobjs as it was before
10093f3561b8bSmrg	  # whole_archive_flag_spec was expanded, because we can't
10094f3561b8bSmrg	  # assume the linker understands whole_archive_flag_spec.
10095f3561b8bSmrg	  # This may have to be revisited, in case too many
10096f3561b8bSmrg	  # convenience libraries get linked in and end up exceeding
10097f3561b8bSmrg	  # the spec.
10098f3561b8bSmrg	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
10099f3561b8bSmrg	    save_libobjs=$libobjs
10100f3561b8bSmrg	  fi
10101f3561b8bSmrg	  save_output=$output
10102bd304fc0Smrg	  func_basename "$output"
10103bd304fc0Smrg	  output_la=$func_basename_result
10104f3561b8bSmrg
10105f3561b8bSmrg	  # Clear the reloadable object creation command queue and
10106f3561b8bSmrg	  # initialize k to one.
10107f3561b8bSmrg	  test_cmds=
10108f3561b8bSmrg	  concat_cmds=
10109f3561b8bSmrg	  objlist=
10110f3561b8bSmrg	  last_robj=
10111f3561b8bSmrg	  k=1
10112f3561b8bSmrg
101136257f37dSmrg	  if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then
101146257f37dSmrg	    output=$output_objdir/$output_la.lnkscript
10115f3561b8bSmrg	    func_verbose "creating GNU ld script: $output"
10116bd304fc0Smrg	    echo 'INPUT (' > $output
10117f3561b8bSmrg	    for obj in $save_libobjs
10118f3561b8bSmrg	    do
10119bd304fc0Smrg	      func_to_tool_file "$obj"
10120bd304fc0Smrg	      $ECHO "$func_to_tool_file_result" >> $output
10121f3561b8bSmrg	    done
10122bd304fc0Smrg	    echo ')' >> $output
10123bd304fc0Smrg	    func_append delfiles " $output"
10124bd304fc0Smrg	    func_to_tool_file "$output"
10125bd304fc0Smrg	    output=$func_to_tool_file_result
101266257f37dSmrg	  elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then
101276257f37dSmrg	    output=$output_objdir/$output_la.lnk
10128f3561b8bSmrg	    func_verbose "creating linker input file list: $output"
10129f3561b8bSmrg	    : > $output
10130f3561b8bSmrg	    set x $save_libobjs
10131f3561b8bSmrg	    shift
10132f3561b8bSmrg	    firstobj=
101336257f37dSmrg	    if test yes = "$compiler_needs_object"; then
10134f3561b8bSmrg	      firstobj="$1 "
10135f3561b8bSmrg	      shift
10136f3561b8bSmrg	    fi
10137f3561b8bSmrg	    for obj
10138f3561b8bSmrg	    do
10139bd304fc0Smrg	      func_to_tool_file "$obj"
10140bd304fc0Smrg	      $ECHO "$func_to_tool_file_result" >> $output
10141f3561b8bSmrg	    done
10142bd304fc0Smrg	    func_append delfiles " $output"
10143bd304fc0Smrg	    func_to_tool_file "$output"
10144bd304fc0Smrg	    output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
10145f3561b8bSmrg	  else
10146f3561b8bSmrg	    if test -n "$save_libobjs"; then
10147f3561b8bSmrg	      func_verbose "creating reloadable object files..."
101486257f37dSmrg	      output=$output_objdir/$output_la-$k.$objext
10149f3561b8bSmrg	      eval test_cmds=\"$reload_cmds\"
10150f3561b8bSmrg	      func_len " $test_cmds"
10151f3561b8bSmrg	      len0=$func_len_result
10152f3561b8bSmrg	      len=$len0
10153f3561b8bSmrg
10154f3561b8bSmrg	      # Loop over the list of objects to be linked.
10155f3561b8bSmrg	      for obj in $save_libobjs
10156f3561b8bSmrg	      do
10157f3561b8bSmrg		func_len " $obj"
10158f3561b8bSmrg		func_arith $len + $func_len_result
10159f3561b8bSmrg		len=$func_arith_result
101606257f37dSmrg		if test -z "$objlist" ||
10161f3561b8bSmrg		   test "$len" -lt "$max_cmd_len"; then
10162f3561b8bSmrg		  func_append objlist " $obj"
10163f3561b8bSmrg		else
10164f3561b8bSmrg		  # The command $test_cmds is almost too long, add a
10165f3561b8bSmrg		  # command to the queue.
101666257f37dSmrg		  if test 1 -eq "$k"; then
10167f3561b8bSmrg		    # The first file doesn't have a previous command to add.
10168bd304fc0Smrg		    reload_objs=$objlist
10169bd304fc0Smrg		    eval concat_cmds=\"$reload_cmds\"
10170f3561b8bSmrg		  else
10171f3561b8bSmrg		    # All subsequent reloadable object files will link in
10172f3561b8bSmrg		    # the last one created.
10173bd304fc0Smrg		    reload_objs="$objlist $last_robj"
10174bd304fc0Smrg		    eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
10175f3561b8bSmrg		  fi
101766257f37dSmrg		  last_robj=$output_objdir/$output_la-$k.$objext
10177f3561b8bSmrg		  func_arith $k + 1
10178f3561b8bSmrg		  k=$func_arith_result
101796257f37dSmrg		  output=$output_objdir/$output_la-$k.$objext
10180bd304fc0Smrg		  objlist=" $obj"
10181f3561b8bSmrg		  func_len " $last_robj"
10182f3561b8bSmrg		  func_arith $len0 + $func_len_result
10183f3561b8bSmrg		  len=$func_arith_result
10184f3561b8bSmrg		fi
10185f3561b8bSmrg	      done
10186f3561b8bSmrg	      # Handle the remaining objects by creating one last
10187f3561b8bSmrg	      # reloadable object file.  All subsequent reloadable object
10188f3561b8bSmrg	      # files will link in the last one created.
10189f3561b8bSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
10190bd304fc0Smrg	      reload_objs="$objlist $last_robj"
101916257f37dSmrg	      eval concat_cmds=\"\$concat_cmds$reload_cmds\"
10192f3561b8bSmrg	      if test -n "$last_robj"; then
101936257f37dSmrg	        eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
10194f3561b8bSmrg	      fi
10195bd304fc0Smrg	      func_append delfiles " $output"
10196fc5a983dSmrg
10197f3561b8bSmrg	    else
10198f3561b8bSmrg	      output=
10199f3561b8bSmrg	    fi
10200fc5a983dSmrg
102016257f37dSmrg	    ${skipped_export-false} && {
102026257f37dSmrg	      func_verbose "generating symbol list for '$libname.la'"
102036257f37dSmrg	      export_symbols=$output_objdir/$libname.exp
10204f3561b8bSmrg	      $opt_dry_run || $RM $export_symbols
10205f3561b8bSmrg	      libobjs=$output
10206f3561b8bSmrg	      # Append the command to create the export file.
10207f3561b8bSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
10208f3561b8bSmrg	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
10209f3561b8bSmrg	      if test -n "$last_robj"; then
10210f3561b8bSmrg		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
10211f3561b8bSmrg	      fi
102126257f37dSmrg	    }
10213fc5a983dSmrg
10214f3561b8bSmrg	    test -n "$save_libobjs" &&
10215f3561b8bSmrg	      func_verbose "creating a temporary reloadable object file: $output"
10216fc5a983dSmrg
10217f3561b8bSmrg	    # Loop through the commands generated above and execute them.
102186257f37dSmrg	    save_ifs=$IFS; IFS='~'
10219f3561b8bSmrg	    for cmd in $concat_cmds; do
102206257f37dSmrg	      IFS=$save_ifs
102216257f37dSmrg	      $opt_quiet || {
10222d422ce2eSmrg		  func_quote_arg expand,pretty "$cmd"
10223d422ce2eSmrg		  eval "func_echo $func_quote_arg_result"
10224f3561b8bSmrg	      }
10225f3561b8bSmrg	      $opt_dry_run || eval "$cmd" || {
10226f3561b8bSmrg		lt_exit=$?
10227f3561b8bSmrg
10228f3561b8bSmrg		# Restore the uninstalled library and exit
102296257f37dSmrg		if test relink = "$opt_mode"; then
10230f3561b8bSmrg		  ( cd "$output_objdir" && \
10231f3561b8bSmrg		    $RM "${realname}T" && \
10232f3561b8bSmrg		    $MV "${realname}U" "$realname" )
10233f3561b8bSmrg		fi
10234fc5a983dSmrg
10235f3561b8bSmrg		exit $lt_exit
10236f3561b8bSmrg	      }
10237f3561b8bSmrg	    done
102386257f37dSmrg	    IFS=$save_ifs
10239fc5a983dSmrg
10240f3561b8bSmrg	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
10241f3561b8bSmrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
10242f3561b8bSmrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
10243fc5a983dSmrg	    fi
10244fc5a983dSmrg	  fi
10245fc5a983dSmrg
102466257f37dSmrg          ${skipped_export-false} && {
10247f3561b8bSmrg	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
102486257f37dSmrg	      tmp_export_symbols=$export_symbols
102496257f37dSmrg	      test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
10250bd304fc0Smrg	      $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
10251f3561b8bSmrg	    fi
10252fc5a983dSmrg
10253f3561b8bSmrg	    if test -n "$orig_export_symbols"; then
10254f3561b8bSmrg	      # The given exports_symbols file has to be filtered, so filter it.
102556257f37dSmrg	      func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
10256f3561b8bSmrg	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
102576257f37dSmrg	      # 's' commands, which not all seds can handle. GNU sed should be fine
10258f3561b8bSmrg	      # though. Also, the filter scales superlinearly with the number of
10259f3561b8bSmrg	      # global variables. join(1) would be nice here, but unfortunately
10260f3561b8bSmrg	      # isn't a blessed tool.
10261f3561b8bSmrg	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
10262bd304fc0Smrg	      func_append delfiles " $export_symbols $output_objdir/$libname.filter"
10263f3561b8bSmrg	      export_symbols=$output_objdir/$libname.def
10264f3561b8bSmrg	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
10265f3561b8bSmrg	    fi
102666257f37dSmrg	  }
10267fc5a983dSmrg
10268f3561b8bSmrg	  libobjs=$output
10269f3561b8bSmrg	  # Restore the value of output.
10270f3561b8bSmrg	  output=$save_output
10271fc5a983dSmrg
10272f3561b8bSmrg	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
10273f3561b8bSmrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
10274f3561b8bSmrg	    test "X$libobjs" = "X " && libobjs=
10275f3561b8bSmrg	  fi
10276f3561b8bSmrg	  # Expand the library linking commands again to reset the
10277f3561b8bSmrg	  # value of $libobjs for piecewise linking.
10278fc5a983dSmrg
10279f3561b8bSmrg	  # Do each of the archive commands.
102806257f37dSmrg	  if test yes = "$module" && test -n "$module_cmds"; then
10281f3561b8bSmrg	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
10282f3561b8bSmrg	      cmds=$module_expsym_cmds
10283f3561b8bSmrg	    else
10284f3561b8bSmrg	      cmds=$module_cmds
10285fc5a983dSmrg	    fi
10286fc5a983dSmrg	  else
10287f3561b8bSmrg	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
10288f3561b8bSmrg	      cmds=$archive_expsym_cmds
10289f3561b8bSmrg	    else
10290f3561b8bSmrg	      cmds=$archive_cmds
10291f3561b8bSmrg	    fi
10292fc5a983dSmrg	  fi
10293f3561b8bSmrg	fi
10294fc5a983dSmrg
10295f3561b8bSmrg	if test -n "$delfiles"; then
10296f3561b8bSmrg	  # Append the command to remove temporary files to $cmds.
10297f3561b8bSmrg	  eval cmds=\"\$cmds~\$RM $delfiles\"
10298f3561b8bSmrg	fi
10299fc5a983dSmrg
10300f3561b8bSmrg	# Add any objects from preloaded convenience libraries
10301f3561b8bSmrg	if test -n "$dlprefiles"; then
103026257f37dSmrg	  gentop=$output_objdir/${outputname}x
10303bd304fc0Smrg	  func_append generated " $gentop"
10304fc5a983dSmrg
10305f3561b8bSmrg	  func_extract_archives $gentop $dlprefiles
10306bd304fc0Smrg	  func_append libobjs " $func_extract_archives_result"
10307f3561b8bSmrg	  test "X$libobjs" = "X " && libobjs=
10308f3561b8bSmrg	fi
10309fc5a983dSmrg
103106257f37dSmrg	save_ifs=$IFS; IFS='~'
10311f3561b8bSmrg	for cmd in $cmds; do
103126257f37dSmrg	  IFS=$sp$nl
10313f3561b8bSmrg	  eval cmd=\"$cmd\"
103146257f37dSmrg	  IFS=$save_ifs
103156257f37dSmrg	  $opt_quiet || {
10316d422ce2eSmrg	    func_quote_arg expand,pretty "$cmd"
10317d422ce2eSmrg	    eval "func_echo $func_quote_arg_result"
10318f3561b8bSmrg	  }
10319f3561b8bSmrg	  $opt_dry_run || eval "$cmd" || {
10320f3561b8bSmrg	    lt_exit=$?
10321fc5a983dSmrg
10322f3561b8bSmrg	    # Restore the uninstalled library and exit
103236257f37dSmrg	    if test relink = "$opt_mode"; then
10324f3561b8bSmrg	      ( cd "$output_objdir" && \
10325f3561b8bSmrg	        $RM "${realname}T" && \
10326f3561b8bSmrg		$MV "${realname}U" "$realname" )
10327f3561b8bSmrg	    fi
10328fc5a983dSmrg
10329f3561b8bSmrg	    exit $lt_exit
10330f3561b8bSmrg	  }
10331f3561b8bSmrg	done
103326257f37dSmrg	IFS=$save_ifs
10333fc5a983dSmrg
10334f3561b8bSmrg	# Restore the uninstalled library and exit
103356257f37dSmrg	if test relink = "$opt_mode"; then
10336f3561b8bSmrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
10337fc5a983dSmrg
10338f3561b8bSmrg	  if test -n "$convenience"; then
10339f3561b8bSmrg	    if test -z "$whole_archive_flag_spec"; then
10340f3561b8bSmrg	      func_show_eval '${RM}r "$gentop"'
10341f3561b8bSmrg	    fi
10342f3561b8bSmrg	  fi
10343fc5a983dSmrg
10344f3561b8bSmrg	  exit $EXIT_SUCCESS
10345f3561b8bSmrg	fi
10346f3561b8bSmrg
10347f3561b8bSmrg	# Create links to the real library.
10348f3561b8bSmrg	for linkname in $linknames; do
10349f3561b8bSmrg	  if test "$realname" != "$linkname"; then
10350f3561b8bSmrg	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
10351fc5a983dSmrg	  fi
10352fc5a983dSmrg	done
10353fc5a983dSmrg
10354f3561b8bSmrg	# If -module or -export-dynamic was specified, set the dlname.
103556257f37dSmrg	if test yes = "$module" || test yes = "$export_dynamic"; then
10356f3561b8bSmrg	  # On all known operating systems, these are identical.
103576257f37dSmrg	  dlname=$soname
10358f3561b8bSmrg	fi
10359f3561b8bSmrg      fi
10360fc5a983dSmrg      ;;
10361fc5a983dSmrg
10362f3561b8bSmrg    obj)
103636257f37dSmrg      if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
103646257f37dSmrg	func_warning "'-dlopen' is ignored for objects"
10365f3561b8bSmrg      fi
10366fc5a983dSmrg
10367f3561b8bSmrg      case " $deplibs" in
10368f3561b8bSmrg      *\ -l* | *\ -L*)
103696257f37dSmrg	func_warning "'-l' and '-L' are ignored for objects" ;;
10370fc5a983dSmrg      esac
10371fc5a983dSmrg
10372f3561b8bSmrg      test -n "$rpath" && \
103736257f37dSmrg	func_warning "'-rpath' is ignored for objects"
10374f3561b8bSmrg
10375f3561b8bSmrg      test -n "$xrpath" && \
103766257f37dSmrg	func_warning "'-R' is ignored for objects"
10377fc5a983dSmrg
10378f3561b8bSmrg      test -n "$vinfo" && \
103796257f37dSmrg	func_warning "'-version-info' is ignored for objects"
10380fc5a983dSmrg
10381f3561b8bSmrg      test -n "$release" && \
103826257f37dSmrg	func_warning "'-release' is ignored for objects"
10383f3561b8bSmrg
10384f3561b8bSmrg      case $output in
10385f3561b8bSmrg      *.lo)
10386f3561b8bSmrg	test -n "$objs$old_deplibs" && \
103876257f37dSmrg	  func_fatal_error "cannot build library object '$output' from non-libtool objects"
10388f3561b8bSmrg
10389f3561b8bSmrg	libobj=$output
10390f3561b8bSmrg	func_lo2o "$libobj"
10391f3561b8bSmrg	obj=$func_lo2o_result
10392fc5a983dSmrg	;;
10393fc5a983dSmrg      *)
10394f3561b8bSmrg	libobj=
103956257f37dSmrg	obj=$output
10396fc5a983dSmrg	;;
10397fc5a983dSmrg      esac
10398fc5a983dSmrg
10399f3561b8bSmrg      # Delete the old objects.
10400f3561b8bSmrg      $opt_dry_run || $RM $obj $libobj
10401fc5a983dSmrg
10402f3561b8bSmrg      # Objects from convenience libraries.  This assumes
10403f3561b8bSmrg      # single-version convenience libraries.  Whenever we create
10404f3561b8bSmrg      # different ones for PIC/non-PIC, this we'll have to duplicate
10405f3561b8bSmrg      # the extraction.
10406f3561b8bSmrg      reload_conv_objs=
10407f3561b8bSmrg      gentop=
104086257f37dSmrg      # if reload_cmds runs $LD directly, get rid of -Wl from
104096257f37dSmrg      # whole_archive_flag_spec and hope we can get by with turning comma
104106257f37dSmrg      # into space.
104116257f37dSmrg      case $reload_cmds in
104126257f37dSmrg        *\$LD[\ \$]*) wl= ;;
104136257f37dSmrg      esac
10414f3561b8bSmrg      if test -n "$convenience"; then
10415f3561b8bSmrg	if test -n "$whole_archive_flag_spec"; then
10416f3561b8bSmrg	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
104176257f37dSmrg	  test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
104186257f37dSmrg	  reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags
10419f3561b8bSmrg	else
104206257f37dSmrg	  gentop=$output_objdir/${obj}x
10421bd304fc0Smrg	  func_append generated " $gentop"
10422fc5a983dSmrg
10423f3561b8bSmrg	  func_extract_archives $gentop $convenience
10424f3561b8bSmrg	  reload_conv_objs="$reload_objs $func_extract_archives_result"
10425f3561b8bSmrg	fi
10426fc5a983dSmrg      fi
10427fc5a983dSmrg
10428bd304fc0Smrg      # If we're not building shared, we need to use non_pic_objs
104296257f37dSmrg      test yes = "$build_libtool_libs" || libobjs=$non_pic_objects
10430bd304fc0Smrg
10431f3561b8bSmrg      # Create the old-style object.
104326257f37dSmrg      reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs
10433fc5a983dSmrg
104346257f37dSmrg      output=$obj
10435f3561b8bSmrg      func_execute_cmds "$reload_cmds" 'exit $?'
10436fc5a983dSmrg
10437f3561b8bSmrg      # Exit if we aren't doing a library object file.
10438f3561b8bSmrg      if test -z "$libobj"; then
10439f3561b8bSmrg	if test -n "$gentop"; then
10440f3561b8bSmrg	  func_show_eval '${RM}r "$gentop"'
10441f3561b8bSmrg	fi
10442f3561b8bSmrg
10443f3561b8bSmrg	exit $EXIT_SUCCESS
10444fc5a983dSmrg      fi
10445f3561b8bSmrg
104466257f37dSmrg      test yes = "$build_libtool_libs" || {
10447f3561b8bSmrg	if test -n "$gentop"; then
10448f3561b8bSmrg	  func_show_eval '${RM}r "$gentop"'
10449f3561b8bSmrg	fi
10450f3561b8bSmrg
10451f3561b8bSmrg	# Create an invalid libtool object if no PIC, so that we don't
10452f3561b8bSmrg	# accidentally link it into a program.
10453f3561b8bSmrg	# $show "echo timestamp > $libobj"
10454f3561b8bSmrg	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
10455f3561b8bSmrg	exit $EXIT_SUCCESS
104566257f37dSmrg      }
10457f3561b8bSmrg
104586257f37dSmrg      if test -n "$pic_flag" || test default != "$pic_mode"; then
10459f3561b8bSmrg	# Only do commands if we really have different PIC objects.
10460f3561b8bSmrg	reload_objs="$libobjs $reload_conv_objs"
104616257f37dSmrg	output=$libobj
10462f3561b8bSmrg	func_execute_cmds "$reload_cmds" 'exit $?'
10463f3561b8bSmrg      fi
10464f3561b8bSmrg
10465f3561b8bSmrg      if test -n "$gentop"; then
10466f3561b8bSmrg	func_show_eval '${RM}r "$gentop"'
10467f3561b8bSmrg      fi
10468f3561b8bSmrg
10469f3561b8bSmrg      exit $EXIT_SUCCESS
10470fc5a983dSmrg      ;;
10471fc5a983dSmrg
10472f3561b8bSmrg    prog)
10473f3561b8bSmrg      case $host in
10474f3561b8bSmrg	*cygwin*) func_stripname '' '.exe' "$output"
10475f3561b8bSmrg	          output=$func_stripname_result.exe;;
10476f3561b8bSmrg      esac
10477f3561b8bSmrg      test -n "$vinfo" && \
104786257f37dSmrg	func_warning "'-version-info' is ignored for programs"
10479fc5a983dSmrg
10480f3561b8bSmrg      test -n "$release" && \
104816257f37dSmrg	func_warning "'-release' is ignored for programs"
10482fc5a983dSmrg
104836257f37dSmrg      $preload \
104846257f37dSmrg	&& test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \
104856257f37dSmrg	&& func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support."
10486f3561b8bSmrg
10487f3561b8bSmrg      case $host in
10488f3561b8bSmrg      *-*-rhapsody* | *-*-darwin1.[012])
10489f3561b8bSmrg	# On Rhapsody replace the C library is the System framework
10490bd304fc0Smrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
10491bd304fc0Smrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
10492fc5a983dSmrg	;;
10493f3561b8bSmrg      esac
10494fc5a983dSmrg
10495f3561b8bSmrg      case $host in
10496f3561b8bSmrg      *-*-darwin*)
10497f3561b8bSmrg	# Don't allow lazy linking, it breaks C++ global constructors
10498f3561b8bSmrg	# But is supposedly fixed on 10.4 or later (yay!).
104996257f37dSmrg	if test CXX = "$tagname"; then
10500f3561b8bSmrg	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
10501f3561b8bSmrg	    10.[0123])
105026257f37dSmrg	      func_append compile_command " $wl-bind_at_load"
105036257f37dSmrg	      func_append finalize_command " $wl-bind_at_load"
10504f3561b8bSmrg	    ;;
10505f3561b8bSmrg	  esac
10506fc5a983dSmrg	fi
10507f3561b8bSmrg	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
10508bd304fc0Smrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
10509bd304fc0Smrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
10510f3561b8bSmrg	;;
10511f3561b8bSmrg      esac
10512fc5a983dSmrg
10513fc5a983dSmrg
10514f3561b8bSmrg      # move library search paths that coincide with paths to not yet
10515f3561b8bSmrg      # installed libraries to the beginning of the library search list
10516f3561b8bSmrg      new_libs=
10517f3561b8bSmrg      for path in $notinst_path; do
10518f3561b8bSmrg	case " $new_libs " in
10519f3561b8bSmrg	*" -L$path/$objdir "*) ;;
10520f3561b8bSmrg	*)
10521f3561b8bSmrg	  case " $compile_deplibs " in
10522f3561b8bSmrg	  *" -L$path/$objdir "*)
10523bd304fc0Smrg	    func_append new_libs " -L$path/$objdir" ;;
10524fc5a983dSmrg	  esac
10525f3561b8bSmrg	  ;;
10526f3561b8bSmrg	esac
10527f3561b8bSmrg      done
10528f3561b8bSmrg      for deplib in $compile_deplibs; do
10529f3561b8bSmrg	case $deplib in
10530f3561b8bSmrg	-L*)
10531f3561b8bSmrg	  case " $new_libs " in
10532f3561b8bSmrg	  *" $deplib "*) ;;
10533bd304fc0Smrg	  *) func_append new_libs " $deplib" ;;
10534fc5a983dSmrg	  esac
10535f3561b8bSmrg	  ;;
10536bd304fc0Smrg	*) func_append new_libs " $deplib" ;;
10537f3561b8bSmrg	esac
10538f3561b8bSmrg      done
105396257f37dSmrg      compile_deplibs=$new_libs
10540fc5a983dSmrg
10541fc5a983dSmrg
10542bd304fc0Smrg      func_append compile_command " $compile_deplibs"
10543bd304fc0Smrg      func_append finalize_command " $finalize_deplibs"
10544fc5a983dSmrg
10545f3561b8bSmrg      if test -n "$rpath$xrpath"; then
10546f3561b8bSmrg	# If the user specified any rpath flags, then add them.
10547f3561b8bSmrg	for libdir in $rpath $xrpath; do
10548f3561b8bSmrg	  # This is the magic to use -rpath.
10549f3561b8bSmrg	  case "$finalize_rpath " in
10550f3561b8bSmrg	  *" $libdir "*) ;;
10551bd304fc0Smrg	  *) func_append finalize_rpath " $libdir" ;;
10552f3561b8bSmrg	  esac
10553f3561b8bSmrg	done
10554f3561b8bSmrg      fi
10555fc5a983dSmrg
10556f3561b8bSmrg      # Now hardcode the library paths
10557f3561b8bSmrg      rpath=
10558f3561b8bSmrg      hardcode_libdirs=
10559f3561b8bSmrg      for libdir in $compile_rpath $finalize_rpath; do
10560f3561b8bSmrg	if test -n "$hardcode_libdir_flag_spec"; then
10561f3561b8bSmrg	  if test -n "$hardcode_libdir_separator"; then
10562f3561b8bSmrg	    if test -z "$hardcode_libdirs"; then
105636257f37dSmrg	      hardcode_libdirs=$libdir
10564f3561b8bSmrg	    else
10565f3561b8bSmrg	      # Just accumulate the unique libdirs.
10566f3561b8bSmrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
10567f3561b8bSmrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
10568f3561b8bSmrg		;;
10569f3561b8bSmrg	      *)
10570bd304fc0Smrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
10571f3561b8bSmrg		;;
10572f3561b8bSmrg	      esac
10573f3561b8bSmrg	    fi
10574fc5a983dSmrg	  else
10575f3561b8bSmrg	    eval flag=\"$hardcode_libdir_flag_spec\"
10576bd304fc0Smrg	    func_append rpath " $flag"
10577fc5a983dSmrg	  fi
10578f3561b8bSmrg	elif test -n "$runpath_var"; then
10579f3561b8bSmrg	  case "$perm_rpath " in
10580f3561b8bSmrg	  *" $libdir "*) ;;
10581bd304fc0Smrg	  *) func_append perm_rpath " $libdir" ;;
10582f3561b8bSmrg	  esac
10583f3561b8bSmrg	fi
10584f3561b8bSmrg	case $host in
10585f3561b8bSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
105866257f37dSmrg	  testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'`
10587f3561b8bSmrg	  case :$dllsearchpath: in
10588f3561b8bSmrg	  *":$libdir:"*) ;;
10589f3561b8bSmrg	  ::) dllsearchpath=$libdir;;
10590bd304fc0Smrg	  *) func_append dllsearchpath ":$libdir";;
10591f3561b8bSmrg	  esac
10592f3561b8bSmrg	  case :$dllsearchpath: in
10593f3561b8bSmrg	  *":$testbindir:"*) ;;
10594f3561b8bSmrg	  ::) dllsearchpath=$testbindir;;
10595bd304fc0Smrg	  *) func_append dllsearchpath ":$testbindir";;
10596f3561b8bSmrg	  esac
10597f3561b8bSmrg	  ;;
10598f3561b8bSmrg	esac
10599f3561b8bSmrg      done
10600f3561b8bSmrg      # Substitute the hardcoded libdirs into the rpath.
10601f3561b8bSmrg      if test -n "$hardcode_libdir_separator" &&
10602f3561b8bSmrg	 test -n "$hardcode_libdirs"; then
106036257f37dSmrg	libdir=$hardcode_libdirs
10604f3561b8bSmrg	eval rpath=\" $hardcode_libdir_flag_spec\"
10605f3561b8bSmrg      fi
106066257f37dSmrg      compile_rpath=$rpath
10607fc5a983dSmrg
10608f3561b8bSmrg      rpath=
10609f3561b8bSmrg      hardcode_libdirs=
10610f3561b8bSmrg      for libdir in $finalize_rpath; do
10611f3561b8bSmrg	if test -n "$hardcode_libdir_flag_spec"; then
10612f3561b8bSmrg	  if test -n "$hardcode_libdir_separator"; then
10613f3561b8bSmrg	    if test -z "$hardcode_libdirs"; then
106146257f37dSmrg	      hardcode_libdirs=$libdir
10615f3561b8bSmrg	    else
10616f3561b8bSmrg	      # Just accumulate the unique libdirs.
10617f3561b8bSmrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
10618f3561b8bSmrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
10619f3561b8bSmrg		;;
10620f3561b8bSmrg	      *)
10621bd304fc0Smrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
10622f3561b8bSmrg		;;
10623f3561b8bSmrg	      esac
10624f3561b8bSmrg	    fi
10625fc5a983dSmrg	  else
10626f3561b8bSmrg	    eval flag=\"$hardcode_libdir_flag_spec\"
10627bd304fc0Smrg	    func_append rpath " $flag"
10628fc5a983dSmrg	  fi
10629f3561b8bSmrg	elif test -n "$runpath_var"; then
10630f3561b8bSmrg	  case "$finalize_perm_rpath " in
10631f3561b8bSmrg	  *" $libdir "*) ;;
10632bd304fc0Smrg	  *) func_append finalize_perm_rpath " $libdir" ;;
10633f3561b8bSmrg	  esac
10634fc5a983dSmrg	fi
10635f3561b8bSmrg      done
10636f3561b8bSmrg      # Substitute the hardcoded libdirs into the rpath.
10637f3561b8bSmrg      if test -n "$hardcode_libdir_separator" &&
10638f3561b8bSmrg	 test -n "$hardcode_libdirs"; then
106396257f37dSmrg	libdir=$hardcode_libdirs
10640f3561b8bSmrg	eval rpath=\" $hardcode_libdir_flag_spec\"
10641f3561b8bSmrg      fi
106426257f37dSmrg      finalize_rpath=$rpath
10643fc5a983dSmrg
106446257f37dSmrg      if test -n "$libobjs" && test yes = "$build_old_libs"; then
10645f3561b8bSmrg	# Transform all the library objects into standard objects.
10646bd304fc0Smrg	compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
10647bd304fc0Smrg	finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
10648f3561b8bSmrg      fi
10649fc5a983dSmrg
106506257f37dSmrg      func_generate_dlsyms "$outputname" "@PROGRAM@" false
10651fc5a983dSmrg
10652f3561b8bSmrg      # template prelinking step
10653f3561b8bSmrg      if test -n "$prelink_cmds"; then
10654f3561b8bSmrg	func_execute_cmds "$prelink_cmds" 'exit $?'
10655f3561b8bSmrg      fi
10656fc5a983dSmrg
106576257f37dSmrg      wrappers_required=:
10658f3561b8bSmrg      case $host in
10659bd304fc0Smrg      *cegcc* | *mingw32ce*)
10660bd304fc0Smrg        # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
106616257f37dSmrg        wrappers_required=false
10662bd304fc0Smrg        ;;
10663f3561b8bSmrg      *cygwin* | *mingw* )
106646257f37dSmrg        test yes = "$build_libtool_libs" || wrappers_required=false
10665f3561b8bSmrg        ;;
10666f3561b8bSmrg      *)
106676257f37dSmrg        if test no = "$need_relink" || test yes != "$build_libtool_libs"; then
106686257f37dSmrg          wrappers_required=false
10669f3561b8bSmrg        fi
10670f3561b8bSmrg        ;;
10671f3561b8bSmrg      esac
106726257f37dSmrg      $wrappers_required || {
10673f3561b8bSmrg	# Replace the output file specification.
10674bd304fc0Smrg	compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
106756257f37dSmrg	link_command=$compile_command$compile_rpath
10676fc5a983dSmrg
10677f3561b8bSmrg	# We have no uninstalled library dependencies, so finalize right now.
10678f3561b8bSmrg	exit_status=0
10679f3561b8bSmrg	func_show_eval "$link_command" 'exit_status=$?'
10680fc5a983dSmrg
10681bd304fc0Smrg	if test -n "$postlink_cmds"; then
10682bd304fc0Smrg	  func_to_tool_file "$output"
10683bd304fc0Smrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
10684bd304fc0Smrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
10685bd304fc0Smrg	fi
10686bd304fc0Smrg
10687f3561b8bSmrg	# Delete the generated files.
106886257f37dSmrg	if test -f "$output_objdir/${outputname}S.$objext"; then
106896257f37dSmrg	  func_show_eval '$RM "$output_objdir/${outputname}S.$objext"'
10690fc5a983dSmrg	fi
10691fc5a983dSmrg
10692f3561b8bSmrg	exit $exit_status
106936257f37dSmrg      }
10694fc5a983dSmrg
10695f3561b8bSmrg      if test -n "$compile_shlibpath$finalize_shlibpath"; then
10696f3561b8bSmrg	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
10697f3561b8bSmrg      fi
10698f3561b8bSmrg      if test -n "$finalize_shlibpath"; then
10699f3561b8bSmrg	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
10700f3561b8bSmrg      fi
10701fc5a983dSmrg
10702f3561b8bSmrg      compile_var=
10703f3561b8bSmrg      finalize_var=
10704f3561b8bSmrg      if test -n "$runpath_var"; then
10705f3561b8bSmrg	if test -n "$perm_rpath"; then
10706f3561b8bSmrg	  # We should set the runpath_var.
10707f3561b8bSmrg	  rpath=
10708f3561b8bSmrg	  for dir in $perm_rpath; do
10709bd304fc0Smrg	    func_append rpath "$dir:"
10710f3561b8bSmrg	  done
10711f3561b8bSmrg	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
10712fc5a983dSmrg	fi
10713f3561b8bSmrg	if test -n "$finalize_perm_rpath"; then
10714f3561b8bSmrg	  # We should set the runpath_var.
10715f3561b8bSmrg	  rpath=
10716f3561b8bSmrg	  for dir in $finalize_perm_rpath; do
10717bd304fc0Smrg	    func_append rpath "$dir:"
10718f3561b8bSmrg	  done
10719f3561b8bSmrg	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
10720fc5a983dSmrg	fi
10721f3561b8bSmrg      fi
10722fc5a983dSmrg
107236257f37dSmrg      if test yes = "$no_install"; then
10724f3561b8bSmrg	# We don't need to create a wrapper script.
107256257f37dSmrg	link_command=$compile_var$compile_command$compile_rpath
10726f3561b8bSmrg	# Replace the output file specification.
10727bd304fc0Smrg	link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
10728f3561b8bSmrg	# Delete the old output file.
10729f3561b8bSmrg	$opt_dry_run || $RM $output
10730f3561b8bSmrg	# Link the executable and exit
10731f3561b8bSmrg	func_show_eval "$link_command" 'exit $?'
10732bd304fc0Smrg
10733bd304fc0Smrg	if test -n "$postlink_cmds"; then
10734bd304fc0Smrg	  func_to_tool_file "$output"
10735bd304fc0Smrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
10736bd304fc0Smrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
10737bd304fc0Smrg	fi
10738bd304fc0Smrg
10739fc5a983dSmrg	exit $EXIT_SUCCESS
10740f3561b8bSmrg      fi
10741fc5a983dSmrg
107426257f37dSmrg      case $hardcode_action,$fast_install in
107436257f37dSmrg        relink,*)
107446257f37dSmrg	  # Fast installation is not supported
107456257f37dSmrg	  link_command=$compile_var$compile_command$compile_rpath
107466257f37dSmrg	  relink_command=$finalize_var$finalize_command$finalize_rpath
10747f3561b8bSmrg
107486257f37dSmrg	  func_warning "this platform does not like uninstalled shared libraries"
107496257f37dSmrg	  func_warning "'$output' will be relinked during installation"
107506257f37dSmrg	  ;;
107516257f37dSmrg        *,yes)
107526257f37dSmrg	  link_command=$finalize_var$compile_command$finalize_rpath
107536257f37dSmrg	  relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
107546257f37dSmrg          ;;
107556257f37dSmrg	*,no)
107566257f37dSmrg	  link_command=$compile_var$compile_command$compile_rpath
107576257f37dSmrg	  relink_command=$finalize_var$finalize_command$finalize_rpath
107586257f37dSmrg          ;;
107596257f37dSmrg	*,needless)
107606257f37dSmrg	  link_command=$finalize_var$compile_command$finalize_rpath
107616257f37dSmrg	  relink_command=
107626257f37dSmrg          ;;
107636257f37dSmrg      esac
10764fc5a983dSmrg
10765f3561b8bSmrg      # Replace the output file specification.
10766bd304fc0Smrg      link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
10767fc5a983dSmrg
10768f3561b8bSmrg      # Delete the old output files.
10769f3561b8bSmrg      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
10770fc5a983dSmrg
10771f3561b8bSmrg      func_show_eval "$link_command" 'exit $?'
10772fc5a983dSmrg
10773bd304fc0Smrg      if test -n "$postlink_cmds"; then
10774bd304fc0Smrg	func_to_tool_file "$output_objdir/$outputname"
10775bd304fc0Smrg	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'`
10776bd304fc0Smrg	func_execute_cmds "$postlink_cmds" 'exit $?'
10777bd304fc0Smrg      fi
10778bd304fc0Smrg
10779f3561b8bSmrg      # Now create the wrapper script.
10780f3561b8bSmrg      func_verbose "creating $output"
10781fc5a983dSmrg
10782f3561b8bSmrg      # Quote the relink command for shipping.
10783f3561b8bSmrg      if test -n "$relink_command"; then
10784f3561b8bSmrg	# Preserve any variables that may affect compiler behavior
10785f3561b8bSmrg	for var in $variables_saved_for_relink; do
10786f3561b8bSmrg	  if eval test -z \"\${$var+set}\"; then
10787f3561b8bSmrg	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
10788f3561b8bSmrg	  elif eval var_value=\$$var; test -z "$var_value"; then
10789f3561b8bSmrg	    relink_command="$var=; export $var; $relink_command"
10790fc5a983dSmrg	  else
10791d422ce2eSmrg	    func_quote_arg pretty "$var_value"
10792d422ce2eSmrg	    relink_command="$var=$func_quote_arg_result; export $var; $relink_command"
10793fc5a983dSmrg	  fi
10794f3561b8bSmrg	done
10795d422ce2eSmrg	func_quote eval cd "`pwd`"
10796d422ce2eSmrg	func_quote_arg pretty,unquoted "($func_quote_result; $relink_command)"
10797d422ce2eSmrg	relink_command=$func_quote_arg_unquoted_result
10798f3561b8bSmrg      fi
10799f3561b8bSmrg
10800f3561b8bSmrg      # Only actually do things if not in dry run mode.
10801f3561b8bSmrg      $opt_dry_run || {
10802f3561b8bSmrg	# win32 will think the script is a binary if it has
10803f3561b8bSmrg	# a .exe suffix, so we strip it off here.
10804f3561b8bSmrg	case $output in
10805f3561b8bSmrg	  *.exe) func_stripname '' '.exe' "$output"
10806f3561b8bSmrg	         output=$func_stripname_result ;;
10807f3561b8bSmrg	esac
10808f3561b8bSmrg	# test for cygwin because mv fails w/o .exe extensions
10809f3561b8bSmrg	case $host in
10810f3561b8bSmrg	  *cygwin*)
10811f3561b8bSmrg	    exeext=.exe
10812f3561b8bSmrg	    func_stripname '' '.exe' "$outputname"
10813f3561b8bSmrg	    outputname=$func_stripname_result ;;
10814f3561b8bSmrg	  *) exeext= ;;
10815fc5a983dSmrg	esac
10816f3561b8bSmrg	case $host in
10817f3561b8bSmrg	  *cygwin* | *mingw* )
10818f3561b8bSmrg	    func_dirname_and_basename "$output" "" "."
10819f3561b8bSmrg	    output_name=$func_basename_result
10820f3561b8bSmrg	    output_path=$func_dirname_result
108216257f37dSmrg	    cwrappersource=$output_path/$objdir/lt-$output_name.c
108226257f37dSmrg	    cwrapper=$output_path/$output_name.exe
10823f3561b8bSmrg	    $RM $cwrappersource $cwrapper
10824f3561b8bSmrg	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
10825f3561b8bSmrg
10826f3561b8bSmrg	    func_emit_cwrapperexe_src > $cwrappersource
10827f3561b8bSmrg
10828f3561b8bSmrg	    # The wrapper executable is built using the $host compiler,
10829f3561b8bSmrg	    # because it contains $host paths and files. If cross-
10830f3561b8bSmrg	    # compiling, it, like the target executable, must be
10831f3561b8bSmrg	    # executed on the $host or under an emulation environment.
10832f3561b8bSmrg	    $opt_dry_run || {
10833f3561b8bSmrg	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
10834f3561b8bSmrg	      $STRIP $cwrapper
10835f3561b8bSmrg	    }
10836fc5a983dSmrg
10837f3561b8bSmrg	    # Now, create the wrapper script for func_source use:
10838f3561b8bSmrg	    func_ltwrapper_scriptname $cwrapper
10839f3561b8bSmrg	    $RM $func_ltwrapper_scriptname_result
10840f3561b8bSmrg	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
10841f3561b8bSmrg	    $opt_dry_run || {
10842f3561b8bSmrg	      # note: this script will not be executed, so do not chmod.
108436257f37dSmrg	      if test "x$build" = "x$host"; then
10844f3561b8bSmrg		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
10845f3561b8bSmrg	      else
10846f3561b8bSmrg		func_emit_wrapper no > $func_ltwrapper_scriptname_result
10847f3561b8bSmrg	      fi
10848f3561b8bSmrg	    }
10849f3561b8bSmrg	  ;;
10850f3561b8bSmrg	  * )
10851f3561b8bSmrg	    $RM $output
10852f3561b8bSmrg	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
10853fc5a983dSmrg
10854f3561b8bSmrg	    func_emit_wrapper no > $output
10855f3561b8bSmrg	    chmod +x $output
10856f3561b8bSmrg	  ;;
10857f3561b8bSmrg	esac
10858f3561b8bSmrg      }
10859f3561b8bSmrg      exit $EXIT_SUCCESS
10860f3561b8bSmrg      ;;
10861f3561b8bSmrg    esac
10862fc5a983dSmrg
10863f3561b8bSmrg    # See if we need to build an old-fashioned archive.
10864f3561b8bSmrg    for oldlib in $oldlibs; do
10865fc5a983dSmrg
108666257f37dSmrg      case $build_libtool_libs in
108676257f37dSmrg        convenience)
108686257f37dSmrg	  oldobjs="$libobjs_save $symfileobj"
108696257f37dSmrg	  addlibs=$convenience
10870f3561b8bSmrg	  build_libtool_libs=no
108716257f37dSmrg	  ;;
108726257f37dSmrg	module)
108736257f37dSmrg	  oldobjs=$libobjs_save
108746257f37dSmrg	  addlibs=$old_convenience
108756257f37dSmrg	  build_libtool_libs=no
108766257f37dSmrg          ;;
108776257f37dSmrg	*)
10878f3561b8bSmrg	  oldobjs="$old_deplibs $non_pic_objects"
108796257f37dSmrg	  $preload && test -f "$symfileobj" \
108806257f37dSmrg	    && func_append oldobjs " $symfileobj"
108816257f37dSmrg	  addlibs=$old_convenience
108826257f37dSmrg	  ;;
108836257f37dSmrg      esac
10884fc5a983dSmrg
10885f3561b8bSmrg      if test -n "$addlibs"; then
108866257f37dSmrg	gentop=$output_objdir/${outputname}x
10887bd304fc0Smrg	func_append generated " $gentop"
10888fc5a983dSmrg
10889f3561b8bSmrg	func_extract_archives $gentop $addlibs
10890bd304fc0Smrg	func_append oldobjs " $func_extract_archives_result"
10891f3561b8bSmrg      fi
10892fc5a983dSmrg
10893f3561b8bSmrg      # Do each command in the archive commands.
108946257f37dSmrg      if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then
10895f3561b8bSmrg	cmds=$old_archive_from_new_cmds
10896f3561b8bSmrg      else
10897fc5a983dSmrg
10898f3561b8bSmrg	# Add any objects from preloaded convenience libraries
10899f3561b8bSmrg	if test -n "$dlprefiles"; then
109006257f37dSmrg	  gentop=$output_objdir/${outputname}x
10901bd304fc0Smrg	  func_append generated " $gentop"
10902fc5a983dSmrg
10903f3561b8bSmrg	  func_extract_archives $gentop $dlprefiles
10904bd304fc0Smrg	  func_append oldobjs " $func_extract_archives_result"
10905f3561b8bSmrg	fi
10906fc5a983dSmrg
10907f3561b8bSmrg	# POSIX demands no paths to be encoded in archives.  We have
10908f3561b8bSmrg	# to avoid creating archives with duplicate basenames if we
10909f3561b8bSmrg	# might have to extract them afterwards, e.g., when creating a
10910f3561b8bSmrg	# static archive out of a convenience library, or when linking
10911f3561b8bSmrg	# the entirety of a libtool archive into another (currently
10912f3561b8bSmrg	# not supported by libtool).
10913f3561b8bSmrg	if (for obj in $oldobjs
10914f3561b8bSmrg	    do
10915f3561b8bSmrg	      func_basename "$obj"
10916f3561b8bSmrg	      $ECHO "$func_basename_result"
10917f3561b8bSmrg	    done | sort | sort -uc >/dev/null 2>&1); then
10918f3561b8bSmrg	  :
10919f3561b8bSmrg	else
10920bd304fc0Smrg	  echo "copying selected object files to avoid basename conflicts..."
109216257f37dSmrg	  gentop=$output_objdir/${outputname}x
10922bd304fc0Smrg	  func_append generated " $gentop"
10923f3561b8bSmrg	  func_mkdir_p "$gentop"
10924f3561b8bSmrg	  save_oldobjs=$oldobjs
10925f3561b8bSmrg	  oldobjs=
10926f3561b8bSmrg	  counter=1
10927f3561b8bSmrg	  for obj in $save_oldobjs
10928f3561b8bSmrg	  do
10929f3561b8bSmrg	    func_basename "$obj"
109306257f37dSmrg	    objbase=$func_basename_result
10931f3561b8bSmrg	    case " $oldobjs " in
10932f3561b8bSmrg	    " ") oldobjs=$obj ;;
10933f3561b8bSmrg	    *[\ /]"$objbase "*)
10934f3561b8bSmrg	      while :; do
10935f3561b8bSmrg		# Make sure we don't pick an alternate name that also
10936f3561b8bSmrg		# overlaps.
10937f3561b8bSmrg		newobj=lt$counter-$objbase
10938f3561b8bSmrg		func_arith $counter + 1
10939f3561b8bSmrg		counter=$func_arith_result
10940f3561b8bSmrg		case " $oldobjs " in
10941f3561b8bSmrg		*[\ /]"$newobj "*) ;;
10942f3561b8bSmrg		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
10943f3561b8bSmrg		esac
10944f3561b8bSmrg	      done
10945f3561b8bSmrg	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
10946bd304fc0Smrg	      func_append oldobjs " $gentop/$newobj"
10947f3561b8bSmrg	      ;;
10948bd304fc0Smrg	    *) func_append oldobjs " $obj" ;;
10949f3561b8bSmrg	    esac
10950fc5a983dSmrg	  done
10951fc5a983dSmrg	fi
10952bd304fc0Smrg	func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
10953bd304fc0Smrg	tool_oldlib=$func_to_tool_file_result
10954f3561b8bSmrg	eval cmds=\"$old_archive_cmds\"
10955fc5a983dSmrg
10956f3561b8bSmrg	func_len " $cmds"
10957f3561b8bSmrg	len=$func_len_result
10958f3561b8bSmrg	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
10959f3561b8bSmrg	  cmds=$old_archive_cmds
10960bd304fc0Smrg	elif test -n "$archiver_list_spec"; then
10961bd304fc0Smrg	  func_verbose "using command file archive linking..."
10962bd304fc0Smrg	  for obj in $oldobjs
10963bd304fc0Smrg	  do
10964bd304fc0Smrg	    func_to_tool_file "$obj"
10965bd304fc0Smrg	    $ECHO "$func_to_tool_file_result"
10966bd304fc0Smrg	  done > $output_objdir/$libname.libcmd
10967bd304fc0Smrg	  func_to_tool_file "$output_objdir/$libname.libcmd"
10968bd304fc0Smrg	  oldobjs=" $archiver_list_spec$func_to_tool_file_result"
10969bd304fc0Smrg	  cmds=$old_archive_cmds
10970f3561b8bSmrg	else
10971f3561b8bSmrg	  # the command line is too long to link in one step, link in parts
10972f3561b8bSmrg	  func_verbose "using piecewise archive linking..."
10973f3561b8bSmrg	  save_RANLIB=$RANLIB
10974f3561b8bSmrg	  RANLIB=:
10975f3561b8bSmrg	  objlist=
10976f3561b8bSmrg	  concat_cmds=
10977f3561b8bSmrg	  save_oldobjs=$oldobjs
10978f3561b8bSmrg	  oldobjs=
10979f3561b8bSmrg	  # Is there a better way of finding the last object in the list?
10980f3561b8bSmrg	  for obj in $save_oldobjs
10981f3561b8bSmrg	  do
10982f3561b8bSmrg	    last_oldobj=$obj
10983f3561b8bSmrg	  done
10984f3561b8bSmrg	  eval test_cmds=\"$old_archive_cmds\"
10985f3561b8bSmrg	  func_len " $test_cmds"
10986f3561b8bSmrg	  len0=$func_len_result
10987f3561b8bSmrg	  len=$len0
10988f3561b8bSmrg	  for obj in $save_oldobjs
10989f3561b8bSmrg	  do
10990f3561b8bSmrg	    func_len " $obj"
10991f3561b8bSmrg	    func_arith $len + $func_len_result
10992f3561b8bSmrg	    len=$func_arith_result
10993f3561b8bSmrg	    func_append objlist " $obj"
10994f3561b8bSmrg	    if test "$len" -lt "$max_cmd_len"; then
10995f3561b8bSmrg	      :
10996f3561b8bSmrg	    else
10997f3561b8bSmrg	      # the above command should be used before it gets too long
10998f3561b8bSmrg	      oldobjs=$objlist
109996257f37dSmrg	      if test "$obj" = "$last_oldobj"; then
11000f3561b8bSmrg		RANLIB=$save_RANLIB
11001f3561b8bSmrg	      fi
11002f3561b8bSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
110036257f37dSmrg	      eval concat_cmds=\"\$concat_cmds$old_archive_cmds\"
11004f3561b8bSmrg	      objlist=
11005f3561b8bSmrg	      len=$len0
11006f3561b8bSmrg	    fi
11007f3561b8bSmrg	  done
11008f3561b8bSmrg	  RANLIB=$save_RANLIB
11009f3561b8bSmrg	  oldobjs=$objlist
110106257f37dSmrg	  if test -z "$oldobjs"; then
11011f3561b8bSmrg	    eval cmds=\"\$concat_cmds\"
11012f3561b8bSmrg	  else
11013f3561b8bSmrg	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
11014f3561b8bSmrg	  fi
11015f3561b8bSmrg	fi
11016f3561b8bSmrg      fi
11017f3561b8bSmrg      func_execute_cmds "$cmds" 'exit $?'
11018fc5a983dSmrg    done
11019fc5a983dSmrg
11020f3561b8bSmrg    test -n "$generated" && \
11021f3561b8bSmrg      func_show_eval "${RM}r$generated"
11022fc5a983dSmrg
11023f3561b8bSmrg    # Now create the libtool archive.
11024f3561b8bSmrg    case $output in
11025f3561b8bSmrg    *.la)
11026f3561b8bSmrg      old_library=
110276257f37dSmrg      test yes = "$build_old_libs" && old_library=$libname.$libext
11028f3561b8bSmrg      func_verbose "creating $output"
11029fc5a983dSmrg
11030f3561b8bSmrg      # Preserve any variables that may affect compiler behavior
11031f3561b8bSmrg      for var in $variables_saved_for_relink; do
11032f3561b8bSmrg	if eval test -z \"\${$var+set}\"; then
11033f3561b8bSmrg	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
11034f3561b8bSmrg	elif eval var_value=\$$var; test -z "$var_value"; then
11035f3561b8bSmrg	  relink_command="$var=; export $var; $relink_command"
11036fc5a983dSmrg	else
11037d422ce2eSmrg	  func_quote_arg pretty,unquoted "$var_value"
11038d422ce2eSmrg	  relink_command="$var=$func_quote_arg_unquoted_result; export $var; $relink_command"
11039fc5a983dSmrg	fi
11040f3561b8bSmrg      done
11041f3561b8bSmrg      # Quote the link command for shipping.
11042d422ce2eSmrg      func_quote eval cd "`pwd`"
11043d422ce2eSmrg      relink_command="($func_quote_result; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
11044d422ce2eSmrg      func_quote_arg pretty,unquoted "$relink_command"
11045d422ce2eSmrg      relink_command=$func_quote_arg_unquoted_result
110466257f37dSmrg      if test yes = "$hardcode_automatic"; then
11047f3561b8bSmrg	relink_command=
11048f3561b8bSmrg      fi
11049fc5a983dSmrg
11050f3561b8bSmrg      # Only create the output if not a dry run.
11051f3561b8bSmrg      $opt_dry_run || {
11052f3561b8bSmrg	for installed in no yes; do
110536257f37dSmrg	  if test yes = "$installed"; then
11054f3561b8bSmrg	    if test -z "$install_libdir"; then
11055f3561b8bSmrg	      break
11056f3561b8bSmrg	    fi
110576257f37dSmrg	    output=$output_objdir/${outputname}i
11058f3561b8bSmrg	    # Replace all uninstalled libtool libraries with the installed ones
11059f3561b8bSmrg	    newdependency_libs=
11060f3561b8bSmrg	    for deplib in $dependency_libs; do
11061f3561b8bSmrg	      case $deplib in
11062f3561b8bSmrg	      *.la)
11063f3561b8bSmrg		func_basename "$deplib"
110646257f37dSmrg		name=$func_basename_result
11065bd304fc0Smrg		func_resolve_sysroot "$deplib"
110666257f37dSmrg		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
11067f3561b8bSmrg		test -z "$libdir" && \
110686257f37dSmrg		  func_fatal_error "'$deplib' is not a valid libtool archive"
11069bd304fc0Smrg		func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
11070bd304fc0Smrg		;;
11071bd304fc0Smrg	      -L*)
11072bd304fc0Smrg		func_stripname -L '' "$deplib"
11073bd304fc0Smrg		func_replace_sysroot "$func_stripname_result"
11074bd304fc0Smrg		func_append newdependency_libs " -L$func_replace_sysroot_result"
11075f3561b8bSmrg		;;
11076bd304fc0Smrg	      -R*)
11077bd304fc0Smrg		func_stripname -R '' "$deplib"
11078bd304fc0Smrg		func_replace_sysroot "$func_stripname_result"
11079bd304fc0Smrg		func_append newdependency_libs " -R$func_replace_sysroot_result"
11080bd304fc0Smrg		;;
11081bd304fc0Smrg	      *) func_append newdependency_libs " $deplib" ;;
11082f3561b8bSmrg	      esac
11083f3561b8bSmrg	    done
110846257f37dSmrg	    dependency_libs=$newdependency_libs
11085f3561b8bSmrg	    newdlfiles=
11086f3561b8bSmrg
11087f3561b8bSmrg	    for lib in $dlfiles; do
11088f3561b8bSmrg	      case $lib in
11089f3561b8bSmrg	      *.la)
11090f3561b8bSmrg	        func_basename "$lib"
110916257f37dSmrg		name=$func_basename_result
110926257f37dSmrg		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
11093f3561b8bSmrg		test -z "$libdir" && \
110946257f37dSmrg		  func_fatal_error "'$lib' is not a valid libtool archive"
11095bd304fc0Smrg		func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
11096f3561b8bSmrg		;;
11097bd304fc0Smrg	      *) func_append newdlfiles " $lib" ;;
11098f3561b8bSmrg	      esac
11099f3561b8bSmrg	    done
111006257f37dSmrg	    dlfiles=$newdlfiles
11101f3561b8bSmrg	    newdlprefiles=
11102f3561b8bSmrg	    for lib in $dlprefiles; do
11103f3561b8bSmrg	      case $lib in
11104f3561b8bSmrg	      *.la)
11105f3561b8bSmrg		# Only pass preopened files to the pseudo-archive (for
11106f3561b8bSmrg		# eventual linking with the app. that links it) if we
11107f3561b8bSmrg		# didn't already link the preopened objects directly into
11108f3561b8bSmrg		# the library:
11109f3561b8bSmrg		func_basename "$lib"
111106257f37dSmrg		name=$func_basename_result
111116257f37dSmrg		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
11112f3561b8bSmrg		test -z "$libdir" && \
111136257f37dSmrg		  func_fatal_error "'$lib' is not a valid libtool archive"
11114bd304fc0Smrg		func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
11115f3561b8bSmrg		;;
11116f3561b8bSmrg	      esac
11117f3561b8bSmrg	    done
111186257f37dSmrg	    dlprefiles=$newdlprefiles
11119f3561b8bSmrg	  else
11120f3561b8bSmrg	    newdlfiles=
11121f3561b8bSmrg	    for lib in $dlfiles; do
11122f3561b8bSmrg	      case $lib in
111236257f37dSmrg		[\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
11124f3561b8bSmrg		*) abs=`pwd`"/$lib" ;;
11125f3561b8bSmrg	      esac
11126bd304fc0Smrg	      func_append newdlfiles " $abs"
11127f3561b8bSmrg	    done
111286257f37dSmrg	    dlfiles=$newdlfiles
11129f3561b8bSmrg	    newdlprefiles=
11130f3561b8bSmrg	    for lib in $dlprefiles; do
11131f3561b8bSmrg	      case $lib in
111326257f37dSmrg		[\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
11133f3561b8bSmrg		*) abs=`pwd`"/$lib" ;;
11134f3561b8bSmrg	      esac
11135bd304fc0Smrg	      func_append newdlprefiles " $abs"
11136f3561b8bSmrg	    done
111376257f37dSmrg	    dlprefiles=$newdlprefiles
11138f3561b8bSmrg	  fi
11139f3561b8bSmrg	  $RM $output
11140f3561b8bSmrg	  # place dlname in correct position for cygwin
11141bd304fc0Smrg	  # In fact, it would be nice if we could use this code for all target
11142bd304fc0Smrg	  # systems that can't hard-code library paths into their executables
11143bd304fc0Smrg	  # and that have no shared library path variable independent of PATH,
11144bd304fc0Smrg	  # but it turns out we can't easily determine that from inspecting
11145bd304fc0Smrg	  # libtool variables, so we have to hard-code the OSs to which it
11146bd304fc0Smrg	  # applies here; at the moment, that means platforms that use the PE
11147bd304fc0Smrg	  # object format with DLL files.  See the long comment at the top of
11148bd304fc0Smrg	  # tests/bindir.at for full details.
11149f3561b8bSmrg	  tdlname=$dlname
11150f3561b8bSmrg	  case $host,$output,$installed,$module,$dlname in
11151bd304fc0Smrg	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
11152bd304fc0Smrg	      # If a -bindir argument was supplied, place the dll there.
111536257f37dSmrg	      if test -n "$bindir"; then
11154bd304fc0Smrg		func_relative_path "$install_libdir" "$bindir"
111556257f37dSmrg		tdlname=$func_relative_path_result/$dlname
11156bd304fc0Smrg	      else
11157bd304fc0Smrg		# Otherwise fall back on heuristic.
11158bd304fc0Smrg		tdlname=../bin/$dlname
11159bd304fc0Smrg	      fi
11160bd304fc0Smrg	      ;;
11161f3561b8bSmrg	  esac
11162f3561b8bSmrg	  $ECHO > $output "\
11163f3561b8bSmrg# $outputname - a libtool library file
111646257f37dSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
11165f3561b8bSmrg#
11166f3561b8bSmrg# Please DO NOT delete this file!
11167f3561b8bSmrg# It is necessary for linking the library.
11168fc5a983dSmrg
11169f3561b8bSmrg# The name that we can dlopen(3).
11170f3561b8bSmrgdlname='$tdlname'
11171fc5a983dSmrg
11172f3561b8bSmrg# Names of this library.
11173f3561b8bSmrglibrary_names='$library_names'
11174fc5a983dSmrg
11175f3561b8bSmrg# The name of the static archive.
11176f3561b8bSmrgold_library='$old_library'
11177fc5a983dSmrg
111786257f37dSmrg# Linker flags that cannot go in dependency_libs.
11179f3561b8bSmrginherited_linker_flags='$new_inherited_linker_flags'
11180fc5a983dSmrg
11181f3561b8bSmrg# Libraries that this one depends upon.
11182f3561b8bSmrgdependency_libs='$dependency_libs'
11183fc5a983dSmrg
11184f3561b8bSmrg# Names of additional weak libraries provided by this library
11185f3561b8bSmrgweak_library_names='$weak_libs'
11186fc5a983dSmrg
11187f3561b8bSmrg# Version information for $libname.
11188f3561b8bSmrgcurrent=$current
11189f3561b8bSmrgage=$age
11190f3561b8bSmrgrevision=$revision
11191fc5a983dSmrg
11192f3561b8bSmrg# Is this an already installed library?
11193f3561b8bSmrginstalled=$installed
11194fc5a983dSmrg
11195f3561b8bSmrg# Should we warn about portability when linking against -modules?
11196f3561b8bSmrgshouldnotlink=$module
11197fc5a983dSmrg
11198f3561b8bSmrg# Files to dlopen/dlpreopen
11199f3561b8bSmrgdlopen='$dlfiles'
11200f3561b8bSmrgdlpreopen='$dlprefiles'
11201fc5a983dSmrg
11202f3561b8bSmrg# Directory that this library needs to be installed in:
11203f3561b8bSmrglibdir='$install_libdir'"
112046257f37dSmrg	  if test no,yes = "$installed,$need_relink"; then
11205f3561b8bSmrg	    $ECHO >> $output "\
11206f3561b8bSmrgrelink_command=\"$relink_command\""
11207f3561b8bSmrg	  fi
11208f3561b8bSmrg	done
11209f3561b8bSmrg      }
11210fc5a983dSmrg
11211f3561b8bSmrg      # Do a symbolic link so that the libtool archive can be found in
11212f3561b8bSmrg      # LD_LIBRARY_PATH before the program is installed.
11213f3561b8bSmrg      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
11214f3561b8bSmrg      ;;
11215f3561b8bSmrg    esac
11216f3561b8bSmrg    exit $EXIT_SUCCESS
11217f3561b8bSmrg}
11218fc5a983dSmrg
112196257f37dSmrgif test link = "$opt_mode" || test relink = "$opt_mode"; then
112206257f37dSmrg  func_mode_link ${1+"$@"}
112216257f37dSmrgfi
11222fc5a983dSmrg
11223fc5a983dSmrg
11224f3561b8bSmrg# func_mode_uninstall arg...
11225f3561b8bSmrgfunc_mode_uninstall ()
11226f3561b8bSmrg{
112276257f37dSmrg    $debug_cmd
112286257f37dSmrg
112296257f37dSmrg    RM=$nonopt
11230fc5a983dSmrg    files=
112316257f37dSmrg    rmforce=false
11232fc5a983dSmrg    exit_status=0
11233fc5a983dSmrg
11234fc5a983dSmrg    # This variable tells wrapper scripts just to set variables rather
11235fc5a983dSmrg    # than running their programs.
112366257f37dSmrg    libtool_install_magic=$magic
11237fc5a983dSmrg
11238fc5a983dSmrg    for arg
11239fc5a983dSmrg    do
11240fc5a983dSmrg      case $arg in
112416257f37dSmrg      -f) func_append RM " $arg"; rmforce=: ;;
11242bd304fc0Smrg      -*) func_append RM " $arg" ;;
11243bd304fc0Smrg      *) func_append files " $arg" ;;
11244fc5a983dSmrg      esac
11245fc5a983dSmrg    done
11246fc5a983dSmrg
11247f3561b8bSmrg    test -z "$RM" && \
11248f3561b8bSmrg      func_fatal_help "you must specify an RM program"
11249fc5a983dSmrg
11250fc5a983dSmrg    rmdirs=
11251fc5a983dSmrg
11252fc5a983dSmrg    for file in $files; do
11253f3561b8bSmrg      func_dirname "$file" "" "."
112546257f37dSmrg      dir=$func_dirname_result
112556257f37dSmrg      if test . = "$dir"; then
112566257f37dSmrg	odir=$objdir
11257fc5a983dSmrg      else
112586257f37dSmrg	odir=$dir/$objdir
11259fc5a983dSmrg      fi
11260f3561b8bSmrg      func_basename "$file"
112616257f37dSmrg      name=$func_basename_result
112626257f37dSmrg      test uninstall = "$opt_mode" && odir=$dir
11263fc5a983dSmrg
11264bd304fc0Smrg      # Remember odir for removal later, being careful to avoid duplicates
112656257f37dSmrg      if test clean = "$opt_mode"; then
11266fc5a983dSmrg	case " $rmdirs " in
11267bd304fc0Smrg	  *" $odir "*) ;;
11268bd304fc0Smrg	  *) func_append rmdirs " $odir" ;;
11269fc5a983dSmrg	esac
11270fc5a983dSmrg      fi
11271fc5a983dSmrg
11272fc5a983dSmrg      # Don't error if the file doesn't exist and rm -f was used.
11273f3561b8bSmrg      if { test -L "$file"; } >/dev/null 2>&1 ||
11274f3561b8bSmrg	 { test -h "$file"; } >/dev/null 2>&1 ||
11275f3561b8bSmrg	 test -f "$file"; then
11276fc5a983dSmrg	:
11277fc5a983dSmrg      elif test -d "$file"; then
11278fc5a983dSmrg	exit_status=1
11279fc5a983dSmrg	continue
112806257f37dSmrg      elif $rmforce; then
11281fc5a983dSmrg	continue
11282fc5a983dSmrg      fi
11283fc5a983dSmrg
112846257f37dSmrg      rmfiles=$file
11285fc5a983dSmrg
11286fc5a983dSmrg      case $name in
11287fc5a983dSmrg      *.la)
11288fc5a983dSmrg	# Possibly a libtool archive, so verify it.
11289f3561b8bSmrg	if func_lalib_p "$file"; then
11290f3561b8bSmrg	  func_source $dir/$name
11291fc5a983dSmrg
11292fc5a983dSmrg	  # Delete the libtool libraries and symlinks.
11293fc5a983dSmrg	  for n in $library_names; do
11294bd304fc0Smrg	    func_append rmfiles " $odir/$n"
11295fc5a983dSmrg	  done
11296bd304fc0Smrg	  test -n "$old_library" && func_append rmfiles " $odir/$old_library"
11297fc5a983dSmrg
112986257f37dSmrg	  case $opt_mode in
11299fc5a983dSmrg	  clean)
11300bd304fc0Smrg	    case " $library_names " in
11301fc5a983dSmrg	    *" $dlname "*) ;;
11302bd304fc0Smrg	    *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
11303fc5a983dSmrg	    esac
11304bd304fc0Smrg	    test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
11305fc5a983dSmrg	    ;;
11306fc5a983dSmrg	  uninstall)
11307fc5a983dSmrg	    if test -n "$library_names"; then
11308fc5a983dSmrg	      # Do each command in the postuninstall commands.
113096257f37dSmrg	      func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1'
11310fc5a983dSmrg	    fi
11311fc5a983dSmrg
11312fc5a983dSmrg	    if test -n "$old_library"; then
11313fc5a983dSmrg	      # Do each command in the old_postuninstall commands.
113146257f37dSmrg	      func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1'
11315fc5a983dSmrg	    fi
11316fc5a983dSmrg	    # FIXME: should reinstall the best remaining shared library.
11317fc5a983dSmrg	    ;;
11318fc5a983dSmrg	  esac
11319fc5a983dSmrg	fi
11320fc5a983dSmrg	;;
11321fc5a983dSmrg
11322fc5a983dSmrg      *.lo)
11323fc5a983dSmrg	# Possibly a libtool object, so verify it.
11324f3561b8bSmrg	if func_lalib_p "$file"; then
11325fc5a983dSmrg
11326fc5a983dSmrg	  # Read the .lo file
11327f3561b8bSmrg	  func_source $dir/$name
11328fc5a983dSmrg
11329fc5a983dSmrg	  # Add PIC object to the list of files to remove.
113306257f37dSmrg	  if test -n "$pic_object" && test none != "$pic_object"; then
11331bd304fc0Smrg	    func_append rmfiles " $dir/$pic_object"
11332fc5a983dSmrg	  fi
11333fc5a983dSmrg
11334fc5a983dSmrg	  # Add non-PIC object to the list of files to remove.
113356257f37dSmrg	  if test -n "$non_pic_object" && test none != "$non_pic_object"; then
11336bd304fc0Smrg	    func_append rmfiles " $dir/$non_pic_object"
11337fc5a983dSmrg	  fi
11338fc5a983dSmrg	fi
11339fc5a983dSmrg	;;
11340fc5a983dSmrg
11341fc5a983dSmrg      *)
113426257f37dSmrg	if test clean = "$opt_mode"; then
11343fc5a983dSmrg	  noexename=$name
11344fc5a983dSmrg	  case $file in
11345fc5a983dSmrg	  *.exe)
11346f3561b8bSmrg	    func_stripname '' '.exe' "$file"
11347f3561b8bSmrg	    file=$func_stripname_result
11348f3561b8bSmrg	    func_stripname '' '.exe' "$name"
11349f3561b8bSmrg	    noexename=$func_stripname_result
11350fc5a983dSmrg	    # $file with .exe has already been added to rmfiles,
11351fc5a983dSmrg	    # add $file without .exe
11352bd304fc0Smrg	    func_append rmfiles " $file"
11353fc5a983dSmrg	    ;;
11354fc5a983dSmrg	  esac
11355fc5a983dSmrg	  # Do a test to see if this is a libtool program.
11356f3561b8bSmrg	  if func_ltwrapper_p "$file"; then
11357f3561b8bSmrg	    if func_ltwrapper_executable_p "$file"; then
11358f3561b8bSmrg	      func_ltwrapper_scriptname "$file"
11359f3561b8bSmrg	      relink_command=
11360f3561b8bSmrg	      func_source $func_ltwrapper_scriptname_result
11361bd304fc0Smrg	      func_append rmfiles " $func_ltwrapper_scriptname_result"
11362f3561b8bSmrg	    else
11363f3561b8bSmrg	      relink_command=
11364f3561b8bSmrg	      func_source $dir/$noexename
11365f3561b8bSmrg	    fi
11366fc5a983dSmrg
11367fc5a983dSmrg	    # note $name still contains .exe if it was in $file originally
11368fc5a983dSmrg	    # as does the version of $file that was added into $rmfiles
113696257f37dSmrg	    func_append rmfiles " $odir/$name $odir/${name}S.$objext"
113706257f37dSmrg	    if test yes = "$fast_install" && test -n "$relink_command"; then
11371bd304fc0Smrg	      func_append rmfiles " $odir/lt-$name"
11372fc5a983dSmrg	    fi
113736257f37dSmrg	    if test "X$noexename" != "X$name"; then
113746257f37dSmrg	      func_append rmfiles " $odir/lt-$noexename.c"
11375fc5a983dSmrg	    fi
11376fc5a983dSmrg	  fi
11377fc5a983dSmrg	fi
11378fc5a983dSmrg	;;
11379fc5a983dSmrg      esac
11380f3561b8bSmrg      func_show_eval "$RM $rmfiles" 'exit_status=1'
11381fc5a983dSmrg    done
11382fc5a983dSmrg
113836257f37dSmrg    # Try to remove the $objdir's in the directories where we deleted files
11384fc5a983dSmrg    for dir in $rmdirs; do
11385fc5a983dSmrg      if test -d "$dir"; then
11386f3561b8bSmrg	func_show_eval "rmdir $dir >/dev/null 2>&1"
11387fc5a983dSmrg      fi
11388fc5a983dSmrg    done
11389fc5a983dSmrg
11390fc5a983dSmrg    exit $exit_status
11391f3561b8bSmrg}
11392fc5a983dSmrg
113936257f37dSmrgif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then
113946257f37dSmrg  func_mode_uninstall ${1+"$@"}
113956257f37dSmrgfi
11396fc5a983dSmrg
11397bd304fc0Smrgtest -z "$opt_mode" && {
113986257f37dSmrg  help=$generic_help
11399f3561b8bSmrg  func_fatal_help "you must specify a MODE"
11400f3561b8bSmrg}
11401f3561b8bSmrg
11402f3561b8bSmrgtest -z "$exec_cmd" && \
114036257f37dSmrg  func_fatal_help "invalid operation mode '$opt_mode'"
11404fc5a983dSmrg
11405fc5a983dSmrgif test -n "$exec_cmd"; then
11406f3561b8bSmrg  eval exec "$exec_cmd"
11407fc5a983dSmrg  exit $EXIT_FAILURE
11408fc5a983dSmrgfi
11409fc5a983dSmrg
11410f3561b8bSmrgexit $exit_status
11411fc5a983dSmrg
11412fc5a983dSmrg
11413fc5a983dSmrg# The TAGs below are defined such that we never get into a situation
114146257f37dSmrg# where we disable both kinds of libraries.  Given conflicting
11415fc5a983dSmrg# choices, we go for a static library, that is the most portable,
11416fc5a983dSmrg# since we can't tell whether shared libraries were disabled because
11417fc5a983dSmrg# the user asked for that or because the platform doesn't support
11418fc5a983dSmrg# them.  This is particularly important on AIX, because we don't
11419fc5a983dSmrg# support having both static and shared libraries enabled at the same
11420fc5a983dSmrg# time on that platform, so we default to a shared-only configuration.
11421fc5a983dSmrg# If a disable-shared tag is given, we'll fallback to a static-only
11422fc5a983dSmrg# configuration.  But we'll never go from static-only to shared-only.
11423fc5a983dSmrg
11424fc5a983dSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
11425f3561b8bSmrgbuild_libtool_libs=no
11426f3561b8bSmrgbuild_old_libs=yes
11427fc5a983dSmrg# ### END LIBTOOL TAG CONFIG: disable-shared
11428fc5a983dSmrg
11429fc5a983dSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static
11430f3561b8bSmrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
11431fc5a983dSmrg# ### END LIBTOOL TAG CONFIG: disable-static
11432fc5a983dSmrg
11433fc5a983dSmrg# Local Variables:
11434fc5a983dSmrg# mode:shell-script
11435fc5a983dSmrg# sh-indentation:2
11436fc5a983dSmrg# End:
11437