ltmain.sh revision 3169be4b
13169be4bSmrg#! /bin/sh
23169be4bSmrg## DO NOT EDIT - This file generated from ./build-aux/ltmain.in
33169be4bSmrg##               by inline-source v2014-01-03.01
48c4a8e55Smrg
53169be4bSmrg# libtool (GNU libtool) 2.4.6
63169be4bSmrg# Provide generalized library-building support services.
78c4a8e55Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
88c4a8e55Smrg
93169be4bSmrg# Copyright (C) 1996-2015 Free Software Foundation, Inc.
108c4a8e55Smrg# This is free software; see the source for copying conditions.  There is NO
118c4a8e55Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
128c4a8e55Smrg
138c4a8e55Smrg# GNU Libtool is free software; you can redistribute it and/or modify
14b042e37fSmrg# it under the terms of the GNU General Public License as published by
15b042e37fSmrg# the Free Software Foundation; either version 2 of the License, or
16b042e37fSmrg# (at your option) any later version.
17b042e37fSmrg#
188c4a8e55Smrg# As a special exception to the GNU General Public License,
198c4a8e55Smrg# if you distribute this file as part of a program or library that
208c4a8e55Smrg# is built using GNU Libtool, you may include this file under the
218c4a8e55Smrg# same distribution terms that you use for the rest of that program.
228c4a8e55Smrg#
238c4a8e55Smrg# GNU Libtool is distributed in the hope that it will be useful, but
24b042e37fSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of
25b042e37fSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
26b042e37fSmrg# General Public License for more details.
27b042e37fSmrg#
28b042e37fSmrg# You should have received a copy of the GNU General Public License
293169be4bSmrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
308c4a8e55Smrg
318c4a8e55Smrg
32706b6b52SmrgPROGRAM=libtool
338c4a8e55SmrgPACKAGE=libtool
343169be4bSmrgVERSION=2.4.6
353169be4bSmrgpackage_revision=2.4.6
368c4a8e55Smrg
373169be4bSmrg
383169be4bSmrg## ------ ##
393169be4bSmrg## Usage. ##
403169be4bSmrg## ------ ##
413169be4bSmrg
423169be4bSmrg# Run './libtool --help' for help with using this script from the
433169be4bSmrg# command line.
443169be4bSmrg
453169be4bSmrg
463169be4bSmrg## ------------------------------- ##
473169be4bSmrg## User overridable command paths. ##
483169be4bSmrg## ------------------------------- ##
493169be4bSmrg
503169be4bSmrg# After configure completes, it has a better idea of some of the
513169be4bSmrg# shell tools we need than the defaults used by the functions shared
523169be4bSmrg# with bootstrap, so set those here where they can still be over-
533169be4bSmrg# ridden by the user, but otherwise take precedence.
543169be4bSmrg
553169be4bSmrg: ${AUTOCONF="autoconf"}
563169be4bSmrg: ${AUTOMAKE="automake"}
573169be4bSmrg
583169be4bSmrg
593169be4bSmrg## -------------------------- ##
603169be4bSmrg## Source external libraries. ##
613169be4bSmrg## -------------------------- ##
623169be4bSmrg
633169be4bSmrg# Much of our low-level functionality needs to be sourced from external
643169be4bSmrg# libraries, which are installed to $pkgauxdir.
653169be4bSmrg
663169be4bSmrg# Set a version string for this script.
673169be4bSmrgscriptversion=2015-01-20.17; # UTC
683169be4bSmrg
693169be4bSmrg# General shell script boiler plate, and helper functions.
703169be4bSmrg# Written by Gary V. Vaughan, 2004
713169be4bSmrg
723169be4bSmrg# Copyright (C) 2004-2015 Free Software Foundation, Inc.
733169be4bSmrg# This is free software; see the source for copying conditions.  There is NO
743169be4bSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
753169be4bSmrg
763169be4bSmrg# This program is free software; you can redistribute it and/or modify
773169be4bSmrg# it under the terms of the GNU General Public License as published by
783169be4bSmrg# the Free Software Foundation; either version 3 of the License, or
793169be4bSmrg# (at your option) any later version.
803169be4bSmrg
813169be4bSmrg# As a special exception to the GNU General Public License, if you distribute
823169be4bSmrg# this file as part of a program or library that is built using GNU Libtool,
833169be4bSmrg# you may include this file under the same distribution terms that you use
843169be4bSmrg# for the rest of that program.
853169be4bSmrg
863169be4bSmrg# This program is distributed in the hope that it will be useful,
873169be4bSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
883169be4bSmrg# MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU
893169be4bSmrg# General Public License for more details.
903169be4bSmrg
913169be4bSmrg# You should have received a copy of the GNU General Public License
923169be4bSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>.
933169be4bSmrg
943169be4bSmrg# Please report bugs or propose patches to gary@gnu.org.
953169be4bSmrg
963169be4bSmrg
973169be4bSmrg## ------ ##
983169be4bSmrg## Usage. ##
993169be4bSmrg## ------ ##
1003169be4bSmrg
1013169be4bSmrg# Evaluate this file near the top of your script to gain access to
1023169be4bSmrg# the functions and variables defined here:
1033169be4bSmrg#
1043169be4bSmrg#   . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh
1053169be4bSmrg#
1063169be4bSmrg# If you need to override any of the default environment variable
1073169be4bSmrg# settings, do that before evaluating this file.
1083169be4bSmrg
1093169be4bSmrg
1103169be4bSmrg## -------------------- ##
1113169be4bSmrg## Shell normalisation. ##
1123169be4bSmrg## -------------------- ##
1133169be4bSmrg
1143169be4bSmrg# Some shells need a little help to be as Bourne compatible as possible.
1153169be4bSmrg# Before doing anything else, make sure all that help has been provided!
1163169be4bSmrg
1173169be4bSmrgDUALCASE=1; export DUALCASE # for MKS sh
1183169be4bSmrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
1198c4a8e55Smrg  emulate sh
1208c4a8e55Smrg  NULLCMD=:
1213169be4bSmrg  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
1228c4a8e55Smrg  # is contrary to our usage.  Disable this feature.
1238c4a8e55Smrg  alias -g '${1+"$@"}'='"$@"'
1248c4a8e55Smrg  setopt NO_GLOB_SUBST
1258c4a8e55Smrgelse
1263169be4bSmrg  case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac
1278c4a8e55Smrgfi
128706b6b52Smrg
1293169be4bSmrg# NLS nuisances: We save the old values in case they are required later.
1303169be4bSmrg_G_user_locale=
1313169be4bSmrg_G_safe_locale=
1323169be4bSmrgfor _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
1338c4a8e55Smrgdo
1343169be4bSmrg  eval "if test set = \"\${$_G_var+set}\"; then
1353169be4bSmrg          save_$_G_var=\$$_G_var
1363169be4bSmrg          $_G_var=C
1373169be4bSmrg	  export $_G_var
1383169be4bSmrg	  _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\"
1393169be4bSmrg	  _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\"
1408c4a8e55Smrg	fi"
1418c4a8e55Smrgdone
1428c4a8e55Smrg
1433169be4bSmrg# CDPATH.
1443169be4bSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
1458c4a8e55Smrg
1463169be4bSmrg# Make sure IFS has a sensible default
1473169be4bSmrgsp=' '
1483169be4bSmrgnl='
1493169be4bSmrg'
1503169be4bSmrgIFS="$sp	$nl"
1513169be4bSmrg
1523169be4bSmrg# There are apparently some retarded systems that use ';' as a PATH separator!
1533169be4bSmrgif test "${PATH_SEPARATOR+set}" != set; then
1543169be4bSmrg  PATH_SEPARATOR=:
1553169be4bSmrg  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
1563169be4bSmrg    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
1573169be4bSmrg      PATH_SEPARATOR=';'
1583169be4bSmrg  }
1593169be4bSmrgfi
1608c4a8e55Smrg
1618c4a8e55Smrg
1628c4a8e55Smrg
1633169be4bSmrg## ------------------------- ##
1643169be4bSmrg## Locate command utilities. ##
1653169be4bSmrg## ------------------------- ##
1663169be4bSmrg
1673169be4bSmrg
1683169be4bSmrg# func_executable_p FILE
1693169be4bSmrg# ----------------------
1703169be4bSmrg# Check that FILE is an executable regular file.
1713169be4bSmrgfunc_executable_p ()
1723169be4bSmrg{
1733169be4bSmrg    test -f "$1" && test -x "$1"
1743169be4bSmrg}
1753169be4bSmrg
1763169be4bSmrg
1773169be4bSmrg# func_path_progs PROGS_LIST CHECK_FUNC [PATH]
1783169be4bSmrg# --------------------------------------------
1793169be4bSmrg# Search for either a program that responds to --version with output
1803169be4bSmrg# containing "GNU", or else returned by CHECK_FUNC otherwise, by
1813169be4bSmrg# trying all the directories in PATH with each of the elements of
1823169be4bSmrg# PROGS_LIST.
1833169be4bSmrg#
1843169be4bSmrg# CHECK_FUNC should accept the path to a candidate program, and
1853169be4bSmrg# set $func_check_prog_result if it truncates its output less than
1863169be4bSmrg# $_G_path_prog_max characters.
1873169be4bSmrgfunc_path_progs ()
1883169be4bSmrg{
1893169be4bSmrg    _G_progs_list=$1
1903169be4bSmrg    _G_check_func=$2
1913169be4bSmrg    _G_PATH=${3-"$PATH"}
1923169be4bSmrg
1933169be4bSmrg    _G_path_prog_max=0
1943169be4bSmrg    _G_path_prog_found=false
1953169be4bSmrg    _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:}
1963169be4bSmrg    for _G_dir in $_G_PATH; do
1973169be4bSmrg      IFS=$_G_save_IFS
1983169be4bSmrg      test -z "$_G_dir" && _G_dir=.
1993169be4bSmrg      for _G_prog_name in $_G_progs_list; do
2003169be4bSmrg        for _exeext in '' .EXE; do
2013169be4bSmrg          _G_path_prog=$_G_dir/$_G_prog_name$_exeext
2023169be4bSmrg          func_executable_p "$_G_path_prog" || continue
2033169be4bSmrg          case `"$_G_path_prog" --version 2>&1` in
2043169be4bSmrg            *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;;
2053169be4bSmrg            *)     $_G_check_func $_G_path_prog
2063169be4bSmrg		   func_path_progs_result=$func_check_prog_result
2073169be4bSmrg		   ;;
2083169be4bSmrg          esac
2093169be4bSmrg          $_G_path_prog_found && break 3
2103169be4bSmrg        done
2113169be4bSmrg      done
2123169be4bSmrg    done
2133169be4bSmrg    IFS=$_G_save_IFS
2143169be4bSmrg    test -z "$func_path_progs_result" && {
2153169be4bSmrg      echo "no acceptable sed could be found in \$PATH" >&2
2163169be4bSmrg      exit 1
2173169be4bSmrg    }
2183169be4bSmrg}
2193169be4bSmrg
2203169be4bSmrg
2213169be4bSmrg# We want to be able to use the functions in this file before configure
2223169be4bSmrg# has figured out where the best binaries are kept, which means we have
2233169be4bSmrg# to search for them ourselves - except when the results are already set
2243169be4bSmrg# where we skip the searches.
2253169be4bSmrg
2263169be4bSmrg# Unless the user overrides by setting SED, search the path for either GNU
2273169be4bSmrg# sed, or the sed that truncates its output the least.
2283169be4bSmrgtest -z "$SED" && {
2293169be4bSmrg  _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
2303169be4bSmrg  for _G_i in 1 2 3 4 5 6 7; do
2313169be4bSmrg    _G_sed_script=$_G_sed_script$nl$_G_sed_script
2323169be4bSmrg  done
2333169be4bSmrg  echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed
2343169be4bSmrg  _G_sed_script=
2353169be4bSmrg
2363169be4bSmrg  func_check_prog_sed ()
2373169be4bSmrg  {
2383169be4bSmrg    _G_path_prog=$1
2393169be4bSmrg
2403169be4bSmrg    _G_count=0
2413169be4bSmrg    printf 0123456789 >conftest.in
2423169be4bSmrg    while :
2433169be4bSmrg    do
2443169be4bSmrg      cat conftest.in conftest.in >conftest.tmp
2453169be4bSmrg      mv conftest.tmp conftest.in
2463169be4bSmrg      cp conftest.in conftest.nl
2473169be4bSmrg      echo '' >> conftest.nl
2483169be4bSmrg      "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break
2493169be4bSmrg      diff conftest.out conftest.nl >/dev/null 2>&1 || break
2503169be4bSmrg      _G_count=`expr $_G_count + 1`
2513169be4bSmrg      if test "$_G_count" -gt "$_G_path_prog_max"; then
2523169be4bSmrg        # Best one so far, save it but keep looking for a better one
2533169be4bSmrg        func_check_prog_result=$_G_path_prog
2543169be4bSmrg        _G_path_prog_max=$_G_count
2553169be4bSmrg      fi
2563169be4bSmrg      # 10*(2^10) chars as input seems more than enough
2573169be4bSmrg      test 10 -lt "$_G_count" && break
2583169be4bSmrg    done
2593169be4bSmrg    rm -f conftest.in conftest.tmp conftest.nl conftest.out
2603169be4bSmrg  }
2613169be4bSmrg
2623169be4bSmrg  func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin
2633169be4bSmrg  rm -f conftest.sed
2643169be4bSmrg  SED=$func_path_progs_result
2653169be4bSmrg}
2663169be4bSmrg
2673169be4bSmrg
2683169be4bSmrg# Unless the user overrides by setting GREP, search the path for either GNU
2693169be4bSmrg# grep, or the grep that truncates its output the least.
2703169be4bSmrgtest -z "$GREP" && {
2713169be4bSmrg  func_check_prog_grep ()
2723169be4bSmrg  {
2733169be4bSmrg    _G_path_prog=$1
2743169be4bSmrg
2753169be4bSmrg    _G_count=0
2763169be4bSmrg    _G_path_prog_max=0
2773169be4bSmrg    printf 0123456789 >conftest.in
2783169be4bSmrg    while :
2793169be4bSmrg    do
2803169be4bSmrg      cat conftest.in conftest.in >conftest.tmp
2813169be4bSmrg      mv conftest.tmp conftest.in
2823169be4bSmrg      cp conftest.in conftest.nl
2833169be4bSmrg      echo 'GREP' >> conftest.nl
2843169be4bSmrg      "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break
2853169be4bSmrg      diff conftest.out conftest.nl >/dev/null 2>&1 || break
2863169be4bSmrg      _G_count=`expr $_G_count + 1`
2873169be4bSmrg      if test "$_G_count" -gt "$_G_path_prog_max"; then
2883169be4bSmrg        # Best one so far, save it but keep looking for a better one
2893169be4bSmrg        func_check_prog_result=$_G_path_prog
2903169be4bSmrg        _G_path_prog_max=$_G_count
2913169be4bSmrg      fi
2923169be4bSmrg      # 10*(2^10) chars as input seems more than enough
2933169be4bSmrg      test 10 -lt "$_G_count" && break
2943169be4bSmrg    done
2953169be4bSmrg    rm -f conftest.in conftest.tmp conftest.nl conftest.out
2963169be4bSmrg  }
2973169be4bSmrg
2983169be4bSmrg  func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin
2993169be4bSmrg  GREP=$func_path_progs_result
3003169be4bSmrg}
3013169be4bSmrg
3023169be4bSmrg
3033169be4bSmrg## ------------------------------- ##
3043169be4bSmrg## User overridable command paths. ##
3053169be4bSmrg## ------------------------------- ##
3063169be4bSmrg
3073169be4bSmrg# All uppercase variable names are used for environment variables.  These
3083169be4bSmrg# variables can be overridden by the user before calling a script that
3093169be4bSmrg# uses them if a suitable command of that name is not already available
3103169be4bSmrg# in the command search PATH.
3118c4a8e55Smrg
3128c4a8e55Smrg: ${CP="cp -f"}
3133169be4bSmrg: ${ECHO="printf %s\n"}
3143169be4bSmrg: ${EGREP="$GREP -E"}
3153169be4bSmrg: ${FGREP="$GREP -F"}
3163169be4bSmrg: ${LN_S="ln -s"}
3178c4a8e55Smrg: ${MAKE="make"}
3188c4a8e55Smrg: ${MKDIR="mkdir"}
3198c4a8e55Smrg: ${MV="mv -f"}
3208c4a8e55Smrg: ${RM="rm -f"}
3218c4a8e55Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
3228c4a8e55Smrg
3238c4a8e55Smrg
3243169be4bSmrg## -------------------- ##
3253169be4bSmrg## Useful sed snippets. ##
3263169be4bSmrg## -------------------- ##
327bd23fbfaSmrg
3283169be4bSmrgsed_dirname='s|/[^/]*$||'
3293169be4bSmrgsed_basename='s|^.*/||'
330bd23fbfaSmrg
3313169be4bSmrg# Sed substitution that helps us do robust quoting.  It backslashifies
3323169be4bSmrg# metacharacters that are still active within double-quoted strings.
3333169be4bSmrgsed_quote_subst='s|\([`"$\\]\)|\\\1|g'
334bd23fbfaSmrg
3353169be4bSmrg# Same as above, but do not quote variable references.
3363169be4bSmrgsed_double_quote_subst='s/\(["`\\]\)/\\\1/g'
337bd23fbfaSmrg
3383169be4bSmrg# Sed substitution that turns a string into a regex matching for the
3393169be4bSmrg# string literally.
3403169be4bSmrgsed_make_literal_regex='s|[].[^$\\*\/]|\\&|g'
341bd23fbfaSmrg
3423169be4bSmrg# Sed substitution that converts a w32 file name or path
3433169be4bSmrg# that contains forward slashes, into one that contains
3443169be4bSmrg# (escaped) backslashes.  A very naive implementation.
3453169be4bSmrgsed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
3463169be4bSmrg
3473169be4bSmrg# Re-'\' parameter expansions in output of sed_double_quote_subst that
3483169be4bSmrg# were '\'-ed in input to the same.  If an odd number of '\' preceded a
3493169be4bSmrg# '$' in input to sed_double_quote_subst, that '$' was protected from
3503169be4bSmrg# expansion.  Since each input '\' is now two '\'s, look for any number
3513169be4bSmrg# of runs of four '\'s followed by two '\'s and then a '$'.  '\' that '$'.
3523169be4bSmrg_G_bs='\\'
3533169be4bSmrg_G_bs2='\\\\'
3543169be4bSmrg_G_bs4='\\\\\\\\'
3553169be4bSmrg_G_dollar='\$'
3563169be4bSmrgsed_double_backslash="\
3573169be4bSmrg  s/$_G_bs4/&\\
3583169be4bSmrg/g
3593169be4bSmrg  s/^$_G_bs2$_G_dollar/$_G_bs&/
3603169be4bSmrg  s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g
3613169be4bSmrg  s/\n//g"
362bd23fbfaSmrg
3638c4a8e55Smrg
3643169be4bSmrg## ----------------- ##
3653169be4bSmrg## Global variables. ##
3663169be4bSmrg## ----------------- ##
367b042e37fSmrg
3683169be4bSmrg# Except for the global variables explicitly listed below, the following
3693169be4bSmrg# functions in the '^func_' namespace, and the '^require_' namespace
3703169be4bSmrg# variables initialised in the 'Resource management' section, sourcing
3713169be4bSmrg# this file will not pollute your global namespace with anything
3723169be4bSmrg# else. There's no portable way to scope variables in Bourne shell
3733169be4bSmrg# though, so actually running these functions will sometimes place
3743169be4bSmrg# results into a variable named after the function, and often use
3753169be4bSmrg# temporary variables in the '^_G_' namespace. If you are careful to
3763169be4bSmrg# avoid using those namespaces casually in your sourcing script, things
3773169be4bSmrg# should continue to work as you expect. And, of course, you can freely
3783169be4bSmrg# overwrite any of the functions or variables defined here before
3793169be4bSmrg# calling anything to customize them.
380706b6b52Smrg
3813169be4bSmrgEXIT_SUCCESS=0
3823169be4bSmrgEXIT_FAILURE=1
3833169be4bSmrgEXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
3843169be4bSmrgEXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
385706b6b52Smrg
3863169be4bSmrg# Allow overriding, eg assuming that you follow the convention of
3873169be4bSmrg# putting '$debug_cmd' at the start of all your functions, you can get
3883169be4bSmrg# bash to show function call trace with:
3893169be4bSmrg#
3903169be4bSmrg#    debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name
3913169be4bSmrgdebug_cmd=${debug_cmd-":"}
3923169be4bSmrgexit_cmd=:
393706b6b52Smrg
3943169be4bSmrg# By convention, finish your script with:
3953169be4bSmrg#
3963169be4bSmrg#    exit $exit_status
3973169be4bSmrg#
3983169be4bSmrg# so that you can set exit_status to non-zero if you want to indicate
3993169be4bSmrg# something went wrong during execution without actually bailing out at
4003169be4bSmrg# the point of failure.
4013169be4bSmrgexit_status=$EXIT_SUCCESS
402706b6b52Smrg
4033169be4bSmrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
4043169be4bSmrg# is ksh but when the shell is invoked as "sh" and the current value of
4053169be4bSmrg# the _XPG environment variable is not equal to 1 (one), the special
4063169be4bSmrg# positional parameter $0, within a function call, is the name of the
4073169be4bSmrg# function.
4083169be4bSmrgprogpath=$0
409b042e37fSmrg
4103169be4bSmrg# The name of this program.
4113169be4bSmrgprogname=`$ECHO "$progpath" |$SED "$sed_basename"`
412b042e37fSmrg
4133169be4bSmrg# Make sure we have an absolute progpath for reexecution:
4148c4a8e55Smrgcase $progpath in
4158c4a8e55Smrg  [\\/]*|[A-Za-z]:\\*) ;;
4168c4a8e55Smrg  *[\\/]*)
4173169be4bSmrg     progdir=`$ECHO "$progpath" |$SED "$sed_dirname"`
4188c4a8e55Smrg     progdir=`cd "$progdir" && pwd`
4193169be4bSmrg     progpath=$progdir/$progname
4208c4a8e55Smrg     ;;
4218c4a8e55Smrg  *)
4223169be4bSmrg     _G_IFS=$IFS
4230597fb56Smrg     IFS=${PATH_SEPARATOR-:}
4248c4a8e55Smrg     for progdir in $PATH; do
4253169be4bSmrg       IFS=$_G_IFS
4268c4a8e55Smrg       test -x "$progdir/$progname" && break
4278c4a8e55Smrg     done
4283169be4bSmrg     IFS=$_G_IFS
4298c4a8e55Smrg     test -n "$progdir" || progdir=`pwd`
4303169be4bSmrg     progpath=$progdir/$progname
4318c4a8e55Smrg     ;;
4328c4a8e55Smrgesac
433b042e37fSmrg
4348c4a8e55Smrg
4353169be4bSmrg## ----------------- ##
4363169be4bSmrg## Standard options. ##
4373169be4bSmrg## ----------------- ##
438bd23fbfaSmrg
4393169be4bSmrg# The following options affect the operation of the functions defined
4403169be4bSmrg# below, and should be set appropriately depending on run-time para-
4413169be4bSmrg# meters passed on the command line.
4428c4a8e55Smrg
4438c4a8e55Smrgopt_dry_run=false
4448c4a8e55Smrgopt_quiet=false
4458c4a8e55Smrgopt_verbose=false
4468c4a8e55Smrg
4473169be4bSmrg# Categories 'all' and 'none' are always available.  Append any others
4483169be4bSmrg# you will pass as the first argument to func_warning from your own
4493169be4bSmrg# code.
4503169be4bSmrgwarning_categories=
451b042e37fSmrg
4523169be4bSmrg# By default, display warnings according to 'opt_warning_types'.  Set
4533169be4bSmrg# 'warning_func'  to ':' to elide all warnings, or func_fatal_error to
4543169be4bSmrg# treat the next displayed warning as a fatal error.
4553169be4bSmrgwarning_func=func_warn_and_continue
456b042e37fSmrg
4573169be4bSmrg# Set to 'all' to display all warnings, 'none' to suppress all
4583169be4bSmrg# warnings, or a space delimited list of some subset of
4593169be4bSmrg# 'warning_categories' to display only the listed warnings.
4603169be4bSmrgopt_warning_types=all
461b042e37fSmrg
462706b6b52Smrg
4633169be4bSmrg## -------------------- ##
4643169be4bSmrg## Resource management. ##
4653169be4bSmrg## -------------------- ##
466b042e37fSmrg
4673169be4bSmrg# This section contains definitions for functions that each ensure a
4683169be4bSmrg# particular resource (a file, or a non-empty configuration variable for
4693169be4bSmrg# example) is available, and if appropriate to extract default values
4703169be4bSmrg# from pertinent package files. Call them using their associated
4713169be4bSmrg# 'require_*' variable to ensure that they are executed, at most, once.
4723169be4bSmrg#
4733169be4bSmrg# It's entirely deliberate that calling these functions can set
4743169be4bSmrg# variables that don't obey the namespace limitations obeyed by the rest
4753169be4bSmrg# of this file, in order that that they be as useful as possible to
4763169be4bSmrg# callers.
477b042e37fSmrg
478b042e37fSmrg
4793169be4bSmrg# require_term_colors
4803169be4bSmrg# -------------------
4813169be4bSmrg# Allow display of bold text on terminals that support it.
4823169be4bSmrgrequire_term_colors=func_require_term_colors
4833169be4bSmrgfunc_require_term_colors ()
4848c4a8e55Smrg{
4853169be4bSmrg    $debug_cmd
4863169be4bSmrg
4873169be4bSmrg    test -t 1 && {
4883169be4bSmrg      # COLORTERM and USE_ANSI_COLORS environment variables take
4893169be4bSmrg      # precedence, because most terminfo databases neglect to describe
4903169be4bSmrg      # whether color sequences are supported.
4913169be4bSmrg      test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"}
4923169be4bSmrg
4933169be4bSmrg      if test 1 = "$USE_ANSI_COLORS"; then
4943169be4bSmrg        # Standard ANSI escape sequences
4953169be4bSmrg        tc_reset='[0m'
4963169be4bSmrg        tc_bold='[1m';   tc_standout='[7m'
4973169be4bSmrg        tc_red='[31m';   tc_green='[32m'
4983169be4bSmrg        tc_blue='[34m';  tc_cyan='[36m'
4993169be4bSmrg      else
5003169be4bSmrg        # Otherwise trust the terminfo database after all.
5013169be4bSmrg        test -n "`tput sgr0 2>/dev/null`" && {
5023169be4bSmrg          tc_reset=`tput sgr0`
5033169be4bSmrg          test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold`
5043169be4bSmrg          tc_standout=$tc_bold
5053169be4bSmrg          test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso`
5063169be4bSmrg          test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1`
5073169be4bSmrg          test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2`
5083169be4bSmrg          test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4`
5093169be4bSmrg          test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5`
5103169be4bSmrg        }
5113169be4bSmrg      fi
5123169be4bSmrg    }
513b042e37fSmrg
5143169be4bSmrg    require_term_colors=:
5158c4a8e55Smrg}
516b042e37fSmrg
517b042e37fSmrg
5183169be4bSmrg## ----------------- ##
5193169be4bSmrg## Function library. ##
5203169be4bSmrg## ----------------- ##
5213169be4bSmrg
5223169be4bSmrg# This section contains a variety of useful functions to call in your
5233169be4bSmrg# scripts. Take note of the portable wrappers for features provided by
5243169be4bSmrg# some modern shells, which will fall back to slower equivalents on
5253169be4bSmrg# less featureful shells.
5263169be4bSmrg
5273169be4bSmrg
5283169be4bSmrg# func_append VAR VALUE
5293169be4bSmrg# ---------------------
5303169be4bSmrg# Append VALUE onto the existing contents of VAR.
5313169be4bSmrg
5323169be4bSmrg  # We should try to minimise forks, especially on Windows where they are
5333169be4bSmrg  # unreasonably slow, so skip the feature probes when bash or zsh are
5343169be4bSmrg  # being used:
5353169be4bSmrg  if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then
5363169be4bSmrg    : ${_G_HAVE_ARITH_OP="yes"}
5373169be4bSmrg    : ${_G_HAVE_XSI_OPS="yes"}
5383169be4bSmrg    # The += operator was introduced in bash 3.1
5393169be4bSmrg    case $BASH_VERSION in
5403169be4bSmrg      [12].* | 3.0 | 3.0*) ;;
5413169be4bSmrg      *)
5423169be4bSmrg        : ${_G_HAVE_PLUSEQ_OP="yes"}
5433169be4bSmrg        ;;
5443169be4bSmrg    esac
5453169be4bSmrg  fi
5463169be4bSmrg
5473169be4bSmrg  # _G_HAVE_PLUSEQ_OP
5483169be4bSmrg  # Can be empty, in which case the shell is probed, "yes" if += is
5493169be4bSmrg  # useable or anything else if it does not work.
5503169be4bSmrg  test -z "$_G_HAVE_PLUSEQ_OP" \
5513169be4bSmrg    && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \
5523169be4bSmrg    && _G_HAVE_PLUSEQ_OP=yes
5533169be4bSmrg
5543169be4bSmrgif test yes = "$_G_HAVE_PLUSEQ_OP"
5553169be4bSmrgthen
5563169be4bSmrg  # This is an XSI compatible shell, allowing a faster implementation...
5573169be4bSmrg  eval 'func_append ()
5583169be4bSmrg  {
5593169be4bSmrg    $debug_cmd
5603169be4bSmrg
5613169be4bSmrg    eval "$1+=\$2"
5623169be4bSmrg  }'
5633169be4bSmrgelse
5643169be4bSmrg  # ...otherwise fall back to using expr, which is often a shell builtin.
5653169be4bSmrg  func_append ()
5663169be4bSmrg  {
5673169be4bSmrg    $debug_cmd
5683169be4bSmrg
5693169be4bSmrg    eval "$1=\$$1\$2"
5703169be4bSmrg  }
5713169be4bSmrgfi
5723169be4bSmrg
5733169be4bSmrg
5743169be4bSmrg# func_append_quoted VAR VALUE
5753169be4bSmrg# ----------------------------
5763169be4bSmrg# Quote VALUE and append to the end of shell variable VAR, separated
5773169be4bSmrg# by a space.
5783169be4bSmrgif test yes = "$_G_HAVE_PLUSEQ_OP"; then
5793169be4bSmrg  eval 'func_append_quoted ()
5803169be4bSmrg  {
5813169be4bSmrg    $debug_cmd
5823169be4bSmrg
5833169be4bSmrg    func_quote_for_eval "$2"
5843169be4bSmrg    eval "$1+=\\ \$func_quote_for_eval_result"
5853169be4bSmrg  }'
5863169be4bSmrgelse
5873169be4bSmrg  func_append_quoted ()
5883169be4bSmrg  {
5893169be4bSmrg    $debug_cmd
5903169be4bSmrg
5913169be4bSmrg    func_quote_for_eval "$2"
5923169be4bSmrg    eval "$1=\$$1\\ \$func_quote_for_eval_result"
5933169be4bSmrg  }
5943169be4bSmrgfi
5953169be4bSmrg
5963169be4bSmrg
5973169be4bSmrg# func_append_uniq VAR VALUE
5983169be4bSmrg# --------------------------
5993169be4bSmrg# Append unique VALUE onto the existing contents of VAR, assuming
6003169be4bSmrg# entries are delimited by the first character of VALUE.  For example:
6013169be4bSmrg#
6023169be4bSmrg#   func_append_uniq options " --another-option option-argument"
6033169be4bSmrg#
6043169be4bSmrg# will only append to $options if " --another-option option-argument "
6053169be4bSmrg# is not already present somewhere in $options already (note spaces at
6063169be4bSmrg# each end implied by leading space in second argument).
6073169be4bSmrgfunc_append_uniq ()
6083169be4bSmrg{
6093169be4bSmrg    $debug_cmd
6103169be4bSmrg
6113169be4bSmrg    eval _G_current_value='`$ECHO $'$1'`'
6123169be4bSmrg    _G_delim=`expr "$2" : '\(.\)'`
6133169be4bSmrg
6143169be4bSmrg    case $_G_delim$_G_current_value$_G_delim in
6153169be4bSmrg      *"$2$_G_delim"*) ;;
6163169be4bSmrg      *) func_append "$@" ;;
6173169be4bSmrg    esac
6183169be4bSmrg}
6193169be4bSmrg
6203169be4bSmrg
6213169be4bSmrg# func_arith TERM...
6223169be4bSmrg# ------------------
6233169be4bSmrg# Set func_arith_result to the result of evaluating TERMs.
6243169be4bSmrg  test -z "$_G_HAVE_ARITH_OP" \
6253169be4bSmrg    && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \
6263169be4bSmrg    && _G_HAVE_ARITH_OP=yes
6273169be4bSmrg
6283169be4bSmrgif test yes = "$_G_HAVE_ARITH_OP"; then
6293169be4bSmrg  eval 'func_arith ()
6303169be4bSmrg  {
6313169be4bSmrg    $debug_cmd
6323169be4bSmrg
6333169be4bSmrg    func_arith_result=$(( $* ))
6343169be4bSmrg  }'
6353169be4bSmrgelse
6363169be4bSmrg  func_arith ()
6373169be4bSmrg  {
6383169be4bSmrg    $debug_cmd
6393169be4bSmrg
6403169be4bSmrg    func_arith_result=`expr "$@"`
6413169be4bSmrg  }
6423169be4bSmrgfi
6433169be4bSmrg
6443169be4bSmrg
6453169be4bSmrg# func_basename FILE
6463169be4bSmrg# ------------------
6473169be4bSmrg# Set func_basename_result to FILE with everything up to and including
6483169be4bSmrg# the last / stripped.
6493169be4bSmrgif test yes = "$_G_HAVE_XSI_OPS"; then
6503169be4bSmrg  # If this shell supports suffix pattern removal, then use it to avoid
6513169be4bSmrg  # forking. Hide the definitions single quotes in case the shell chokes
6523169be4bSmrg  # on unsupported syntax...
6533169be4bSmrg  _b='func_basename_result=${1##*/}'
6543169be4bSmrg  _d='case $1 in
6553169be4bSmrg        */*) func_dirname_result=${1%/*}$2 ;;
6563169be4bSmrg        *  ) func_dirname_result=$3        ;;
6573169be4bSmrg      esac'
6583169be4bSmrg
6593169be4bSmrgelse
6603169be4bSmrg  # ...otherwise fall back to using sed.
6613169be4bSmrg  _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`'
6623169be4bSmrg  _d='func_dirname_result=`$ECHO "$1"  |$SED "$sed_dirname"`
6633169be4bSmrg      if test "X$func_dirname_result" = "X$1"; then
6643169be4bSmrg        func_dirname_result=$3
6653169be4bSmrg      else
6663169be4bSmrg        func_append func_dirname_result "$2"
6673169be4bSmrg      fi'
6683169be4bSmrgfi
6693169be4bSmrg
6703169be4bSmrgeval 'func_basename ()
6713169be4bSmrg{
6723169be4bSmrg    $debug_cmd
6733169be4bSmrg
6743169be4bSmrg    '"$_b"'
6753169be4bSmrg}'
6763169be4bSmrg
6773169be4bSmrg
6783169be4bSmrg# func_dirname FILE APPEND NONDIR_REPLACEMENT
6793169be4bSmrg# -------------------------------------------
6803169be4bSmrg# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
6813169be4bSmrg# otherwise set result to NONDIR_REPLACEMENT.
6823169be4bSmrgeval 'func_dirname ()
6833169be4bSmrg{
6843169be4bSmrg    $debug_cmd
6853169be4bSmrg
6863169be4bSmrg    '"$_d"'
6873169be4bSmrg}'
6883169be4bSmrg
6893169be4bSmrg
6903169be4bSmrg# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT
6913169be4bSmrg# --------------------------------------------------------
6923169be4bSmrg# Perform func_basename and func_dirname in a single function
6933169be4bSmrg# call:
6943169be4bSmrg#   dirname:  Compute the dirname of FILE.  If nonempty,
6953169be4bSmrg#             add APPEND to the result, otherwise set result
6963169be4bSmrg#             to NONDIR_REPLACEMENT.
6973169be4bSmrg#             value returned in "$func_dirname_result"
6983169be4bSmrg#   basename: Compute filename of FILE.
6993169be4bSmrg#             value retuned in "$func_basename_result"
7003169be4bSmrg# For efficiency, we do not delegate to the functions above but instead
7013169be4bSmrg# duplicate the functionality here.
7023169be4bSmrgeval 'func_dirname_and_basename ()
7033169be4bSmrg{
7043169be4bSmrg    $debug_cmd
7053169be4bSmrg
7063169be4bSmrg    '"$_b"'
7073169be4bSmrg    '"$_d"'
7083169be4bSmrg}'
7093169be4bSmrg
7103169be4bSmrg
7113169be4bSmrg# func_echo ARG...
7123169be4bSmrg# ----------------
7133169be4bSmrg# Echo program name prefixed message.
7143169be4bSmrgfunc_echo ()
7153169be4bSmrg{
7163169be4bSmrg    $debug_cmd
7173169be4bSmrg
7183169be4bSmrg    _G_message=$*
7193169be4bSmrg
7203169be4bSmrg    func_echo_IFS=$IFS
7213169be4bSmrg    IFS=$nl
7223169be4bSmrg    for _G_line in $_G_message; do
7233169be4bSmrg      IFS=$func_echo_IFS
7243169be4bSmrg      $ECHO "$progname: $_G_line"
7253169be4bSmrg    done
7263169be4bSmrg    IFS=$func_echo_IFS
7273169be4bSmrg}
7283169be4bSmrg
7293169be4bSmrg
7303169be4bSmrg# func_echo_all ARG...
7313169be4bSmrg# --------------------
7323169be4bSmrg# Invoke $ECHO with all args, space-separated.
7333169be4bSmrgfunc_echo_all ()
7343169be4bSmrg{
7353169be4bSmrg    $ECHO "$*"
7363169be4bSmrg}
7373169be4bSmrg
7383169be4bSmrg
7393169be4bSmrg# func_echo_infix_1 INFIX ARG...
7403169be4bSmrg# ------------------------------
7413169be4bSmrg# Echo program name, followed by INFIX on the first line, with any
7423169be4bSmrg# additional lines not showing INFIX.
7433169be4bSmrgfunc_echo_infix_1 ()
7443169be4bSmrg{
7453169be4bSmrg    $debug_cmd
7463169be4bSmrg
7473169be4bSmrg    $require_term_colors
7483169be4bSmrg
7493169be4bSmrg    _G_infix=$1; shift
7503169be4bSmrg    _G_indent=$_G_infix
7513169be4bSmrg    _G_prefix="$progname: $_G_infix: "
7523169be4bSmrg    _G_message=$*
7533169be4bSmrg
7543169be4bSmrg    # Strip color escape sequences before counting printable length
7553169be4bSmrg    for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan"
7563169be4bSmrg    do
7573169be4bSmrg      test -n "$_G_tc" && {
7583169be4bSmrg        _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"`
7593169be4bSmrg        _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"`
7603169be4bSmrg      }
7613169be4bSmrg    done
7623169be4bSmrg    _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`"  " ## exclude from sc_prohibit_nested_quotes
7633169be4bSmrg
7643169be4bSmrg    func_echo_infix_1_IFS=$IFS
7653169be4bSmrg    IFS=$nl
7663169be4bSmrg    for _G_line in $_G_message; do
7673169be4bSmrg      IFS=$func_echo_infix_1_IFS
7683169be4bSmrg      $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2
7693169be4bSmrg      _G_prefix=$_G_indent
7703169be4bSmrg    done
7713169be4bSmrg    IFS=$func_echo_infix_1_IFS
7723169be4bSmrg}
7733169be4bSmrg
7743169be4bSmrg
7753169be4bSmrg# func_error ARG...
7763169be4bSmrg# -----------------
7773169be4bSmrg# Echo program name prefixed message to standard error.
7783169be4bSmrgfunc_error ()
7793169be4bSmrg{
7803169be4bSmrg    $debug_cmd
7813169be4bSmrg
7823169be4bSmrg    $require_term_colors
7833169be4bSmrg
7843169be4bSmrg    func_echo_infix_1 "  $tc_standout${tc_red}error$tc_reset" "$*" >&2
7853169be4bSmrg}
7863169be4bSmrg
7873169be4bSmrg
7883169be4bSmrg# func_fatal_error ARG...
7893169be4bSmrg# -----------------------
7903169be4bSmrg# Echo program name prefixed message to standard error, and exit.
7913169be4bSmrgfunc_fatal_error ()
7923169be4bSmrg{
7933169be4bSmrg    $debug_cmd
7943169be4bSmrg
7953169be4bSmrg    func_error "$*"
7963169be4bSmrg    exit $EXIT_FAILURE
7973169be4bSmrg}
7983169be4bSmrg
7993169be4bSmrg
8003169be4bSmrg# func_grep EXPRESSION FILENAME
8013169be4bSmrg# -----------------------------
8028c4a8e55Smrg# Check whether EXPRESSION matches any line of FILENAME, without output.
8038c4a8e55Smrgfunc_grep ()
8048c4a8e55Smrg{
8053169be4bSmrg    $debug_cmd
8063169be4bSmrg
8078c4a8e55Smrg    $GREP "$1" "$2" >/dev/null 2>&1
8088c4a8e55Smrg}
8098c4a8e55Smrg
8108c4a8e55Smrg
8113169be4bSmrg# func_len STRING
8123169be4bSmrg# ---------------
8133169be4bSmrg# Set func_len_result to the length of STRING. STRING may not
8143169be4bSmrg# start with a hyphen.
8153169be4bSmrg  test -z "$_G_HAVE_XSI_OPS" \
8163169be4bSmrg    && (eval 'x=a/b/c;
8173169be4bSmrg      test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
8183169be4bSmrg    && _G_HAVE_XSI_OPS=yes
8193169be4bSmrg
8203169be4bSmrgif test yes = "$_G_HAVE_XSI_OPS"; then
8213169be4bSmrg  eval 'func_len ()
8223169be4bSmrg  {
8233169be4bSmrg    $debug_cmd
8243169be4bSmrg
8253169be4bSmrg    func_len_result=${#1}
8263169be4bSmrg  }'
8273169be4bSmrgelse
8283169be4bSmrg  func_len ()
8293169be4bSmrg  {
8303169be4bSmrg    $debug_cmd
8313169be4bSmrg
8323169be4bSmrg    func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len`
8333169be4bSmrg  }
8343169be4bSmrgfi
8353169be4bSmrg
8363169be4bSmrg
8373169be4bSmrg# func_mkdir_p DIRECTORY-PATH
8383169be4bSmrg# ---------------------------
8398c4a8e55Smrg# Make sure the entire path to DIRECTORY-PATH is available.
8408c4a8e55Smrgfunc_mkdir_p ()
8418c4a8e55Smrg{
8423169be4bSmrg    $debug_cmd
8433169be4bSmrg
8443169be4bSmrg    _G_directory_path=$1
8453169be4bSmrg    _G_dir_list=
8468c4a8e55Smrg
8473169be4bSmrg    if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then
8488c4a8e55Smrg
8493169be4bSmrg      # Protect directory names starting with '-'
8503169be4bSmrg      case $_G_directory_path in
8513169be4bSmrg        -*) _G_directory_path=./$_G_directory_path ;;
8528c4a8e55Smrg      esac
8538c4a8e55Smrg
8548c4a8e55Smrg      # While some portion of DIR does not yet exist...
8553169be4bSmrg      while test ! -d "$_G_directory_path"; do
8568c4a8e55Smrg        # ...make a list in topmost first order.  Use a colon delimited
8578c4a8e55Smrg	# list incase some portion of path contains whitespace.
8583169be4bSmrg        _G_dir_list=$_G_directory_path:$_G_dir_list
8598c4a8e55Smrg
8608c4a8e55Smrg        # If the last portion added has no slash in it, the list is done
8613169be4bSmrg        case $_G_directory_path in */*) ;; *) break ;; esac
8628c4a8e55Smrg
8638c4a8e55Smrg        # ...otherwise throw away the child directory and loop
8643169be4bSmrg        _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"`
8658c4a8e55Smrg      done
8663169be4bSmrg      _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'`
8678c4a8e55Smrg
8683169be4bSmrg      func_mkdir_p_IFS=$IFS; IFS=:
8693169be4bSmrg      for _G_dir in $_G_dir_list; do
8703169be4bSmrg	IFS=$func_mkdir_p_IFS
8713169be4bSmrg        # mkdir can fail with a 'File exist' error if two processes
8728c4a8e55Smrg        # try to create one of the directories concurrently.  Don't
8738c4a8e55Smrg        # stop in that case!
8743169be4bSmrg        $MKDIR "$_G_dir" 2>/dev/null || :
8758c4a8e55Smrg      done
8763169be4bSmrg      IFS=$func_mkdir_p_IFS
8778c4a8e55Smrg
8788c4a8e55Smrg      # Bail out if we (or some other process) failed to create a directory.
8793169be4bSmrg      test -d "$_G_directory_path" || \
8803169be4bSmrg        func_fatal_error "Failed to create '$1'"
8818c4a8e55Smrg    fi
8828c4a8e55Smrg}
883b042e37fSmrg
884b042e37fSmrg
8853169be4bSmrg# func_mktempdir [BASENAME]
8863169be4bSmrg# -------------------------
887b042e37fSmrg# Make a temporary directory that won't clash with other running
888b042e37fSmrg# libtool processes, and avoids race conditions if possible.  If
8893169be4bSmrg# given, BASENAME is the basename for that directory.
890b042e37fSmrgfunc_mktempdir ()
891b042e37fSmrg{
8923169be4bSmrg    $debug_cmd
8933169be4bSmrg
8943169be4bSmrg    _G_template=${TMPDIR-/tmp}/${1-$progname}
895b042e37fSmrg
8963169be4bSmrg    if test : = "$opt_dry_run"; then
897b042e37fSmrg      # Return a directory name, but don't create it in dry-run mode
8983169be4bSmrg      _G_tmpdir=$_G_template-$$
899b042e37fSmrg    else
900b042e37fSmrg
901b042e37fSmrg      # If mktemp works, use that first and foremost
9023169be4bSmrg      _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null`
903b042e37fSmrg
9043169be4bSmrg      if test ! -d "$_G_tmpdir"; then
9058c4a8e55Smrg        # Failing that, at least try and use $RANDOM to avoid a race
9063169be4bSmrg        _G_tmpdir=$_G_template-${RANDOM-0}$$
907b042e37fSmrg
9083169be4bSmrg        func_mktempdir_umask=`umask`
9098c4a8e55Smrg        umask 0077
9103169be4bSmrg        $MKDIR "$_G_tmpdir"
9113169be4bSmrg        umask $func_mktempdir_umask
912b042e37fSmrg      fi
913b042e37fSmrg
914b042e37fSmrg      # If we're not in dry-run mode, bomb out on failure
9153169be4bSmrg      test -d "$_G_tmpdir" || \
9163169be4bSmrg        func_fatal_error "cannot create temporary directory '$_G_tmpdir'"
917b042e37fSmrg    fi
918b042e37fSmrg
9193169be4bSmrg    $ECHO "$_G_tmpdir"
920b042e37fSmrg}
921b042e37fSmrg
922b042e37fSmrg
9233169be4bSmrg# func_normal_abspath PATH
9243169be4bSmrg# ------------------------
9253169be4bSmrg# Remove doubled-up and trailing slashes, "." path components,
9263169be4bSmrg# and cancel out any ".." path components in PATH after making
9273169be4bSmrg# it an absolute path.
9283169be4bSmrgfunc_normal_abspath ()
929b042e37fSmrg{
9303169be4bSmrg    $debug_cmd
9318c4a8e55Smrg
9323169be4bSmrg    # These SED scripts presuppose an absolute path with a trailing slash.
9333169be4bSmrg    _G_pathcar='s|^/\([^/]*\).*$|\1|'
9343169be4bSmrg    _G_pathcdr='s|^/[^/]*||'
9353169be4bSmrg    _G_removedotparts=':dotsl
9363169be4bSmrg		s|/\./|/|g
9373169be4bSmrg		t dotsl
9383169be4bSmrg		s|/\.$|/|'
9393169be4bSmrg    _G_collapseslashes='s|/\{1,\}|/|g'
9403169be4bSmrg    _G_finalslash='s|/*$|/|'
9413169be4bSmrg
9423169be4bSmrg    # Start from root dir and reassemble the path.
9433169be4bSmrg    func_normal_abspath_result=
9443169be4bSmrg    func_normal_abspath_tpath=$1
9453169be4bSmrg    func_normal_abspath_altnamespace=
9463169be4bSmrg    case $func_normal_abspath_tpath in
9473169be4bSmrg      "")
9483169be4bSmrg        # Empty path, that just means $cwd.
9493169be4bSmrg        func_stripname '' '/' "`pwd`"
9503169be4bSmrg        func_normal_abspath_result=$func_stripname_result
9513169be4bSmrg        return
9523169be4bSmrg        ;;
9533169be4bSmrg      # The next three entries are used to spot a run of precisely
9543169be4bSmrg      # two leading slashes without using negated character classes;
9553169be4bSmrg      # we take advantage of case's first-match behaviour.
9563169be4bSmrg      ///*)
9573169be4bSmrg        # Unusual form of absolute path, do nothing.
9583169be4bSmrg        ;;
9593169be4bSmrg      //*)
9603169be4bSmrg        # Not necessarily an ordinary path; POSIX reserves leading '//'
9613169be4bSmrg        # and for example Cygwin uses it to access remote file shares
9623169be4bSmrg        # over CIFS/SMB, so we conserve a leading double slash if found.
9633169be4bSmrg        func_normal_abspath_altnamespace=/
9643169be4bSmrg        ;;
9653169be4bSmrg      /*)
9663169be4bSmrg        # Absolute path, do nothing.
9678c4a8e55Smrg        ;;
9688c4a8e55Smrg      *)
9693169be4bSmrg        # Relative path, prepend $cwd.
9703169be4bSmrg        func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
9713169be4bSmrg        ;;
972b042e37fSmrg    esac
9733169be4bSmrg
9743169be4bSmrg    # Cancel out all the simple stuff to save iterations.  We also want
9753169be4bSmrg    # the path to end with a slash for ease of parsing, so make sure
9763169be4bSmrg    # there is one (and only one) here.
9773169be4bSmrg    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
9783169be4bSmrg          -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"`
9793169be4bSmrg    while :; do
9803169be4bSmrg      # Processed it all yet?
9813169be4bSmrg      if test / = "$func_normal_abspath_tpath"; then
9823169be4bSmrg        # If we ascended to the root using ".." the result may be empty now.
9833169be4bSmrg        if test -z "$func_normal_abspath_result"; then
9843169be4bSmrg          func_normal_abspath_result=/
9853169be4bSmrg        fi
9863169be4bSmrg        break
9873169be4bSmrg      fi
9883169be4bSmrg      func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
9893169be4bSmrg          -e "$_G_pathcar"`
9903169be4bSmrg      func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
9913169be4bSmrg          -e "$_G_pathcdr"`
9923169be4bSmrg      # Figure out what to do with it
9933169be4bSmrg      case $func_normal_abspath_tcomponent in
9943169be4bSmrg        "")
9953169be4bSmrg          # Trailing empty path component, ignore it.
9963169be4bSmrg          ;;
9973169be4bSmrg        ..)
9983169be4bSmrg          # Parent dir; strip last assembled component from result.
9993169be4bSmrg          func_dirname "$func_normal_abspath_result"
10003169be4bSmrg          func_normal_abspath_result=$func_dirname_result
10013169be4bSmrg          ;;
10023169be4bSmrg        *)
10033169be4bSmrg          # Actual path component, append it.
10043169be4bSmrg          func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent"
10053169be4bSmrg          ;;
10063169be4bSmrg      esac
10073169be4bSmrg    done
10083169be4bSmrg    # Restore leading double-slash if one was found on entry.
10093169be4bSmrg    func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
10103169be4bSmrg}
10113169be4bSmrg
10123169be4bSmrg
10133169be4bSmrg# func_notquiet ARG...
10143169be4bSmrg# --------------------
10153169be4bSmrg# Echo program name prefixed message only when not in quiet mode.
10163169be4bSmrgfunc_notquiet ()
10173169be4bSmrg{
10183169be4bSmrg    $debug_cmd
10193169be4bSmrg
10203169be4bSmrg    $opt_quiet || func_echo ${1+"$@"}
10213169be4bSmrg
10223169be4bSmrg    # A bug in bash halts the script if the last line of a function
10233169be4bSmrg    # fails when set -e is in force, so we need another command to
10243169be4bSmrg    # work around that:
10253169be4bSmrg    :
10263169be4bSmrg}
10273169be4bSmrg
10283169be4bSmrg
10293169be4bSmrg# func_relative_path SRCDIR DSTDIR
10303169be4bSmrg# --------------------------------
10313169be4bSmrg# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR.
10323169be4bSmrgfunc_relative_path ()
10333169be4bSmrg{
10343169be4bSmrg    $debug_cmd
10353169be4bSmrg
10363169be4bSmrg    func_relative_path_result=
10373169be4bSmrg    func_normal_abspath "$1"
10383169be4bSmrg    func_relative_path_tlibdir=$func_normal_abspath_result
10393169be4bSmrg    func_normal_abspath "$2"
10403169be4bSmrg    func_relative_path_tbindir=$func_normal_abspath_result
10413169be4bSmrg
10423169be4bSmrg    # Ascend the tree starting from libdir
10433169be4bSmrg    while :; do
10443169be4bSmrg      # check if we have found a prefix of bindir
10453169be4bSmrg      case $func_relative_path_tbindir in
10463169be4bSmrg        $func_relative_path_tlibdir)
10473169be4bSmrg          # found an exact match
10483169be4bSmrg          func_relative_path_tcancelled=
10493169be4bSmrg          break
10503169be4bSmrg          ;;
10513169be4bSmrg        $func_relative_path_tlibdir*)
10523169be4bSmrg          # found a matching prefix
10533169be4bSmrg          func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
10543169be4bSmrg          func_relative_path_tcancelled=$func_stripname_result
10553169be4bSmrg          if test -z "$func_relative_path_result"; then
10563169be4bSmrg            func_relative_path_result=.
10573169be4bSmrg          fi
10583169be4bSmrg          break
10593169be4bSmrg          ;;
10603169be4bSmrg        *)
10613169be4bSmrg          func_dirname $func_relative_path_tlibdir
10623169be4bSmrg          func_relative_path_tlibdir=$func_dirname_result
10633169be4bSmrg          if test -z "$func_relative_path_tlibdir"; then
10643169be4bSmrg            # Have to descend all the way to the root!
10653169be4bSmrg            func_relative_path_result=../$func_relative_path_result
10663169be4bSmrg            func_relative_path_tcancelled=$func_relative_path_tbindir
10673169be4bSmrg            break
10683169be4bSmrg          fi
10693169be4bSmrg          func_relative_path_result=../$func_relative_path_result
10703169be4bSmrg          ;;
10713169be4bSmrg      esac
10723169be4bSmrg    done
10733169be4bSmrg
10743169be4bSmrg    # Now calculate path; take care to avoid doubling-up slashes.
10753169be4bSmrg    func_stripname '' '/' "$func_relative_path_result"
10763169be4bSmrg    func_relative_path_result=$func_stripname_result
10773169be4bSmrg    func_stripname '/' '/' "$func_relative_path_tcancelled"
10783169be4bSmrg    if test -n "$func_stripname_result"; then
10793169be4bSmrg      func_append func_relative_path_result "/$func_stripname_result"
10803169be4bSmrg    fi
10813169be4bSmrg
10823169be4bSmrg    # Normalisation. If bindir is libdir, return '.' else relative path.
10833169be4bSmrg    if test -n "$func_relative_path_result"; then
10843169be4bSmrg      func_stripname './' '' "$func_relative_path_result"
10853169be4bSmrg      func_relative_path_result=$func_stripname_result
10863169be4bSmrg    fi
10873169be4bSmrg
10883169be4bSmrg    test -n "$func_relative_path_result" || func_relative_path_result=.
10893169be4bSmrg
10903169be4bSmrg    :
1091b042e37fSmrg}
1092b042e37fSmrg
1093b042e37fSmrg
10943169be4bSmrg# func_quote_for_eval ARG...
10953169be4bSmrg# --------------------------
10963169be4bSmrg# Aesthetically quote ARGs to be evaled later.
10973169be4bSmrg# This function returns two values:
10983169be4bSmrg#   i) func_quote_for_eval_result
10993169be4bSmrg#      double-quoted, suitable for a subsequent eval
11003169be4bSmrg#  ii) func_quote_for_eval_unquoted_result
11013169be4bSmrg#      has all characters that are still active within double
11023169be4bSmrg#      quotes backslashified.
11033169be4bSmrgfunc_quote_for_eval ()
11043169be4bSmrg{
11053169be4bSmrg    $debug_cmd
11063169be4bSmrg
11073169be4bSmrg    func_quote_for_eval_unquoted_result=
11083169be4bSmrg    func_quote_for_eval_result=
11093169be4bSmrg    while test 0 -lt $#; do
11103169be4bSmrg      case $1 in
11113169be4bSmrg        *[\\\`\"\$]*)
11123169be4bSmrg	  _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;;
11133169be4bSmrg        *)
11143169be4bSmrg          _G_unquoted_arg=$1 ;;
11153169be4bSmrg      esac
11163169be4bSmrg      if test -n "$func_quote_for_eval_unquoted_result"; then
11173169be4bSmrg	func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg"
11183169be4bSmrg      else
11193169be4bSmrg        func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg"
11203169be4bSmrg      fi
11213169be4bSmrg
11223169be4bSmrg      case $_G_unquoted_arg in
11233169be4bSmrg        # Double-quote args containing shell metacharacters to delay
11243169be4bSmrg        # word splitting, command substitution and variable expansion
11253169be4bSmrg        # for a subsequent eval.
11263169be4bSmrg        # Many Bourne shells cannot handle close brackets correctly
11273169be4bSmrg        # in scan sets, so we specify it separately.
11283169be4bSmrg        *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
11293169be4bSmrg          _G_quoted_arg=\"$_G_unquoted_arg\"
11303169be4bSmrg          ;;
11313169be4bSmrg        *)
11323169be4bSmrg          _G_quoted_arg=$_G_unquoted_arg
11333169be4bSmrg	  ;;
11343169be4bSmrg      esac
11353169be4bSmrg
11363169be4bSmrg      if test -n "$func_quote_for_eval_result"; then
11373169be4bSmrg	func_append func_quote_for_eval_result " $_G_quoted_arg"
11383169be4bSmrg      else
11393169be4bSmrg        func_append func_quote_for_eval_result "$_G_quoted_arg"
11403169be4bSmrg      fi
11413169be4bSmrg      shift
11423169be4bSmrg    done
11433169be4bSmrg}
11443169be4bSmrg
11453169be4bSmrg
11463169be4bSmrg# func_quote_for_expand ARG
11473169be4bSmrg# -------------------------
11488c4a8e55Smrg# Aesthetically quote ARG to be evaled later; same as above,
11498c4a8e55Smrg# but do not quote variable references.
11508c4a8e55Smrgfunc_quote_for_expand ()
1151b042e37fSmrg{
11523169be4bSmrg    $debug_cmd
11533169be4bSmrg
11548c4a8e55Smrg    case $1 in
11558c4a8e55Smrg      *[\\\`\"]*)
11563169be4bSmrg	_G_arg=`$ECHO "$1" | $SED \
11573169be4bSmrg	    -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;;
1158b042e37fSmrg      *)
11593169be4bSmrg        _G_arg=$1 ;;
11608c4a8e55Smrg    esac
1161b042e37fSmrg
11623169be4bSmrg    case $_G_arg in
11638c4a8e55Smrg      # Double-quote args containing shell metacharacters to delay
11648c4a8e55Smrg      # word splitting and command substitution for a subsequent eval.
11658c4a8e55Smrg      # Many Bourne shells cannot handle close brackets correctly
11668c4a8e55Smrg      # in scan sets, so we specify it separately.
11678c4a8e55Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
11683169be4bSmrg        _G_arg=\"$_G_arg\"
11698c4a8e55Smrg        ;;
11708c4a8e55Smrg    esac
11718c4a8e55Smrg
11723169be4bSmrg    func_quote_for_expand_result=$_G_arg
11733169be4bSmrg}
11743169be4bSmrg
11753169be4bSmrg
11763169be4bSmrg# func_stripname PREFIX SUFFIX NAME
11773169be4bSmrg# ---------------------------------
11783169be4bSmrg# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result.
11793169be4bSmrg# PREFIX and SUFFIX must not contain globbing or regex special
11803169be4bSmrg# characters, hashes, percent signs, but SUFFIX may contain a leading
11813169be4bSmrg# dot (in which case that matches only a dot).
11823169be4bSmrgif test yes = "$_G_HAVE_XSI_OPS"; then
11833169be4bSmrg  eval 'func_stripname ()
11843169be4bSmrg  {
11853169be4bSmrg    $debug_cmd
11863169be4bSmrg
11873169be4bSmrg    # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
11883169be4bSmrg    # positional parameters, so assign one to ordinary variable first.
11893169be4bSmrg    func_stripname_result=$3
11903169be4bSmrg    func_stripname_result=${func_stripname_result#"$1"}
11913169be4bSmrg    func_stripname_result=${func_stripname_result%"$2"}
11923169be4bSmrg  }'
11933169be4bSmrgelse
11943169be4bSmrg  func_stripname ()
11953169be4bSmrg  {
11963169be4bSmrg    $debug_cmd
11973169be4bSmrg
11983169be4bSmrg    case $2 in
11993169be4bSmrg      .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;;
12003169be4bSmrg      *)  func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;;
12013169be4bSmrg    esac
12023169be4bSmrg  }
12033169be4bSmrgfi
12043169be4bSmrg
12053169be4bSmrg
12063169be4bSmrg# func_show_eval CMD [FAIL_EXP]
12073169be4bSmrg# -----------------------------
12083169be4bSmrg# Unless opt_quiet is true, then output CMD.  Then, if opt_dryrun is
12093169be4bSmrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
12103169be4bSmrg# is given, then evaluate it.
12113169be4bSmrgfunc_show_eval ()
12123169be4bSmrg{
12133169be4bSmrg    $debug_cmd
12143169be4bSmrg
12153169be4bSmrg    _G_cmd=$1
12163169be4bSmrg    _G_fail_exp=${2-':'}
12173169be4bSmrg
12183169be4bSmrg    func_quote_for_expand "$_G_cmd"
12193169be4bSmrg    eval "func_notquiet $func_quote_for_expand_result"
12203169be4bSmrg
12213169be4bSmrg    $opt_dry_run || {
12223169be4bSmrg      eval "$_G_cmd"
12233169be4bSmrg      _G_status=$?
12243169be4bSmrg      if test 0 -ne "$_G_status"; then
12253169be4bSmrg	eval "(exit $_G_status); $_G_fail_exp"
12263169be4bSmrg      fi
12273169be4bSmrg    }
12283169be4bSmrg}
12293169be4bSmrg
12303169be4bSmrg
12313169be4bSmrg# func_show_eval_locale CMD [FAIL_EXP]
12323169be4bSmrg# ------------------------------------
12333169be4bSmrg# Unless opt_quiet is true, then output CMD.  Then, if opt_dryrun is
12343169be4bSmrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
12353169be4bSmrg# is given, then evaluate it.  Use the saved locale for evaluation.
12363169be4bSmrgfunc_show_eval_locale ()
12373169be4bSmrg{
12383169be4bSmrg    $debug_cmd
12393169be4bSmrg
12403169be4bSmrg    _G_cmd=$1
12413169be4bSmrg    _G_fail_exp=${2-':'}
12423169be4bSmrg
12433169be4bSmrg    $opt_quiet || {
12443169be4bSmrg      func_quote_for_expand "$_G_cmd"
12453169be4bSmrg      eval "func_echo $func_quote_for_expand_result"
12463169be4bSmrg    }
12473169be4bSmrg
12483169be4bSmrg    $opt_dry_run || {
12493169be4bSmrg      eval "$_G_user_locale
12503169be4bSmrg	    $_G_cmd"
12513169be4bSmrg      _G_status=$?
12523169be4bSmrg      eval "$_G_safe_locale"
12533169be4bSmrg      if test 0 -ne "$_G_status"; then
12543169be4bSmrg	eval "(exit $_G_status); $_G_fail_exp"
12553169be4bSmrg      fi
12563169be4bSmrg    }
12573169be4bSmrg}
12583169be4bSmrg
12593169be4bSmrg
12603169be4bSmrg# func_tr_sh
12613169be4bSmrg# ----------
12623169be4bSmrg# Turn $1 into a string suitable for a shell variable name.
12633169be4bSmrg# Result is stored in $func_tr_sh_result.  All characters
12643169be4bSmrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
12653169be4bSmrg# if $1 begins with a digit, a '_' is prepended as well.
12663169be4bSmrgfunc_tr_sh ()
12673169be4bSmrg{
12683169be4bSmrg    $debug_cmd
12693169be4bSmrg
12703169be4bSmrg    case $1 in
12713169be4bSmrg    [0-9]* | *[!a-zA-Z0-9_]*)
12723169be4bSmrg      func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'`
12733169be4bSmrg      ;;
12743169be4bSmrg    * )
12753169be4bSmrg      func_tr_sh_result=$1
12763169be4bSmrg      ;;
12773169be4bSmrg    esac
12783169be4bSmrg}
12793169be4bSmrg
12803169be4bSmrg
12813169be4bSmrg# func_verbose ARG...
12823169be4bSmrg# -------------------
12833169be4bSmrg# Echo program name prefixed message in verbose mode only.
12843169be4bSmrgfunc_verbose ()
12853169be4bSmrg{
12863169be4bSmrg    $debug_cmd
12873169be4bSmrg
12883169be4bSmrg    $opt_verbose && func_echo "$*"
12893169be4bSmrg
12903169be4bSmrg    :
12913169be4bSmrg}
12923169be4bSmrg
12933169be4bSmrg
12943169be4bSmrg# func_warn_and_continue ARG...
12953169be4bSmrg# -----------------------------
12963169be4bSmrg# Echo program name prefixed warning message to standard error.
12973169be4bSmrgfunc_warn_and_continue ()
12983169be4bSmrg{
12993169be4bSmrg    $debug_cmd
13003169be4bSmrg
13013169be4bSmrg    $require_term_colors
13023169be4bSmrg
13033169be4bSmrg    func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2
13043169be4bSmrg}
13053169be4bSmrg
13063169be4bSmrg
13073169be4bSmrg# func_warning CATEGORY ARG...
13083169be4bSmrg# ----------------------------
13093169be4bSmrg# Echo program name prefixed warning message to standard error. Warning
13103169be4bSmrg# messages can be filtered according to CATEGORY, where this function
13113169be4bSmrg# elides messages where CATEGORY is not listed in the global variable
13123169be4bSmrg# 'opt_warning_types'.
13133169be4bSmrgfunc_warning ()
13143169be4bSmrg{
13153169be4bSmrg    $debug_cmd
13163169be4bSmrg
13173169be4bSmrg    # CATEGORY must be in the warning_categories list!
13183169be4bSmrg    case " $warning_categories " in
13193169be4bSmrg      *" $1 "*) ;;
13203169be4bSmrg      *) func_internal_error "invalid warning category '$1'" ;;
13213169be4bSmrg    esac
13223169be4bSmrg
13233169be4bSmrg    _G_category=$1
13243169be4bSmrg    shift
13253169be4bSmrg
13263169be4bSmrg    case " $opt_warning_types " in
13273169be4bSmrg      *" $_G_category "*) $warning_func ${1+"$@"} ;;
13283169be4bSmrg    esac
1329b042e37fSmrg}
1330b042e37fSmrg
1331b042e37fSmrg
13323169be4bSmrg# func_sort_ver VER1 VER2
13333169be4bSmrg# -----------------------
13343169be4bSmrg# 'sort -V' is not generally available.
13353169be4bSmrg# Note this deviates from the version comparison in automake
13363169be4bSmrg# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a
13373169be4bSmrg# but this should suffice as we won't be specifying old
13383169be4bSmrg# version formats or redundant trailing .0 in bootstrap.conf.
13393169be4bSmrg# If we did want full compatibility then we should probably
13403169be4bSmrg# use m4_version_compare from autoconf.
13413169be4bSmrgfunc_sort_ver ()
13423169be4bSmrg{
13433169be4bSmrg    $debug_cmd
13443169be4bSmrg
13453169be4bSmrg    printf '%s\n%s\n' "$1" "$2" \
13463169be4bSmrg      | 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
13473169be4bSmrg}
13483169be4bSmrg
13493169be4bSmrg# func_lt_ver PREV CURR
13503169be4bSmrg# ---------------------
13513169be4bSmrg# Return true if PREV and CURR are in the correct order according to
13523169be4bSmrg# func_sort_ver, otherwise false.  Use it like this:
13533169be4bSmrg#
13543169be4bSmrg#  func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..."
13553169be4bSmrgfunc_lt_ver ()
13563169be4bSmrg{
13573169be4bSmrg    $debug_cmd
13583169be4bSmrg
13593169be4bSmrg    test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q`
13603169be4bSmrg}
13613169be4bSmrg
13623169be4bSmrg
13633169be4bSmrg# Local variables:
13643169be4bSmrg# mode: shell-script
13653169be4bSmrg# sh-indentation: 2
13663169be4bSmrg# eval: (add-hook 'before-save-hook 'time-stamp)
13673169be4bSmrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
13683169be4bSmrg# time-stamp-time-zone: "UTC"
13693169be4bSmrg# End:
13703169be4bSmrg#! /bin/sh
13713169be4bSmrg
13723169be4bSmrg# Set a version string for this script.
13733169be4bSmrgscriptversion=2014-01-07.03; # UTC
13743169be4bSmrg
13753169be4bSmrg# A portable, pluggable option parser for Bourne shell.
13763169be4bSmrg# Written by Gary V. Vaughan, 2010
13773169be4bSmrg
13783169be4bSmrg# Copyright (C) 2010-2015 Free Software Foundation, Inc.
13793169be4bSmrg# This is free software; see the source for copying conditions.  There is NO
13803169be4bSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13813169be4bSmrg
13823169be4bSmrg# This program is free software: you can redistribute it and/or modify
13833169be4bSmrg# it under the terms of the GNU General Public License as published by
13843169be4bSmrg# the Free Software Foundation, either version 3 of the License, or
13853169be4bSmrg# (at your option) any later version.
13863169be4bSmrg
13873169be4bSmrg# This program is distributed in the hope that it will be useful,
13883169be4bSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
13893169be4bSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13903169be4bSmrg# GNU General Public License for more details.
13913169be4bSmrg
13923169be4bSmrg# You should have received a copy of the GNU General Public License
13933169be4bSmrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
13943169be4bSmrg
13953169be4bSmrg# Please report bugs or propose patches to gary@gnu.org.
13963169be4bSmrg
13973169be4bSmrg
13983169be4bSmrg## ------ ##
13993169be4bSmrg## Usage. ##
14003169be4bSmrg## ------ ##
14013169be4bSmrg
14023169be4bSmrg# This file is a library for parsing options in your shell scripts along
14033169be4bSmrg# with assorted other useful supporting features that you can make use
14043169be4bSmrg# of too.
14053169be4bSmrg#
14063169be4bSmrg# For the simplest scripts you might need only:
14073169be4bSmrg#
14083169be4bSmrg#   #!/bin/sh
14093169be4bSmrg#   . relative/path/to/funclib.sh
14103169be4bSmrg#   . relative/path/to/options-parser
14113169be4bSmrg#   scriptversion=1.0
14123169be4bSmrg#   func_options ${1+"$@"}
14133169be4bSmrg#   eval set dummy "$func_options_result"; shift
14143169be4bSmrg#   ...rest of your script...
14153169be4bSmrg#
14163169be4bSmrg# In order for the '--version' option to work, you will need to have a
14173169be4bSmrg# suitably formatted comment like the one at the top of this file
14183169be4bSmrg# starting with '# Written by ' and ending with '# warranty; '.
14193169be4bSmrg#
14203169be4bSmrg# For '-h' and '--help' to work, you will also need a one line
14213169be4bSmrg# description of your script's purpose in a comment directly above the
14223169be4bSmrg# '# Written by ' line, like the one at the top of this file.
14233169be4bSmrg#
14243169be4bSmrg# The default options also support '--debug', which will turn on shell
14253169be4bSmrg# execution tracing (see the comment above debug_cmd below for another
14263169be4bSmrg# use), and '--verbose' and the func_verbose function to allow your script
14273169be4bSmrg# to display verbose messages only when your user has specified
14283169be4bSmrg# '--verbose'.
14293169be4bSmrg#
14303169be4bSmrg# After sourcing this file, you can plug processing for additional
14313169be4bSmrg# options by amending the variables from the 'Configuration' section
14323169be4bSmrg# below, and following the instructions in the 'Option parsing'
14333169be4bSmrg# section further down.
14343169be4bSmrg
14353169be4bSmrg## -------------- ##
14363169be4bSmrg## Configuration. ##
14373169be4bSmrg## -------------- ##
14383169be4bSmrg
14393169be4bSmrg# You should override these variables in your script after sourcing this
14403169be4bSmrg# file so that they reflect the customisations you have added to the
14413169be4bSmrg# option parser.
14423169be4bSmrg
14433169be4bSmrg# The usage line for option parsing errors and the start of '-h' and
14443169be4bSmrg# '--help' output messages. You can embed shell variables for delayed
14453169be4bSmrg# expansion at the time the message is displayed, but you will need to
14463169be4bSmrg# quote other shell meta-characters carefully to prevent them being
14473169be4bSmrg# expanded when the contents are evaled.
14483169be4bSmrgusage='$progpath [OPTION]...'
14493169be4bSmrg
14503169be4bSmrg# Short help message in response to '-h' and '--help'.  Add to this or
14513169be4bSmrg# override it after sourcing this library to reflect the full set of
14523169be4bSmrg# options your script accepts.
14533169be4bSmrgusage_message="\
14543169be4bSmrg       --debug        enable verbose shell tracing
14553169be4bSmrg   -W, --warnings=CATEGORY
14563169be4bSmrg                      report the warnings falling in CATEGORY [all]
14573169be4bSmrg   -v, --verbose      verbosely report processing
14583169be4bSmrg       --version      print version information and exit
14593169be4bSmrg   -h, --help         print short or long help message and exit
14603169be4bSmrg"
14613169be4bSmrg
14623169be4bSmrg# Additional text appended to 'usage_message' in response to '--help'.
14633169be4bSmrglong_help_message="
14643169be4bSmrgWarning categories include:
14653169be4bSmrg       'all'          show all warnings
14663169be4bSmrg       'none'         turn off all the warnings
14673169be4bSmrg       'error'        warnings are treated as fatal errors"
14683169be4bSmrg
14693169be4bSmrg# Help message printed before fatal option parsing errors.
14703169be4bSmrgfatal_help="Try '\$progname --help' for more information."
14713169be4bSmrg
14723169be4bSmrg
14733169be4bSmrg
14743169be4bSmrg## ------------------------- ##
14753169be4bSmrg## Hook function management. ##
14763169be4bSmrg## ------------------------- ##
14773169be4bSmrg
14783169be4bSmrg# This section contains functions for adding, removing, and running hooks
14793169be4bSmrg# to the main code.  A hook is just a named list of of function, that can
14803169be4bSmrg# be run in order later on.
14813169be4bSmrg
14823169be4bSmrg# func_hookable FUNC_NAME
14833169be4bSmrg# -----------------------
14843169be4bSmrg# Declare that FUNC_NAME will run hooks added with
14853169be4bSmrg# 'func_add_hook FUNC_NAME ...'.
14863169be4bSmrgfunc_hookable ()
14873169be4bSmrg{
14883169be4bSmrg    $debug_cmd
14893169be4bSmrg
14903169be4bSmrg    func_append hookable_fns " $1"
14913169be4bSmrg}
14923169be4bSmrg
14933169be4bSmrg
14943169be4bSmrg# func_add_hook FUNC_NAME HOOK_FUNC
14953169be4bSmrg# ---------------------------------
14963169be4bSmrg# Request that FUNC_NAME call HOOK_FUNC before it returns.  FUNC_NAME must
14973169be4bSmrg# first have been declared "hookable" by a call to 'func_hookable'.
14983169be4bSmrgfunc_add_hook ()
14993169be4bSmrg{
15003169be4bSmrg    $debug_cmd
15013169be4bSmrg
15023169be4bSmrg    case " $hookable_fns " in
15033169be4bSmrg      *" $1 "*) ;;
15043169be4bSmrg      *) func_fatal_error "'$1' does not accept hook functions." ;;
15053169be4bSmrg    esac
15063169be4bSmrg
15073169be4bSmrg    eval func_append ${1}_hooks '" $2"'
15083169be4bSmrg}
15093169be4bSmrg
15103169be4bSmrg
15113169be4bSmrg# func_remove_hook FUNC_NAME HOOK_FUNC
15123169be4bSmrg# ------------------------------------
15133169be4bSmrg# Remove HOOK_FUNC from the list of functions called by FUNC_NAME.
15143169be4bSmrgfunc_remove_hook ()
15153169be4bSmrg{
15163169be4bSmrg    $debug_cmd
15173169be4bSmrg
15183169be4bSmrg    eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`'
15193169be4bSmrg}
15203169be4bSmrg
15213169be4bSmrg
15223169be4bSmrg# func_run_hooks FUNC_NAME [ARG]...
15233169be4bSmrg# ---------------------------------
15243169be4bSmrg# Run all hook functions registered to FUNC_NAME.
15253169be4bSmrg# It is assumed that the list of hook functions contains nothing more
15263169be4bSmrg# than a whitespace-delimited list of legal shell function names, and
15273169be4bSmrg# no effort is wasted trying to catch shell meta-characters or preserve
15283169be4bSmrg# whitespace.
15293169be4bSmrgfunc_run_hooks ()
15303169be4bSmrg{
15313169be4bSmrg    $debug_cmd
15323169be4bSmrg
15333169be4bSmrg    case " $hookable_fns " in
15343169be4bSmrg      *" $1 "*) ;;
15353169be4bSmrg      *) func_fatal_error "'$1' does not support hook funcions.n" ;;
15363169be4bSmrg    esac
15373169be4bSmrg
15383169be4bSmrg    eval _G_hook_fns=\$$1_hooks; shift
15393169be4bSmrg
15403169be4bSmrg    for _G_hook in $_G_hook_fns; do
15413169be4bSmrg      eval $_G_hook '"$@"'
15423169be4bSmrg
15433169be4bSmrg      # store returned options list back into positional
15443169be4bSmrg      # parameters for next 'cmd' execution.
15453169be4bSmrg      eval _G_hook_result=\$${_G_hook}_result
15463169be4bSmrg      eval set dummy "$_G_hook_result"; shift
15473169be4bSmrg    done
15483169be4bSmrg
15493169be4bSmrg    func_quote_for_eval ${1+"$@"}
15503169be4bSmrg    func_run_hooks_result=$func_quote_for_eval_result
15513169be4bSmrg}
15523169be4bSmrg
15533169be4bSmrg
15543169be4bSmrg
15553169be4bSmrg## --------------- ##
15563169be4bSmrg## Option parsing. ##
15573169be4bSmrg## --------------- ##
15583169be4bSmrg
15593169be4bSmrg# In order to add your own option parsing hooks, you must accept the
15603169be4bSmrg# full positional parameter list in your hook function, remove any
15613169be4bSmrg# options that you action, and then pass back the remaining unprocessed
15623169be4bSmrg# options in '<hooked_function_name>_result', escaped suitably for
15633169be4bSmrg# 'eval'.  Like this:
15643169be4bSmrg#
15653169be4bSmrg#    my_options_prep ()
15663169be4bSmrg#    {
15673169be4bSmrg#        $debug_cmd
15683169be4bSmrg#
15693169be4bSmrg#        # Extend the existing usage message.
15703169be4bSmrg#        usage_message=$usage_message'
15713169be4bSmrg#      -s, --silent       don'\''t print informational messages
15723169be4bSmrg#    '
15733169be4bSmrg#
15743169be4bSmrg#        func_quote_for_eval ${1+"$@"}
15753169be4bSmrg#        my_options_prep_result=$func_quote_for_eval_result
15763169be4bSmrg#    }
15773169be4bSmrg#    func_add_hook func_options_prep my_options_prep
15783169be4bSmrg#
15793169be4bSmrg#
15803169be4bSmrg#    my_silent_option ()
15813169be4bSmrg#    {
15823169be4bSmrg#        $debug_cmd
15833169be4bSmrg#
15843169be4bSmrg#        # Note that for efficiency, we parse as many options as we can
15853169be4bSmrg#        # recognise in a loop before passing the remainder back to the
15863169be4bSmrg#        # caller on the first unrecognised argument we encounter.
15873169be4bSmrg#        while test $# -gt 0; do
15883169be4bSmrg#          opt=$1; shift
15893169be4bSmrg#          case $opt in
15903169be4bSmrg#            --silent|-s) opt_silent=: ;;
15913169be4bSmrg#            # Separate non-argument short options:
15923169be4bSmrg#            -s*)         func_split_short_opt "$_G_opt"
15933169be4bSmrg#                         set dummy "$func_split_short_opt_name" \
15943169be4bSmrg#                             "-$func_split_short_opt_arg" ${1+"$@"}
15953169be4bSmrg#                         shift
15963169be4bSmrg#                         ;;
15973169be4bSmrg#            *)            set dummy "$_G_opt" "$*"; shift; break ;;
15983169be4bSmrg#          esac
15993169be4bSmrg#        done
16003169be4bSmrg#
16013169be4bSmrg#        func_quote_for_eval ${1+"$@"}
16023169be4bSmrg#        my_silent_option_result=$func_quote_for_eval_result
16033169be4bSmrg#    }
16043169be4bSmrg#    func_add_hook func_parse_options my_silent_option
16053169be4bSmrg#
16063169be4bSmrg#
16073169be4bSmrg#    my_option_validation ()
16083169be4bSmrg#    {
16093169be4bSmrg#        $debug_cmd
16103169be4bSmrg#
16113169be4bSmrg#        $opt_silent && $opt_verbose && func_fatal_help "\
16123169be4bSmrg#    '--silent' and '--verbose' options are mutually exclusive."
16133169be4bSmrg#
16143169be4bSmrg#        func_quote_for_eval ${1+"$@"}
16153169be4bSmrg#        my_option_validation_result=$func_quote_for_eval_result
16163169be4bSmrg#    }
16173169be4bSmrg#    func_add_hook func_validate_options my_option_validation
16183169be4bSmrg#
16193169be4bSmrg# You'll alse need to manually amend $usage_message to reflect the extra
16203169be4bSmrg# options you parse.  It's preferable to append if you can, so that
16213169be4bSmrg# multiple option parsing hooks can be added safely.
16223169be4bSmrg
16233169be4bSmrg
16243169be4bSmrg# func_options [ARG]...
16253169be4bSmrg# ---------------------
16263169be4bSmrg# All the functions called inside func_options are hookable. See the
16273169be4bSmrg# individual implementations for details.
16283169be4bSmrgfunc_hookable func_options
16293169be4bSmrgfunc_options ()
1630b042e37fSmrg{
16313169be4bSmrg    $debug_cmd
1632b042e37fSmrg
16333169be4bSmrg    func_options_prep ${1+"$@"}
16343169be4bSmrg    eval func_parse_options \
16353169be4bSmrg        ${func_options_prep_result+"$func_options_prep_result"}
16363169be4bSmrg    eval func_validate_options \
16373169be4bSmrg        ${func_parse_options_result+"$func_parse_options_result"}
16388c4a8e55Smrg
16393169be4bSmrg    eval func_run_hooks func_options \
16403169be4bSmrg        ${func_validate_options_result+"$func_validate_options_result"}
16413169be4bSmrg
16423169be4bSmrg    # save modified positional parameters for caller
16433169be4bSmrg    func_options_result=$func_run_hooks_result
1644b042e37fSmrg}
1645b042e37fSmrg
16468c4a8e55Smrg
16473169be4bSmrg# func_options_prep [ARG]...
16483169be4bSmrg# --------------------------
16493169be4bSmrg# All initialisations required before starting the option parse loop.
16503169be4bSmrg# Note that when calling hook functions, we pass through the list of
16513169be4bSmrg# positional parameters.  If a hook function modifies that list, and
16523169be4bSmrg# needs to propogate that back to rest of this script, then the complete
16533169be4bSmrg# modified list must be put in 'func_run_hooks_result' before
16543169be4bSmrg# returning.
16553169be4bSmrgfunc_hookable func_options_prep
16563169be4bSmrgfunc_options_prep ()
1657b042e37fSmrg{
16583169be4bSmrg    $debug_cmd
1659b042e37fSmrg
16603169be4bSmrg    # Option defaults:
16613169be4bSmrg    opt_verbose=false
16623169be4bSmrg    opt_warning_types=
16638c4a8e55Smrg
16643169be4bSmrg    func_run_hooks func_options_prep ${1+"$@"}
16653169be4bSmrg
16663169be4bSmrg    # save modified positional parameters for caller
16673169be4bSmrg    func_options_prep_result=$func_run_hooks_result
1668b042e37fSmrg}
1669b042e37fSmrg
16703169be4bSmrg
16713169be4bSmrg# func_parse_options [ARG]...
16723169be4bSmrg# ---------------------------
16733169be4bSmrg# The main option parsing loop.
16743169be4bSmrgfunc_hookable func_parse_options
16753169be4bSmrgfunc_parse_options ()
1676bd23fbfaSmrg{
16773169be4bSmrg    $debug_cmd
16783169be4bSmrg
16793169be4bSmrg    func_parse_options_result=
16803169be4bSmrg
16813169be4bSmrg    # this just eases exit handling
16823169be4bSmrg    while test $# -gt 0; do
16833169be4bSmrg      # Defer to hook functions for initial option parsing, so they
16843169be4bSmrg      # get priority in the event of reusing an option name.
16853169be4bSmrg      func_run_hooks func_parse_options ${1+"$@"}
16863169be4bSmrg
16873169be4bSmrg      # Adjust func_parse_options positional parameters to match
16883169be4bSmrg      eval set dummy "$func_run_hooks_result"; shift
16893169be4bSmrg
16903169be4bSmrg      # Break out of the loop if we already parsed every option.
16913169be4bSmrg      test $# -gt 0 || break
16923169be4bSmrg
16933169be4bSmrg      _G_opt=$1
16943169be4bSmrg      shift
16953169be4bSmrg      case $_G_opt in
16963169be4bSmrg        --debug|-x)   debug_cmd='set -x'
16973169be4bSmrg                      func_echo "enabling shell trace mode"
16983169be4bSmrg                      $debug_cmd
16993169be4bSmrg                      ;;
17003169be4bSmrg
17013169be4bSmrg        --no-warnings|--no-warning|--no-warn)
17023169be4bSmrg                      set dummy --warnings none ${1+"$@"}
17033169be4bSmrg                      shift
17043169be4bSmrg		      ;;
17053169be4bSmrg
17063169be4bSmrg        --warnings|--warning|-W)
17073169be4bSmrg                      test $# = 0 && func_missing_arg $_G_opt && break
17083169be4bSmrg                      case " $warning_categories $1" in
17093169be4bSmrg                        *" $1 "*)
17103169be4bSmrg                          # trailing space prevents matching last $1 above
17113169be4bSmrg                          func_append_uniq opt_warning_types " $1"
17123169be4bSmrg                          ;;
17133169be4bSmrg                        *all)
17143169be4bSmrg                          opt_warning_types=$warning_categories
17153169be4bSmrg                          ;;
17163169be4bSmrg                        *none)
17173169be4bSmrg                          opt_warning_types=none
17183169be4bSmrg                          warning_func=:
17193169be4bSmrg                          ;;
17203169be4bSmrg                        *error)
17213169be4bSmrg                          opt_warning_types=$warning_categories
17223169be4bSmrg                          warning_func=func_fatal_error
17233169be4bSmrg                          ;;
17243169be4bSmrg                        *)
17253169be4bSmrg                          func_fatal_error \
17263169be4bSmrg                             "unsupported warning category: '$1'"
17273169be4bSmrg                          ;;
17283169be4bSmrg                      esac
17293169be4bSmrg                      shift
17303169be4bSmrg                      ;;
17313169be4bSmrg
17323169be4bSmrg        --verbose|-v) opt_verbose=: ;;
17333169be4bSmrg        --version)    func_version ;;
17343169be4bSmrg        -\?|-h)       func_usage ;;
17353169be4bSmrg        --help)       func_help ;;
17363169be4bSmrg
17373169be4bSmrg	# Separate optargs to long options (plugins may need this):
17383169be4bSmrg	--*=*)        func_split_equals "$_G_opt"
17393169be4bSmrg	              set dummy "$func_split_equals_lhs" \
17403169be4bSmrg                          "$func_split_equals_rhs" ${1+"$@"}
17413169be4bSmrg                      shift
17423169be4bSmrg                      ;;
17433169be4bSmrg
17443169be4bSmrg       # Separate optargs to short options:
17453169be4bSmrg        -W*)
17463169be4bSmrg                      func_split_short_opt "$_G_opt"
17473169be4bSmrg                      set dummy "$func_split_short_opt_name" \
17483169be4bSmrg                          "$func_split_short_opt_arg" ${1+"$@"}
17493169be4bSmrg                      shift
17503169be4bSmrg                      ;;
17513169be4bSmrg
17523169be4bSmrg        # Separate non-argument short options:
17533169be4bSmrg        -\?*|-h*|-v*|-x*)
17543169be4bSmrg                      func_split_short_opt "$_G_opt"
17553169be4bSmrg                      set dummy "$func_split_short_opt_name" \
17563169be4bSmrg                          "-$func_split_short_opt_arg" ${1+"$@"}
17573169be4bSmrg                      shift
17583169be4bSmrg                      ;;
17593169be4bSmrg
17603169be4bSmrg        --)           break ;;
17613169be4bSmrg        -*)           func_fatal_help "unrecognised option: '$_G_opt'" ;;
17623169be4bSmrg        *)            set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
17633169be4bSmrg      esac
17643169be4bSmrg    done
17653169be4bSmrg
17663169be4bSmrg    # save modified positional parameters for caller
17673169be4bSmrg    func_quote_for_eval ${1+"$@"}
17683169be4bSmrg    func_parse_options_result=$func_quote_for_eval_result
1769bd23fbfaSmrg}
1770bd23fbfaSmrg
1771b042e37fSmrg
17723169be4bSmrg# func_validate_options [ARG]...
17733169be4bSmrg# ------------------------------
17743169be4bSmrg# Perform any sanity checks on option settings and/or unconsumed
17753169be4bSmrg# arguments.
17763169be4bSmrgfunc_hookable func_validate_options
17773169be4bSmrgfunc_validate_options ()
17788c4a8e55Smrg{
17793169be4bSmrg    $debug_cmd
1780bd23fbfaSmrg
17813169be4bSmrg    # Display all warnings if -W was not given.
17823169be4bSmrg    test -n "$opt_warning_types" || opt_warning_types=" $warning_categories"
17833169be4bSmrg
17843169be4bSmrg    func_run_hooks func_validate_options ${1+"$@"}
17853169be4bSmrg
17863169be4bSmrg    # Bail if the options were screwed!
17873169be4bSmrg    $exit_cmd $EXIT_FAILURE
17883169be4bSmrg
17893169be4bSmrg    # save modified positional parameters for caller
17903169be4bSmrg    func_validate_options_result=$func_run_hooks_result
17918c4a8e55Smrg}
17928c4a8e55Smrg
17933169be4bSmrg
17943169be4bSmrg
17953169be4bSmrg## ----------------- ##
17963169be4bSmrg## Helper functions. ##
17973169be4bSmrg## ----------------- ##
17983169be4bSmrg
17993169be4bSmrg# This section contains the helper functions used by the rest of the
18003169be4bSmrg# hookable option parser framework in ascii-betical order.
18013169be4bSmrg
18023169be4bSmrg
18033169be4bSmrg# func_fatal_help ARG...
18043169be4bSmrg# ----------------------
18053169be4bSmrg# Echo program name prefixed message to standard error, followed by
18063169be4bSmrg# a help hint, and exit.
18073169be4bSmrgfunc_fatal_help ()
18088c4a8e55Smrg{
18093169be4bSmrg    $debug_cmd
1810bd23fbfaSmrg
18113169be4bSmrg    eval \$ECHO \""Usage: $usage"\"
18123169be4bSmrg    eval \$ECHO \""$fatal_help"\"
18133169be4bSmrg    func_error ${1+"$@"}
18143169be4bSmrg    exit $EXIT_FAILURE
18158c4a8e55Smrg}
18168c4a8e55Smrg
18173169be4bSmrg
18183169be4bSmrg# func_help
18193169be4bSmrg# ---------
18203169be4bSmrg# Echo long help message to standard output and exit.
18218c4a8e55Smrgfunc_help ()
18228c4a8e55Smrg{
18233169be4bSmrg    $debug_cmd
18243169be4bSmrg
18253169be4bSmrg    func_usage_message
18263169be4bSmrg    $ECHO "$long_help_message"
18273169be4bSmrg    exit 0
18288c4a8e55Smrg}
18298c4a8e55Smrg
18303169be4bSmrg
18313169be4bSmrg# func_missing_arg ARGNAME
18323169be4bSmrg# ------------------------
18338c4a8e55Smrg# Echo program name prefixed message to standard error and set global
18348c4a8e55Smrg# exit_cmd.
18358c4a8e55Smrgfunc_missing_arg ()
18368c4a8e55Smrg{
18373169be4bSmrg    $debug_cmd
1838bd23fbfaSmrg
18393169be4bSmrg    func_error "Missing argument for '$1'."
18408c4a8e55Smrg    exit_cmd=exit
18418c4a8e55Smrg}
18428c4a8e55Smrg
18438c4a8e55Smrg
18443169be4bSmrg# func_split_equals STRING
18453169be4bSmrg# ------------------------
18463169be4bSmrg# Set func_split_equals_lhs and func_split_equals_rhs shell variables after
18473169be4bSmrg# splitting STRING at the '=' sign.
18483169be4bSmrgtest -z "$_G_HAVE_XSI_OPS" \
18493169be4bSmrg    && (eval 'x=a/b/c;
18503169be4bSmrg      test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
18513169be4bSmrg    && _G_HAVE_XSI_OPS=yes
18523169be4bSmrg
18533169be4bSmrgif test yes = "$_G_HAVE_XSI_OPS"
18543169be4bSmrgthen
18553169be4bSmrg  # This is an XSI compatible shell, allowing a faster implementation...
18563169be4bSmrg  eval 'func_split_equals ()
18573169be4bSmrg  {
18583169be4bSmrg      $debug_cmd
18593169be4bSmrg
18603169be4bSmrg      func_split_equals_lhs=${1%%=*}
18613169be4bSmrg      func_split_equals_rhs=${1#*=}
18623169be4bSmrg      test "x$func_split_equals_lhs" = "x$1" \
18633169be4bSmrg        && func_split_equals_rhs=
18643169be4bSmrg  }'
18653169be4bSmrgelse
18663169be4bSmrg  # ...otherwise fall back to using expr, which is often a shell builtin.
18673169be4bSmrg  func_split_equals ()
18683169be4bSmrg  {
18693169be4bSmrg      $debug_cmd
18703169be4bSmrg
18713169be4bSmrg      func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'`
18723169be4bSmrg      func_split_equals_rhs=
18733169be4bSmrg      test "x$func_split_equals_lhs" = "x$1" \
18743169be4bSmrg        || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'`
18753169be4bSmrg  }
18763169be4bSmrgfi #func_split_equals
18773169be4bSmrg
18783169be4bSmrg
18793169be4bSmrg# func_split_short_opt SHORTOPT
18803169be4bSmrg# -----------------------------
1881bd23fbfaSmrg# Set func_split_short_opt_name and func_split_short_opt_arg shell
1882bd23fbfaSmrg# variables after splitting SHORTOPT after the 2nd character.
18833169be4bSmrgif test yes = "$_G_HAVE_XSI_OPS"
18843169be4bSmrgthen
18853169be4bSmrg  # This is an XSI compatible shell, allowing a faster implementation...
18863169be4bSmrg  eval 'func_split_short_opt ()
18873169be4bSmrg  {
18883169be4bSmrg      $debug_cmd
18893169be4bSmrg
18903169be4bSmrg      func_split_short_opt_arg=${1#??}
18913169be4bSmrg      func_split_short_opt_name=${1%"$func_split_short_opt_arg"}
18923169be4bSmrg  }'
18933169be4bSmrgelse
18943169be4bSmrg  # ...otherwise fall back to using expr, which is often a shell builtin.
18953169be4bSmrg  func_split_short_opt ()
18963169be4bSmrg  {
18973169be4bSmrg      $debug_cmd
18983169be4bSmrg
18993169be4bSmrg      func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'`
19003169be4bSmrg      func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'`
19013169be4bSmrg  }
19023169be4bSmrgfi #func_split_short_opt
19033169be4bSmrg
19043169be4bSmrg
19053169be4bSmrg# func_usage
19063169be4bSmrg# ----------
19073169be4bSmrg# Echo short help message to standard output and exit.
19083169be4bSmrgfunc_usage ()
1909bd23fbfaSmrg{
19103169be4bSmrg    $debug_cmd
1911bd23fbfaSmrg
19123169be4bSmrg    func_usage_message
19133169be4bSmrg    $ECHO "Run '$progname --help |${PAGER-more}' for full usage"
19143169be4bSmrg    exit 0
19153169be4bSmrg}
1916bd23fbfaSmrg
1917bd23fbfaSmrg
19183169be4bSmrg# func_usage_message
19193169be4bSmrg# ------------------
19203169be4bSmrg# Echo short help message to standard output.
19213169be4bSmrgfunc_usage_message ()
1922bd23fbfaSmrg{
19233169be4bSmrg    $debug_cmd
1924bd23fbfaSmrg
19253169be4bSmrg    eval \$ECHO \""Usage: $usage"\"
19263169be4bSmrg    echo
19273169be4bSmrg    $SED -n 's|^# ||
19283169be4bSmrg        /^Written by/{
19293169be4bSmrg          x;p;x
19303169be4bSmrg        }
19313169be4bSmrg	h
19323169be4bSmrg	/^Written by/q' < "$progpath"
19333169be4bSmrg    echo
19343169be4bSmrg    eval \$ECHO \""$usage_message"\"
19353169be4bSmrg}
1936bd23fbfaSmrg
19378c4a8e55Smrg
19383169be4bSmrg# func_version
19393169be4bSmrg# ------------
19403169be4bSmrg# Echo version message to standard output and exit.
19413169be4bSmrgfunc_version ()
19423169be4bSmrg{
19433169be4bSmrg    $debug_cmd
19448c4a8e55Smrg
19453169be4bSmrg    printf '%s\n' "$progname $scriptversion"
19463169be4bSmrg    $SED -n '
19473169be4bSmrg        /(C)/!b go
19483169be4bSmrg        :more
19493169be4bSmrg        /\./!{
19503169be4bSmrg          N
19513169be4bSmrg          s|\n# | |
19523169be4bSmrg          b more
19533169be4bSmrg        }
19543169be4bSmrg        :go
19553169be4bSmrg        /^# Written by /,/# warranty; / {
19563169be4bSmrg          s|^# ||
19573169be4bSmrg          s|^# *$||
19583169be4bSmrg          s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2|
19593169be4bSmrg          p
19603169be4bSmrg        }
19613169be4bSmrg        /^# Written by / {
19623169be4bSmrg          s|^# ||
19633169be4bSmrg          p
19643169be4bSmrg        }
19653169be4bSmrg        /^warranty; /q' < "$progpath"
19668c4a8e55Smrg
19673169be4bSmrg    exit $?
19683169be4bSmrg}
19698c4a8e55Smrg
1970b042e37fSmrg
19713169be4bSmrg# Local variables:
19723169be4bSmrg# mode: shell-script
19733169be4bSmrg# sh-indentation: 2
19743169be4bSmrg# eval: (add-hook 'before-save-hook 'time-stamp)
19753169be4bSmrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
19763169be4bSmrg# time-stamp-time-zone: "UTC"
19773169be4bSmrg# End:
1978b042e37fSmrg
19793169be4bSmrg# Set a version string.
19803169be4bSmrgscriptversion='(GNU libtool) 2.4.6'
1981b042e37fSmrg
19828c4a8e55Smrg
19833169be4bSmrg# func_echo ARG...
19843169be4bSmrg# ----------------
19853169be4bSmrg# Libtool also displays the current mode in messages, so override
19863169be4bSmrg# funclib.sh func_echo with this custom definition.
19873169be4bSmrgfunc_echo ()
1988bd23fbfaSmrg{
19893169be4bSmrg    $debug_cmd
1990bd23fbfaSmrg
19913169be4bSmrg    _G_message=$*
19923169be4bSmrg
19933169be4bSmrg    func_echo_IFS=$IFS
19943169be4bSmrg    IFS=$nl
19953169be4bSmrg    for _G_line in $_G_message; do
19963169be4bSmrg      IFS=$func_echo_IFS
19973169be4bSmrg      $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line"
19983169be4bSmrg    done
19993169be4bSmrg    IFS=$func_echo_IFS
20003169be4bSmrg}
2001bd23fbfaSmrg
2002bd23fbfaSmrg
20033169be4bSmrg# func_warning ARG...
20043169be4bSmrg# -------------------
20053169be4bSmrg# Libtool warnings are not categorized, so override funclib.sh
20063169be4bSmrg# func_warning with this simpler definition.
20073169be4bSmrgfunc_warning ()
2008bd23fbfaSmrg{
20093169be4bSmrg    $debug_cmd
20103169be4bSmrg
20113169be4bSmrg    $warning_func ${1+"$@"}
20123169be4bSmrg}
20133169be4bSmrg
2014bd23fbfaSmrg
20153169be4bSmrg## ---------------- ##
20163169be4bSmrg## Options parsing. ##
20173169be4bSmrg## ---------------- ##
20183169be4bSmrg
20193169be4bSmrg# Hook in the functions to make sure our own options are parsed during
20203169be4bSmrg# the option parsing loop.
20213169be4bSmrg
20223169be4bSmrgusage='$progpath [OPTION]... [MODE-ARG]...'
20233169be4bSmrg
20243169be4bSmrg# Short help message in response to '-h'.
20253169be4bSmrgusage_message="Options:
20263169be4bSmrg       --config             show all configuration variables
20273169be4bSmrg       --debug              enable verbose shell tracing
20283169be4bSmrg   -n, --dry-run            display commands without modifying any files
20293169be4bSmrg       --features           display basic configuration information and exit
20303169be4bSmrg       --mode=MODE          use operation mode MODE
20313169be4bSmrg       --no-warnings        equivalent to '-Wnone'
20323169be4bSmrg       --preserve-dup-deps  don't remove duplicate dependency libraries
20333169be4bSmrg       --quiet, --silent    don't print informational messages
20343169be4bSmrg       --tag=TAG            use configuration variables from tag TAG
20353169be4bSmrg   -v, --verbose            print more informational messages than default
20363169be4bSmrg       --version            print version information
20373169be4bSmrg   -W, --warnings=CATEGORY  report the warnings falling in CATEGORY [all]
20383169be4bSmrg   -h, --help, --help-all   print short, long, or detailed help message
20393169be4bSmrg"
2040bd23fbfaSmrg
20413169be4bSmrg# Additional text appended to 'usage_message' in response to '--help'.
20423169be4bSmrgfunc_help ()
2043bd23fbfaSmrg{
20443169be4bSmrg    $debug_cmd
20453169be4bSmrg
20463169be4bSmrg    func_usage_message
20473169be4bSmrg    $ECHO "$long_help_message
20483169be4bSmrg
20493169be4bSmrgMODE must be one of the following:
20503169be4bSmrg
20513169be4bSmrg       clean           remove files from the build directory
20523169be4bSmrg       compile         compile a source file into a libtool object
20533169be4bSmrg       execute         automatically set library path, then run a program
20543169be4bSmrg       finish          complete the installation of libtool libraries
20553169be4bSmrg       install         install libraries or executables
20563169be4bSmrg       link            create a library or an executable
20573169be4bSmrg       uninstall       remove libraries from an installed directory
20583169be4bSmrg
20593169be4bSmrgMODE-ARGS vary depending on the MODE.  When passed as first option,
20603169be4bSmrg'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that.
20613169be4bSmrgTry '$progname --help --mode=MODE' for a more detailed description of MODE.
20623169be4bSmrg
20633169be4bSmrgWhen reporting a bug, please describe a test case to reproduce it and
20643169be4bSmrginclude the following information:
20653169be4bSmrg
20663169be4bSmrg       host-triplet:   $host
20673169be4bSmrg       shell:          $SHELL
20683169be4bSmrg       compiler:       $LTCC
20693169be4bSmrg       compiler flags: $LTCFLAGS
20703169be4bSmrg       linker:         $LD (gnu? $with_gnu_ld)
20713169be4bSmrg       version:        $progname (GNU libtool) 2.4.6
20723169be4bSmrg       automake:       `($AUTOMAKE --version) 2>/dev/null |$SED 1q`
20733169be4bSmrg       autoconf:       `($AUTOCONF --version) 2>/dev/null |$SED 1q`
20743169be4bSmrg
20753169be4bSmrgReport bugs to <bug-libtool@gnu.org>.
20763169be4bSmrgGNU libtool home page: <http://www.gnu.org/s/libtool/>.
20773169be4bSmrgGeneral help using GNU software: <http://www.gnu.org/gethelp/>."
20783169be4bSmrg    exit 0
20793169be4bSmrg}
2080bd23fbfaSmrg
2081bd23fbfaSmrg
20823169be4bSmrg# func_lo2o OBJECT-NAME
20833169be4bSmrg# ---------------------
20843169be4bSmrg# Transform OBJECT-NAME from a '.lo' suffix to the platform specific
20853169be4bSmrg# object suffix.
2086bd23fbfaSmrg
20873169be4bSmrglo2o=s/\\.lo\$/.$objext/
20883169be4bSmrgo2lo=s/\\.$objext\$/.lo/
2089bd23fbfaSmrg
20903169be4bSmrgif test yes = "$_G_HAVE_XSI_OPS"; then
20913169be4bSmrg  eval 'func_lo2o ()
20923169be4bSmrg  {
20933169be4bSmrg    case $1 in
20943169be4bSmrg      *.lo) func_lo2o_result=${1%.lo}.$objext ;;
20953169be4bSmrg      *   ) func_lo2o_result=$1               ;;
20963169be4bSmrg    esac
20973169be4bSmrg  }'
20983169be4bSmrg
20993169be4bSmrg  # func_xform LIBOBJ-OR-SOURCE
21003169be4bSmrg  # ---------------------------
21013169be4bSmrg  # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise)
21023169be4bSmrg  # suffix to a '.lo' libtool-object suffix.
21033169be4bSmrg  eval 'func_xform ()
21043169be4bSmrg  {
21053169be4bSmrg    func_xform_result=${1%.*}.lo
21063169be4bSmrg  }'
21073169be4bSmrgelse
21083169be4bSmrg  # ...otherwise fall back to using sed.
21093169be4bSmrg  func_lo2o ()
21103169be4bSmrg  {
21113169be4bSmrg    func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"`
21123169be4bSmrg  }
21133169be4bSmrg
21143169be4bSmrg  func_xform ()
21153169be4bSmrg  {
21163169be4bSmrg    func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'`
21173169be4bSmrg  }
21183169be4bSmrgfi
2119bd23fbfaSmrg
2120bd23fbfaSmrg
21213169be4bSmrg# func_fatal_configuration ARG...
21223169be4bSmrg# -------------------------------
21238c4a8e55Smrg# Echo program name prefixed message to standard error, followed by
21248c4a8e55Smrg# a configuration failure hint, and exit.
21258c4a8e55Smrgfunc_fatal_configuration ()
21268c4a8e55Smrg{
21273169be4bSmrg    func__fatal_error ${1+"$@"} \
21283169be4bSmrg      "See the $PACKAGE documentation for more information." \
21293169be4bSmrg      "Fatal configuration error."
21308c4a8e55Smrg}
2131b042e37fSmrg
2132b042e37fSmrg
21338c4a8e55Smrg# func_config
21343169be4bSmrg# -----------
21358c4a8e55Smrg# Display the configuration for all the tags in this script.
21368c4a8e55Smrgfunc_config ()
21378c4a8e55Smrg{
21388c4a8e55Smrg    re_begincf='^# ### BEGIN LIBTOOL'
21398c4a8e55Smrg    re_endcf='^# ### END LIBTOOL'
21408c4a8e55Smrg
21418c4a8e55Smrg    # Default configuration.
21428c4a8e55Smrg    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
21438c4a8e55Smrg
2144b042e37fSmrg    # Now print the configurations for the tags.
2145b042e37fSmrg    for tagname in $taglist; do
21468c4a8e55Smrg      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
2147b042e37fSmrg    done
2148b042e37fSmrg
21498c4a8e55Smrg    exit $?
21508c4a8e55Smrg}
2151b042e37fSmrg
21523169be4bSmrg
21538c4a8e55Smrg# func_features
21543169be4bSmrg# -------------
21558c4a8e55Smrg# Display the features supported by this script.
21568c4a8e55Smrgfunc_features ()
21578c4a8e55Smrg{
2158706b6b52Smrg    echo "host: $host"
21593169be4bSmrg    if test yes = "$build_libtool_libs"; then
2160706b6b52Smrg      echo "enable shared libraries"
2161b042e37fSmrg    else
2162706b6b52Smrg      echo "disable shared libraries"
2163b042e37fSmrg    fi
21643169be4bSmrg    if test yes = "$build_old_libs"; then
2165706b6b52Smrg      echo "enable static libraries"
2166b042e37fSmrg    else
2167706b6b52Smrg      echo "disable static libraries"
2168b042e37fSmrg    fi
21698c4a8e55Smrg
2170b042e37fSmrg    exit $?
21718c4a8e55Smrg}
2172b042e37fSmrg
21733169be4bSmrg
21743169be4bSmrg# func_enable_tag TAGNAME
21753169be4bSmrg# -----------------------
21768c4a8e55Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or
21778c4a8e55Smrg# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
21788c4a8e55Smrg# variable here.
21798c4a8e55Smrgfunc_enable_tag ()
21808c4a8e55Smrg{
21813169be4bSmrg    # Global variable:
21823169be4bSmrg    tagname=$1
2183b042e37fSmrg
21843169be4bSmrg    re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
21853169be4bSmrg    re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
21863169be4bSmrg    sed_extractcf=/$re_begincf/,/$re_endcf/p
2187b042e37fSmrg
21883169be4bSmrg    # Validate tagname.
21893169be4bSmrg    case $tagname in
21903169be4bSmrg      *[!-_A-Za-z0-9,/]*)
21913169be4bSmrg        func_fatal_error "invalid tag name: $tagname"
21923169be4bSmrg        ;;
21933169be4bSmrg    esac
2194b042e37fSmrg
21953169be4bSmrg    # Don't test for the "default" C tag, as we know it's
21963169be4bSmrg    # there but not specially marked.
21973169be4bSmrg    case $tagname in
21983169be4bSmrg        CC) ;;
21998c4a8e55Smrg    *)
22003169be4bSmrg        if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
22013169be4bSmrg	  taglist="$taglist $tagname"
22023169be4bSmrg
22033169be4bSmrg	  # Evaluate the configuration.  Be careful to quote the path
22043169be4bSmrg	  # and the sed script, to avoid splitting on whitespace, but
22053169be4bSmrg	  # also don't use non-portable quotes within backquotes within
22063169be4bSmrg	  # quotes we have to do it in 2 steps:
22073169be4bSmrg	  extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
22083169be4bSmrg	  eval "$extractedcf"
22093169be4bSmrg        else
22103169be4bSmrg	  func_error "ignoring unknown tag $tagname"
22113169be4bSmrg        fi
22123169be4bSmrg        ;;
22133169be4bSmrg    esac
22148c4a8e55Smrg}
2215b042e37fSmrg
22163169be4bSmrg
2217bd23fbfaSmrg# func_check_version_match
22183169be4bSmrg# ------------------------
2219bd23fbfaSmrg# Ensure that we are using m4 macros, and libtool script from the same
2220bd23fbfaSmrg# release of libtool.
2221bd23fbfaSmrgfunc_check_version_match ()
22228c4a8e55Smrg{
22233169be4bSmrg    if test "$package_revision" != "$macro_revision"; then
22243169be4bSmrg      if test "$VERSION" != "$macro_version"; then
22253169be4bSmrg        if test -z "$macro_version"; then
22263169be4bSmrg          cat >&2 <<_LT_EOF
2227bd23fbfaSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
2228bd23fbfaSmrg$progname: definition of this LT_INIT comes from an older release.
2229bd23fbfaSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
2230bd23fbfaSmrg$progname: and run autoconf again.
2231bd23fbfaSmrg_LT_EOF
22323169be4bSmrg        else
22333169be4bSmrg          cat >&2 <<_LT_EOF
2234bd23fbfaSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
2235bd23fbfaSmrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
2236bd23fbfaSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
2237bd23fbfaSmrg$progname: and run autoconf again.
2238bd23fbfaSmrg_LT_EOF
22393169be4bSmrg        fi
22403169be4bSmrg      else
22413169be4bSmrg        cat >&2 <<_LT_EOF
2242bd23fbfaSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
2243bd23fbfaSmrg$progname: but the definition of this LT_INIT comes from revision $macro_revision.
2244bd23fbfaSmrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision
2245bd23fbfaSmrg$progname: of $PACKAGE $VERSION and run autoconf again.
2246bd23fbfaSmrg_LT_EOF
22473169be4bSmrg      fi
22488c4a8e55Smrg
22493169be4bSmrg      exit $EXIT_MISMATCH
22503169be4bSmrg    fi
2251bd23fbfaSmrg}
2252bd23fbfaSmrg
2253bd23fbfaSmrg
22543169be4bSmrg# libtool_options_prep [ARG]...
22553169be4bSmrg# -----------------------------
22563169be4bSmrg# Preparation for options parsed by libtool.
22573169be4bSmrglibtool_options_prep ()
22583169be4bSmrg{
22593169be4bSmrg    $debug_mode
2260b042e37fSmrg
22613169be4bSmrg    # Option defaults:
22623169be4bSmrg    opt_config=false
22633169be4bSmrg    opt_dlopen=
22643169be4bSmrg    opt_dry_run=false
22653169be4bSmrg    opt_help=false
22663169be4bSmrg    opt_mode=
22673169be4bSmrg    opt_preserve_dup_deps=false
22683169be4bSmrg    opt_quiet=false
2269bd23fbfaSmrg
22703169be4bSmrg    nonopt=
22713169be4bSmrg    preserve_args=
2272bd23fbfaSmrg
22733169be4bSmrg    # Shorthand for --mode=foo, only valid as the first argument
22743169be4bSmrg    case $1 in
22753169be4bSmrg    clean|clea|cle|cl)
22763169be4bSmrg      shift; set dummy --mode clean ${1+"$@"}; shift
22773169be4bSmrg      ;;
22783169be4bSmrg    compile|compil|compi|comp|com|co|c)
22793169be4bSmrg      shift; set dummy --mode compile ${1+"$@"}; shift
22803169be4bSmrg      ;;
22813169be4bSmrg    execute|execut|execu|exec|exe|ex|e)
22823169be4bSmrg      shift; set dummy --mode execute ${1+"$@"}; shift
22833169be4bSmrg      ;;
22843169be4bSmrg    finish|finis|fini|fin|fi|f)
22853169be4bSmrg      shift; set dummy --mode finish ${1+"$@"}; shift
22863169be4bSmrg      ;;
22873169be4bSmrg    install|instal|insta|inst|ins|in|i)
22883169be4bSmrg      shift; set dummy --mode install ${1+"$@"}; shift
22893169be4bSmrg      ;;
22903169be4bSmrg    link|lin|li|l)
22913169be4bSmrg      shift; set dummy --mode link ${1+"$@"}; shift
22923169be4bSmrg      ;;
22933169be4bSmrg    uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
22943169be4bSmrg      shift; set dummy --mode uninstall ${1+"$@"}; shift
22953169be4bSmrg      ;;
22963169be4bSmrg    esac
22973169be4bSmrg
22983169be4bSmrg    # Pass back the list of options.
22993169be4bSmrg    func_quote_for_eval ${1+"$@"}
23003169be4bSmrg    libtool_options_prep_result=$func_quote_for_eval_result
23013169be4bSmrg}
23023169be4bSmrgfunc_add_hook func_options_prep libtool_options_prep
2303bd23fbfaSmrg
2304bd23fbfaSmrg
23053169be4bSmrg# libtool_parse_options [ARG]...
23063169be4bSmrg# ---------------------------------
23073169be4bSmrg# Provide handling for libtool specific options.
23083169be4bSmrglibtool_parse_options ()
2309bd23fbfaSmrg{
23103169be4bSmrg    $debug_cmd
23118c4a8e55Smrg
23123169be4bSmrg    # Perform our own loop to consume as many options as possible in
23133169be4bSmrg    # each iteration.
23143169be4bSmrg    while test $# -gt 0; do
23153169be4bSmrg      _G_opt=$1
23163169be4bSmrg      shift
23173169be4bSmrg      case $_G_opt in
23183169be4bSmrg        --dry-run|--dryrun|-n)
23193169be4bSmrg                        opt_dry_run=:
23203169be4bSmrg                        ;;
23213169be4bSmrg
23223169be4bSmrg        --config)       func_config ;;
23233169be4bSmrg
23243169be4bSmrg        --dlopen|-dlopen)
23253169be4bSmrg                        opt_dlopen="${opt_dlopen+$opt_dlopen
23263169be4bSmrg}$1"
23273169be4bSmrg                        shift
23283169be4bSmrg                        ;;
23293169be4bSmrg
23303169be4bSmrg        --preserve-dup-deps)
23313169be4bSmrg                        opt_preserve_dup_deps=: ;;
23323169be4bSmrg
23333169be4bSmrg        --features)     func_features ;;
23343169be4bSmrg
23353169be4bSmrg        --finish)       set dummy --mode finish ${1+"$@"}; shift ;;
23363169be4bSmrg
23373169be4bSmrg        --help)         opt_help=: ;;
23383169be4bSmrg
23393169be4bSmrg        --help-all)     opt_help=': help-all' ;;
23403169be4bSmrg
23413169be4bSmrg        --mode)         test $# = 0 && func_missing_arg $_G_opt && break
23423169be4bSmrg                        opt_mode=$1
23433169be4bSmrg                        case $1 in
23443169be4bSmrg                          # Valid mode arguments:
23453169be4bSmrg                          clean|compile|execute|finish|install|link|relink|uninstall) ;;
23463169be4bSmrg
23473169be4bSmrg                          # Catch anything else as an error
23483169be4bSmrg                          *) func_error "invalid argument for $_G_opt"
23493169be4bSmrg                             exit_cmd=exit
23503169be4bSmrg                             break
23513169be4bSmrg                             ;;
23523169be4bSmrg                        esac
23533169be4bSmrg                        shift
23543169be4bSmrg                        ;;
23553169be4bSmrg
23563169be4bSmrg        --no-silent|--no-quiet)
23573169be4bSmrg                        opt_quiet=false
23583169be4bSmrg                        func_append preserve_args " $_G_opt"
23593169be4bSmrg                        ;;
23603169be4bSmrg
23613169be4bSmrg        --no-warnings|--no-warning|--no-warn)
23623169be4bSmrg                        opt_warning=false
23633169be4bSmrg                        func_append preserve_args " $_G_opt"
23643169be4bSmrg                        ;;
23653169be4bSmrg
23663169be4bSmrg        --no-verbose)
23673169be4bSmrg                        opt_verbose=false
23683169be4bSmrg                        func_append preserve_args " $_G_opt"
23693169be4bSmrg                        ;;
23703169be4bSmrg
23713169be4bSmrg        --silent|--quiet)
23723169be4bSmrg                        opt_quiet=:
23733169be4bSmrg                        opt_verbose=false
23743169be4bSmrg                        func_append preserve_args " $_G_opt"
23753169be4bSmrg                        ;;
23763169be4bSmrg
23773169be4bSmrg        --tag)          test $# = 0 && func_missing_arg $_G_opt && break
23783169be4bSmrg                        opt_tag=$1
23793169be4bSmrg                        func_append preserve_args " $_G_opt $1"
23803169be4bSmrg                        func_enable_tag "$1"
23813169be4bSmrg                        shift
23823169be4bSmrg                        ;;
23833169be4bSmrg
23843169be4bSmrg        --verbose|-v)   opt_quiet=false
23853169be4bSmrg                        opt_verbose=:
23863169be4bSmrg                        func_append preserve_args " $_G_opt"
23873169be4bSmrg                        ;;
23883169be4bSmrg
23893169be4bSmrg	# An option not handled by this hook function:
23903169be4bSmrg        *)		set dummy "$_G_opt" ${1+"$@"};	shift; break  ;;
23913169be4bSmrg      esac
23923169be4bSmrg    done
2393bd23fbfaSmrg
2394bd23fbfaSmrg
23953169be4bSmrg    # save modified positional parameters for caller
23963169be4bSmrg    func_quote_for_eval ${1+"$@"}
23973169be4bSmrg    libtool_parse_options_result=$func_quote_for_eval_result
23983169be4bSmrg}
23993169be4bSmrgfunc_add_hook func_parse_options libtool_parse_options
24008c4a8e55Smrg
2401b042e37fSmrg
24028c4a8e55Smrg
24033169be4bSmrg# libtool_validate_options [ARG]...
24043169be4bSmrg# ---------------------------------
24053169be4bSmrg# Perform any sanity checks on option settings and/or unconsumed
24063169be4bSmrg# arguments.
24073169be4bSmrglibtool_validate_options ()
24083169be4bSmrg{
24093169be4bSmrg    # save first non-option argument
24103169be4bSmrg    if test 0 -lt $#; then
24113169be4bSmrg      nonopt=$1
24123169be4bSmrg      shift
24138c4a8e55Smrg    fi
24148c4a8e55Smrg
24153169be4bSmrg    # preserve --debug
24163169be4bSmrg    test : = "$debug_cmd" || func_append preserve_args " --debug"
24178c4a8e55Smrg
24183169be4bSmrg    case $host in
24193169be4bSmrg      # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452
24203169be4bSmrg      # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788
24213169be4bSmrg      *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*)
24223169be4bSmrg        # don't eliminate duplications in $postdeps and $predeps
24233169be4bSmrg        opt_duplicate_compiler_generated_deps=:
24243169be4bSmrg        ;;
24253169be4bSmrg      *)
24263169be4bSmrg        opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
24273169be4bSmrg        ;;
24283169be4bSmrg    esac
24298c4a8e55Smrg
24303169be4bSmrg    $opt_help || {
24313169be4bSmrg      # Sanity checks first:
24323169be4bSmrg      func_check_version_match
24338c4a8e55Smrg
24343169be4bSmrg      test yes != "$build_libtool_libs" \
24353169be4bSmrg        && test yes != "$build_old_libs" \
24363169be4bSmrg        && func_fatal_configuration "not configured to build any kind of library"
24378c4a8e55Smrg
24383169be4bSmrg      # Darwin sucks
24393169be4bSmrg      eval std_shrext=\"$shrext_cmds\"
24403169be4bSmrg
24413169be4bSmrg      # Only execute mode is allowed to have -dlopen flags.
24423169be4bSmrg      if test -n "$opt_dlopen" && test execute != "$opt_mode"; then
24433169be4bSmrg        func_error "unrecognized option '-dlopen'"
24443169be4bSmrg        $ECHO "$help" 1>&2
24453169be4bSmrg        exit $EXIT_FAILURE
24463169be4bSmrg      fi
24473169be4bSmrg
24483169be4bSmrg      # Change the help message to a mode-specific one.
24493169be4bSmrg      generic_help=$help
24503169be4bSmrg      help="Try '$progname --help --mode=$opt_mode' for more information."
24513169be4bSmrg    }
24523169be4bSmrg
24533169be4bSmrg    # Pass back the unparsed argument list
24543169be4bSmrg    func_quote_for_eval ${1+"$@"}
24553169be4bSmrg    libtool_validate_options_result=$func_quote_for_eval_result
2456bd23fbfaSmrg}
24573169be4bSmrgfunc_add_hook func_validate_options libtool_validate_options
24583169be4bSmrg
24598c4a8e55Smrg
24603169be4bSmrg# Process options as early as possible so that --help and --version
24613169be4bSmrg# can return quickly.
24623169be4bSmrgfunc_options ${1+"$@"}
24633169be4bSmrgeval set dummy "$func_options_result"; shift
24648c4a8e55Smrg
2465b042e37fSmrg
2466b042e37fSmrg
2467bd23fbfaSmrg## ----------- ##
2468bd23fbfaSmrg##    Main.    ##
2469bd23fbfaSmrg## ----------- ##
2470b042e37fSmrg
24713169be4bSmrgmagic='%%%MAGIC variable%%%'
24723169be4bSmrgmagic_exe='%%%MAGIC EXE variable%%%'
24733169be4bSmrg
24743169be4bSmrg# Global variables.
24753169be4bSmrgextracted_archives=
24763169be4bSmrgextracted_serial=0
24773169be4bSmrg
24783169be4bSmrg# If this variable is set in any of the actions, the command in it
24793169be4bSmrg# will be execed at the end.  This prevents here-documents from being
24803169be4bSmrg# left over by shells.
24813169be4bSmrgexec_cmd=
24823169be4bSmrg
24833169be4bSmrg
24843169be4bSmrg# A function that is used when there is no print builtin or printf.
24853169be4bSmrgfunc_fallback_echo ()
24863169be4bSmrg{
24873169be4bSmrg  eval 'cat <<_LTECHO_EOF
24883169be4bSmrg$1
24893169be4bSmrg_LTECHO_EOF'
24903169be4bSmrg}
24913169be4bSmrg
24923169be4bSmrg# func_generated_by_libtool
24933169be4bSmrg# True iff stdin has been generated by Libtool. This function is only
24943169be4bSmrg# a basic sanity check; it will hardly flush out determined imposters.
24953169be4bSmrgfunc_generated_by_libtool_p ()
24963169be4bSmrg{
24973169be4bSmrg  $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
24983169be4bSmrg}
24993169be4bSmrg
25008c4a8e55Smrg# func_lalib_p file
25013169be4bSmrg# True iff FILE is a libtool '.la' library or '.lo' object file.
25028c4a8e55Smrg# This function is only a basic sanity check; it will hardly flush out
25038c4a8e55Smrg# determined imposters.
25048c4a8e55Smrgfunc_lalib_p ()
25058c4a8e55Smrg{
25068c4a8e55Smrg    test -f "$1" &&
25073169be4bSmrg      $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p
25088c4a8e55Smrg}
2509b042e37fSmrg
25108c4a8e55Smrg# func_lalib_unsafe_p file
25113169be4bSmrg# True iff FILE is a libtool '.la' library or '.lo' object file.
25128c4a8e55Smrg# This function implements the same check as func_lalib_p without
25138c4a8e55Smrg# resorting to external programs.  To this end, it redirects stdin and
25148c4a8e55Smrg# closes it afterwards, without saving the original file descriptor.
25158c4a8e55Smrg# As a safety measure, use it only where a negative result would be
25163169be4bSmrg# fatal anyway.  Works if 'file' does not exist.
25178c4a8e55Smrgfunc_lalib_unsafe_p ()
25188c4a8e55Smrg{
25198c4a8e55Smrg    lalib_p=no
25208c4a8e55Smrg    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
25218c4a8e55Smrg	for lalib_p_l in 1 2 3 4
25228c4a8e55Smrg	do
25238c4a8e55Smrg	    read lalib_p_line
25243169be4bSmrg	    case $lalib_p_line in
25258c4a8e55Smrg		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
25268c4a8e55Smrg	    esac
25278c4a8e55Smrg	done
25288c4a8e55Smrg	exec 0<&5 5<&-
25298c4a8e55Smrg    fi
25303169be4bSmrg    test yes = "$lalib_p"
25318c4a8e55Smrg}
2532b042e37fSmrg
25338c4a8e55Smrg# func_ltwrapper_script_p file
25348c4a8e55Smrg# True iff FILE is a libtool wrapper script
25358c4a8e55Smrg# This function is only a basic sanity check; it will hardly flush out
25368c4a8e55Smrg# determined imposters.
25378c4a8e55Smrgfunc_ltwrapper_script_p ()
25388c4a8e55Smrg{
25393169be4bSmrg    test -f "$1" &&
25403169be4bSmrg      $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p
25418c4a8e55Smrg}
2542b042e37fSmrg
25438c4a8e55Smrg# func_ltwrapper_executable_p file
25448c4a8e55Smrg# True iff FILE is a libtool wrapper executable
25458c4a8e55Smrg# This function is only a basic sanity check; it will hardly flush out
25468c4a8e55Smrg# determined imposters.
25478c4a8e55Smrgfunc_ltwrapper_executable_p ()
25488c4a8e55Smrg{
25498c4a8e55Smrg    func_ltwrapper_exec_suffix=
25508c4a8e55Smrg    case $1 in
25518c4a8e55Smrg    *.exe) ;;
25528c4a8e55Smrg    *) func_ltwrapper_exec_suffix=.exe ;;
25538c4a8e55Smrg    esac
25548c4a8e55Smrg    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
25558c4a8e55Smrg}
2556b042e37fSmrg
25578c4a8e55Smrg# func_ltwrapper_scriptname file
25588c4a8e55Smrg# Assumes file is an ltwrapper_executable
25598c4a8e55Smrg# uses $file to determine the appropriate filename for a
25608c4a8e55Smrg# temporary ltwrapper_script.
25618c4a8e55Smrgfunc_ltwrapper_scriptname ()
25628c4a8e55Smrg{
2563bd23fbfaSmrg    func_dirname_and_basename "$1" "" "."
2564bd23fbfaSmrg    func_stripname '' '.exe' "$func_basename_result"
25653169be4bSmrg    func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper
25668c4a8e55Smrg}
2567b042e37fSmrg
25688c4a8e55Smrg# func_ltwrapper_p file
25698c4a8e55Smrg# True iff FILE is a libtool wrapper script or wrapper executable
25708c4a8e55Smrg# This function is only a basic sanity check; it will hardly flush out
25718c4a8e55Smrg# determined imposters.
25728c4a8e55Smrgfunc_ltwrapper_p ()
25738c4a8e55Smrg{
25748c4a8e55Smrg    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
25758c4a8e55Smrg}
25768c4a8e55Smrg
25778c4a8e55Smrg
25788c4a8e55Smrg# func_execute_cmds commands fail_cmd
25798c4a8e55Smrg# Execute tilde-delimited COMMANDS.
25808c4a8e55Smrg# If FAIL_CMD is given, eval that upon failure.
25818c4a8e55Smrg# FAIL_CMD may read-access the current command in variable CMD!
25828c4a8e55Smrgfunc_execute_cmds ()
25838c4a8e55Smrg{
25843169be4bSmrg    $debug_cmd
25853169be4bSmrg
25868c4a8e55Smrg    save_ifs=$IFS; IFS='~'
25878c4a8e55Smrg    for cmd in $1; do
25883169be4bSmrg      IFS=$sp$nl
25898c4a8e55Smrg      eval cmd=\"$cmd\"
25903169be4bSmrg      IFS=$save_ifs
25918c4a8e55Smrg      func_show_eval "$cmd" "${2-:}"
25928c4a8e55Smrg    done
25938c4a8e55Smrg    IFS=$save_ifs
25948c4a8e55Smrg}
25958c4a8e55Smrg
25968c4a8e55Smrg
25978c4a8e55Smrg# func_source file
25988c4a8e55Smrg# Source FILE, adding directory component if necessary.
25998c4a8e55Smrg# Note that it is not necessary on cygwin/mingw to append a dot to
26008c4a8e55Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
26018c4a8e55Smrg# behavior happens only for exec(3), not for open(2)!  Also, sourcing
26023169be4bSmrg# 'FILE.' does not work on cygwin managed mounts.
26038c4a8e55Smrgfunc_source ()
26048c4a8e55Smrg{
26053169be4bSmrg    $debug_cmd
26063169be4bSmrg
26078c4a8e55Smrg    case $1 in
26088c4a8e55Smrg    */* | *\\*)	. "$1" ;;
26098c4a8e55Smrg    *)		. "./$1" ;;
26108c4a8e55Smrg    esac
26118c4a8e55Smrg}
26128c4a8e55Smrg
26138c4a8e55Smrg
2614bd23fbfaSmrg# func_resolve_sysroot PATH
2615bd23fbfaSmrg# Replace a leading = in PATH with a sysroot.  Store the result into
2616bd23fbfaSmrg# func_resolve_sysroot_result
2617bd23fbfaSmrgfunc_resolve_sysroot ()
2618bd23fbfaSmrg{
2619bd23fbfaSmrg  func_resolve_sysroot_result=$1
2620bd23fbfaSmrg  case $func_resolve_sysroot_result in
2621bd23fbfaSmrg  =*)
2622bd23fbfaSmrg    func_stripname '=' '' "$func_resolve_sysroot_result"
2623bd23fbfaSmrg    func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
2624bd23fbfaSmrg    ;;
2625bd23fbfaSmrg  esac
2626bd23fbfaSmrg}
2627bd23fbfaSmrg
2628bd23fbfaSmrg# func_replace_sysroot PATH
2629bd23fbfaSmrg# If PATH begins with the sysroot, replace it with = and
2630bd23fbfaSmrg# store the result into func_replace_sysroot_result.
2631bd23fbfaSmrgfunc_replace_sysroot ()
2632bd23fbfaSmrg{
26333169be4bSmrg  case $lt_sysroot:$1 in
2634bd23fbfaSmrg  ?*:"$lt_sysroot"*)
2635bd23fbfaSmrg    func_stripname "$lt_sysroot" '' "$1"
26363169be4bSmrg    func_replace_sysroot_result='='$func_stripname_result
2637bd23fbfaSmrg    ;;
2638bd23fbfaSmrg  *)
2639bd23fbfaSmrg    # Including no sysroot.
2640bd23fbfaSmrg    func_replace_sysroot_result=$1
2641bd23fbfaSmrg    ;;
2642bd23fbfaSmrg  esac
2643bd23fbfaSmrg}
2644bd23fbfaSmrg
26458c4a8e55Smrg# func_infer_tag arg
26468c4a8e55Smrg# Infer tagged configuration to use if any are available and
26478c4a8e55Smrg# if one wasn't chosen via the "--tag" command line option.
26488c4a8e55Smrg# Only attempt this if the compiler in the base compile
26498c4a8e55Smrg# command doesn't match the default compiler.
26508c4a8e55Smrg# arg is usually of the form 'gcc ...'
26518c4a8e55Smrgfunc_infer_tag ()
26528c4a8e55Smrg{
26533169be4bSmrg    $debug_cmd
26543169be4bSmrg
26558c4a8e55Smrg    if test -n "$available_tags" && test -z "$tagname"; then
26568c4a8e55Smrg      CC_quoted=
26578c4a8e55Smrg      for arg in $CC; do
2658bd23fbfaSmrg	func_append_quoted CC_quoted "$arg"
26598c4a8e55Smrg      done
2660706b6b52Smrg      CC_expanded=`func_echo_all $CC`
2661706b6b52Smrg      CC_quoted_expanded=`func_echo_all $CC_quoted`
26628c4a8e55Smrg      case $@ in
26638c4a8e55Smrg      # Blanks in the command may have been stripped by the calling shell,
26648c4a8e55Smrg      # but not from the CC environment variable when configure was run.
2665706b6b52Smrg      " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
2666706b6b52Smrg      " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
26678c4a8e55Smrg      # Blanks at the start of $base_compile will cause this to fail
26688c4a8e55Smrg      # if we don't check for them as well.
26698c4a8e55Smrg      *)
26708c4a8e55Smrg	for z in $available_tags; do
26718c4a8e55Smrg	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
26728c4a8e55Smrg	    # Evaluate the configuration.
26733169be4bSmrg	    eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
26748c4a8e55Smrg	    CC_quoted=
26758c4a8e55Smrg	    for arg in $CC; do
26768c4a8e55Smrg	      # Double-quote args containing other shell metacharacters.
2677bd23fbfaSmrg	      func_append_quoted CC_quoted "$arg"
26788c4a8e55Smrg	    done
2679706b6b52Smrg	    CC_expanded=`func_echo_all $CC`
2680706b6b52Smrg	    CC_quoted_expanded=`func_echo_all $CC_quoted`
26818c4a8e55Smrg	    case "$@ " in
2682706b6b52Smrg	    " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
2683706b6b52Smrg	    " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
26848c4a8e55Smrg	      # The compiler in the base compile command matches
26858c4a8e55Smrg	      # the one in the tagged configuration.
26868c4a8e55Smrg	      # Assume this is the tagged configuration we want.
26878c4a8e55Smrg	      tagname=$z
26888c4a8e55Smrg	      break
26898c4a8e55Smrg	      ;;
26908c4a8e55Smrg	    esac
26918c4a8e55Smrg	  fi
26928c4a8e55Smrg	done
26938c4a8e55Smrg	# If $tagname still isn't set, then no tagged configuration
26948c4a8e55Smrg	# was found and let the user know that the "--tag" command
26958c4a8e55Smrg	# line option must be used.
26968c4a8e55Smrg	if test -z "$tagname"; then
26978c4a8e55Smrg	  func_echo "unable to infer tagged configuration"
26983169be4bSmrg	  func_fatal_error "specify a tag with '--tag'"
26998c4a8e55Smrg#	else
27008c4a8e55Smrg#	  func_verbose "using $tagname tagged configuration"
27018c4a8e55Smrg	fi
27028c4a8e55Smrg	;;
27038c4a8e55Smrg      esac
27048c4a8e55Smrg    fi
27058c4a8e55Smrg}
27068c4a8e55Smrg
27078c4a8e55Smrg
27088c4a8e55Smrg
2709bd23fbfaSmrg# func_write_libtool_object output_name pic_name nonpic_name
2710bd23fbfaSmrg# Create a libtool object file (analogous to a ".la" file),
2711bd23fbfaSmrg# but don't create it if we're doing a dry run.
2712bd23fbfaSmrgfunc_write_libtool_object ()
2713bd23fbfaSmrg{
27143169be4bSmrg    write_libobj=$1
27153169be4bSmrg    if test yes = "$build_libtool_libs"; then
27163169be4bSmrg      write_lobj=\'$2\'
2717bd23fbfaSmrg    else
2718bd23fbfaSmrg      write_lobj=none
2719bd23fbfaSmrg    fi
2720bd23fbfaSmrg
27213169be4bSmrg    if test yes = "$build_old_libs"; then
27223169be4bSmrg      write_oldobj=\'$3\'
2723bd23fbfaSmrg    else
2724bd23fbfaSmrg      write_oldobj=none
2725bd23fbfaSmrg    fi
2726bd23fbfaSmrg
2727bd23fbfaSmrg    $opt_dry_run || {
2728bd23fbfaSmrg      cat >${write_libobj}T <<EOF
2729bd23fbfaSmrg# $write_libobj - a libtool object file
27303169be4bSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
2731bd23fbfaSmrg#
2732bd23fbfaSmrg# Please DO NOT delete this file!
2733bd23fbfaSmrg# It is necessary for linking the library.
2734bd23fbfaSmrg
2735bd23fbfaSmrg# Name of the PIC object.
2736bd23fbfaSmrgpic_object=$write_lobj
2737bd23fbfaSmrg
2738bd23fbfaSmrg# Name of the non-PIC object
2739bd23fbfaSmrgnon_pic_object=$write_oldobj
2740bd23fbfaSmrg
2741bd23fbfaSmrgEOF
27423169be4bSmrg      $MV "${write_libobj}T" "$write_libobj"
2743bd23fbfaSmrg    }
2744bd23fbfaSmrg}
2745bd23fbfaSmrg
2746bd23fbfaSmrg
2747bd23fbfaSmrg##################################################
2748bd23fbfaSmrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
2749bd23fbfaSmrg##################################################
2750bd23fbfaSmrg
2751bd23fbfaSmrg# func_convert_core_file_wine_to_w32 ARG
2752bd23fbfaSmrg# Helper function used by file name conversion functions when $build is *nix,
2753bd23fbfaSmrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a
2754bd23fbfaSmrg# correctly configured wine environment available, with the winepath program
2755bd23fbfaSmrg# in $build's $PATH.
2756bd23fbfaSmrg#
2757bd23fbfaSmrg# ARG is the $build file name to be converted to w32 format.
2758bd23fbfaSmrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will
2759bd23fbfaSmrg# be empty on error (or when ARG is empty)
2760bd23fbfaSmrgfunc_convert_core_file_wine_to_w32 ()
2761bd23fbfaSmrg{
27623169be4bSmrg  $debug_cmd
27633169be4bSmrg
27643169be4bSmrg  func_convert_core_file_wine_to_w32_result=$1
2765bd23fbfaSmrg  if test -n "$1"; then
2766bd23fbfaSmrg    # Unfortunately, winepath does not exit with a non-zero error code, so we
2767bd23fbfaSmrg    # are forced to check the contents of stdout. On the other hand, if the
2768bd23fbfaSmrg    # command is not found, the shell will set an exit code of 127 and print
2769bd23fbfaSmrg    # *an error message* to stdout. So we must check for both error code of
2770bd23fbfaSmrg    # zero AND non-empty stdout, which explains the odd construction:
2771bd23fbfaSmrg    func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
27723169be4bSmrg    if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then
2773bd23fbfaSmrg      func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
27743169be4bSmrg        $SED -e "$sed_naive_backslashify"`
2775bd23fbfaSmrg    else
2776bd23fbfaSmrg      func_convert_core_file_wine_to_w32_result=
2777bd23fbfaSmrg    fi
2778bd23fbfaSmrg  fi
2779bd23fbfaSmrg}
2780bd23fbfaSmrg# end: func_convert_core_file_wine_to_w32
2781bd23fbfaSmrg
2782bd23fbfaSmrg
2783bd23fbfaSmrg# func_convert_core_path_wine_to_w32 ARG
2784bd23fbfaSmrg# Helper function used by path conversion functions when $build is *nix, and
2785bd23fbfaSmrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
2786bd23fbfaSmrg# configured wine environment available, with the winepath program in $build's
2787bd23fbfaSmrg# $PATH. Assumes ARG has no leading or trailing path separator characters.
2788bd23fbfaSmrg#
2789bd23fbfaSmrg# ARG is path to be converted from $build format to win32.
2790bd23fbfaSmrg# Result is available in $func_convert_core_path_wine_to_w32_result.
2791bd23fbfaSmrg# Unconvertible file (directory) names in ARG are skipped; if no directory names
2792bd23fbfaSmrg# are convertible, then the result may be empty.
2793bd23fbfaSmrgfunc_convert_core_path_wine_to_w32 ()
2794bd23fbfaSmrg{
27953169be4bSmrg  $debug_cmd
27963169be4bSmrg
2797bd23fbfaSmrg  # unfortunately, winepath doesn't convert paths, only file names
27983169be4bSmrg  func_convert_core_path_wine_to_w32_result=
2799bd23fbfaSmrg  if test -n "$1"; then
2800bd23fbfaSmrg    oldIFS=$IFS
2801bd23fbfaSmrg    IFS=:
2802bd23fbfaSmrg    for func_convert_core_path_wine_to_w32_f in $1; do
2803bd23fbfaSmrg      IFS=$oldIFS
2804bd23fbfaSmrg      func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
28053169be4bSmrg      if test -n "$func_convert_core_file_wine_to_w32_result"; then
2806bd23fbfaSmrg        if test -z "$func_convert_core_path_wine_to_w32_result"; then
28073169be4bSmrg          func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result
2808bd23fbfaSmrg        else
2809bd23fbfaSmrg          func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
2810bd23fbfaSmrg        fi
2811bd23fbfaSmrg      fi
2812bd23fbfaSmrg    done
2813bd23fbfaSmrg    IFS=$oldIFS
2814bd23fbfaSmrg  fi
2815bd23fbfaSmrg}
2816bd23fbfaSmrg# end: func_convert_core_path_wine_to_w32
2817bd23fbfaSmrg
2818bd23fbfaSmrg
2819bd23fbfaSmrg# func_cygpath ARGS...
2820bd23fbfaSmrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
2821bd23fbfaSmrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
2822bd23fbfaSmrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
2823bd23fbfaSmrg# (2), returns the Cygwin file name or path in func_cygpath_result (input
2824bd23fbfaSmrg# file name or path is assumed to be in w32 format, as previously converted
2825bd23fbfaSmrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name
2826bd23fbfaSmrg# or path in func_cygpath_result (input file name or path is assumed to be in
2827bd23fbfaSmrg# Cygwin format). Returns an empty string on error.
2828bd23fbfaSmrg#
2829bd23fbfaSmrg# ARGS are passed to cygpath, with the last one being the file name or path to
2830bd23fbfaSmrg# be converted.
2831bd23fbfaSmrg#
2832bd23fbfaSmrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
2833bd23fbfaSmrg# environment variable; do not put it in $PATH.
2834bd23fbfaSmrgfunc_cygpath ()
2835bd23fbfaSmrg{
28363169be4bSmrg  $debug_cmd
28373169be4bSmrg
2838bd23fbfaSmrg  if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
2839bd23fbfaSmrg    func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
2840bd23fbfaSmrg    if test "$?" -ne 0; then
2841bd23fbfaSmrg      # on failure, ensure result is empty
2842bd23fbfaSmrg      func_cygpath_result=
2843bd23fbfaSmrg    fi
2844bd23fbfaSmrg  else
2845bd23fbfaSmrg    func_cygpath_result=
28463169be4bSmrg    func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'"
2847bd23fbfaSmrg  fi
2848bd23fbfaSmrg}
2849bd23fbfaSmrg#end: func_cygpath
2850bd23fbfaSmrg
2851bd23fbfaSmrg
2852bd23fbfaSmrg# func_convert_core_msys_to_w32 ARG
2853bd23fbfaSmrg# Convert file name or path ARG from MSYS format to w32 format.  Return
2854bd23fbfaSmrg# result in func_convert_core_msys_to_w32_result.
2855bd23fbfaSmrgfunc_convert_core_msys_to_w32 ()
2856bd23fbfaSmrg{
28573169be4bSmrg  $debug_cmd
28583169be4bSmrg
2859bd23fbfaSmrg  # awkward: cmd appends spaces to result
2860bd23fbfaSmrg  func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
28613169be4bSmrg    $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"`
2862bd23fbfaSmrg}
2863bd23fbfaSmrg#end: func_convert_core_msys_to_w32
2864bd23fbfaSmrg
2865bd23fbfaSmrg
2866bd23fbfaSmrg# func_convert_file_check ARG1 ARG2
2867bd23fbfaSmrg# Verify that ARG1 (a file name in $build format) was converted to $host
2868bd23fbfaSmrg# format in ARG2. Otherwise, emit an error message, but continue (resetting
2869bd23fbfaSmrg# func_to_host_file_result to ARG1).
2870bd23fbfaSmrgfunc_convert_file_check ()
2871bd23fbfaSmrg{
28723169be4bSmrg  $debug_cmd
28733169be4bSmrg
28743169be4bSmrg  if test -z "$2" && test -n "$1"; then
2875bd23fbfaSmrg    func_error "Could not determine host file name corresponding to"
28763169be4bSmrg    func_error "  '$1'"
2877bd23fbfaSmrg    func_error "Continuing, but uninstalled executables may not work."
2878bd23fbfaSmrg    # Fallback:
28793169be4bSmrg    func_to_host_file_result=$1
2880bd23fbfaSmrg  fi
2881bd23fbfaSmrg}
2882bd23fbfaSmrg# end func_convert_file_check
2883bd23fbfaSmrg
2884bd23fbfaSmrg
2885bd23fbfaSmrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
2886bd23fbfaSmrg# Verify that FROM_PATH (a path in $build format) was converted to $host
2887bd23fbfaSmrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting
2888bd23fbfaSmrg# func_to_host_file_result to a simplistic fallback value (see below).
2889bd23fbfaSmrgfunc_convert_path_check ()
2890bd23fbfaSmrg{
28913169be4bSmrg  $debug_cmd
28923169be4bSmrg
2893bd23fbfaSmrg  if test -z "$4" && test -n "$3"; then
2894bd23fbfaSmrg    func_error "Could not determine the host path corresponding to"
28953169be4bSmrg    func_error "  '$3'"
2896bd23fbfaSmrg    func_error "Continuing, but uninstalled executables may not work."
2897bd23fbfaSmrg    # Fallback.  This is a deliberately simplistic "conversion" and
2898bd23fbfaSmrg    # should not be "improved".  See libtool.info.
2899bd23fbfaSmrg    if test "x$1" != "x$2"; then
2900bd23fbfaSmrg      lt_replace_pathsep_chars="s|$1|$2|g"
2901bd23fbfaSmrg      func_to_host_path_result=`echo "$3" |
2902bd23fbfaSmrg        $SED -e "$lt_replace_pathsep_chars"`
2903bd23fbfaSmrg    else
29043169be4bSmrg      func_to_host_path_result=$3
2905bd23fbfaSmrg    fi
2906bd23fbfaSmrg  fi
2907bd23fbfaSmrg}
2908bd23fbfaSmrg# end func_convert_path_check
2909bd23fbfaSmrg
2910bd23fbfaSmrg
2911bd23fbfaSmrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
2912bd23fbfaSmrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
2913bd23fbfaSmrg# and appending REPL if ORIG matches BACKPAT.
2914bd23fbfaSmrgfunc_convert_path_front_back_pathsep ()
2915bd23fbfaSmrg{
29163169be4bSmrg  $debug_cmd
29173169be4bSmrg
2918bd23fbfaSmrg  case $4 in
29193169be4bSmrg  $1 ) func_to_host_path_result=$3$func_to_host_path_result
2920bd23fbfaSmrg    ;;
2921bd23fbfaSmrg  esac
2922bd23fbfaSmrg  case $4 in
2923bd23fbfaSmrg  $2 ) func_append func_to_host_path_result "$3"
2924bd23fbfaSmrg    ;;
2925bd23fbfaSmrg  esac
2926bd23fbfaSmrg}
2927bd23fbfaSmrg# end func_convert_path_front_back_pathsep
2928bd23fbfaSmrg
2929bd23fbfaSmrg
2930bd23fbfaSmrg##################################################
2931bd23fbfaSmrg# $build to $host FILE NAME CONVERSION FUNCTIONS #
2932bd23fbfaSmrg##################################################
29333169be4bSmrg# invoked via '$to_host_file_cmd ARG'
2934bd23fbfaSmrg#
2935bd23fbfaSmrg# In each case, ARG is the path to be converted from $build to $host format.
2936bd23fbfaSmrg# Result will be available in $func_to_host_file_result.
2937bd23fbfaSmrg
2938bd23fbfaSmrg
2939bd23fbfaSmrg# func_to_host_file ARG
2940bd23fbfaSmrg# Converts the file name ARG from $build format to $host format. Return result
2941bd23fbfaSmrg# in func_to_host_file_result.
2942bd23fbfaSmrgfunc_to_host_file ()
2943bd23fbfaSmrg{
29443169be4bSmrg  $debug_cmd
29453169be4bSmrg
2946bd23fbfaSmrg  $to_host_file_cmd "$1"
2947bd23fbfaSmrg}
2948bd23fbfaSmrg# end func_to_host_file
2949bd23fbfaSmrg
2950bd23fbfaSmrg
2951bd23fbfaSmrg# func_to_tool_file ARG LAZY
2952bd23fbfaSmrg# converts the file name ARG from $build format to toolchain format. Return
2953bd23fbfaSmrg# result in func_to_tool_file_result.  If the conversion in use is listed
2954bd23fbfaSmrg# in (the comma separated) LAZY, no conversion takes place.
2955bd23fbfaSmrgfunc_to_tool_file ()
2956bd23fbfaSmrg{
29573169be4bSmrg  $debug_cmd
29583169be4bSmrg
2959bd23fbfaSmrg  case ,$2, in
2960bd23fbfaSmrg    *,"$to_tool_file_cmd",*)
2961bd23fbfaSmrg      func_to_tool_file_result=$1
2962bd23fbfaSmrg      ;;
2963bd23fbfaSmrg    *)
2964bd23fbfaSmrg      $to_tool_file_cmd "$1"
2965bd23fbfaSmrg      func_to_tool_file_result=$func_to_host_file_result
2966bd23fbfaSmrg      ;;
2967bd23fbfaSmrg  esac
2968bd23fbfaSmrg}
2969bd23fbfaSmrg# end func_to_tool_file
2970bd23fbfaSmrg
2971bd23fbfaSmrg
2972bd23fbfaSmrg# func_convert_file_noop ARG
2973bd23fbfaSmrg# Copy ARG to func_to_host_file_result.
2974bd23fbfaSmrgfunc_convert_file_noop ()
2975bd23fbfaSmrg{
29763169be4bSmrg  func_to_host_file_result=$1
2977bd23fbfaSmrg}
2978bd23fbfaSmrg# end func_convert_file_noop
2979bd23fbfaSmrg
2980bd23fbfaSmrg
2981bd23fbfaSmrg# func_convert_file_msys_to_w32 ARG
2982bd23fbfaSmrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
2983bd23fbfaSmrg# conversion to w32 is not available inside the cwrapper.  Returns result in
2984bd23fbfaSmrg# func_to_host_file_result.
2985bd23fbfaSmrgfunc_convert_file_msys_to_w32 ()
2986bd23fbfaSmrg{
29873169be4bSmrg  $debug_cmd
29883169be4bSmrg
29893169be4bSmrg  func_to_host_file_result=$1
2990bd23fbfaSmrg  if test -n "$1"; then
2991bd23fbfaSmrg    func_convert_core_msys_to_w32 "$1"
29923169be4bSmrg    func_to_host_file_result=$func_convert_core_msys_to_w32_result
2993bd23fbfaSmrg  fi
2994bd23fbfaSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
2995bd23fbfaSmrg}
2996bd23fbfaSmrg# end func_convert_file_msys_to_w32
2997bd23fbfaSmrg
2998bd23fbfaSmrg
2999bd23fbfaSmrg# func_convert_file_cygwin_to_w32 ARG
3000bd23fbfaSmrg# Convert file name ARG from Cygwin to w32 format.  Returns result in
3001bd23fbfaSmrg# func_to_host_file_result.
3002bd23fbfaSmrgfunc_convert_file_cygwin_to_w32 ()
3003bd23fbfaSmrg{
30043169be4bSmrg  $debug_cmd
30053169be4bSmrg
30063169be4bSmrg  func_to_host_file_result=$1
3007bd23fbfaSmrg  if test -n "$1"; then
3008bd23fbfaSmrg    # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
3009bd23fbfaSmrg    # LT_CYGPATH in this case.
3010bd23fbfaSmrg    func_to_host_file_result=`cygpath -m "$1"`
3011bd23fbfaSmrg  fi
3012bd23fbfaSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
3013bd23fbfaSmrg}
3014bd23fbfaSmrg# end func_convert_file_cygwin_to_w32
3015bd23fbfaSmrg
3016bd23fbfaSmrg
3017bd23fbfaSmrg# func_convert_file_nix_to_w32 ARG
3018bd23fbfaSmrg# Convert file name ARG from *nix to w32 format.  Requires a wine environment
3019bd23fbfaSmrg# and a working winepath. Returns result in func_to_host_file_result.
3020bd23fbfaSmrgfunc_convert_file_nix_to_w32 ()
3021bd23fbfaSmrg{
30223169be4bSmrg  $debug_cmd
30233169be4bSmrg
30243169be4bSmrg  func_to_host_file_result=$1
3025bd23fbfaSmrg  if test -n "$1"; then
3026bd23fbfaSmrg    func_convert_core_file_wine_to_w32 "$1"
30273169be4bSmrg    func_to_host_file_result=$func_convert_core_file_wine_to_w32_result
3028bd23fbfaSmrg  fi
3029bd23fbfaSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
3030bd23fbfaSmrg}
3031bd23fbfaSmrg# end func_convert_file_nix_to_w32
3032bd23fbfaSmrg
3033bd23fbfaSmrg
3034bd23fbfaSmrg# func_convert_file_msys_to_cygwin ARG
3035bd23fbfaSmrg# Convert file name ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
3036bd23fbfaSmrg# Returns result in func_to_host_file_result.
3037bd23fbfaSmrgfunc_convert_file_msys_to_cygwin ()
3038bd23fbfaSmrg{
30393169be4bSmrg  $debug_cmd
30403169be4bSmrg
30413169be4bSmrg  func_to_host_file_result=$1
3042bd23fbfaSmrg  if test -n "$1"; then
3043bd23fbfaSmrg    func_convert_core_msys_to_w32 "$1"
3044bd23fbfaSmrg    func_cygpath -u "$func_convert_core_msys_to_w32_result"
30453169be4bSmrg    func_to_host_file_result=$func_cygpath_result
3046bd23fbfaSmrg  fi
3047bd23fbfaSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
3048bd23fbfaSmrg}
3049bd23fbfaSmrg# end func_convert_file_msys_to_cygwin
3050bd23fbfaSmrg
3051bd23fbfaSmrg
3052bd23fbfaSmrg# func_convert_file_nix_to_cygwin ARG
3053bd23fbfaSmrg# Convert file name ARG from *nix to Cygwin format.  Requires Cygwin installed
3054bd23fbfaSmrg# in a wine environment, working winepath, and LT_CYGPATH set.  Returns result
3055bd23fbfaSmrg# in func_to_host_file_result.
3056bd23fbfaSmrgfunc_convert_file_nix_to_cygwin ()
3057bd23fbfaSmrg{
30583169be4bSmrg  $debug_cmd
30593169be4bSmrg
30603169be4bSmrg  func_to_host_file_result=$1
3061bd23fbfaSmrg  if test -n "$1"; then
3062bd23fbfaSmrg    # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
3063bd23fbfaSmrg    func_convert_core_file_wine_to_w32 "$1"
3064bd23fbfaSmrg    func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
30653169be4bSmrg    func_to_host_file_result=$func_cygpath_result
3066bd23fbfaSmrg  fi
3067bd23fbfaSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
3068bd23fbfaSmrg}
3069bd23fbfaSmrg# end func_convert_file_nix_to_cygwin
3070bd23fbfaSmrg
3071bd23fbfaSmrg
3072bd23fbfaSmrg#############################################
3073bd23fbfaSmrg# $build to $host PATH CONVERSION FUNCTIONS #
3074bd23fbfaSmrg#############################################
30753169be4bSmrg# invoked via '$to_host_path_cmd ARG'
3076bd23fbfaSmrg#
3077bd23fbfaSmrg# In each case, ARG is the path to be converted from $build to $host format.
3078bd23fbfaSmrg# The result will be available in $func_to_host_path_result.
3079bd23fbfaSmrg#
3080bd23fbfaSmrg# Path separators are also converted from $build format to $host format.  If
3081bd23fbfaSmrg# ARG begins or ends with a path separator character, it is preserved (but
3082bd23fbfaSmrg# converted to $host format) on output.
3083bd23fbfaSmrg#
3084bd23fbfaSmrg# All path conversion functions are named using the following convention:
3085bd23fbfaSmrg#   file name conversion function    : func_convert_file_X_to_Y ()
3086bd23fbfaSmrg#   path conversion function         : func_convert_path_X_to_Y ()
3087bd23fbfaSmrg# where, for any given $build/$host combination the 'X_to_Y' value is the
3088bd23fbfaSmrg# same.  If conversion functions are added for new $build/$host combinations,
3089bd23fbfaSmrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd
3090bd23fbfaSmrg# will break.
3091bd23fbfaSmrg
3092bd23fbfaSmrg
3093bd23fbfaSmrg# func_init_to_host_path_cmd
3094bd23fbfaSmrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the
3095bd23fbfaSmrg# appropriate value, based on the value of $to_host_file_cmd.
3096bd23fbfaSmrgto_host_path_cmd=
3097bd23fbfaSmrgfunc_init_to_host_path_cmd ()
3098bd23fbfaSmrg{
30993169be4bSmrg  $debug_cmd
31003169be4bSmrg
3101bd23fbfaSmrg  if test -z "$to_host_path_cmd"; then
3102bd23fbfaSmrg    func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
31033169be4bSmrg    to_host_path_cmd=func_convert_path_$func_stripname_result
3104bd23fbfaSmrg  fi
3105bd23fbfaSmrg}
3106bd23fbfaSmrg
3107bd23fbfaSmrg
3108bd23fbfaSmrg# func_to_host_path ARG
3109bd23fbfaSmrg# Converts the path ARG from $build format to $host format. Return result
3110bd23fbfaSmrg# in func_to_host_path_result.
3111bd23fbfaSmrgfunc_to_host_path ()
3112bd23fbfaSmrg{
31133169be4bSmrg  $debug_cmd
31143169be4bSmrg
3115bd23fbfaSmrg  func_init_to_host_path_cmd
3116bd23fbfaSmrg  $to_host_path_cmd "$1"
3117bd23fbfaSmrg}
3118bd23fbfaSmrg# end func_to_host_path
3119bd23fbfaSmrg
3120bd23fbfaSmrg
3121bd23fbfaSmrg# func_convert_path_noop ARG
3122bd23fbfaSmrg# Copy ARG to func_to_host_path_result.
3123bd23fbfaSmrgfunc_convert_path_noop ()
3124bd23fbfaSmrg{
31253169be4bSmrg  func_to_host_path_result=$1
3126bd23fbfaSmrg}
3127bd23fbfaSmrg# end func_convert_path_noop
3128bd23fbfaSmrg
3129bd23fbfaSmrg
3130bd23fbfaSmrg# func_convert_path_msys_to_w32 ARG
3131bd23fbfaSmrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
3132bd23fbfaSmrg# conversion to w32 is not available inside the cwrapper.  Returns result in
3133bd23fbfaSmrg# func_to_host_path_result.
3134bd23fbfaSmrgfunc_convert_path_msys_to_w32 ()
31358c4a8e55Smrg{
31363169be4bSmrg  $debug_cmd
31373169be4bSmrg
31383169be4bSmrg  func_to_host_path_result=$1
3139bd23fbfaSmrg  if test -n "$1"; then
3140bd23fbfaSmrg    # Remove leading and trailing path separator characters from ARG.  MSYS
3141bd23fbfaSmrg    # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
3142bd23fbfaSmrg    # and winepath ignores them completely.
3143bd23fbfaSmrg    func_stripname : : "$1"
3144bd23fbfaSmrg    func_to_host_path_tmp1=$func_stripname_result
3145bd23fbfaSmrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
31463169be4bSmrg    func_to_host_path_result=$func_convert_core_msys_to_w32_result
3147bd23fbfaSmrg    func_convert_path_check : ";" \
3148bd23fbfaSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
3149bd23fbfaSmrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
3150bd23fbfaSmrg  fi
3151bd23fbfaSmrg}
3152bd23fbfaSmrg# end func_convert_path_msys_to_w32
31538c4a8e55Smrg
31548c4a8e55Smrg
3155bd23fbfaSmrg# func_convert_path_cygwin_to_w32 ARG
3156bd23fbfaSmrg# Convert path ARG from Cygwin to w32 format.  Returns result in
3157bd23fbfaSmrg# func_to_host_file_result.
3158bd23fbfaSmrgfunc_convert_path_cygwin_to_w32 ()
3159bd23fbfaSmrg{
31603169be4bSmrg  $debug_cmd
31613169be4bSmrg
31623169be4bSmrg  func_to_host_path_result=$1
3163bd23fbfaSmrg  if test -n "$1"; then
3164bd23fbfaSmrg    # See func_convert_path_msys_to_w32:
3165bd23fbfaSmrg    func_stripname : : "$1"
3166bd23fbfaSmrg    func_to_host_path_tmp1=$func_stripname_result
3167bd23fbfaSmrg    func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
3168bd23fbfaSmrg    func_convert_path_check : ";" \
3169bd23fbfaSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
3170bd23fbfaSmrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
3171bd23fbfaSmrg  fi
3172bd23fbfaSmrg}
3173bd23fbfaSmrg# end func_convert_path_cygwin_to_w32
31748c4a8e55Smrg
31758c4a8e55Smrg
3176bd23fbfaSmrg# func_convert_path_nix_to_w32 ARG
3177bd23fbfaSmrg# Convert path ARG from *nix to w32 format.  Requires a wine environment and
3178bd23fbfaSmrg# a working winepath.  Returns result in func_to_host_file_result.
3179bd23fbfaSmrgfunc_convert_path_nix_to_w32 ()
3180bd23fbfaSmrg{
31813169be4bSmrg  $debug_cmd
31823169be4bSmrg
31833169be4bSmrg  func_to_host_path_result=$1
3184bd23fbfaSmrg  if test -n "$1"; then
3185bd23fbfaSmrg    # See func_convert_path_msys_to_w32:
3186bd23fbfaSmrg    func_stripname : : "$1"
3187bd23fbfaSmrg    func_to_host_path_tmp1=$func_stripname_result
3188bd23fbfaSmrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
31893169be4bSmrg    func_to_host_path_result=$func_convert_core_path_wine_to_w32_result
3190bd23fbfaSmrg    func_convert_path_check : ";" \
3191bd23fbfaSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
3192bd23fbfaSmrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
3193bd23fbfaSmrg  fi
3194bd23fbfaSmrg}
3195bd23fbfaSmrg# end func_convert_path_nix_to_w32
31968c4a8e55Smrg
3197bd23fbfaSmrg
3198bd23fbfaSmrg# func_convert_path_msys_to_cygwin ARG
3199bd23fbfaSmrg# Convert path ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
3200bd23fbfaSmrg# Returns result in func_to_host_file_result.
3201bd23fbfaSmrgfunc_convert_path_msys_to_cygwin ()
3202bd23fbfaSmrg{
32033169be4bSmrg  $debug_cmd
32043169be4bSmrg
32053169be4bSmrg  func_to_host_path_result=$1
3206bd23fbfaSmrg  if test -n "$1"; then
3207bd23fbfaSmrg    # See func_convert_path_msys_to_w32:
3208bd23fbfaSmrg    func_stripname : : "$1"
3209bd23fbfaSmrg    func_to_host_path_tmp1=$func_stripname_result
3210bd23fbfaSmrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
3211bd23fbfaSmrg    func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
32123169be4bSmrg    func_to_host_path_result=$func_cygpath_result
3213bd23fbfaSmrg    func_convert_path_check : : \
3214bd23fbfaSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
3215bd23fbfaSmrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
3216bd23fbfaSmrg  fi
3217bd23fbfaSmrg}
3218bd23fbfaSmrg# end func_convert_path_msys_to_cygwin
3219bd23fbfaSmrg
3220bd23fbfaSmrg
3221bd23fbfaSmrg# func_convert_path_nix_to_cygwin ARG
3222bd23fbfaSmrg# Convert path ARG from *nix to Cygwin format.  Requires Cygwin installed in a
3223bd23fbfaSmrg# a wine environment, working winepath, and LT_CYGPATH set.  Returns result in
3224bd23fbfaSmrg# func_to_host_file_result.
3225bd23fbfaSmrgfunc_convert_path_nix_to_cygwin ()
3226bd23fbfaSmrg{
32273169be4bSmrg  $debug_cmd
32283169be4bSmrg
32293169be4bSmrg  func_to_host_path_result=$1
3230bd23fbfaSmrg  if test -n "$1"; then
3231bd23fbfaSmrg    # Remove leading and trailing path separator characters from
3232bd23fbfaSmrg    # ARG. msys behavior is inconsistent here, cygpath turns them
3233bd23fbfaSmrg    # into '.;' and ';.', and winepath ignores them completely.
3234bd23fbfaSmrg    func_stripname : : "$1"
3235bd23fbfaSmrg    func_to_host_path_tmp1=$func_stripname_result
3236bd23fbfaSmrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
3237bd23fbfaSmrg    func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
32383169be4bSmrg    func_to_host_path_result=$func_cygpath_result
3239bd23fbfaSmrg    func_convert_path_check : : \
3240bd23fbfaSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
3241bd23fbfaSmrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
3242bd23fbfaSmrg  fi
32438c4a8e55Smrg}
3244bd23fbfaSmrg# end func_convert_path_nix_to_cygwin
3245bd23fbfaSmrg
32468c4a8e55Smrg
32473169be4bSmrg# func_dll_def_p FILE
32483169be4bSmrg# True iff FILE is a Windows DLL '.def' file.
32493169be4bSmrg# Keep in sync with _LT_DLL_DEF_P in libtool.m4
32503169be4bSmrgfunc_dll_def_p ()
32513169be4bSmrg{
32523169be4bSmrg  $debug_cmd
32533169be4bSmrg
32543169be4bSmrg  func_dll_def_p_tmp=`$SED -n \
32553169be4bSmrg    -e 's/^[	 ]*//' \
32563169be4bSmrg    -e '/^\(;.*\)*$/d' \
32573169be4bSmrg    -e 's/^\(EXPORTS\|LIBRARY\)\([	 ].*\)*$/DEF/p' \
32583169be4bSmrg    -e q \
32593169be4bSmrg    "$1"`
32603169be4bSmrg  test DEF = "$func_dll_def_p_tmp"
32613169be4bSmrg}
32623169be4bSmrg
32633169be4bSmrg
32648c4a8e55Smrg# func_mode_compile arg...
32658c4a8e55Smrgfunc_mode_compile ()
32668c4a8e55Smrg{
32673169be4bSmrg    $debug_cmd
32683169be4bSmrg
32698c4a8e55Smrg    # Get the compilation command and the source file.
32708c4a8e55Smrg    base_compile=
32713169be4bSmrg    srcfile=$nonopt  #  always keep a non-empty value in "srcfile"
32728c4a8e55Smrg    suppress_opt=yes
32738c4a8e55Smrg    suppress_output=
32748c4a8e55Smrg    arg_mode=normal
32758c4a8e55Smrg    libobj=
32768c4a8e55Smrg    later=
32778c4a8e55Smrg    pie_flag=
32788c4a8e55Smrg
32798c4a8e55Smrg    for arg
32808c4a8e55Smrg    do
32818c4a8e55Smrg      case $arg_mode in
32828c4a8e55Smrg      arg  )
32838c4a8e55Smrg	# do not "continue".  Instead, add this to base_compile
32843169be4bSmrg	lastarg=$arg
32858c4a8e55Smrg	arg_mode=normal
32868c4a8e55Smrg	;;
32878c4a8e55Smrg
32888c4a8e55Smrg      target )
32893169be4bSmrg	libobj=$arg
32908c4a8e55Smrg	arg_mode=normal
32918c4a8e55Smrg	continue
32928c4a8e55Smrg	;;
32938c4a8e55Smrg
32948c4a8e55Smrg      normal )
32958c4a8e55Smrg	# Accept any command-line options.
32968c4a8e55Smrg	case $arg in
32978c4a8e55Smrg	-o)
32988c4a8e55Smrg	  test -n "$libobj" && \
32993169be4bSmrg	    func_fatal_error "you cannot specify '-o' more than once"
33008c4a8e55Smrg	  arg_mode=target
33018c4a8e55Smrg	  continue
33028c4a8e55Smrg	  ;;
33038c4a8e55Smrg
33048c4a8e55Smrg	-pie | -fpie | -fPIE)
3305bd23fbfaSmrg          func_append pie_flag " $arg"
33068c4a8e55Smrg	  continue
33078c4a8e55Smrg	  ;;
33088c4a8e55Smrg
33098c4a8e55Smrg	-shared | -static | -prefer-pic | -prefer-non-pic)
3310bd23fbfaSmrg	  func_append later " $arg"
33118c4a8e55Smrg	  continue
33128c4a8e55Smrg	  ;;
33138c4a8e55Smrg
33148c4a8e55Smrg	-no-suppress)
33158c4a8e55Smrg	  suppress_opt=no
33168c4a8e55Smrg	  continue
33178c4a8e55Smrg	  ;;
33188c4a8e55Smrg
33198c4a8e55Smrg	-Xcompiler)
33208c4a8e55Smrg	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
33218c4a8e55Smrg	  continue      #  The current "srcfile" will either be retained or
33228c4a8e55Smrg	  ;;            #  replaced later.  I would guess that would be a bug.
3323b042e37fSmrg
3324b042e37fSmrg	-Wc,*)
33258c4a8e55Smrg	  func_stripname '-Wc,' '' "$arg"
33268c4a8e55Smrg	  args=$func_stripname_result
3327b042e37fSmrg	  lastarg=
33283169be4bSmrg	  save_ifs=$IFS; IFS=,
33298c4a8e55Smrg	  for arg in $args; do
33303169be4bSmrg	    IFS=$save_ifs
3331bd23fbfaSmrg	    func_append_quoted lastarg "$arg"
3332b042e37fSmrg	  done
33333169be4bSmrg	  IFS=$save_ifs
33348c4a8e55Smrg	  func_stripname ' ' '' "$lastarg"
33358c4a8e55Smrg	  lastarg=$func_stripname_result
3336b042e37fSmrg
3337b042e37fSmrg	  # Add the arguments to base_compile.
3338bd23fbfaSmrg	  func_append base_compile " $lastarg"
3339b042e37fSmrg	  continue
3340b042e37fSmrg	  ;;
3341b042e37fSmrg
33428c4a8e55Smrg	*)
3343b042e37fSmrg	  # Accept the current argument as the source file.
3344b042e37fSmrg	  # The previous "srcfile" becomes the current argument.
3345b042e37fSmrg	  #
33463169be4bSmrg	  lastarg=$srcfile
33473169be4bSmrg	  srcfile=$arg
3348b042e37fSmrg	  ;;
3349b042e37fSmrg	esac  #  case $arg
3350b042e37fSmrg	;;
3351b042e37fSmrg      esac    #  case $arg_mode
3352b042e37fSmrg
3353b042e37fSmrg      # Aesthetically quote the previous argument.
3354bd23fbfaSmrg      func_append_quoted base_compile "$lastarg"
3355b042e37fSmrg    done # for arg
3356b042e37fSmrg
3357b042e37fSmrg    case $arg_mode in
3358b042e37fSmrg    arg)
33598c4a8e55Smrg      func_fatal_error "you must specify an argument for -Xcompile"
3360b042e37fSmrg      ;;
3361b042e37fSmrg    target)
33623169be4bSmrg      func_fatal_error "you must specify a target with '-o'"
3363b042e37fSmrg      ;;
3364b042e37fSmrg    *)
3365b042e37fSmrg      # Get the name of the library object.
33668c4a8e55Smrg      test -z "$libobj" && {
33678c4a8e55Smrg	func_basename "$srcfile"
33683169be4bSmrg	libobj=$func_basename_result
33698c4a8e55Smrg      }
3370b042e37fSmrg      ;;
3371b042e37fSmrg    esac
3372b042e37fSmrg
3373b042e37fSmrg    # Recognize several different file suffixes.
3374b042e37fSmrg    # If the user specifies -o file.o, it is replaced with file.lo
3375b042e37fSmrg    case $libobj in
33768c4a8e55Smrg    *.[cCFSifmso] | \
33778c4a8e55Smrg    *.ada | *.adb | *.ads | *.asm | \
33788c4a8e55Smrg    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
33790597fb56Smrg    *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
33808c4a8e55Smrg      func_xform "$libobj"
33818c4a8e55Smrg      libobj=$func_xform_result
33828c4a8e55Smrg      ;;
3383b042e37fSmrg    esac
3384b042e37fSmrg
3385b042e37fSmrg    case $libobj in
33868c4a8e55Smrg    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
3387b042e37fSmrg    *)
33883169be4bSmrg      func_fatal_error "cannot determine name of library object from '$libobj'"
3389b042e37fSmrg      ;;
3390b042e37fSmrg    esac
3391b042e37fSmrg
3392b042e37fSmrg    func_infer_tag $base_compile
3393b042e37fSmrg
3394b042e37fSmrg    for arg in $later; do
3395b042e37fSmrg      case $arg in
33968c4a8e55Smrg      -shared)
33973169be4bSmrg	test yes = "$build_libtool_libs" \
33983169be4bSmrg	  || func_fatal_configuration "cannot build a shared library"
33998c4a8e55Smrg	build_old_libs=no
34008c4a8e55Smrg	continue
34018c4a8e55Smrg	;;
34028c4a8e55Smrg
3403b042e37fSmrg      -static)
34048c4a8e55Smrg	build_libtool_libs=no
3405b042e37fSmrg	build_old_libs=yes
3406b042e37fSmrg	continue
3407b042e37fSmrg	;;
3408b042e37fSmrg
3409b042e37fSmrg      -prefer-pic)
3410b042e37fSmrg	pic_mode=yes
3411b042e37fSmrg	continue
3412b042e37fSmrg	;;
3413b042e37fSmrg
3414b042e37fSmrg      -prefer-non-pic)
3415b042e37fSmrg	pic_mode=no
3416b042e37fSmrg	continue
3417b042e37fSmrg	;;
3418b042e37fSmrg      esac
3419b042e37fSmrg    done
3420b042e37fSmrg
34218c4a8e55Smrg    func_quote_for_eval "$libobj"
34228c4a8e55Smrg    test "X$libobj" != "X$func_quote_for_eval_result" \
34238c4a8e55Smrg      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
34243169be4bSmrg      && func_warning "libobj name '$libobj' may not contain shell special characters."
34258c4a8e55Smrg    func_dirname_and_basename "$obj" "/" ""
34263169be4bSmrg    objname=$func_basename_result
34273169be4bSmrg    xdir=$func_dirname_result
34283169be4bSmrg    lobj=$xdir$objdir/$objname
3429b042e37fSmrg
34308c4a8e55Smrg    test -z "$base_compile" && \
34318c4a8e55Smrg      func_fatal_help "you must specify a compilation command"
3432b042e37fSmrg
3433b042e37fSmrg    # Delete any leftover library objects.
34343169be4bSmrg    if test yes = "$build_old_libs"; then
3435b042e37fSmrg      removelist="$obj $lobj $libobj ${libobj}T"
3436b042e37fSmrg    else
3437b042e37fSmrg      removelist="$lobj $libobj ${libobj}T"
3438b042e37fSmrg    fi
3439b042e37fSmrg
3440b042e37fSmrg    # On Cygwin there's no "real" PIC flag so we must build both object types
3441b042e37fSmrg    case $host_os in
34428c4a8e55Smrg    cygwin* | mingw* | pw32* | os2* | cegcc*)
3443b042e37fSmrg      pic_mode=default
3444b042e37fSmrg      ;;
3445b042e37fSmrg    esac
34463169be4bSmrg    if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then
3447b042e37fSmrg      # non-PIC code in shared libraries is not supported
3448b042e37fSmrg      pic_mode=default
3449b042e37fSmrg    fi
3450b042e37fSmrg
3451b042e37fSmrg    # Calculate the filename of the output object if compiler does
3452b042e37fSmrg    # not support -o with -c
34533169be4bSmrg    if test no = "$compiler_c_o"; then
34543169be4bSmrg      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext
34553169be4bSmrg      lockfile=$output_obj.lock
3456b042e37fSmrg    else
3457b042e37fSmrg      output_obj=
3458b042e37fSmrg      need_locks=no
3459b042e37fSmrg      lockfile=
3460b042e37fSmrg    fi
3461b042e37fSmrg
3462b042e37fSmrg    # Lock this critical section if it is needed
3463b042e37fSmrg    # We use this script file to make the link, it avoids creating a new file
34643169be4bSmrg    if test yes = "$need_locks"; then
34658c4a8e55Smrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
34668c4a8e55Smrg	func_echo "Waiting for $lockfile to be removed"
3467b042e37fSmrg	sleep 2
3468b042e37fSmrg      done
34693169be4bSmrg    elif test warn = "$need_locks"; then
3470b042e37fSmrg      if test -f "$lockfile"; then
34718c4a8e55Smrg	$ECHO "\
3472b042e37fSmrg*** ERROR, $lockfile exists and contains:
3473b042e37fSmrg`cat $lockfile 2>/dev/null`
3474b042e37fSmrg
3475b042e37fSmrgThis indicates that another process is trying to use the same
3476b042e37fSmrgtemporary object file, and libtool could not work around it because
34773169be4bSmrgyour compiler does not support '-c' and '-o' together.  If you
3478b042e37fSmrgrepeat this compilation, it may succeed, by chance, but you had better
3479b042e37fSmrgavoid parallel builds (make -j) in this platform, or get a better
3480b042e37fSmrgcompiler."
3481b042e37fSmrg
34828c4a8e55Smrg	$opt_dry_run || $RM $removelist
3483b042e37fSmrg	exit $EXIT_FAILURE
3484b042e37fSmrg      fi
3485bd23fbfaSmrg      func_append removelist " $output_obj"
34868c4a8e55Smrg      $ECHO "$srcfile" > "$lockfile"
3487b042e37fSmrg    fi
3488b042e37fSmrg
34898c4a8e55Smrg    $opt_dry_run || $RM $removelist
3490bd23fbfaSmrg    func_append removelist " $lockfile"
34918c4a8e55Smrg    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
34928c4a8e55Smrg
3493bd23fbfaSmrg    func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
3494bd23fbfaSmrg    srcfile=$func_to_tool_file_result
34958c4a8e55Smrg    func_quote_for_eval "$srcfile"
34968c4a8e55Smrg    qsrcfile=$func_quote_for_eval_result
3497b042e37fSmrg
3498b042e37fSmrg    # Only build a PIC object if we are building libtool libraries.
34993169be4bSmrg    if test yes = "$build_libtool_libs"; then
3500b042e37fSmrg      # Without this assignment, base_compile gets emptied.
3501b042e37fSmrg      fbsd_hideous_sh_bug=$base_compile
3502b042e37fSmrg
35033169be4bSmrg      if test no != "$pic_mode"; then
3504b042e37fSmrg	command="$base_compile $qsrcfile $pic_flag"
3505b042e37fSmrg      else
3506b042e37fSmrg	# Don't build PIC code
3507b042e37fSmrg	command="$base_compile $qsrcfile"
3508b042e37fSmrg      fi
3509b042e37fSmrg
35108c4a8e55Smrg      func_mkdir_p "$xdir$objdir"
3511b042e37fSmrg
3512b042e37fSmrg      if test -z "$output_obj"; then
3513b042e37fSmrg	# Place PIC objects in $objdir
3514bd23fbfaSmrg	func_append command " -o $lobj"
3515b042e37fSmrg      fi
3516b042e37fSmrg
35178c4a8e55Smrg      func_show_eval_locale "$command"	\
35188c4a8e55Smrg          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
3519b042e37fSmrg
35203169be4bSmrg      if test warn = "$need_locks" &&
3521b042e37fSmrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
35228c4a8e55Smrg	$ECHO "\
3523b042e37fSmrg*** ERROR, $lockfile contains:
3524b042e37fSmrg`cat $lockfile 2>/dev/null`
3525b042e37fSmrg
3526b042e37fSmrgbut it should contain:
3527b042e37fSmrg$srcfile
3528b042e37fSmrg
3529b042e37fSmrgThis indicates that another process is trying to use the same
3530b042e37fSmrgtemporary object file, and libtool could not work around it because
35313169be4bSmrgyour compiler does not support '-c' and '-o' together.  If you
3532b042e37fSmrgrepeat this compilation, it may succeed, by chance, but you had better
3533b042e37fSmrgavoid parallel builds (make -j) in this platform, or get a better
3534b042e37fSmrgcompiler."
3535b042e37fSmrg
35368c4a8e55Smrg	$opt_dry_run || $RM $removelist
3537b042e37fSmrg	exit $EXIT_FAILURE
3538b042e37fSmrg      fi
3539b042e37fSmrg
3540b042e37fSmrg      # Just move the object if needed, then go on to compile the next one
3541b042e37fSmrg      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
35428c4a8e55Smrg	func_show_eval '$MV "$output_obj" "$lobj"' \
35438c4a8e55Smrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
3544b042e37fSmrg      fi
3545b042e37fSmrg
3546b042e37fSmrg      # Allow error messages only from the first compilation.
35473169be4bSmrg      if test yes = "$suppress_opt"; then
35488c4a8e55Smrg	suppress_output=' >/dev/null 2>&1'
3549b042e37fSmrg      fi
3550b042e37fSmrg    fi
3551b042e37fSmrg
3552b042e37fSmrg    # Only build a position-dependent object if we build old libraries.
35533169be4bSmrg    if test yes = "$build_old_libs"; then
35543169be4bSmrg      if test yes != "$pic_mode"; then
3555b042e37fSmrg	# Don't build PIC code
35568c4a8e55Smrg	command="$base_compile $qsrcfile$pie_flag"
3557b042e37fSmrg      else
3558b042e37fSmrg	command="$base_compile $qsrcfile $pic_flag"
3559b042e37fSmrg      fi
35603169be4bSmrg      if test yes = "$compiler_c_o"; then
3561bd23fbfaSmrg	func_append command " -o $obj"
3562b042e37fSmrg      fi
3563b042e37fSmrg
3564b042e37fSmrg      # Suppress compiler output if we already did a PIC compilation.
3565bd23fbfaSmrg      func_append command "$suppress_output"
35668c4a8e55Smrg      func_show_eval_locale "$command" \
35678c4a8e55Smrg        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
3568b042e37fSmrg
35693169be4bSmrg      if test warn = "$need_locks" &&
3570b042e37fSmrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
35718c4a8e55Smrg	$ECHO "\
3572b042e37fSmrg*** ERROR, $lockfile contains:
3573b042e37fSmrg`cat $lockfile 2>/dev/null`
3574b042e37fSmrg
3575b042e37fSmrgbut it should contain:
3576b042e37fSmrg$srcfile
3577b042e37fSmrg
3578b042e37fSmrgThis indicates that another process is trying to use the same
3579b042e37fSmrgtemporary object file, and libtool could not work around it because
35803169be4bSmrgyour compiler does not support '-c' and '-o' together.  If you
3581b042e37fSmrgrepeat this compilation, it may succeed, by chance, but you had better
3582b042e37fSmrgavoid parallel builds (make -j) in this platform, or get a better
3583b042e37fSmrgcompiler."
3584b042e37fSmrg
35858c4a8e55Smrg	$opt_dry_run || $RM $removelist
3586b042e37fSmrg	exit $EXIT_FAILURE
3587b042e37fSmrg      fi
3588b042e37fSmrg
3589b042e37fSmrg      # Just move the object if needed
3590b042e37fSmrg      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
35918c4a8e55Smrg	func_show_eval '$MV "$output_obj" "$obj"' \
35928c4a8e55Smrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
3593b042e37fSmrg      fi
35948c4a8e55Smrg    fi
3595b042e37fSmrg
35968c4a8e55Smrg    $opt_dry_run || {
35978c4a8e55Smrg      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
3598b042e37fSmrg
35998c4a8e55Smrg      # Unlock the critical section if it was locked
36003169be4bSmrg      if test no != "$need_locks"; then
36018c4a8e55Smrg	removelist=$lockfile
36028c4a8e55Smrg        $RM "$lockfile"
36038c4a8e55Smrg      fi
36048c4a8e55Smrg    }
3605b042e37fSmrg
36068c4a8e55Smrg    exit $EXIT_SUCCESS
36078c4a8e55Smrg}
3608b042e37fSmrg
36098c4a8e55Smrg$opt_help || {
36103169be4bSmrg  test compile = "$opt_mode" && func_mode_compile ${1+"$@"}
36118c4a8e55Smrg}
3612b042e37fSmrg
36138c4a8e55Smrgfunc_mode_help ()
36148c4a8e55Smrg{
36158c4a8e55Smrg    # We need to display help for each of the modes.
3616bd23fbfaSmrg    case $opt_mode in
36178c4a8e55Smrg      "")
36188c4a8e55Smrg        # Generic help is extracted from the usage comments
36198c4a8e55Smrg        # at the start of this file.
36208c4a8e55Smrg        func_help
36218c4a8e55Smrg        ;;
3622b042e37fSmrg
36238c4a8e55Smrg      clean)
36248c4a8e55Smrg        $ECHO \
36258c4a8e55Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
3626b042e37fSmrg
36278c4a8e55SmrgRemove files from the build directory.
3628b042e37fSmrg
36298c4a8e55SmrgRM is the name of the program to use to delete files associated with each FILE
36303169be4bSmrg(typically '/bin/rm').  RM-OPTIONS are options (such as '-f') to be passed
36318c4a8e55Smrgto RM.
3632b042e37fSmrg
36338c4a8e55SmrgIf FILE is a libtool library, object or program, all the files associated
36348c4a8e55Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM."
36358c4a8e55Smrg        ;;
3636b042e37fSmrg
36378c4a8e55Smrg      compile)
36388c4a8e55Smrg      $ECHO \
36398c4a8e55Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
3640b042e37fSmrg
36418c4a8e55SmrgCompile a source file into a libtool library object.
3642b042e37fSmrg
36438c4a8e55SmrgThis mode accepts the following additional options:
3644b042e37fSmrg
36458c4a8e55Smrg  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
36468c4a8e55Smrg  -no-suppress      do not suppress compiler output for multiple passes
3647706b6b52Smrg  -prefer-pic       try to build PIC objects only
3648706b6b52Smrg  -prefer-non-pic   try to build non-PIC objects only
36493169be4bSmrg  -shared           do not build a '.o' file suitable for static linking
36503169be4bSmrg  -static           only build a '.o' file suitable for static linking
3651706b6b52Smrg  -Wc,FLAG          pass FLAG directly to the compiler
3652b042e37fSmrg
36533169be4bSmrgCOMPILE-COMMAND is a command to be used in creating a 'standard' object file
36548c4a8e55Smrgfrom the given SOURCEFILE.
3655b042e37fSmrg
36568c4a8e55SmrgThe output file name is determined by removing the directory component from
36573169be4bSmrgSOURCEFILE, then substituting the C source code suffix '.c' with the
36583169be4bSmrglibrary object suffix, '.lo'."
36598c4a8e55Smrg        ;;
3660b042e37fSmrg
36618c4a8e55Smrg      execute)
36628c4a8e55Smrg        $ECHO \
36638c4a8e55Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
3664b042e37fSmrg
36658c4a8e55SmrgAutomatically set library path, then run a program.
3666b042e37fSmrg
36678c4a8e55SmrgThis mode accepts the following additional options:
3668b042e37fSmrg
36698c4a8e55Smrg  -dlopen FILE      add the directory containing FILE to the library path
3670b042e37fSmrg
36713169be4bSmrgThis mode sets the library path environment variable according to '-dlopen'
36728c4a8e55Smrgflags.
3673b042e37fSmrg
36748c4a8e55SmrgIf any of the ARGS are libtool executable wrappers, then they are translated
36758c4a8e55Smrginto their corresponding uninstalled binary, and any of their required library
36768c4a8e55Smrgdirectories are added to the library path.
3677b042e37fSmrg
36788c4a8e55SmrgThen, COMMAND is executed, with ARGS as arguments."
36798c4a8e55Smrg        ;;
3680b042e37fSmrg
36818c4a8e55Smrg      finish)
36828c4a8e55Smrg        $ECHO \
36838c4a8e55Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
3684b042e37fSmrg
36858c4a8e55SmrgComplete the installation of libtool libraries.
3686b042e37fSmrg
36878c4a8e55SmrgEach LIBDIR is a directory that contains libtool libraries.
3688b042e37fSmrg
36898c4a8e55SmrgThe commands that this mode executes may require superuser privileges.  Use
36903169be4bSmrgthe '--dry-run' option if you just want to see what would be executed."
36918c4a8e55Smrg        ;;
3692b042e37fSmrg
36938c4a8e55Smrg      install)
36948c4a8e55Smrg        $ECHO \
36958c4a8e55Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
3696b042e37fSmrg
36978c4a8e55SmrgInstall executables or libraries.
3698b042e37fSmrg
36998c4a8e55SmrgINSTALL-COMMAND is the installation command.  The first component should be
37003169be4bSmrgeither the 'install' or 'cp' program.
3701b042e37fSmrg
37028c4a8e55SmrgThe following components of INSTALL-COMMAND are treated specially:
3703b042e37fSmrg
3704706b6b52Smrg  -inst-prefix-dir PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
3705b042e37fSmrg
37068c4a8e55SmrgThe rest of the components are interpreted as arguments to that command (only
37078c4a8e55SmrgBSD-compatible install options are recognized)."
37088c4a8e55Smrg        ;;
3709b042e37fSmrg
37108c4a8e55Smrg      link)
37118c4a8e55Smrg        $ECHO \
37128c4a8e55Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
3713b042e37fSmrg
37148c4a8e55SmrgLink object files or libraries together to form another library, or to
37158c4a8e55Smrgcreate an executable program.
3716b042e37fSmrg
37178c4a8e55SmrgLINK-COMMAND is a command using the C compiler that you would use to create
37188c4a8e55Smrga program from several object files.
3719b042e37fSmrg
37208c4a8e55SmrgThe following components of LINK-COMMAND are treated specially:
3721b042e37fSmrg
37228c4a8e55Smrg  -all-static       do not do any dynamic linking at all
37238c4a8e55Smrg  -avoid-version    do not add a version suffix if possible
3724706b6b52Smrg  -bindir BINDIR    specify path to binaries directory (for systems where
3725706b6b52Smrg                    libraries must be found in the PATH setting at runtime)
37263169be4bSmrg  -dlopen FILE      '-dlpreopen' FILE if it cannot be dlopened at runtime
37278c4a8e55Smrg  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
37288c4a8e55Smrg  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
37298c4a8e55Smrg  -export-symbols SYMFILE
37308c4a8e55Smrg                    try to export only the symbols listed in SYMFILE
37318c4a8e55Smrg  -export-symbols-regex REGEX
37328c4a8e55Smrg                    try to export only the symbols matching REGEX
37338c4a8e55Smrg  -LLIBDIR          search LIBDIR for required installed libraries
37348c4a8e55Smrg  -lNAME            OUTPUT-FILE requires the installed library libNAME
37358c4a8e55Smrg  -module           build a library that can dlopened
37368c4a8e55Smrg  -no-fast-install  disable the fast-install mode
37378c4a8e55Smrg  -no-install       link a not-installable executable
37388c4a8e55Smrg  -no-undefined     declare that a library does not refer to external symbols
37398c4a8e55Smrg  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
37403169be4bSmrg  -objectlist FILE  use a list of object files found in FILE to specify objects
37413169be4bSmrg  -os2dllname NAME  force a short DLL name on OS/2 (no effect on other OSes)
37428c4a8e55Smrg  -precious-files-regex REGEX
37438c4a8e55Smrg                    don't remove output files matching REGEX
37448c4a8e55Smrg  -release RELEASE  specify package release information
37458c4a8e55Smrg  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
37468c4a8e55Smrg  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
37478c4a8e55Smrg  -shared           only do dynamic linking of libtool libraries
37488c4a8e55Smrg  -shrext SUFFIX    override the standard shared library file extension
37498c4a8e55Smrg  -static           do not do any dynamic linking of uninstalled libtool libraries
37508c4a8e55Smrg  -static-libtool-libs
37518c4a8e55Smrg                    do not do any dynamic linking of libtool libraries
37528c4a8e55Smrg  -version-info CURRENT[:REVISION[:AGE]]
37538c4a8e55Smrg                    specify library version info [each variable defaults to 0]
37548c4a8e55Smrg  -weak LIBNAME     declare that the target provides the LIBNAME interface
3755706b6b52Smrg  -Wc,FLAG
3756706b6b52Smrg  -Xcompiler FLAG   pass linker-specific FLAG directly to the compiler
3757706b6b52Smrg  -Wl,FLAG
3758706b6b52Smrg  -Xlinker FLAG     pass linker-specific FLAG directly to the linker
3759706b6b52Smrg  -XCClinker FLAG   pass link-specific FLAG to the compiler driver (CC)
3760b042e37fSmrg
37613169be4bSmrgAll other options (arguments beginning with '-') are ignored.
3762b042e37fSmrg
37633169be4bSmrgEvery other argument is treated as a filename.  Files ending in '.la' are
37648c4a8e55Smrgtreated as uninstalled libtool libraries, other files are standard or library
37658c4a8e55Smrgobject files.
3766b042e37fSmrg
37673169be4bSmrgIf the OUTPUT-FILE ends in '.la', then a libtool library is created,
37683169be4bSmrgonly library objects ('.lo' files) may be specified, and '-rpath' is
37698c4a8e55Smrgrequired, except when creating a convenience library.
3770b042e37fSmrg
37713169be4bSmrgIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created
37723169be4bSmrgusing 'ar' and 'ranlib', or on Windows using 'lib'.
3773b042e37fSmrg
37743169be4bSmrgIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file
37758c4a8e55Smrgis created, otherwise an executable program is created."
37768c4a8e55Smrg        ;;
3777b042e37fSmrg
37788c4a8e55Smrg      uninstall)
37798c4a8e55Smrg        $ECHO \
37808c4a8e55Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
3781b042e37fSmrg
37828c4a8e55SmrgRemove libraries from an installation directory.
3783b042e37fSmrg
37848c4a8e55SmrgRM is the name of the program to use to delete files associated with each FILE
37853169be4bSmrg(typically '/bin/rm').  RM-OPTIONS are options (such as '-f') to be passed
37868c4a8e55Smrgto RM.
3787b042e37fSmrg
37888c4a8e55SmrgIf FILE is a libtool library, all the files associated with it are deleted.
37898c4a8e55SmrgOtherwise, only FILE itself is deleted using RM."
3790b042e37fSmrg        ;;
3791b042e37fSmrg
37928c4a8e55Smrg      *)
37933169be4bSmrg        func_fatal_help "invalid operation mode '$opt_mode'"
37948c4a8e55Smrg        ;;
37958c4a8e55Smrg    esac
3796b042e37fSmrg
3797706b6b52Smrg    echo
37983169be4bSmrg    $ECHO "Try '$progname --help' for more information about other modes."
37998c4a8e55Smrg}
3800b042e37fSmrg
3801706b6b52Smrg# Now that we've collected a possible --mode arg, show help if necessary
3802706b6b52Smrgif $opt_help; then
38033169be4bSmrg  if test : = "$opt_help"; then
3804706b6b52Smrg    func_mode_help
3805706b6b52Smrg  else
3806706b6b52Smrg    {
3807706b6b52Smrg      func_help noexit
3808bd23fbfaSmrg      for opt_mode in compile link execute install finish uninstall clean; do
3809706b6b52Smrg	func_mode_help
3810706b6b52Smrg      done
38113169be4bSmrg    } | $SED -n '1p; 2,$s/^Usage:/  or: /p'
3812706b6b52Smrg    {
3813706b6b52Smrg      func_help noexit
3814bd23fbfaSmrg      for opt_mode in compile link execute install finish uninstall clean; do
3815706b6b52Smrg	echo
3816706b6b52Smrg	func_mode_help
3817706b6b52Smrg      done
3818706b6b52Smrg    } |
38193169be4bSmrg    $SED '1d
3820706b6b52Smrg      /^When reporting/,/^Report/{
3821706b6b52Smrg	H
3822706b6b52Smrg	d
3823706b6b52Smrg      }
3824706b6b52Smrg      $x
3825706b6b52Smrg      /information about other modes/d
3826706b6b52Smrg      /more detailed .*MODE/d
3827706b6b52Smrg      s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
3828706b6b52Smrg  fi
3829706b6b52Smrg  exit $?
3830706b6b52Smrgfi
3831b042e37fSmrg
3832b042e37fSmrg
38338c4a8e55Smrg# func_mode_execute arg...
38348c4a8e55Smrgfunc_mode_execute ()
38358c4a8e55Smrg{
38363169be4bSmrg    $debug_cmd
38373169be4bSmrg
38388c4a8e55Smrg    # The first argument is the command name.
38393169be4bSmrg    cmd=$nonopt
38408c4a8e55Smrg    test -z "$cmd" && \
38418c4a8e55Smrg      func_fatal_help "you must specify a COMMAND"
3842b042e37fSmrg
38438c4a8e55Smrg    # Handle -dlopen flags immediately.
3844bd23fbfaSmrg    for file in $opt_dlopen; do
38458c4a8e55Smrg      test -f "$file" \
38463169be4bSmrg	|| func_fatal_help "'$file' is not a file"
3847b042e37fSmrg
38488c4a8e55Smrg      dir=
38498c4a8e55Smrg      case $file in
38508c4a8e55Smrg      *.la)
3851bd23fbfaSmrg	func_resolve_sysroot "$file"
3852bd23fbfaSmrg	file=$func_resolve_sysroot_result
3853bd23fbfaSmrg
38548c4a8e55Smrg	# Check to see that this really is a libtool archive.
38558c4a8e55Smrg	func_lalib_unsafe_p "$file" \
38563169be4bSmrg	  || func_fatal_help "'$lib' is not a valid libtool archive"
3857b042e37fSmrg
38588c4a8e55Smrg	# Read the libtool library.
38598c4a8e55Smrg	dlname=
38608c4a8e55Smrg	library_names=
38618c4a8e55Smrg	func_source "$file"
3862b042e37fSmrg
38638c4a8e55Smrg	# Skip this library if it cannot be dlopened.
38648c4a8e55Smrg	if test -z "$dlname"; then
38658c4a8e55Smrg	  # Warn if it was a shared library.
38668c4a8e55Smrg	  test -n "$library_names" && \
38673169be4bSmrg	    func_warning "'$file' was not linked with '-export-dynamic'"
38688c4a8e55Smrg	  continue
38698c4a8e55Smrg	fi
3870b042e37fSmrg
38718c4a8e55Smrg	func_dirname "$file" "" "."
38723169be4bSmrg	dir=$func_dirname_result
3873b042e37fSmrg
38748c4a8e55Smrg	if test -f "$dir/$objdir/$dlname"; then
3875bd23fbfaSmrg	  func_append dir "/$objdir"
38768c4a8e55Smrg	else
38778c4a8e55Smrg	  if test ! -f "$dir/$dlname"; then
38783169be4bSmrg	    func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'"
38798c4a8e55Smrg	  fi
38808c4a8e55Smrg	fi
3881b042e37fSmrg	;;
3882b042e37fSmrg
38838c4a8e55Smrg      *.lo)
38848c4a8e55Smrg	# Just add the directory containing the .lo file.
38858c4a8e55Smrg	func_dirname "$file" "" "."
38863169be4bSmrg	dir=$func_dirname_result
3887b042e37fSmrg	;;
3888b042e37fSmrg
38898c4a8e55Smrg      *)
38903169be4bSmrg	func_warning "'-dlopen' is ignored for non-libtool libraries and objects"
3891b042e37fSmrg	continue
3892b042e37fSmrg	;;
38938c4a8e55Smrg      esac
3894b042e37fSmrg
38958c4a8e55Smrg      # Get the absolute pathname.
38968c4a8e55Smrg      absdir=`cd "$dir" && pwd`
38973169be4bSmrg      test -n "$absdir" && dir=$absdir
3898b042e37fSmrg
38998c4a8e55Smrg      # Now add the directory to shlibpath_var.
39008c4a8e55Smrg      if eval "test -z \"\$$shlibpath_var\""; then
39018c4a8e55Smrg	eval "$shlibpath_var=\"\$dir\""
39028c4a8e55Smrg      else
39038c4a8e55Smrg	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
39048c4a8e55Smrg      fi
39058c4a8e55Smrg    done
3906b042e37fSmrg
39078c4a8e55Smrg    # This variable tells wrapper scripts just to set shlibpath_var
39088c4a8e55Smrg    # rather than running their programs.
39093169be4bSmrg    libtool_execute_magic=$magic
3910b042e37fSmrg
39118c4a8e55Smrg    # Check if any of the arguments is a wrapper script.
39128c4a8e55Smrg    args=
39138c4a8e55Smrg    for file
39148c4a8e55Smrg    do
39158c4a8e55Smrg      case $file in
3916706b6b52Smrg      -* | *.la | *.lo ) ;;
39178c4a8e55Smrg      *)
39188c4a8e55Smrg	# Do a test to see if this is really a libtool program.
39198c4a8e55Smrg	if func_ltwrapper_script_p "$file"; then
39208c4a8e55Smrg	  func_source "$file"
39218c4a8e55Smrg	  # Transform arg to wrapped name.
39223169be4bSmrg	  file=$progdir/$program
39238c4a8e55Smrg	elif func_ltwrapper_executable_p "$file"; then
39248c4a8e55Smrg	  func_ltwrapper_scriptname "$file"
39258c4a8e55Smrg	  func_source "$func_ltwrapper_scriptname_result"
39268c4a8e55Smrg	  # Transform arg to wrapped name.
39273169be4bSmrg	  file=$progdir/$program
39288c4a8e55Smrg	fi
3929b042e37fSmrg	;;
39308c4a8e55Smrg      esac
39318c4a8e55Smrg      # Quote arguments (to preserve shell metacharacters).
3932bd23fbfaSmrg      func_append_quoted args "$file"
39338c4a8e55Smrg    done
3934b042e37fSmrg
39353169be4bSmrg    if $opt_dry_run; then
39363169be4bSmrg      # Display what would be done.
39373169be4bSmrg      if test -n "$shlibpath_var"; then
39383169be4bSmrg	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
39393169be4bSmrg	echo "export $shlibpath_var"
39403169be4bSmrg      fi
39413169be4bSmrg      $ECHO "$cmd$args"
39423169be4bSmrg      exit $EXIT_SUCCESS
39433169be4bSmrg    else
39448c4a8e55Smrg      if test -n "$shlibpath_var"; then
39458c4a8e55Smrg	# Export the shlibpath_var.
39468c4a8e55Smrg	eval "export $shlibpath_var"
39478c4a8e55Smrg      fi
3948b042e37fSmrg
39498c4a8e55Smrg      # Restore saved environment variables
39508c4a8e55Smrg      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
39518c4a8e55Smrg      do
39528c4a8e55Smrg	eval "if test \"\${save_$lt_var+set}\" = set; then
39538c4a8e55Smrg                $lt_var=\$save_$lt_var; export $lt_var
39548c4a8e55Smrg	      else
39558c4a8e55Smrg		$lt_unset $lt_var
39568c4a8e55Smrg	      fi"
39578c4a8e55Smrg      done
3958b042e37fSmrg
39598c4a8e55Smrg      # Now prepare to actually exec the command.
39603169be4bSmrg      exec_cmd=\$cmd$args
39618c4a8e55Smrg    fi
39628c4a8e55Smrg}
3963b042e37fSmrg
39643169be4bSmrgtest execute = "$opt_mode" && func_mode_execute ${1+"$@"}
3965b042e37fSmrg
3966b042e37fSmrg
39678c4a8e55Smrg# func_mode_finish arg...
39688c4a8e55Smrgfunc_mode_finish ()
39698c4a8e55Smrg{
39703169be4bSmrg    $debug_cmd
39713169be4bSmrg
3972bd23fbfaSmrg    libs=
3973bd23fbfaSmrg    libdirs=
39748c4a8e55Smrg    admincmds=
3975b042e37fSmrg
3976bd23fbfaSmrg    for opt in "$nonopt" ${1+"$@"}
3977bd23fbfaSmrg    do
3978bd23fbfaSmrg      if test -d "$opt"; then
3979bd23fbfaSmrg	func_append libdirs " $opt"
3980bd23fbfaSmrg
3981bd23fbfaSmrg      elif test -f "$opt"; then
3982bd23fbfaSmrg	if func_lalib_unsafe_p "$opt"; then
3983bd23fbfaSmrg	  func_append libs " $opt"
3984bd23fbfaSmrg	else
39853169be4bSmrg	  func_warning "'$opt' is not a valid libtool archive"
3986bd23fbfaSmrg	fi
3987bd23fbfaSmrg
3988bd23fbfaSmrg      else
39893169be4bSmrg	func_fatal_error "invalid argument '$opt'"
3990bd23fbfaSmrg      fi
3991bd23fbfaSmrg    done
3992bd23fbfaSmrg
3993bd23fbfaSmrg    if test -n "$libs"; then
3994bd23fbfaSmrg      if test -n "$lt_sysroot"; then
3995bd23fbfaSmrg        sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
3996bd23fbfaSmrg        sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
3997bd23fbfaSmrg      else
3998bd23fbfaSmrg        sysroot_cmd=
3999bd23fbfaSmrg      fi
4000bd23fbfaSmrg
4001bd23fbfaSmrg      # Remove sysroot references
4002bd23fbfaSmrg      if $opt_dry_run; then
4003bd23fbfaSmrg        for lib in $libs; do
40043169be4bSmrg          echo "removing references to $lt_sysroot and '=' prefixes from $lib"
4005bd23fbfaSmrg        done
4006bd23fbfaSmrg      else
4007bd23fbfaSmrg        tmpdir=`func_mktempdir`
4008bd23fbfaSmrg        for lib in $libs; do
40093169be4bSmrg	  $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
4010bd23fbfaSmrg	    > $tmpdir/tmp-la
4011bd23fbfaSmrg	  mv -f $tmpdir/tmp-la $lib
4012bd23fbfaSmrg	done
4013bd23fbfaSmrg        ${RM}r "$tmpdir"
4014bd23fbfaSmrg      fi
4015bd23fbfaSmrg    fi
4016b042e37fSmrg
4017bd23fbfaSmrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
40188c4a8e55Smrg      for libdir in $libdirs; do
40198c4a8e55Smrg	if test -n "$finish_cmds"; then
40208c4a8e55Smrg	  # Do each command in the finish commands.
40218c4a8e55Smrg	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
40228c4a8e55Smrg'"$cmd"'"'
40238c4a8e55Smrg	fi
40248c4a8e55Smrg	if test -n "$finish_eval"; then
40258c4a8e55Smrg	  # Do the single finish_eval.
40268c4a8e55Smrg	  eval cmds=\"$finish_eval\"
4027bd23fbfaSmrg	  $opt_dry_run || eval "$cmds" || func_append admincmds "
40288c4a8e55Smrg       $cmds"
40298c4a8e55Smrg	fi
40308c4a8e55Smrg      done
40318c4a8e55Smrg    fi
4032b042e37fSmrg
40338c4a8e55Smrg    # Exit here if they wanted silent mode.
40343169be4bSmrg    $opt_quiet && exit $EXIT_SUCCESS
4035b042e37fSmrg
4036bd23fbfaSmrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
4037bd23fbfaSmrg      echo "----------------------------------------------------------------------"
4038bd23fbfaSmrg      echo "Libraries have been installed in:"
4039bd23fbfaSmrg      for libdir in $libdirs; do
4040bd23fbfaSmrg	$ECHO "   $libdir"
4041bd23fbfaSmrg      done
4042bd23fbfaSmrg      echo
4043bd23fbfaSmrg      echo "If you ever happen to want to link against installed libraries"
4044bd23fbfaSmrg      echo "in a given directory, LIBDIR, you must either use libtool, and"
40453169be4bSmrg      echo "specify the full pathname of the library, or use the '-LLIBDIR'"
4046bd23fbfaSmrg      echo "flag during linking and do at least one of the following:"
4047bd23fbfaSmrg      if test -n "$shlibpath_var"; then
40483169be4bSmrg	echo "   - add LIBDIR to the '$shlibpath_var' environment variable"
4049bd23fbfaSmrg	echo "     during execution"
4050bd23fbfaSmrg      fi
4051bd23fbfaSmrg      if test -n "$runpath_var"; then
40523169be4bSmrg	echo "   - add LIBDIR to the '$runpath_var' environment variable"
4053bd23fbfaSmrg	echo "     during linking"
4054bd23fbfaSmrg      fi
4055bd23fbfaSmrg      if test -n "$hardcode_libdir_flag_spec"; then
4056bd23fbfaSmrg	libdir=LIBDIR
4057bd23fbfaSmrg	eval flag=\"$hardcode_libdir_flag_spec\"
4058b042e37fSmrg
40593169be4bSmrg	$ECHO "   - use the '$flag' linker flag"
4060bd23fbfaSmrg      fi
4061bd23fbfaSmrg      if test -n "$admincmds"; then
4062bd23fbfaSmrg	$ECHO "   - have your system administrator run these commands:$admincmds"
4063bd23fbfaSmrg      fi
4064bd23fbfaSmrg      if test -f /etc/ld.so.conf; then
40653169be4bSmrg	echo "   - have your system administrator add LIBDIR to '/etc/ld.so.conf'"
4066bd23fbfaSmrg      fi
4067bd23fbfaSmrg      echo
4068b042e37fSmrg
4069bd23fbfaSmrg      echo "See any operating system documentation about shared libraries for"
4070bd23fbfaSmrg      case $host in
4071bd23fbfaSmrg	solaris2.[6789]|solaris2.1[0-9])
4072bd23fbfaSmrg	  echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
4073bd23fbfaSmrg	  echo "pages."
4074bd23fbfaSmrg	  ;;
4075bd23fbfaSmrg	*)
4076bd23fbfaSmrg	  echo "more information, such as the ld(1) and ld.so(8) manual pages."
4077bd23fbfaSmrg	  ;;
4078bd23fbfaSmrg      esac
4079bd23fbfaSmrg      echo "----------------------------------------------------------------------"
4080bd23fbfaSmrg    fi
40818c4a8e55Smrg    exit $EXIT_SUCCESS
40828c4a8e55Smrg}
4083b042e37fSmrg
40843169be4bSmrgtest finish = "$opt_mode" && func_mode_finish ${1+"$@"}
4085b042e37fSmrg
4086b042e37fSmrg
40878c4a8e55Smrg# func_mode_install arg...
40888c4a8e55Smrgfunc_mode_install ()
40898c4a8e55Smrg{
40903169be4bSmrg    $debug_cmd
40913169be4bSmrg
40928c4a8e55Smrg    # There may be an optional sh(1) argument at the beginning of
40938c4a8e55Smrg    # install_prog (especially on Windows NT).
40943169be4bSmrg    if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" ||
40958c4a8e55Smrg       # Allow the use of GNU shtool's install command.
40963169be4bSmrg       case $nonopt in *shtool*) :;; *) false;; esac
40973169be4bSmrg    then
40988c4a8e55Smrg      # Aesthetically quote it.
40998c4a8e55Smrg      func_quote_for_eval "$nonopt"
41008c4a8e55Smrg      install_prog="$func_quote_for_eval_result "
41018c4a8e55Smrg      arg=$1
41028c4a8e55Smrg      shift
41038c4a8e55Smrg    else
41048c4a8e55Smrg      install_prog=
41058c4a8e55Smrg      arg=$nonopt
41068c4a8e55Smrg    fi
41078c4a8e55Smrg
41088c4a8e55Smrg    # The real first argument should be the name of the installation program.
41098c4a8e55Smrg    # Aesthetically quote it.
41108c4a8e55Smrg    func_quote_for_eval "$arg"
4111bd23fbfaSmrg    func_append install_prog "$func_quote_for_eval_result"
4112706b6b52Smrg    install_shared_prog=$install_prog
4113706b6b52Smrg    case " $install_prog " in
4114706b6b52Smrg      *[\\\ /]cp\ *) install_cp=: ;;
4115706b6b52Smrg      *) install_cp=false ;;
4116706b6b52Smrg    esac
41178c4a8e55Smrg
41188c4a8e55Smrg    # We need to accept at least all the BSD install flags.
41198c4a8e55Smrg    dest=
41208c4a8e55Smrg    files=
41218c4a8e55Smrg    opts=
41228c4a8e55Smrg    prev=
41238c4a8e55Smrg    install_type=
41243169be4bSmrg    isdir=false
41258c4a8e55Smrg    stripme=
4126706b6b52Smrg    no_mode=:
41278c4a8e55Smrg    for arg
41288c4a8e55Smrg    do
4129706b6b52Smrg      arg2=
41308c4a8e55Smrg      if test -n "$dest"; then
4131bd23fbfaSmrg	func_append files " $dest"
41328c4a8e55Smrg	dest=$arg
4133b042e37fSmrg	continue
41348c4a8e55Smrg      fi
4135b042e37fSmrg
41368c4a8e55Smrg      case $arg in
41373169be4bSmrg      -d) isdir=: ;;
41388c4a8e55Smrg      -f)
4139706b6b52Smrg	if $install_cp; then :; else
4140706b6b52Smrg	  prev=$arg
4141706b6b52Smrg	fi
4142b042e37fSmrg	;;
41438c4a8e55Smrg      -g | -m | -o)
41448c4a8e55Smrg	prev=$arg
41458c4a8e55Smrg	;;
41468c4a8e55Smrg      -s)
41478c4a8e55Smrg	stripme=" -s"
41488c4a8e55Smrg	continue
41498c4a8e55Smrg	;;
41508c4a8e55Smrg      -*)
41518c4a8e55Smrg	;;
41528c4a8e55Smrg      *)
41538c4a8e55Smrg	# If the previous option needed an argument, then skip it.
41548c4a8e55Smrg	if test -n "$prev"; then
41553169be4bSmrg	  if test X-m = "X$prev" && test -n "$install_override_mode"; then
4156706b6b52Smrg	    arg2=$install_override_mode
4157706b6b52Smrg	    no_mode=false
4158706b6b52Smrg	  fi
41598c4a8e55Smrg	  prev=
41608c4a8e55Smrg	else
41618c4a8e55Smrg	  dest=$arg
41628c4a8e55Smrg	  continue
41638c4a8e55Smrg	fi
41648c4a8e55Smrg	;;
41658c4a8e55Smrg      esac
4166b042e37fSmrg
41678c4a8e55Smrg      # Aesthetically quote the argument.
41688c4a8e55Smrg      func_quote_for_eval "$arg"
4169bd23fbfaSmrg      func_append install_prog " $func_quote_for_eval_result"
4170706b6b52Smrg      if test -n "$arg2"; then
4171706b6b52Smrg	func_quote_for_eval "$arg2"
4172706b6b52Smrg      fi
4173bd23fbfaSmrg      func_append install_shared_prog " $func_quote_for_eval_result"
41748c4a8e55Smrg    done
4175b042e37fSmrg
41768c4a8e55Smrg    test -z "$install_prog" && \
41778c4a8e55Smrg      func_fatal_help "you must specify an install program"
4178b042e37fSmrg
41798c4a8e55Smrg    test -n "$prev" && \
41803169be4bSmrg      func_fatal_help "the '$prev' option requires an argument"
41818c4a8e55Smrg
4182706b6b52Smrg    if test -n "$install_override_mode" && $no_mode; then
4183706b6b52Smrg      if $install_cp; then :; else
4184706b6b52Smrg	func_quote_for_eval "$install_override_mode"
4185bd23fbfaSmrg	func_append install_shared_prog " -m $func_quote_for_eval_result"
4186706b6b52Smrg      fi
4187706b6b52Smrg    fi
4188706b6b52Smrg
41898c4a8e55Smrg    if test -z "$files"; then
41908c4a8e55Smrg      if test -z "$dest"; then
41918c4a8e55Smrg	func_fatal_help "no file or destination specified"
41928c4a8e55Smrg      else
41938c4a8e55Smrg	func_fatal_help "you must specify a destination"
41948c4a8e55Smrg      fi
4195b042e37fSmrg    fi
4196b042e37fSmrg
41978c4a8e55Smrg    # Strip any trailing slash from the destination.
41988c4a8e55Smrg    func_stripname '' '/' "$dest"
41998c4a8e55Smrg    dest=$func_stripname_result
4200b042e37fSmrg
42018c4a8e55Smrg    # Check to see that the destination is a directory.
42023169be4bSmrg    test -d "$dest" && isdir=:
42033169be4bSmrg    if $isdir; then
42043169be4bSmrg      destdir=$dest
42058c4a8e55Smrg      destname=
4206b042e37fSmrg    else
42078c4a8e55Smrg      func_dirname_and_basename "$dest" "" "."
42083169be4bSmrg      destdir=$func_dirname_result
42093169be4bSmrg      destname=$func_basename_result
4210b042e37fSmrg
42118c4a8e55Smrg      # Not a directory, so check to see that there is only one file specified.
42128c4a8e55Smrg      set dummy $files; shift
42138c4a8e55Smrg      test "$#" -gt 1 && \
42143169be4bSmrg	func_fatal_help "'$dest' is not a directory"
4215b042e37fSmrg    fi
42168c4a8e55Smrg    case $destdir in
42178c4a8e55Smrg    [\\/]* | [A-Za-z]:[\\/]*) ;;
4218b042e37fSmrg    *)
42198c4a8e55Smrg      for file in $files; do
42208c4a8e55Smrg	case $file in
42218c4a8e55Smrg	*.lo) ;;
42228c4a8e55Smrg	*)
42233169be4bSmrg	  func_fatal_help "'$destdir' must be an absolute directory name"
42248c4a8e55Smrg	  ;;
42258c4a8e55Smrg	esac
42268c4a8e55Smrg      done
4227b042e37fSmrg      ;;
4228b042e37fSmrg    esac
4229b042e37fSmrg
42308c4a8e55Smrg    # This variable tells wrapper scripts just to set variables rather
42318c4a8e55Smrg    # than running their programs.
42323169be4bSmrg    libtool_install_magic=$magic
4233b042e37fSmrg
42348c4a8e55Smrg    staticlibs=
42358c4a8e55Smrg    future_libdirs=
42368c4a8e55Smrg    current_libdirs=
42378c4a8e55Smrg    for file in $files; do
4238b042e37fSmrg
42398c4a8e55Smrg      # Do each installation.
42408c4a8e55Smrg      case $file in
42418c4a8e55Smrg      *.$libext)
42428c4a8e55Smrg	# Do the static libraries later.
4243bd23fbfaSmrg	func_append staticlibs " $file"
42448c4a8e55Smrg	;;
42458c4a8e55Smrg
42468c4a8e55Smrg      *.la)
4247bd23fbfaSmrg	func_resolve_sysroot "$file"
4248bd23fbfaSmrg	file=$func_resolve_sysroot_result
4249bd23fbfaSmrg
42508c4a8e55Smrg	# Check to see that this really is a libtool archive.
42518c4a8e55Smrg	func_lalib_unsafe_p "$file" \
42523169be4bSmrg	  || func_fatal_help "'$file' is not a valid libtool archive"
42538c4a8e55Smrg
42548c4a8e55Smrg	library_names=
42558c4a8e55Smrg	old_library=
42568c4a8e55Smrg	relink_command=
42578c4a8e55Smrg	func_source "$file"
42588c4a8e55Smrg
42598c4a8e55Smrg	# Add the libdir to current_libdirs if it is the destination.
42608c4a8e55Smrg	if test "X$destdir" = "X$libdir"; then
42618c4a8e55Smrg	  case "$current_libdirs " in
42628c4a8e55Smrg	  *" $libdir "*) ;;
4263bd23fbfaSmrg	  *) func_append current_libdirs " $libdir" ;;
4264b042e37fSmrg	  esac
42658c4a8e55Smrg	else
42668c4a8e55Smrg	  # Note the libdir as a future libdir.
42678c4a8e55Smrg	  case "$future_libdirs " in
42688c4a8e55Smrg	  *" $libdir "*) ;;
4269bd23fbfaSmrg	  *) func_append future_libdirs " $libdir" ;;
42708c4a8e55Smrg	  esac
42718c4a8e55Smrg	fi
4272b042e37fSmrg
42738c4a8e55Smrg	func_dirname "$file" "/" ""
42743169be4bSmrg	dir=$func_dirname_result
4275bd23fbfaSmrg	func_append dir "$objdir"
42768c4a8e55Smrg
42778c4a8e55Smrg	if test -n "$relink_command"; then
42788c4a8e55Smrg	  # Determine the prefix the user has applied to our future dir.
4279706b6b52Smrg	  inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
42808c4a8e55Smrg
42818c4a8e55Smrg	  # Don't allow the user to place us outside of our expected
42828c4a8e55Smrg	  # location b/c this prevents finding dependent libraries that
42838c4a8e55Smrg	  # are installed to the same prefix.
42848c4a8e55Smrg	  # At present, this check doesn't affect windows .dll's that
42858c4a8e55Smrg	  # are installed into $libdir/../bin (currently, that works fine)
42868c4a8e55Smrg	  # but it's something to keep an eye on.
42878c4a8e55Smrg	  test "$inst_prefix_dir" = "$destdir" && \
42883169be4bSmrg	    func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir"
42898c4a8e55Smrg
42908c4a8e55Smrg	  if test -n "$inst_prefix_dir"; then
42918c4a8e55Smrg	    # Stick the inst_prefix_dir data into the link command.
4292706b6b52Smrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
42938c4a8e55Smrg	  else
4294706b6b52Smrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
42958c4a8e55Smrg	  fi
42968c4a8e55Smrg
42973169be4bSmrg	  func_warning "relinking '$file'"
42988c4a8e55Smrg	  func_show_eval "$relink_command" \
42993169be4bSmrg	    'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"'
43008c4a8e55Smrg	fi
43018c4a8e55Smrg
43028c4a8e55Smrg	# See the names of the shared library.
43038c4a8e55Smrg	set dummy $library_names; shift
43048c4a8e55Smrg	if test -n "$1"; then
43053169be4bSmrg	  realname=$1
43068c4a8e55Smrg	  shift
43078c4a8e55Smrg
43083169be4bSmrg	  srcname=$realname
43093169be4bSmrg	  test -n "$relink_command" && srcname=${realname}T
43108c4a8e55Smrg
43118c4a8e55Smrg	  # Install the shared library and build the symlinks.
4312706b6b52Smrg	  func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
43138c4a8e55Smrg	      'exit $?'
43143169be4bSmrg	  tstripme=$stripme
43158c4a8e55Smrg	  case $host_os in
43168c4a8e55Smrg	  cygwin* | mingw* | pw32* | cegcc*)
43178c4a8e55Smrg	    case $realname in
43188c4a8e55Smrg	    *.dll.a)
43193169be4bSmrg	      tstripme=
43203169be4bSmrg	      ;;
43213169be4bSmrg	    esac
43223169be4bSmrg	    ;;
43233169be4bSmrg	  os2*)
43243169be4bSmrg	    case $realname in
43253169be4bSmrg	    *_dll.a)
43263169be4bSmrg	      tstripme=
43278c4a8e55Smrg	      ;;
43288c4a8e55Smrg	    esac
4329b042e37fSmrg	    ;;
4330b042e37fSmrg	  esac
43318c4a8e55Smrg	  if test -n "$tstripme" && test -n "$striplib"; then
43328c4a8e55Smrg	    func_show_eval "$striplib $destdir/$realname" 'exit $?'
4333b042e37fSmrg	  fi
4334b042e37fSmrg
43358c4a8e55Smrg	  if test "$#" -gt 0; then
43368c4a8e55Smrg	    # Delete the old symlinks, and create new ones.
43373169be4bSmrg	    # Try 'ln -sf' first, because the 'ln' binary might depend on
43388c4a8e55Smrg	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
43398c4a8e55Smrg	    # so we also need to try rm && ln -s.
43408c4a8e55Smrg	    for linkname
43418c4a8e55Smrg	    do
43428c4a8e55Smrg	      test "$linkname" != "$realname" \
43438c4a8e55Smrg		&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
4344b042e37fSmrg	    done
4345b042e37fSmrg	  fi
4346b042e37fSmrg
43478c4a8e55Smrg	  # Do each command in the postinstall commands.
43483169be4bSmrg	  lib=$destdir/$realname
43498c4a8e55Smrg	  func_execute_cmds "$postinstall_cmds" 'exit $?'
4350b042e37fSmrg	fi
4351b042e37fSmrg
43528c4a8e55Smrg	# Install the pseudo-library for information purposes.
43538c4a8e55Smrg	func_basename "$file"
43543169be4bSmrg	name=$func_basename_result
43553169be4bSmrg	instname=$dir/${name}i
43568c4a8e55Smrg	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
4357b042e37fSmrg
43588c4a8e55Smrg	# Maybe install the static library, too.
4359bd23fbfaSmrg	test -n "$old_library" && func_append staticlibs " $dir/$old_library"
43608c4a8e55Smrg	;;
4361b042e37fSmrg
43628c4a8e55Smrg      *.lo)
43638c4a8e55Smrg	# Install (i.e. copy) a libtool object.
4364b042e37fSmrg
43658c4a8e55Smrg	# Figure out destination file name, if it wasn't already specified.
43668c4a8e55Smrg	if test -n "$destname"; then
43673169be4bSmrg	  destfile=$destdir/$destname
43688c4a8e55Smrg	else
43698c4a8e55Smrg	  func_basename "$file"
43703169be4bSmrg	  destfile=$func_basename_result
43713169be4bSmrg	  destfile=$destdir/$destfile
4372b042e37fSmrg	fi
4373b042e37fSmrg
43748c4a8e55Smrg	# Deduce the name of the destination old-style object file.
43758c4a8e55Smrg	case $destfile in
43768c4a8e55Smrg	*.lo)
43778c4a8e55Smrg	  func_lo2o "$destfile"
43788c4a8e55Smrg	  staticdest=$func_lo2o_result
43798c4a8e55Smrg	  ;;
43808c4a8e55Smrg	*.$objext)
43813169be4bSmrg	  staticdest=$destfile
43828c4a8e55Smrg	  destfile=
43838c4a8e55Smrg	  ;;
43848c4a8e55Smrg	*)
43853169be4bSmrg	  func_fatal_help "cannot copy a libtool object to '$destfile'"
43868c4a8e55Smrg	  ;;
43878c4a8e55Smrg	esac
4388b042e37fSmrg
43898c4a8e55Smrg	# Install the libtool object if requested.
43908c4a8e55Smrg	test -n "$destfile" && \
43918c4a8e55Smrg	  func_show_eval "$install_prog $file $destfile" 'exit $?'
4392b042e37fSmrg
43938c4a8e55Smrg	# Install the old object if enabled.
43943169be4bSmrg	if test yes = "$build_old_libs"; then
43958c4a8e55Smrg	  # Deduce the name of the old-style object file.
43968c4a8e55Smrg	  func_lo2o "$file"
43978c4a8e55Smrg	  staticobj=$func_lo2o_result
43988c4a8e55Smrg	  func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
4399b042e37fSmrg	fi
44008c4a8e55Smrg	exit $EXIT_SUCCESS
44018c4a8e55Smrg	;;
4402b042e37fSmrg
44038c4a8e55Smrg      *)
44048c4a8e55Smrg	# Figure out destination file name, if it wasn't already specified.
44058c4a8e55Smrg	if test -n "$destname"; then
44063169be4bSmrg	  destfile=$destdir/$destname
44078c4a8e55Smrg	else
44088c4a8e55Smrg	  func_basename "$file"
44093169be4bSmrg	  destfile=$func_basename_result
44103169be4bSmrg	  destfile=$destdir/$destfile
44118c4a8e55Smrg	fi
4412b042e37fSmrg
44138c4a8e55Smrg	# If the file is missing, and there is a .exe on the end, strip it
44148c4a8e55Smrg	# because it is most likely a libtool script we actually want to
44158c4a8e55Smrg	# install
44163169be4bSmrg	stripped_ext=
44178c4a8e55Smrg	case $file in
44188c4a8e55Smrg	  *.exe)
44198c4a8e55Smrg	    if test ! -f "$file"; then
44208c4a8e55Smrg	      func_stripname '' '.exe' "$file"
44218c4a8e55Smrg	      file=$func_stripname_result
44223169be4bSmrg	      stripped_ext=.exe
44238c4a8e55Smrg	    fi
44248c4a8e55Smrg	    ;;
44258c4a8e55Smrg	esac
44268c4a8e55Smrg
44278c4a8e55Smrg	# Do a test to see if this is really a libtool program.
44288c4a8e55Smrg	case $host in
44298c4a8e55Smrg	*cygwin* | *mingw*)
44308c4a8e55Smrg	    if func_ltwrapper_executable_p "$file"; then
44318c4a8e55Smrg	      func_ltwrapper_scriptname "$file"
44328c4a8e55Smrg	      wrapper=$func_ltwrapper_scriptname_result
44338c4a8e55Smrg	    else
44348c4a8e55Smrg	      func_stripname '' '.exe' "$file"
44358c4a8e55Smrg	      wrapper=$func_stripname_result
44368c4a8e55Smrg	    fi
44378c4a8e55Smrg	    ;;
4438b042e37fSmrg	*)
44398c4a8e55Smrg	    wrapper=$file
44408c4a8e55Smrg	    ;;
44418c4a8e55Smrg	esac
44428c4a8e55Smrg	if func_ltwrapper_script_p "$wrapper"; then
44438c4a8e55Smrg	  notinst_deplibs=
44448c4a8e55Smrg	  relink_command=
44458c4a8e55Smrg
44468c4a8e55Smrg	  func_source "$wrapper"
44478c4a8e55Smrg
44488c4a8e55Smrg	  # Check the variables that should have been set.
44498c4a8e55Smrg	  test -z "$generated_by_libtool_version" && \
44503169be4bSmrg	    func_fatal_error "invalid libtool wrapper script '$wrapper'"
44518c4a8e55Smrg
44523169be4bSmrg	  finalize=:
44538c4a8e55Smrg	  for lib in $notinst_deplibs; do
44548c4a8e55Smrg	    # Check to see that each library is installed.
44558c4a8e55Smrg	    libdir=
44568c4a8e55Smrg	    if test -f "$lib"; then
44578c4a8e55Smrg	      func_source "$lib"
44588c4a8e55Smrg	    fi
44593169be4bSmrg	    libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'`
44608c4a8e55Smrg	    if test -n "$libdir" && test ! -f "$libfile"; then
44613169be4bSmrg	      func_warning "'$lib' has not been installed in '$libdir'"
44623169be4bSmrg	      finalize=false
44638c4a8e55Smrg	    fi
44648c4a8e55Smrg	  done
44658c4a8e55Smrg
44668c4a8e55Smrg	  relink_command=
44678c4a8e55Smrg	  func_source "$wrapper"
44688c4a8e55Smrg
44698c4a8e55Smrg	  outputname=
44703169be4bSmrg	  if test no = "$fast_install" && test -n "$relink_command"; then
44718c4a8e55Smrg	    $opt_dry_run || {
44723169be4bSmrg	      if $finalize; then
44738c4a8e55Smrg	        tmpdir=`func_mktempdir`
44748c4a8e55Smrg		func_basename "$file$stripped_ext"
44753169be4bSmrg		file=$func_basename_result
44763169be4bSmrg	        outputname=$tmpdir/$file
44778c4a8e55Smrg	        # Replace the output file specification.
4478706b6b52Smrg	        relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
44798c4a8e55Smrg
44803169be4bSmrg	        $opt_quiet || {
44818c4a8e55Smrg	          func_quote_for_expand "$relink_command"
44828c4a8e55Smrg		  eval "func_echo $func_quote_for_expand_result"
44838c4a8e55Smrg	        }
44848c4a8e55Smrg	        if eval "$relink_command"; then :
44858c4a8e55Smrg	          else
44863169be4bSmrg		  func_error "error: relink '$file' with the above command before installing it"
44878c4a8e55Smrg		  $opt_dry_run || ${RM}r "$tmpdir"
44888c4a8e55Smrg		  continue
44898c4a8e55Smrg	        fi
44903169be4bSmrg	        file=$outputname
44918c4a8e55Smrg	      else
44923169be4bSmrg	        func_warning "cannot relink '$file'"
44938c4a8e55Smrg	      fi
44948c4a8e55Smrg	    }
44958c4a8e55Smrg	  else
44968c4a8e55Smrg	    # Install the binary that we compiled earlier.
4497706b6b52Smrg	    file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
4498b042e37fSmrg	  fi
44998c4a8e55Smrg	fi
45008c4a8e55Smrg
45018c4a8e55Smrg	# remove .exe since cygwin /usr/bin/install will append another
45028c4a8e55Smrg	# one anyway
45038c4a8e55Smrg	case $install_prog,$host in
45048c4a8e55Smrg	*/usr/bin/install*,*cygwin*)
45058c4a8e55Smrg	  case $file:$destfile in
45068c4a8e55Smrg	  *.exe:*.exe)
45078c4a8e55Smrg	    # this is ok
45088c4a8e55Smrg	    ;;
45098c4a8e55Smrg	  *.exe:*)
45108c4a8e55Smrg	    destfile=$destfile.exe
45118c4a8e55Smrg	    ;;
45128c4a8e55Smrg	  *:*.exe)
45138c4a8e55Smrg	    func_stripname '' '.exe' "$destfile"
45148c4a8e55Smrg	    destfile=$func_stripname_result
45158c4a8e55Smrg	    ;;
45168c4a8e55Smrg	  esac
4517b042e37fSmrg	  ;;
4518b042e37fSmrg	esac
45198c4a8e55Smrg	func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
45208c4a8e55Smrg	$opt_dry_run || if test -n "$outputname"; then
45218c4a8e55Smrg	  ${RM}r "$tmpdir"
45228c4a8e55Smrg	fi
45238c4a8e55Smrg	;;
45248c4a8e55Smrg      esac
45258c4a8e55Smrg    done
4526b042e37fSmrg
45278c4a8e55Smrg    for file in $staticlibs; do
45288c4a8e55Smrg      func_basename "$file"
45293169be4bSmrg      name=$func_basename_result
45308c4a8e55Smrg
45318c4a8e55Smrg      # Set up the ranlib parameters.
45323169be4bSmrg      oldlib=$destdir/$name
45330597fb56Smrg      func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
45340597fb56Smrg      tool_oldlib=$func_to_tool_file_result
45358c4a8e55Smrg
45368c4a8e55Smrg      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
45378c4a8e55Smrg
45388c4a8e55Smrg      if test -n "$stripme" && test -n "$old_striplib"; then
45390597fb56Smrg	func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
45408c4a8e55Smrg      fi
45418c4a8e55Smrg
45428c4a8e55Smrg      # Do each command in the postinstall commands.
45438c4a8e55Smrg      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
45448c4a8e55Smrg    done
45458c4a8e55Smrg
45468c4a8e55Smrg    test -n "$future_libdirs" && \
45473169be4bSmrg      func_warning "remember to run '$progname --finish$future_libdirs'"
45488c4a8e55Smrg
45498c4a8e55Smrg    if test -n "$current_libdirs"; then
45508c4a8e55Smrg      # Maybe just do a dry run.
45518c4a8e55Smrg      $opt_dry_run && current_libdirs=" -n$current_libdirs"
45523169be4bSmrg      exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs'
45538c4a8e55Smrg    else
45548c4a8e55Smrg      exit $EXIT_SUCCESS
45558c4a8e55Smrg    fi
45568c4a8e55Smrg}
45578c4a8e55Smrg
45583169be4bSmrgtest install = "$opt_mode" && func_mode_install ${1+"$@"}
45598c4a8e55Smrg
45608c4a8e55Smrg
45618c4a8e55Smrg# func_generate_dlsyms outputname originator pic_p
45628c4a8e55Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with
45638c4a8e55Smrg# a dlpreopen symbol table.
45648c4a8e55Smrgfunc_generate_dlsyms ()
45658c4a8e55Smrg{
45663169be4bSmrg    $debug_cmd
45673169be4bSmrg
45683169be4bSmrg    my_outputname=$1
45693169be4bSmrg    my_originator=$2
45703169be4bSmrg    my_pic_p=${3-false}
45713169be4bSmrg    my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'`
45728c4a8e55Smrg    my_dlsyms=
45738c4a8e55Smrg
45743169be4bSmrg    if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
45758c4a8e55Smrg      if test -n "$NM" && test -n "$global_symbol_pipe"; then
45763169be4bSmrg	my_dlsyms=${my_outputname}S.c
45778c4a8e55Smrg      else
45788c4a8e55Smrg	func_error "not configured to extract global symbols from dlpreopened files"
45798c4a8e55Smrg      fi
45808c4a8e55Smrg    fi
45818c4a8e55Smrg
45828c4a8e55Smrg    if test -n "$my_dlsyms"; then
45838c4a8e55Smrg      case $my_dlsyms in
45848c4a8e55Smrg      "") ;;
45858c4a8e55Smrg      *.c)
45868c4a8e55Smrg	# Discover the nlist of each of the dlfiles.
45873169be4bSmrg	nlist=$output_objdir/$my_outputname.nm
45888c4a8e55Smrg
45898c4a8e55Smrg	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
45908c4a8e55Smrg
45918c4a8e55Smrg	# Parse the name list into a source file.
45928c4a8e55Smrg	func_verbose "creating $output_objdir/$my_dlsyms"
45938c4a8e55Smrg
45948c4a8e55Smrg	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
45953169be4bSmrg/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */
45963169be4bSmrg/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */
45978c4a8e55Smrg
45988c4a8e55Smrg#ifdef __cplusplus
45998c4a8e55Smrgextern \"C\" {
46008c4a8e55Smrg#endif
46018c4a8e55Smrg
46023169be4bSmrg#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
4603706b6b52Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
4604706b6b52Smrg#endif
4605706b6b52Smrg
4606bd23fbfaSmrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
46073169be4bSmrg#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE
46083169be4bSmrg/* DATA imports from DLLs on WIN32 can't be const, because runtime
4609bd23fbfaSmrg   relocations are performed -- see ld's documentation on pseudo-relocs.  */
4610bd23fbfaSmrg# define LT_DLSYM_CONST
46113169be4bSmrg#elif defined __osf__
4612bd23fbfaSmrg/* This system does not cope well with relocations in const data.  */
4613bd23fbfaSmrg# define LT_DLSYM_CONST
4614bd23fbfaSmrg#else
4615bd23fbfaSmrg# define LT_DLSYM_CONST const
4616bd23fbfaSmrg#endif
4617bd23fbfaSmrg
46183169be4bSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
46193169be4bSmrg
46208c4a8e55Smrg/* External symbol declarations for the compiler. */\
46218c4a8e55Smrg"
46228c4a8e55Smrg
46233169be4bSmrg	if test yes = "$dlself"; then
46243169be4bSmrg	  func_verbose "generating symbol list for '$output'"
46258c4a8e55Smrg
46268c4a8e55Smrg	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
46278c4a8e55Smrg
46288c4a8e55Smrg	  # Add our own program objects to the symbol list.
4629706b6b52Smrg	  progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
46308c4a8e55Smrg	  for progfile in $progfiles; do
4631bd23fbfaSmrg	    func_to_tool_file "$progfile" func_convert_file_msys_to_w32
46323169be4bSmrg	    func_verbose "extracting global C symbols from '$func_to_tool_file_result'"
4633bd23fbfaSmrg	    $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
46348c4a8e55Smrg	  done
46358c4a8e55Smrg
46368c4a8e55Smrg	  if test -n "$exclude_expsyms"; then
46378c4a8e55Smrg	    $opt_dry_run || {
46388c4a8e55Smrg	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
46398c4a8e55Smrg	      eval '$MV "$nlist"T "$nlist"'
46408c4a8e55Smrg	    }
4641b042e37fSmrg	  fi
46428c4a8e55Smrg
46438c4a8e55Smrg	  if test -n "$export_symbols_regex"; then
46448c4a8e55Smrg	    $opt_dry_run || {
46458c4a8e55Smrg	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
46468c4a8e55Smrg	      eval '$MV "$nlist"T "$nlist"'
46478c4a8e55Smrg	    }
46488c4a8e55Smrg	  fi
46498c4a8e55Smrg
46508c4a8e55Smrg	  # Prepare the list of exported symbols
46518c4a8e55Smrg	  if test -z "$export_symbols"; then
46523169be4bSmrg	    export_symbols=$output_objdir/$outputname.exp
46538c4a8e55Smrg	    $opt_dry_run || {
46548c4a8e55Smrg	      $RM $export_symbols
46553169be4bSmrg	      eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
46568c4a8e55Smrg	      case $host in
46578c4a8e55Smrg	      *cygwin* | *mingw* | *cegcc* )
46588c4a8e55Smrg                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
46598c4a8e55Smrg                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
46608c4a8e55Smrg	        ;;
46618c4a8e55Smrg	      esac
46628c4a8e55Smrg	    }
4663b042e37fSmrg	  else
46648c4a8e55Smrg	    $opt_dry_run || {
46653169be4bSmrg	      eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
46668c4a8e55Smrg	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
46678c4a8e55Smrg	      eval '$MV "$nlist"T "$nlist"'
46688c4a8e55Smrg	      case $host in
4669706b6b52Smrg	        *cygwin* | *mingw* | *cegcc* )
46708c4a8e55Smrg	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
46718c4a8e55Smrg	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
46728c4a8e55Smrg	          ;;
46738c4a8e55Smrg	      esac
46748c4a8e55Smrg	    }
4675b042e37fSmrg	  fi
46768c4a8e55Smrg	fi
4677b042e37fSmrg
46788c4a8e55Smrg	for dlprefile in $dlprefiles; do
46793169be4bSmrg	  func_verbose "extracting global C symbols from '$dlprefile'"
46808c4a8e55Smrg	  func_basename "$dlprefile"
46813169be4bSmrg	  name=$func_basename_result
4682bd23fbfaSmrg          case $host in
4683bd23fbfaSmrg	    *cygwin* | *mingw* | *cegcc* )
4684bd23fbfaSmrg	      # if an import library, we need to obtain dlname
4685bd23fbfaSmrg	      if func_win32_import_lib_p "$dlprefile"; then
4686bd23fbfaSmrg	        func_tr_sh "$dlprefile"
4687bd23fbfaSmrg	        eval "curr_lafile=\$libfile_$func_tr_sh_result"
46883169be4bSmrg	        dlprefile_dlbasename=
4689bd23fbfaSmrg	        if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
4690bd23fbfaSmrg	          # Use subshell, to avoid clobbering current variable values
4691bd23fbfaSmrg	          dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
46923169be4bSmrg	          if test -n "$dlprefile_dlname"; then
4693bd23fbfaSmrg	            func_basename "$dlprefile_dlname"
46943169be4bSmrg	            dlprefile_dlbasename=$func_basename_result
4695bd23fbfaSmrg	          else
4696bd23fbfaSmrg	            # no lafile. user explicitly requested -dlpreopen <import library>.
4697bd23fbfaSmrg	            $sharedlib_from_linklib_cmd "$dlprefile"
4698bd23fbfaSmrg	            dlprefile_dlbasename=$sharedlib_from_linklib_result
4699bd23fbfaSmrg	          fi
4700bd23fbfaSmrg	        fi
4701bd23fbfaSmrg	        $opt_dry_run || {
47023169be4bSmrg	          if test -n "$dlprefile_dlbasename"; then
4703bd23fbfaSmrg	            eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
4704bd23fbfaSmrg	          else
4705bd23fbfaSmrg	            func_warning "Could not compute DLL name from $name"
4706bd23fbfaSmrg	            eval '$ECHO ": $name " >> "$nlist"'
4707bd23fbfaSmrg	          fi
4708bd23fbfaSmrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
4709bd23fbfaSmrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
4710bd23fbfaSmrg	            $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
4711bd23fbfaSmrg	        }
4712bd23fbfaSmrg	      else # not an import lib
4713bd23fbfaSmrg	        $opt_dry_run || {
4714bd23fbfaSmrg	          eval '$ECHO ": $name " >> "$nlist"'
4715bd23fbfaSmrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
4716bd23fbfaSmrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
4717bd23fbfaSmrg	        }
4718bd23fbfaSmrg	      fi
4719bd23fbfaSmrg	    ;;
4720bd23fbfaSmrg	    *)
4721bd23fbfaSmrg	      $opt_dry_run || {
4722bd23fbfaSmrg	        eval '$ECHO ": $name " >> "$nlist"'
4723bd23fbfaSmrg	        func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
4724bd23fbfaSmrg	        eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
4725bd23fbfaSmrg	      }
4726bd23fbfaSmrg	    ;;
4727bd23fbfaSmrg          esac
47288c4a8e55Smrg	done
47298c4a8e55Smrg
47308c4a8e55Smrg	$opt_dry_run || {
47318c4a8e55Smrg	  # Make sure we have at least an empty file.
47328c4a8e55Smrg	  test -f "$nlist" || : > "$nlist"
47338c4a8e55Smrg
47348c4a8e55Smrg	  if test -n "$exclude_expsyms"; then
47358c4a8e55Smrg	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
47368c4a8e55Smrg	    $MV "$nlist"T "$nlist"
4737b042e37fSmrg	  fi
47388c4a8e55Smrg
47398c4a8e55Smrg	  # Try sorting and uniquifying the output.
47408c4a8e55Smrg	  if $GREP -v "^: " < "$nlist" |
47418c4a8e55Smrg	      if sort -k 3 </dev/null >/dev/null 2>&1; then
47428c4a8e55Smrg		sort -k 3
47438c4a8e55Smrg	      else
47448c4a8e55Smrg		sort +2
47458c4a8e55Smrg	      fi |
47468c4a8e55Smrg	      uniq > "$nlist"S; then
47478c4a8e55Smrg	    :
4748b042e37fSmrg	  else
47498c4a8e55Smrg	    $GREP -v "^: " < "$nlist" > "$nlist"S
4750b042e37fSmrg	  fi
4751b042e37fSmrg
47528c4a8e55Smrg	  if test -f "$nlist"S; then
47538c4a8e55Smrg	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
4754b042e37fSmrg	  else
4755706b6b52Smrg	    echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
4756b042e37fSmrg	  fi
4757b042e37fSmrg
47583169be4bSmrg	  func_show_eval '$RM "${nlist}I"'
47593169be4bSmrg	  if test -n "$global_symbol_to_import"; then
47603169be4bSmrg	    eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I'
47613169be4bSmrg	  fi
47623169be4bSmrg
4763706b6b52Smrg	  echo >> "$output_objdir/$my_dlsyms" "\
4764b042e37fSmrg
47658c4a8e55Smrg/* The mapping between symbol names and symbols.  */
47668c4a8e55Smrgtypedef struct {
47678c4a8e55Smrg  const char *name;
47688c4a8e55Smrg  void *address;
47698c4a8e55Smrg} lt_dlsymlist;
4770bd23fbfaSmrgextern LT_DLSYM_CONST lt_dlsymlist
47713169be4bSmrglt_${my_prefix}_LTX_preloaded_symbols[];\
47723169be4bSmrg"
47733169be4bSmrg
47743169be4bSmrg	  if test -s "$nlist"I; then
47753169be4bSmrg	    echo >> "$output_objdir/$my_dlsyms" "\
47763169be4bSmrgstatic void lt_syminit(void)
47773169be4bSmrg{
47783169be4bSmrg  LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols;
47793169be4bSmrg  for (; symbol->name; ++symbol)
47803169be4bSmrg    {"
47813169be4bSmrg	    $SED 's/.*/      if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms"
47823169be4bSmrg	    echo >> "$output_objdir/$my_dlsyms" "\
47833169be4bSmrg    }
47843169be4bSmrg}"
47853169be4bSmrg	  fi
47863169be4bSmrg	  echo >> "$output_objdir/$my_dlsyms" "\
4787bd23fbfaSmrgLT_DLSYM_CONST lt_dlsymlist
47888c4a8e55Smrglt_${my_prefix}_LTX_preloaded_symbols[] =
47893169be4bSmrg{ {\"$my_originator\", (void *) 0},"
47903169be4bSmrg
47913169be4bSmrg	  if test -s "$nlist"I; then
47923169be4bSmrg	    echo >> "$output_objdir/$my_dlsyms" "\
47933169be4bSmrg  {\"@INIT@\", (void *) &lt_syminit},"
47943169be4bSmrg	  fi
4795b042e37fSmrg
47968c4a8e55Smrg	  case $need_lib_prefix in
47978c4a8e55Smrg	  no)
47988c4a8e55Smrg	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
47998c4a8e55Smrg	    ;;
48008c4a8e55Smrg	  *)
48018c4a8e55Smrg	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
48028c4a8e55Smrg	    ;;
48038c4a8e55Smrg	  esac
4804706b6b52Smrg	  echo >> "$output_objdir/$my_dlsyms" "\
48058c4a8e55Smrg  {0, (void *) 0}
48068c4a8e55Smrg};
4807b042e37fSmrg
48088c4a8e55Smrg/* This works around a problem in FreeBSD linker */
48098c4a8e55Smrg#ifdef FREEBSD_WORKAROUND
48108c4a8e55Smrgstatic const void *lt_preloaded_setup() {
48118c4a8e55Smrg  return lt_${my_prefix}_LTX_preloaded_symbols;
48128c4a8e55Smrg}
48138c4a8e55Smrg#endif
4814b042e37fSmrg
48158c4a8e55Smrg#ifdef __cplusplus
48168c4a8e55Smrg}
48178c4a8e55Smrg#endif\
48188c4a8e55Smrg"
48198c4a8e55Smrg	} # !$opt_dry_run
4820b042e37fSmrg
48218c4a8e55Smrg	pic_flag_for_symtable=
48228c4a8e55Smrg	case "$compile_command " in
48238c4a8e55Smrg	*" -static "*) ;;
48248c4a8e55Smrg	*)
48258c4a8e55Smrg	  case $host in
48268c4a8e55Smrg	  # compiling the symbol table file with pic_flag works around
48278c4a8e55Smrg	  # a FreeBSD bug that causes programs to crash when -lm is
48288c4a8e55Smrg	  # linked before any other PIC object.  But we must not use
48298c4a8e55Smrg	  # pic_flag when linking with -static.  The problem exists in
48308c4a8e55Smrg	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
48310597fb56Smrg	  *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
48328c4a8e55Smrg	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
48338c4a8e55Smrg	  *-*-hpux*)
48348c4a8e55Smrg	    pic_flag_for_symtable=" $pic_flag"  ;;
48358c4a8e55Smrg	  *)
48363169be4bSmrg	    $my_pic_p && pic_flag_for_symtable=" $pic_flag"
48378c4a8e55Smrg	    ;;
48388c4a8e55Smrg	  esac
48398c4a8e55Smrg	  ;;
48408c4a8e55Smrg	esac
48418c4a8e55Smrg	symtab_cflags=
48428c4a8e55Smrg	for arg in $LTCFLAGS; do
48438c4a8e55Smrg	  case $arg in
48448c4a8e55Smrg	  -pie | -fpie | -fPIE) ;;
4845bd23fbfaSmrg	  *) func_append symtab_cflags " $arg" ;;
48468c4a8e55Smrg	  esac
48478c4a8e55Smrg	done
4848b042e37fSmrg
48498c4a8e55Smrg	# Now compile the dynamic symbol file.
48508c4a8e55Smrg	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
4851b042e37fSmrg
48528c4a8e55Smrg	# Clean up the generated files.
48533169be4bSmrg	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"'
48548c4a8e55Smrg
48558c4a8e55Smrg	# Transform the symbol file into the correct name.
48563169be4bSmrg	symfileobj=$output_objdir/${my_outputname}S.$objext
48578c4a8e55Smrg	case $host in
48588c4a8e55Smrg	*cygwin* | *mingw* | *cegcc* )
48598c4a8e55Smrg	  if test -f "$output_objdir/$my_outputname.def"; then
4860706b6b52Smrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
4861706b6b52Smrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
48628c4a8e55Smrg	  else
4863706b6b52Smrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
4864706b6b52Smrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
4865b042e37fSmrg	  fi
48668c4a8e55Smrg	  ;;
48678c4a8e55Smrg	*)
4868706b6b52Smrg	  compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
4869706b6b52Smrg	  finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
48708c4a8e55Smrg	  ;;
48718c4a8e55Smrg	esac
48728c4a8e55Smrg	;;
48738c4a8e55Smrg      *)
48743169be4bSmrg	func_fatal_error "unknown suffix for '$my_dlsyms'"
48758c4a8e55Smrg	;;
48768c4a8e55Smrg      esac
48778c4a8e55Smrg    else
48788c4a8e55Smrg      # We keep going just in case the user didn't refer to
48798c4a8e55Smrg      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
48808c4a8e55Smrg      # really was required.
4881b042e37fSmrg
48828c4a8e55Smrg      # Nullify the symbol file.
4883706b6b52Smrg      compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
4884706b6b52Smrg      finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
48858c4a8e55Smrg    fi
48868c4a8e55Smrg}
4887b042e37fSmrg
48883169be4bSmrg# func_cygming_gnu_implib_p ARG
48893169be4bSmrg# This predicate returns with zero status (TRUE) if
48903169be4bSmrg# ARG is a GNU/binutils-style import library. Returns
48913169be4bSmrg# with nonzero status (FALSE) otherwise.
48923169be4bSmrgfunc_cygming_gnu_implib_p ()
48933169be4bSmrg{
48943169be4bSmrg  $debug_cmd
48953169be4bSmrg
48963169be4bSmrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
48973169be4bSmrg  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)$'`
48983169be4bSmrg  test -n "$func_cygming_gnu_implib_tmp"
48993169be4bSmrg}
49003169be4bSmrg
49013169be4bSmrg# func_cygming_ms_implib_p ARG
49023169be4bSmrg# This predicate returns with zero status (TRUE) if
49033169be4bSmrg# ARG is an MS-style import library. Returns
49043169be4bSmrg# with nonzero status (FALSE) otherwise.
49053169be4bSmrgfunc_cygming_ms_implib_p ()
49063169be4bSmrg{
49073169be4bSmrg  $debug_cmd
49083169be4bSmrg
49093169be4bSmrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
49103169be4bSmrg  func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
49113169be4bSmrg  test -n "$func_cygming_ms_implib_tmp"
49123169be4bSmrg}
49133169be4bSmrg
49148c4a8e55Smrg# func_win32_libid arg
49158c4a8e55Smrg# return the library type of file 'arg'
49168c4a8e55Smrg#
49178c4a8e55Smrg# Need a lot of goo to handle *both* DLLs and import libs
49188c4a8e55Smrg# Has to be a shell function in order to 'eat' the argument
49198c4a8e55Smrg# that is supplied when $file_magic_command is called.
4920706b6b52Smrg# Despite the name, also deal with 64 bit binaries.
49218c4a8e55Smrgfunc_win32_libid ()
49228c4a8e55Smrg{
49233169be4bSmrg  $debug_cmd
49243169be4bSmrg
49253169be4bSmrg  win32_libid_type=unknown
49268c4a8e55Smrg  win32_fileres=`file -L $1 2>/dev/null`
49278c4a8e55Smrg  case $win32_fileres in
49288c4a8e55Smrg  *ar\ archive\ import\ library*) # definitely import
49298c4a8e55Smrg    win32_libid_type="x86 archive import"
49308c4a8e55Smrg    ;;
49318c4a8e55Smrg  *ar\ archive*) # could be an import, or static
4932706b6b52Smrg    # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
49338c4a8e55Smrg    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
4934706b6b52Smrg       $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
49353169be4bSmrg      case $nm_interface in
49363169be4bSmrg      "MS dumpbin")
49373169be4bSmrg	if func_cygming_ms_implib_p "$1" ||
49383169be4bSmrg	   func_cygming_gnu_implib_p "$1"
49393169be4bSmrg	then
49403169be4bSmrg	  win32_nmres=import
49413169be4bSmrg	else
49423169be4bSmrg	  win32_nmres=
49433169be4bSmrg	fi
49443169be4bSmrg	;;
49453169be4bSmrg      *)
49463169be4bSmrg	func_to_tool_file "$1" func_convert_file_msys_to_w32
49473169be4bSmrg	win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
49483169be4bSmrg	  $SED -n -e '
49498c4a8e55Smrg	    1,100{
49508c4a8e55Smrg		/ I /{
49513169be4bSmrg		    s|.*|import|
49528c4a8e55Smrg		    p
49538c4a8e55Smrg		    q
49548c4a8e55Smrg		}
49558c4a8e55Smrg	    }'`
49563169be4bSmrg	;;
49573169be4bSmrg      esac
49588c4a8e55Smrg      case $win32_nmres in
49598c4a8e55Smrg      import*)  win32_libid_type="x86 archive import";;
49608c4a8e55Smrg      *)        win32_libid_type="x86 archive static";;
49618c4a8e55Smrg      esac
49628c4a8e55Smrg    fi
49638c4a8e55Smrg    ;;
49648c4a8e55Smrg  *DLL*)
49658c4a8e55Smrg    win32_libid_type="x86 DLL"
49668c4a8e55Smrg    ;;
49678c4a8e55Smrg  *executable*) # but shell scripts are "executable" too...
49688c4a8e55Smrg    case $win32_fileres in
49698c4a8e55Smrg    *MS\ Windows\ PE\ Intel*)
49708c4a8e55Smrg      win32_libid_type="x86 DLL"
49718c4a8e55Smrg      ;;
49728c4a8e55Smrg    esac
49738c4a8e55Smrg    ;;
49748c4a8e55Smrg  esac
49758c4a8e55Smrg  $ECHO "$win32_libid_type"
49768c4a8e55Smrg}
4977b042e37fSmrg
4978bd23fbfaSmrg# func_cygming_dll_for_implib ARG
4979bd23fbfaSmrg#
4980bd23fbfaSmrg# Platform-specific function to extract the
4981bd23fbfaSmrg# name of the DLL associated with the specified
4982bd23fbfaSmrg# import library ARG.
4983bd23fbfaSmrg# Invoked by eval'ing the libtool variable
4984bd23fbfaSmrg#    $sharedlib_from_linklib_cmd
4985bd23fbfaSmrg# Result is available in the variable
4986bd23fbfaSmrg#    $sharedlib_from_linklib_result
4987bd23fbfaSmrgfunc_cygming_dll_for_implib ()
4988bd23fbfaSmrg{
49893169be4bSmrg  $debug_cmd
49903169be4bSmrg
4991bd23fbfaSmrg  sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
4992bd23fbfaSmrg}
4993bd23fbfaSmrg
4994bd23fbfaSmrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
4995bd23fbfaSmrg#
4996bd23fbfaSmrg# The is the core of a fallback implementation of a
4997bd23fbfaSmrg# platform-specific function to extract the name of the
4998bd23fbfaSmrg# DLL associated with the specified import library LIBNAME.
4999bd23fbfaSmrg#
5000bd23fbfaSmrg# SECTION_NAME is either .idata$6 or .idata$7, depending
5001bd23fbfaSmrg# on the platform and compiler that created the implib.
5002bd23fbfaSmrg#
5003bd23fbfaSmrg# Echos the name of the DLL associated with the
5004bd23fbfaSmrg# specified import library.
5005bd23fbfaSmrgfunc_cygming_dll_for_implib_fallback_core ()
5006bd23fbfaSmrg{
50073169be4bSmrg  $debug_cmd
50083169be4bSmrg
5009bd23fbfaSmrg  match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
5010bd23fbfaSmrg  $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
5011bd23fbfaSmrg    $SED '/^Contents of section '"$match_literal"':/{
5012bd23fbfaSmrg      # Place marker at beginning of archive member dllname section
5013bd23fbfaSmrg      s/.*/====MARK====/
5014bd23fbfaSmrg      p
5015bd23fbfaSmrg      d
5016bd23fbfaSmrg    }
5017bd23fbfaSmrg    # These lines can sometimes be longer than 43 characters, but
5018bd23fbfaSmrg    # are always uninteresting
5019bd23fbfaSmrg    /:[	 ]*file format pe[i]\{,1\}-/d
5020bd23fbfaSmrg    /^In archive [^:]*:/d
5021bd23fbfaSmrg    # Ensure marker is printed
5022bd23fbfaSmrg    /^====MARK====/p
5023bd23fbfaSmrg    # Remove all lines with less than 43 characters
5024bd23fbfaSmrg    /^.\{43\}/!d
5025bd23fbfaSmrg    # From remaining lines, remove first 43 characters
5026bd23fbfaSmrg    s/^.\{43\}//' |
5027bd23fbfaSmrg    $SED -n '
5028bd23fbfaSmrg      # Join marker and all lines until next marker into a single line
5029bd23fbfaSmrg      /^====MARK====/ b para
5030bd23fbfaSmrg      H
5031bd23fbfaSmrg      $ b para
5032bd23fbfaSmrg      b
5033bd23fbfaSmrg      :para
5034bd23fbfaSmrg      x
5035bd23fbfaSmrg      s/\n//g
5036bd23fbfaSmrg      # Remove the marker
5037bd23fbfaSmrg      s/^====MARK====//
5038bd23fbfaSmrg      # Remove trailing dots and whitespace
5039bd23fbfaSmrg      s/[\. \t]*$//
5040bd23fbfaSmrg      # Print
5041bd23fbfaSmrg      /./p' |
5042bd23fbfaSmrg    # we now have a list, one entry per line, of the stringified
5043bd23fbfaSmrg    # contents of the appropriate section of all members of the
50443169be4bSmrg    # archive that possess that section. Heuristic: eliminate
50453169be4bSmrg    # all those that have a first or second character that is
5046bd23fbfaSmrg    # a '.' (that is, objdump's representation of an unprintable
5047bd23fbfaSmrg    # character.) This should work for all archives with less than
5048bd23fbfaSmrg    # 0x302f exports -- but will fail for DLLs whose name actually
5049bd23fbfaSmrg    # begins with a literal '.' or a single character followed by
5050bd23fbfaSmrg    # a '.'.
5051bd23fbfaSmrg    #
5052bd23fbfaSmrg    # Of those that remain, print the first one.
5053bd23fbfaSmrg    $SED -e '/^\./d;/^.\./d;q'
5054bd23fbfaSmrg}
5055bd23fbfaSmrg
5056bd23fbfaSmrg# func_cygming_dll_for_implib_fallback ARG
5057bd23fbfaSmrg# Platform-specific function to extract the
5058bd23fbfaSmrg# name of the DLL associated with the specified
5059bd23fbfaSmrg# import library ARG.
5060bd23fbfaSmrg#
5061bd23fbfaSmrg# This fallback implementation is for use when $DLLTOOL
5062bd23fbfaSmrg# does not support the --identify-strict option.
5063bd23fbfaSmrg# Invoked by eval'ing the libtool variable
5064bd23fbfaSmrg#    $sharedlib_from_linklib_cmd
5065bd23fbfaSmrg# Result is available in the variable
5066bd23fbfaSmrg#    $sharedlib_from_linklib_result
5067bd23fbfaSmrgfunc_cygming_dll_for_implib_fallback ()
5068bd23fbfaSmrg{
50693169be4bSmrg  $debug_cmd
50703169be4bSmrg
50713169be4bSmrg  if func_cygming_gnu_implib_p "$1"; then
5072bd23fbfaSmrg    # binutils import library
5073bd23fbfaSmrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
50743169be4bSmrg  elif func_cygming_ms_implib_p "$1"; then
5075bd23fbfaSmrg    # ms-generated import library
5076bd23fbfaSmrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
5077bd23fbfaSmrg  else
5078bd23fbfaSmrg    # unknown
50793169be4bSmrg    sharedlib_from_linklib_result=
5080bd23fbfaSmrg  fi
5081bd23fbfaSmrg}
5082b042e37fSmrg
5083b042e37fSmrg
50848c4a8e55Smrg# func_extract_an_archive dir oldlib
50858c4a8e55Smrgfunc_extract_an_archive ()
50868c4a8e55Smrg{
50873169be4bSmrg    $debug_cmd
50883169be4bSmrg
50893169be4bSmrg    f_ex_an_ar_dir=$1; shift
50903169be4bSmrg    f_ex_an_ar_oldlib=$1
50913169be4bSmrg    if test yes = "$lock_old_archive_extraction"; then
5092706b6b52Smrg      lockfile=$f_ex_an_ar_oldlib.lock
5093706b6b52Smrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
5094706b6b52Smrg	func_echo "Waiting for $lockfile to be removed"
5095706b6b52Smrg	sleep 2
5096706b6b52Smrg      done
5097706b6b52Smrg    fi
5098706b6b52Smrg    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
5099706b6b52Smrg		   'stat=$?; rm -f "$lockfile"; exit $stat'
51003169be4bSmrg    if test yes = "$lock_old_archive_extraction"; then
5101706b6b52Smrg      $opt_dry_run || rm -f "$lockfile"
5102706b6b52Smrg    fi
51038c4a8e55Smrg    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
51048c4a8e55Smrg     :
51058c4a8e55Smrg    else
51068c4a8e55Smrg      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
51078c4a8e55Smrg    fi
51088c4a8e55Smrg}
5109b042e37fSmrg
5110b042e37fSmrg
51118c4a8e55Smrg# func_extract_archives gentop oldlib ...
51128c4a8e55Smrgfunc_extract_archives ()
51138c4a8e55Smrg{
51143169be4bSmrg    $debug_cmd
51153169be4bSmrg
51163169be4bSmrg    my_gentop=$1; shift
51178c4a8e55Smrg    my_oldlibs=${1+"$@"}
51183169be4bSmrg    my_oldobjs=
51193169be4bSmrg    my_xlib=
51203169be4bSmrg    my_xabs=
51213169be4bSmrg    my_xdir=
5122b042e37fSmrg
51238c4a8e55Smrg    for my_xlib in $my_oldlibs; do
51248c4a8e55Smrg      # Extract the objects.
51258c4a8e55Smrg      case $my_xlib in
51263169be4bSmrg	[\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;;
51278c4a8e55Smrg	*) my_xabs=`pwd`"/$my_xlib" ;;
51288c4a8e55Smrg      esac
51298c4a8e55Smrg      func_basename "$my_xlib"
51303169be4bSmrg      my_xlib=$func_basename_result
51318c4a8e55Smrg      my_xlib_u=$my_xlib
51328c4a8e55Smrg      while :; do
51338c4a8e55Smrg        case " $extracted_archives " in
51348c4a8e55Smrg	*" $my_xlib_u "*)
51358c4a8e55Smrg	  func_arith $extracted_serial + 1
51368c4a8e55Smrg	  extracted_serial=$func_arith_result
51378c4a8e55Smrg	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
51388c4a8e55Smrg	*) break ;;
51398c4a8e55Smrg	esac
51408c4a8e55Smrg      done
51418c4a8e55Smrg      extracted_archives="$extracted_archives $my_xlib_u"
51423169be4bSmrg      my_xdir=$my_gentop/$my_xlib_u
5143b042e37fSmrg
51448c4a8e55Smrg      func_mkdir_p "$my_xdir"
5145b042e37fSmrg
51468c4a8e55Smrg      case $host in
51478c4a8e55Smrg      *-darwin*)
51488c4a8e55Smrg	func_verbose "Extracting $my_xabs"
51498c4a8e55Smrg	# Do not bother doing anything if just a dry run
51508c4a8e55Smrg	$opt_dry_run || {
51518c4a8e55Smrg	  darwin_orig_dir=`pwd`
51528c4a8e55Smrg	  cd $my_xdir || exit $?
51538c4a8e55Smrg	  darwin_archive=$my_xabs
51548c4a8e55Smrg	  darwin_curdir=`pwd`
51553169be4bSmrg	  func_basename "$darwin_archive"
51563169be4bSmrg	  darwin_base_archive=$func_basename_result
51578c4a8e55Smrg	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
51588c4a8e55Smrg	  if test -n "$darwin_arches"; then
51598c4a8e55Smrg	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
51608c4a8e55Smrg	    darwin_arch=
51618c4a8e55Smrg	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
51623169be4bSmrg	    for darwin_arch in  $darwin_arches; do
51633169be4bSmrg	      func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch"
51643169be4bSmrg	      $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive"
51653169be4bSmrg	      cd "unfat-$$/$darwin_base_archive-$darwin_arch"
51663169be4bSmrg	      func_extract_an_archive "`pwd`" "$darwin_base_archive"
51678c4a8e55Smrg	      cd "$darwin_curdir"
51683169be4bSmrg	      $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive"
51698c4a8e55Smrg	    done # $darwin_arches
51708c4a8e55Smrg            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
51713169be4bSmrg	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u`
51728c4a8e55Smrg	    darwin_file=
51738c4a8e55Smrg	    darwin_files=
51748c4a8e55Smrg	    for darwin_file in $darwin_filelist; do
5175706b6b52Smrg	      darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
51768c4a8e55Smrg	      $LIPO -create -output "$darwin_file" $darwin_files
51778c4a8e55Smrg	    done # $darwin_filelist
51788c4a8e55Smrg	    $RM -rf unfat-$$
51798c4a8e55Smrg	    cd "$darwin_orig_dir"
5180b042e37fSmrg	  else
51818c4a8e55Smrg	    cd $darwin_orig_dir
51828c4a8e55Smrg	    func_extract_an_archive "$my_xdir" "$my_xabs"
51838c4a8e55Smrg	  fi # $darwin_arches
51848c4a8e55Smrg	} # !$opt_dry_run
51858c4a8e55Smrg	;;
51868c4a8e55Smrg      *)
51878c4a8e55Smrg        func_extract_an_archive "$my_xdir" "$my_xabs"
51888c4a8e55Smrg	;;
51898c4a8e55Smrg      esac
5190706b6b52Smrg      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
51918c4a8e55Smrg    done
5192b042e37fSmrg
51933169be4bSmrg    func_extract_archives_result=$my_oldobjs
51948c4a8e55Smrg}
5195b042e37fSmrg
5196b042e37fSmrg
5197706b6b52Smrg# func_emit_wrapper [arg=no]
5198706b6b52Smrg#
5199706b6b52Smrg# Emit a libtool wrapper script on stdout.
5200706b6b52Smrg# Don't directly open a file because we may want to
5201706b6b52Smrg# incorporate the script contents within a cygwin/mingw
5202706b6b52Smrg# wrapper executable.  Must ONLY be called from within
5203706b6b52Smrg# func_mode_link because it depends on a number of variables
5204706b6b52Smrg# set therein.
52058c4a8e55Smrg#
5206706b6b52Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
5207706b6b52Smrg# variable will take.  If 'yes', then the emitted script
52083169be4bSmrg# will assume that the directory where it is stored is
5209706b6b52Smrg# the $objdir directory.  This is a cygwin/mingw-specific
5210706b6b52Smrg# behavior.
5211706b6b52Smrgfunc_emit_wrapper ()
52128c4a8e55Smrg{
5213706b6b52Smrg	func_emit_wrapper_arg1=${1-no}
5214b042e37fSmrg
52158c4a8e55Smrg	$ECHO "\
52168c4a8e55Smrg#! $SHELL
5217b042e37fSmrg
52188c4a8e55Smrg# $output - temporary wrapper script for $objdir/$outputname
52193169be4bSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
52208c4a8e55Smrg#
52218c4a8e55Smrg# The $output program cannot be directly executed until all the libtool
52228c4a8e55Smrg# libraries that it depends on are installed.
52238c4a8e55Smrg#
52248c4a8e55Smrg# This wrapper script should never be moved out of the build directory.
52258c4a8e55Smrg# If it is, it will not operate correctly.
5226b042e37fSmrg
52278c4a8e55Smrg# Sed substitution that helps us do robust quoting.  It backslashifies
52288c4a8e55Smrg# metacharacters that are still active within double-quoted strings.
52298c4a8e55Smrgsed_quote_subst='$sed_quote_subst'
5230b042e37fSmrg
52318c4a8e55Smrg# Be Bourne compatible
52328c4a8e55Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
52338c4a8e55Smrg  emulate sh
52348c4a8e55Smrg  NULLCMD=:
52358c4a8e55Smrg  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
52368c4a8e55Smrg  # is contrary to our usage.  Disable this feature.
52378c4a8e55Smrg  alias -g '\${1+\"\$@\"}'='\"\$@\"'
52388c4a8e55Smrg  setopt NO_GLOB_SUBST
52398c4a8e55Smrgelse
52408c4a8e55Smrg  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
52418c4a8e55Smrgfi
52428c4a8e55SmrgBIN_SH=xpg4; export BIN_SH # for Tru64
52438c4a8e55SmrgDUALCASE=1; export DUALCASE # for MKS sh
5244b042e37fSmrg
52458c4a8e55Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout
52468c4a8e55Smrg# if CDPATH is set.
52478c4a8e55Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
5248b042e37fSmrg
52498c4a8e55Smrgrelink_command=\"$relink_command\"
5250b042e37fSmrg
52518c4a8e55Smrg# This environment variable determines our operation mode.
52528c4a8e55Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then
52538c4a8e55Smrg  # install mode needs the following variables:
52548c4a8e55Smrg  generated_by_libtool_version='$macro_version'
52558c4a8e55Smrg  notinst_deplibs='$notinst_deplibs'
52568c4a8e55Smrgelse
52578c4a8e55Smrg  # When we are sourced in execute mode, \$file and \$ECHO are already set.
52588c4a8e55Smrg  if test \"\$libtool_execute_magic\" != \"$magic\"; then
5259706b6b52Smrg    file=\"\$0\""
5260706b6b52Smrg
5261706b6b52Smrg    qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
5262706b6b52Smrg    $ECHO "\
5263706b6b52Smrg
5264706b6b52Smrg# A function that is used when there is no print builtin or printf.
5265706b6b52Smrgfunc_fallback_echo ()
5266706b6b52Smrg{
5267706b6b52Smrg  eval 'cat <<_LTECHO_EOF
5268706b6b52Smrg\$1
5269706b6b52Smrg_LTECHO_EOF'
5270706b6b52Smrg}
5271706b6b52Smrg    ECHO=\"$qECHO\"
5272706b6b52Smrg  fi
5273706b6b52Smrg
5274706b6b52Smrg# Very basic option parsing. These options are (a) specific to
5275706b6b52Smrg# the libtool wrapper, (b) are identical between the wrapper
52763169be4bSmrg# /script/ and the wrapper /executable/ that is used only on
5277706b6b52Smrg# windows platforms, and (c) all begin with the string "--lt-"
52783169be4bSmrg# (application programs are unlikely to have options that match
5279706b6b52Smrg# this pattern).
5280706b6b52Smrg#
5281706b6b52Smrg# There are only two supported options: --lt-debug and
5282706b6b52Smrg# --lt-dump-script. There is, deliberately, no --lt-help.
5283706b6b52Smrg#
5284706b6b52Smrg# The first argument to this parsing function should be the
5285706b6b52Smrg# script's $0 value, followed by "$@".
5286706b6b52Smrglt_option_debug=
5287706b6b52Smrgfunc_parse_lt_options ()
5288706b6b52Smrg{
5289706b6b52Smrg  lt_script_arg0=\$0
5290706b6b52Smrg  shift
5291706b6b52Smrg  for lt_opt
5292706b6b52Smrg  do
5293706b6b52Smrg    case \"\$lt_opt\" in
5294706b6b52Smrg    --lt-debug) lt_option_debug=1 ;;
5295706b6b52Smrg    --lt-dump-script)
5296706b6b52Smrg        lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
5297706b6b52Smrg        test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
5298706b6b52Smrg        lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
5299706b6b52Smrg        cat \"\$lt_dump_D/\$lt_dump_F\"
5300706b6b52Smrg        exit 0
5301706b6b52Smrg      ;;
5302706b6b52Smrg    --lt-*)
5303706b6b52Smrg        \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
5304706b6b52Smrg        exit 1
5305706b6b52Smrg      ;;
5306706b6b52Smrg    esac
5307706b6b52Smrg  done
5308706b6b52Smrg
5309706b6b52Smrg  # Print the debug banner immediately:
5310706b6b52Smrg  if test -n \"\$lt_option_debug\"; then
53113169be4bSmrg    echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2
5312706b6b52Smrg  fi
5313706b6b52Smrg}
5314706b6b52Smrg
5315706b6b52Smrg# Used when --lt-debug. Prints its arguments to stdout
5316706b6b52Smrg# (redirection is the responsibility of the caller)
5317706b6b52Smrgfunc_lt_dump_args ()
5318706b6b52Smrg{
5319706b6b52Smrg  lt_dump_args_N=1;
5320706b6b52Smrg  for lt_arg
5321706b6b52Smrg  do
53223169be4bSmrg    \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\"
5323706b6b52Smrg    lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
5324706b6b52Smrg  done
5325706b6b52Smrg}
5326706b6b52Smrg
5327706b6b52Smrg# Core function for launching the target application
5328706b6b52Smrgfunc_exec_program_core ()
5329706b6b52Smrg{
53308c4a8e55Smrg"
5331706b6b52Smrg  case $host in
5332706b6b52Smrg  # Backslashes separate directories on plain windows
5333706b6b52Smrg  *-*-mingw | *-*-os2* | *-cegcc*)
5334706b6b52Smrg    $ECHO "\
5335706b6b52Smrg      if test -n \"\$lt_option_debug\"; then
53363169be4bSmrg        \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2
5337706b6b52Smrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
5338706b6b52Smrg      fi
5339706b6b52Smrg      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
5340706b6b52Smrg"
5341706b6b52Smrg    ;;
5342706b6b52Smrg
5343706b6b52Smrg  *)
5344706b6b52Smrg    $ECHO "\
5345706b6b52Smrg      if test -n \"\$lt_option_debug\"; then
53463169be4bSmrg        \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2
5347706b6b52Smrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
5348706b6b52Smrg      fi
5349706b6b52Smrg      exec \"\$progdir/\$program\" \${1+\"\$@\"}
5350706b6b52Smrg"
5351706b6b52Smrg    ;;
5352706b6b52Smrg  esac
5353706b6b52Smrg  $ECHO "\
5354706b6b52Smrg      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
5355706b6b52Smrg      exit 1
5356706b6b52Smrg}
5357706b6b52Smrg
5358706b6b52Smrg# A function to encapsulate launching the target application
5359706b6b52Smrg# Strips options in the --lt-* namespace from \$@ and
5360706b6b52Smrg# launches target application with the remaining arguments.
5361706b6b52Smrgfunc_exec_program ()
5362706b6b52Smrg{
53630597fb56Smrg  case \" \$* \" in
53640597fb56Smrg  *\\ --lt-*)
53650597fb56Smrg    for lt_wr_arg
53660597fb56Smrg    do
53670597fb56Smrg      case \$lt_wr_arg in
53680597fb56Smrg      --lt-*) ;;
53690597fb56Smrg      *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
53700597fb56Smrg      esac
53710597fb56Smrg      shift
53720597fb56Smrg    done ;;
53730597fb56Smrg  esac
5374706b6b52Smrg  func_exec_program_core \${1+\"\$@\"}
5375706b6b52Smrg}
5376706b6b52Smrg
5377706b6b52Smrg  # Parse options
5378706b6b52Smrg  func_parse_lt_options \"\$0\" \${1+\"\$@\"}
5379b042e37fSmrg
53808c4a8e55Smrg  # Find the directory that this script lives in.
5381706b6b52Smrg  thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
53828c4a8e55Smrg  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
5383b042e37fSmrg
53848c4a8e55Smrg  # Follow symbolic links until we get to the real thisdir.
5385706b6b52Smrg  file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
53868c4a8e55Smrg  while test -n \"\$file\"; do
5387706b6b52Smrg    destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
53888c4a8e55Smrg
53898c4a8e55Smrg    # If there was a directory component, then change thisdir.
53908c4a8e55Smrg    if test \"x\$destdir\" != \"x\$file\"; then
53918c4a8e55Smrg      case \"\$destdir\" in
53928c4a8e55Smrg      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
53938c4a8e55Smrg      *) thisdir=\"\$thisdir/\$destdir\" ;;
5394b042e37fSmrg      esac
53958c4a8e55Smrg    fi
5396b042e37fSmrg
5397706b6b52Smrg    file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
5398706b6b52Smrg    file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
53998c4a8e55Smrg  done
5400b042e37fSmrg
54018c4a8e55Smrg  # Usually 'no', except on cygwin/mingw when embedded into
54028c4a8e55Smrg  # the cwrapper.
5403706b6b52Smrg  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
54048c4a8e55Smrg  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
54058c4a8e55Smrg    # special case for '.'
54068c4a8e55Smrg    if test \"\$thisdir\" = \".\"; then
54078c4a8e55Smrg      thisdir=\`pwd\`
54088c4a8e55Smrg    fi
54098c4a8e55Smrg    # remove .libs from thisdir
54108c4a8e55Smrg    case \"\$thisdir\" in
5411706b6b52Smrg    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
54128c4a8e55Smrg    $objdir )   thisdir=. ;;
54138c4a8e55Smrg    esac
54148c4a8e55Smrg  fi
54158c4a8e55Smrg
54168c4a8e55Smrg  # Try to get the absolute directory name.
54178c4a8e55Smrg  absdir=\`cd \"\$thisdir\" && pwd\`
54188c4a8e55Smrg  test -n \"\$absdir\" && thisdir=\"\$absdir\"
54198c4a8e55Smrg"
54208c4a8e55Smrg
54213169be4bSmrg	if test yes = "$fast_install"; then
54228c4a8e55Smrg	  $ECHO "\
54238c4a8e55Smrg  program=lt-'$outputname'$exeext
54248c4a8e55Smrg  progdir=\"\$thisdir/$objdir\"
54258c4a8e55Smrg
54268c4a8e55Smrg  if test ! -f \"\$progdir/\$program\" ||
54273169be4bSmrg     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\
54288c4a8e55Smrg       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
54298c4a8e55Smrg
54308c4a8e55Smrg    file=\"\$\$-\$program\"
54318c4a8e55Smrg
54328c4a8e55Smrg    if test ! -d \"\$progdir\"; then
54338c4a8e55Smrg      $MKDIR \"\$progdir\"
54348c4a8e55Smrg    else
54358c4a8e55Smrg      $RM \"\$progdir/\$file\"
54368c4a8e55Smrg    fi"
54378c4a8e55Smrg
54388c4a8e55Smrg	  $ECHO "\
54398c4a8e55Smrg
54408c4a8e55Smrg    # relink executable if necessary
54418c4a8e55Smrg    if test -n \"\$relink_command\"; then
54428c4a8e55Smrg      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
54438c4a8e55Smrg      else
54443169be4bSmrg	\$ECHO \"\$relink_command_output\" >&2
54458c4a8e55Smrg	$RM \"\$progdir/\$file\"
54468c4a8e55Smrg	exit 1
5447b042e37fSmrg      fi
54488c4a8e55Smrg    fi
5449b042e37fSmrg
54508c4a8e55Smrg    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
54518c4a8e55Smrg    { $RM \"\$progdir/\$program\";
54528c4a8e55Smrg      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
54538c4a8e55Smrg    $RM \"\$progdir/\$file\"
54548c4a8e55Smrg  fi"
54558c4a8e55Smrg	else
54568c4a8e55Smrg	  $ECHO "\
54578c4a8e55Smrg  program='$outputname'
54588c4a8e55Smrg  progdir=\"\$thisdir/$objdir\"
54598c4a8e55Smrg"
5460b042e37fSmrg	fi
5461b042e37fSmrg
54628c4a8e55Smrg	$ECHO "\
5463b042e37fSmrg
54648c4a8e55Smrg  if test -f \"\$progdir/\$program\"; then"
5465b042e37fSmrg
5466bd23fbfaSmrg	# fixup the dll searchpath if we need to.
5467bd23fbfaSmrg	#
5468bd23fbfaSmrg	# Fix the DLL searchpath if we need to.  Do this before prepending
5469bd23fbfaSmrg	# to shlibpath, because on Windows, both are PATH and uninstalled
5470bd23fbfaSmrg	# libraries must come first.
5471bd23fbfaSmrg	if test -n "$dllsearchpath"; then
5472bd23fbfaSmrg	  $ECHO "\
5473bd23fbfaSmrg    # Add the dll search path components to the executable PATH
5474bd23fbfaSmrg    PATH=$dllsearchpath:\$PATH
5475bd23fbfaSmrg"
5476bd23fbfaSmrg	fi
5477bd23fbfaSmrg
54788c4a8e55Smrg	# Export our shlibpath_var if we have one.
54793169be4bSmrg	if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
54808c4a8e55Smrg	  $ECHO "\
54818c4a8e55Smrg    # Add our own library path to $shlibpath_var
54828c4a8e55Smrg    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
54838c4a8e55Smrg
54848c4a8e55Smrg    # Some systems cannot cope with colon-terminated $shlibpath_var
54858c4a8e55Smrg    # The second colon is a workaround for a bug in BeOS R4 sed
5486706b6b52Smrg    $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
5487b042e37fSmrg
54888c4a8e55Smrg    export $shlibpath_var
54898c4a8e55Smrg"
5490b042e37fSmrg	fi
5491b042e37fSmrg
54928c4a8e55Smrg	$ECHO "\
54938c4a8e55Smrg    if test \"\$libtool_execute_magic\" != \"$magic\"; then
54948c4a8e55Smrg      # Run the actual program with our arguments.
5495706b6b52Smrg      func_exec_program \${1+\"\$@\"}
54968c4a8e55Smrg    fi
54978c4a8e55Smrg  else
54988c4a8e55Smrg    # The program doesn't exist.
54993169be4bSmrg    \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2
55008c4a8e55Smrg    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
5501706b6b52Smrg    \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
55028c4a8e55Smrg    exit 1
55038c4a8e55Smrg  fi
55048c4a8e55Smrgfi\
55058c4a8e55Smrg"
55068c4a8e55Smrg}
5507b042e37fSmrg
5508b042e37fSmrg
55098c4a8e55Smrg# func_emit_cwrapperexe_src
55108c4a8e55Smrg# emit the source code for a wrapper executable on stdout
55118c4a8e55Smrg# Must ONLY be called from within func_mode_link because
55128c4a8e55Smrg# it depends on a number of variable set therein.
55138c4a8e55Smrgfunc_emit_cwrapperexe_src ()
55148c4a8e55Smrg{
55158c4a8e55Smrg	cat <<EOF
5516b042e37fSmrg
55178c4a8e55Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
55183169be4bSmrg   Generated by $PROGRAM (GNU $PACKAGE) $VERSION
5519b042e37fSmrg
55208c4a8e55Smrg   The $output program cannot be directly executed until all the libtool
55218c4a8e55Smrg   libraries that it depends on are installed.
5522b042e37fSmrg
55238c4a8e55Smrg   This wrapper executable should never be moved out of the build directory.
55248c4a8e55Smrg   If it is, it will not operate correctly.
55258c4a8e55Smrg*/
55268c4a8e55SmrgEOF
55278c4a8e55Smrg	    cat <<"EOF"
5528706b6b52Smrg#ifdef _MSC_VER
5529706b6b52Smrg# define _CRT_SECURE_NO_DEPRECATE 1
5530706b6b52Smrg#endif
55318c4a8e55Smrg#include <stdio.h>
55328c4a8e55Smrg#include <stdlib.h>
55338c4a8e55Smrg#ifdef _MSC_VER
55348c4a8e55Smrg# include <direct.h>
55358c4a8e55Smrg# include <process.h>
55368c4a8e55Smrg# include <io.h>
55378c4a8e55Smrg#else
55388c4a8e55Smrg# include <unistd.h>
55398c4a8e55Smrg# include <stdint.h>
55408c4a8e55Smrg# ifdef __CYGWIN__
55418c4a8e55Smrg#  include <io.h>
55428c4a8e55Smrg# endif
55438c4a8e55Smrg#endif
55448c4a8e55Smrg#include <malloc.h>
55458c4a8e55Smrg#include <stdarg.h>
55468c4a8e55Smrg#include <assert.h>
55478c4a8e55Smrg#include <string.h>
55488c4a8e55Smrg#include <ctype.h>
55498c4a8e55Smrg#include <errno.h>
55508c4a8e55Smrg#include <fcntl.h>
55518c4a8e55Smrg#include <sys/stat.h>
5552b042e37fSmrg
55533169be4bSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
55543169be4bSmrg
5555706b6b52Smrg/* declarations of non-ANSI functions */
55563169be4bSmrg#if defined __MINGW32__
5557706b6b52Smrg# ifdef __STRICT_ANSI__
5558706b6b52Smrgint _putenv (const char *);
5559706b6b52Smrg# endif
55603169be4bSmrg#elif defined __CYGWIN__
5561706b6b52Smrg# ifdef __STRICT_ANSI__
5562706b6b52Smrgchar *realpath (const char *, char *);
5563706b6b52Smrgint putenv (char *);
5564706b6b52Smrgint setenv (const char *, const char *, int);
5565706b6b52Smrg# endif
55663169be4bSmrg/* #elif defined other_platform || defined ... */
5567706b6b52Smrg#endif
5568706b6b52Smrg
5569706b6b52Smrg/* portability defines, excluding path handling macros */
55703169be4bSmrg#if defined _MSC_VER
5571706b6b52Smrg# define setmode _setmode
5572706b6b52Smrg# define stat    _stat
5573706b6b52Smrg# define chmod   _chmod
5574706b6b52Smrg# define getcwd  _getcwd
5575706b6b52Smrg# define putenv  _putenv
5576706b6b52Smrg# define S_IXUSR _S_IEXEC
55773169be4bSmrg#elif defined __MINGW32__
5578706b6b52Smrg# define setmode _setmode
5579706b6b52Smrg# define stat    _stat
5580706b6b52Smrg# define chmod   _chmod
5581706b6b52Smrg# define getcwd  _getcwd
5582706b6b52Smrg# define putenv  _putenv
55833169be4bSmrg#elif defined __CYGWIN__
5584706b6b52Smrg# define HAVE_SETENV
5585706b6b52Smrg# define FOPEN_WB "wb"
55863169be4bSmrg/* #elif defined other platforms ... */
5587706b6b52Smrg#endif
5588706b6b52Smrg
55893169be4bSmrg#if defined PATH_MAX
55908c4a8e55Smrg# define LT_PATHMAX PATH_MAX
55913169be4bSmrg#elif defined MAXPATHLEN
55928c4a8e55Smrg# define LT_PATHMAX MAXPATHLEN
55938c4a8e55Smrg#else
55948c4a8e55Smrg# define LT_PATHMAX 1024
55958c4a8e55Smrg#endif
5596b042e37fSmrg
55978c4a8e55Smrg#ifndef S_IXOTH
55988c4a8e55Smrg# define S_IXOTH 0
55998c4a8e55Smrg#endif
56008c4a8e55Smrg#ifndef S_IXGRP
56018c4a8e55Smrg# define S_IXGRP 0
56028c4a8e55Smrg#endif
5603b042e37fSmrg
5604706b6b52Smrg/* path handling portability macros */
56058c4a8e55Smrg#ifndef DIR_SEPARATOR
56068c4a8e55Smrg# define DIR_SEPARATOR '/'
56078c4a8e55Smrg# define PATH_SEPARATOR ':'
56088c4a8e55Smrg#endif
5609b042e37fSmrg
56103169be4bSmrg#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \
56113169be4bSmrg  defined __OS2__
56128c4a8e55Smrg# define HAVE_DOS_BASED_FILE_SYSTEM
56138c4a8e55Smrg# define FOPEN_WB "wb"
56148c4a8e55Smrg# ifndef DIR_SEPARATOR_2
56158c4a8e55Smrg#  define DIR_SEPARATOR_2 '\\'
56168c4a8e55Smrg# endif
56178c4a8e55Smrg# ifndef PATH_SEPARATOR_2
56188c4a8e55Smrg#  define PATH_SEPARATOR_2 ';'
56198c4a8e55Smrg# endif
56208c4a8e55Smrg#endif
5621b042e37fSmrg
56228c4a8e55Smrg#ifndef DIR_SEPARATOR_2
56238c4a8e55Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
56248c4a8e55Smrg#else /* DIR_SEPARATOR_2 */
56258c4a8e55Smrg# define IS_DIR_SEPARATOR(ch) \
56268c4a8e55Smrg	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
56278c4a8e55Smrg#endif /* DIR_SEPARATOR_2 */
5628b042e37fSmrg
56298c4a8e55Smrg#ifndef PATH_SEPARATOR_2
56308c4a8e55Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
56318c4a8e55Smrg#else /* PATH_SEPARATOR_2 */
56328c4a8e55Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
56338c4a8e55Smrg#endif /* PATH_SEPARATOR_2 */
5634b042e37fSmrg
56358c4a8e55Smrg#ifndef FOPEN_WB
56368c4a8e55Smrg# define FOPEN_WB "w"
56378c4a8e55Smrg#endif
56388c4a8e55Smrg#ifndef _O_BINARY
56398c4a8e55Smrg# define _O_BINARY 0
56408c4a8e55Smrg#endif
5641b042e37fSmrg
56428c4a8e55Smrg#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
56438c4a8e55Smrg#define XFREE(stale) do { \
56443169be4bSmrg  if (stale) { free (stale); stale = 0; } \
56458c4a8e55Smrg} while (0)
5646b042e37fSmrg
56473169be4bSmrg#if defined LT_DEBUGWRAPPER
5648706b6b52Smrgstatic int lt_debug = 1;
56498c4a8e55Smrg#else
5650706b6b52Smrgstatic int lt_debug = 0;
56518c4a8e55Smrg#endif
5652b042e37fSmrg
5653706b6b52Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
5654b042e37fSmrg
56558c4a8e55Smrgvoid *xmalloc (size_t num);
56568c4a8e55Smrgchar *xstrdup (const char *string);
56578c4a8e55Smrgconst char *base_name (const char *name);
56588c4a8e55Smrgchar *find_executable (const char *wrapper);
56598c4a8e55Smrgchar *chase_symlinks (const char *pathspec);
56608c4a8e55Smrgint make_executable (const char *path);
56618c4a8e55Smrgint check_executable (const char *path);
56628c4a8e55Smrgchar *strendzap (char *str, const char *pat);
5663706b6b52Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...);
5664706b6b52Smrgvoid lt_fatal (const char *file, int line, const char *message, ...);
5665706b6b52Smrgstatic const char *nonnull (const char *s);
5666706b6b52Smrgstatic const char *nonempty (const char *s);
56678c4a8e55Smrgvoid lt_setenv (const char *name, const char *value);
56688c4a8e55Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end);
56698c4a8e55Smrgvoid lt_update_exe_path (const char *name, const char *value);
56708c4a8e55Smrgvoid lt_update_lib_path (const char *name, const char *value);
5671706b6b52Smrgchar **prepare_spawn (char **argv);
5672706b6b52Smrgvoid lt_dump_script (FILE *f);
56738c4a8e55SmrgEOF
56748c4a8e55Smrg
56758c4a8e55Smrg	    cat <<EOF
56763169be4bSmrg#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5)
56773169be4bSmrg# define externally_visible volatile
56783169be4bSmrg#else
56793169be4bSmrg# define externally_visible __attribute__((externally_visible)) volatile
56803169be4bSmrg#endif
56813169be4bSmrgexternally_visible const char * MAGIC_EXE = "$magic_exe";
56828c4a8e55Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var";
56838c4a8e55SmrgEOF
5684b042e37fSmrg
56853169be4bSmrg	    if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
5686bd23fbfaSmrg              func_to_host_path "$temp_rpath"
56878c4a8e55Smrg	      cat <<EOF
5688bd23fbfaSmrgconst char * LIB_PATH_VALUE   = "$func_to_host_path_result";
5689b042e37fSmrgEOF
5690b042e37fSmrg	    else
56918c4a8e55Smrg	      cat <<"EOF"
56928c4a8e55Smrgconst char * LIB_PATH_VALUE   = "";
56938c4a8e55SmrgEOF
5694b042e37fSmrg	    fi
56958c4a8e55Smrg
56968c4a8e55Smrg	    if test -n "$dllsearchpath"; then
5697bd23fbfaSmrg              func_to_host_path "$dllsearchpath:"
56988c4a8e55Smrg	      cat <<EOF
56998c4a8e55Smrgconst char * EXE_PATH_VARNAME = "PATH";
5700bd23fbfaSmrgconst char * EXE_PATH_VALUE   = "$func_to_host_path_result";
57018c4a8e55SmrgEOF
5702b042e37fSmrg	    else
57038c4a8e55Smrg	      cat <<"EOF"
57048c4a8e55Smrgconst char * EXE_PATH_VARNAME = "";
57058c4a8e55Smrgconst char * EXE_PATH_VALUE   = "";
57068c4a8e55SmrgEOF
5707b042e37fSmrg	    fi
57088c4a8e55Smrg
57093169be4bSmrg	    if test yes = "$fast_install"; then
57108c4a8e55Smrg	      cat <<EOF
57118c4a8e55Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
57128c4a8e55SmrgEOF
5713b042e37fSmrg	    else
57148c4a8e55Smrg	      cat <<EOF
57158c4a8e55Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
57168c4a8e55SmrgEOF
5717b042e37fSmrg	    fi
5718b042e37fSmrg
5719b042e37fSmrg
57208c4a8e55Smrg	    cat <<"EOF"
5721b042e37fSmrg
57228c4a8e55Smrg#define LTWRAPPER_OPTION_PREFIX         "--lt-"
5723b042e37fSmrg
57248c4a8e55Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
57258c4a8e55Smrgstatic const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
5726706b6b52Smrgstatic const char *debug_opt            = LTWRAPPER_OPTION_PREFIX "debug";
5727b042e37fSmrg
57288c4a8e55Smrgint
57298c4a8e55Smrgmain (int argc, char *argv[])
57308c4a8e55Smrg{
57318c4a8e55Smrg  char **newargz;
57328c4a8e55Smrg  int  newargc;
57338c4a8e55Smrg  char *tmp_pathspec;
57348c4a8e55Smrg  char *actual_cwrapper_path;
57358c4a8e55Smrg  char *actual_cwrapper_name;
57368c4a8e55Smrg  char *target_name;
57378c4a8e55Smrg  char *lt_argv_zero;
57383169be4bSmrg  int rval = 127;
5739b042e37fSmrg
57408c4a8e55Smrg  int i;
5741b042e37fSmrg
57428c4a8e55Smrg  program_name = (char *) xstrdup (base_name (argv[0]));
57433169be4bSmrg  newargz = XMALLOC (char *, (size_t) argc + 1);
5744b042e37fSmrg
5745706b6b52Smrg  /* very simple arg parsing; don't want to rely on getopt
5746706b6b52Smrg   * also, copy all non cwrapper options to newargz, except
5747706b6b52Smrg   * argz[0], which is handled differently
5748706b6b52Smrg   */
5749706b6b52Smrg  newargc=0;
57508c4a8e55Smrg  for (i = 1; i < argc; i++)
57518c4a8e55Smrg    {
57523169be4bSmrg      if (STREQ (argv[i], dumpscript_opt))
57538c4a8e55Smrg	{
57548c4a8e55SmrgEOF
57553169be4bSmrg	    case $host in
57568c4a8e55Smrg	      *mingw* | *cygwin* )
57578c4a8e55Smrg		# make stdout use "unix" line endings
57588c4a8e55Smrg		echo "          setmode(1,_O_BINARY);"
57598c4a8e55Smrg		;;
57608c4a8e55Smrg	      esac
5761b042e37fSmrg
57628c4a8e55Smrg	    cat <<"EOF"
5763706b6b52Smrg	  lt_dump_script (stdout);
57648c4a8e55Smrg	  return 0;
57658c4a8e55Smrg	}
57663169be4bSmrg      if (STREQ (argv[i], debug_opt))
5767706b6b52Smrg	{
5768706b6b52Smrg          lt_debug = 1;
5769706b6b52Smrg          continue;
5770706b6b52Smrg	}
57713169be4bSmrg      if (STREQ (argv[i], ltwrapper_option_prefix))
5772706b6b52Smrg        {
5773706b6b52Smrg          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
5774706b6b52Smrg             namespace, but it is not one of the ones we know about and
5775706b6b52Smrg             have already dealt with, above (inluding dump-script), then
5776706b6b52Smrg             report an error. Otherwise, targets might begin to believe
5777706b6b52Smrg             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
5778706b6b52Smrg             namespace. The first time any user complains about this, we'll
5779706b6b52Smrg             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
5780706b6b52Smrg             or a configure.ac-settable value.
5781706b6b52Smrg           */
5782706b6b52Smrg          lt_fatal (__FILE__, __LINE__,
5783706b6b52Smrg		    "unrecognized %s option: '%s'",
5784706b6b52Smrg                    ltwrapper_option_prefix, argv[i]);
5785706b6b52Smrg        }
5786706b6b52Smrg      /* otherwise ... */
5787706b6b52Smrg      newargz[++newargc] = xstrdup (argv[i]);
57888c4a8e55Smrg    }
5789706b6b52Smrg  newargz[++newargc] = NULL;
5790706b6b52Smrg
5791706b6b52SmrgEOF
5792706b6b52Smrg	    cat <<EOF
5793706b6b52Smrg  /* The GNU banner must be the first non-error debug message */
57943169be4bSmrg  lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n");
5795706b6b52SmrgEOF
5796706b6b52Smrg	    cat <<"EOF"
5797706b6b52Smrg  lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
5798706b6b52Smrg  lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
5799b042e37fSmrg
58008c4a8e55Smrg  tmp_pathspec = find_executable (argv[0]);
58018c4a8e55Smrg  if (tmp_pathspec == NULL)
5802706b6b52Smrg    lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
5803706b6b52Smrg  lt_debugprintf (__FILE__, __LINE__,
5804706b6b52Smrg                  "(main) found exe (before symlink chase) at: %s\n",
5805706b6b52Smrg		  tmp_pathspec);
58068c4a8e55Smrg
58078c4a8e55Smrg  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
5808706b6b52Smrg  lt_debugprintf (__FILE__, __LINE__,
5809706b6b52Smrg                  "(main) found exe (after symlink chase) at: %s\n",
5810706b6b52Smrg		  actual_cwrapper_path);
58118c4a8e55Smrg  XFREE (tmp_pathspec);
58128c4a8e55Smrg
5813706b6b52Smrg  actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
58148c4a8e55Smrg  strendzap (actual_cwrapper_path, actual_cwrapper_name);
58158c4a8e55Smrg
58168c4a8e55Smrg  /* wrapper name transforms */
58178c4a8e55Smrg  strendzap (actual_cwrapper_name, ".exe");
58188c4a8e55Smrg  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
58198c4a8e55Smrg  XFREE (actual_cwrapper_name);
58208c4a8e55Smrg  actual_cwrapper_name = tmp_pathspec;
58218c4a8e55Smrg  tmp_pathspec = 0;
58228c4a8e55Smrg
58238c4a8e55Smrg  /* target_name transforms -- use actual target program name; might have lt- prefix */
58248c4a8e55Smrg  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
58258c4a8e55Smrg  strendzap (target_name, ".exe");
58268c4a8e55Smrg  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
58278c4a8e55Smrg  XFREE (target_name);
58288c4a8e55Smrg  target_name = tmp_pathspec;
58298c4a8e55Smrg  tmp_pathspec = 0;
58308c4a8e55Smrg
5831706b6b52Smrg  lt_debugprintf (__FILE__, __LINE__,
5832706b6b52Smrg		  "(main) libtool target name: %s\n",
5833706b6b52Smrg		  target_name);
58348c4a8e55SmrgEOF
5835b042e37fSmrg
58368c4a8e55Smrg	    cat <<EOF
58378c4a8e55Smrg  newargz[0] =
58388c4a8e55Smrg    XMALLOC (char, (strlen (actual_cwrapper_path) +
58398c4a8e55Smrg		    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
58408c4a8e55Smrg  strcpy (newargz[0], actual_cwrapper_path);
58418c4a8e55Smrg  strcat (newargz[0], "$objdir");
58428c4a8e55Smrg  strcat (newargz[0], "/");
58438c4a8e55SmrgEOF
5844b042e37fSmrg
58458c4a8e55Smrg	    cat <<"EOF"
58468c4a8e55Smrg  /* stop here, and copy so we don't have to do this twice */
58478c4a8e55Smrg  tmp_pathspec = xstrdup (newargz[0]);
5848b042e37fSmrg
58498c4a8e55Smrg  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
58508c4a8e55Smrg  strcat (newargz[0], actual_cwrapper_name);
5851b042e37fSmrg
58528c4a8e55Smrg  /* DO want the lt- prefix here if it exists, so use target_name */
58538c4a8e55Smrg  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
58548c4a8e55Smrg  XFREE (tmp_pathspec);
58558c4a8e55Smrg  tmp_pathspec = NULL;
58568c4a8e55SmrgEOF
5857b042e37fSmrg
58588c4a8e55Smrg	    case $host_os in
58598c4a8e55Smrg	      mingw*)
58608c4a8e55Smrg	    cat <<"EOF"
58618c4a8e55Smrg  {
58628c4a8e55Smrg    char* p;
58638c4a8e55Smrg    while ((p = strchr (newargz[0], '\\')) != NULL)
58648c4a8e55Smrg      {
58658c4a8e55Smrg	*p = '/';
58668c4a8e55Smrg      }
58678c4a8e55Smrg    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
58688c4a8e55Smrg      {
58698c4a8e55Smrg	*p = '/';
58708c4a8e55Smrg      }
58718c4a8e55Smrg  }
58728c4a8e55SmrgEOF
58738c4a8e55Smrg	    ;;
58748c4a8e55Smrg	    esac
5875b042e37fSmrg
58768c4a8e55Smrg	    cat <<"EOF"
58778c4a8e55Smrg  XFREE (target_name);
58788c4a8e55Smrg  XFREE (actual_cwrapper_path);
58798c4a8e55Smrg  XFREE (actual_cwrapper_name);
5880b042e37fSmrg
58818c4a8e55Smrg  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
58828c4a8e55Smrg  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
5883bd23fbfaSmrg  /* Update the DLL searchpath.  EXE_PATH_VALUE ($dllsearchpath) must
5884bd23fbfaSmrg     be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
5885bd23fbfaSmrg     because on Windows, both *_VARNAMEs are PATH but uninstalled
5886bd23fbfaSmrg     libraries must come first. */
58878c4a8e55Smrg  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
5888bd23fbfaSmrg  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
5889b042e37fSmrg
5890706b6b52Smrg  lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
5891706b6b52Smrg		  nonnull (lt_argv_zero));
58928c4a8e55Smrg  for (i = 0; i < newargc; i++)
58938c4a8e55Smrg    {
5894706b6b52Smrg      lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
5895706b6b52Smrg		      i, nonnull (newargz[i]));
58968c4a8e55Smrg    }
5897b042e37fSmrg
58988c4a8e55SmrgEOF
5899b042e37fSmrg
59008c4a8e55Smrg	    case $host_os in
59018c4a8e55Smrg	      mingw*)
59028c4a8e55Smrg		cat <<"EOF"
59038c4a8e55Smrg  /* execv doesn't actually work on mingw as expected on unix */
5904706b6b52Smrg  newargz = prepare_spawn (newargz);
59053169be4bSmrg  rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
59068c4a8e55Smrg  if (rval == -1)
59078c4a8e55Smrg    {
59088c4a8e55Smrg      /* failed to start process */
5909706b6b52Smrg      lt_debugprintf (__FILE__, __LINE__,
5910706b6b52Smrg		      "(main) failed to launch target \"%s\": %s\n",
5911706b6b52Smrg		      lt_argv_zero, nonnull (strerror (errno)));
59128c4a8e55Smrg      return 127;
59138c4a8e55Smrg    }
59148c4a8e55Smrg  return rval;
59158c4a8e55SmrgEOF
59168c4a8e55Smrg		;;
59178c4a8e55Smrg	      *)
59188c4a8e55Smrg		cat <<"EOF"
59198c4a8e55Smrg  execv (lt_argv_zero, newargz);
59208c4a8e55Smrg  return rval; /* =127, but avoids unused variable warning */
59218c4a8e55SmrgEOF
59228c4a8e55Smrg		;;
59238c4a8e55Smrg	    esac
5924b042e37fSmrg
59258c4a8e55Smrg	    cat <<"EOF"
59268c4a8e55Smrg}
5927b042e37fSmrg
59288c4a8e55Smrgvoid *
59298c4a8e55Smrgxmalloc (size_t num)
59308c4a8e55Smrg{
59318c4a8e55Smrg  void *p = (void *) malloc (num);
59328c4a8e55Smrg  if (!p)
5933706b6b52Smrg    lt_fatal (__FILE__, __LINE__, "memory exhausted");
5934b042e37fSmrg
59358c4a8e55Smrg  return p;
59368c4a8e55Smrg}
5937b042e37fSmrg
59388c4a8e55Smrgchar *
59398c4a8e55Smrgxstrdup (const char *string)
59408c4a8e55Smrg{
59418c4a8e55Smrg  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
59428c4a8e55Smrg			  string) : NULL;
59438c4a8e55Smrg}
5944b042e37fSmrg
59458c4a8e55Smrgconst char *
59468c4a8e55Smrgbase_name (const char *name)
59478c4a8e55Smrg{
59488c4a8e55Smrg  const char *base;
5949b042e37fSmrg
59503169be4bSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM
59518c4a8e55Smrg  /* Skip over the disk name in MSDOS pathnames. */
59528c4a8e55Smrg  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
59538c4a8e55Smrg    name += 2;
59548c4a8e55Smrg#endif
5955b042e37fSmrg
59568c4a8e55Smrg  for (base = name; *name; name++)
59578c4a8e55Smrg    if (IS_DIR_SEPARATOR (*name))
59588c4a8e55Smrg      base = name + 1;
59598c4a8e55Smrg  return base;
59608c4a8e55Smrg}
5961b042e37fSmrg
59628c4a8e55Smrgint
59638c4a8e55Smrgcheck_executable (const char *path)
59648c4a8e55Smrg{
59658c4a8e55Smrg  struct stat st;
5966b042e37fSmrg
5967706b6b52Smrg  lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
5968706b6b52Smrg                  nonempty (path));
59698c4a8e55Smrg  if ((!path) || (!*path))
59708c4a8e55Smrg    return 0;
5971b042e37fSmrg
59728c4a8e55Smrg  if ((stat (path, &st) >= 0)
59738c4a8e55Smrg      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
59748c4a8e55Smrg    return 1;
59758c4a8e55Smrg  else
59768c4a8e55Smrg    return 0;
59778c4a8e55Smrg}
5978b042e37fSmrg
59798c4a8e55Smrgint
59808c4a8e55Smrgmake_executable (const char *path)
59818c4a8e55Smrg{
59828c4a8e55Smrg  int rval = 0;
59838c4a8e55Smrg  struct stat st;
5984b042e37fSmrg
5985706b6b52Smrg  lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
5986706b6b52Smrg                  nonempty (path));
59878c4a8e55Smrg  if ((!path) || (!*path))
59888c4a8e55Smrg    return 0;
5989b042e37fSmrg
59908c4a8e55Smrg  if (stat (path, &st) >= 0)
59918c4a8e55Smrg    {
59928c4a8e55Smrg      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
59938c4a8e55Smrg    }
59948c4a8e55Smrg  return rval;
59958c4a8e55Smrg}
5996b042e37fSmrg
59978c4a8e55Smrg/* Searches for the full path of the wrapper.  Returns
59988c4a8e55Smrg   newly allocated full path name if found, NULL otherwise
59998c4a8e55Smrg   Does not chase symlinks, even on platforms that support them.
60008c4a8e55Smrg*/
60018c4a8e55Smrgchar *
60028c4a8e55Smrgfind_executable (const char *wrapper)
60038c4a8e55Smrg{
60048c4a8e55Smrg  int has_slash = 0;
60058c4a8e55Smrg  const char *p;
60068c4a8e55Smrg  const char *p_next;
60078c4a8e55Smrg  /* static buffer for getcwd */
60088c4a8e55Smrg  char tmp[LT_PATHMAX + 1];
60093169be4bSmrg  size_t tmp_len;
60108c4a8e55Smrg  char *concat_name;
6011b042e37fSmrg
6012706b6b52Smrg  lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
6013706b6b52Smrg                  nonempty (wrapper));
6014b042e37fSmrg
60158c4a8e55Smrg  if ((wrapper == NULL) || (*wrapper == '\0'))
60168c4a8e55Smrg    return NULL;
6017b042e37fSmrg
60188c4a8e55Smrg  /* Absolute path? */
60193169be4bSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM
60208c4a8e55Smrg  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
60218c4a8e55Smrg    {
60228c4a8e55Smrg      concat_name = xstrdup (wrapper);
60238c4a8e55Smrg      if (check_executable (concat_name))
60248c4a8e55Smrg	return concat_name;
60258c4a8e55Smrg      XFREE (concat_name);
60268c4a8e55Smrg    }
60278c4a8e55Smrg  else
60288c4a8e55Smrg    {
60298c4a8e55Smrg#endif
60308c4a8e55Smrg      if (IS_DIR_SEPARATOR (wrapper[0]))
60318c4a8e55Smrg	{
60328c4a8e55Smrg	  concat_name = xstrdup (wrapper);
60338c4a8e55Smrg	  if (check_executable (concat_name))
60348c4a8e55Smrg	    return concat_name;
60358c4a8e55Smrg	  XFREE (concat_name);
60368c4a8e55Smrg	}
60373169be4bSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM
60388c4a8e55Smrg    }
60398c4a8e55Smrg#endif
6040b042e37fSmrg
60418c4a8e55Smrg  for (p = wrapper; *p; p++)
60428c4a8e55Smrg    if (*p == '/')
60438c4a8e55Smrg      {
60448c4a8e55Smrg	has_slash = 1;
60458c4a8e55Smrg	break;
60468c4a8e55Smrg      }
60478c4a8e55Smrg  if (!has_slash)
60488c4a8e55Smrg    {
60498c4a8e55Smrg      /* no slashes; search PATH */
60508c4a8e55Smrg      const char *path = getenv ("PATH");
60518c4a8e55Smrg      if (path != NULL)
60528c4a8e55Smrg	{
60538c4a8e55Smrg	  for (p = path; *p; p = p_next)
60548c4a8e55Smrg	    {
60558c4a8e55Smrg	      const char *q;
60568c4a8e55Smrg	      size_t p_len;
60578c4a8e55Smrg	      for (q = p; *q; q++)
60588c4a8e55Smrg		if (IS_PATH_SEPARATOR (*q))
60598c4a8e55Smrg		  break;
60603169be4bSmrg	      p_len = (size_t) (q - p);
60618c4a8e55Smrg	      p_next = (*q == '\0' ? q : q + 1);
60628c4a8e55Smrg	      if (p_len == 0)
60638c4a8e55Smrg		{
60648c4a8e55Smrg		  /* empty path: current directory */
60658c4a8e55Smrg		  if (getcwd (tmp, LT_PATHMAX) == NULL)
6066706b6b52Smrg		    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
6067706b6b52Smrg                              nonnull (strerror (errno)));
60688c4a8e55Smrg		  tmp_len = strlen (tmp);
60698c4a8e55Smrg		  concat_name =
60708c4a8e55Smrg		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
60718c4a8e55Smrg		  memcpy (concat_name, tmp, tmp_len);
60728c4a8e55Smrg		  concat_name[tmp_len] = '/';
60738c4a8e55Smrg		  strcpy (concat_name + tmp_len + 1, wrapper);
60748c4a8e55Smrg		}
60758c4a8e55Smrg	      else
60768c4a8e55Smrg		{
60778c4a8e55Smrg		  concat_name =
60788c4a8e55Smrg		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
60798c4a8e55Smrg		  memcpy (concat_name, p, p_len);
60808c4a8e55Smrg		  concat_name[p_len] = '/';
60818c4a8e55Smrg		  strcpy (concat_name + p_len + 1, wrapper);
60828c4a8e55Smrg		}
60838c4a8e55Smrg	      if (check_executable (concat_name))
60848c4a8e55Smrg		return concat_name;
60858c4a8e55Smrg	      XFREE (concat_name);
60868c4a8e55Smrg	    }
60878c4a8e55Smrg	}
60888c4a8e55Smrg      /* not found in PATH; assume curdir */
60898c4a8e55Smrg    }
60908c4a8e55Smrg  /* Relative path | not found in path: prepend cwd */
60918c4a8e55Smrg  if (getcwd (tmp, LT_PATHMAX) == NULL)
6092706b6b52Smrg    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
6093706b6b52Smrg              nonnull (strerror (errno)));
60948c4a8e55Smrg  tmp_len = strlen (tmp);
60958c4a8e55Smrg  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
60968c4a8e55Smrg  memcpy (concat_name, tmp, tmp_len);
60978c4a8e55Smrg  concat_name[tmp_len] = '/';
60988c4a8e55Smrg  strcpy (concat_name + tmp_len + 1, wrapper);
6099b042e37fSmrg
61008c4a8e55Smrg  if (check_executable (concat_name))
61018c4a8e55Smrg    return concat_name;
61028c4a8e55Smrg  XFREE (concat_name);
61038c4a8e55Smrg  return NULL;
61048c4a8e55Smrg}
6105b042e37fSmrg
61068c4a8e55Smrgchar *
61078c4a8e55Smrgchase_symlinks (const char *pathspec)
61088c4a8e55Smrg{
61098c4a8e55Smrg#ifndef S_ISLNK
61108c4a8e55Smrg  return xstrdup (pathspec);
61118c4a8e55Smrg#else
61128c4a8e55Smrg  char buf[LT_PATHMAX];
61138c4a8e55Smrg  struct stat s;
61148c4a8e55Smrg  char *tmp_pathspec = xstrdup (pathspec);
61158c4a8e55Smrg  char *p;
61168c4a8e55Smrg  int has_symlinks = 0;
61178c4a8e55Smrg  while (strlen (tmp_pathspec) && !has_symlinks)
61188c4a8e55Smrg    {
6119706b6b52Smrg      lt_debugprintf (__FILE__, __LINE__,
6120706b6b52Smrg		      "checking path component for symlinks: %s\n",
6121706b6b52Smrg		      tmp_pathspec);
61228c4a8e55Smrg      if (lstat (tmp_pathspec, &s) == 0)
61238c4a8e55Smrg	{
61248c4a8e55Smrg	  if (S_ISLNK (s.st_mode) != 0)
61258c4a8e55Smrg	    {
61268c4a8e55Smrg	      has_symlinks = 1;
61278c4a8e55Smrg	      break;
61288c4a8e55Smrg	    }
6129b042e37fSmrg
61308c4a8e55Smrg	  /* search backwards for last DIR_SEPARATOR */
61318c4a8e55Smrg	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
61328c4a8e55Smrg	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
61338c4a8e55Smrg	    p--;
61348c4a8e55Smrg	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
61358c4a8e55Smrg	    {
61368c4a8e55Smrg	      /* no more DIR_SEPARATORS left */
61378c4a8e55Smrg	      break;
61388c4a8e55Smrg	    }
61398c4a8e55Smrg	  *p = '\0';
61408c4a8e55Smrg	}
61418c4a8e55Smrg      else
61428c4a8e55Smrg	{
6143706b6b52Smrg	  lt_fatal (__FILE__, __LINE__,
6144706b6b52Smrg		    "error accessing file \"%s\": %s",
6145706b6b52Smrg		    tmp_pathspec, nonnull (strerror (errno)));
61468c4a8e55Smrg	}
61478c4a8e55Smrg    }
61488c4a8e55Smrg  XFREE (tmp_pathspec);
6149b042e37fSmrg
61508c4a8e55Smrg  if (!has_symlinks)
61518c4a8e55Smrg    {
61528c4a8e55Smrg      return xstrdup (pathspec);
61538c4a8e55Smrg    }
6154b042e37fSmrg
61558c4a8e55Smrg  tmp_pathspec = realpath (pathspec, buf);
61568c4a8e55Smrg  if (tmp_pathspec == 0)
61578c4a8e55Smrg    {
6158706b6b52Smrg      lt_fatal (__FILE__, __LINE__,
6159706b6b52Smrg		"could not follow symlinks for %s", pathspec);
61608c4a8e55Smrg    }
61618c4a8e55Smrg  return xstrdup (tmp_pathspec);
61628c4a8e55Smrg#endif
61638c4a8e55Smrg}
6164b042e37fSmrg
61658c4a8e55Smrgchar *
61668c4a8e55Smrgstrendzap (char *str, const char *pat)
61678c4a8e55Smrg{
61688c4a8e55Smrg  size_t len, patlen;
6169b042e37fSmrg
61708c4a8e55Smrg  assert (str != NULL);
61718c4a8e55Smrg  assert (pat != NULL);
6172b042e37fSmrg
61738c4a8e55Smrg  len = strlen (str);
61748c4a8e55Smrg  patlen = strlen (pat);
6175b042e37fSmrg
61768c4a8e55Smrg  if (patlen <= len)
61778c4a8e55Smrg    {
61788c4a8e55Smrg      str += len - patlen;
61793169be4bSmrg      if (STREQ (str, pat))
61808c4a8e55Smrg	*str = '\0';
61818c4a8e55Smrg    }
61828c4a8e55Smrg  return str;
61838c4a8e55Smrg}
6184b042e37fSmrg
6185706b6b52Smrgvoid
6186706b6b52Smrglt_debugprintf (const char *file, int line, const char *fmt, ...)
6187706b6b52Smrg{
6188706b6b52Smrg  va_list args;
6189706b6b52Smrg  if (lt_debug)
6190706b6b52Smrg    {
6191706b6b52Smrg      (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
6192706b6b52Smrg      va_start (args, fmt);
6193706b6b52Smrg      (void) vfprintf (stderr, fmt, args);
6194706b6b52Smrg      va_end (args);
6195706b6b52Smrg    }
6196706b6b52Smrg}
6197706b6b52Smrg
61988c4a8e55Smrgstatic void
6199706b6b52Smrglt_error_core (int exit_status, const char *file,
6200706b6b52Smrg	       int line, const char *mode,
62018c4a8e55Smrg	       const char *message, va_list ap)
62028c4a8e55Smrg{
6203706b6b52Smrg  fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
62048c4a8e55Smrg  vfprintf (stderr, message, ap);
62058c4a8e55Smrg  fprintf (stderr, ".\n");
6206b042e37fSmrg
62078c4a8e55Smrg  if (exit_status >= 0)
62088c4a8e55Smrg    exit (exit_status);
62098c4a8e55Smrg}
6210b042e37fSmrg
62118c4a8e55Smrgvoid
6212706b6b52Smrglt_fatal (const char *file, int line, const char *message, ...)
62138c4a8e55Smrg{
62148c4a8e55Smrg  va_list ap;
62158c4a8e55Smrg  va_start (ap, message);
6216706b6b52Smrg  lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
62178c4a8e55Smrg  va_end (ap);
62188c4a8e55Smrg}
6219b042e37fSmrg
6220706b6b52Smrgstatic const char *
6221706b6b52Smrgnonnull (const char *s)
6222706b6b52Smrg{
6223706b6b52Smrg  return s ? s : "(null)";
6224706b6b52Smrg}
6225706b6b52Smrg
6226706b6b52Smrgstatic const char *
6227706b6b52Smrgnonempty (const char *s)
6228706b6b52Smrg{
6229706b6b52Smrg  return (s && !*s) ? "(empty)" : nonnull (s);
6230706b6b52Smrg}
6231706b6b52Smrg
62328c4a8e55Smrgvoid
62338c4a8e55Smrglt_setenv (const char *name, const char *value)
62348c4a8e55Smrg{
6235706b6b52Smrg  lt_debugprintf (__FILE__, __LINE__,
6236706b6b52Smrg		  "(lt_setenv) setting '%s' to '%s'\n",
6237706b6b52Smrg                  nonnull (name), nonnull (value));
62388c4a8e55Smrg  {
62398c4a8e55Smrg#ifdef HAVE_SETENV
62408c4a8e55Smrg    /* always make a copy, for consistency with !HAVE_SETENV */
62418c4a8e55Smrg    char *str = xstrdup (value);
62428c4a8e55Smrg    setenv (name, str, 1);
62438c4a8e55Smrg#else
62443169be4bSmrg    size_t len = strlen (name) + 1 + strlen (value) + 1;
62458c4a8e55Smrg    char *str = XMALLOC (char, len);
62468c4a8e55Smrg    sprintf (str, "%s=%s", name, value);
62478c4a8e55Smrg    if (putenv (str) != EXIT_SUCCESS)
62488c4a8e55Smrg      {
62498c4a8e55Smrg        XFREE (str);
62508c4a8e55Smrg      }
62518c4a8e55Smrg#endif
62528c4a8e55Smrg  }
62538c4a8e55Smrg}
6254b042e37fSmrg
62558c4a8e55Smrgchar *
62568c4a8e55Smrglt_extend_str (const char *orig_value, const char *add, int to_end)
62578c4a8e55Smrg{
62588c4a8e55Smrg  char *new_value;
62598c4a8e55Smrg  if (orig_value && *orig_value)
62608c4a8e55Smrg    {
62613169be4bSmrg      size_t orig_value_len = strlen (orig_value);
62623169be4bSmrg      size_t add_len = strlen (add);
62638c4a8e55Smrg      new_value = XMALLOC (char, add_len + orig_value_len + 1);
62648c4a8e55Smrg      if (to_end)
62658c4a8e55Smrg        {
62668c4a8e55Smrg          strcpy (new_value, orig_value);
62678c4a8e55Smrg          strcpy (new_value + orig_value_len, add);
62688c4a8e55Smrg        }
62698c4a8e55Smrg      else
62708c4a8e55Smrg        {
62718c4a8e55Smrg          strcpy (new_value, add);
62728c4a8e55Smrg          strcpy (new_value + add_len, orig_value);
62738c4a8e55Smrg        }
62748c4a8e55Smrg    }
62758c4a8e55Smrg  else
62768c4a8e55Smrg    {
62778c4a8e55Smrg      new_value = xstrdup (add);
62788c4a8e55Smrg    }
62798c4a8e55Smrg  return new_value;
62808c4a8e55Smrg}
6281b042e37fSmrg
62828c4a8e55Smrgvoid
62838c4a8e55Smrglt_update_exe_path (const char *name, const char *value)
62848c4a8e55Smrg{
6285706b6b52Smrg  lt_debugprintf (__FILE__, __LINE__,
6286706b6b52Smrg		  "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
6287706b6b52Smrg                  nonnull (name), nonnull (value));
6288b042e37fSmrg
62898c4a8e55Smrg  if (name && *name && value && *value)
62908c4a8e55Smrg    {
62918c4a8e55Smrg      char *new_value = lt_extend_str (getenv (name), value, 0);
62928c4a8e55Smrg      /* some systems can't cope with a ':'-terminated path #' */
62933169be4bSmrg      size_t len = strlen (new_value);
62943169be4bSmrg      while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
62958c4a8e55Smrg        {
62963169be4bSmrg          new_value[--len] = '\0';
62978c4a8e55Smrg        }
62988c4a8e55Smrg      lt_setenv (name, new_value);
62998c4a8e55Smrg      XFREE (new_value);
63008c4a8e55Smrg    }
63018c4a8e55Smrg}
6302b042e37fSmrg
63038c4a8e55Smrgvoid
63048c4a8e55Smrglt_update_lib_path (const char *name, const char *value)
63058c4a8e55Smrg{
6306706b6b52Smrg  lt_debugprintf (__FILE__, __LINE__,
6307706b6b52Smrg		  "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
6308706b6b52Smrg                  nonnull (name), nonnull (value));
6309b042e37fSmrg
63108c4a8e55Smrg  if (name && *name && value && *value)
63118c4a8e55Smrg    {
63128c4a8e55Smrg      char *new_value = lt_extend_str (getenv (name), value, 0);
63138c4a8e55Smrg      lt_setenv (name, new_value);
63148c4a8e55Smrg      XFREE (new_value);
63158c4a8e55Smrg    }
63168c4a8e55Smrg}
6317b042e37fSmrg
6318706b6b52SmrgEOF
6319706b6b52Smrg	    case $host_os in
6320706b6b52Smrg	      mingw*)
6321706b6b52Smrg		cat <<"EOF"
6322706b6b52Smrg
6323706b6b52Smrg/* Prepares an argument vector before calling spawn().
6324706b6b52Smrg   Note that spawn() does not by itself call the command interpreter
6325706b6b52Smrg     (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
6326706b6b52Smrg      ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
6327706b6b52Smrg         GetVersionEx(&v);
6328706b6b52Smrg         v.dwPlatformId == VER_PLATFORM_WIN32_NT;
6329706b6b52Smrg      }) ? "cmd.exe" : "command.com").
6330706b6b52Smrg   Instead it simply concatenates the arguments, separated by ' ', and calls
6331706b6b52Smrg   CreateProcess().  We must quote the arguments since Win32 CreateProcess()
6332706b6b52Smrg   interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
6333706b6b52Smrg   special way:
6334706b6b52Smrg   - Space and tab are interpreted as delimiters. They are not treated as
6335706b6b52Smrg     delimiters if they are surrounded by double quotes: "...".
6336706b6b52Smrg   - Unescaped double quotes are removed from the input. Their only effect is
6337706b6b52Smrg     that within double quotes, space and tab are treated like normal
6338706b6b52Smrg     characters.
6339706b6b52Smrg   - Backslashes not followed by double quotes are not special.
6340706b6b52Smrg   - But 2*n+1 backslashes followed by a double quote become
6341706b6b52Smrg     n backslashes followed by a double quote (n >= 0):
6342706b6b52Smrg       \" -> "
6343706b6b52Smrg       \\\" -> \"
6344706b6b52Smrg       \\\\\" -> \\"
6345706b6b52Smrg */
6346706b6b52Smrg#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"
6347706b6b52Smrg#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"
6348706b6b52Smrgchar **
6349706b6b52Smrgprepare_spawn (char **argv)
6350706b6b52Smrg{
6351706b6b52Smrg  size_t argc;
6352706b6b52Smrg  char **new_argv;
6353706b6b52Smrg  size_t i;
6354706b6b52Smrg
6355706b6b52Smrg  /* Count number of arguments.  */
6356706b6b52Smrg  for (argc = 0; argv[argc] != NULL; argc++)
6357706b6b52Smrg    ;
6358706b6b52Smrg
6359706b6b52Smrg  /* Allocate new argument vector.  */
6360706b6b52Smrg  new_argv = XMALLOC (char *, argc + 1);
6361706b6b52Smrg
6362706b6b52Smrg  /* Put quoted arguments into the new argument vector.  */
6363706b6b52Smrg  for (i = 0; i < argc; i++)
6364706b6b52Smrg    {
6365706b6b52Smrg      const char *string = argv[i];
6366706b6b52Smrg
6367706b6b52Smrg      if (string[0] == '\0')
6368706b6b52Smrg	new_argv[i] = xstrdup ("\"\"");
6369706b6b52Smrg      else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
6370706b6b52Smrg	{
6371706b6b52Smrg	  int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
6372706b6b52Smrg	  size_t length;
6373706b6b52Smrg	  unsigned int backslashes;
6374706b6b52Smrg	  const char *s;
6375706b6b52Smrg	  char *quoted_string;
6376706b6b52Smrg	  char *p;
6377706b6b52Smrg
6378706b6b52Smrg	  length = 0;
6379706b6b52Smrg	  backslashes = 0;
6380706b6b52Smrg	  if (quote_around)
6381706b6b52Smrg	    length++;
6382706b6b52Smrg	  for (s = string; *s != '\0'; s++)
6383706b6b52Smrg	    {
6384706b6b52Smrg	      char c = *s;
6385706b6b52Smrg	      if (c == '"')
6386706b6b52Smrg		length += backslashes + 1;
6387706b6b52Smrg	      length++;
6388706b6b52Smrg	      if (c == '\\')
6389706b6b52Smrg		backslashes++;
6390706b6b52Smrg	      else
6391706b6b52Smrg		backslashes = 0;
6392706b6b52Smrg	    }
6393706b6b52Smrg	  if (quote_around)
6394706b6b52Smrg	    length += backslashes + 1;
6395706b6b52Smrg
6396706b6b52Smrg	  quoted_string = XMALLOC (char, length + 1);
6397706b6b52Smrg
6398706b6b52Smrg	  p = quoted_string;
6399706b6b52Smrg	  backslashes = 0;
6400706b6b52Smrg	  if (quote_around)
6401706b6b52Smrg	    *p++ = '"';
6402706b6b52Smrg	  for (s = string; *s != '\0'; s++)
6403706b6b52Smrg	    {
6404706b6b52Smrg	      char c = *s;
6405706b6b52Smrg	      if (c == '"')
6406706b6b52Smrg		{
6407706b6b52Smrg		  unsigned int j;
6408706b6b52Smrg		  for (j = backslashes + 1; j > 0; j--)
6409706b6b52Smrg		    *p++ = '\\';
6410706b6b52Smrg		}
6411706b6b52Smrg	      *p++ = c;
6412706b6b52Smrg	      if (c == '\\')
6413706b6b52Smrg		backslashes++;
6414706b6b52Smrg	      else
6415706b6b52Smrg		backslashes = 0;
6416706b6b52Smrg	    }
6417706b6b52Smrg	  if (quote_around)
6418706b6b52Smrg	    {
6419706b6b52Smrg	      unsigned int j;
6420706b6b52Smrg	      for (j = backslashes; j > 0; j--)
6421706b6b52Smrg		*p++ = '\\';
6422706b6b52Smrg	      *p++ = '"';
6423706b6b52Smrg	    }
6424706b6b52Smrg	  *p = '\0';
6425706b6b52Smrg
6426706b6b52Smrg	  new_argv[i] = quoted_string;
6427706b6b52Smrg	}
6428706b6b52Smrg      else
6429706b6b52Smrg	new_argv[i] = (char *) string;
6430706b6b52Smrg    }
6431706b6b52Smrg  new_argv[argc] = NULL;
6432706b6b52Smrg
6433706b6b52Smrg  return new_argv;
6434706b6b52Smrg}
6435706b6b52SmrgEOF
6436706b6b52Smrg		;;
6437706b6b52Smrg	    esac
6438706b6b52Smrg
6439706b6b52Smrg            cat <<"EOF"
6440706b6b52Smrgvoid lt_dump_script (FILE* f)
6441706b6b52Smrg{
6442706b6b52SmrgEOF
6443706b6b52Smrg	    func_emit_wrapper yes |
64440597fb56Smrg	      $SED -n -e '
64450597fb56Smrgs/^\(.\{79\}\)\(..*\)/\1\
64460597fb56Smrg\2/
64470597fb56Smrgh
64480597fb56Smrgs/\([\\"]\)/\\\1/g
64490597fb56Smrgs/$/\\n/
64500597fb56Smrgs/\([^\n]*\).*/  fputs ("\1", f);/p
64510597fb56Smrgg
64520597fb56SmrgD'
6453706b6b52Smrg            cat <<"EOF"
6454706b6b52Smrg}
64558c4a8e55SmrgEOF
64568c4a8e55Smrg}
64578c4a8e55Smrg# end: func_emit_cwrapperexe_src
6458b042e37fSmrg
6459706b6b52Smrg# func_win32_import_lib_p ARG
6460706b6b52Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd
6461706b6b52Smrgfunc_win32_import_lib_p ()
6462706b6b52Smrg{
64633169be4bSmrg    $debug_cmd
64643169be4bSmrg
6465706b6b52Smrg    case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
6466706b6b52Smrg    *import*) : ;;
6467706b6b52Smrg    *) false ;;
6468706b6b52Smrg    esac
6469706b6b52Smrg}
6470706b6b52Smrg
64713169be4bSmrg# func_suncc_cstd_abi
64723169be4bSmrg# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!!
64733169be4bSmrg# Several compiler flags select an ABI that is incompatible with the
64743169be4bSmrg# Cstd library. Avoid specifying it if any are in CXXFLAGS.
64753169be4bSmrgfunc_suncc_cstd_abi ()
64763169be4bSmrg{
64773169be4bSmrg    $debug_cmd
64783169be4bSmrg
64793169be4bSmrg    case " $compile_command " in
64803169be4bSmrg    *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*)
64813169be4bSmrg      suncc_use_cstd_abi=no
64823169be4bSmrg      ;;
64833169be4bSmrg    *)
64843169be4bSmrg      suncc_use_cstd_abi=yes
64853169be4bSmrg      ;;
64863169be4bSmrg    esac
64873169be4bSmrg}
64883169be4bSmrg
64898c4a8e55Smrg# func_mode_link arg...
64908c4a8e55Smrgfunc_mode_link ()
64918c4a8e55Smrg{
64923169be4bSmrg    $debug_cmd
64933169be4bSmrg
64948c4a8e55Smrg    case $host in
64958c4a8e55Smrg    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
64968c4a8e55Smrg      # It is impossible to link a dll without this setting, and
64978c4a8e55Smrg      # we shouldn't force the makefile maintainer to figure out
64983169be4bSmrg      # what system we are compiling for in order to pass an extra
64998c4a8e55Smrg      # flag for every libtool invocation.
65008c4a8e55Smrg      # allow_undefined=no
6501b042e37fSmrg
65028c4a8e55Smrg      # FIXME: Unfortunately, there are problems with the above when trying
65033169be4bSmrg      # to make a dll that has undefined symbols, in which case not
65048c4a8e55Smrg      # even a static library is built.  For now, we need to specify
65058c4a8e55Smrg      # -no-undefined on the libtool link line when we can be certain
65068c4a8e55Smrg      # that all symbols are satisfied, otherwise we get a static library.
65078c4a8e55Smrg      allow_undefined=yes
65088c4a8e55Smrg      ;;
65098c4a8e55Smrg    *)
65108c4a8e55Smrg      allow_undefined=yes
65118c4a8e55Smrg      ;;
65128c4a8e55Smrg    esac
65138c4a8e55Smrg    libtool_args=$nonopt
65148c4a8e55Smrg    base_compile="$nonopt $@"
65158c4a8e55Smrg    compile_command=$nonopt
65168c4a8e55Smrg    finalize_command=$nonopt
6517b042e37fSmrg
65188c4a8e55Smrg    compile_rpath=
65198c4a8e55Smrg    finalize_rpath=
65208c4a8e55Smrg    compile_shlibpath=
65218c4a8e55Smrg    finalize_shlibpath=
65228c4a8e55Smrg    convenience=
65238c4a8e55Smrg    old_convenience=
65248c4a8e55Smrg    deplibs=
65258c4a8e55Smrg    old_deplibs=
65268c4a8e55Smrg    compiler_flags=
65278c4a8e55Smrg    linker_flags=
65288c4a8e55Smrg    dllsearchpath=
65298c4a8e55Smrg    lib_search_path=`pwd`
65308c4a8e55Smrg    inst_prefix_dir=
65318c4a8e55Smrg    new_inherited_linker_flags=
6532b042e37fSmrg
65338c4a8e55Smrg    avoid_version=no
6534706b6b52Smrg    bindir=
65358c4a8e55Smrg    dlfiles=
65368c4a8e55Smrg    dlprefiles=
65378c4a8e55Smrg    dlself=no
65388c4a8e55Smrg    export_dynamic=no
65398c4a8e55Smrg    export_symbols=
65408c4a8e55Smrg    export_symbols_regex=
65418c4a8e55Smrg    generated=
65428c4a8e55Smrg    libobjs=
65438c4a8e55Smrg    ltlibs=
65448c4a8e55Smrg    module=no
65458c4a8e55Smrg    no_install=no
65468c4a8e55Smrg    objs=
65473169be4bSmrg    os2dllname=
65488c4a8e55Smrg    non_pic_objects=
65498c4a8e55Smrg    precious_files_regex=
65508c4a8e55Smrg    prefer_static_libs=no
65513169be4bSmrg    preload=false
65528c4a8e55Smrg    prev=
65538c4a8e55Smrg    prevarg=
65548c4a8e55Smrg    release=
65558c4a8e55Smrg    rpath=
65568c4a8e55Smrg    xrpath=
65578c4a8e55Smrg    perm_rpath=
65588c4a8e55Smrg    temp_rpath=
65598c4a8e55Smrg    thread_safe=no
65608c4a8e55Smrg    vinfo=
65618c4a8e55Smrg    vinfo_number=no
65628c4a8e55Smrg    weak_libs=
65633169be4bSmrg    single_module=$wl-single_module
65648c4a8e55Smrg    func_infer_tag $base_compile
6565b042e37fSmrg
65668c4a8e55Smrg    # We need to know -static, to get the right output filenames.
65678c4a8e55Smrg    for arg
65688c4a8e55Smrg    do
65698c4a8e55Smrg      case $arg in
65708c4a8e55Smrg      -shared)
65713169be4bSmrg	test yes != "$build_libtool_libs" \
65723169be4bSmrg	  && func_fatal_configuration "cannot build a shared library"
65738c4a8e55Smrg	build_old_libs=no
65748c4a8e55Smrg	break
65758c4a8e55Smrg	;;
65768c4a8e55Smrg      -all-static | -static | -static-libtool-libs)
65778c4a8e55Smrg	case $arg in
65788c4a8e55Smrg	-all-static)
65793169be4bSmrg	  if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then
65808c4a8e55Smrg	    func_warning "complete static linking is impossible in this configuration"
65818c4a8e55Smrg	  fi
65828c4a8e55Smrg	  if test -n "$link_static_flag"; then
65838c4a8e55Smrg	    dlopen_self=$dlopen_self_static
65848c4a8e55Smrg	  fi
65858c4a8e55Smrg	  prefer_static_libs=yes
65868c4a8e55Smrg	  ;;
65878c4a8e55Smrg	-static)
65888c4a8e55Smrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
65898c4a8e55Smrg	    dlopen_self=$dlopen_self_static
65908c4a8e55Smrg	  fi
65918c4a8e55Smrg	  prefer_static_libs=built
65928c4a8e55Smrg	  ;;
65938c4a8e55Smrg	-static-libtool-libs)
65948c4a8e55Smrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
65958c4a8e55Smrg	    dlopen_self=$dlopen_self_static
65968c4a8e55Smrg	  fi
65978c4a8e55Smrg	  prefer_static_libs=yes
65988c4a8e55Smrg	  ;;
65998c4a8e55Smrg	esac
66008c4a8e55Smrg	build_libtool_libs=no
66018c4a8e55Smrg	build_old_libs=yes
66028c4a8e55Smrg	break
66038c4a8e55Smrg	;;
66048c4a8e55Smrg      esac
66058c4a8e55Smrg    done
6606b042e37fSmrg
66078c4a8e55Smrg    # See if our shared archives depend on static archives.
66088c4a8e55Smrg    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
6609b042e37fSmrg
66108c4a8e55Smrg    # Go through the arguments, transforming them on the way.
66118c4a8e55Smrg    while test "$#" -gt 0; do
66123169be4bSmrg      arg=$1
66138c4a8e55Smrg      shift
66148c4a8e55Smrg      func_quote_for_eval "$arg"
66158c4a8e55Smrg      qarg=$func_quote_for_eval_unquoted_result
66168c4a8e55Smrg      func_append libtool_args " $func_quote_for_eval_result"
6617b042e37fSmrg
66188c4a8e55Smrg      # If the previous option needs an argument, assign it.
66198c4a8e55Smrg      if test -n "$prev"; then
66208c4a8e55Smrg	case $prev in
66218c4a8e55Smrg	output)
66228c4a8e55Smrg	  func_append compile_command " @OUTPUT@"
66238c4a8e55Smrg	  func_append finalize_command " @OUTPUT@"
66248c4a8e55Smrg	  ;;
66258c4a8e55Smrg	esac
6626b042e37fSmrg
66278c4a8e55Smrg	case $prev in
6628706b6b52Smrg	bindir)
66293169be4bSmrg	  bindir=$arg
6630706b6b52Smrg	  prev=
6631706b6b52Smrg	  continue
6632706b6b52Smrg	  ;;
66338c4a8e55Smrg	dlfiles|dlprefiles)
66343169be4bSmrg	  $preload || {
66358c4a8e55Smrg	    # Add the symbol object into the linking commands.
66368c4a8e55Smrg	    func_append compile_command " @SYMFILE@"
66378c4a8e55Smrg	    func_append finalize_command " @SYMFILE@"
66383169be4bSmrg	    preload=:
66393169be4bSmrg	  }
66408c4a8e55Smrg	  case $arg in
66418c4a8e55Smrg	  *.la | *.lo) ;;  # We handle these cases below.
66428c4a8e55Smrg	  force)
66433169be4bSmrg	    if test no = "$dlself"; then
66448c4a8e55Smrg	      dlself=needless
66458c4a8e55Smrg	      export_dynamic=yes
66468c4a8e55Smrg	    fi
66478c4a8e55Smrg	    prev=
66488c4a8e55Smrg	    continue
66498c4a8e55Smrg	    ;;
66508c4a8e55Smrg	  self)
66513169be4bSmrg	    if test dlprefiles = "$prev"; then
66528c4a8e55Smrg	      dlself=yes
66533169be4bSmrg	    elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then
66548c4a8e55Smrg	      dlself=yes
66558c4a8e55Smrg	    else
66568c4a8e55Smrg	      dlself=needless
66578c4a8e55Smrg	      export_dynamic=yes
66588c4a8e55Smrg	    fi
66598c4a8e55Smrg	    prev=
66608c4a8e55Smrg	    continue
66618c4a8e55Smrg	    ;;
66628c4a8e55Smrg	  *)
66633169be4bSmrg	    if test dlfiles = "$prev"; then
6664bd23fbfaSmrg	      func_append dlfiles " $arg"
66658c4a8e55Smrg	    else
6666bd23fbfaSmrg	      func_append dlprefiles " $arg"
66678c4a8e55Smrg	    fi
66688c4a8e55Smrg	    prev=
66698c4a8e55Smrg	    continue
66708c4a8e55Smrg	    ;;
66718c4a8e55Smrg	  esac
66728c4a8e55Smrg	  ;;
66738c4a8e55Smrg	expsyms)
66743169be4bSmrg	  export_symbols=$arg
66758c4a8e55Smrg	  test -f "$arg" \
66763169be4bSmrg	    || func_fatal_error "symbol file '$arg' does not exist"
66778c4a8e55Smrg	  prev=
66788c4a8e55Smrg	  continue
66798c4a8e55Smrg	  ;;
66808c4a8e55Smrg	expsyms_regex)
66813169be4bSmrg	  export_symbols_regex=$arg
66828c4a8e55Smrg	  prev=
66838c4a8e55Smrg	  continue
66848c4a8e55Smrg	  ;;
66858c4a8e55Smrg	framework)
66868c4a8e55Smrg	  case $host in
66878c4a8e55Smrg	    *-*-darwin*)
66888c4a8e55Smrg	      case "$deplibs " in
66898c4a8e55Smrg		*" $qarg.ltframework "*) ;;
6690bd23fbfaSmrg		*) func_append deplibs " $qarg.ltframework" # this is fixed later
66918c4a8e55Smrg		   ;;
66928c4a8e55Smrg	      esac
6693b042e37fSmrg	      ;;
66948c4a8e55Smrg	  esac
66958c4a8e55Smrg	  prev=
66968c4a8e55Smrg	  continue
66978c4a8e55Smrg	  ;;
66988c4a8e55Smrg	inst_prefix)
66993169be4bSmrg	  inst_prefix_dir=$arg
67003169be4bSmrg	  prev=
67013169be4bSmrg	  continue
67023169be4bSmrg	  ;;
67033169be4bSmrg	mllvm)
67043169be4bSmrg	  # Clang does not use LLVM to link, so we can simply discard any
67053169be4bSmrg	  # '-mllvm $arg' options when doing the link step.
67068c4a8e55Smrg	  prev=
67078c4a8e55Smrg	  continue
67088c4a8e55Smrg	  ;;
67098c4a8e55Smrg	objectlist)
67108c4a8e55Smrg	  if test -f "$arg"; then
67118c4a8e55Smrg	    save_arg=$arg
67128c4a8e55Smrg	    moreargs=
67138c4a8e55Smrg	    for fil in `cat "$save_arg"`
67148c4a8e55Smrg	    do
6715bd23fbfaSmrg#	      func_append moreargs " $fil"
67168c4a8e55Smrg	      arg=$fil
67178c4a8e55Smrg	      # A libtool-controlled object.
6718b042e37fSmrg
67198c4a8e55Smrg	      # Check to see that this really is a libtool object.
67208c4a8e55Smrg	      if func_lalib_unsafe_p "$arg"; then
67218c4a8e55Smrg		pic_object=
67228c4a8e55Smrg		non_pic_object=
6723b042e37fSmrg
67248c4a8e55Smrg		# Read the .lo file
67258c4a8e55Smrg		func_source "$arg"
6726b042e37fSmrg
67278c4a8e55Smrg		if test -z "$pic_object" ||
67288c4a8e55Smrg		   test -z "$non_pic_object" ||
67293169be4bSmrg		   test none = "$pic_object" &&
67303169be4bSmrg		   test none = "$non_pic_object"; then
67313169be4bSmrg		  func_fatal_error "cannot find name of object for '$arg'"
67328c4a8e55Smrg		fi
6733b042e37fSmrg
67348c4a8e55Smrg		# Extract subdirectory from the argument.
67358c4a8e55Smrg		func_dirname "$arg" "/" ""
67363169be4bSmrg		xdir=$func_dirname_result
6737b042e37fSmrg
67383169be4bSmrg		if test none != "$pic_object"; then
67398c4a8e55Smrg		  # Prepend the subdirectory the object is found in.
67403169be4bSmrg		  pic_object=$xdir$pic_object
6741b042e37fSmrg
67423169be4bSmrg		  if test dlfiles = "$prev"; then
67433169be4bSmrg		    if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
6744bd23fbfaSmrg		      func_append dlfiles " $pic_object"
67458c4a8e55Smrg		      prev=
67468c4a8e55Smrg		      continue
67478c4a8e55Smrg		    else
67488c4a8e55Smrg		      # If libtool objects are unsupported, then we need to preload.
67498c4a8e55Smrg		      prev=dlprefiles
67508c4a8e55Smrg		    fi
67518c4a8e55Smrg		  fi
6752b042e37fSmrg
67538c4a8e55Smrg		  # CHECK ME:  I think I busted this.  -Ossama
67543169be4bSmrg		  if test dlprefiles = "$prev"; then
67558c4a8e55Smrg		    # Preload the old-style object.
6756bd23fbfaSmrg		    func_append dlprefiles " $pic_object"
67578c4a8e55Smrg		    prev=
67588c4a8e55Smrg		  fi
6759b042e37fSmrg
67608c4a8e55Smrg		  # A PIC object.
67618c4a8e55Smrg		  func_append libobjs " $pic_object"
67623169be4bSmrg		  arg=$pic_object
67638c4a8e55Smrg		fi
6764b042e37fSmrg
67658c4a8e55Smrg		# Non-PIC object.
67663169be4bSmrg		if test none != "$non_pic_object"; then
67678c4a8e55Smrg		  # Prepend the subdirectory the object is found in.
67683169be4bSmrg		  non_pic_object=$xdir$non_pic_object
6769b042e37fSmrg
67708c4a8e55Smrg		  # A standard non-PIC object
67718c4a8e55Smrg		  func_append non_pic_objects " $non_pic_object"
67723169be4bSmrg		  if test -z "$pic_object" || test none = "$pic_object"; then
67733169be4bSmrg		    arg=$non_pic_object
67748c4a8e55Smrg		  fi
67758c4a8e55Smrg		else
67768c4a8e55Smrg		  # If the PIC object exists, use it instead.
67778c4a8e55Smrg		  # $xdir was prepended to $pic_object above.
67783169be4bSmrg		  non_pic_object=$pic_object
67798c4a8e55Smrg		  func_append non_pic_objects " $non_pic_object"
67808c4a8e55Smrg		fi
67818c4a8e55Smrg	      else
67828c4a8e55Smrg		# Only an error if not doing a dry-run.
67838c4a8e55Smrg		if $opt_dry_run; then
67848c4a8e55Smrg		  # Extract subdirectory from the argument.
67858c4a8e55Smrg		  func_dirname "$arg" "/" ""
67863169be4bSmrg		  xdir=$func_dirname_result
67878c4a8e55Smrg
67888c4a8e55Smrg		  func_lo2o "$arg"
67898c4a8e55Smrg		  pic_object=$xdir$objdir/$func_lo2o_result
67908c4a8e55Smrg		  non_pic_object=$xdir$func_lo2o_result
67918c4a8e55Smrg		  func_append libobjs " $pic_object"
67928c4a8e55Smrg		  func_append non_pic_objects " $non_pic_object"
67938c4a8e55Smrg	        else
67943169be4bSmrg		  func_fatal_error "'$arg' is not a valid libtool object"
67958c4a8e55Smrg		fi
67968c4a8e55Smrg	      fi
67978c4a8e55Smrg	    done
67988c4a8e55Smrg	  else
67993169be4bSmrg	    func_fatal_error "link input file '$arg' does not exist"
68008c4a8e55Smrg	  fi
68018c4a8e55Smrg	  arg=$save_arg
68028c4a8e55Smrg	  prev=
68038c4a8e55Smrg	  continue
6804b042e37fSmrg	  ;;
68053169be4bSmrg	os2dllname)
68063169be4bSmrg	  os2dllname=$arg
68073169be4bSmrg	  prev=
68083169be4bSmrg	  continue
68093169be4bSmrg	  ;;
68108c4a8e55Smrg	precious_regex)
68113169be4bSmrg	  precious_files_regex=$arg
68128c4a8e55Smrg	  prev=
68138c4a8e55Smrg	  continue
6814b042e37fSmrg	  ;;
68158c4a8e55Smrg	release)
68163169be4bSmrg	  release=-$arg
68178c4a8e55Smrg	  prev=
68188c4a8e55Smrg	  continue
6819b042e37fSmrg	  ;;
68208c4a8e55Smrg	rpath | xrpath)
68218c4a8e55Smrg	  # We need an absolute path.
68228c4a8e55Smrg	  case $arg in
68238c4a8e55Smrg	  [\\/]* | [A-Za-z]:[\\/]*) ;;
6824b042e37fSmrg	  *)
68258c4a8e55Smrg	    func_fatal_error "only absolute run-paths are allowed"
6826b042e37fSmrg	    ;;
6827b042e37fSmrg	  esac
68283169be4bSmrg	  if test rpath = "$prev"; then
68298c4a8e55Smrg	    case "$rpath " in
68308c4a8e55Smrg	    *" $arg "*) ;;
6831bd23fbfaSmrg	    *) func_append rpath " $arg" ;;
68328c4a8e55Smrg	    esac
68338c4a8e55Smrg	  else
68348c4a8e55Smrg	    case "$xrpath " in
68358c4a8e55Smrg	    *" $arg "*) ;;
6836bd23fbfaSmrg	    *) func_append xrpath " $arg" ;;
68378c4a8e55Smrg	    esac
68388c4a8e55Smrg	  fi
68398c4a8e55Smrg	  prev=
68408c4a8e55Smrg	  continue
68418c4a8e55Smrg	  ;;
68428c4a8e55Smrg	shrext)
68433169be4bSmrg	  shrext_cmds=$arg
68448c4a8e55Smrg	  prev=
68458c4a8e55Smrg	  continue
68468c4a8e55Smrg	  ;;
68478c4a8e55Smrg	weak)
6848bd23fbfaSmrg	  func_append weak_libs " $arg"
68498c4a8e55Smrg	  prev=
68508c4a8e55Smrg	  continue
68518c4a8e55Smrg	  ;;
68528c4a8e55Smrg	xcclinker)
6853bd23fbfaSmrg	  func_append linker_flags " $qarg"
6854bd23fbfaSmrg	  func_append compiler_flags " $qarg"
68558c4a8e55Smrg	  prev=
68568c4a8e55Smrg	  func_append compile_command " $qarg"
68578c4a8e55Smrg	  func_append finalize_command " $qarg"
68588c4a8e55Smrg	  continue
68598c4a8e55Smrg	  ;;
68608c4a8e55Smrg	xcompiler)
6861bd23fbfaSmrg	  func_append compiler_flags " $qarg"
68628c4a8e55Smrg	  prev=
68638c4a8e55Smrg	  func_append compile_command " $qarg"
68648c4a8e55Smrg	  func_append finalize_command " $qarg"
68658c4a8e55Smrg	  continue
68668c4a8e55Smrg	  ;;
68678c4a8e55Smrg	xlinker)
6868bd23fbfaSmrg	  func_append linker_flags " $qarg"
6869bd23fbfaSmrg	  func_append compiler_flags " $wl$qarg"
68708c4a8e55Smrg	  prev=
68718c4a8e55Smrg	  func_append compile_command " $wl$qarg"
68728c4a8e55Smrg	  func_append finalize_command " $wl$qarg"
68738c4a8e55Smrg	  continue
68748c4a8e55Smrg	  ;;
68758c4a8e55Smrg	*)
68768c4a8e55Smrg	  eval "$prev=\"\$arg\""
68778c4a8e55Smrg	  prev=
68788c4a8e55Smrg	  continue
68798c4a8e55Smrg	  ;;
68808c4a8e55Smrg	esac
68818c4a8e55Smrg      fi # test -n "$prev"
68828c4a8e55Smrg
68833169be4bSmrg      prevarg=$arg
68848c4a8e55Smrg
68858c4a8e55Smrg      case $arg in
68868c4a8e55Smrg      -all-static)
68878c4a8e55Smrg	if test -n "$link_static_flag"; then
68888c4a8e55Smrg	  # See comment for -static flag below, for more details.
68898c4a8e55Smrg	  func_append compile_command " $link_static_flag"
68908c4a8e55Smrg	  func_append finalize_command " $link_static_flag"
6891b042e37fSmrg	fi
68928c4a8e55Smrg	continue
68938c4a8e55Smrg	;;
6894b042e37fSmrg
68958c4a8e55Smrg      -allow-undefined)
68968c4a8e55Smrg	# FIXME: remove this flag sometime in the future.
68973169be4bSmrg	func_fatal_error "'-allow-undefined' must not be used because it is the default"
68988c4a8e55Smrg	;;
6899b042e37fSmrg
69008c4a8e55Smrg      -avoid-version)
69018c4a8e55Smrg	avoid_version=yes
69028c4a8e55Smrg	continue
69038c4a8e55Smrg	;;
6904b042e37fSmrg
6905706b6b52Smrg      -bindir)
6906706b6b52Smrg	prev=bindir
6907706b6b52Smrg	continue
6908706b6b52Smrg	;;
6909706b6b52Smrg
69108c4a8e55Smrg      -dlopen)
69118c4a8e55Smrg	prev=dlfiles
69128c4a8e55Smrg	continue
69138c4a8e55Smrg	;;
69148c4a8e55Smrg
69158c4a8e55Smrg      -dlpreopen)
69168c4a8e55Smrg	prev=dlprefiles
69178c4a8e55Smrg	continue
69188c4a8e55Smrg	;;
69198c4a8e55Smrg
69208c4a8e55Smrg      -export-dynamic)
69218c4a8e55Smrg	export_dynamic=yes
69228c4a8e55Smrg	continue
69238c4a8e55Smrg	;;
69248c4a8e55Smrg
69258c4a8e55Smrg      -export-symbols | -export-symbols-regex)
69268c4a8e55Smrg	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
69278c4a8e55Smrg	  func_fatal_error "more than one -exported-symbols argument is not allowed"
69288c4a8e55Smrg	fi
69293169be4bSmrg	if test X-export-symbols = "X$arg"; then
69308c4a8e55Smrg	  prev=expsyms
6931b042e37fSmrg	else
69328c4a8e55Smrg	  prev=expsyms_regex
6933b042e37fSmrg	fi
69348c4a8e55Smrg	continue
69358c4a8e55Smrg	;;
6936b042e37fSmrg
69378c4a8e55Smrg      -framework)
69388c4a8e55Smrg	prev=framework
69398c4a8e55Smrg	continue
69408c4a8e55Smrg	;;
6941b042e37fSmrg
69428c4a8e55Smrg      -inst-prefix-dir)
69438c4a8e55Smrg	prev=inst_prefix
69448c4a8e55Smrg	continue
69458c4a8e55Smrg	;;
6946b042e37fSmrg
69478c4a8e55Smrg      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
69488c4a8e55Smrg      # so, if we see these flags be careful not to treat them like -L
69498c4a8e55Smrg      -L[A-Z][A-Z]*:*)
69508c4a8e55Smrg	case $with_gcc/$host in
69518c4a8e55Smrg	no/*-*-irix* | /*-*-irix*)
69528c4a8e55Smrg	  func_append compile_command " $arg"
69538c4a8e55Smrg	  func_append finalize_command " $arg"
69548c4a8e55Smrg	  ;;
69558c4a8e55Smrg	esac
69568c4a8e55Smrg	continue
69578c4a8e55Smrg	;;
6958b042e37fSmrg
69598c4a8e55Smrg      -L*)
6960bd23fbfaSmrg	func_stripname "-L" '' "$arg"
6961bd23fbfaSmrg	if test -z "$func_stripname_result"; then
69628c4a8e55Smrg	  if test "$#" -gt 0; then
69633169be4bSmrg	    func_fatal_error "require no space between '-L' and '$1'"
6964b042e37fSmrg	  else
69653169be4bSmrg	    func_fatal_error "need path for '-L' option"
6966b042e37fSmrg	  fi
69678c4a8e55Smrg	fi
6968bd23fbfaSmrg	func_resolve_sysroot "$func_stripname_result"
6969bd23fbfaSmrg	dir=$func_resolve_sysroot_result
69708c4a8e55Smrg	# We need an absolute path.
69718c4a8e55Smrg	case $dir in
69728c4a8e55Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
69738c4a8e55Smrg	*)
69748c4a8e55Smrg	  absdir=`cd "$dir" && pwd`
69758c4a8e55Smrg	  test -z "$absdir" && \
69763169be4bSmrg	    func_fatal_error "cannot determine absolute directory name of '$dir'"
69773169be4bSmrg	  dir=$absdir
69788c4a8e55Smrg	  ;;
6979b042e37fSmrg	esac
69808c4a8e55Smrg	case "$deplibs " in
6981bd23fbfaSmrg	*" -L$dir "* | *" $arg "*)
6982bd23fbfaSmrg	  # Will only happen for absolute or sysroot arguments
6983bd23fbfaSmrg	  ;;
69848c4a8e55Smrg	*)
6985bd23fbfaSmrg	  # Preserve sysroot, but never include relative directories
6986bd23fbfaSmrg	  case $dir in
6987bd23fbfaSmrg	    [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
6988bd23fbfaSmrg	    *) func_append deplibs " -L$dir" ;;
6989bd23fbfaSmrg	  esac
6990bd23fbfaSmrg	  func_append lib_search_path " $dir"
69918c4a8e55Smrg	  ;;
6992b042e37fSmrg	esac
6993b042e37fSmrg	case $host in
69948c4a8e55Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
6995706b6b52Smrg	  testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
69968c4a8e55Smrg	  case :$dllsearchpath: in
69978c4a8e55Smrg	  *":$dir:"*) ;;
69988c4a8e55Smrg	  ::) dllsearchpath=$dir;;
6999bd23fbfaSmrg	  *) func_append dllsearchpath ":$dir";;
70008c4a8e55Smrg	  esac
70018c4a8e55Smrg	  case :$dllsearchpath: in
70028c4a8e55Smrg	  *":$testbindir:"*) ;;
70038c4a8e55Smrg	  ::) dllsearchpath=$testbindir;;
7004bd23fbfaSmrg	  *) func_append dllsearchpath ":$testbindir";;
70058c4a8e55Smrg	  esac
70068c4a8e55Smrg	  ;;
7007b042e37fSmrg	esac
70088c4a8e55Smrg	continue
70098c4a8e55Smrg	;;
7010b042e37fSmrg
70118c4a8e55Smrg      -l*)
70123169be4bSmrg	if test X-lc = "X$arg" || test X-lm = "X$arg"; then
70138c4a8e55Smrg	  case $host in
7014706b6b52Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
70158c4a8e55Smrg	    # These systems don't actually have a C or math library (as such)
70168c4a8e55Smrg	    continue
70178c4a8e55Smrg	    ;;
70188c4a8e55Smrg	  *-*-os2*)
70198c4a8e55Smrg	    # These systems don't actually have a C library (as such)
70203169be4bSmrg	    test X-lc = "X$arg" && continue
70218c4a8e55Smrg	    ;;
70223169be4bSmrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
70238c4a8e55Smrg	    # Do not include libc due to us having libc/libc_r.
70243169be4bSmrg	    test X-lc = "X$arg" && continue
70258c4a8e55Smrg	    ;;
70268c4a8e55Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
70278c4a8e55Smrg	    # Rhapsody C and math libraries are in the System framework
7028bd23fbfaSmrg	    func_append deplibs " System.ltframework"
70298c4a8e55Smrg	    continue
70308c4a8e55Smrg	    ;;
70318c4a8e55Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
70328c4a8e55Smrg	    # Causes problems with __ctype
70333169be4bSmrg	    test X-lc = "X$arg" && continue
70348c4a8e55Smrg	    ;;
70358c4a8e55Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
70368c4a8e55Smrg	    # Compiler inserts libc in the correct place for threads to work
70373169be4bSmrg	    test X-lc = "X$arg" && continue
70388c4a8e55Smrg	    ;;
70398c4a8e55Smrg	  esac
70403169be4bSmrg	elif test X-lc_r = "X$arg"; then
70418c4a8e55Smrg	 case $host in
70423169be4bSmrg	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
70438c4a8e55Smrg	   # Do not include libc_r directly, use -pthread flag.
70448c4a8e55Smrg	   continue
70458c4a8e55Smrg	   ;;
70468c4a8e55Smrg	 esac
70478c4a8e55Smrg	fi
7048bd23fbfaSmrg	func_append deplibs " $arg"
70498c4a8e55Smrg	continue
70508c4a8e55Smrg	;;
7051b042e37fSmrg
70523169be4bSmrg      -mllvm)
70533169be4bSmrg	prev=mllvm
70543169be4bSmrg	continue
70553169be4bSmrg	;;
70563169be4bSmrg
70578c4a8e55Smrg      -module)
70588c4a8e55Smrg	module=yes
70598c4a8e55Smrg	continue
70608c4a8e55Smrg	;;
7061b042e37fSmrg
70628c4a8e55Smrg      # Tru64 UNIX uses -model [arg] to determine the layout of C++
70638c4a8e55Smrg      # classes, name mangling, and exception handling.
70648c4a8e55Smrg      # Darwin uses the -arch flag to determine output architecture.
7065bd23fbfaSmrg      -model|-arch|-isysroot|--sysroot)
7066bd23fbfaSmrg	func_append compiler_flags " $arg"
70678c4a8e55Smrg	func_append compile_command " $arg"
70688c4a8e55Smrg	func_append finalize_command " $arg"
70698c4a8e55Smrg	prev=xcompiler
70708c4a8e55Smrg	continue
70718c4a8e55Smrg	;;
7072b042e37fSmrg
70730597fb56Smrg      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
70740597fb56Smrg      |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
7075bd23fbfaSmrg	func_append compiler_flags " $arg"
70768c4a8e55Smrg	func_append compile_command " $arg"
70778c4a8e55Smrg	func_append finalize_command " $arg"
70788c4a8e55Smrg	case "$new_inherited_linker_flags " in
70798c4a8e55Smrg	    *" $arg "*) ;;
7080bd23fbfaSmrg	    * ) func_append new_inherited_linker_flags " $arg" ;;
70818c4a8e55Smrg	esac
70828c4a8e55Smrg	continue
70838c4a8e55Smrg	;;
7084b042e37fSmrg
70858c4a8e55Smrg      -multi_module)
70863169be4bSmrg	single_module=$wl-multi_module
70878c4a8e55Smrg	continue
70888c4a8e55Smrg	;;
7089b042e37fSmrg
70908c4a8e55Smrg      -no-fast-install)
70918c4a8e55Smrg	fast_install=no
70928c4a8e55Smrg	continue
70938c4a8e55Smrg	;;
7094b042e37fSmrg
70958c4a8e55Smrg      -no-install)
70968c4a8e55Smrg	case $host in
70978c4a8e55Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
70988c4a8e55Smrg	  # The PATH hackery in wrapper scripts is required on Windows
70998c4a8e55Smrg	  # and Darwin in order for the loader to find any dlls it needs.
71003169be4bSmrg	  func_warning "'-no-install' is ignored for $host"
71013169be4bSmrg	  func_warning "assuming '-no-fast-install' instead"
71028c4a8e55Smrg	  fast_install=no
71038c4a8e55Smrg	  ;;
71048c4a8e55Smrg	*) no_install=yes ;;
71058c4a8e55Smrg	esac
71068c4a8e55Smrg	continue
71078c4a8e55Smrg	;;
7108b042e37fSmrg
71098c4a8e55Smrg      -no-undefined)
71108c4a8e55Smrg	allow_undefined=no
71118c4a8e55Smrg	continue
71128c4a8e55Smrg	;;
7113b042e37fSmrg
71148c4a8e55Smrg      -objectlist)
71158c4a8e55Smrg	prev=objectlist
71168c4a8e55Smrg	continue
71178c4a8e55Smrg	;;
7118b042e37fSmrg
71193169be4bSmrg      -os2dllname)
71203169be4bSmrg	prev=os2dllname
71213169be4bSmrg	continue
71223169be4bSmrg	;;
71233169be4bSmrg
71248c4a8e55Smrg      -o) prev=output ;;
7125b042e37fSmrg
71268c4a8e55Smrg      -precious-files-regex)
71278c4a8e55Smrg	prev=precious_regex
71288c4a8e55Smrg	continue
71298c4a8e55Smrg	;;
7130b042e37fSmrg
71318c4a8e55Smrg      -release)
71328c4a8e55Smrg	prev=release
71338c4a8e55Smrg	continue
71348c4a8e55Smrg	;;
7135b042e37fSmrg
71368c4a8e55Smrg      -rpath)
71378c4a8e55Smrg	prev=rpath
71388c4a8e55Smrg	continue
71398c4a8e55Smrg	;;
7140b042e37fSmrg
71418c4a8e55Smrg      -R)
71428c4a8e55Smrg	prev=xrpath
71438c4a8e55Smrg	continue
71448c4a8e55Smrg	;;
7145b042e37fSmrg
71468c4a8e55Smrg      -R*)
71478c4a8e55Smrg	func_stripname '-R' '' "$arg"
71488c4a8e55Smrg	dir=$func_stripname_result
71498c4a8e55Smrg	# We need an absolute path.
71508c4a8e55Smrg	case $dir in
71518c4a8e55Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
7152bd23fbfaSmrg	=*)
7153bd23fbfaSmrg	  func_stripname '=' '' "$dir"
7154bd23fbfaSmrg	  dir=$lt_sysroot$func_stripname_result
7155bd23fbfaSmrg	  ;;
71568c4a8e55Smrg	*)
71578c4a8e55Smrg	  func_fatal_error "only absolute run-paths are allowed"
71588c4a8e55Smrg	  ;;
71598c4a8e55Smrg	esac
71608c4a8e55Smrg	case "$xrpath " in
71618c4a8e55Smrg	*" $dir "*) ;;
7162bd23fbfaSmrg	*) func_append xrpath " $dir" ;;
71638c4a8e55Smrg	esac
71648c4a8e55Smrg	continue
71658c4a8e55Smrg	;;
7166b042e37fSmrg
71678c4a8e55Smrg      -shared)
71688c4a8e55Smrg	# The effects of -shared are defined in a previous loop.
71698c4a8e55Smrg	continue
71708c4a8e55Smrg	;;
7171b042e37fSmrg
71728c4a8e55Smrg      -shrext)
71738c4a8e55Smrg	prev=shrext
71748c4a8e55Smrg	continue
71758c4a8e55Smrg	;;
7176b042e37fSmrg
71778c4a8e55Smrg      -static | -static-libtool-libs)
71788c4a8e55Smrg	# The effects of -static are defined in a previous loop.
71798c4a8e55Smrg	# We used to do the same as -all-static on platforms that
71808c4a8e55Smrg	# didn't have a PIC flag, but the assumption that the effects
71818c4a8e55Smrg	# would be equivalent was wrong.  It would break on at least
71828c4a8e55Smrg	# Digital Unix and AIX.
71838c4a8e55Smrg	continue
71848c4a8e55Smrg	;;
7185b042e37fSmrg
71868c4a8e55Smrg      -thread-safe)
71878c4a8e55Smrg	thread_safe=yes
71888c4a8e55Smrg	continue
71898c4a8e55Smrg	;;
7190b042e37fSmrg
71918c4a8e55Smrg      -version-info)
71928c4a8e55Smrg	prev=vinfo
71938c4a8e55Smrg	continue
71948c4a8e55Smrg	;;
7195b042e37fSmrg
71968c4a8e55Smrg      -version-number)
71978c4a8e55Smrg	prev=vinfo
71988c4a8e55Smrg	vinfo_number=yes
71998c4a8e55Smrg	continue
72008c4a8e55Smrg	;;
7201b042e37fSmrg
72028c4a8e55Smrg      -weak)
72038c4a8e55Smrg        prev=weak
72048c4a8e55Smrg	continue
72058c4a8e55Smrg	;;
7206b042e37fSmrg
72078c4a8e55Smrg      -Wc,*)
72088c4a8e55Smrg	func_stripname '-Wc,' '' "$arg"
72098c4a8e55Smrg	args=$func_stripname_result
72108c4a8e55Smrg	arg=
72113169be4bSmrg	save_ifs=$IFS; IFS=,
72128c4a8e55Smrg	for flag in $args; do
72133169be4bSmrg	  IFS=$save_ifs
72148c4a8e55Smrg          func_quote_for_eval "$flag"
7215bd23fbfaSmrg	  func_append arg " $func_quote_for_eval_result"
7216bd23fbfaSmrg	  func_append compiler_flags " $func_quote_for_eval_result"
72178c4a8e55Smrg	done
72183169be4bSmrg	IFS=$save_ifs
72198c4a8e55Smrg	func_stripname ' ' '' "$arg"
72208c4a8e55Smrg	arg=$func_stripname_result
72218c4a8e55Smrg	;;
7222b042e37fSmrg
72238c4a8e55Smrg      -Wl,*)
72248c4a8e55Smrg	func_stripname '-Wl,' '' "$arg"
72258c4a8e55Smrg	args=$func_stripname_result
72268c4a8e55Smrg	arg=
72273169be4bSmrg	save_ifs=$IFS; IFS=,
72288c4a8e55Smrg	for flag in $args; do
72293169be4bSmrg	  IFS=$save_ifs
72308c4a8e55Smrg          func_quote_for_eval "$flag"
7231bd23fbfaSmrg	  func_append arg " $wl$func_quote_for_eval_result"
7232bd23fbfaSmrg	  func_append compiler_flags " $wl$func_quote_for_eval_result"
7233bd23fbfaSmrg	  func_append linker_flags " $func_quote_for_eval_result"
72348c4a8e55Smrg	done
72353169be4bSmrg	IFS=$save_ifs
72368c4a8e55Smrg	func_stripname ' ' '' "$arg"
72378c4a8e55Smrg	arg=$func_stripname_result
72388c4a8e55Smrg	;;
7239b042e37fSmrg
72408c4a8e55Smrg      -Xcompiler)
72418c4a8e55Smrg	prev=xcompiler
72428c4a8e55Smrg	continue
72438c4a8e55Smrg	;;
7244b042e37fSmrg
72458c4a8e55Smrg      -Xlinker)
72468c4a8e55Smrg	prev=xlinker
72478c4a8e55Smrg	continue
72488c4a8e55Smrg	;;
7249b042e37fSmrg
72508c4a8e55Smrg      -XCClinker)
72518c4a8e55Smrg	prev=xcclinker
72528c4a8e55Smrg	continue
72538c4a8e55Smrg	;;
7254b042e37fSmrg
72558c4a8e55Smrg      # -msg_* for osf cc
72568c4a8e55Smrg      -msg_*)
72578c4a8e55Smrg	func_quote_for_eval "$arg"
72583169be4bSmrg	arg=$func_quote_for_eval_result
72598c4a8e55Smrg	;;
7260b042e37fSmrg
7261706b6b52Smrg      # Flags to be passed through unchanged, with rationale:
7262706b6b52Smrg      # -64, -mips[0-9]      enable 64-bit mode for the SGI compiler
7263706b6b52Smrg      # -r[0-9][0-9]*        specify processor for the SGI compiler
7264706b6b52Smrg      # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
7265706b6b52Smrg      # +DA*, +DD*           enable 64-bit mode for the HP compiler
7266706b6b52Smrg      # -q*                  compiler args for the IBM compiler
7267706b6b52Smrg      # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
7268706b6b52Smrg      # -F/path              path to uninstalled frameworks, gcc on darwin
7269706b6b52Smrg      # -p, -pg, --coverage, -fprofile-*  profiling flags for GCC
72703169be4bSmrg      # -fstack-protector*   stack protector flags for GCC
7271706b6b52Smrg      # @file                GCC response files
7272706b6b52Smrg      # -tp=*                Portland pgcc target processor selection
7273bd23fbfaSmrg      # --sysroot=*          for sysroot support
72743169be4bSmrg      # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
72753169be4bSmrg      # -stdlib=*            select c++ std lib with clang
72768c4a8e55Smrg      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
7277bd23fbfaSmrg      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
72783169be4bSmrg      -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*)
72798c4a8e55Smrg        func_quote_for_eval "$arg"
72803169be4bSmrg	arg=$func_quote_for_eval_result
72818c4a8e55Smrg        func_append compile_command " $arg"
72828c4a8e55Smrg        func_append finalize_command " $arg"
7283bd23fbfaSmrg        func_append compiler_flags " $arg"
72848c4a8e55Smrg        continue
72858c4a8e55Smrg        ;;
7286b042e37fSmrg
72873169be4bSmrg      -Z*)
72883169be4bSmrg        if test os2 = "`expr $host : '.*\(os2\)'`"; then
72893169be4bSmrg          # OS/2 uses -Zxxx to specify OS/2-specific options
72903169be4bSmrg	  compiler_flags="$compiler_flags $arg"
72913169be4bSmrg	  func_append compile_command " $arg"
72923169be4bSmrg	  func_append finalize_command " $arg"
72933169be4bSmrg	  case $arg in
72943169be4bSmrg	  -Zlinker | -Zstack)
72953169be4bSmrg	    prev=xcompiler
72963169be4bSmrg	    ;;
72973169be4bSmrg	  esac
72983169be4bSmrg	  continue
72993169be4bSmrg        else
73003169be4bSmrg	  # Otherwise treat like 'Some other compiler flag' below
73013169be4bSmrg	  func_quote_for_eval "$arg"
73023169be4bSmrg	  arg=$func_quote_for_eval_result
73033169be4bSmrg        fi
73043169be4bSmrg	;;
73053169be4bSmrg
73068c4a8e55Smrg      # Some other compiler flag.
73078c4a8e55Smrg      -* | +*)
73088c4a8e55Smrg        func_quote_for_eval "$arg"
73093169be4bSmrg	arg=$func_quote_for_eval_result
73108c4a8e55Smrg	;;
7311b042e37fSmrg
73128c4a8e55Smrg      *.$objext)
73138c4a8e55Smrg	# A standard object.
7314bd23fbfaSmrg	func_append objs " $arg"
73158c4a8e55Smrg	;;
7316b042e37fSmrg
73178c4a8e55Smrg      *.lo)
73188c4a8e55Smrg	# A libtool-controlled object.
7319b042e37fSmrg
73208c4a8e55Smrg	# Check to see that this really is a libtool object.
73218c4a8e55Smrg	if func_lalib_unsafe_p "$arg"; then
73228c4a8e55Smrg	  pic_object=
73238c4a8e55Smrg	  non_pic_object=
7324b042e37fSmrg
73258c4a8e55Smrg	  # Read the .lo file
73268c4a8e55Smrg	  func_source "$arg"
7327b042e37fSmrg
73288c4a8e55Smrg	  if test -z "$pic_object" ||
73298c4a8e55Smrg	     test -z "$non_pic_object" ||
73303169be4bSmrg	     test none = "$pic_object" &&
73313169be4bSmrg	     test none = "$non_pic_object"; then
73323169be4bSmrg	    func_fatal_error "cannot find name of object for '$arg'"
73338c4a8e55Smrg	  fi
7334b042e37fSmrg
73358c4a8e55Smrg	  # Extract subdirectory from the argument.
73368c4a8e55Smrg	  func_dirname "$arg" "/" ""
73373169be4bSmrg	  xdir=$func_dirname_result
7338b042e37fSmrg
73393169be4bSmrg	  test none = "$pic_object" || {
73408c4a8e55Smrg	    # Prepend the subdirectory the object is found in.
73413169be4bSmrg	    pic_object=$xdir$pic_object
7342b042e37fSmrg
73433169be4bSmrg	    if test dlfiles = "$prev"; then
73443169be4bSmrg	      if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
7345bd23fbfaSmrg		func_append dlfiles " $pic_object"
73468c4a8e55Smrg		prev=
73478c4a8e55Smrg		continue
73488c4a8e55Smrg	      else
73498c4a8e55Smrg		# If libtool objects are unsupported, then we need to preload.
73508c4a8e55Smrg		prev=dlprefiles
73518c4a8e55Smrg	      fi
73528c4a8e55Smrg	    fi
7353b042e37fSmrg
73548c4a8e55Smrg	    # CHECK ME:  I think I busted this.  -Ossama
73553169be4bSmrg	    if test dlprefiles = "$prev"; then
73568c4a8e55Smrg	      # Preload the old-style object.
7357bd23fbfaSmrg	      func_append dlprefiles " $pic_object"
73588c4a8e55Smrg	      prev=
73598c4a8e55Smrg	    fi
7360b042e37fSmrg
73618c4a8e55Smrg	    # A PIC object.
73628c4a8e55Smrg	    func_append libobjs " $pic_object"
73633169be4bSmrg	    arg=$pic_object
73643169be4bSmrg	  }
7365b042e37fSmrg
73668c4a8e55Smrg	  # Non-PIC object.
73673169be4bSmrg	  if test none != "$non_pic_object"; then
73688c4a8e55Smrg	    # Prepend the subdirectory the object is found in.
73693169be4bSmrg	    non_pic_object=$xdir$non_pic_object
7370b042e37fSmrg
73718c4a8e55Smrg	    # A standard non-PIC object
73728c4a8e55Smrg	    func_append non_pic_objects " $non_pic_object"
73733169be4bSmrg	    if test -z "$pic_object" || test none = "$pic_object"; then
73743169be4bSmrg	      arg=$non_pic_object
73758c4a8e55Smrg	    fi
73768c4a8e55Smrg	  else
73778c4a8e55Smrg	    # If the PIC object exists, use it instead.
73788c4a8e55Smrg	    # $xdir was prepended to $pic_object above.
73793169be4bSmrg	    non_pic_object=$pic_object
73808c4a8e55Smrg	    func_append non_pic_objects " $non_pic_object"
73818c4a8e55Smrg	  fi
73828c4a8e55Smrg	else
73838c4a8e55Smrg	  # Only an error if not doing a dry-run.
73848c4a8e55Smrg	  if $opt_dry_run; then
73858c4a8e55Smrg	    # Extract subdirectory from the argument.
73868c4a8e55Smrg	    func_dirname "$arg" "/" ""
73873169be4bSmrg	    xdir=$func_dirname_result
73888c4a8e55Smrg
73898c4a8e55Smrg	    func_lo2o "$arg"
73908c4a8e55Smrg	    pic_object=$xdir$objdir/$func_lo2o_result
73918c4a8e55Smrg	    non_pic_object=$xdir$func_lo2o_result
73928c4a8e55Smrg	    func_append libobjs " $pic_object"
73938c4a8e55Smrg	    func_append non_pic_objects " $non_pic_object"
73948c4a8e55Smrg	  else
73953169be4bSmrg	    func_fatal_error "'$arg' is not a valid libtool object"
73968c4a8e55Smrg	  fi
73978c4a8e55Smrg	fi
73988c4a8e55Smrg	;;
7399b042e37fSmrg
74008c4a8e55Smrg      *.$libext)
74018c4a8e55Smrg	# An archive.
7402bd23fbfaSmrg	func_append deplibs " $arg"
7403bd23fbfaSmrg	func_append old_deplibs " $arg"
74048c4a8e55Smrg	continue
74058c4a8e55Smrg	;;
7406b042e37fSmrg
74078c4a8e55Smrg      *.la)
74088c4a8e55Smrg	# A libtool-controlled library.
7409b042e37fSmrg
7410bd23fbfaSmrg	func_resolve_sysroot "$arg"
74113169be4bSmrg	if test dlfiles = "$prev"; then
74128c4a8e55Smrg	  # This library was specified with -dlopen.
7413bd23fbfaSmrg	  func_append dlfiles " $func_resolve_sysroot_result"
74148c4a8e55Smrg	  prev=
74153169be4bSmrg	elif test dlprefiles = "$prev"; then
74168c4a8e55Smrg	  # The library was specified with -dlpreopen.
7417bd23fbfaSmrg	  func_append dlprefiles " $func_resolve_sysroot_result"
74188c4a8e55Smrg	  prev=
74198c4a8e55Smrg	else
7420bd23fbfaSmrg	  func_append deplibs " $func_resolve_sysroot_result"
74218c4a8e55Smrg	fi
74228c4a8e55Smrg	continue
74238c4a8e55Smrg	;;
7424b042e37fSmrg
74258c4a8e55Smrg      # Some other compiler argument.
74268c4a8e55Smrg      *)
74278c4a8e55Smrg	# Unknown arguments in both finalize_command and compile_command need
74288c4a8e55Smrg	# to be aesthetically quoted because they are evaled later.
74298c4a8e55Smrg	func_quote_for_eval "$arg"
74303169be4bSmrg	arg=$func_quote_for_eval_result
74318c4a8e55Smrg	;;
74328c4a8e55Smrg      esac # arg
7433b042e37fSmrg
74348c4a8e55Smrg      # Now actually substitute the argument into the commands.
74358c4a8e55Smrg      if test -n "$arg"; then
74368c4a8e55Smrg	func_append compile_command " $arg"
74378c4a8e55Smrg	func_append finalize_command " $arg"
74388c4a8e55Smrg      fi
74398c4a8e55Smrg    done # argument parsing loop
7440b042e37fSmrg
74418c4a8e55Smrg    test -n "$prev" && \
74423169be4bSmrg      func_fatal_help "the '$prevarg' option requires an argument"
7443b042e37fSmrg
74443169be4bSmrg    if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then
74458c4a8e55Smrg      eval arg=\"$export_dynamic_flag_spec\"
74468c4a8e55Smrg      func_append compile_command " $arg"
74478c4a8e55Smrg      func_append finalize_command " $arg"
74488c4a8e55Smrg    fi
7449b042e37fSmrg
74508c4a8e55Smrg    oldlibs=
74518c4a8e55Smrg    # calculate the name of the file, without its directory
74528c4a8e55Smrg    func_basename "$output"
74533169be4bSmrg    outputname=$func_basename_result
74543169be4bSmrg    libobjs_save=$libobjs
74558c4a8e55Smrg
74568c4a8e55Smrg    if test -n "$shlibpath_var"; then
74578c4a8e55Smrg      # get the directories listed in $shlibpath_var
74583169be4bSmrg      eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\`
7459b042e37fSmrg    else
74608c4a8e55Smrg      shlib_search_path=
7461b042e37fSmrg    fi
74628c4a8e55Smrg    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
74638c4a8e55Smrg    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
7464b042e37fSmrg
74653169be4bSmrg    # Definition is injected by LT_CONFIG during libtool generation.
74663169be4bSmrg    func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH"
74673169be4bSmrg
74688c4a8e55Smrg    func_dirname "$output" "/" ""
74693169be4bSmrg    output_objdir=$func_dirname_result$objdir
7470bd23fbfaSmrg    func_to_tool_file "$output_objdir/"
7471bd23fbfaSmrg    tool_output_objdir=$func_to_tool_file_result
74728c4a8e55Smrg    # Create the object directory.
74738c4a8e55Smrg    func_mkdir_p "$output_objdir"
7474b042e37fSmrg
74758c4a8e55Smrg    # Determine the type of output
74768c4a8e55Smrg    case $output in
74778c4a8e55Smrg    "")
74788c4a8e55Smrg      func_fatal_help "you must specify an output file"
74798c4a8e55Smrg      ;;
74808c4a8e55Smrg    *.$libext) linkmode=oldlib ;;
74818c4a8e55Smrg    *.lo | *.$objext) linkmode=obj ;;
74828c4a8e55Smrg    *.la) linkmode=lib ;;
74838c4a8e55Smrg    *) linkmode=prog ;; # Anything else should be a program.
74848c4a8e55Smrg    esac
74858c4a8e55Smrg
74868c4a8e55Smrg    specialdeplibs=
74878c4a8e55Smrg
74888c4a8e55Smrg    libs=
74898c4a8e55Smrg    # Find all interdependent deplibs by searching for libraries
74908c4a8e55Smrg    # that are linked more than once (e.g. -la -lb -la)
74918c4a8e55Smrg    for deplib in $deplibs; do
74923169be4bSmrg      if $opt_preserve_dup_deps; then
74938c4a8e55Smrg	case "$libs " in
7494bd23fbfaSmrg	*" $deplib "*) func_append specialdeplibs " $deplib" ;;
74958c4a8e55Smrg	esac
74968c4a8e55Smrg      fi
7497bd23fbfaSmrg      func_append libs " $deplib"
74988c4a8e55Smrg    done
74998c4a8e55Smrg
75003169be4bSmrg    if test lib = "$linkmode"; then
75018c4a8e55Smrg      libs="$predeps $libs $compiler_lib_search_path $postdeps"
75028c4a8e55Smrg
75038c4a8e55Smrg      # Compute libraries that are listed more than once in $predeps
75048c4a8e55Smrg      # $postdeps and mark them as special (i.e., whose duplicates are
75058c4a8e55Smrg      # not to be eliminated).
75068c4a8e55Smrg      pre_post_deps=
75078c4a8e55Smrg      if $opt_duplicate_compiler_generated_deps; then
75088c4a8e55Smrg	for pre_post_dep in $predeps $postdeps; do
75098c4a8e55Smrg	  case "$pre_post_deps " in
7510bd23fbfaSmrg	  *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
75118c4a8e55Smrg	  esac
7512bd23fbfaSmrg	  func_append pre_post_deps " $pre_post_dep"
75138c4a8e55Smrg	done
75148c4a8e55Smrg      fi
75158c4a8e55Smrg      pre_post_deps=
75168c4a8e55Smrg    fi
75178c4a8e55Smrg
75188c4a8e55Smrg    deplibs=
75198c4a8e55Smrg    newdependency_libs=
75208c4a8e55Smrg    newlib_search_path=
75218c4a8e55Smrg    need_relink=no # whether we're linking any uninstalled libtool libraries
75228c4a8e55Smrg    notinst_deplibs= # not-installed libtool libraries
75238c4a8e55Smrg    notinst_path= # paths that contain not-installed libtool libraries
75248c4a8e55Smrg
75258c4a8e55Smrg    case $linkmode in
75268c4a8e55Smrg    lib)
75278c4a8e55Smrg	passes="conv dlpreopen link"
75288c4a8e55Smrg	for file in $dlfiles $dlprefiles; do
75298c4a8e55Smrg	  case $file in
75308c4a8e55Smrg	  *.la) ;;
75318c4a8e55Smrg	  *)
75323169be4bSmrg	    func_fatal_help "libraries can '-dlopen' only libtool libraries: $file"
75338c4a8e55Smrg	    ;;
75348c4a8e55Smrg	  esac
75358c4a8e55Smrg	done
75368c4a8e55Smrg	;;
75378c4a8e55Smrg    prog)
75388c4a8e55Smrg	compile_deplibs=
75398c4a8e55Smrg	finalize_deplibs=
75403169be4bSmrg	alldeplibs=false
75418c4a8e55Smrg	newdlfiles=
75428c4a8e55Smrg	newdlprefiles=
75438c4a8e55Smrg	passes="conv scan dlopen dlpreopen link"
75448c4a8e55Smrg	;;
75458c4a8e55Smrg    *)  passes="conv"
75468c4a8e55Smrg	;;
75478c4a8e55Smrg    esac
75488c4a8e55Smrg
75498c4a8e55Smrg    for pass in $passes; do
75508c4a8e55Smrg      # The preopen pass in lib mode reverses $deplibs; put it back here
75518c4a8e55Smrg      # so that -L comes before libs that need it for instance...
75523169be4bSmrg      if test lib,link = "$linkmode,$pass"; then
75538c4a8e55Smrg	## FIXME: Find the place where the list is rebuilt in the wrong
75548c4a8e55Smrg	##        order, and fix it there properly
75558c4a8e55Smrg        tmp_deplibs=
75568c4a8e55Smrg	for deplib in $deplibs; do
75578c4a8e55Smrg	  tmp_deplibs="$deplib $tmp_deplibs"
75588c4a8e55Smrg	done
75593169be4bSmrg	deplibs=$tmp_deplibs
75608c4a8e55Smrg      fi
75618c4a8e55Smrg
75623169be4bSmrg      if test lib,link = "$linkmode,$pass" ||
75633169be4bSmrg	 test prog,scan = "$linkmode,$pass"; then
75643169be4bSmrg	libs=$deplibs
75658c4a8e55Smrg	deplibs=
75668c4a8e55Smrg      fi
75673169be4bSmrg      if test prog = "$linkmode"; then
75688c4a8e55Smrg	case $pass in
75693169be4bSmrg	dlopen) libs=$dlfiles ;;
75703169be4bSmrg	dlpreopen) libs=$dlprefiles ;;
75713169be4bSmrg	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
75728c4a8e55Smrg	esac
75738c4a8e55Smrg      fi
75743169be4bSmrg      if test lib,dlpreopen = "$linkmode,$pass"; then
75758c4a8e55Smrg	# Collect and forward deplibs of preopened libtool libs
75768c4a8e55Smrg	for lib in $dlprefiles; do
75778c4a8e55Smrg	  # Ignore non-libtool-libs
75788c4a8e55Smrg	  dependency_libs=
7579bd23fbfaSmrg	  func_resolve_sysroot "$lib"
75808c4a8e55Smrg	  case $lib in
7581bd23fbfaSmrg	  *.la)	func_source "$func_resolve_sysroot_result" ;;
75828c4a8e55Smrg	  esac
75838c4a8e55Smrg
75848c4a8e55Smrg	  # Collect preopened libtool deplibs, except any this library
75858c4a8e55Smrg	  # has declared as weak libs
75868c4a8e55Smrg	  for deplib in $dependency_libs; do
7587706b6b52Smrg	    func_basename "$deplib"
7588706b6b52Smrg            deplib_base=$func_basename_result
75898c4a8e55Smrg	    case " $weak_libs " in
75908c4a8e55Smrg	    *" $deplib_base "*) ;;
7591bd23fbfaSmrg	    *) func_append deplibs " $deplib" ;;
75928c4a8e55Smrg	    esac
75938c4a8e55Smrg	  done
75948c4a8e55Smrg	done
75953169be4bSmrg	libs=$dlprefiles
75968c4a8e55Smrg      fi
75973169be4bSmrg      if test dlopen = "$pass"; then
75988c4a8e55Smrg	# Collect dlpreopened libraries
75993169be4bSmrg	save_deplibs=$deplibs
76008c4a8e55Smrg	deplibs=
76018c4a8e55Smrg      fi
76028c4a8e55Smrg
76038c4a8e55Smrg      for deplib in $libs; do
76048c4a8e55Smrg	lib=
76053169be4bSmrg	found=false
76068c4a8e55Smrg	case $deplib in
76070597fb56Smrg	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
76080597fb56Smrg        |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
76093169be4bSmrg	  if test prog,link = "$linkmode,$pass"; then
76108c4a8e55Smrg	    compile_deplibs="$deplib $compile_deplibs"
76118c4a8e55Smrg	    finalize_deplibs="$deplib $finalize_deplibs"
76128c4a8e55Smrg	  else
7613bd23fbfaSmrg	    func_append compiler_flags " $deplib"
76143169be4bSmrg	    if test lib = "$linkmode"; then
76158c4a8e55Smrg		case "$new_inherited_linker_flags " in
76168c4a8e55Smrg		    *" $deplib "*) ;;
7617bd23fbfaSmrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
76188c4a8e55Smrg		esac
76198c4a8e55Smrg	    fi
76208c4a8e55Smrg	  fi
76218c4a8e55Smrg	  continue
76228c4a8e55Smrg	  ;;
76238c4a8e55Smrg	-l*)
76243169be4bSmrg	  if test lib != "$linkmode" && test prog != "$linkmode"; then
76253169be4bSmrg	    func_warning "'-l' is ignored for archives/objects"
76268c4a8e55Smrg	    continue
76278c4a8e55Smrg	  fi
76288c4a8e55Smrg	  func_stripname '-l' '' "$deplib"
76298c4a8e55Smrg	  name=$func_stripname_result
76303169be4bSmrg	  if test lib = "$linkmode"; then
76318c4a8e55Smrg	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
76328c4a8e55Smrg	  else
76338c4a8e55Smrg	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
76348c4a8e55Smrg	  fi
76358c4a8e55Smrg	  for searchdir in $searchdirs; do
76368c4a8e55Smrg	    for search_ext in .la $std_shrext .so .a; do
76378c4a8e55Smrg	      # Search the libtool library
76383169be4bSmrg	      lib=$searchdir/lib$name$search_ext
76398c4a8e55Smrg	      if test -f "$lib"; then
76403169be4bSmrg		if test .la = "$search_ext"; then
76413169be4bSmrg		  found=:
76428c4a8e55Smrg		else
76433169be4bSmrg		  found=false
76448c4a8e55Smrg		fi
76458c4a8e55Smrg		break 2
76468c4a8e55Smrg	      fi
76478c4a8e55Smrg	    done
76488c4a8e55Smrg	  done
76493169be4bSmrg	  if $found; then
76503169be4bSmrg	    # deplib is a libtool library
76518c4a8e55Smrg	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
76528c4a8e55Smrg	    # We need to do some special things here, and not later.
76533169be4bSmrg	    if test yes = "$allow_libtool_libs_with_static_runtimes"; then
76548c4a8e55Smrg	      case " $predeps $postdeps " in
76558c4a8e55Smrg	      *" $deplib "*)
76568c4a8e55Smrg		if func_lalib_p "$lib"; then
76578c4a8e55Smrg		  library_names=
76588c4a8e55Smrg		  old_library=
76598c4a8e55Smrg		  func_source "$lib"
76608c4a8e55Smrg		  for l in $old_library $library_names; do
76613169be4bSmrg		    ll=$l
76628c4a8e55Smrg		  done
76633169be4bSmrg		  if test "X$ll" = "X$old_library"; then # only static version available
76643169be4bSmrg		    found=false
76658c4a8e55Smrg		    func_dirname "$lib" "" "."
76663169be4bSmrg		    ladir=$func_dirname_result
76678c4a8e55Smrg		    lib=$ladir/$old_library
76683169be4bSmrg		    if test prog,link = "$linkmode,$pass"; then
76698c4a8e55Smrg		      compile_deplibs="$deplib $compile_deplibs"
76708c4a8e55Smrg		      finalize_deplibs="$deplib $finalize_deplibs"
76718c4a8e55Smrg		    else
76728c4a8e55Smrg		      deplibs="$deplib $deplibs"
76733169be4bSmrg		      test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
76748c4a8e55Smrg		    fi
76758c4a8e55Smrg		    continue
76768c4a8e55Smrg		  fi
76778c4a8e55Smrg		fi
76788c4a8e55Smrg		;;
76798c4a8e55Smrg	      *) ;;
76808c4a8e55Smrg	      esac
76818c4a8e55Smrg	    fi
76823169be4bSmrg	  else
76833169be4bSmrg	    # deplib doesn't seem to be a libtool library
76843169be4bSmrg	    if test prog,link = "$linkmode,$pass"; then
76853169be4bSmrg	      compile_deplibs="$deplib $compile_deplibs"
76863169be4bSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
76873169be4bSmrg	    else
76883169be4bSmrg	      deplibs="$deplib $deplibs"
76893169be4bSmrg	      test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
76903169be4bSmrg	    fi
76913169be4bSmrg	    continue
76928c4a8e55Smrg	  fi
76938c4a8e55Smrg	  ;; # -l
76948c4a8e55Smrg	*.ltframework)
76953169be4bSmrg	  if test prog,link = "$linkmode,$pass"; then
76968c4a8e55Smrg	    compile_deplibs="$deplib $compile_deplibs"
76978c4a8e55Smrg	    finalize_deplibs="$deplib $finalize_deplibs"
76988c4a8e55Smrg	  else
76998c4a8e55Smrg	    deplibs="$deplib $deplibs"
77003169be4bSmrg	    if test lib = "$linkmode"; then
77018c4a8e55Smrg		case "$new_inherited_linker_flags " in
77028c4a8e55Smrg		    *" $deplib "*) ;;
7703bd23fbfaSmrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
77048c4a8e55Smrg		esac
77058c4a8e55Smrg	    fi
77068c4a8e55Smrg	  fi
77078c4a8e55Smrg	  continue
77088c4a8e55Smrg	  ;;
77098c4a8e55Smrg	-L*)
77108c4a8e55Smrg	  case $linkmode in
77118c4a8e55Smrg	  lib)
77128c4a8e55Smrg	    deplibs="$deplib $deplibs"
77133169be4bSmrg	    test conv = "$pass" && continue
77148c4a8e55Smrg	    newdependency_libs="$deplib $newdependency_libs"
77158c4a8e55Smrg	    func_stripname '-L' '' "$deplib"
7716bd23fbfaSmrg	    func_resolve_sysroot "$func_stripname_result"
7717bd23fbfaSmrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
77188c4a8e55Smrg	    ;;
77198c4a8e55Smrg	  prog)
77203169be4bSmrg	    if test conv = "$pass"; then
77218c4a8e55Smrg	      deplibs="$deplib $deplibs"
77228c4a8e55Smrg	      continue
77238c4a8e55Smrg	    fi
77243169be4bSmrg	    if test scan = "$pass"; then
77258c4a8e55Smrg	      deplibs="$deplib $deplibs"
77268c4a8e55Smrg	    else
77278c4a8e55Smrg	      compile_deplibs="$deplib $compile_deplibs"
77288c4a8e55Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
77298c4a8e55Smrg	    fi
77308c4a8e55Smrg	    func_stripname '-L' '' "$deplib"
7731bd23fbfaSmrg	    func_resolve_sysroot "$func_stripname_result"
7732bd23fbfaSmrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
77338c4a8e55Smrg	    ;;
77348c4a8e55Smrg	  *)
77353169be4bSmrg	    func_warning "'-L' is ignored for archives/objects"
77368c4a8e55Smrg	    ;;
77378c4a8e55Smrg	  esac # linkmode
77388c4a8e55Smrg	  continue
77398c4a8e55Smrg	  ;; # -L
77408c4a8e55Smrg	-R*)
77413169be4bSmrg	  if test link = "$pass"; then
77428c4a8e55Smrg	    func_stripname '-R' '' "$deplib"
7743bd23fbfaSmrg	    func_resolve_sysroot "$func_stripname_result"
7744bd23fbfaSmrg	    dir=$func_resolve_sysroot_result
77458c4a8e55Smrg	    # Make sure the xrpath contains only unique directories.
77468c4a8e55Smrg	    case "$xrpath " in
77478c4a8e55Smrg	    *" $dir "*) ;;
7748bd23fbfaSmrg	    *) func_append xrpath " $dir" ;;
77498c4a8e55Smrg	    esac
77508c4a8e55Smrg	  fi
77518c4a8e55Smrg	  deplibs="$deplib $deplibs"
77528c4a8e55Smrg	  continue
77538c4a8e55Smrg	  ;;
7754bd23fbfaSmrg	*.la)
7755bd23fbfaSmrg	  func_resolve_sysroot "$deplib"
7756bd23fbfaSmrg	  lib=$func_resolve_sysroot_result
7757bd23fbfaSmrg	  ;;
77588c4a8e55Smrg	*.$libext)
77593169be4bSmrg	  if test conv = "$pass"; then
77608c4a8e55Smrg	    deplibs="$deplib $deplibs"
77618c4a8e55Smrg	    continue
77628c4a8e55Smrg	  fi
77638c4a8e55Smrg	  case $linkmode in
77648c4a8e55Smrg	  lib)
77658c4a8e55Smrg	    # Linking convenience modules into shared libraries is allowed,
77668c4a8e55Smrg	    # but linking other static libraries is non-portable.
77678c4a8e55Smrg	    case " $dlpreconveniencelibs " in
77688c4a8e55Smrg	    *" $deplib "*) ;;
77698c4a8e55Smrg	    *)
77703169be4bSmrg	      valid_a_lib=false
77718c4a8e55Smrg	      case $deplibs_check_method in
77728c4a8e55Smrg		match_pattern*)
77738c4a8e55Smrg		  set dummy $deplibs_check_method; shift
77748c4a8e55Smrg		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
7775706b6b52Smrg		  if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
77768c4a8e55Smrg		    | $EGREP "$match_pattern_regex" > /dev/null; then
77773169be4bSmrg		    valid_a_lib=:
77788c4a8e55Smrg		  fi
77798c4a8e55Smrg		;;
77808c4a8e55Smrg		pass_all)
77813169be4bSmrg		  valid_a_lib=:
77828c4a8e55Smrg		;;
77838c4a8e55Smrg	      esac
77843169be4bSmrg	      if $valid_a_lib; then
77853169be4bSmrg		echo
77863169be4bSmrg		$ECHO "*** Warning: Linking the shared library $output against the"
77873169be4bSmrg		$ECHO "*** static library $deplib is not portable!"
77883169be4bSmrg		deplibs="$deplib $deplibs"
77893169be4bSmrg	      else
7790706b6b52Smrg		echo
77918c4a8e55Smrg		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
7792706b6b52Smrg		echo "*** I have the capability to make that library automatically link in when"
7793706b6b52Smrg		echo "*** you link to this library.  But I can only do this if you have a"
7794706b6b52Smrg		echo "*** shared version of the library, which you do not appear to have"
7795706b6b52Smrg		echo "*** because the file extensions .$libext of this argument makes me believe"
7796706b6b52Smrg		echo "*** that it is just a static archive that I should not use here."
77978c4a8e55Smrg	      fi
77988c4a8e55Smrg	      ;;
77998c4a8e55Smrg	    esac
78008c4a8e55Smrg	    continue
78018c4a8e55Smrg	    ;;
78028c4a8e55Smrg	  prog)
78033169be4bSmrg	    if test link != "$pass"; then
78048c4a8e55Smrg	      deplibs="$deplib $deplibs"
78058c4a8e55Smrg	    else
78068c4a8e55Smrg	      compile_deplibs="$deplib $compile_deplibs"
78078c4a8e55Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
78088c4a8e55Smrg	    fi
78098c4a8e55Smrg	    continue
78108c4a8e55Smrg	    ;;
78118c4a8e55Smrg	  esac # linkmode
78128c4a8e55Smrg	  ;; # *.$libext
78138c4a8e55Smrg	*.lo | *.$objext)
78143169be4bSmrg	  if test conv = "$pass"; then
78158c4a8e55Smrg	    deplibs="$deplib $deplibs"
78163169be4bSmrg	  elif test prog = "$linkmode"; then
78173169be4bSmrg	    if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then
78188c4a8e55Smrg	      # If there is no dlopen support or we're linking statically,
78198c4a8e55Smrg	      # we need to preload.
7820bd23fbfaSmrg	      func_append newdlprefiles " $deplib"
78218c4a8e55Smrg	      compile_deplibs="$deplib $compile_deplibs"
78228c4a8e55Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
78238c4a8e55Smrg	    else
7824bd23fbfaSmrg	      func_append newdlfiles " $deplib"
78258c4a8e55Smrg	    fi
78268c4a8e55Smrg	  fi
78278c4a8e55Smrg	  continue
78288c4a8e55Smrg	  ;;
78298c4a8e55Smrg	%DEPLIBS%)
78303169be4bSmrg	  alldeplibs=:
78318c4a8e55Smrg	  continue
78328c4a8e55Smrg	  ;;
78338c4a8e55Smrg	esac # case $deplib
78348c4a8e55Smrg
78353169be4bSmrg	$found || test -f "$lib" \
78363169be4bSmrg	  || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'"
78378c4a8e55Smrg
78388c4a8e55Smrg	# Check to see that this really is a libtool archive.
78398c4a8e55Smrg	func_lalib_unsafe_p "$lib" \
78403169be4bSmrg	  || func_fatal_error "'$lib' is not a valid libtool archive"
78418c4a8e55Smrg
78428c4a8e55Smrg	func_dirname "$lib" "" "."
78433169be4bSmrg	ladir=$func_dirname_result
78448c4a8e55Smrg
78458c4a8e55Smrg	dlname=
78468c4a8e55Smrg	dlopen=
78478c4a8e55Smrg	dlpreopen=
78488c4a8e55Smrg	libdir=
78498c4a8e55Smrg	library_names=
78508c4a8e55Smrg	old_library=
78518c4a8e55Smrg	inherited_linker_flags=
78528c4a8e55Smrg	# If the library was installed with an old release of libtool,
78538c4a8e55Smrg	# it will not redefine variables installed, or shouldnotlink
78548c4a8e55Smrg	installed=yes
78558c4a8e55Smrg	shouldnotlink=no
78568c4a8e55Smrg	avoidtemprpath=
78578c4a8e55Smrg
78588c4a8e55Smrg
78598c4a8e55Smrg	# Read the .la file
78608c4a8e55Smrg	func_source "$lib"
78618c4a8e55Smrg
78628c4a8e55Smrg	# Convert "-framework foo" to "foo.ltframework"
78638c4a8e55Smrg	if test -n "$inherited_linker_flags"; then
7864706b6b52Smrg	  tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
78658c4a8e55Smrg	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
78668c4a8e55Smrg	    case " $new_inherited_linker_flags " in
78678c4a8e55Smrg	      *" $tmp_inherited_linker_flag "*) ;;
7868bd23fbfaSmrg	      *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
78698c4a8e55Smrg	    esac
78708c4a8e55Smrg	  done
78718c4a8e55Smrg	fi
7872706b6b52Smrg	dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
78733169be4bSmrg	if test lib,link = "$linkmode,$pass" ||
78743169be4bSmrg	   test prog,scan = "$linkmode,$pass" ||
78753169be4bSmrg	   { test prog != "$linkmode" && test lib != "$linkmode"; }; then
7876bd23fbfaSmrg	  test -n "$dlopen" && func_append dlfiles " $dlopen"
7877bd23fbfaSmrg	  test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
78788c4a8e55Smrg	fi
78798c4a8e55Smrg
78803169be4bSmrg	if test conv = "$pass"; then
78818c4a8e55Smrg	  # Only check for convenience libraries
78828c4a8e55Smrg	  deplibs="$lib $deplibs"
78838c4a8e55Smrg	  if test -z "$libdir"; then
78848c4a8e55Smrg	    if test -z "$old_library"; then
78853169be4bSmrg	      func_fatal_error "cannot find name of link library for '$lib'"
78868c4a8e55Smrg	    fi
78878c4a8e55Smrg	    # It is a libtool convenience library, so add in its objects.
7888bd23fbfaSmrg	    func_append convenience " $ladir/$objdir/$old_library"
7889bd23fbfaSmrg	    func_append old_convenience " $ladir/$objdir/$old_library"
78903169be4bSmrg	  elif test prog != "$linkmode" && test lib != "$linkmode"; then
78913169be4bSmrg	    func_fatal_error "'$lib' is not a convenience library"
78928c4a8e55Smrg	  fi
78933169be4bSmrg	  tmp_libs=
78943169be4bSmrg	  for deplib in $dependency_libs; do
78953169be4bSmrg	    deplibs="$deplib $deplibs"
78963169be4bSmrg	    if $opt_preserve_dup_deps; then
78973169be4bSmrg	      case "$tmp_libs " in
78983169be4bSmrg	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
78993169be4bSmrg	      esac
79003169be4bSmrg	    fi
79013169be4bSmrg	    func_append tmp_libs " $deplib"
79023169be4bSmrg	  done
79038c4a8e55Smrg	  continue
79048c4a8e55Smrg	fi # $pass = conv
79058c4a8e55Smrg
79068c4a8e55Smrg
79078c4a8e55Smrg	# Get the name of the library we link against.
79088c4a8e55Smrg	linklib=
7909bd23fbfaSmrg	if test -n "$old_library" &&
79103169be4bSmrg	   { test yes = "$prefer_static_libs" ||
79113169be4bSmrg	     test built,no = "$prefer_static_libs,$installed"; }; then
7912bd23fbfaSmrg	  linklib=$old_library
7913bd23fbfaSmrg	else
7914bd23fbfaSmrg	  for l in $old_library $library_names; do
79153169be4bSmrg	    linklib=$l
7916bd23fbfaSmrg	  done
7917bd23fbfaSmrg	fi
79188c4a8e55Smrg	if test -z "$linklib"; then
79193169be4bSmrg	  func_fatal_error "cannot find name of link library for '$lib'"
79208c4a8e55Smrg	fi
79218c4a8e55Smrg
79228c4a8e55Smrg	# This library was specified with -dlopen.
79233169be4bSmrg	if test dlopen = "$pass"; then
79243169be4bSmrg	  test -z "$libdir" \
79253169be4bSmrg	    && func_fatal_error "cannot -dlopen a convenience library: '$lib'"
79268c4a8e55Smrg	  if test -z "$dlname" ||
79273169be4bSmrg	     test yes != "$dlopen_support" ||
79283169be4bSmrg	     test no = "$build_libtool_libs"
79293169be4bSmrg	  then
79308c4a8e55Smrg	    # If there is no dlname, no dlopen support or we're linking
79318c4a8e55Smrg	    # statically, we need to preload.  We also need to preload any
79328c4a8e55Smrg	    # dependent libraries so libltdl's deplib preloader doesn't
79338c4a8e55Smrg	    # bomb out in the load deplibs phase.
7934bd23fbfaSmrg	    func_append dlprefiles " $lib $dependency_libs"
79358c4a8e55Smrg	  else
7936bd23fbfaSmrg	    func_append newdlfiles " $lib"
79378c4a8e55Smrg	  fi
79388c4a8e55Smrg	  continue
79398c4a8e55Smrg	fi # $pass = dlopen
79408c4a8e55Smrg
79418c4a8e55Smrg	# We need an absolute path.
79428c4a8e55Smrg	case $ladir in
79433169be4bSmrg	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;;
79448c4a8e55Smrg	*)
79458c4a8e55Smrg	  abs_ladir=`cd "$ladir" && pwd`
79468c4a8e55Smrg	  if test -z "$abs_ladir"; then
79473169be4bSmrg	    func_warning "cannot determine absolute directory name of '$ladir'"
79488c4a8e55Smrg	    func_warning "passing it literally to the linker, although it might fail"
79493169be4bSmrg	    abs_ladir=$ladir
79508c4a8e55Smrg	  fi
79518c4a8e55Smrg	  ;;
79528c4a8e55Smrg	esac
79538c4a8e55Smrg	func_basename "$lib"
79543169be4bSmrg	laname=$func_basename_result
79558c4a8e55Smrg
79568c4a8e55Smrg	# Find the relevant object directory and library name.
79573169be4bSmrg	if test yes = "$installed"; then
7958bd23fbfaSmrg	  if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
79593169be4bSmrg	    func_warning "library '$lib' was moved."
79603169be4bSmrg	    dir=$ladir
79613169be4bSmrg	    absdir=$abs_ladir
79623169be4bSmrg	    libdir=$abs_ladir
79638c4a8e55Smrg	  else
79643169be4bSmrg	    dir=$lt_sysroot$libdir
79653169be4bSmrg	    absdir=$lt_sysroot$libdir
79668c4a8e55Smrg	  fi
79673169be4bSmrg	  test yes = "$hardcode_automatic" && avoidtemprpath=yes
79688c4a8e55Smrg	else
79698c4a8e55Smrg	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
79703169be4bSmrg	    dir=$ladir
79713169be4bSmrg	    absdir=$abs_ladir
79728c4a8e55Smrg	    # Remove this search path later
7973bd23fbfaSmrg	    func_append notinst_path " $abs_ladir"
79748c4a8e55Smrg	  else
79753169be4bSmrg	    dir=$ladir/$objdir
79763169be4bSmrg	    absdir=$abs_ladir/$objdir
79778c4a8e55Smrg	    # Remove this search path later
7978bd23fbfaSmrg	    func_append notinst_path " $abs_ladir"
79798c4a8e55Smrg	  fi
79808c4a8e55Smrg	fi # $installed = yes
79818c4a8e55Smrg	func_stripname 'lib' '.la' "$laname"
79828c4a8e55Smrg	name=$func_stripname_result
79838c4a8e55Smrg
79848c4a8e55Smrg	# This library was specified with -dlpreopen.
79853169be4bSmrg	if test dlpreopen = "$pass"; then
79863169be4bSmrg	  if test -z "$libdir" && test prog = "$linkmode"; then
79873169be4bSmrg	    func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'"
79888c4a8e55Smrg	  fi
79893169be4bSmrg	  case $host in
7990bd23fbfaSmrg	    # special handling for platforms with PE-DLLs.
7991bd23fbfaSmrg	    *cygwin* | *mingw* | *cegcc* )
7992bd23fbfaSmrg	      # Linker will automatically link against shared library if both
7993bd23fbfaSmrg	      # static and shared are present.  Therefore, ensure we extract
7994bd23fbfaSmrg	      # symbols from the import library if a shared library is present
7995bd23fbfaSmrg	      # (otherwise, the dlopen module name will be incorrect).  We do
7996bd23fbfaSmrg	      # this by putting the import library name into $newdlprefiles.
7997bd23fbfaSmrg	      # We recover the dlopen module name by 'saving' the la file
7998bd23fbfaSmrg	      # name in a special purpose variable, and (later) extracting the
7999bd23fbfaSmrg	      # dlname from the la file.
8000bd23fbfaSmrg	      if test -n "$dlname"; then
8001bd23fbfaSmrg	        func_tr_sh "$dir/$linklib"
8002bd23fbfaSmrg	        eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
8003bd23fbfaSmrg	        func_append newdlprefiles " $dir/$linklib"
8004bd23fbfaSmrg	      else
8005bd23fbfaSmrg	        func_append newdlprefiles " $dir/$old_library"
8006bd23fbfaSmrg	        # Keep a list of preopened convenience libraries to check
8007bd23fbfaSmrg	        # that they are being used correctly in the link pass.
8008bd23fbfaSmrg	        test -z "$libdir" && \
8009bd23fbfaSmrg	          func_append dlpreconveniencelibs " $dir/$old_library"
8010bd23fbfaSmrg	      fi
8011bd23fbfaSmrg	    ;;
8012bd23fbfaSmrg	    * )
8013bd23fbfaSmrg	      # Prefer using a static library (so that no silly _DYNAMIC symbols
8014bd23fbfaSmrg	      # are required to link).
8015bd23fbfaSmrg	      if test -n "$old_library"; then
8016bd23fbfaSmrg	        func_append newdlprefiles " $dir/$old_library"
8017bd23fbfaSmrg	        # Keep a list of preopened convenience libraries to check
8018bd23fbfaSmrg	        # that they are being used correctly in the link pass.
8019bd23fbfaSmrg	        test -z "$libdir" && \
8020bd23fbfaSmrg	          func_append dlpreconveniencelibs " $dir/$old_library"
8021bd23fbfaSmrg	      # Otherwise, use the dlname, so that lt_dlopen finds it.
8022bd23fbfaSmrg	      elif test -n "$dlname"; then
8023bd23fbfaSmrg	        func_append newdlprefiles " $dir/$dlname"
8024bd23fbfaSmrg	      else
8025bd23fbfaSmrg	        func_append newdlprefiles " $dir/$linklib"
8026bd23fbfaSmrg	      fi
8027bd23fbfaSmrg	    ;;
8028bd23fbfaSmrg	  esac
80298c4a8e55Smrg	fi # $pass = dlpreopen
80308c4a8e55Smrg
80318c4a8e55Smrg	if test -z "$libdir"; then
80328c4a8e55Smrg	  # Link the convenience library
80333169be4bSmrg	  if test lib = "$linkmode"; then
80348c4a8e55Smrg	    deplibs="$dir/$old_library $deplibs"
80353169be4bSmrg	  elif test prog,link = "$linkmode,$pass"; then
80368c4a8e55Smrg	    compile_deplibs="$dir/$old_library $compile_deplibs"
80378c4a8e55Smrg	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
80388c4a8e55Smrg	  else
80398c4a8e55Smrg	    deplibs="$lib $deplibs" # used for prog,scan pass
80408c4a8e55Smrg	  fi
80418c4a8e55Smrg	  continue
80428c4a8e55Smrg	fi
80438c4a8e55Smrg
80448c4a8e55Smrg
80453169be4bSmrg	if test prog = "$linkmode" && test link != "$pass"; then
8046bd23fbfaSmrg	  func_append newlib_search_path " $ladir"
80478c4a8e55Smrg	  deplibs="$lib $deplibs"
80488c4a8e55Smrg
80493169be4bSmrg	  linkalldeplibs=false
80503169be4bSmrg	  if test no != "$link_all_deplibs" || test -z "$library_names" ||
80513169be4bSmrg	     test no = "$build_libtool_libs"; then
80523169be4bSmrg	    linkalldeplibs=:
80538c4a8e55Smrg	  fi
80548c4a8e55Smrg
80558c4a8e55Smrg	  tmp_libs=
80568c4a8e55Smrg	  for deplib in $dependency_libs; do
80578c4a8e55Smrg	    case $deplib in
80588c4a8e55Smrg	    -L*) func_stripname '-L' '' "$deplib"
8059bd23fbfaSmrg	         func_resolve_sysroot "$func_stripname_result"
8060bd23fbfaSmrg	         func_append newlib_search_path " $func_resolve_sysroot_result"
80618c4a8e55Smrg		 ;;
80628c4a8e55Smrg	    esac
80638c4a8e55Smrg	    # Need to link against all dependency_libs?
80643169be4bSmrg	    if $linkalldeplibs; then
80658c4a8e55Smrg	      deplibs="$deplib $deplibs"
80668c4a8e55Smrg	    else
80678c4a8e55Smrg	      # Need to hardcode shared library paths
80688c4a8e55Smrg	      # or/and link against static libraries
80698c4a8e55Smrg	      newdependency_libs="$deplib $newdependency_libs"
80708c4a8e55Smrg	    fi
80713169be4bSmrg	    if $opt_preserve_dup_deps; then
80728c4a8e55Smrg	      case "$tmp_libs " in
8073bd23fbfaSmrg	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
80748c4a8e55Smrg	      esac
80758c4a8e55Smrg	    fi
8076bd23fbfaSmrg	    func_append tmp_libs " $deplib"
80778c4a8e55Smrg	  done # for deplib
80788c4a8e55Smrg	  continue
80798c4a8e55Smrg	fi # $linkmode = prog...
80808c4a8e55Smrg
80813169be4bSmrg	if test prog,link = "$linkmode,$pass"; then
80828c4a8e55Smrg	  if test -n "$library_names" &&
80833169be4bSmrg	     { { test no = "$prefer_static_libs" ||
80843169be4bSmrg	         test built,yes = "$prefer_static_libs,$installed"; } ||
80858c4a8e55Smrg	       test -z "$old_library"; }; then
80868c4a8e55Smrg	    # We need to hardcode the library path
80873169be4bSmrg	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then
80888c4a8e55Smrg	      # Make sure the rpath contains only unique directories.
80893169be4bSmrg	      case $temp_rpath: in
80908c4a8e55Smrg	      *"$absdir:"*) ;;
8091bd23fbfaSmrg	      *) func_append temp_rpath "$absdir:" ;;
80928c4a8e55Smrg	      esac
80938c4a8e55Smrg	    fi
80948c4a8e55Smrg
80958c4a8e55Smrg	    # Hardcode the library path.
80968c4a8e55Smrg	    # Skip directories that are in the system default run-time
80978c4a8e55Smrg	    # search path.
80988c4a8e55Smrg	    case " $sys_lib_dlsearch_path " in
80998c4a8e55Smrg	    *" $absdir "*) ;;
81008c4a8e55Smrg	    *)
81018c4a8e55Smrg	      case "$compile_rpath " in
81028c4a8e55Smrg	      *" $absdir "*) ;;
8103bd23fbfaSmrg	      *) func_append compile_rpath " $absdir" ;;
81048c4a8e55Smrg	      esac
81058c4a8e55Smrg	      ;;
81068c4a8e55Smrg	    esac
81078c4a8e55Smrg	    case " $sys_lib_dlsearch_path " in
81088c4a8e55Smrg	    *" $libdir "*) ;;
81098c4a8e55Smrg	    *)
81108c4a8e55Smrg	      case "$finalize_rpath " in
81118c4a8e55Smrg	      *" $libdir "*) ;;
8112bd23fbfaSmrg	      *) func_append finalize_rpath " $libdir" ;;
81138c4a8e55Smrg	      esac
81148c4a8e55Smrg	      ;;
81158c4a8e55Smrg	    esac
81168c4a8e55Smrg	  fi # $linkmode,$pass = prog,link...
81178c4a8e55Smrg
81183169be4bSmrg	  if $alldeplibs &&
81193169be4bSmrg	     { test pass_all = "$deplibs_check_method" ||
81203169be4bSmrg	       { test yes = "$build_libtool_libs" &&
81218c4a8e55Smrg		 test -n "$library_names"; }; }; then
81228c4a8e55Smrg	    # We only need to search for static libraries
81238c4a8e55Smrg	    continue
81248c4a8e55Smrg	  fi
81258c4a8e55Smrg	fi
81268c4a8e55Smrg
81278c4a8e55Smrg	link_static=no # Whether the deplib will be linked statically
81288c4a8e55Smrg	use_static_libs=$prefer_static_libs
81293169be4bSmrg	if test built = "$use_static_libs" && test yes = "$installed"; then
81308c4a8e55Smrg	  use_static_libs=no
81318c4a8e55Smrg	fi
81328c4a8e55Smrg	if test -n "$library_names" &&
81333169be4bSmrg	   { test no = "$use_static_libs" || test -z "$old_library"; }; then
81348c4a8e55Smrg	  case $host in
81353169be4bSmrg	  *cygwin* | *mingw* | *cegcc* | *os2*)
81368c4a8e55Smrg	      # No point in relinking DLLs because paths are not encoded
8137bd23fbfaSmrg	      func_append notinst_deplibs " $lib"
81388c4a8e55Smrg	      need_relink=no
81398c4a8e55Smrg	    ;;
81408c4a8e55Smrg	  *)
81413169be4bSmrg	    if test no = "$installed"; then
8142bd23fbfaSmrg	      func_append notinst_deplibs " $lib"
81438c4a8e55Smrg	      need_relink=yes
81448c4a8e55Smrg	    fi
81458c4a8e55Smrg	    ;;
81468c4a8e55Smrg	  esac
81478c4a8e55Smrg	  # This is a shared library
81488c4a8e55Smrg
81498c4a8e55Smrg	  # Warn about portability, can't link against -module's on some
81508c4a8e55Smrg	  # systems (darwin).  Don't bleat about dlopened modules though!
81513169be4bSmrg	  dlopenmodule=
81528c4a8e55Smrg	  for dlpremoduletest in $dlprefiles; do
81538c4a8e55Smrg	    if test "X$dlpremoduletest" = "X$lib"; then
81543169be4bSmrg	      dlopenmodule=$dlpremoduletest
81558c4a8e55Smrg	      break
81568c4a8e55Smrg	    fi
81578c4a8e55Smrg	  done
81583169be4bSmrg	  if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then
8159706b6b52Smrg	    echo
81603169be4bSmrg	    if test prog = "$linkmode"; then
81618c4a8e55Smrg	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
81628c4a8e55Smrg	    else
81638c4a8e55Smrg	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
81648c4a8e55Smrg	    fi
81658c4a8e55Smrg	    $ECHO "*** $linklib is not portable!"
81668c4a8e55Smrg	  fi
81673169be4bSmrg	  if test lib = "$linkmode" &&
81683169be4bSmrg	     test yes = "$hardcode_into_libs"; then
81698c4a8e55Smrg	    # Hardcode the library path.
81708c4a8e55Smrg	    # Skip directories that are in the system default run-time
81718c4a8e55Smrg	    # search path.
81728c4a8e55Smrg	    case " $sys_lib_dlsearch_path " in
81738c4a8e55Smrg	    *" $absdir "*) ;;
81748c4a8e55Smrg	    *)
81758c4a8e55Smrg	      case "$compile_rpath " in
81768c4a8e55Smrg	      *" $absdir "*) ;;
8177bd23fbfaSmrg	      *) func_append compile_rpath " $absdir" ;;
81788c4a8e55Smrg	      esac
81798c4a8e55Smrg	      ;;
81808c4a8e55Smrg	    esac
81818c4a8e55Smrg	    case " $sys_lib_dlsearch_path " in
81828c4a8e55Smrg	    *" $libdir "*) ;;
81838c4a8e55Smrg	    *)
81848c4a8e55Smrg	      case "$finalize_rpath " in
81858c4a8e55Smrg	      *" $libdir "*) ;;
8186bd23fbfaSmrg	      *) func_append finalize_rpath " $libdir" ;;
81878c4a8e55Smrg	      esac
81888c4a8e55Smrg	      ;;
81898c4a8e55Smrg	    esac
81908c4a8e55Smrg	  fi
81918c4a8e55Smrg
81928c4a8e55Smrg	  if test -n "$old_archive_from_expsyms_cmds"; then
81938c4a8e55Smrg	    # figure out the soname
81948c4a8e55Smrg	    set dummy $library_names
81958c4a8e55Smrg	    shift
81963169be4bSmrg	    realname=$1
81978c4a8e55Smrg	    shift
81988c4a8e55Smrg	    libname=`eval "\\$ECHO \"$libname_spec\""`
81998c4a8e55Smrg	    # use dlname if we got it. it's perfectly good, no?
82008c4a8e55Smrg	    if test -n "$dlname"; then
82013169be4bSmrg	      soname=$dlname
82028c4a8e55Smrg	    elif test -n "$soname_spec"; then
82038c4a8e55Smrg	      # bleh windows
82048c4a8e55Smrg	      case $host in
82053169be4bSmrg	      *cygwin* | mingw* | *cegcc* | *os2*)
82068c4a8e55Smrg	        func_arith $current - $age
82078c4a8e55Smrg		major=$func_arith_result
82083169be4bSmrg		versuffix=-$major
82098c4a8e55Smrg		;;
82108c4a8e55Smrg	      esac
82118c4a8e55Smrg	      eval soname=\"$soname_spec\"
82128c4a8e55Smrg	    else
82133169be4bSmrg	      soname=$realname
82148c4a8e55Smrg	    fi
82158c4a8e55Smrg
82168c4a8e55Smrg	    # Make a new name for the extract_expsyms_cmds to use
82173169be4bSmrg	    soroot=$soname
82188c4a8e55Smrg	    func_basename "$soroot"
82193169be4bSmrg	    soname=$func_basename_result
82208c4a8e55Smrg	    func_stripname 'lib' '.dll' "$soname"
82218c4a8e55Smrg	    newlib=libimp-$func_stripname_result.a
82228c4a8e55Smrg
82238c4a8e55Smrg	    # If the library has no export list, then create one now
82248c4a8e55Smrg	    if test -f "$output_objdir/$soname-def"; then :
82258c4a8e55Smrg	    else
82263169be4bSmrg	      func_verbose "extracting exported symbol list from '$soname'"
82278c4a8e55Smrg	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
82288c4a8e55Smrg	    fi
82298c4a8e55Smrg
82308c4a8e55Smrg	    # Create $newlib
82318c4a8e55Smrg	    if test -f "$output_objdir/$newlib"; then :; else
82323169be4bSmrg	      func_verbose "generating import library for '$soname'"
82338c4a8e55Smrg	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
82348c4a8e55Smrg	    fi
82358c4a8e55Smrg	    # make sure the library variables are pointing to the new library
82368c4a8e55Smrg	    dir=$output_objdir
82378c4a8e55Smrg	    linklib=$newlib
82388c4a8e55Smrg	  fi # test -n "$old_archive_from_expsyms_cmds"
82398c4a8e55Smrg
82403169be4bSmrg	  if test prog = "$linkmode" || test relink != "$opt_mode"; then
82418c4a8e55Smrg	    add_shlibpath=
82428c4a8e55Smrg	    add_dir=
82438c4a8e55Smrg	    add=
82448c4a8e55Smrg	    lib_linked=yes
82458c4a8e55Smrg	    case $hardcode_action in
82468c4a8e55Smrg	    immediate | unsupported)
82473169be4bSmrg	      if test no = "$hardcode_direct"; then
82483169be4bSmrg		add=$dir/$linklib
82498c4a8e55Smrg		case $host in
82503169be4bSmrg		  *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;;
82513169be4bSmrg		  *-*-sysv4*uw2*) add_dir=-L$dir ;;
82528c4a8e55Smrg		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
82533169be4bSmrg		    *-*-unixware7*) add_dir=-L$dir ;;
82548c4a8e55Smrg		  *-*-darwin* )
82553169be4bSmrg		    # if the lib is a (non-dlopened) module then we cannot
82568c4a8e55Smrg		    # link against it, someone is ignoring the earlier warnings
82578c4a8e55Smrg		    if /usr/bin/file -L $add 2> /dev/null |
82583169be4bSmrg			 $GREP ": [^:]* bundle" >/dev/null; then
82598c4a8e55Smrg		      if test "X$dlopenmodule" != "X$lib"; then
82608c4a8e55Smrg			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
82613169be4bSmrg			if test -z "$old_library"; then
8262706b6b52Smrg			  echo
8263706b6b52Smrg			  echo "*** And there doesn't seem to be a static archive available"
8264706b6b52Smrg			  echo "*** The link will probably fail, sorry"
82658c4a8e55Smrg			else
82663169be4bSmrg			  add=$dir/$old_library
82678c4a8e55Smrg			fi
82688c4a8e55Smrg		      elif test -n "$old_library"; then
82693169be4bSmrg			add=$dir/$old_library
82708c4a8e55Smrg		      fi
82718c4a8e55Smrg		    fi
82728c4a8e55Smrg		esac
82733169be4bSmrg	      elif test no = "$hardcode_minus_L"; then
82748c4a8e55Smrg		case $host in
82753169be4bSmrg		*-*-sunos*) add_shlibpath=$dir ;;
82768c4a8e55Smrg		esac
82773169be4bSmrg		add_dir=-L$dir
82783169be4bSmrg		add=-l$name
82793169be4bSmrg	      elif test no = "$hardcode_shlibpath_var"; then
82803169be4bSmrg		add_shlibpath=$dir
82813169be4bSmrg		add=-l$name
82828c4a8e55Smrg	      else
82838c4a8e55Smrg		lib_linked=no
82848c4a8e55Smrg	      fi
82858c4a8e55Smrg	      ;;
82868c4a8e55Smrg	    relink)
82873169be4bSmrg	      if test yes = "$hardcode_direct" &&
82883169be4bSmrg	         test no = "$hardcode_direct_absolute"; then
82893169be4bSmrg		add=$dir/$linklib
82903169be4bSmrg	      elif test yes = "$hardcode_minus_L"; then
82913169be4bSmrg		add_dir=-L$absdir
82928c4a8e55Smrg		# Try looking first in the location we're being installed to.
82938c4a8e55Smrg		if test -n "$inst_prefix_dir"; then
82948c4a8e55Smrg		  case $libdir in
82958c4a8e55Smrg		    [\\/]*)
8296bd23fbfaSmrg		      func_append add_dir " -L$inst_prefix_dir$libdir"
82978c4a8e55Smrg		      ;;
82988c4a8e55Smrg		  esac
82998c4a8e55Smrg		fi
83003169be4bSmrg		add=-l$name
83013169be4bSmrg	      elif test yes = "$hardcode_shlibpath_var"; then
83023169be4bSmrg		add_shlibpath=$dir
83033169be4bSmrg		add=-l$name
83048c4a8e55Smrg	      else
83058c4a8e55Smrg		lib_linked=no
83068c4a8e55Smrg	      fi
83078c4a8e55Smrg	      ;;
83088c4a8e55Smrg	    *) lib_linked=no ;;
83098c4a8e55Smrg	    esac
83108c4a8e55Smrg
83113169be4bSmrg	    if test yes != "$lib_linked"; then
83128c4a8e55Smrg	      func_fatal_configuration "unsupported hardcode properties"
83138c4a8e55Smrg	    fi
83148c4a8e55Smrg
83158c4a8e55Smrg	    if test -n "$add_shlibpath"; then
83168c4a8e55Smrg	      case :$compile_shlibpath: in
83178c4a8e55Smrg	      *":$add_shlibpath:"*) ;;
8318bd23fbfaSmrg	      *) func_append compile_shlibpath "$add_shlibpath:" ;;
83198c4a8e55Smrg	      esac
83208c4a8e55Smrg	    fi
83213169be4bSmrg	    if test prog = "$linkmode"; then
83228c4a8e55Smrg	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
83238c4a8e55Smrg	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
83248c4a8e55Smrg	    else
83258c4a8e55Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
83268c4a8e55Smrg	      test -n "$add" && deplibs="$add $deplibs"
83273169be4bSmrg	      if test yes != "$hardcode_direct" &&
83283169be4bSmrg		 test yes != "$hardcode_minus_L" &&
83293169be4bSmrg		 test yes = "$hardcode_shlibpath_var"; then
83308c4a8e55Smrg		case :$finalize_shlibpath: in
83318c4a8e55Smrg		*":$libdir:"*) ;;
8332bd23fbfaSmrg		*) func_append finalize_shlibpath "$libdir:" ;;
83338c4a8e55Smrg		esac
83348c4a8e55Smrg	      fi
83358c4a8e55Smrg	    fi
83368c4a8e55Smrg	  fi
83378c4a8e55Smrg
83383169be4bSmrg	  if test prog = "$linkmode" || test relink = "$opt_mode"; then
83398c4a8e55Smrg	    add_shlibpath=
83408c4a8e55Smrg	    add_dir=
83418c4a8e55Smrg	    add=
83428c4a8e55Smrg	    # Finalize command for both is simple: just hardcode it.
83433169be4bSmrg	    if test yes = "$hardcode_direct" &&
83443169be4bSmrg	       test no = "$hardcode_direct_absolute"; then
83453169be4bSmrg	      add=$libdir/$linklib
83463169be4bSmrg	    elif test yes = "$hardcode_minus_L"; then
83473169be4bSmrg	      add_dir=-L$libdir
83483169be4bSmrg	      add=-l$name
83493169be4bSmrg	    elif test yes = "$hardcode_shlibpath_var"; then
83508c4a8e55Smrg	      case :$finalize_shlibpath: in
83518c4a8e55Smrg	      *":$libdir:"*) ;;
8352bd23fbfaSmrg	      *) func_append finalize_shlibpath "$libdir:" ;;
83538c4a8e55Smrg	      esac
83543169be4bSmrg	      add=-l$name
83553169be4bSmrg	    elif test yes = "$hardcode_automatic"; then
83568c4a8e55Smrg	      if test -n "$inst_prefix_dir" &&
83573169be4bSmrg		 test -f "$inst_prefix_dir$libdir/$linklib"; then
83583169be4bSmrg		add=$inst_prefix_dir$libdir/$linklib
83598c4a8e55Smrg	      else
83603169be4bSmrg		add=$libdir/$linklib
83618c4a8e55Smrg	      fi
83628c4a8e55Smrg	    else
83638c4a8e55Smrg	      # We cannot seem to hardcode it, guess we'll fake it.
83643169be4bSmrg	      add_dir=-L$libdir
83658c4a8e55Smrg	      # Try looking first in the location we're being installed to.
83668c4a8e55Smrg	      if test -n "$inst_prefix_dir"; then
83678c4a8e55Smrg		case $libdir in
83688c4a8e55Smrg		  [\\/]*)
8369bd23fbfaSmrg		    func_append add_dir " -L$inst_prefix_dir$libdir"
83708c4a8e55Smrg		    ;;
83718c4a8e55Smrg		esac
83728c4a8e55Smrg	      fi
83733169be4bSmrg	      add=-l$name
83748c4a8e55Smrg	    fi
83758c4a8e55Smrg
83763169be4bSmrg	    if test prog = "$linkmode"; then
83778c4a8e55Smrg	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
83788c4a8e55Smrg	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
83798c4a8e55Smrg	    else
83808c4a8e55Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
83818c4a8e55Smrg	      test -n "$add" && deplibs="$add $deplibs"
83828c4a8e55Smrg	    fi
83838c4a8e55Smrg	  fi
83843169be4bSmrg	elif test prog = "$linkmode"; then
83858c4a8e55Smrg	  # Here we assume that one of hardcode_direct or hardcode_minus_L
83868c4a8e55Smrg	  # is not unsupported.  This is valid on all known static and
83878c4a8e55Smrg	  # shared platforms.
83883169be4bSmrg	  if test unsupported != "$hardcode_direct"; then
83893169be4bSmrg	    test -n "$old_library" && linklib=$old_library
83908c4a8e55Smrg	    compile_deplibs="$dir/$linklib $compile_deplibs"
83918c4a8e55Smrg	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
83928c4a8e55Smrg	  else
83938c4a8e55Smrg	    compile_deplibs="-l$name -L$dir $compile_deplibs"
83948c4a8e55Smrg	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
83958c4a8e55Smrg	  fi
83963169be4bSmrg	elif test yes = "$build_libtool_libs"; then
83978c4a8e55Smrg	  # Not a shared library
83983169be4bSmrg	  if test pass_all != "$deplibs_check_method"; then
83998c4a8e55Smrg	    # We're trying link a shared library against a static one
84008c4a8e55Smrg	    # but the system doesn't support it.
84018c4a8e55Smrg
84028c4a8e55Smrg	    # Just print a warning and add the library to dependency_libs so
84038c4a8e55Smrg	    # that the program can be linked against the static library.
8404706b6b52Smrg	    echo
84053169be4bSmrg	    $ECHO "*** Warning: This system cannot link to static lib archive $lib."
8406706b6b52Smrg	    echo "*** I have the capability to make that library automatically link in when"
8407706b6b52Smrg	    echo "*** you link to this library.  But I can only do this if you have a"
8408706b6b52Smrg	    echo "*** shared version of the library, which you do not appear to have."
84093169be4bSmrg	    if test yes = "$module"; then
8410706b6b52Smrg	      echo "*** But as you try to build a module library, libtool will still create "
8411706b6b52Smrg	      echo "*** a static module, that should work as long as the dlopening application"
8412706b6b52Smrg	      echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
84138c4a8e55Smrg	      if test -z "$global_symbol_pipe"; then
8414706b6b52Smrg		echo
8415706b6b52Smrg		echo "*** However, this would only work if libtool was able to extract symbol"
84163169be4bSmrg		echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
8417706b6b52Smrg		echo "*** not find such a program.  So, this module is probably useless."
84183169be4bSmrg		echo "*** 'nm' from GNU binutils and a full rebuild may help."
84198c4a8e55Smrg	      fi
84203169be4bSmrg	      if test no = "$build_old_libs"; then
84218c4a8e55Smrg		build_libtool_libs=module
84228c4a8e55Smrg		build_old_libs=yes
84238c4a8e55Smrg	      else
84248c4a8e55Smrg		build_libtool_libs=no
84258c4a8e55Smrg	      fi
84268c4a8e55Smrg	    fi
84278c4a8e55Smrg	  else
84288c4a8e55Smrg	    deplibs="$dir/$old_library $deplibs"
84298c4a8e55Smrg	    link_static=yes
84308c4a8e55Smrg	  fi
84318c4a8e55Smrg	fi # link shared/static library?
84328c4a8e55Smrg
84333169be4bSmrg	if test lib = "$linkmode"; then
84348c4a8e55Smrg	  if test -n "$dependency_libs" &&
84353169be4bSmrg	     { test yes != "$hardcode_into_libs" ||
84363169be4bSmrg	       test yes = "$build_old_libs" ||
84373169be4bSmrg	       test yes = "$link_static"; }; then
84388c4a8e55Smrg	    # Extract -R from dependency_libs
84398c4a8e55Smrg	    temp_deplibs=
84408c4a8e55Smrg	    for libdir in $dependency_libs; do
84418c4a8e55Smrg	      case $libdir in
84428c4a8e55Smrg	      -R*) func_stripname '-R' '' "$libdir"
84438c4a8e55Smrg	           temp_xrpath=$func_stripname_result
84448c4a8e55Smrg		   case " $xrpath " in
84458c4a8e55Smrg		   *" $temp_xrpath "*) ;;
8446bd23fbfaSmrg		   *) func_append xrpath " $temp_xrpath";;
84478c4a8e55Smrg		   esac;;
8448bd23fbfaSmrg	      *) func_append temp_deplibs " $libdir";;
84498c4a8e55Smrg	      esac
84508c4a8e55Smrg	    done
84513169be4bSmrg	    dependency_libs=$temp_deplibs
84528c4a8e55Smrg	  fi
84538c4a8e55Smrg
8454bd23fbfaSmrg	  func_append newlib_search_path " $absdir"
84558c4a8e55Smrg	  # Link against this library
84563169be4bSmrg	  test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
84578c4a8e55Smrg	  # ... and its dependency_libs
84588c4a8e55Smrg	  tmp_libs=
84598c4a8e55Smrg	  for deplib in $dependency_libs; do
84608c4a8e55Smrg	    newdependency_libs="$deplib $newdependency_libs"
8461bd23fbfaSmrg	    case $deplib in
8462bd23fbfaSmrg              -L*) func_stripname '-L' '' "$deplib"
8463bd23fbfaSmrg                   func_resolve_sysroot "$func_stripname_result";;
8464bd23fbfaSmrg              *) func_resolve_sysroot "$deplib" ;;
8465bd23fbfaSmrg            esac
84663169be4bSmrg	    if $opt_preserve_dup_deps; then
84678c4a8e55Smrg	      case "$tmp_libs " in
8468bd23fbfaSmrg	      *" $func_resolve_sysroot_result "*)
8469bd23fbfaSmrg                func_append specialdeplibs " $func_resolve_sysroot_result" ;;
84708c4a8e55Smrg	      esac
84718c4a8e55Smrg	    fi
8472bd23fbfaSmrg	    func_append tmp_libs " $func_resolve_sysroot_result"
84738c4a8e55Smrg	  done
84748c4a8e55Smrg
84753169be4bSmrg	  if test no != "$link_all_deplibs"; then
84768c4a8e55Smrg	    # Add the search paths of all dependency libraries
84778c4a8e55Smrg	    for deplib in $dependency_libs; do
8478706b6b52Smrg	      path=
84798c4a8e55Smrg	      case $deplib in
84803169be4bSmrg	      -L*) path=$deplib ;;
84818c4a8e55Smrg	      *.la)
8482bd23fbfaSmrg	        func_resolve_sysroot "$deplib"
8483bd23fbfaSmrg	        deplib=$func_resolve_sysroot_result
84848c4a8e55Smrg	        func_dirname "$deplib" "" "."
8485bd23fbfaSmrg		dir=$func_dirname_result
84868c4a8e55Smrg		# We need an absolute path.
84878c4a8e55Smrg		case $dir in
84883169be4bSmrg		[\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;;
84898c4a8e55Smrg		*)
84908c4a8e55Smrg		  absdir=`cd "$dir" && pwd`
84918c4a8e55Smrg		  if test -z "$absdir"; then
84923169be4bSmrg		    func_warning "cannot determine absolute directory name of '$dir'"
84933169be4bSmrg		    absdir=$dir
84948c4a8e55Smrg		  fi
84958c4a8e55Smrg		  ;;
84968c4a8e55Smrg		esac
84978c4a8e55Smrg		if $GREP "^installed=no" $deplib > /dev/null; then
84988c4a8e55Smrg		case $host in
84998c4a8e55Smrg		*-*-darwin*)
85008c4a8e55Smrg		  depdepl=
85013169be4bSmrg		  eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
85023169be4bSmrg		  if test -n "$deplibrary_names"; then
85033169be4bSmrg		    for tmp in $deplibrary_names; do
85048c4a8e55Smrg		      depdepl=$tmp
85058c4a8e55Smrg		    done
85063169be4bSmrg		    if test -f "$absdir/$objdir/$depdepl"; then
85073169be4bSmrg		      depdepl=$absdir/$objdir/$depdepl
85083169be4bSmrg		      darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
85098c4a8e55Smrg                      if test -z "$darwin_install_name"; then
85103169be4bSmrg                          darwin_install_name=`$OTOOL64 -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
85118c4a8e55Smrg                      fi
85123169be4bSmrg		      func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl"
85133169be4bSmrg		      func_append linker_flags " -dylib_file $darwin_install_name:$depdepl"
85148c4a8e55Smrg		      path=
85158c4a8e55Smrg		    fi
85168c4a8e55Smrg		  fi
85178c4a8e55Smrg		  ;;
85188c4a8e55Smrg		*)
85193169be4bSmrg		  path=-L$absdir/$objdir
85208c4a8e55Smrg		  ;;
85218c4a8e55Smrg		esac
85228c4a8e55Smrg		else
85233169be4bSmrg		  eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
85248c4a8e55Smrg		  test -z "$libdir" && \
85253169be4bSmrg		    func_fatal_error "'$deplib' is not a valid libtool archive"
85268c4a8e55Smrg		  test "$absdir" != "$libdir" && \
85273169be4bSmrg		    func_warning "'$deplib' seems to be moved"
85288c4a8e55Smrg
85293169be4bSmrg		  path=-L$absdir
85308c4a8e55Smrg		fi
85318c4a8e55Smrg		;;
85328c4a8e55Smrg	      esac
85338c4a8e55Smrg	      case " $deplibs " in
85348c4a8e55Smrg	      *" $path "*) ;;
85358c4a8e55Smrg	      *) deplibs="$path $deplibs" ;;
85368c4a8e55Smrg	      esac
85378c4a8e55Smrg	    done
85388c4a8e55Smrg	  fi # link_all_deplibs != no
85398c4a8e55Smrg	fi # linkmode = lib
85408c4a8e55Smrg      done # for deplib in $libs
85413169be4bSmrg      if test link = "$pass"; then
85423169be4bSmrg	if test prog = "$linkmode"; then
85438c4a8e55Smrg	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
85448c4a8e55Smrg	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
85458c4a8e55Smrg	else
8546706b6b52Smrg	  compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
85478c4a8e55Smrg	fi
85488c4a8e55Smrg      fi
85493169be4bSmrg      dependency_libs=$newdependency_libs
85503169be4bSmrg      if test dlpreopen = "$pass"; then
85518c4a8e55Smrg	# Link the dlpreopened libraries before other libraries
85528c4a8e55Smrg	for deplib in $save_deplibs; do
85538c4a8e55Smrg	  deplibs="$deplib $deplibs"
85548c4a8e55Smrg	done
85558c4a8e55Smrg      fi
85563169be4bSmrg      if test dlopen != "$pass"; then
85573169be4bSmrg	test conv = "$pass" || {
85588c4a8e55Smrg	  # Make sure lib_search_path contains only unique directories.
85598c4a8e55Smrg	  lib_search_path=
85608c4a8e55Smrg	  for dir in $newlib_search_path; do
85618c4a8e55Smrg	    case "$lib_search_path " in
85628c4a8e55Smrg	    *" $dir "*) ;;
8563bd23fbfaSmrg	    *) func_append lib_search_path " $dir" ;;
85648c4a8e55Smrg	    esac
85658c4a8e55Smrg	  done
85668c4a8e55Smrg	  newlib_search_path=
85673169be4bSmrg	}
85688c4a8e55Smrg
85693169be4bSmrg	if test prog,link = "$linkmode,$pass"; then
85708c4a8e55Smrg	  vars="compile_deplibs finalize_deplibs"
85713169be4bSmrg	else
85723169be4bSmrg	  vars=deplibs
85738c4a8e55Smrg	fi
85748c4a8e55Smrg	for var in $vars dependency_libs; do
85758c4a8e55Smrg	  # Add libraries to $var in reverse order
85768c4a8e55Smrg	  eval tmp_libs=\"\$$var\"
85778c4a8e55Smrg	  new_libs=
85788c4a8e55Smrg	  for deplib in $tmp_libs; do
85798c4a8e55Smrg	    # FIXME: Pedantically, this is the right thing to do, so
85808c4a8e55Smrg	    #        that some nasty dependency loop isn't accidentally
85818c4a8e55Smrg	    #        broken:
85828c4a8e55Smrg	    #new_libs="$deplib $new_libs"
85838c4a8e55Smrg	    # Pragmatically, this seems to cause very few problems in
85848c4a8e55Smrg	    # practice:
85858c4a8e55Smrg	    case $deplib in
85868c4a8e55Smrg	    -L*) new_libs="$deplib $new_libs" ;;
85878c4a8e55Smrg	    -R*) ;;
85888c4a8e55Smrg	    *)
85898c4a8e55Smrg	      # And here is the reason: when a library appears more
85908c4a8e55Smrg	      # than once as an explicit dependence of a library, or
85918c4a8e55Smrg	      # is implicitly linked in more than once by the
85928c4a8e55Smrg	      # compiler, it is considered special, and multiple
85938c4a8e55Smrg	      # occurrences thereof are not removed.  Compare this
85948c4a8e55Smrg	      # with having the same library being listed as a
85958c4a8e55Smrg	      # dependency of multiple other libraries: in this case,
85968c4a8e55Smrg	      # we know (pedantically, we assume) the library does not
85978c4a8e55Smrg	      # need to be listed more than once, so we keep only the
85988c4a8e55Smrg	      # last copy.  This is not always right, but it is rare
85998c4a8e55Smrg	      # enough that we require users that really mean to play
86008c4a8e55Smrg	      # such unportable linking tricks to link the library
86018c4a8e55Smrg	      # using -Wl,-lname, so that libtool does not consider it
86028c4a8e55Smrg	      # for duplicate removal.
86038c4a8e55Smrg	      case " $specialdeplibs " in
86048c4a8e55Smrg	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
86058c4a8e55Smrg	      *)
86068c4a8e55Smrg		case " $new_libs " in
86078c4a8e55Smrg		*" $deplib "*) ;;
86088c4a8e55Smrg		*) new_libs="$deplib $new_libs" ;;
86098c4a8e55Smrg		esac
86108c4a8e55Smrg		;;
86118c4a8e55Smrg	      esac
86128c4a8e55Smrg	      ;;
86138c4a8e55Smrg	    esac
86148c4a8e55Smrg	  done
86158c4a8e55Smrg	  tmp_libs=
86168c4a8e55Smrg	  for deplib in $new_libs; do
86178c4a8e55Smrg	    case $deplib in
86188c4a8e55Smrg	    -L*)
86198c4a8e55Smrg	      case " $tmp_libs " in
86208c4a8e55Smrg	      *" $deplib "*) ;;
8621bd23fbfaSmrg	      *) func_append tmp_libs " $deplib" ;;
86228c4a8e55Smrg	      esac
86238c4a8e55Smrg	      ;;
8624bd23fbfaSmrg	    *) func_append tmp_libs " $deplib" ;;
86258c4a8e55Smrg	    esac
86268c4a8e55Smrg	  done
86278c4a8e55Smrg	  eval $var=\"$tmp_libs\"
86288c4a8e55Smrg	done # for var
86298c4a8e55Smrg      fi
86303169be4bSmrg
86313169be4bSmrg      # Add Sun CC postdeps if required:
86323169be4bSmrg      test CXX = "$tagname" && {
86333169be4bSmrg        case $host_os in
86343169be4bSmrg        linux*)
86353169be4bSmrg          case `$CC -V 2>&1 | sed 5q` in
86363169be4bSmrg          *Sun\ C*) # Sun C++ 5.9
86373169be4bSmrg            func_suncc_cstd_abi
86383169be4bSmrg
86393169be4bSmrg            if test no != "$suncc_use_cstd_abi"; then
86403169be4bSmrg              func_append postdeps ' -library=Cstd -library=Crun'
86413169be4bSmrg            fi
86423169be4bSmrg            ;;
86433169be4bSmrg          esac
86443169be4bSmrg          ;;
86453169be4bSmrg
86463169be4bSmrg        solaris*)
86473169be4bSmrg          func_cc_basename "$CC"
86483169be4bSmrg          case $func_cc_basename_result in
86493169be4bSmrg          CC* | sunCC*)
86503169be4bSmrg            func_suncc_cstd_abi
86513169be4bSmrg
86523169be4bSmrg            if test no != "$suncc_use_cstd_abi"; then
86533169be4bSmrg              func_append postdeps ' -library=Cstd -library=Crun'
86543169be4bSmrg            fi
86553169be4bSmrg            ;;
86563169be4bSmrg          esac
86573169be4bSmrg          ;;
86583169be4bSmrg        esac
86593169be4bSmrg      }
86603169be4bSmrg
86618c4a8e55Smrg      # Last step: remove runtime libs from dependency_libs
86628c4a8e55Smrg      # (they stay in deplibs)
86638c4a8e55Smrg      tmp_libs=
86643169be4bSmrg      for i in $dependency_libs; do
86658c4a8e55Smrg	case " $predeps $postdeps $compiler_lib_search_path " in
86668c4a8e55Smrg	*" $i "*)
86673169be4bSmrg	  i=
86688c4a8e55Smrg	  ;;
86698c4a8e55Smrg	esac
86703169be4bSmrg	if test -n "$i"; then
8671bd23fbfaSmrg	  func_append tmp_libs " $i"
86728c4a8e55Smrg	fi
86738c4a8e55Smrg      done
86748c4a8e55Smrg      dependency_libs=$tmp_libs
86758c4a8e55Smrg    done # for pass
86763169be4bSmrg    if test prog = "$linkmode"; then
86773169be4bSmrg      dlfiles=$newdlfiles
86788c4a8e55Smrg    fi
86793169be4bSmrg    if test prog = "$linkmode" || test lib = "$linkmode"; then
86803169be4bSmrg      dlprefiles=$newdlprefiles
86818c4a8e55Smrg    fi
86828c4a8e55Smrg
86838c4a8e55Smrg    case $linkmode in
86848c4a8e55Smrg    oldlib)
86853169be4bSmrg      if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
86863169be4bSmrg	func_warning "'-dlopen' is ignored for archives"
86878c4a8e55Smrg      fi
86888c4a8e55Smrg
86898c4a8e55Smrg      case " $deplibs" in
86908c4a8e55Smrg      *\ -l* | *\ -L*)
86913169be4bSmrg	func_warning "'-l' and '-L' are ignored for archives" ;;
86928c4a8e55Smrg      esac
86938c4a8e55Smrg
86948c4a8e55Smrg      test -n "$rpath" && \
86953169be4bSmrg	func_warning "'-rpath' is ignored for archives"
86968c4a8e55Smrg
86978c4a8e55Smrg      test -n "$xrpath" && \
86983169be4bSmrg	func_warning "'-R' is ignored for archives"
86998c4a8e55Smrg
87008c4a8e55Smrg      test -n "$vinfo" && \
87013169be4bSmrg	func_warning "'-version-info/-version-number' is ignored for archives"
87028c4a8e55Smrg
87038c4a8e55Smrg      test -n "$release" && \
87043169be4bSmrg	func_warning "'-release' is ignored for archives"
87058c4a8e55Smrg
87068c4a8e55Smrg      test -n "$export_symbols$export_symbols_regex" && \
87073169be4bSmrg	func_warning "'-export-symbols' is ignored for archives"
87088c4a8e55Smrg
87098c4a8e55Smrg      # Now set the variables for building old libraries.
87108c4a8e55Smrg      build_libtool_libs=no
87113169be4bSmrg      oldlibs=$output
8712bd23fbfaSmrg      func_append objs "$old_deplibs"
87138c4a8e55Smrg      ;;
87148c4a8e55Smrg
87158c4a8e55Smrg    lib)
87163169be4bSmrg      # Make sure we only generate libraries of the form 'libNAME.la'.
87178c4a8e55Smrg      case $outputname in
87188c4a8e55Smrg      lib*)
87198c4a8e55Smrg	func_stripname 'lib' '.la' "$outputname"
87208c4a8e55Smrg	name=$func_stripname_result
87218c4a8e55Smrg	eval shared_ext=\"$shrext_cmds\"
87228c4a8e55Smrg	eval libname=\"$libname_spec\"
87238c4a8e55Smrg	;;
87248c4a8e55Smrg      *)
87253169be4bSmrg	test no = "$module" \
87263169be4bSmrg	  && func_fatal_help "libtool library '$output' must begin with 'lib'"
87278c4a8e55Smrg
87283169be4bSmrg	if test no != "$need_lib_prefix"; then
87298c4a8e55Smrg	  # Add the "lib" prefix for modules if required
87308c4a8e55Smrg	  func_stripname '' '.la' "$outputname"
87318c4a8e55Smrg	  name=$func_stripname_result
87328c4a8e55Smrg	  eval shared_ext=\"$shrext_cmds\"
87338c4a8e55Smrg	  eval libname=\"$libname_spec\"
87348c4a8e55Smrg	else
87358c4a8e55Smrg	  func_stripname '' '.la' "$outputname"
87368c4a8e55Smrg	  libname=$func_stripname_result
87378c4a8e55Smrg	fi
87388c4a8e55Smrg	;;
87398c4a8e55Smrg      esac
87408c4a8e55Smrg
87418c4a8e55Smrg      if test -n "$objs"; then
87423169be4bSmrg	if test pass_all != "$deplibs_check_method"; then
87433169be4bSmrg	  func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs"
87448c4a8e55Smrg	else
8745706b6b52Smrg	  echo
87468c4a8e55Smrg	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
87478c4a8e55Smrg	  $ECHO "*** objects $objs is not portable!"
8748bd23fbfaSmrg	  func_append libobjs " $objs"
87498c4a8e55Smrg	fi
87508c4a8e55Smrg      fi
87518c4a8e55Smrg
87523169be4bSmrg      test no = "$dlself" \
87533169be4bSmrg	|| func_warning "'-dlopen self' is ignored for libtool libraries"
87548c4a8e55Smrg
87558c4a8e55Smrg      set dummy $rpath
87568c4a8e55Smrg      shift
87573169be4bSmrg      test 1 -lt "$#" \
87583169be4bSmrg	&& func_warning "ignoring multiple '-rpath's for a libtool library"
87598c4a8e55Smrg
87603169be4bSmrg      install_libdir=$1
87618c4a8e55Smrg
87628c4a8e55Smrg      oldlibs=
87638c4a8e55Smrg      if test -z "$rpath"; then
87643169be4bSmrg	if test yes = "$build_libtool_libs"; then
87658c4a8e55Smrg	  # Building a libtool convenience library.
87663169be4bSmrg	  # Some compilers have problems with a '.al' extension so
87678c4a8e55Smrg	  # convenience libraries should have the same extension an
87688c4a8e55Smrg	  # archive normally would.
87698c4a8e55Smrg	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
87708c4a8e55Smrg	  build_libtool_libs=convenience
87718c4a8e55Smrg	  build_old_libs=yes
87728c4a8e55Smrg	fi
87738c4a8e55Smrg
87748c4a8e55Smrg	test -n "$vinfo" && \
87753169be4bSmrg	  func_warning "'-version-info/-version-number' is ignored for convenience libraries"
87768c4a8e55Smrg
87778c4a8e55Smrg	test -n "$release" && \
87783169be4bSmrg	  func_warning "'-release' is ignored for convenience libraries"
87798c4a8e55Smrg      else
87808c4a8e55Smrg
87818c4a8e55Smrg	# Parse the version information argument.
87823169be4bSmrg	save_ifs=$IFS; IFS=:
87838c4a8e55Smrg	set dummy $vinfo 0 0 0
87848c4a8e55Smrg	shift
87853169be4bSmrg	IFS=$save_ifs
87868c4a8e55Smrg
87878c4a8e55Smrg	test -n "$7" && \
87883169be4bSmrg	  func_fatal_help "too many parameters to '-version-info'"
87898c4a8e55Smrg
87908c4a8e55Smrg	# convert absolute version numbers to libtool ages
87918c4a8e55Smrg	# this retains compatibility with .la files and attempts
87928c4a8e55Smrg	# to make the code below a bit more comprehensible
87938c4a8e55Smrg
87948c4a8e55Smrg	case $vinfo_number in
87958c4a8e55Smrg	yes)
87963169be4bSmrg	  number_major=$1
87973169be4bSmrg	  number_minor=$2
87983169be4bSmrg	  number_revision=$3
87998c4a8e55Smrg	  #
88008c4a8e55Smrg	  # There are really only two kinds -- those that
88018c4a8e55Smrg	  # use the current revision as the major version
88028c4a8e55Smrg	  # and those that subtract age and use age as
88038c4a8e55Smrg	  # a minor version.  But, then there is irix
88043169be4bSmrg	  # that has an extra 1 added just for fun
88058c4a8e55Smrg	  #
88068c4a8e55Smrg	  case $version_type in
88070597fb56Smrg	  # correct linux to gnu/linux during the next big refactor
88083169be4bSmrg	  darwin|freebsd-elf|linux|osf|windows|none)
88098c4a8e55Smrg	    func_arith $number_major + $number_minor
88108c4a8e55Smrg	    current=$func_arith_result
88113169be4bSmrg	    age=$number_minor
88123169be4bSmrg	    revision=$number_revision
88138c4a8e55Smrg	    ;;
88143169be4bSmrg	  freebsd-aout|qnx|sunos)
88153169be4bSmrg	    current=$number_major
88163169be4bSmrg	    revision=$number_minor
88173169be4bSmrg	    age=0
88188c4a8e55Smrg	    ;;
88198c4a8e55Smrg	  irix|nonstopux)
88208c4a8e55Smrg	    func_arith $number_major + $number_minor
88218c4a8e55Smrg	    current=$func_arith_result
88223169be4bSmrg	    age=$number_minor
88233169be4bSmrg	    revision=$number_minor
88248c4a8e55Smrg	    lt_irix_increment=no
88258c4a8e55Smrg	    ;;
88268c4a8e55Smrg	  esac
88278c4a8e55Smrg	  ;;
88288c4a8e55Smrg	no)
88293169be4bSmrg	  current=$1
88303169be4bSmrg	  revision=$2
88313169be4bSmrg	  age=$3
88328c4a8e55Smrg	  ;;
88338c4a8e55Smrg	esac
88348c4a8e55Smrg
88358c4a8e55Smrg	# Check that each of the things are valid numbers.
88368c4a8e55Smrg	case $current in
88378c4a8e55Smrg	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]) ;;
88388c4a8e55Smrg	*)
88393169be4bSmrg	  func_error "CURRENT '$current' must be a nonnegative integer"
88403169be4bSmrg	  func_fatal_error "'$vinfo' is not valid version information"
88418c4a8e55Smrg	  ;;
88428c4a8e55Smrg	esac
88438c4a8e55Smrg
88448c4a8e55Smrg	case $revision in
88458c4a8e55Smrg	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]) ;;
88468c4a8e55Smrg	*)
88473169be4bSmrg	  func_error "REVISION '$revision' must be a nonnegative integer"
88483169be4bSmrg	  func_fatal_error "'$vinfo' is not valid version information"
88498c4a8e55Smrg	  ;;
88508c4a8e55Smrg	esac
88518c4a8e55Smrg
88528c4a8e55Smrg	case $age in
88538c4a8e55Smrg	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]) ;;
88548c4a8e55Smrg	*)
88553169be4bSmrg	  func_error "AGE '$age' must be a nonnegative integer"
88563169be4bSmrg	  func_fatal_error "'$vinfo' is not valid version information"
88578c4a8e55Smrg	  ;;
88588c4a8e55Smrg	esac
88598c4a8e55Smrg
88608c4a8e55Smrg	if test "$age" -gt "$current"; then
88613169be4bSmrg	  func_error "AGE '$age' is greater than the current interface number '$current'"
88623169be4bSmrg	  func_fatal_error "'$vinfo' is not valid version information"
88638c4a8e55Smrg	fi
88648c4a8e55Smrg
88658c4a8e55Smrg	# Calculate the version variables.
88668c4a8e55Smrg	major=
88678c4a8e55Smrg	versuffix=
88688c4a8e55Smrg	verstring=
88698c4a8e55Smrg	case $version_type in
88708c4a8e55Smrg	none) ;;
88718c4a8e55Smrg
88728c4a8e55Smrg	darwin)
88738c4a8e55Smrg	  # Like Linux, but with the current version available in
88748c4a8e55Smrg	  # verstring for coding it into the library header
88758c4a8e55Smrg	  func_arith $current - $age
88768c4a8e55Smrg	  major=.$func_arith_result
88773169be4bSmrg	  versuffix=$major.$age.$revision
88788c4a8e55Smrg	  # Darwin ld doesn't like 0 for these options...
88798c4a8e55Smrg	  func_arith $current + 1
88808c4a8e55Smrg	  minor_current=$func_arith_result
88813169be4bSmrg	  xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
88828c4a8e55Smrg	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
88833169be4bSmrg          # On Darwin other compilers
88843169be4bSmrg          case $CC in
88853169be4bSmrg              nagfor*)
88863169be4bSmrg                  verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
88873169be4bSmrg                  ;;
88883169be4bSmrg              *)
88893169be4bSmrg                  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
88903169be4bSmrg                  ;;
88913169be4bSmrg          esac
88928c4a8e55Smrg	  ;;
88938c4a8e55Smrg
88948c4a8e55Smrg	freebsd-aout)
88953169be4bSmrg	  major=.$current
88963169be4bSmrg	  versuffix=.$current.$revision
88978c4a8e55Smrg	  ;;
88988c4a8e55Smrg
88998c4a8e55Smrg	freebsd-elf)
89003169be4bSmrg	  func_arith $current - $age
89013169be4bSmrg	  major=.$func_arith_result
89023169be4bSmrg	  versuffix=$major.$age.$revision
89038c4a8e55Smrg	  ;;
89048c4a8e55Smrg
89058c4a8e55Smrg	irix | nonstopux)
89063169be4bSmrg	  if test no = "$lt_irix_increment"; then
89078c4a8e55Smrg	    func_arith $current - $age
89088c4a8e55Smrg	  else
89098c4a8e55Smrg	    func_arith $current - $age + 1
89108c4a8e55Smrg	  fi
89118c4a8e55Smrg	  major=$func_arith_result
89128c4a8e55Smrg
89138c4a8e55Smrg	  case $version_type in
89148c4a8e55Smrg	    nonstopux) verstring_prefix=nonstopux ;;
89158c4a8e55Smrg	    *)         verstring_prefix=sgi ;;
89168c4a8e55Smrg	  esac
89173169be4bSmrg	  verstring=$verstring_prefix$major.$revision
89188c4a8e55Smrg
89198c4a8e55Smrg	  # Add in all the interfaces that we are compatible with.
89208c4a8e55Smrg	  loop=$revision
89213169be4bSmrg	  while test 0 -ne "$loop"; do
89228c4a8e55Smrg	    func_arith $revision - $loop
89238c4a8e55Smrg	    iface=$func_arith_result
89248c4a8e55Smrg	    func_arith $loop - 1
89258c4a8e55Smrg	    loop=$func_arith_result
89263169be4bSmrg	    verstring=$verstring_prefix$major.$iface:$verstring
89278c4a8e55Smrg	  done
89288c4a8e55Smrg
89293169be4bSmrg	  # Before this point, $major must not contain '.'.
89308c4a8e55Smrg	  major=.$major
89313169be4bSmrg	  versuffix=$major.$revision
89328c4a8e55Smrg	  ;;
89338c4a8e55Smrg
89340597fb56Smrg	linux) # correct to gnu/linux during the next big refactor
89358c4a8e55Smrg	  func_arith $current - $age
89368c4a8e55Smrg	  major=.$func_arith_result
89373169be4bSmrg	  versuffix=$major.$age.$revision
89388c4a8e55Smrg	  ;;
89398c4a8e55Smrg
89408c4a8e55Smrg	osf)
89418c4a8e55Smrg	  func_arith $current - $age
89428c4a8e55Smrg	  major=.$func_arith_result
89433169be4bSmrg	  versuffix=.$current.$age.$revision
89443169be4bSmrg	  verstring=$current.$age.$revision
89458c4a8e55Smrg
89468c4a8e55Smrg	  # Add in all the interfaces that we are compatible with.
89478c4a8e55Smrg	  loop=$age
89483169be4bSmrg	  while test 0 -ne "$loop"; do
89498c4a8e55Smrg	    func_arith $current - $loop
89508c4a8e55Smrg	    iface=$func_arith_result
89518c4a8e55Smrg	    func_arith $loop - 1
89528c4a8e55Smrg	    loop=$func_arith_result
89533169be4bSmrg	    verstring=$verstring:$iface.0
89548c4a8e55Smrg	  done
89558c4a8e55Smrg
89568c4a8e55Smrg	  # Make executables depend on our current version.
89573169be4bSmrg	  func_append verstring ":$current.0"
89588c4a8e55Smrg	  ;;
89598c4a8e55Smrg
89608c4a8e55Smrg	qnx)
89613169be4bSmrg	  major=.$current
89623169be4bSmrg	  versuffix=.$current
89633169be4bSmrg	  ;;
89643169be4bSmrg
89653169be4bSmrg	sco)
89663169be4bSmrg	  major=.$current
89673169be4bSmrg	  versuffix=.$current
89688c4a8e55Smrg	  ;;
89698c4a8e55Smrg
89708c4a8e55Smrg	sunos)
89713169be4bSmrg	  major=.$current
89723169be4bSmrg	  versuffix=.$current.$revision
89738c4a8e55Smrg	  ;;
89748c4a8e55Smrg
89758c4a8e55Smrg	windows)
89768c4a8e55Smrg	  # Use '-' rather than '.', since we only want one
89773169be4bSmrg	  # extension on DOS 8.3 file systems.
89788c4a8e55Smrg	  func_arith $current - $age
89798c4a8e55Smrg	  major=$func_arith_result
89803169be4bSmrg	  versuffix=-$major
89818c4a8e55Smrg	  ;;
89828c4a8e55Smrg
89838c4a8e55Smrg	*)
89843169be4bSmrg	  func_fatal_configuration "unknown library version type '$version_type'"
89858c4a8e55Smrg	  ;;
89868c4a8e55Smrg	esac
89878c4a8e55Smrg
89888c4a8e55Smrg	# Clear the version info if we defaulted, and they specified a release.
89898c4a8e55Smrg	if test -z "$vinfo" && test -n "$release"; then
89908c4a8e55Smrg	  major=
89918c4a8e55Smrg	  case $version_type in
89928c4a8e55Smrg	  darwin)
89938c4a8e55Smrg	    # we can't check for "0.0" in archive_cmds due to quoting
89948c4a8e55Smrg	    # problems, so we reset it completely
89958c4a8e55Smrg	    verstring=
89968c4a8e55Smrg	    ;;
89978c4a8e55Smrg	  *)
89983169be4bSmrg	    verstring=0.0
89998c4a8e55Smrg	    ;;
90008c4a8e55Smrg	  esac
90013169be4bSmrg	  if test no = "$need_version"; then
90028c4a8e55Smrg	    versuffix=
90038c4a8e55Smrg	  else
90043169be4bSmrg	    versuffix=.0.0
90058c4a8e55Smrg	  fi
90068c4a8e55Smrg	fi
90078c4a8e55Smrg
90088c4a8e55Smrg	# Remove version info from name if versioning should be avoided
90093169be4bSmrg	if test yes,no = "$avoid_version,$need_version"; then
90108c4a8e55Smrg	  major=
90118c4a8e55Smrg	  versuffix=
90123169be4bSmrg	  verstring=
90138c4a8e55Smrg	fi
90148c4a8e55Smrg
90158c4a8e55Smrg	# Check to see if the archive will have undefined symbols.
90163169be4bSmrg	if test yes = "$allow_undefined"; then
90173169be4bSmrg	  if test unsupported = "$allow_undefined_flag"; then
90183169be4bSmrg	    if test yes = "$build_old_libs"; then
90193169be4bSmrg	      func_warning "undefined symbols not allowed in $host shared libraries; building static only"
90203169be4bSmrg	      build_libtool_libs=no
90213169be4bSmrg	    else
90223169be4bSmrg	      func_fatal_error "can't build $host shared library unless -no-undefined is specified"
90233169be4bSmrg	    fi
90248c4a8e55Smrg	  fi
90258c4a8e55Smrg	else
90268c4a8e55Smrg	  # Don't allow undefined symbols.
90273169be4bSmrg	  allow_undefined_flag=$no_undefined_flag
90288c4a8e55Smrg	fi
90298c4a8e55Smrg
90308c4a8e55Smrg      fi
90318c4a8e55Smrg
90323169be4bSmrg      func_generate_dlsyms "$libname" "$libname" :
9033bd23fbfaSmrg      func_append libobjs " $symfileobj"
90343169be4bSmrg      test " " = "$libobjs" && libobjs=
90358c4a8e55Smrg
90363169be4bSmrg      if test relink != "$opt_mode"; then
90378c4a8e55Smrg	# Remove our outputs, but don't remove object files since they
90388c4a8e55Smrg	# may have been created when compiling PIC objects.
90398c4a8e55Smrg	removelist=
90408c4a8e55Smrg	tempremovelist=`$ECHO "$output_objdir/*"`
90418c4a8e55Smrg	for p in $tempremovelist; do
90428c4a8e55Smrg	  case $p in
90438c4a8e55Smrg	    *.$objext | *.gcno)
90448c4a8e55Smrg	       ;;
90453169be4bSmrg	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*)
90463169be4bSmrg	       if test -n "$precious_files_regex"; then
90478c4a8e55Smrg		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
90488c4a8e55Smrg		 then
90498c4a8e55Smrg		   continue
90508c4a8e55Smrg		 fi
90518c4a8e55Smrg	       fi
9052bd23fbfaSmrg	       func_append removelist " $p"
90538c4a8e55Smrg	       ;;
90548c4a8e55Smrg	    *) ;;
90558c4a8e55Smrg	  esac
90568c4a8e55Smrg	done
90578c4a8e55Smrg	test -n "$removelist" && \
90588c4a8e55Smrg	  func_show_eval "${RM}r \$removelist"
90598c4a8e55Smrg      fi
90608c4a8e55Smrg
90618c4a8e55Smrg      # Now set the variables for building old libraries.
90623169be4bSmrg      if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then
9063bd23fbfaSmrg	func_append oldlibs " $output_objdir/$libname.$libext"
90648c4a8e55Smrg
90658c4a8e55Smrg	# Transform .lo files to .o files.
90663169be4bSmrg	oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP`
90678c4a8e55Smrg      fi
90688c4a8e55Smrg
90698c4a8e55Smrg      # Eliminate all temporary directories.
90708c4a8e55Smrg      #for path in $notinst_path; do
9071706b6b52Smrg      #	lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
9072706b6b52Smrg      #	deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
9073706b6b52Smrg      #	dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
90748c4a8e55Smrg      #done
90758c4a8e55Smrg
90768c4a8e55Smrg      if test -n "$xrpath"; then
90778c4a8e55Smrg	# If the user specified any rpath flags, then add them.
90788c4a8e55Smrg	temp_xrpath=
90798c4a8e55Smrg	for libdir in $xrpath; do
9080bd23fbfaSmrg	  func_replace_sysroot "$libdir"
9081bd23fbfaSmrg	  func_append temp_xrpath " -R$func_replace_sysroot_result"
90828c4a8e55Smrg	  case "$finalize_rpath " in
90838c4a8e55Smrg	  *" $libdir "*) ;;
9084bd23fbfaSmrg	  *) func_append finalize_rpath " $libdir" ;;
90858c4a8e55Smrg	  esac
90868c4a8e55Smrg	done
90873169be4bSmrg	if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then
90888c4a8e55Smrg	  dependency_libs="$temp_xrpath $dependency_libs"
90898c4a8e55Smrg	fi
90908c4a8e55Smrg      fi
90918c4a8e55Smrg
90928c4a8e55Smrg      # Make sure dlfiles contains only unique files that won't be dlpreopened
90933169be4bSmrg      old_dlfiles=$dlfiles
90948c4a8e55Smrg      dlfiles=
90958c4a8e55Smrg      for lib in $old_dlfiles; do
90968c4a8e55Smrg	case " $dlprefiles $dlfiles " in
90978c4a8e55Smrg	*" $lib "*) ;;
9098bd23fbfaSmrg	*) func_append dlfiles " $lib" ;;
90998c4a8e55Smrg	esac
91008c4a8e55Smrg      done
91018c4a8e55Smrg
91028c4a8e55Smrg      # Make sure dlprefiles contains only unique files
91033169be4bSmrg      old_dlprefiles=$dlprefiles
91048c4a8e55Smrg      dlprefiles=
91058c4a8e55Smrg      for lib in $old_dlprefiles; do
91068c4a8e55Smrg	case "$dlprefiles " in
91078c4a8e55Smrg	*" $lib "*) ;;
9108bd23fbfaSmrg	*) func_append dlprefiles " $lib" ;;
91098c4a8e55Smrg	esac
91108c4a8e55Smrg      done
91118c4a8e55Smrg
91123169be4bSmrg      if test yes = "$build_libtool_libs"; then
91138c4a8e55Smrg	if test -n "$rpath"; then
91148c4a8e55Smrg	  case $host in
9115706b6b52Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
91168c4a8e55Smrg	    # these systems don't actually have a c library (as such)!
91178c4a8e55Smrg	    ;;
91188c4a8e55Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
91198c4a8e55Smrg	    # Rhapsody C library is in the System framework
9120bd23fbfaSmrg	    func_append deplibs " System.ltframework"
91218c4a8e55Smrg	    ;;
91228c4a8e55Smrg	  *-*-netbsd*)
91238c4a8e55Smrg	    # Don't link with libc until the a.out ld.so is fixed.
91248c4a8e55Smrg	    ;;
91258c4a8e55Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
91268c4a8e55Smrg	    # Do not include libc due to us having libc/libc_r.
91278c4a8e55Smrg	    ;;
91288c4a8e55Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
91298c4a8e55Smrg	    # Causes problems with __ctype
91308c4a8e55Smrg	    ;;
91318c4a8e55Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
91328c4a8e55Smrg	    # Compiler inserts libc in the correct place for threads to work
91338c4a8e55Smrg	    ;;
91348c4a8e55Smrg	  *)
91358c4a8e55Smrg	    # Add libc to deplibs on all other systems if necessary.
91363169be4bSmrg	    if test yes = "$build_libtool_need_lc"; then
9137bd23fbfaSmrg	      func_append deplibs " -lc"
91388c4a8e55Smrg	    fi
91398c4a8e55Smrg	    ;;
91408c4a8e55Smrg	  esac
91418c4a8e55Smrg	fi
91428c4a8e55Smrg
91438c4a8e55Smrg	# Transform deplibs into only deplibs that can be linked in shared.
91448c4a8e55Smrg	name_save=$name
91458c4a8e55Smrg	libname_save=$libname
91468c4a8e55Smrg	release_save=$release
91478c4a8e55Smrg	versuffix_save=$versuffix
91488c4a8e55Smrg	major_save=$major
91498c4a8e55Smrg	# I'm not sure if I'm treating the release correctly.  I think
91508c4a8e55Smrg	# release should show up in the -l (ie -lgmp5) so we don't want to
91518c4a8e55Smrg	# add it in twice.  Is that correct?
91523169be4bSmrg	release=
91533169be4bSmrg	versuffix=
91543169be4bSmrg	major=
91558c4a8e55Smrg	newdeplibs=
91568c4a8e55Smrg	droppeddeps=no
91578c4a8e55Smrg	case $deplibs_check_method in
91588c4a8e55Smrg	pass_all)
91598c4a8e55Smrg	  # Don't check for shared/static.  Everything works.
91608c4a8e55Smrg	  # This might be a little naive.  We might want to check
91618c4a8e55Smrg	  # whether the library exists or not.  But this is on
91628c4a8e55Smrg	  # osf3 & osf4 and I'm not really sure... Just
91638c4a8e55Smrg	  # implementing what was already the behavior.
91648c4a8e55Smrg	  newdeplibs=$deplibs
91658c4a8e55Smrg	  ;;
91668c4a8e55Smrg	test_compile)
91678c4a8e55Smrg	  # This code stresses the "libraries are programs" paradigm to its
91688c4a8e55Smrg	  # limits. Maybe even breaks it.  We compile a program, linking it
91698c4a8e55Smrg	  # against the deplibs as a proxy for the library.  Then we can check
91708c4a8e55Smrg	  # whether they linked in statically or dynamically with ldd.
91718c4a8e55Smrg	  $opt_dry_run || $RM conftest.c
91728c4a8e55Smrg	  cat > conftest.c <<EOF
91738c4a8e55Smrg	  int main() { return 0; }
91748c4a8e55SmrgEOF
91758c4a8e55Smrg	  $opt_dry_run || $RM conftest
91768c4a8e55Smrg	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
91778c4a8e55Smrg	    ldd_output=`ldd conftest`
91788c4a8e55Smrg	    for i in $deplibs; do
91798c4a8e55Smrg	      case $i in
91808c4a8e55Smrg	      -l*)
91818c4a8e55Smrg		func_stripname -l '' "$i"
91828c4a8e55Smrg		name=$func_stripname_result
91833169be4bSmrg		if test yes = "$allow_libtool_libs_with_static_runtimes"; then
91848c4a8e55Smrg		  case " $predeps $postdeps " in
91858c4a8e55Smrg		  *" $i "*)
9186bd23fbfaSmrg		    func_append newdeplibs " $i"
91873169be4bSmrg		    i=
91888c4a8e55Smrg		    ;;
91898c4a8e55Smrg		  esac
91908c4a8e55Smrg		fi
91913169be4bSmrg		if test -n "$i"; then
91928c4a8e55Smrg		  libname=`eval "\\$ECHO \"$libname_spec\""`
91938c4a8e55Smrg		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
91948c4a8e55Smrg		  set dummy $deplib_matches; shift
91958c4a8e55Smrg		  deplib_match=$1
91963169be4bSmrg		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
9197bd23fbfaSmrg		    func_append newdeplibs " $i"
91988c4a8e55Smrg		  else
91998c4a8e55Smrg		    droppeddeps=yes
9200706b6b52Smrg		    echo
92018c4a8e55Smrg		    $ECHO "*** Warning: dynamic linker does not accept needed library $i."
9202706b6b52Smrg		    echo "*** I have the capability to make that library automatically link in when"
9203706b6b52Smrg		    echo "*** you link to this library.  But I can only do this if you have a"
9204706b6b52Smrg		    echo "*** shared version of the library, which I believe you do not have"
9205706b6b52Smrg		    echo "*** because a test_compile did reveal that the linker did not use it for"
9206706b6b52Smrg		    echo "*** its dynamic dependency list that programs get resolved with at runtime."
92078c4a8e55Smrg		  fi
92088c4a8e55Smrg		fi
92098c4a8e55Smrg		;;
92108c4a8e55Smrg	      *)
9211bd23fbfaSmrg		func_append newdeplibs " $i"
92128c4a8e55Smrg		;;
92138c4a8e55Smrg	      esac
92148c4a8e55Smrg	    done
92158c4a8e55Smrg	  else
92168c4a8e55Smrg	    # Error occurred in the first compile.  Let's try to salvage
92178c4a8e55Smrg	    # the situation: Compile a separate program for each library.
92188c4a8e55Smrg	    for i in $deplibs; do
92198c4a8e55Smrg	      case $i in
92208c4a8e55Smrg	      -l*)
92218c4a8e55Smrg		func_stripname -l '' "$i"
92228c4a8e55Smrg		name=$func_stripname_result
92238c4a8e55Smrg		$opt_dry_run || $RM conftest
92248c4a8e55Smrg		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
92258c4a8e55Smrg		  ldd_output=`ldd conftest`
92263169be4bSmrg		  if test yes = "$allow_libtool_libs_with_static_runtimes"; then
92278c4a8e55Smrg		    case " $predeps $postdeps " in
92288c4a8e55Smrg		    *" $i "*)
9229bd23fbfaSmrg		      func_append newdeplibs " $i"
92303169be4bSmrg		      i=
92318c4a8e55Smrg		      ;;
92328c4a8e55Smrg		    esac
92338c4a8e55Smrg		  fi
92343169be4bSmrg		  if test -n "$i"; then
92358c4a8e55Smrg		    libname=`eval "\\$ECHO \"$libname_spec\""`
92368c4a8e55Smrg		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
92378c4a8e55Smrg		    set dummy $deplib_matches; shift
92388c4a8e55Smrg		    deplib_match=$1
92393169be4bSmrg		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
9240bd23fbfaSmrg		      func_append newdeplibs " $i"
92418c4a8e55Smrg		    else
92428c4a8e55Smrg		      droppeddeps=yes
9243706b6b52Smrg		      echo
92448c4a8e55Smrg		      $ECHO "*** Warning: dynamic linker does not accept needed library $i."
9245706b6b52Smrg		      echo "*** I have the capability to make that library automatically link in when"
9246706b6b52Smrg		      echo "*** you link to this library.  But I can only do this if you have a"
9247706b6b52Smrg		      echo "*** shared version of the library, which you do not appear to have"
9248706b6b52Smrg		      echo "*** because a test_compile did reveal that the linker did not use this one"
9249706b6b52Smrg		      echo "*** as a dynamic dependency that programs can get resolved with at runtime."
92508c4a8e55Smrg		    fi
92518c4a8e55Smrg		  fi
92528c4a8e55Smrg		else
92538c4a8e55Smrg		  droppeddeps=yes
9254706b6b52Smrg		  echo
92558c4a8e55Smrg		  $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
9256706b6b52Smrg		  echo "*** make it link in!  You will probably need to install it or some"
9257706b6b52Smrg		  echo "*** library that it depends on before this library will be fully"
9258706b6b52Smrg		  echo "*** functional.  Installing it before continuing would be even better."
92598c4a8e55Smrg		fi
92608c4a8e55Smrg		;;
92618c4a8e55Smrg	      *)
9262bd23fbfaSmrg		func_append newdeplibs " $i"
92638c4a8e55Smrg		;;
92648c4a8e55Smrg	      esac
92658c4a8e55Smrg	    done
92668c4a8e55Smrg	  fi
92678c4a8e55Smrg	  ;;
92688c4a8e55Smrg	file_magic*)
92698c4a8e55Smrg	  set dummy $deplibs_check_method; shift
92708c4a8e55Smrg	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
92718c4a8e55Smrg	  for a_deplib in $deplibs; do
92728c4a8e55Smrg	    case $a_deplib in
92738c4a8e55Smrg	    -l*)
92748c4a8e55Smrg	      func_stripname -l '' "$a_deplib"
92758c4a8e55Smrg	      name=$func_stripname_result
92763169be4bSmrg	      if test yes = "$allow_libtool_libs_with_static_runtimes"; then
92778c4a8e55Smrg		case " $predeps $postdeps " in
92788c4a8e55Smrg		*" $a_deplib "*)
9279bd23fbfaSmrg		  func_append newdeplibs " $a_deplib"
92803169be4bSmrg		  a_deplib=
92818c4a8e55Smrg		  ;;
92828c4a8e55Smrg		esac
92838c4a8e55Smrg	      fi
92843169be4bSmrg	      if test -n "$a_deplib"; then
92858c4a8e55Smrg		libname=`eval "\\$ECHO \"$libname_spec\""`
9286bd23fbfaSmrg		if test -n "$file_magic_glob"; then
9287bd23fbfaSmrg		  libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
9288bd23fbfaSmrg		else
9289bd23fbfaSmrg		  libnameglob=$libname
9290bd23fbfaSmrg		fi
92913169be4bSmrg		test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob`
92928c4a8e55Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
92933169be4bSmrg		  if test yes = "$want_nocaseglob"; then
9294bd23fbfaSmrg		    shopt -s nocaseglob
9295bd23fbfaSmrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
9296bd23fbfaSmrg		    $nocaseglob
9297bd23fbfaSmrg		  else
9298bd23fbfaSmrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
9299bd23fbfaSmrg		  fi
93008c4a8e55Smrg		  for potent_lib in $potential_libs; do
93018c4a8e55Smrg		      # Follow soft links.
93028c4a8e55Smrg		      if ls -lLd "$potent_lib" 2>/dev/null |
93038c4a8e55Smrg			 $GREP " -> " >/dev/null; then
93048c4a8e55Smrg			continue
93058c4a8e55Smrg		      fi
93068c4a8e55Smrg		      # The statement above tries to avoid entering an
93078c4a8e55Smrg		      # endless loop below, in case of cyclic links.
93088c4a8e55Smrg		      # We might still enter an endless loop, since a link
93098c4a8e55Smrg		      # loop can be closed while we follow links,
93108c4a8e55Smrg		      # but so what?
93113169be4bSmrg		      potlib=$potent_lib
93128c4a8e55Smrg		      while test -h "$potlib" 2>/dev/null; do
93133169be4bSmrg			potliblink=`ls -ld $potlib | $SED 's/.* -> //'`
93148c4a8e55Smrg			case $potliblink in
93153169be4bSmrg			[\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;;
93163169be4bSmrg			*) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";;
93178c4a8e55Smrg			esac
93188c4a8e55Smrg		      done
93198c4a8e55Smrg		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
93208c4a8e55Smrg			 $SED -e 10q |
93218c4a8e55Smrg			 $EGREP "$file_magic_regex" > /dev/null; then
9322bd23fbfaSmrg			func_append newdeplibs " $a_deplib"
93233169be4bSmrg			a_deplib=
93248c4a8e55Smrg			break 2
93258c4a8e55Smrg		      fi
93268c4a8e55Smrg		  done
93278c4a8e55Smrg		done
93288c4a8e55Smrg	      fi
93293169be4bSmrg	      if test -n "$a_deplib"; then
93308c4a8e55Smrg		droppeddeps=yes
9331706b6b52Smrg		echo
93328c4a8e55Smrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
9333706b6b52Smrg		echo "*** I have the capability to make that library automatically link in when"
9334706b6b52Smrg		echo "*** you link to this library.  But I can only do this if you have a"
9335706b6b52Smrg		echo "*** shared version of the library, which you do not appear to have"
9336706b6b52Smrg		echo "*** because I did check the linker path looking for a file starting"
93373169be4bSmrg		if test -z "$potlib"; then
93388c4a8e55Smrg		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
93398c4a8e55Smrg		else
93408c4a8e55Smrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
93418c4a8e55Smrg		  $ECHO "*** using a file magic. Last file checked: $potlib"
93428c4a8e55Smrg		fi
93438c4a8e55Smrg	      fi
93448c4a8e55Smrg	      ;;
93458c4a8e55Smrg	    *)
93468c4a8e55Smrg	      # Add a -L argument.
9347bd23fbfaSmrg	      func_append newdeplibs " $a_deplib"
93488c4a8e55Smrg	      ;;
93498c4a8e55Smrg	    esac
93508c4a8e55Smrg	  done # Gone through all deplibs.
93518c4a8e55Smrg	  ;;
93528c4a8e55Smrg	match_pattern*)
93538c4a8e55Smrg	  set dummy $deplibs_check_method; shift
93548c4a8e55Smrg	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
93558c4a8e55Smrg	  for a_deplib in $deplibs; do
93568c4a8e55Smrg	    case $a_deplib in
93578c4a8e55Smrg	    -l*)
93588c4a8e55Smrg	      func_stripname -l '' "$a_deplib"
93598c4a8e55Smrg	      name=$func_stripname_result
93603169be4bSmrg	      if test yes = "$allow_libtool_libs_with_static_runtimes"; then
93618c4a8e55Smrg		case " $predeps $postdeps " in
93628c4a8e55Smrg		*" $a_deplib "*)
9363bd23fbfaSmrg		  func_append newdeplibs " $a_deplib"
93643169be4bSmrg		  a_deplib=
93658c4a8e55Smrg		  ;;
93668c4a8e55Smrg		esac
93678c4a8e55Smrg	      fi
93683169be4bSmrg	      if test -n "$a_deplib"; then
93698c4a8e55Smrg		libname=`eval "\\$ECHO \"$libname_spec\""`
93708c4a8e55Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
93718c4a8e55Smrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
93728c4a8e55Smrg		  for potent_lib in $potential_libs; do
93733169be4bSmrg		    potlib=$potent_lib # see symlink-check above in file_magic test
9374706b6b52Smrg		    if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
93758c4a8e55Smrg		       $EGREP "$match_pattern_regex" > /dev/null; then
9376bd23fbfaSmrg		      func_append newdeplibs " $a_deplib"
93773169be4bSmrg		      a_deplib=
93788c4a8e55Smrg		      break 2
93798c4a8e55Smrg		    fi
93808c4a8e55Smrg		  done
93818c4a8e55Smrg		done
93828c4a8e55Smrg	      fi
93833169be4bSmrg	      if test -n "$a_deplib"; then
93848c4a8e55Smrg		droppeddeps=yes
9385706b6b52Smrg		echo
93868c4a8e55Smrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
9387706b6b52Smrg		echo "*** I have the capability to make that library automatically link in when"
9388706b6b52Smrg		echo "*** you link to this library.  But I can only do this if you have a"
9389706b6b52Smrg		echo "*** shared version of the library, which you do not appear to have"
9390706b6b52Smrg		echo "*** because I did check the linker path looking for a file starting"
93913169be4bSmrg		if test -z "$potlib"; then
93928c4a8e55Smrg		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
93938c4a8e55Smrg		else
93948c4a8e55Smrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
93958c4a8e55Smrg		  $ECHO "*** using a regex pattern. Last file checked: $potlib"
93968c4a8e55Smrg		fi
93978c4a8e55Smrg	      fi
93988c4a8e55Smrg	      ;;
93998c4a8e55Smrg	    *)
94008c4a8e55Smrg	      # Add a -L argument.
9401bd23fbfaSmrg	      func_append newdeplibs " $a_deplib"
94028c4a8e55Smrg	      ;;
94038c4a8e55Smrg	    esac
94048c4a8e55Smrg	  done # Gone through all deplibs.
94058c4a8e55Smrg	  ;;
94068c4a8e55Smrg	none | unknown | *)
94073169be4bSmrg	  newdeplibs=
9408706b6b52Smrg	  tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
94093169be4bSmrg	  if test yes = "$allow_libtool_libs_with_static_runtimes"; then
94103169be4bSmrg	    for i in $predeps $postdeps; do
94118c4a8e55Smrg	      # can't use Xsed below, because $i might contain '/'
94123169be4bSmrg	      tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"`
94138c4a8e55Smrg	    done
94148c4a8e55Smrg	  fi
9415706b6b52Smrg	  case $tmp_deplibs in
9416706b6b52Smrg	  *[!\	\ ]*)
9417706b6b52Smrg	    echo
94183169be4bSmrg	    if test none = "$deplibs_check_method"; then
9419706b6b52Smrg	      echo "*** Warning: inter-library dependencies are not supported in this platform."
94208c4a8e55Smrg	    else
9421706b6b52Smrg	      echo "*** Warning: inter-library dependencies are not known to be supported."
94228c4a8e55Smrg	    fi
9423706b6b52Smrg	    echo "*** All declared inter-library dependencies are being dropped."
94248c4a8e55Smrg	    droppeddeps=yes
9425706b6b52Smrg	    ;;
9426706b6b52Smrg	  esac
94278c4a8e55Smrg	  ;;
94288c4a8e55Smrg	esac
94298c4a8e55Smrg	versuffix=$versuffix_save
94308c4a8e55Smrg	major=$major_save
94318c4a8e55Smrg	release=$release_save
94328c4a8e55Smrg	libname=$libname_save
94338c4a8e55Smrg	name=$name_save
94348c4a8e55Smrg
94358c4a8e55Smrg	case $host in
94368c4a8e55Smrg	*-*-rhapsody* | *-*-darwin1.[012])
94378c4a8e55Smrg	  # On Rhapsody replace the C library with the System framework
9438706b6b52Smrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
94398c4a8e55Smrg	  ;;
94408c4a8e55Smrg	esac
94418c4a8e55Smrg
94423169be4bSmrg	if test yes = "$droppeddeps"; then
94433169be4bSmrg	  if test yes = "$module"; then
9444706b6b52Smrg	    echo
9445706b6b52Smrg	    echo "*** Warning: libtool could not satisfy all declared inter-library"
94468c4a8e55Smrg	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
9447706b6b52Smrg	    echo "*** a static module, that should work as long as the dlopening"
9448706b6b52Smrg	    echo "*** application is linked with the -dlopen flag."
94498c4a8e55Smrg	    if test -z "$global_symbol_pipe"; then
9450706b6b52Smrg	      echo
9451706b6b52Smrg	      echo "*** However, this would only work if libtool was able to extract symbol"
94523169be4bSmrg	      echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
9453706b6b52Smrg	      echo "*** not find such a program.  So, this module is probably useless."
94543169be4bSmrg	      echo "*** 'nm' from GNU binutils and a full rebuild may help."
94558c4a8e55Smrg	    fi
94563169be4bSmrg	    if test no = "$build_old_libs"; then
94573169be4bSmrg	      oldlibs=$output_objdir/$libname.$libext
94588c4a8e55Smrg	      build_libtool_libs=module
94598c4a8e55Smrg	      build_old_libs=yes
94608c4a8e55Smrg	    else
94618c4a8e55Smrg	      build_libtool_libs=no
94628c4a8e55Smrg	    fi
94638c4a8e55Smrg	  else
9464706b6b52Smrg	    echo "*** The inter-library dependencies that have been dropped here will be"
9465706b6b52Smrg	    echo "*** automatically added whenever a program is linked with this library"
9466706b6b52Smrg	    echo "*** or is declared to -dlopen it."
94678c4a8e55Smrg
94683169be4bSmrg	    if test no = "$allow_undefined"; then
9469706b6b52Smrg	      echo
9470706b6b52Smrg	      echo "*** Since this library must not contain undefined symbols,"
9471706b6b52Smrg	      echo "*** because either the platform does not support them or"
9472706b6b52Smrg	      echo "*** it was explicitly requested with -no-undefined,"
9473706b6b52Smrg	      echo "*** libtool will only create a static version of it."
94743169be4bSmrg	      if test no = "$build_old_libs"; then
94753169be4bSmrg		oldlibs=$output_objdir/$libname.$libext
94768c4a8e55Smrg		build_libtool_libs=module
94778c4a8e55Smrg		build_old_libs=yes
94788c4a8e55Smrg	      else
94798c4a8e55Smrg		build_libtool_libs=no
94808c4a8e55Smrg	      fi
94818c4a8e55Smrg	    fi
94828c4a8e55Smrg	  fi
94838c4a8e55Smrg	fi
94848c4a8e55Smrg	# Done checking deplibs!
94858c4a8e55Smrg	deplibs=$newdeplibs
94868c4a8e55Smrg      fi
94878c4a8e55Smrg      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
94888c4a8e55Smrg      case $host in
94898c4a8e55Smrg	*-*-darwin*)
9490706b6b52Smrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
9491706b6b52Smrg	  new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
9492706b6b52Smrg	  deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
94938c4a8e55Smrg	  ;;
94948c4a8e55Smrg      esac
94958c4a8e55Smrg
94968c4a8e55Smrg      # move library search paths that coincide with paths to not yet
94978c4a8e55Smrg      # installed libraries to the beginning of the library search list
94988c4a8e55Smrg      new_libs=
94998c4a8e55Smrg      for path in $notinst_path; do
95008c4a8e55Smrg	case " $new_libs " in
95018c4a8e55Smrg	*" -L$path/$objdir "*) ;;
95028c4a8e55Smrg	*)
95038c4a8e55Smrg	  case " $deplibs " in
95048c4a8e55Smrg	  *" -L$path/$objdir "*)
9505bd23fbfaSmrg	    func_append new_libs " -L$path/$objdir" ;;
95068c4a8e55Smrg	  esac
95078c4a8e55Smrg	  ;;
95088c4a8e55Smrg	esac
95098c4a8e55Smrg      done
95108c4a8e55Smrg      for deplib in $deplibs; do
95118c4a8e55Smrg	case $deplib in
95128c4a8e55Smrg	-L*)
95138c4a8e55Smrg	  case " $new_libs " in
95148c4a8e55Smrg	  *" $deplib "*) ;;
9515bd23fbfaSmrg	  *) func_append new_libs " $deplib" ;;
95168c4a8e55Smrg	  esac
95178c4a8e55Smrg	  ;;
9518bd23fbfaSmrg	*) func_append new_libs " $deplib" ;;
95198c4a8e55Smrg	esac
95208c4a8e55Smrg      done
95213169be4bSmrg      deplibs=$new_libs
95228c4a8e55Smrg
95238c4a8e55Smrg      # All the library-specific variables (install_libdir is set above).
95248c4a8e55Smrg      library_names=
95258c4a8e55Smrg      old_library=
95268c4a8e55Smrg      dlname=
95278c4a8e55Smrg
95288c4a8e55Smrg      # Test again, we may have decided not to build it any more
95293169be4bSmrg      if test yes = "$build_libtool_libs"; then
95303169be4bSmrg	# Remove $wl instances when linking with ld.
95310597fb56Smrg	# FIXME: should test the right _cmds variable.
95320597fb56Smrg	case $archive_cmds in
95330597fb56Smrg	  *\$LD\ *) wl= ;;
95340597fb56Smrg        esac
95353169be4bSmrg	if test yes = "$hardcode_into_libs"; then
95368c4a8e55Smrg	  # Hardcode the library paths
95378c4a8e55Smrg	  hardcode_libdirs=
95388c4a8e55Smrg	  dep_rpath=
95393169be4bSmrg	  rpath=$finalize_rpath
95403169be4bSmrg	  test relink = "$opt_mode" || rpath=$compile_rpath$rpath
95418c4a8e55Smrg	  for libdir in $rpath; do
95428c4a8e55Smrg	    if test -n "$hardcode_libdir_flag_spec"; then
95438c4a8e55Smrg	      if test -n "$hardcode_libdir_separator"; then
9544bd23fbfaSmrg		func_replace_sysroot "$libdir"
9545bd23fbfaSmrg		libdir=$func_replace_sysroot_result
95468c4a8e55Smrg		if test -z "$hardcode_libdirs"; then
95473169be4bSmrg		  hardcode_libdirs=$libdir
95488c4a8e55Smrg		else
95498c4a8e55Smrg		  # Just accumulate the unique libdirs.
95508c4a8e55Smrg		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
95518c4a8e55Smrg		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
95528c4a8e55Smrg		    ;;
95538c4a8e55Smrg		  *)
9554bd23fbfaSmrg		    func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
95558c4a8e55Smrg		    ;;
95568c4a8e55Smrg		  esac
95578c4a8e55Smrg		fi
95588c4a8e55Smrg	      else
95598c4a8e55Smrg		eval flag=\"$hardcode_libdir_flag_spec\"
9560bd23fbfaSmrg		func_append dep_rpath " $flag"
95618c4a8e55Smrg	      fi
95628c4a8e55Smrg	    elif test -n "$runpath_var"; then
95638c4a8e55Smrg	      case "$perm_rpath " in
95648c4a8e55Smrg	      *" $libdir "*) ;;
95650597fb56Smrg	      *) func_append perm_rpath " $libdir" ;;
95668c4a8e55Smrg	      esac
95678c4a8e55Smrg	    fi
95688c4a8e55Smrg	  done
95698c4a8e55Smrg	  # Substitute the hardcoded libdirs into the rpath.
95708c4a8e55Smrg	  if test -n "$hardcode_libdir_separator" &&
95718c4a8e55Smrg	     test -n "$hardcode_libdirs"; then
95723169be4bSmrg	    libdir=$hardcode_libdirs
95730597fb56Smrg	    eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
95748c4a8e55Smrg	  fi
95758c4a8e55Smrg	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
95768c4a8e55Smrg	    # We should set the runpath_var.
95778c4a8e55Smrg	    rpath=
95788c4a8e55Smrg	    for dir in $perm_rpath; do
9579bd23fbfaSmrg	      func_append rpath "$dir:"
95808c4a8e55Smrg	    done
95818c4a8e55Smrg	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
95828c4a8e55Smrg	  fi
95838c4a8e55Smrg	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
95848c4a8e55Smrg	fi
9585b042e37fSmrg
95863169be4bSmrg	shlibpath=$finalize_shlibpath
95873169be4bSmrg	test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath
95888c4a8e55Smrg	if test -n "$shlibpath"; then
95898c4a8e55Smrg	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
95908c4a8e55Smrg	fi
9591b042e37fSmrg
95928c4a8e55Smrg	# Get the real and link names of the library.
95938c4a8e55Smrg	eval shared_ext=\"$shrext_cmds\"
95948c4a8e55Smrg	eval library_names=\"$library_names_spec\"
95958c4a8e55Smrg	set dummy $library_names
95968c4a8e55Smrg	shift
95973169be4bSmrg	realname=$1
95988c4a8e55Smrg	shift
9599b042e37fSmrg
96008c4a8e55Smrg	if test -n "$soname_spec"; then
96018c4a8e55Smrg	  eval soname=\"$soname_spec\"
96028c4a8e55Smrg	else
96033169be4bSmrg	  soname=$realname
96048c4a8e55Smrg	fi
96058c4a8e55Smrg	if test -z "$dlname"; then
96068c4a8e55Smrg	  dlname=$soname
96078c4a8e55Smrg	fi
9608b042e37fSmrg
96093169be4bSmrg	lib=$output_objdir/$realname
96108c4a8e55Smrg	linknames=
96118c4a8e55Smrg	for link
96128c4a8e55Smrg	do
9613bd23fbfaSmrg	  func_append linknames " $link"
96148c4a8e55Smrg	done
9615b042e37fSmrg
96168c4a8e55Smrg	# Use standard objects if they are pic
9617706b6b52Smrg	test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
96188c4a8e55Smrg	test "X$libobjs" = "X " && libobjs=
9619b042e37fSmrg
96208c4a8e55Smrg	delfiles=
96218c4a8e55Smrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
96228c4a8e55Smrg	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
96233169be4bSmrg	  export_symbols=$output_objdir/$libname.uexp
9624bd23fbfaSmrg	  func_append delfiles " $export_symbols"
96258c4a8e55Smrg	fi
9626b042e37fSmrg
96278c4a8e55Smrg	orig_export_symbols=
96288c4a8e55Smrg	case $host_os in
96298c4a8e55Smrg	cygwin* | mingw* | cegcc*)
96308c4a8e55Smrg	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
96318c4a8e55Smrg	    # exporting using user supplied symfile
96323169be4bSmrg	    func_dll_def_p "$export_symbols" || {
96338c4a8e55Smrg	      # and it's NOT already a .def file. Must figure out
96348c4a8e55Smrg	      # which of the given symbols are data symbols and tag
96358c4a8e55Smrg	      # them as such. So, trigger use of export_symbols_cmds.
96368c4a8e55Smrg	      # export_symbols gets reassigned inside the "prepare
96378c4a8e55Smrg	      # the list of exported symbols" if statement, so the
96388c4a8e55Smrg	      # include_expsyms logic still works.
96393169be4bSmrg	      orig_export_symbols=$export_symbols
96408c4a8e55Smrg	      export_symbols=
96418c4a8e55Smrg	      always_export_symbols=yes
96423169be4bSmrg	    }
96438c4a8e55Smrg	  fi
96448c4a8e55Smrg	  ;;
96458c4a8e55Smrg	esac
9646b042e37fSmrg
96478c4a8e55Smrg	# Prepare the list of exported symbols
96488c4a8e55Smrg	if test -z "$export_symbols"; then
96493169be4bSmrg	  if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then
96503169be4bSmrg	    func_verbose "generating symbol list for '$libname.la'"
96513169be4bSmrg	    export_symbols=$output_objdir/$libname.exp
96528c4a8e55Smrg	    $opt_dry_run || $RM $export_symbols
96538c4a8e55Smrg	    cmds=$export_symbols_cmds
96543169be4bSmrg	    save_ifs=$IFS; IFS='~'
9655bd23fbfaSmrg	    for cmd1 in $cmds; do
96563169be4bSmrg	      IFS=$save_ifs
9657bd23fbfaSmrg	      # Take the normal branch if the nm_file_list_spec branch
9658bd23fbfaSmrg	      # doesn't work or if tool conversion is not needed.
9659bd23fbfaSmrg	      case $nm_file_list_spec~$to_tool_file_cmd in
9660bd23fbfaSmrg		*~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
9661bd23fbfaSmrg		  try_normal_branch=yes
9662bd23fbfaSmrg		  eval cmd=\"$cmd1\"
9663bd23fbfaSmrg		  func_len " $cmd"
9664bd23fbfaSmrg		  len=$func_len_result
9665bd23fbfaSmrg		  ;;
9666bd23fbfaSmrg		*)
9667bd23fbfaSmrg		  try_normal_branch=no
9668bd23fbfaSmrg		  ;;
9669bd23fbfaSmrg	      esac
96703169be4bSmrg	      if test yes = "$try_normal_branch" \
9671bd23fbfaSmrg		 && { test "$len" -lt "$max_cmd_len" \
9672bd23fbfaSmrg		      || test "$max_cmd_len" -le -1; }
9673bd23fbfaSmrg	      then
9674bd23fbfaSmrg		func_show_eval "$cmd" 'exit $?'
9675bd23fbfaSmrg		skipped_export=false
9676bd23fbfaSmrg	      elif test -n "$nm_file_list_spec"; then
9677bd23fbfaSmrg		func_basename "$output"
9678bd23fbfaSmrg		output_la=$func_basename_result
9679bd23fbfaSmrg		save_libobjs=$libobjs
9680bd23fbfaSmrg		save_output=$output
96813169be4bSmrg		output=$output_objdir/$output_la.nm
9682bd23fbfaSmrg		func_to_tool_file "$output"
9683bd23fbfaSmrg		libobjs=$nm_file_list_spec$func_to_tool_file_result
9684bd23fbfaSmrg		func_append delfiles " $output"
9685bd23fbfaSmrg		func_verbose "creating $NM input file list: $output"
9686bd23fbfaSmrg		for obj in $save_libobjs; do
9687bd23fbfaSmrg		  func_to_tool_file "$obj"
9688bd23fbfaSmrg		  $ECHO "$func_to_tool_file_result"
9689bd23fbfaSmrg		done > "$output"
9690bd23fbfaSmrg		eval cmd=\"$cmd1\"
96918c4a8e55Smrg		func_show_eval "$cmd" 'exit $?'
9692bd23fbfaSmrg		output=$save_output
9693bd23fbfaSmrg		libobjs=$save_libobjs
96948c4a8e55Smrg		skipped_export=false
96958c4a8e55Smrg	      else
96968c4a8e55Smrg		# The command line is too long to execute in one step.
96978c4a8e55Smrg		func_verbose "using reloadable object file for export list..."
96988c4a8e55Smrg		skipped_export=:
96998c4a8e55Smrg		# Break out early, otherwise skipped_export may be
97008c4a8e55Smrg		# set to false by a later but shorter cmd.
97018c4a8e55Smrg		break
97028c4a8e55Smrg	      fi
97038c4a8e55Smrg	    done
97043169be4bSmrg	    IFS=$save_ifs
97053169be4bSmrg	    if test -n "$export_symbols_regex" && test : != "$skipped_export"; then
97068c4a8e55Smrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
97078c4a8e55Smrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
97088c4a8e55Smrg	    fi
97098c4a8e55Smrg	  fi
97108c4a8e55Smrg	fi
9711b042e37fSmrg
97128c4a8e55Smrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
97133169be4bSmrg	  tmp_export_symbols=$export_symbols
97143169be4bSmrg	  test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
9715706b6b52Smrg	  $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
97168c4a8e55Smrg	fi
9717b042e37fSmrg
97183169be4bSmrg	if test : != "$skipped_export" && test -n "$orig_export_symbols"; then
97198c4a8e55Smrg	  # The given exports_symbols file has to be filtered, so filter it.
97203169be4bSmrg	  func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
97218c4a8e55Smrg	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
97223169be4bSmrg	  # 's' commands, which not all seds can handle. GNU sed should be fine
97238c4a8e55Smrg	  # though. Also, the filter scales superlinearly with the number of
97248c4a8e55Smrg	  # global variables. join(1) would be nice here, but unfortunately
97258c4a8e55Smrg	  # isn't a blessed tool.
97268c4a8e55Smrg	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
9727bd23fbfaSmrg	  func_append delfiles " $export_symbols $output_objdir/$libname.filter"
97288c4a8e55Smrg	  export_symbols=$output_objdir/$libname.def
97298c4a8e55Smrg	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
9730b042e37fSmrg	fi
9731b042e37fSmrg
97328c4a8e55Smrg	tmp_deplibs=
97338c4a8e55Smrg	for test_deplib in $deplibs; do
97348c4a8e55Smrg	  case " $convenience " in
97358c4a8e55Smrg	  *" $test_deplib "*) ;;
97368c4a8e55Smrg	  *)
9737bd23fbfaSmrg	    func_append tmp_deplibs " $test_deplib"
97388c4a8e55Smrg	    ;;
97398c4a8e55Smrg	  esac
97408c4a8e55Smrg	done
97413169be4bSmrg	deplibs=$tmp_deplibs
9742b042e37fSmrg
97438c4a8e55Smrg	if test -n "$convenience"; then
97448c4a8e55Smrg	  if test -n "$whole_archive_flag_spec" &&
97453169be4bSmrg	    test yes = "$compiler_needs_object" &&
97468c4a8e55Smrg	    test -z "$libobjs"; then
97478c4a8e55Smrg	    # extract the archives, so we have objects to list.
97488c4a8e55Smrg	    # TODO: could optimize this to just extract one archive.
97498c4a8e55Smrg	    whole_archive_flag_spec=
97508c4a8e55Smrg	  fi
97518c4a8e55Smrg	  if test -n "$whole_archive_flag_spec"; then
97528c4a8e55Smrg	    save_libobjs=$libobjs
97538c4a8e55Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
97548c4a8e55Smrg	    test "X$libobjs" = "X " && libobjs=
97558c4a8e55Smrg	  else
97563169be4bSmrg	    gentop=$output_objdir/${outputname}x
9757bd23fbfaSmrg	    func_append generated " $gentop"
9758b042e37fSmrg
97598c4a8e55Smrg	    func_extract_archives $gentop $convenience
9760bd23fbfaSmrg	    func_append libobjs " $func_extract_archives_result"
97618c4a8e55Smrg	    test "X$libobjs" = "X " && libobjs=
97628c4a8e55Smrg	  fi
97638c4a8e55Smrg	fi
9764b042e37fSmrg
97653169be4bSmrg	if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then
97668c4a8e55Smrg	  eval flag=\"$thread_safe_flag_spec\"
9767bd23fbfaSmrg	  func_append linker_flags " $flag"
97688c4a8e55Smrg	fi
9769b042e37fSmrg
97708c4a8e55Smrg	# Make a backup of the uninstalled library when relinking
97713169be4bSmrg	if test relink = "$opt_mode"; then
97728c4a8e55Smrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
9773b042e37fSmrg	fi
9774b042e37fSmrg
97758c4a8e55Smrg	# Do each of the archive commands.
97763169be4bSmrg	if test yes = "$module" && test -n "$module_cmds"; then
97778c4a8e55Smrg	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
97788c4a8e55Smrg	    eval test_cmds=\"$module_expsym_cmds\"
97798c4a8e55Smrg	    cmds=$module_expsym_cmds
97808c4a8e55Smrg	  else
97818c4a8e55Smrg	    eval test_cmds=\"$module_cmds\"
97828c4a8e55Smrg	    cmds=$module_cmds
97838c4a8e55Smrg	  fi
97848c4a8e55Smrg	else
97858c4a8e55Smrg	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
97868c4a8e55Smrg	    eval test_cmds=\"$archive_expsym_cmds\"
97878c4a8e55Smrg	    cmds=$archive_expsym_cmds
97888c4a8e55Smrg	  else
97898c4a8e55Smrg	    eval test_cmds=\"$archive_cmds\"
97908c4a8e55Smrg	    cmds=$archive_cmds
97918c4a8e55Smrg	  fi
9792b042e37fSmrg	fi
9793b042e37fSmrg
97943169be4bSmrg	if test : != "$skipped_export" &&
97958c4a8e55Smrg	   func_len " $test_cmds" &&
97968c4a8e55Smrg	   len=$func_len_result &&
97978c4a8e55Smrg	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
97988c4a8e55Smrg	  :
97998c4a8e55Smrg	else
98008c4a8e55Smrg	  # The command line is too long to link in one step, link piecewise
98018c4a8e55Smrg	  # or, if using GNU ld and skipped_export is not :, use a linker
98028c4a8e55Smrg	  # script.
9803b042e37fSmrg
98048c4a8e55Smrg	  # Save the value of $output and $libobjs because we want to
98058c4a8e55Smrg	  # use them later.  If we have whole_archive_flag_spec, we
98068c4a8e55Smrg	  # want to use save_libobjs as it was before
98078c4a8e55Smrg	  # whole_archive_flag_spec was expanded, because we can't
98088c4a8e55Smrg	  # assume the linker understands whole_archive_flag_spec.
98098c4a8e55Smrg	  # This may have to be revisited, in case too many
98108c4a8e55Smrg	  # convenience libraries get linked in and end up exceeding
98118c4a8e55Smrg	  # the spec.
98128c4a8e55Smrg	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
98138c4a8e55Smrg	    save_libobjs=$libobjs
98148c4a8e55Smrg	  fi
98158c4a8e55Smrg	  save_output=$output
9816706b6b52Smrg	  func_basename "$output"
9817706b6b52Smrg	  output_la=$func_basename_result
9818b042e37fSmrg
98198c4a8e55Smrg	  # Clear the reloadable object creation command queue and
98208c4a8e55Smrg	  # initialize k to one.
98218c4a8e55Smrg	  test_cmds=
98228c4a8e55Smrg	  concat_cmds=
98238c4a8e55Smrg	  objlist=
98248c4a8e55Smrg	  last_robj=
98258c4a8e55Smrg	  k=1
9826b042e37fSmrg
98273169be4bSmrg	  if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then
98283169be4bSmrg	    output=$output_objdir/$output_la.lnkscript
98298c4a8e55Smrg	    func_verbose "creating GNU ld script: $output"
9830706b6b52Smrg	    echo 'INPUT (' > $output
98318c4a8e55Smrg	    for obj in $save_libobjs
98328c4a8e55Smrg	    do
9833bd23fbfaSmrg	      func_to_tool_file "$obj"
9834bd23fbfaSmrg	      $ECHO "$func_to_tool_file_result" >> $output
98358c4a8e55Smrg	    done
9836706b6b52Smrg	    echo ')' >> $output
9837bd23fbfaSmrg	    func_append delfiles " $output"
9838bd23fbfaSmrg	    func_to_tool_file "$output"
9839bd23fbfaSmrg	    output=$func_to_tool_file_result
98403169be4bSmrg	  elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then
98413169be4bSmrg	    output=$output_objdir/$output_la.lnk
98428c4a8e55Smrg	    func_verbose "creating linker input file list: $output"
98438c4a8e55Smrg	    : > $output
98448c4a8e55Smrg	    set x $save_libobjs
98458c4a8e55Smrg	    shift
98468c4a8e55Smrg	    firstobj=
98473169be4bSmrg	    if test yes = "$compiler_needs_object"; then
98488c4a8e55Smrg	      firstobj="$1 "
98498c4a8e55Smrg	      shift
98508c4a8e55Smrg	    fi
98518c4a8e55Smrg	    for obj
98528c4a8e55Smrg	    do
9853bd23fbfaSmrg	      func_to_tool_file "$obj"
9854bd23fbfaSmrg	      $ECHO "$func_to_tool_file_result" >> $output
98558c4a8e55Smrg	    done
9856bd23fbfaSmrg	    func_append delfiles " $output"
9857bd23fbfaSmrg	    func_to_tool_file "$output"
9858bd23fbfaSmrg	    output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
98598c4a8e55Smrg	  else
98608c4a8e55Smrg	    if test -n "$save_libobjs"; then
98618c4a8e55Smrg	      func_verbose "creating reloadable object files..."
98623169be4bSmrg	      output=$output_objdir/$output_la-$k.$objext
98638c4a8e55Smrg	      eval test_cmds=\"$reload_cmds\"
98648c4a8e55Smrg	      func_len " $test_cmds"
98658c4a8e55Smrg	      len0=$func_len_result
98668c4a8e55Smrg	      len=$len0
98678c4a8e55Smrg
98688c4a8e55Smrg	      # Loop over the list of objects to be linked.
98698c4a8e55Smrg	      for obj in $save_libobjs
98708c4a8e55Smrg	      do
98718c4a8e55Smrg		func_len " $obj"
98728c4a8e55Smrg		func_arith $len + $func_len_result
98738c4a8e55Smrg		len=$func_arith_result
98743169be4bSmrg		if test -z "$objlist" ||
98758c4a8e55Smrg		   test "$len" -lt "$max_cmd_len"; then
98768c4a8e55Smrg		  func_append objlist " $obj"
98778c4a8e55Smrg		else
98788c4a8e55Smrg		  # The command $test_cmds is almost too long, add a
98798c4a8e55Smrg		  # command to the queue.
98803169be4bSmrg		  if test 1 -eq "$k"; then
98818c4a8e55Smrg		    # The first file doesn't have a previous command to add.
9882706b6b52Smrg		    reload_objs=$objlist
9883706b6b52Smrg		    eval concat_cmds=\"$reload_cmds\"
98848c4a8e55Smrg		  else
98858c4a8e55Smrg		    # All subsequent reloadable object files will link in
98868c4a8e55Smrg		    # the last one created.
9887706b6b52Smrg		    reload_objs="$objlist $last_robj"
9888706b6b52Smrg		    eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
98898c4a8e55Smrg		  fi
98903169be4bSmrg		  last_robj=$output_objdir/$output_la-$k.$objext
98918c4a8e55Smrg		  func_arith $k + 1
98928c4a8e55Smrg		  k=$func_arith_result
98933169be4bSmrg		  output=$output_objdir/$output_la-$k.$objext
9894706b6b52Smrg		  objlist=" $obj"
98958c4a8e55Smrg		  func_len " $last_robj"
98968c4a8e55Smrg		  func_arith $len0 + $func_len_result
98978c4a8e55Smrg		  len=$func_arith_result
98988c4a8e55Smrg		fi
98998c4a8e55Smrg	      done
99008c4a8e55Smrg	      # Handle the remaining objects by creating one last
99018c4a8e55Smrg	      # reloadable object file.  All subsequent reloadable object
99028c4a8e55Smrg	      # files will link in the last one created.
99038c4a8e55Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
9904706b6b52Smrg	      reload_objs="$objlist $last_robj"
99053169be4bSmrg	      eval concat_cmds=\"\$concat_cmds$reload_cmds\"
99068c4a8e55Smrg	      if test -n "$last_robj"; then
99073169be4bSmrg	        eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
99088c4a8e55Smrg	      fi
9909bd23fbfaSmrg	      func_append delfiles " $output"
9910b042e37fSmrg
99118c4a8e55Smrg	    else
99128c4a8e55Smrg	      output=
99138c4a8e55Smrg	    fi
9914b042e37fSmrg
99153169be4bSmrg	    ${skipped_export-false} && {
99163169be4bSmrg	      func_verbose "generating symbol list for '$libname.la'"
99173169be4bSmrg	      export_symbols=$output_objdir/$libname.exp
99188c4a8e55Smrg	      $opt_dry_run || $RM $export_symbols
99198c4a8e55Smrg	      libobjs=$output
99208c4a8e55Smrg	      # Append the command to create the export file.
99218c4a8e55Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
99228c4a8e55Smrg	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
99238c4a8e55Smrg	      if test -n "$last_robj"; then
99248c4a8e55Smrg		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
99258c4a8e55Smrg	      fi
99263169be4bSmrg	    }
9927b042e37fSmrg
99288c4a8e55Smrg	    test -n "$save_libobjs" &&
99298c4a8e55Smrg	      func_verbose "creating a temporary reloadable object file: $output"
9930b042e37fSmrg
99318c4a8e55Smrg	    # Loop through the commands generated above and execute them.
99323169be4bSmrg	    save_ifs=$IFS; IFS='~'
99338c4a8e55Smrg	    for cmd in $concat_cmds; do
99343169be4bSmrg	      IFS=$save_ifs
99353169be4bSmrg	      $opt_quiet || {
99368c4a8e55Smrg		  func_quote_for_expand "$cmd"
99378c4a8e55Smrg		  eval "func_echo $func_quote_for_expand_result"
99388c4a8e55Smrg	      }
99398c4a8e55Smrg	      $opt_dry_run || eval "$cmd" || {
99408c4a8e55Smrg		lt_exit=$?
99418c4a8e55Smrg
99428c4a8e55Smrg		# Restore the uninstalled library and exit
99433169be4bSmrg		if test relink = "$opt_mode"; then
99448c4a8e55Smrg		  ( cd "$output_objdir" && \
99458c4a8e55Smrg		    $RM "${realname}T" && \
99468c4a8e55Smrg		    $MV "${realname}U" "$realname" )
99478c4a8e55Smrg		fi
9948b042e37fSmrg
99498c4a8e55Smrg		exit $lt_exit
99508c4a8e55Smrg	      }
99518c4a8e55Smrg	    done
99523169be4bSmrg	    IFS=$save_ifs
99538c4a8e55Smrg
99548c4a8e55Smrg	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
99558c4a8e55Smrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
99568c4a8e55Smrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
9957b042e37fSmrg	    fi
9958b042e37fSmrg	  fi
9959b042e37fSmrg
99603169be4bSmrg          ${skipped_export-false} && {
99618c4a8e55Smrg	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
99623169be4bSmrg	      tmp_export_symbols=$export_symbols
99633169be4bSmrg	      test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
9964706b6b52Smrg	      $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
99658c4a8e55Smrg	    fi
9966b042e37fSmrg
99678c4a8e55Smrg	    if test -n "$orig_export_symbols"; then
99688c4a8e55Smrg	      # The given exports_symbols file has to be filtered, so filter it.
99693169be4bSmrg	      func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
99708c4a8e55Smrg	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
99713169be4bSmrg	      # 's' commands, which not all seds can handle. GNU sed should be fine
99728c4a8e55Smrg	      # though. Also, the filter scales superlinearly with the number of
99738c4a8e55Smrg	      # global variables. join(1) would be nice here, but unfortunately
99748c4a8e55Smrg	      # isn't a blessed tool.
99758c4a8e55Smrg	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
9976bd23fbfaSmrg	      func_append delfiles " $export_symbols $output_objdir/$libname.filter"
99778c4a8e55Smrg	      export_symbols=$output_objdir/$libname.def
99788c4a8e55Smrg	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
99798c4a8e55Smrg	    fi
99803169be4bSmrg	  }
9981b042e37fSmrg
99828c4a8e55Smrg	  libobjs=$output
99838c4a8e55Smrg	  # Restore the value of output.
99848c4a8e55Smrg	  output=$save_output
9985b042e37fSmrg
99868c4a8e55Smrg	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
99878c4a8e55Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
99888c4a8e55Smrg	    test "X$libobjs" = "X " && libobjs=
99898c4a8e55Smrg	  fi
99908c4a8e55Smrg	  # Expand the library linking commands again to reset the
99918c4a8e55Smrg	  # value of $libobjs for piecewise linking.
99928c4a8e55Smrg
99938c4a8e55Smrg	  # Do each of the archive commands.
99943169be4bSmrg	  if test yes = "$module" && test -n "$module_cmds"; then
99958c4a8e55Smrg	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
99968c4a8e55Smrg	      cmds=$module_expsym_cmds
9997b042e37fSmrg	    else
99988c4a8e55Smrg	      cmds=$module_cmds
9999b042e37fSmrg	    fi
10000b042e37fSmrg	  else
100018c4a8e55Smrg	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
100028c4a8e55Smrg	      cmds=$archive_expsym_cmds
100038c4a8e55Smrg	    else
100048c4a8e55Smrg	      cmds=$archive_cmds
100058c4a8e55Smrg	    fi
10006b042e37fSmrg	  fi
10007b042e37fSmrg	fi
10008b042e37fSmrg
100098c4a8e55Smrg	if test -n "$delfiles"; then
100108c4a8e55Smrg	  # Append the command to remove temporary files to $cmds.
100118c4a8e55Smrg	  eval cmds=\"\$cmds~\$RM $delfiles\"
100128c4a8e55Smrg	fi
10013b042e37fSmrg
100148c4a8e55Smrg	# Add any objects from preloaded convenience libraries
100158c4a8e55Smrg	if test -n "$dlprefiles"; then
100163169be4bSmrg	  gentop=$output_objdir/${outputname}x
10017bd23fbfaSmrg	  func_append generated " $gentop"
10018b042e37fSmrg
100198c4a8e55Smrg	  func_extract_archives $gentop $dlprefiles
10020bd23fbfaSmrg	  func_append libobjs " $func_extract_archives_result"
100218c4a8e55Smrg	  test "X$libobjs" = "X " && libobjs=
10022b042e37fSmrg	fi
10023b042e37fSmrg
100243169be4bSmrg	save_ifs=$IFS; IFS='~'
100258c4a8e55Smrg	for cmd in $cmds; do
100263169be4bSmrg	  IFS=$sp$nl
100278c4a8e55Smrg	  eval cmd=\"$cmd\"
100283169be4bSmrg	  IFS=$save_ifs
100293169be4bSmrg	  $opt_quiet || {
100308c4a8e55Smrg	    func_quote_for_expand "$cmd"
100318c4a8e55Smrg	    eval "func_echo $func_quote_for_expand_result"
100328c4a8e55Smrg	  }
100338c4a8e55Smrg	  $opt_dry_run || eval "$cmd" || {
100348c4a8e55Smrg	    lt_exit=$?
10035b042e37fSmrg
100368c4a8e55Smrg	    # Restore the uninstalled library and exit
100373169be4bSmrg	    if test relink = "$opt_mode"; then
100388c4a8e55Smrg	      ( cd "$output_objdir" && \
100398c4a8e55Smrg	        $RM "${realname}T" && \
100408c4a8e55Smrg		$MV "${realname}U" "$realname" )
100418c4a8e55Smrg	    fi
100428c4a8e55Smrg
100438c4a8e55Smrg	    exit $lt_exit
100448c4a8e55Smrg	  }
100458c4a8e55Smrg	done
100463169be4bSmrg	IFS=$save_ifs
100478c4a8e55Smrg
100488c4a8e55Smrg	# Restore the uninstalled library and exit
100493169be4bSmrg	if test relink = "$opt_mode"; then
100508c4a8e55Smrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
100518c4a8e55Smrg
100528c4a8e55Smrg	  if test -n "$convenience"; then
100538c4a8e55Smrg	    if test -z "$whole_archive_flag_spec"; then
100548c4a8e55Smrg	      func_show_eval '${RM}r "$gentop"'
10055b042e37fSmrg	    fi
10056b042e37fSmrg	  fi
10057b042e37fSmrg
100588c4a8e55Smrg	  exit $EXIT_SUCCESS
100598c4a8e55Smrg	fi
10060b042e37fSmrg
100618c4a8e55Smrg	# Create links to the real library.
100628c4a8e55Smrg	for linkname in $linknames; do
100638c4a8e55Smrg	  if test "$realname" != "$linkname"; then
100648c4a8e55Smrg	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
100658c4a8e55Smrg	  fi
100668c4a8e55Smrg	done
100678c4a8e55Smrg
100688c4a8e55Smrg	# If -module or -export-dynamic was specified, set the dlname.
100693169be4bSmrg	if test yes = "$module" || test yes = "$export_dynamic"; then
100708c4a8e55Smrg	  # On all known operating systems, these are identical.
100713169be4bSmrg	  dlname=$soname
100728c4a8e55Smrg	fi
100738c4a8e55Smrg      fi
100748c4a8e55Smrg      ;;
100758c4a8e55Smrg
100768c4a8e55Smrg    obj)
100773169be4bSmrg      if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
100783169be4bSmrg	func_warning "'-dlopen' is ignored for objects"
100798c4a8e55Smrg      fi
100808c4a8e55Smrg
100818c4a8e55Smrg      case " $deplibs" in
100828c4a8e55Smrg      *\ -l* | *\ -L*)
100833169be4bSmrg	func_warning "'-l' and '-L' are ignored for objects" ;;
100848c4a8e55Smrg      esac
100858c4a8e55Smrg
100868c4a8e55Smrg      test -n "$rpath" && \
100873169be4bSmrg	func_warning "'-rpath' is ignored for objects"
100888c4a8e55Smrg
100898c4a8e55Smrg      test -n "$xrpath" && \
100903169be4bSmrg	func_warning "'-R' is ignored for objects"
100918c4a8e55Smrg
100928c4a8e55Smrg      test -n "$vinfo" && \
100933169be4bSmrg	func_warning "'-version-info' is ignored for objects"
100948c4a8e55Smrg
100958c4a8e55Smrg      test -n "$release" && \
100963169be4bSmrg	func_warning "'-release' is ignored for objects"
100978c4a8e55Smrg
100988c4a8e55Smrg      case $output in
100998c4a8e55Smrg      *.lo)
101008c4a8e55Smrg	test -n "$objs$old_deplibs" && \
101013169be4bSmrg	  func_fatal_error "cannot build library object '$output' from non-libtool objects"
101028c4a8e55Smrg
101038c4a8e55Smrg	libobj=$output
101048c4a8e55Smrg	func_lo2o "$libobj"
101058c4a8e55Smrg	obj=$func_lo2o_result
101068c4a8e55Smrg	;;
101078c4a8e55Smrg      *)
101088c4a8e55Smrg	libobj=
101093169be4bSmrg	obj=$output
101108c4a8e55Smrg	;;
101118c4a8e55Smrg      esac
101128c4a8e55Smrg
101138c4a8e55Smrg      # Delete the old objects.
101148c4a8e55Smrg      $opt_dry_run || $RM $obj $libobj
101158c4a8e55Smrg
101168c4a8e55Smrg      # Objects from convenience libraries.  This assumes
101178c4a8e55Smrg      # single-version convenience libraries.  Whenever we create
101188c4a8e55Smrg      # different ones for PIC/non-PIC, this we'll have to duplicate
101198c4a8e55Smrg      # the extraction.
101208c4a8e55Smrg      reload_conv_objs=
101218c4a8e55Smrg      gentop=
101223169be4bSmrg      # if reload_cmds runs $LD directly, get rid of -Wl from
101233169be4bSmrg      # whole_archive_flag_spec and hope we can get by with turning comma
101243169be4bSmrg      # into space.
101253169be4bSmrg      case $reload_cmds in
101263169be4bSmrg        *\$LD[\ \$]*) wl= ;;
101273169be4bSmrg      esac
101288c4a8e55Smrg      if test -n "$convenience"; then
101298c4a8e55Smrg	if test -n "$whole_archive_flag_spec"; then
101308c4a8e55Smrg	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
101313169be4bSmrg	  test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
101323169be4bSmrg	  reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags
101338c4a8e55Smrg	else
101343169be4bSmrg	  gentop=$output_objdir/${obj}x
10135bd23fbfaSmrg	  func_append generated " $gentop"
101368c4a8e55Smrg
101378c4a8e55Smrg	  func_extract_archives $gentop $convenience
101388c4a8e55Smrg	  reload_conv_objs="$reload_objs $func_extract_archives_result"
101398c4a8e55Smrg	fi
101408c4a8e55Smrg      fi
10141b042e37fSmrg
10142bd23fbfaSmrg      # If we're not building shared, we need to use non_pic_objs
101433169be4bSmrg      test yes = "$build_libtool_libs" || libobjs=$non_pic_objects
10144bd23fbfaSmrg
101458c4a8e55Smrg      # Create the old-style object.
101463169be4bSmrg      reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs
10147b042e37fSmrg
101483169be4bSmrg      output=$obj
101498c4a8e55Smrg      func_execute_cmds "$reload_cmds" 'exit $?'
10150b042e37fSmrg
101518c4a8e55Smrg      # Exit if we aren't doing a library object file.
101528c4a8e55Smrg      if test -z "$libobj"; then
101538c4a8e55Smrg	if test -n "$gentop"; then
101548c4a8e55Smrg	  func_show_eval '${RM}r "$gentop"'
101558c4a8e55Smrg	fi
10156b042e37fSmrg
101578c4a8e55Smrg	exit $EXIT_SUCCESS
101588c4a8e55Smrg      fi
10159b042e37fSmrg
101603169be4bSmrg      test yes = "$build_libtool_libs" || {
101618c4a8e55Smrg	if test -n "$gentop"; then
101628c4a8e55Smrg	  func_show_eval '${RM}r "$gentop"'
101638c4a8e55Smrg	fi
10164b042e37fSmrg
101658c4a8e55Smrg	# Create an invalid libtool object if no PIC, so that we don't
101668c4a8e55Smrg	# accidentally link it into a program.
101678c4a8e55Smrg	# $show "echo timestamp > $libobj"
101688c4a8e55Smrg	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
101698c4a8e55Smrg	exit $EXIT_SUCCESS
101703169be4bSmrg      }
10171b042e37fSmrg
101723169be4bSmrg      if test -n "$pic_flag" || test default != "$pic_mode"; then
101738c4a8e55Smrg	# Only do commands if we really have different PIC objects.
101748c4a8e55Smrg	reload_objs="$libobjs $reload_conv_objs"
101753169be4bSmrg	output=$libobj
101768c4a8e55Smrg	func_execute_cmds "$reload_cmds" 'exit $?'
10177b042e37fSmrg      fi
10178b042e37fSmrg
101798c4a8e55Smrg      if test -n "$gentop"; then
101808c4a8e55Smrg	func_show_eval '${RM}r "$gentop"'
101818c4a8e55Smrg      fi
10182b042e37fSmrg
101838c4a8e55Smrg      exit $EXIT_SUCCESS
101848c4a8e55Smrg      ;;
10185b042e37fSmrg
101868c4a8e55Smrg    prog)
101878c4a8e55Smrg      case $host in
101888c4a8e55Smrg	*cygwin*) func_stripname '' '.exe' "$output"
101898c4a8e55Smrg	          output=$func_stripname_result.exe;;
10190b042e37fSmrg      esac
101918c4a8e55Smrg      test -n "$vinfo" && \
101923169be4bSmrg	func_warning "'-version-info' is ignored for programs"
10193b042e37fSmrg
101948c4a8e55Smrg      test -n "$release" && \
101953169be4bSmrg	func_warning "'-release' is ignored for programs"
10196b042e37fSmrg
101973169be4bSmrg      $preload \
101983169be4bSmrg	&& test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \
101993169be4bSmrg	&& func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support."
10200b042e37fSmrg
102018c4a8e55Smrg      case $host in
102028c4a8e55Smrg      *-*-rhapsody* | *-*-darwin1.[012])
102038c4a8e55Smrg	# On Rhapsody replace the C library is the System framework
10204706b6b52Smrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
10205706b6b52Smrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
10206b042e37fSmrg	;;
10207b042e37fSmrg      esac
10208b042e37fSmrg
102098c4a8e55Smrg      case $host in
102108c4a8e55Smrg      *-*-darwin*)
102118c4a8e55Smrg	# Don't allow lazy linking, it breaks C++ global constructors
102128c4a8e55Smrg	# But is supposedly fixed on 10.4 or later (yay!).
102133169be4bSmrg	if test CXX = "$tagname"; then
102148c4a8e55Smrg	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
102158c4a8e55Smrg	    10.[0123])
102163169be4bSmrg	      func_append compile_command " $wl-bind_at_load"
102173169be4bSmrg	      func_append finalize_command " $wl-bind_at_load"
102188c4a8e55Smrg	    ;;
102198c4a8e55Smrg	  esac
102208c4a8e55Smrg	fi
102218c4a8e55Smrg	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
10222706b6b52Smrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
10223706b6b52Smrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
10224b042e37fSmrg	;;
10225b042e37fSmrg      esac
10226b042e37fSmrg
10227b042e37fSmrg
102288c4a8e55Smrg      # move library search paths that coincide with paths to not yet
102298c4a8e55Smrg      # installed libraries to the beginning of the library search list
102308c4a8e55Smrg      new_libs=
102318c4a8e55Smrg      for path in $notinst_path; do
102328c4a8e55Smrg	case " $new_libs " in
102338c4a8e55Smrg	*" -L$path/$objdir "*) ;;
10234b042e37fSmrg	*)
102358c4a8e55Smrg	  case " $compile_deplibs " in
102368c4a8e55Smrg	  *" -L$path/$objdir "*)
10237bd23fbfaSmrg	    func_append new_libs " -L$path/$objdir" ;;
102388c4a8e55Smrg	  esac
10239b042e37fSmrg	  ;;
10240b042e37fSmrg	esac
10241b042e37fSmrg      done
102428c4a8e55Smrg      for deplib in $compile_deplibs; do
102438c4a8e55Smrg	case $deplib in
102448c4a8e55Smrg	-L*)
102458c4a8e55Smrg	  case " $new_libs " in
102468c4a8e55Smrg	  *" $deplib "*) ;;
10247bd23fbfaSmrg	  *) func_append new_libs " $deplib" ;;
102488c4a8e55Smrg	  esac
102498c4a8e55Smrg	  ;;
10250bd23fbfaSmrg	*) func_append new_libs " $deplib" ;;
102518c4a8e55Smrg	esac
102528c4a8e55Smrg      done
102533169be4bSmrg      compile_deplibs=$new_libs
10254b042e37fSmrg
10255b042e37fSmrg
10256bd23fbfaSmrg      func_append compile_command " $compile_deplibs"
10257bd23fbfaSmrg      func_append finalize_command " $finalize_deplibs"
10258b042e37fSmrg
102598c4a8e55Smrg      if test -n "$rpath$xrpath"; then
102608c4a8e55Smrg	# If the user specified any rpath flags, then add them.
102618c4a8e55Smrg	for libdir in $rpath $xrpath; do
102628c4a8e55Smrg	  # This is the magic to use -rpath.
102638c4a8e55Smrg	  case "$finalize_rpath " in
102648c4a8e55Smrg	  *" $libdir "*) ;;
10265bd23fbfaSmrg	  *) func_append finalize_rpath " $libdir" ;;
102668c4a8e55Smrg	  esac
102678c4a8e55Smrg	done
102688c4a8e55Smrg      fi
10269b042e37fSmrg
102708c4a8e55Smrg      # Now hardcode the library paths
102718c4a8e55Smrg      rpath=
102728c4a8e55Smrg      hardcode_libdirs=
102738c4a8e55Smrg      for libdir in $compile_rpath $finalize_rpath; do
102748c4a8e55Smrg	if test -n "$hardcode_libdir_flag_spec"; then
102758c4a8e55Smrg	  if test -n "$hardcode_libdir_separator"; then
102768c4a8e55Smrg	    if test -z "$hardcode_libdirs"; then
102773169be4bSmrg	      hardcode_libdirs=$libdir
102788c4a8e55Smrg	    else
102798c4a8e55Smrg	      # Just accumulate the unique libdirs.
102808c4a8e55Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
102818c4a8e55Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
102828c4a8e55Smrg		;;
102838c4a8e55Smrg	      *)
10284bd23fbfaSmrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
102858c4a8e55Smrg		;;
102868c4a8e55Smrg	      esac
102878c4a8e55Smrg	    fi
102888c4a8e55Smrg	  else
102898c4a8e55Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
10290bd23fbfaSmrg	    func_append rpath " $flag"
102918c4a8e55Smrg	  fi
102928c4a8e55Smrg	elif test -n "$runpath_var"; then
102938c4a8e55Smrg	  case "$perm_rpath " in
10294b042e37fSmrg	  *" $libdir "*) ;;
10295bd23fbfaSmrg	  *) func_append perm_rpath " $libdir" ;;
10296b042e37fSmrg	  esac
102978c4a8e55Smrg	fi
102988c4a8e55Smrg	case $host in
102998c4a8e55Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
103003169be4bSmrg	  testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'`
103018c4a8e55Smrg	  case :$dllsearchpath: in
103028c4a8e55Smrg	  *":$libdir:"*) ;;
103038c4a8e55Smrg	  ::) dllsearchpath=$libdir;;
10304bd23fbfaSmrg	  *) func_append dllsearchpath ":$libdir";;
103058c4a8e55Smrg	  esac
103068c4a8e55Smrg	  case :$dllsearchpath: in
103078c4a8e55Smrg	  *":$testbindir:"*) ;;
103088c4a8e55Smrg	  ::) dllsearchpath=$testbindir;;
10309bd23fbfaSmrg	  *) func_append dllsearchpath ":$testbindir";;
103108c4a8e55Smrg	  esac
103118c4a8e55Smrg	  ;;
103128c4a8e55Smrg	esac
103138c4a8e55Smrg      done
103148c4a8e55Smrg      # Substitute the hardcoded libdirs into the rpath.
103158c4a8e55Smrg      if test -n "$hardcode_libdir_separator" &&
103168c4a8e55Smrg	 test -n "$hardcode_libdirs"; then
103173169be4bSmrg	libdir=$hardcode_libdirs
103188c4a8e55Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
103198c4a8e55Smrg      fi
103203169be4bSmrg      compile_rpath=$rpath
103218c4a8e55Smrg
103228c4a8e55Smrg      rpath=
103238c4a8e55Smrg      hardcode_libdirs=
103248c4a8e55Smrg      for libdir in $finalize_rpath; do
103258c4a8e55Smrg	if test -n "$hardcode_libdir_flag_spec"; then
103268c4a8e55Smrg	  if test -n "$hardcode_libdir_separator"; then
103278c4a8e55Smrg	    if test -z "$hardcode_libdirs"; then
103283169be4bSmrg	      hardcode_libdirs=$libdir
103298c4a8e55Smrg	    else
103308c4a8e55Smrg	      # Just accumulate the unique libdirs.
103318c4a8e55Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
103328c4a8e55Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
103338c4a8e55Smrg		;;
103348c4a8e55Smrg	      *)
10335bd23fbfaSmrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
103368c4a8e55Smrg		;;
103378c4a8e55Smrg	      esac
103388c4a8e55Smrg	    fi
103398c4a8e55Smrg	  else
103408c4a8e55Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
10341bd23fbfaSmrg	    func_append rpath " $flag"
103428c4a8e55Smrg	  fi
103438c4a8e55Smrg	elif test -n "$runpath_var"; then
103448c4a8e55Smrg	  case "$finalize_perm_rpath " in
10345b042e37fSmrg	  *" $libdir "*) ;;
10346bd23fbfaSmrg	  *) func_append finalize_perm_rpath " $libdir" ;;
10347b042e37fSmrg	  esac
10348b042e37fSmrg	fi
103498c4a8e55Smrg      done
103508c4a8e55Smrg      # Substitute the hardcoded libdirs into the rpath.
103518c4a8e55Smrg      if test -n "$hardcode_libdir_separator" &&
103528c4a8e55Smrg	 test -n "$hardcode_libdirs"; then
103533169be4bSmrg	libdir=$hardcode_libdirs
103548c4a8e55Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
103558c4a8e55Smrg      fi
103563169be4bSmrg      finalize_rpath=$rpath
10357b042e37fSmrg
103583169be4bSmrg      if test -n "$libobjs" && test yes = "$build_old_libs"; then
103598c4a8e55Smrg	# Transform all the library objects into standard objects.
10360706b6b52Smrg	compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
10361706b6b52Smrg	finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
103628c4a8e55Smrg      fi
10363b042e37fSmrg
103643169be4bSmrg      func_generate_dlsyms "$outputname" "@PROGRAM@" false
10365b042e37fSmrg
103668c4a8e55Smrg      # template prelinking step
103678c4a8e55Smrg      if test -n "$prelink_cmds"; then
103688c4a8e55Smrg	func_execute_cmds "$prelink_cmds" 'exit $?'
103698c4a8e55Smrg      fi
10370b042e37fSmrg
103713169be4bSmrg      wrappers_required=:
103728c4a8e55Smrg      case $host in
10373706b6b52Smrg      *cegcc* | *mingw32ce*)
10374706b6b52Smrg        # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
103753169be4bSmrg        wrappers_required=false
10376706b6b52Smrg        ;;
103778c4a8e55Smrg      *cygwin* | *mingw* )
103783169be4bSmrg        test yes = "$build_libtool_libs" || wrappers_required=false
103798c4a8e55Smrg        ;;
103808c4a8e55Smrg      *)
103813169be4bSmrg        if test no = "$need_relink" || test yes != "$build_libtool_libs"; then
103823169be4bSmrg          wrappers_required=false
103838c4a8e55Smrg        fi
103848c4a8e55Smrg        ;;
103858c4a8e55Smrg      esac
103863169be4bSmrg      $wrappers_required || {
103878c4a8e55Smrg	# Replace the output file specification.
10388706b6b52Smrg	compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
103893169be4bSmrg	link_command=$compile_command$compile_rpath
10390b042e37fSmrg
103918c4a8e55Smrg	# We have no uninstalled library dependencies, so finalize right now.
103928c4a8e55Smrg	exit_status=0
103938c4a8e55Smrg	func_show_eval "$link_command" 'exit_status=$?'
10394b042e37fSmrg
10395bd23fbfaSmrg	if test -n "$postlink_cmds"; then
10396bd23fbfaSmrg	  func_to_tool_file "$output"
10397bd23fbfaSmrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
10398bd23fbfaSmrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
10399bd23fbfaSmrg	fi
10400bd23fbfaSmrg
104018c4a8e55Smrg	# Delete the generated files.
104023169be4bSmrg	if test -f "$output_objdir/${outputname}S.$objext"; then
104033169be4bSmrg	  func_show_eval '$RM "$output_objdir/${outputname}S.$objext"'
104048c4a8e55Smrg	fi
10405b042e37fSmrg
104068c4a8e55Smrg	exit $exit_status
104073169be4bSmrg      }
10408b042e37fSmrg
104098c4a8e55Smrg      if test -n "$compile_shlibpath$finalize_shlibpath"; then
104108c4a8e55Smrg	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
104118c4a8e55Smrg      fi
104128c4a8e55Smrg      if test -n "$finalize_shlibpath"; then
104138c4a8e55Smrg	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
104148c4a8e55Smrg      fi
10415b042e37fSmrg
104168c4a8e55Smrg      compile_var=
104178c4a8e55Smrg      finalize_var=
104188c4a8e55Smrg      if test -n "$runpath_var"; then
104198c4a8e55Smrg	if test -n "$perm_rpath"; then
104208c4a8e55Smrg	  # We should set the runpath_var.
104218c4a8e55Smrg	  rpath=
104228c4a8e55Smrg	  for dir in $perm_rpath; do
10423bd23fbfaSmrg	    func_append rpath "$dir:"
10424b042e37fSmrg	  done
104258c4a8e55Smrg	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
10426b042e37fSmrg	fi
104278c4a8e55Smrg	if test -n "$finalize_perm_rpath"; then
104288c4a8e55Smrg	  # We should set the runpath_var.
104298c4a8e55Smrg	  rpath=
104308c4a8e55Smrg	  for dir in $finalize_perm_rpath; do
10431bd23fbfaSmrg	    func_append rpath "$dir:"
104328c4a8e55Smrg	  done
104338c4a8e55Smrg	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
104348c4a8e55Smrg	fi
104358c4a8e55Smrg      fi
10436b042e37fSmrg
104373169be4bSmrg      if test yes = "$no_install"; then
104388c4a8e55Smrg	# We don't need to create a wrapper script.
104393169be4bSmrg	link_command=$compile_var$compile_command$compile_rpath
104408c4a8e55Smrg	# Replace the output file specification.
10441706b6b52Smrg	link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
104428c4a8e55Smrg	# Delete the old output file.
104438c4a8e55Smrg	$opt_dry_run || $RM $output
104448c4a8e55Smrg	# Link the executable and exit
104458c4a8e55Smrg	func_show_eval "$link_command" 'exit $?'
10446bd23fbfaSmrg
10447bd23fbfaSmrg	if test -n "$postlink_cmds"; then
10448bd23fbfaSmrg	  func_to_tool_file "$output"
10449bd23fbfaSmrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
10450bd23fbfaSmrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
10451bd23fbfaSmrg	fi
10452bd23fbfaSmrg
104538c4a8e55Smrg	exit $EXIT_SUCCESS
104548c4a8e55Smrg      fi
10455b042e37fSmrg
104563169be4bSmrg      case $hardcode_action,$fast_install in
104573169be4bSmrg        relink,*)
104583169be4bSmrg	  # Fast installation is not supported
104593169be4bSmrg	  link_command=$compile_var$compile_command$compile_rpath
104603169be4bSmrg	  relink_command=$finalize_var$finalize_command$finalize_rpath
10461b042e37fSmrg
104623169be4bSmrg	  func_warning "this platform does not like uninstalled shared libraries"
104633169be4bSmrg	  func_warning "'$output' will be relinked during installation"
104643169be4bSmrg	  ;;
104653169be4bSmrg        *,yes)
104663169be4bSmrg	  link_command=$finalize_var$compile_command$finalize_rpath
104673169be4bSmrg	  relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
104683169be4bSmrg          ;;
104693169be4bSmrg	*,no)
104703169be4bSmrg	  link_command=$compile_var$compile_command$compile_rpath
104713169be4bSmrg	  relink_command=$finalize_var$finalize_command$finalize_rpath
104723169be4bSmrg          ;;
104733169be4bSmrg	*,needless)
104743169be4bSmrg	  link_command=$finalize_var$compile_command$finalize_rpath
104753169be4bSmrg	  relink_command=
104763169be4bSmrg          ;;
104773169be4bSmrg      esac
10478b042e37fSmrg
104798c4a8e55Smrg      # Replace the output file specification.
10480706b6b52Smrg      link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
10481b042e37fSmrg
104828c4a8e55Smrg      # Delete the old output files.
104838c4a8e55Smrg      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
10484b042e37fSmrg
104858c4a8e55Smrg      func_show_eval "$link_command" 'exit $?'
10486b042e37fSmrg
10487bd23fbfaSmrg      if test -n "$postlink_cmds"; then
10488bd23fbfaSmrg	func_to_tool_file "$output_objdir/$outputname"
10489bd23fbfaSmrg	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'`
10490bd23fbfaSmrg	func_execute_cmds "$postlink_cmds" 'exit $?'
10491bd23fbfaSmrg      fi
10492bd23fbfaSmrg
104938c4a8e55Smrg      # Now create the wrapper script.
104948c4a8e55Smrg      func_verbose "creating $output"
10495b042e37fSmrg
104968c4a8e55Smrg      # Quote the relink command for shipping.
104978c4a8e55Smrg      if test -n "$relink_command"; then
104988c4a8e55Smrg	# Preserve any variables that may affect compiler behavior
104998c4a8e55Smrg	for var in $variables_saved_for_relink; do
105008c4a8e55Smrg	  if eval test -z \"\${$var+set}\"; then
105018c4a8e55Smrg	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
105028c4a8e55Smrg	  elif eval var_value=\$$var; test -z "$var_value"; then
105038c4a8e55Smrg	    relink_command="$var=; export $var; $relink_command"
105048c4a8e55Smrg	  else
105058c4a8e55Smrg	    func_quote_for_eval "$var_value"
105068c4a8e55Smrg	    relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
105078c4a8e55Smrg	  fi
105088c4a8e55Smrg	done
105098c4a8e55Smrg	relink_command="(cd `pwd`; $relink_command)"
10510706b6b52Smrg	relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
105118c4a8e55Smrg      fi
10512b042e37fSmrg
105138c4a8e55Smrg      # Only actually do things if not in dry run mode.
105148c4a8e55Smrg      $opt_dry_run || {
105158c4a8e55Smrg	# win32 will think the script is a binary if it has
105168c4a8e55Smrg	# a .exe suffix, so we strip it off here.
105178c4a8e55Smrg	case $output in
105188c4a8e55Smrg	  *.exe) func_stripname '' '.exe' "$output"
105198c4a8e55Smrg	         output=$func_stripname_result ;;
105208c4a8e55Smrg	esac
105218c4a8e55Smrg	# test for cygwin because mv fails w/o .exe extensions
10522b042e37fSmrg	case $host in
105238c4a8e55Smrg	  *cygwin*)
105248c4a8e55Smrg	    exeext=.exe
105258c4a8e55Smrg	    func_stripname '' '.exe' "$outputname"
105268c4a8e55Smrg	    outputname=$func_stripname_result ;;
105278c4a8e55Smrg	  *) exeext= ;;
10528b042e37fSmrg	esac
105298c4a8e55Smrg	case $host in
105308c4a8e55Smrg	  *cygwin* | *mingw* )
105318c4a8e55Smrg	    func_dirname_and_basename "$output" "" "."
105328c4a8e55Smrg	    output_name=$func_basename_result
105338c4a8e55Smrg	    output_path=$func_dirname_result
105343169be4bSmrg	    cwrappersource=$output_path/$objdir/lt-$output_name.c
105353169be4bSmrg	    cwrapper=$output_path/$output_name.exe
105368c4a8e55Smrg	    $RM $cwrappersource $cwrapper
105378c4a8e55Smrg	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
105388c4a8e55Smrg
105398c4a8e55Smrg	    func_emit_cwrapperexe_src > $cwrappersource
105408c4a8e55Smrg
105418c4a8e55Smrg	    # The wrapper executable is built using the $host compiler,
105428c4a8e55Smrg	    # because it contains $host paths and files. If cross-
105438c4a8e55Smrg	    # compiling, it, like the target executable, must be
105448c4a8e55Smrg	    # executed on the $host or under an emulation environment.
105458c4a8e55Smrg	    $opt_dry_run || {
105468c4a8e55Smrg	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
105478c4a8e55Smrg	      $STRIP $cwrapper
105488c4a8e55Smrg	    }
10549b042e37fSmrg
105508c4a8e55Smrg	    # Now, create the wrapper script for func_source use:
105518c4a8e55Smrg	    func_ltwrapper_scriptname $cwrapper
105528c4a8e55Smrg	    $RM $func_ltwrapper_scriptname_result
105538c4a8e55Smrg	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
105548c4a8e55Smrg	    $opt_dry_run || {
105558c4a8e55Smrg	      # note: this script will not be executed, so do not chmod.
105563169be4bSmrg	      if test "x$build" = "x$host"; then
105578c4a8e55Smrg		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
10558b042e37fSmrg	      else
105598c4a8e55Smrg		func_emit_wrapper no > $func_ltwrapper_scriptname_result
10560b042e37fSmrg	      fi
105618c4a8e55Smrg	    }
105628c4a8e55Smrg	  ;;
105638c4a8e55Smrg	  * )
105648c4a8e55Smrg	    $RM $output
105658c4a8e55Smrg	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
10566b042e37fSmrg
105678c4a8e55Smrg	    func_emit_wrapper no > $output
105688c4a8e55Smrg	    chmod +x $output
10569b042e37fSmrg	  ;;
10570b042e37fSmrg	esac
105718c4a8e55Smrg      }
105728c4a8e55Smrg      exit $EXIT_SUCCESS
105738c4a8e55Smrg      ;;
105748c4a8e55Smrg    esac
10575b042e37fSmrg
105768c4a8e55Smrg    # See if we need to build an old-fashioned archive.
105778c4a8e55Smrg    for oldlib in $oldlibs; do
10578b042e37fSmrg
105793169be4bSmrg      case $build_libtool_libs in
105803169be4bSmrg        convenience)
105813169be4bSmrg	  oldobjs="$libobjs_save $symfileobj"
105823169be4bSmrg	  addlibs=$convenience
105838c4a8e55Smrg	  build_libtool_libs=no
105843169be4bSmrg	  ;;
105853169be4bSmrg	module)
105863169be4bSmrg	  oldobjs=$libobjs_save
105873169be4bSmrg	  addlibs=$old_convenience
105883169be4bSmrg	  build_libtool_libs=no
105893169be4bSmrg          ;;
105903169be4bSmrg	*)
105918c4a8e55Smrg	  oldobjs="$old_deplibs $non_pic_objects"
105923169be4bSmrg	  $preload && test -f "$symfileobj" \
105933169be4bSmrg	    && func_append oldobjs " $symfileobj"
105943169be4bSmrg	  addlibs=$old_convenience
105953169be4bSmrg	  ;;
105963169be4bSmrg      esac
10597b042e37fSmrg
105988c4a8e55Smrg      if test -n "$addlibs"; then
105993169be4bSmrg	gentop=$output_objdir/${outputname}x
10600bd23fbfaSmrg	func_append generated " $gentop"
10601b042e37fSmrg
106028c4a8e55Smrg	func_extract_archives $gentop $addlibs
10603bd23fbfaSmrg	func_append oldobjs " $func_extract_archives_result"
106048c4a8e55Smrg      fi
10605b042e37fSmrg
106068c4a8e55Smrg      # Do each command in the archive commands.
106073169be4bSmrg      if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then
106088c4a8e55Smrg	cmds=$old_archive_from_new_cmds
106098c4a8e55Smrg      else
10610b042e37fSmrg
106118c4a8e55Smrg	# Add any objects from preloaded convenience libraries
106128c4a8e55Smrg	if test -n "$dlprefiles"; then
106133169be4bSmrg	  gentop=$output_objdir/${outputname}x
10614bd23fbfaSmrg	  func_append generated " $gentop"
10615b042e37fSmrg
106168c4a8e55Smrg	  func_extract_archives $gentop $dlprefiles
10617bd23fbfaSmrg	  func_append oldobjs " $func_extract_archives_result"
106188c4a8e55Smrg	fi
10619b042e37fSmrg
106208c4a8e55Smrg	# POSIX demands no paths to be encoded in archives.  We have
106218c4a8e55Smrg	# to avoid creating archives with duplicate basenames if we
106228c4a8e55Smrg	# might have to extract them afterwards, e.g., when creating a
106238c4a8e55Smrg	# static archive out of a convenience library, or when linking
106248c4a8e55Smrg	# the entirety of a libtool archive into another (currently
106258c4a8e55Smrg	# not supported by libtool).
106268c4a8e55Smrg	if (for obj in $oldobjs
106278c4a8e55Smrg	    do
106288c4a8e55Smrg	      func_basename "$obj"
106298c4a8e55Smrg	      $ECHO "$func_basename_result"
106308c4a8e55Smrg	    done | sort | sort -uc >/dev/null 2>&1); then
106318c4a8e55Smrg	  :
106328c4a8e55Smrg	else
10633706b6b52Smrg	  echo "copying selected object files to avoid basename conflicts..."
106343169be4bSmrg	  gentop=$output_objdir/${outputname}x
10635bd23fbfaSmrg	  func_append generated " $gentop"
106368c4a8e55Smrg	  func_mkdir_p "$gentop"
106378c4a8e55Smrg	  save_oldobjs=$oldobjs
106388c4a8e55Smrg	  oldobjs=
106398c4a8e55Smrg	  counter=1
106408c4a8e55Smrg	  for obj in $save_oldobjs
106418c4a8e55Smrg	  do
106428c4a8e55Smrg	    func_basename "$obj"
106433169be4bSmrg	    objbase=$func_basename_result
106448c4a8e55Smrg	    case " $oldobjs " in
106458c4a8e55Smrg	    " ") oldobjs=$obj ;;
106468c4a8e55Smrg	    *[\ /]"$objbase "*)
106478c4a8e55Smrg	      while :; do
106488c4a8e55Smrg		# Make sure we don't pick an alternate name that also
106498c4a8e55Smrg		# overlaps.
106508c4a8e55Smrg		newobj=lt$counter-$objbase
106518c4a8e55Smrg		func_arith $counter + 1
106528c4a8e55Smrg		counter=$func_arith_result
106538c4a8e55Smrg		case " $oldobjs " in
106548c4a8e55Smrg		*[\ /]"$newobj "*) ;;
106558c4a8e55Smrg		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
106568c4a8e55Smrg		esac
106578c4a8e55Smrg	      done
106588c4a8e55Smrg	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
10659bd23fbfaSmrg	      func_append oldobjs " $gentop/$newobj"
106608c4a8e55Smrg	      ;;
10661bd23fbfaSmrg	    *) func_append oldobjs " $obj" ;;
106628c4a8e55Smrg	    esac
10663b042e37fSmrg	  done
10664b042e37fSmrg	fi
106650597fb56Smrg	func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
106660597fb56Smrg	tool_oldlib=$func_to_tool_file_result
106678c4a8e55Smrg	eval cmds=\"$old_archive_cmds\"
10668b042e37fSmrg
106698c4a8e55Smrg	func_len " $cmds"
106708c4a8e55Smrg	len=$func_len_result
106718c4a8e55Smrg	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
106728c4a8e55Smrg	  cmds=$old_archive_cmds
10673bd23fbfaSmrg	elif test -n "$archiver_list_spec"; then
10674bd23fbfaSmrg	  func_verbose "using command file archive linking..."
10675bd23fbfaSmrg	  for obj in $oldobjs
10676bd23fbfaSmrg	  do
10677bd23fbfaSmrg	    func_to_tool_file "$obj"
10678bd23fbfaSmrg	    $ECHO "$func_to_tool_file_result"
10679bd23fbfaSmrg	  done > $output_objdir/$libname.libcmd
10680bd23fbfaSmrg	  func_to_tool_file "$output_objdir/$libname.libcmd"
10681bd23fbfaSmrg	  oldobjs=" $archiver_list_spec$func_to_tool_file_result"
10682bd23fbfaSmrg	  cmds=$old_archive_cmds
106838c4a8e55Smrg	else
106848c4a8e55Smrg	  # the command line is too long to link in one step, link in parts
106858c4a8e55Smrg	  func_verbose "using piecewise archive linking..."
106868c4a8e55Smrg	  save_RANLIB=$RANLIB
106878c4a8e55Smrg	  RANLIB=:
106888c4a8e55Smrg	  objlist=
106898c4a8e55Smrg	  concat_cmds=
106908c4a8e55Smrg	  save_oldobjs=$oldobjs
106918c4a8e55Smrg	  oldobjs=
106928c4a8e55Smrg	  # Is there a better way of finding the last object in the list?
106938c4a8e55Smrg	  for obj in $save_oldobjs
106948c4a8e55Smrg	  do
106958c4a8e55Smrg	    last_oldobj=$obj
106968c4a8e55Smrg	  done
106978c4a8e55Smrg	  eval test_cmds=\"$old_archive_cmds\"
106988c4a8e55Smrg	  func_len " $test_cmds"
106998c4a8e55Smrg	  len0=$func_len_result
107008c4a8e55Smrg	  len=$len0
107018c4a8e55Smrg	  for obj in $save_oldobjs
107028c4a8e55Smrg	  do
107038c4a8e55Smrg	    func_len " $obj"
107048c4a8e55Smrg	    func_arith $len + $func_len_result
107058c4a8e55Smrg	    len=$func_arith_result
107068c4a8e55Smrg	    func_append objlist " $obj"
107078c4a8e55Smrg	    if test "$len" -lt "$max_cmd_len"; then
107088c4a8e55Smrg	      :
107098c4a8e55Smrg	    else
107108c4a8e55Smrg	      # the above command should be used before it gets too long
107118c4a8e55Smrg	      oldobjs=$objlist
107123169be4bSmrg	      if test "$obj" = "$last_oldobj"; then
107138c4a8e55Smrg		RANLIB=$save_RANLIB
107148c4a8e55Smrg	      fi
107158c4a8e55Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
107163169be4bSmrg	      eval concat_cmds=\"\$concat_cmds$old_archive_cmds\"
107178c4a8e55Smrg	      objlist=
107188c4a8e55Smrg	      len=$len0
107198c4a8e55Smrg	    fi
107208c4a8e55Smrg	  done
107218c4a8e55Smrg	  RANLIB=$save_RANLIB
107228c4a8e55Smrg	  oldobjs=$objlist
107233169be4bSmrg	  if test -z "$oldobjs"; then
107248c4a8e55Smrg	    eval cmds=\"\$concat_cmds\"
107258c4a8e55Smrg	  else
107268c4a8e55Smrg	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
107278c4a8e55Smrg	  fi
107288c4a8e55Smrg	fi
107298c4a8e55Smrg      fi
107308c4a8e55Smrg      func_execute_cmds "$cmds" 'exit $?'
10731b042e37fSmrg    done
10732b042e37fSmrg
107338c4a8e55Smrg    test -n "$generated" && \
107348c4a8e55Smrg      func_show_eval "${RM}r$generated"
10735b042e37fSmrg
107368c4a8e55Smrg    # Now create the libtool archive.
107378c4a8e55Smrg    case $output in
107388c4a8e55Smrg    *.la)
107398c4a8e55Smrg      old_library=
107403169be4bSmrg      test yes = "$build_old_libs" && old_library=$libname.$libext
107418c4a8e55Smrg      func_verbose "creating $output"
10742b042e37fSmrg
107438c4a8e55Smrg      # Preserve any variables that may affect compiler behavior
107448c4a8e55Smrg      for var in $variables_saved_for_relink; do
107458c4a8e55Smrg	if eval test -z \"\${$var+set}\"; then
107468c4a8e55Smrg	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
107478c4a8e55Smrg	elif eval var_value=\$$var; test -z "$var_value"; then
107488c4a8e55Smrg	  relink_command="$var=; export $var; $relink_command"
10749b042e37fSmrg	else
107508c4a8e55Smrg	  func_quote_for_eval "$var_value"
107518c4a8e55Smrg	  relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
10752b042e37fSmrg	fi
107538c4a8e55Smrg      done
107548c4a8e55Smrg      # Quote the link command for shipping.
107553169be4bSmrg      relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
10756706b6b52Smrg      relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
107573169be4bSmrg      if test yes = "$hardcode_automatic"; then
107588c4a8e55Smrg	relink_command=
107598c4a8e55Smrg      fi
10760b042e37fSmrg
107618c4a8e55Smrg      # Only create the output if not a dry run.
107628c4a8e55Smrg      $opt_dry_run || {
107638c4a8e55Smrg	for installed in no yes; do
107643169be4bSmrg	  if test yes = "$installed"; then
107658c4a8e55Smrg	    if test -z "$install_libdir"; then
107668c4a8e55Smrg	      break
107678c4a8e55Smrg	    fi
107683169be4bSmrg	    output=$output_objdir/${outputname}i
107698c4a8e55Smrg	    # Replace all uninstalled libtool libraries with the installed ones
107708c4a8e55Smrg	    newdependency_libs=
107718c4a8e55Smrg	    for deplib in $dependency_libs; do
107728c4a8e55Smrg	      case $deplib in
107738c4a8e55Smrg	      *.la)
107748c4a8e55Smrg		func_basename "$deplib"
107753169be4bSmrg		name=$func_basename_result
107760597fb56Smrg		func_resolve_sysroot "$deplib"
107773169be4bSmrg		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
107788c4a8e55Smrg		test -z "$libdir" && \
107793169be4bSmrg		  func_fatal_error "'$deplib' is not a valid libtool archive"
10780bd23fbfaSmrg		func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
10781bd23fbfaSmrg		;;
10782bd23fbfaSmrg	      -L*)
10783bd23fbfaSmrg		func_stripname -L '' "$deplib"
10784bd23fbfaSmrg		func_replace_sysroot "$func_stripname_result"
10785bd23fbfaSmrg		func_append newdependency_libs " -L$func_replace_sysroot_result"
10786bd23fbfaSmrg		;;
10787bd23fbfaSmrg	      -R*)
10788bd23fbfaSmrg		func_stripname -R '' "$deplib"
10789bd23fbfaSmrg		func_replace_sysroot "$func_stripname_result"
10790bd23fbfaSmrg		func_append newdependency_libs " -R$func_replace_sysroot_result"
107918c4a8e55Smrg		;;
10792bd23fbfaSmrg	      *) func_append newdependency_libs " $deplib" ;;
107938c4a8e55Smrg	      esac
107948c4a8e55Smrg	    done
107953169be4bSmrg	    dependency_libs=$newdependency_libs
107968c4a8e55Smrg	    newdlfiles=
107978c4a8e55Smrg
107988c4a8e55Smrg	    for lib in $dlfiles; do
107998c4a8e55Smrg	      case $lib in
108008c4a8e55Smrg	      *.la)
108018c4a8e55Smrg	        func_basename "$lib"
108023169be4bSmrg		name=$func_basename_result
108033169be4bSmrg		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
108048c4a8e55Smrg		test -z "$libdir" && \
108053169be4bSmrg		  func_fatal_error "'$lib' is not a valid libtool archive"
10806bd23fbfaSmrg		func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
108078c4a8e55Smrg		;;
10808bd23fbfaSmrg	      *) func_append newdlfiles " $lib" ;;
108098c4a8e55Smrg	      esac
108108c4a8e55Smrg	    done
108113169be4bSmrg	    dlfiles=$newdlfiles
108128c4a8e55Smrg	    newdlprefiles=
108138c4a8e55Smrg	    for lib in $dlprefiles; do
108148c4a8e55Smrg	      case $lib in
108158c4a8e55Smrg	      *.la)
108168c4a8e55Smrg		# Only pass preopened files to the pseudo-archive (for
108178c4a8e55Smrg		# eventual linking with the app. that links it) if we
108188c4a8e55Smrg		# didn't already link the preopened objects directly into
108198c4a8e55Smrg		# the library:
108208c4a8e55Smrg		func_basename "$lib"
108213169be4bSmrg		name=$func_basename_result
108223169be4bSmrg		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
108238c4a8e55Smrg		test -z "$libdir" && \
108243169be4bSmrg		  func_fatal_error "'$lib' is not a valid libtool archive"
10825bd23fbfaSmrg		func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
108268c4a8e55Smrg		;;
108278c4a8e55Smrg	      esac
108288c4a8e55Smrg	    done
108293169be4bSmrg	    dlprefiles=$newdlprefiles
108308c4a8e55Smrg	  else
108318c4a8e55Smrg	    newdlfiles=
108328c4a8e55Smrg	    for lib in $dlfiles; do
108338c4a8e55Smrg	      case $lib in
108343169be4bSmrg		[\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
108358c4a8e55Smrg		*) abs=`pwd`"/$lib" ;;
108368c4a8e55Smrg	      esac
10837bd23fbfaSmrg	      func_append newdlfiles " $abs"
108388c4a8e55Smrg	    done
108393169be4bSmrg	    dlfiles=$newdlfiles
108408c4a8e55Smrg	    newdlprefiles=
108418c4a8e55Smrg	    for lib in $dlprefiles; do
108428c4a8e55Smrg	      case $lib in
108433169be4bSmrg		[\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
108448c4a8e55Smrg		*) abs=`pwd`"/$lib" ;;
108458c4a8e55Smrg	      esac
10846bd23fbfaSmrg	      func_append newdlprefiles " $abs"
108478c4a8e55Smrg	    done
108483169be4bSmrg	    dlprefiles=$newdlprefiles
108498c4a8e55Smrg	  fi
108508c4a8e55Smrg	  $RM $output
108518c4a8e55Smrg	  # place dlname in correct position for cygwin
10852706b6b52Smrg	  # In fact, it would be nice if we could use this code for all target
10853706b6b52Smrg	  # systems that can't hard-code library paths into their executables
10854706b6b52Smrg	  # and that have no shared library path variable independent of PATH,
10855706b6b52Smrg	  # but it turns out we can't easily determine that from inspecting
10856706b6b52Smrg	  # libtool variables, so we have to hard-code the OSs to which it
10857706b6b52Smrg	  # applies here; at the moment, that means platforms that use the PE
10858706b6b52Smrg	  # object format with DLL files.  See the long comment at the top of
10859706b6b52Smrg	  # tests/bindir.at for full details.
108608c4a8e55Smrg	  tdlname=$dlname
108618c4a8e55Smrg	  case $host,$output,$installed,$module,$dlname in
10862706b6b52Smrg	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
10863706b6b52Smrg	      # If a -bindir argument was supplied, place the dll there.
108643169be4bSmrg	      if test -n "$bindir"; then
10865706b6b52Smrg		func_relative_path "$install_libdir" "$bindir"
108663169be4bSmrg		tdlname=$func_relative_path_result/$dlname
10867706b6b52Smrg	      else
10868706b6b52Smrg		# Otherwise fall back on heuristic.
10869706b6b52Smrg		tdlname=../bin/$dlname
10870706b6b52Smrg	      fi
10871706b6b52Smrg	      ;;
108728c4a8e55Smrg	  esac
108738c4a8e55Smrg	  $ECHO > $output "\
108748c4a8e55Smrg# $outputname - a libtool library file
108753169be4bSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
108768c4a8e55Smrg#
108778c4a8e55Smrg# Please DO NOT delete this file!
108788c4a8e55Smrg# It is necessary for linking the library.
10879b042e37fSmrg
108808c4a8e55Smrg# The name that we can dlopen(3).
108818c4a8e55Smrgdlname='$tdlname'
10882b042e37fSmrg
108838c4a8e55Smrg# Names of this library.
108848c4a8e55Smrglibrary_names='$library_names'
10885b042e37fSmrg
108868c4a8e55Smrg# The name of the static archive.
108878c4a8e55Smrgold_library='$old_library'
10888b042e37fSmrg
108893169be4bSmrg# Linker flags that cannot go in dependency_libs.
108908c4a8e55Smrginherited_linker_flags='$new_inherited_linker_flags'
10891b042e37fSmrg
108928c4a8e55Smrg# Libraries that this one depends upon.
108938c4a8e55Smrgdependency_libs='$dependency_libs'
10894b042e37fSmrg
108958c4a8e55Smrg# Names of additional weak libraries provided by this library
108968c4a8e55Smrgweak_library_names='$weak_libs'
10897b042e37fSmrg
108988c4a8e55Smrg# Version information for $libname.
108998c4a8e55Smrgcurrent=$current
109008c4a8e55Smrgage=$age
109018c4a8e55Smrgrevision=$revision
10902b042e37fSmrg
109038c4a8e55Smrg# Is this an already installed library?
109048c4a8e55Smrginstalled=$installed
10905b042e37fSmrg
109068c4a8e55Smrg# Should we warn about portability when linking against -modules?
109078c4a8e55Smrgshouldnotlink=$module
10908b042e37fSmrg
109098c4a8e55Smrg# Files to dlopen/dlpreopen
109108c4a8e55Smrgdlopen='$dlfiles'
109118c4a8e55Smrgdlpreopen='$dlprefiles'
10912b042e37fSmrg
109138c4a8e55Smrg# Directory that this library needs to be installed in:
109148c4a8e55Smrglibdir='$install_libdir'"
109153169be4bSmrg	  if test no,yes = "$installed,$need_relink"; then
109168c4a8e55Smrg	    $ECHO >> $output "\
109178c4a8e55Smrgrelink_command=\"$relink_command\""
109188c4a8e55Smrg	  fi
109198c4a8e55Smrg	done
109208c4a8e55Smrg      }
10921b042e37fSmrg
109228c4a8e55Smrg      # Do a symbolic link so that the libtool archive can be found in
109238c4a8e55Smrg      # LD_LIBRARY_PATH before the program is installed.
109248c4a8e55Smrg      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
109258c4a8e55Smrg      ;;
109268c4a8e55Smrg    esac
109278c4a8e55Smrg    exit $EXIT_SUCCESS
109288c4a8e55Smrg}
10929b042e37fSmrg
109303169be4bSmrgif test link = "$opt_mode" || test relink = "$opt_mode"; then
109313169be4bSmrg  func_mode_link ${1+"$@"}
109323169be4bSmrgfi
10933b042e37fSmrg
10934b042e37fSmrg
109358c4a8e55Smrg# func_mode_uninstall arg...
109368c4a8e55Smrgfunc_mode_uninstall ()
109378c4a8e55Smrg{
109383169be4bSmrg    $debug_cmd
109393169be4bSmrg
109403169be4bSmrg    RM=$nonopt
10941b042e37fSmrg    files=
109423169be4bSmrg    rmforce=false
10943b042e37fSmrg    exit_status=0
10944b042e37fSmrg
10945b042e37fSmrg    # This variable tells wrapper scripts just to set variables rather
10946b042e37fSmrg    # than running their programs.
109473169be4bSmrg    libtool_install_magic=$magic
10948b042e37fSmrg
10949b042e37fSmrg    for arg
10950b042e37fSmrg    do
10951b042e37fSmrg      case $arg in
109523169be4bSmrg      -f) func_append RM " $arg"; rmforce=: ;;
10953bd23fbfaSmrg      -*) func_append RM " $arg" ;;
10954bd23fbfaSmrg      *) func_append files " $arg" ;;
10955b042e37fSmrg      esac
10956b042e37fSmrg    done
10957b042e37fSmrg
109588c4a8e55Smrg    test -z "$RM" && \
109598c4a8e55Smrg      func_fatal_help "you must specify an RM program"
10960b042e37fSmrg
10961b042e37fSmrg    rmdirs=
10962b042e37fSmrg
10963b042e37fSmrg    for file in $files; do
109648c4a8e55Smrg      func_dirname "$file" "" "."
109653169be4bSmrg      dir=$func_dirname_result
109663169be4bSmrg      if test . = "$dir"; then
109673169be4bSmrg	odir=$objdir
10968b042e37fSmrg      else
109693169be4bSmrg	odir=$dir/$objdir
10970b042e37fSmrg      fi
109718c4a8e55Smrg      func_basename "$file"
109723169be4bSmrg      name=$func_basename_result
109733169be4bSmrg      test uninstall = "$opt_mode" && odir=$dir
10974b042e37fSmrg
10975bd23fbfaSmrg      # Remember odir for removal later, being careful to avoid duplicates
109763169be4bSmrg      if test clean = "$opt_mode"; then
10977b042e37fSmrg	case " $rmdirs " in
10978bd23fbfaSmrg	  *" $odir "*) ;;
10979bd23fbfaSmrg	  *) func_append rmdirs " $odir" ;;
10980b042e37fSmrg	esac
10981b042e37fSmrg      fi
10982b042e37fSmrg
10983b042e37fSmrg      # Don't error if the file doesn't exist and rm -f was used.
109848c4a8e55Smrg      if { test -L "$file"; } >/dev/null 2>&1 ||
109858c4a8e55Smrg	 { test -h "$file"; } >/dev/null 2>&1 ||
109868c4a8e55Smrg	 test -f "$file"; then
10987b042e37fSmrg	:
10988b042e37fSmrg      elif test -d "$file"; then
10989b042e37fSmrg	exit_status=1
10990b042e37fSmrg	continue
109913169be4bSmrg      elif $rmforce; then
10992b042e37fSmrg	continue
10993b042e37fSmrg      fi
10994b042e37fSmrg
109953169be4bSmrg      rmfiles=$file
10996b042e37fSmrg
10997b042e37fSmrg      case $name in
10998b042e37fSmrg      *.la)
10999b042e37fSmrg	# Possibly a libtool archive, so verify it.
110008c4a8e55Smrg	if func_lalib_p "$file"; then
110018c4a8e55Smrg	  func_source $dir/$name
11002b042e37fSmrg
11003b042e37fSmrg	  # Delete the libtool libraries and symlinks.
11004b042e37fSmrg	  for n in $library_names; do
11005bd23fbfaSmrg	    func_append rmfiles " $odir/$n"
11006b042e37fSmrg	  done
11007bd23fbfaSmrg	  test -n "$old_library" && func_append rmfiles " $odir/$old_library"
11008b042e37fSmrg
110093169be4bSmrg	  case $opt_mode in
11010b042e37fSmrg	  clean)
11011bd23fbfaSmrg	    case " $library_names " in
11012b042e37fSmrg	    *" $dlname "*) ;;
11013bd23fbfaSmrg	    *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
11014b042e37fSmrg	    esac
11015bd23fbfaSmrg	    test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
11016b042e37fSmrg	    ;;
11017b042e37fSmrg	  uninstall)
11018b042e37fSmrg	    if test -n "$library_names"; then
11019b042e37fSmrg	      # Do each command in the postuninstall commands.
110203169be4bSmrg	      func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1'
11021b042e37fSmrg	    fi
11022b042e37fSmrg
11023b042e37fSmrg	    if test -n "$old_library"; then
11024b042e37fSmrg	      # Do each command in the old_postuninstall commands.
110253169be4bSmrg	      func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1'
11026b042e37fSmrg	    fi
11027b042e37fSmrg	    # FIXME: should reinstall the best remaining shared library.
11028b042e37fSmrg	    ;;
11029b042e37fSmrg	  esac
11030b042e37fSmrg	fi
11031b042e37fSmrg	;;
11032b042e37fSmrg
11033b042e37fSmrg      *.lo)
11034b042e37fSmrg	# Possibly a libtool object, so verify it.
110358c4a8e55Smrg	if func_lalib_p "$file"; then
11036b042e37fSmrg
11037b042e37fSmrg	  # Read the .lo file
110388c4a8e55Smrg	  func_source $dir/$name
11039b042e37fSmrg
11040b042e37fSmrg	  # Add PIC object to the list of files to remove.
110413169be4bSmrg	  if test -n "$pic_object" && test none != "$pic_object"; then
11042bd23fbfaSmrg	    func_append rmfiles " $dir/$pic_object"
11043b042e37fSmrg	  fi
11044b042e37fSmrg
11045b042e37fSmrg	  # Add non-PIC object to the list of files to remove.
110463169be4bSmrg	  if test -n "$non_pic_object" && test none != "$non_pic_object"; then
11047bd23fbfaSmrg	    func_append rmfiles " $dir/$non_pic_object"
11048b042e37fSmrg	  fi
11049b042e37fSmrg	fi
11050b042e37fSmrg	;;
11051b042e37fSmrg
11052b042e37fSmrg      *)
110533169be4bSmrg	if test clean = "$opt_mode"; then
11054b042e37fSmrg	  noexename=$name
11055b042e37fSmrg	  case $file in
11056b042e37fSmrg	  *.exe)
110578c4a8e55Smrg	    func_stripname '' '.exe' "$file"
110588c4a8e55Smrg	    file=$func_stripname_result
110598c4a8e55Smrg	    func_stripname '' '.exe' "$name"
110608c4a8e55Smrg	    noexename=$func_stripname_result
11061b042e37fSmrg	    # $file with .exe has already been added to rmfiles,
11062b042e37fSmrg	    # add $file without .exe
11063bd23fbfaSmrg	    func_append rmfiles " $file"
11064b042e37fSmrg	    ;;
11065b042e37fSmrg	  esac
11066b042e37fSmrg	  # Do a test to see if this is a libtool program.
110678c4a8e55Smrg	  if func_ltwrapper_p "$file"; then
110688c4a8e55Smrg	    if func_ltwrapper_executable_p "$file"; then
110698c4a8e55Smrg	      func_ltwrapper_scriptname "$file"
110708c4a8e55Smrg	      relink_command=
110718c4a8e55Smrg	      func_source $func_ltwrapper_scriptname_result
11072bd23fbfaSmrg	      func_append rmfiles " $func_ltwrapper_scriptname_result"
110738c4a8e55Smrg	    else
110748c4a8e55Smrg	      relink_command=
110758c4a8e55Smrg	      func_source $dir/$noexename
110768c4a8e55Smrg	    fi
11077b042e37fSmrg
11078b042e37fSmrg	    # note $name still contains .exe if it was in $file originally
11079b042e37fSmrg	    # as does the version of $file that was added into $rmfiles
110803169be4bSmrg	    func_append rmfiles " $odir/$name $odir/${name}S.$objext"
110813169be4bSmrg	    if test yes = "$fast_install" && test -n "$relink_command"; then
11082bd23fbfaSmrg	      func_append rmfiles " $odir/lt-$name"
11083b042e37fSmrg	    fi
110843169be4bSmrg	    if test "X$noexename" != "X$name"; then
110853169be4bSmrg	      func_append rmfiles " $odir/lt-$noexename.c"
11086b042e37fSmrg	    fi
11087b042e37fSmrg	  fi
11088b042e37fSmrg	fi
11089b042e37fSmrg	;;
11090b042e37fSmrg      esac
110918c4a8e55Smrg      func_show_eval "$RM $rmfiles" 'exit_status=1'
11092b042e37fSmrg    done
11093b042e37fSmrg
110943169be4bSmrg    # Try to remove the $objdir's in the directories where we deleted files
11095b042e37fSmrg    for dir in $rmdirs; do
11096b042e37fSmrg      if test -d "$dir"; then
110978c4a8e55Smrg	func_show_eval "rmdir $dir >/dev/null 2>&1"
11098b042e37fSmrg      fi
11099b042e37fSmrg    done
11100b042e37fSmrg
11101b042e37fSmrg    exit $exit_status
111028c4a8e55Smrg}
11103b042e37fSmrg
111043169be4bSmrgif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then
111053169be4bSmrg  func_mode_uninstall ${1+"$@"}
111063169be4bSmrgfi
11107b042e37fSmrg
11108bd23fbfaSmrgtest -z "$opt_mode" && {
111093169be4bSmrg  help=$generic_help
111108c4a8e55Smrg  func_fatal_help "you must specify a MODE"
111118c4a8e55Smrg}
111128c4a8e55Smrg
111138c4a8e55Smrgtest -z "$exec_cmd" && \
111143169be4bSmrg  func_fatal_help "invalid operation mode '$opt_mode'"
11115b042e37fSmrg
11116b042e37fSmrgif test -n "$exec_cmd"; then
111178c4a8e55Smrg  eval exec "$exec_cmd"
11118b042e37fSmrg  exit $EXIT_FAILURE
11119b042e37fSmrgfi
11120b042e37fSmrg
111218c4a8e55Smrgexit $exit_status
11122b042e37fSmrg
11123b042e37fSmrg
11124b042e37fSmrg# The TAGs below are defined such that we never get into a situation
111253169be4bSmrg# where we disable both kinds of libraries.  Given conflicting
11126b042e37fSmrg# choices, we go for a static library, that is the most portable,
11127b042e37fSmrg# since we can't tell whether shared libraries were disabled because
11128b042e37fSmrg# the user asked for that or because the platform doesn't support
11129b042e37fSmrg# them.  This is particularly important on AIX, because we don't
11130b042e37fSmrg# support having both static and shared libraries enabled at the same
11131b042e37fSmrg# time on that platform, so we default to a shared-only configuration.
11132b042e37fSmrg# If a disable-shared tag is given, we'll fallback to a static-only
11133b042e37fSmrg# configuration.  But we'll never go from static-only to shared-only.
11134b042e37fSmrg
11135b042e37fSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
111368c4a8e55Smrgbuild_libtool_libs=no
111378c4a8e55Smrgbuild_old_libs=yes
11138b042e37fSmrg# ### END LIBTOOL TAG CONFIG: disable-shared
11139b042e37fSmrg
11140b042e37fSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static
111418c4a8e55Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
11142b042e37fSmrg# ### END LIBTOOL TAG CONFIG: disable-static
11143b042e37fSmrg
11144b042e37fSmrg# Local Variables:
11145b042e37fSmrg# mode:shell-script
11146b042e37fSmrg# sh-indentation:2
11147b042e37fSmrg# End:
11148